Repository navigation
feat: upgrade to Places SDK for Android 6.0.2 and migrate removed legacy APIs - #1092
Conversation
| val markerState = rememberPlaceMarkerState( | ||
| reference = PlaceReference.PlaceId(placeId), | ||
| icon = MarkerIcon.Type, | ||
| text = MarkerText.Rating | ||
| ) |
There was a problem hiding this comment.
Just to understand it: does rememberPlaceMarkerState key on the reference internally? If not, when the user selects a different place the state stays at the same call site and might keep showing the previous one. Should we wrap this in key(placeId) { ... } to be safe?
There was a problem hiding this comment.
Great question! rememberPlaceMarkerState does key on reference internally (remember(reference) { PlaceMarkerStateImpl(reference = reference, icon = icon, text = text) }, where PlaceReference.PlaceId implements structural equals/hashCode on the placeId).
However, wrapping the block in key(placeId) { ... } (and passing placeId into MarkerComposable keys) is even safer because it guarantees that both the PlaceMarkerState and the underlying MarkerComposable lifecycle reset cleanly when switching between places. Added key(placeId) in e44b50e!
| val fields = listOf(Place.Field.ID, Place.Field.DISPLAY_NAME, Place.Field.FORMATTED_ADDRESS) | ||
| val intent = Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY, fields) | ||
| .build(context) | ||
| val intent = PlaceAutocomplete.createIntent(context) |
There was a problem hiding this comment.
Here we use PlaceAutocomplete.createIntent(context), but the migration table below points to PlaceAutocomplete.IntentBuilder(). Could we use the same entry point in both places, so the skill doesn't mix two patterns?
There was a problem hiding this comment.
Good catch! Updated AutocompleteSearchButton in Section 7 to use PlaceAutocomplete.IntentBuilder().build(context) in e44b50e so it matches the migration table in Section 8 and the rest of the sample activities.
| | `Place.Field.TYPES` / `place.types` | `Place.Field.TYPES` (`place.placeTypes: List<String>`) or `Place.Field.PRIMARY_TYPE` (`place.primaryType`) | | ||
| | `Place.Field.PRICE_LEVEL` | `Place.Field.PRICE_LEVEL` or `Place.Field.PRICE_RANGE` (`place.priceRange`) | |
There was a problem hiding this comment.
nit: these two rows list Place.Field.TYPES and Place.Field.PRICE_LEVEL as both removed and the replacement, which reads a bit confusing. What about saying explicitly that the constant stays and only the getter changes (e.g. place.types -> place.placeTypes)?
There was a problem hiding this comment.
Done in e44b50e! Updated both rows to explicitly note that Place.Field.TYPES and Place.Field.PRICE_LEVEL constants remain unchanged, while place.types -> place.placeTypes: List<String> (or Place.Field.PRIMARY_TYPE / place.primaryType) and Place.Field.PRICE_RANGE (place.priceRange) is available for min/max price ranges.
73808c3 to
bb325d1
Compare
Summary
Upgrades$\rightarrow$ 6.0.x+ migration guide.
com.google.android.libraries.places:placesfrom5.3.0to6.0.2across all demo and snippet modules, migrates removed Legacy Places APIs, showcases native 6.0.2 Jetpack Compose UI components, replaces reflection with@VisibleForTestingin unit tests, and updates theplaces-androidagent skill with a 4.x/5.xChanges Included
placesto6.0.2ingradle/libs.versions.tomlandsnippets/build.gradle.kts.5.3.06.0.2):Autocomplete,AutocompleteSupportFragment, andAutocompleteActivityModewithPlaceAutocompleteandBasicPlaceAutocompleteacross:demo-kotlin,:demo-java, and:snippets.FindCurrentPlaceRequestwithSearchNearbyRequest+CircularBoundsin:demo-javaand:snippets.FetchPhotoRequestwithFetchResolvedPhotoUriRequestin:demo-java.Places.initializewithPlaces.initializeWithNewPlacesApiEnabledin:snippets.Place.Fieldconstants (NAMEDISPLAY_NAME,ADDRESSFORMATTED_ADDRESS,LAT_LNGLOCATION).:PlaceDetailsCompose):PlaceDetailsView.kt,MapScreen.kt, andMapViewModel.ktto demonstrateAdvancedPlaceDetailsCompactcontent slots (basicSectionTop,basicSectionBottom) andPlaceMarker/rememberPlaceMarkerState.:demo-kotlin):@VisibleForTestingresult handlers (handleAutocompleteResultandhandleBasicAutocompleteResult) inPlaceAutocompleteActivity.ktand removed alljava.lang.reflect.Fieldusage inPlaceAutocompleteActivityTest.kt..gemini/skills/places-android/SKILL.md):Place.Fieldmapping tables and code examples, plus Section 5/7 coverage of 6.0.2 Compose and Autocomplete APIs.Verification
./gradlew assembleDebug testDebugUnitTestpasses across all modules.// [START ...]/// [END ...]region tags and file paths verified intact.