feat(demo): Add StreetViewJavaHelper and demo and enable edge-to-edge#1595
Merged
feat(demo): Add StreetViewJavaHelper and demo and enable edge-to-edge#1595
Conversation
This commit adds a new demo activity written in Java to demonstrate the usage of the Street View utility. To facilitate this, a Kotlin helper has been introduced to bridge the gap between suspend functions and Java's callback-based asynchronous model. The key changes are: - **`StreetViewDemoActivityJava`**: A new demo activity that shows how to check for Street View availability from Java. - **`StreetViewHelper`**: A Kotlin object that wraps the `suspend` function `StreetViewUtils.fetchStreetViewData` and exposes it to Java consumers via a callback interface. - **`ApiKeyValidator`**: A new utility class to check for a valid Maps API key within the demo application. - **Unit Tests**: Added tests for `StreetViewHelper` using Robolectric, MockK, and coroutine testing libraries to verify its behavior. - **Dependencies**: Added `mockk`, `kotlinx-coroutines-test`, and `robolectric` to the demo module's test dependencies.
This commit refactors the `StreetViewDemoActivity` in both its Kotlin and Java versions to support edge-to-edge display. The key changes include: - Changing the base class from `Activity` to `AppCompatActivity`. - Using `WindowCompat.setDecorFitsSystemWindows` to allow the app to draw behind the system bars. - Adding an `OnApplyWindowInsetsListener` to the root view to apply padding for the system bars, preventing content from being obscured. - Updating the `street_view_demo.xml` layout with an ID for the root view to facilitate the insets listener. - Updating the copyright year.
Contributor
Code Coverage
|
Collaborator
|
Since this is not adding functionality to the library, should we keep the commit name as "docs" or "chore", to avoid triggering a new release? |
kikoso
reviewed
Sep 10, 2025
kikoso
reviewed
Sep 10, 2025
kikoso
reviewed
Sep 10, 2025
| /** | ||
| * An activity that demonstrates how to use the Street View utility in Java to check for Street View | ||
| * availability at different locations. | ||
| * |
Collaborator
There was a problem hiding this comment.
This line will be ignored when the Javadoc is generated. Suggestion:
Suggested change
| * | |
| * <p> |
kikoso
reviewed
Sep 10, 2025
kikoso
reviewed
Sep 10, 2025
Comment on lines
+100
to
+102
| runOnUiThread(() -> { | ||
| ((TextView) findViewById(R.id.textViewSecondLocation)).setText("Location 2 is supported in StreetView: " + status); | ||
| }); |
Collaborator
There was a problem hiding this comment.
nit: replace with expression lambda
Suggested change
| runOnUiThread(() -> { | |
| ((TextView) findViewById(R.id.textViewSecondLocation)).setText("Location 2 is supported in StreetView: " + status); | |
| }); | |
| runOnUiThread(() -> ((TextView) findViewById(R.id.textViewSecondLocation)).setText("Location 2 is supported in StreetView: " + status)); |
kikoso
reviewed
Sep 10, 2025
kikoso
approved these changes
Sep 10, 2025
Collaborator
kikoso
left a comment
There was a problem hiding this comment.
LGTM! Just a couple of comments. Most importantly: do we want to change the commit name to avoid triggering a new release?
Collaborator
|
Actually, on a second thought, would it make sense to add the |
This commit moves the `StreetViewHelper` from the `demo` module to the `library` module, making it an officially supported utility for Java consumers. The key changes include: - Renaming `StreetViewHelper` to `StreetViewJavaHelper` for better clarity and moving it to the `com.google.maps.android` package within the library. - Migrating the corresponding unit tests from the `demo` to the `library` module and updating them to reflect the class rename. - Adjusting `build.gradle.kts` files to move test dependencies (`mockk`, `coroutines-test`, `robolectric`) from the `demo` to the `library` module. - Renaming `StreetViewDemoActivityJava` to `StreetViewDemoJavaActivity` and updating it to use the new helper from the library. - Improving the warning message for invalid or missing API keys in the demo app.
googlemaps-bot
pushed a commit
that referenced
this pull request
Sep 10, 2025
# [3.17.0](v3.16.2...v3.17.0) (2025-09-10) ### Features * **demo:** Add StreetViewJavaHelper and demo and enable edge-to-edge ([#1595](#1595)) ([23a4bb5](23a4bb5))
Contributor
|
🎉 This PR is included in version 3.17.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains two main features:
Java Street View Demo
A new demo activity, StreetViewDemoActivityJava, has been added to show how to use the Street View utility from a Java-based Android application. This required the creation of a Kotlin helper class, StreetViewHelper, which bridges the gap between the suspend function StreetViewUtils.fetchStreetViewData and Java's callback-based asynchronous model. Additionally, an ApiKeyValidator utility was created to centralize the logic for checking for a valid Maps API key. The changes include adding unit tests for StreetViewHelper using Robolectric, MockK, and coroutine testing libraries to ensure its reliability.
Edge-to-Edge Support
Both the new Java demo and the existing Kotlin demo have been refactored to enable edge-to-edge display. This is achieved by changing the base activity to AppCompatActivity, using WindowCompat.setDecorFitsSystemWindows(window, false) to draw behind the system bars, and implementing ViewCompat.setOnApplyWindowInsetsListener on the root view to handle padding. This modern UI practice provides a more immersive and aesthetically pleasing user interface by utilizing the full screen space.
Fixes #1590