Repository navigation
Conversation
Contributor
Code Coverage
Files
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a public
UnitsAPI (com.google.maps.android) to:libraryfor type-safe distance and elevation representation, framework-agnostic unit system resolution, and KMP-compatible logical precision formatting.Key Additions
METERS_PER_FOOT = 0.3048,FEET_PER_METER = 1.0 / METERS_PER_FOOT) and statute mile (FEET_PER_MILE = 5_280,METERS_PER_MILE = 1609.344,MILES_PER_METER) constants alongsideMETERS_PER_KILOMETER = 1_000.MetersInline Value Class:@JvmInline value class Meters(val value: Double) : Comparable<Meters>with+,-,*,/, unary-,Numberconstruction extensions (.meters/.m,.kilometers/.km,.feet/.ft,.miles/.mi), and scalar conversions (.toMeters,.toKilometers,.toFeet,.toMiles).UnitSystem&NumberFormatSymbols:UnitSystem.METRICandUnitSystem.IMPERIALwithfromLocale(locale = Locale.getDefault())andfromCountryCode(countryCode)defaulting"US","LR","MM", and"GB"toIMPERIALand all others toMETRIC.NumberFormatSymbolsfor KMP-friendly locale grouping and decimal separator resolution without relying onjava.util.Formatter(String.format).UnitsConverter,MetricUnitsConverter,ImperialUnitsConverter):fttomiat0.25miles (1,320feet) and frommtokmat1,000meters (1.0km).mbelow1 km,ftbelow0.25 mi, and all elevations) as whole integers (0decimals, with locale thousands grouping, e.g.,"450 m","528 ft","14,440 ft").0.25to< 10mi,1.0to< 10km) with1decimal digit, keeping the trailing.0(e.g.,"0.3 mi","1.0 km","2.0 km","2.5 mi").>= 10km or>= 10mi) as whole integers (0decimals, e.g.,"10 km","12 mi").Locale/NumberFormatSymbols) and AndroidResourcesformatting (amu_in_*), plusDoubleoverloads for Java callers.UnitsDemoActivity(Kotlin + Compose + GoogleMap) and updatedDistanceDemoActivity(Java).UnitsTestandUnitsDemoTest.Test Plan
./gradlew apiCheck spotlessCheck :library:testDebugUnitTest :demo:testStandardDebugUnitTest :library:lintDebugUnitsDemoActivityandDistanceDemoActivityon emulator (emulator-5554) and Pixel 6.