fix!: finalize library as 100% compatibility shim#306
Conversation
|
Just as a comment: this will trigger a 5.0.0 version. |
...rc/test/java/com/google/android/libraries/places/ktx/api/net/SearchNearbyPlaceRequestTest.kt
Outdated
Show resolved
Hide resolved
MIGRATION_GUIDE.md
Outdated
|
|
||
| While this library is now primarily a compatibility shim, it still provides a few minor Kotlin-specific conveniences not yet present in the core SDK: | ||
|
|
||
| 1. **DSL Builders**: Lightweight Kotlin DSL builders for models (e.g., `place { ... }`, `photoMetadata { ... }`). |
There was a problem hiding this comment.
There is Kotlin wrapper for models like Place and PhotoMetadata
MIGRATION_GUIDE.md
Outdated
|
|
||
| 1. **DSL Builders**: Lightweight Kotlin DSL builders for models (e.g., `place { ... }`, `photoMetadata { ... }`). | ||
| 2. **PriceLevel Enum**: A type-safe `PriceLevel` enum for `SearchByTextRequest` filtering. | ||
| 3. **SearchNearby Support**: Helper for `searchNearbyPlaceRequest` with a simplified API. |
There was a problem hiding this comment.
Kotlin wrapper for SearchNearbyRequest is provided.
We should call it SearchNearbyRequest (no 'place') to be consist with the name in SDK.
MIGRATION_GUIDE.md
Outdated
| The entire `AutocompleteSupportFragment.kt` file has been deleted. | ||
| - **Removed**: `AutocompleteSupportFragment.placeSelectionEvents()` | ||
| - **Removed**: `PlaceSelectionResult`, `PlaceSelectionSuccess`, and `PlaceSelectionError` classes. | ||
| - **Migration**: Use the official SDK's `AutocompleteSupportFragment` or migrate to the Compose-based patterns shown in the demo app. |
There was a problem hiding this comment.
The AutocompleteSupportFragment is deprecated. Use com.google.android.libraries.places.widget.PlaceAutocompleteActivity instead.
MIGRATION_GUIDE.md
Outdated
| | Old File | New File | API Maintained | | ||
| | :--- | :--- | :--- | | ||
| | `FetchPhotoRequest.kt` | `FetchResolvedPhotoUriRequest.kt` | `fetchResolvedPhotoUriRequest` | | ||
| | `FindCurrentPlaceRequest.kt` | `SearchNearbyRequest.kt` | `searchNearbyPlaceRequest` | |
There was a problem hiding this comment.
searchNearbyRequest instead of searchNearbyPlaceRequest to be consist with the name in the SDK
MIGRATION_GUIDE.md
Outdated
| | File | API | | ||
| | :--- | :--- | | ||
| | **`PlacesClient.kt`** | `awaitFetchPlace`, `awaitFetchResolvedPhotoUri`, `awaitFindAutocompletePredictions`, `awaitSearchNearby`, `awaitIsOpen`, `awaitSearchByText` | | ||
| | **DSL Builders** | `fetchPlaceRequest`, `findAutocompletePredictionsRequest`, `isOpenRequest`, `searchByTextRequest` | |
There was a problem hiding this comment.
Should we also list the newly added fetchResolvedPhotoUriRequest and searchNearbyRequest here?
yuhan1212
left a comment
There was a problem hiding this comment.
I reviewed those files related to Places SDK usage.
There was a problem hiding this comment.
Can this also import and use the kotlin wrapper from SDK?
There was a problem hiding this comment.
Nope. Unfortunately, it causes the Kotlin compiler to crash. Not worth fixing for a library that is going to be archived.
public fun openingHours(actions: OpeningHours.Builder.() -> Unit): OpeningHours {
return com.google.android.libraries.places.api.model.kotlin.openingHours(actions)
}
results in this crash from the compiler
java.lang.RuntimeException: Exception while generating code for:
FUN name:openingHours visibility:public modality:FINAL returnType:com.google.android.libraries.places.api.model.OpeningHours
VALUE_PARAMETER kind:Regular name:actions index:0 type:@[ExtensionFunctionType] kotlin.Function1<com.google.android.libraries.places.api.model.OpeningHours.Builder, kotlin.Unit>
annotations:
Deprecated(message = "Use the version in the Places SDK instead.", replaceWith = ReplaceWith(expression = "openingHours(actions)", imports = ["com.google.android.libraries.places.api.model.kotlin.openingHours"] type=kotlin.Array<out kotlin.String> varargElementType=kotlin.String), level = <null>)
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun openingHours (actions: @[ExtensionFunctionType] kotlin.Function1<com.google.android.libraries.places.api.model.OpeningHours.Builder, kotlin.Unit>): com.google.android.libraries.places.api.model.OpeningHours declared in com.google.android.libraries.places.ktx.api.model.OpeningHoursKt'
CALL 'public final fun openingHours (actions: @[ExtensionFunctionType] kotlin.Function1<com.google.android.libraries.places.api.model.OpeningHours.Builder, kotlin.Unit>): com.google.android.libraries.places.api.model.OpeningHours [inline] declared in com.google.android.libraries.places.api.model.kotlin.OpeningHoursKt' type=com.google.android.libraries.places.api.model.OpeningHours origin=null
ARG actions: GET_VAR 'actions: @[ExtensionFunctionType] kotlin.Function1<com.google.android.libraries.places.api.model.OpeningHours.Builder, kotlin.Unit> declared in com.google.android.libraries.places.ktx.api.model.OpeningHoursKt.openingHours' type=@[ExtensionFunctionType] kotlin.Function1<com.google.android.libraries.places.api.model.OpeningHours.Builder, kotlin.Unit> origin=null
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:43)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethodNode(ClassCodegen.kt:422)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethod(ClassCodegen.kt:439)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generate(ClassCodegen.kt:164)
There was a problem hiding this comment.
Can this also import and use the kotlin wrapper from SDK?
There was a problem hiding this comment.
Same problem with the compiler crash
There was a problem hiding this comment.
Can this also import and use the kotlin wrapper from SDK?
There was a problem hiding this comment.
Same problem with the compiler crash
There was a problem hiding this comment.
This imports sdkPlusCode but it doesn't use it.
There was a problem hiding this comment.
Same problem with the compiler crash
(But I missed the extra import. Thanks!)
There was a problem hiding this comment.
Do you want to make it consist to import it as sdkFindAutocompletePredictionsRequest as other files do?
| @@ -1,4 +1,4 @@ | |||
| // Copyright 2026 Google LLC | |||
| // Copyright 2020 Google LLC | |||
There was a problem hiding this comment.
Yes. The date was accidently updated in the previous commit
| actions: SearchByTextRequest.Builder.() -> Unit = {}, | ||
| ): SearchByTextRequest { | ||
| return sdkSearchByTextRequest(textQuery, placeFields, actions) | ||
| return com.google.android.libraries.places.api.net.kotlin.searchByTextRequest(textQuery, placeFields, actions) |
There was a problem hiding this comment.
Can we import it as sdkSearchByTextRequest as how other files do?
- Standardize on the 'sdk*' naming convention for official SDK Kotlin delegation imports. - Update FindAutocompletePredictionsRequest and SearchByTextRequest to use explicit delegation aliases. - Remove redundant 'sdkPlusCode' alias in PlusCode.kt and cleanup imports.
This PR completes the transformation of the library into a 100% compatibility shim.
Key Changes: