Skip to content

fix!: finalize library as 100% compatibility shim#306

Open
dkhawk wants to merge 21 commits intomainfrom
fix/address-more-deprecations
Open

fix!: finalize library as 100% compatibility shim#306
dkhawk wants to merge 21 commits intomainfrom
fix/address-more-deprecations

Conversation

@dkhawk
Copy link
Contributor

@dkhawk dkhawk commented Feb 27, 2026

This PR completes the transformation of the library into a 100% compatibility shim.

Key Changes:

  • API Realignment: Moved APIs to match official SDK conventions (e.g., , ).
  • Complete Deprecation: All remaining custom KTX APIs are now and delegate to the core SDK (including and model builders).
  • Build Stabilization: Reverted IR-crashing shims to manual Builder calls to ensure build stability while maintaining the deprecation interface.
  • Modernized Demo App: Added a comprehensive, modernized Places Photo demo using Compose, Material 3, and Hilt, with extensive pedagogical documentation.
  • Migration Guide: Created and refined with explicit instructions and examples for removing the KTX dependency.

@dkhawk dkhawk requested review from kikoso and yuhan1212 February 27, 2026 16:10
@dkhawk dkhawk marked this pull request as draft February 27, 2026 16:13
@dkhawk dkhawk changed the title refactor!: remove redundant and deprecated request wrappers fix!: remove redundant and deprecated request wrappers Feb 27, 2026
@kikoso
Copy link
Collaborator

kikoso commented Feb 27, 2026

Just as a comment: this will trigger a 5.0.0 version.


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 { ... }`).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin wrapper for SearchNearbyRequest is provided.

https://developers.google.com/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/kotlin/SearchNearbyRequestKt

We should call it SearchNearbyRequest (no 'place') to be consist with the name in SDK.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| Old File | New File | API Maintained |
| :--- | :--- | :--- |
| `FetchPhotoRequest.kt` | `FetchResolvedPhotoUriRequest.kt` | `fetchResolvedPhotoUriRequest` |
| `FindCurrentPlaceRequest.kt` | `SearchNearbyRequest.kt` | `searchNearbyPlaceRequest` |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchNearbyRequest instead of searchNearbyPlaceRequest to be consist with the name in the SDK

| File | API |
| :--- | :--- |
| **`PlacesClient.kt`** | `awaitFetchPlace`, `awaitFetchResolvedPhotoUri`, `awaitFindAutocompletePredictions`, `awaitSearchNearby`, `awaitIsOpen`, `awaitSearchByText` |
| **DSL Builders** | `fetchPlaceRequest`, `findAutocompletePredictionsRequest`, `isOpenRequest`, `searchByTextRequest` |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also list the newly added fetchResolvedPhotoUriRequest and searchNearbyRequest here?

@dkhawk dkhawk changed the title fix!: remove redundant and deprecated request wrappers fix!: finalize library as 100% compatibility shim Feb 27, 2026
@dkhawk dkhawk marked this pull request as ready for review February 27, 2026 20:01
@dkhawk dkhawk requested a review from yuhan1212 February 27, 2026 21:55
Copy link
Collaborator

@yuhan1212 yuhan1212 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed those files related to Places SDK usage.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this also import and use the kotlin wrapper from SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this also import and use the kotlin wrapper from SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem with the compiler crash

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this also import and use the kotlin wrapper from SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem with the compiler crash

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This imports sdkPlusCode but it doesn't use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem with the compiler crash

(But I missed the extra import. Thanks!)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we import it as sdkSearchByTextRequest as how other files do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- 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.
@dkhawk dkhawk requested a review from yuhan1212 February 28, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants