-
Notifications
You must be signed in to change notification settings - Fork 13
refactor: Modernize build, enhance demo app, and prepare for archival #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- 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.
| } | ||
|
|
||
| kotlinOptions { | ||
| jvmTarget = "1.8" |
There was a problem hiding this comment.
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?
|
We would need to mark this PR as fix to trigger a new build. |
app/src/main/java/com/google/maps/android/rx/demo/MainActivity.kt
Dismissed
Show dismissed
Hide dismissed
| 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
| 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
| 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
| 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
| 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
| @@ -0,0 +1,39 @@ | |||
| // Copyright 2021 Google LLC | |||
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous Java version.
kikoso
left a comment
There was a problem hiding this 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.
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:
compileSdk(36) andminSdkacross all modules using the version catalog.Demo App UI/UX Enhancements:
Breaking Change: Internalized Shared Code:
sharedmodule has been removed. Its utility classes (likeMainThreadObservable) have been copied directly into themaps-rxandplaces-rxmodules asinternalclasses.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.