Skip to content

Conversation

@dkhawk
Copy link
Contributor

@dkhawk dkhawk commented Dec 22, 2025

This pull request introduces a series of significant updates to modernize the project, improve the demo application, and streamline the library structure in preparation for archiving.

Key Changes:

  • Build Modernization:

    • Upgraded Gradle to 8.13.2 and Kotlin to 2.3.0.
    • Standardized compileSdk (36) and minSdk across all modules using the version catalog.
    • Resolved various build deprecation warnings.
    • Added a basic testing infrastructure with dependencies for JUnit, Mockito, and Mockk.
  • Demo App UI/UX Enhancements:

    • Implemented a sticky immersive, edge-to-edge display for a more modern user experience.
    • Added UI components to demonstrate "Find Current Place" and "Fetch Photo" functionality from the Places SDK.
  • Breaking Change: Internalized Shared Code:

    • The shared module has been removed. Its utility classes (like MainThreadObservable) have been copied directly into the maps-rx and places-rx modules as internal classes.
    • Reasoning: This eliminates the need for a separate Maven artifact for the shared code, simplifying the dependency graph for consumers who might install the AARs manually. This structural change is a prerequisite for archiving the repository.

This prepares the repository for its final, archived state by ensuring the libraries are self-contained and the demo app is a robust example of their usage.

- Extract `compileSdk`, `minSdk`, `targetSdk` to version catalog and set `compileSdk`/`targetSdk` to 36.
- Fix build deprecations: replace `buildDir` with `layout.buildDirectory` and move `kotlinOptions` to `compilerOptions`.
- Update Kotlin to 2.3.0 and Gradle to 8.13.2.
- Switch app module to use local project dependencies (`:maps-rx`, `:places-rx`) instead of version catalog artifacts.
- Remove unused `ExampleInstrumentedTest`.
- Update .gitignore to exclude secrets.properties.
- Fix lint/deprecation warnings in MainActivity and PlacesRx
- Expand demo app with FindCurrentPlace and FetchPhoto UI
- Update build files to JDK 17
- Add testing dependencies (JUnit, Mockito, Mockk)
- Add initial (ignored) unit tests for maps-rx and places-rx
Removes the 'shared' module and duplicates its utility classes into 'maps-rx' and 'places-rx' as internal extensions.

This change eliminates the need for a separate 'shared' Maven artifact, allowing 'maps-rx' and 'places-rx' to be used as standalone libraries without complex transitive dependencies for manual AAR consumers. Code duplication was chosen over a shared artifact to simplify distribution as we prepare to archive these libraries.

Key changes:
- Deleted 'shared' module and updated settings.gradle.
- Copied MainThreadObservable and related utilities to 'com.google.maps.android.rx.maps.internal' and 'com.google.maps.android.rx.places.internal'.
- Updated all imports to use the local internal versions.
- Removed project dependency on ':shared' from build files.
- Marked all duplicated code as 'internal' to prevent binary compatibility issues or duplicate class definitions if both libraries are used together.

This refactoring streamlines the project structure in anticipation of archiving the repository.
@dkhawk dkhawk requested a review from kikoso December 22, 2025 21:24
}

kotlinOptions {
jvmTarget = "1.8"
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 keep the previous Java version, to avoid any issues?

@kikoso
Copy link
Collaborator

kikoso commented Dec 22, 2025

We would need to mark this PR as fix to trigger a new build.

Comment on lines +173 to +188
placesClient.findCurrentPlace(fields)
.compose(provider.bindToLifecycle())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ response ->
val place = response.placeLikelihoods.firstOrNull()?.place
place?.let {
val message = "You are at ${it.displayName} (ID: ${it.id})"
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
Log.d(TAG, message)
} ?: run {
Toast.makeText(this, "No place found", Toast.LENGTH_SHORT).show()
}
}, { error ->
Log.e(TAG, "Error finding place", error)
Toast.makeText(this, "Error: ${error.message}", Toast.LENGTH_SHORT).show()
})

Check warning

Code scanning / Android Lint

Ignoring results Warning

The result of subscribe is not used
Comment on lines +206 to +226
placesClient.findCurrentPlace(fields)
.flatMap { response ->
val photoMetadata = response.placeLikelihoods.firstOrNull()?.place?.photoMetadatas?.firstOrNull()
if (photoMetadata != null) {
placesClient.fetchPhoto(photoMetadata)
} else {
io.reactivex.rxjava3.core.Single.error(Exception("No photos found"))
}
}
.compose(provider.bindToLifecycle())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ response ->
val message = "Photo fetched! Size: ${response.bitmap.width}x${response.bitmap.height}"
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
Log.d(TAG, message)
// Ideally show the bitmap in a dialog
}, { error ->
val msg = "Error fetching photo: ${error.message}"
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
Log.e(TAG, msg)
})

Check warning

Code scanning / Android Lint

Ignoring results Warning

The result of subscribe is not used
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Current Place" />

Check warning

Code scanning / Android Lint

Hardcoded text Warning

Hardcoded string "Current Place", should use @string resource
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Fetch Photo" />

Check warning

Code scanning / Android Lint

Hardcoded text Warning

Hardcoded string "Fetch Photo", should use @string resource
jacoco-android = "0.2.1"
kotlin = "2.3.0"
lifecycleRuntimeKtx = "2.10.0"
mapsKtx = "5.2.1"

Check warning

Code scanning / Android Lint

Newer Library Versions Available Warning

A newer version of com.google.maps.android:maps-ktx than 5.2.1 is available: 5.2.2
@@ -0,0 +1,39 @@
// Copyright 2021 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.

What about renaming this module to places/internal? We need a different name to avoid conflicts with the maps-rx module.

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about keeping the previous Java version?

freeCompilerArgs += "-Xexplicit-api=strict"
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Previous Java version.

Copy link
Collaborator

@kikoso kikoso left a comment

Choose a reason for hiding this comment

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

Some minor comments, most specifically about keeping the previous Java version. This seems to work if packed as an aar.

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.

2 participants