Skip to content

Conversation

@dkhawk
Copy link
Collaborator

@dkhawk dkhawk commented Sep 24, 2025

Adds a awaitMapSteady function to the Map3dViewModel. Adds waitUntilTheMapIsSteady to the Scenarios. The result is that the scenarios can be paused while waiting for the 3D data to load.

dkhawk added 23 commits August 25, 2025 10:24
This commit introduces Espresso UI tests for `HelloMapActivity` in both the Java and Kotlin sample apps to verify that the map view is displayed.

Additionally, this commit includes several build and dependency updates:
- Upgrades Gradle, the Android Gradle Plugin, Kotlin, and other AndroidX libraries.
- Centralizes `minSdk` and `targetSdk` in the version catalog (`libs.versions.toml`).
- Moves the Maps 3D SDK dependency to the `common` module and exposes it to the app modules using the `api` configuration.
This commit introduces an instrumented test for `CameraControlsActivity`.

The test verifies two main functionalities:
- The `Map3DView` is displayed correctly.
- The "Fly to" button animates the camera to the expected location.

The `androidx.test.uiautomator` dependency was added to support the test implementation.
This commit introduces a new instrumentation test, `testFlyAround`, to `CameraControlsActivityTest`.

The test verifies the functionality of the "Fly Around" button by clicking it and then using `OnMapSteadyListener` to assert that the animation completes and the map returns to a steady state.
This commit updates the project to use version 0.0.3 of the Maps3D SDK, which is now included as a local AAR file. It also updates various dependencies, including the Android Gradle Plugin, Kotlin, Compose BOM, and the Gradle wrapper.

Key API changes from the SDK update have been applied:
*   `PolygonOptions.outerCoordinates` is now `path`.
*   `PolygonOptions.innerCoordinates` is now `innerPaths`.
*   `PolylineOptions.coordinates` is now `path`.

Additionally, the build configuration is streamlined by centralizing `compileSdk`, `minSdk`, and `targetSdk` versions in the `libs.versions.toml` files.
This commit adds the Google Truth assertion library as a testing dependency for both the Java and Kotlin sample apps.

Existing instrumentation tests have been refactored to use Truth's fluent `assertThat` API instead of JUnit assertions, improving the readability and expressiveness of the test code.
This commit introduces click handling for various map elements and adds a new sample to demonstrate place clicks.

- **Map Interactions Sample:** A new `MapInteractionsActivity` has been added to show how to use `setMap3DClickListener` to handle clicks on the map and on places.
- **Marker Clicks:** The `MarkersActivity` now sets a `clickListener` on each marker, displaying a `Toast` with the marker's label when clicked.
- **Polyline Clicks:** The `PolylinesActivity` now sets a `clickListener` on the trail polyline.
- **Polygon Clicks:** The `PolygonsActivity` now sets `clickListener`s on the museum and zoo polygons.
This commit introduces several improvements to the sample applications:

- The build configuration is updated across all modules to depend on a local `play-services-maps3d` AAR file instead of a remote dependency.
- The Kotlin `MainActivity` is refactored to use a `Sample` data class for the list of demos, improving type safety and code readability.
- The XML themes for the Java and Kotlin ApiDemos apps are updated to consistently use `Theme.Material3.DayNight.NoActionBar`.
This commit enhances the `HelloMapActivity` and `MarkersActivity` samples with improved documentation and modern Android development patterns.

Key changes include:
- Expanded KDoc comments in `HelloMapActivity` and `MarkersActivity` to provide more detailed explanations of the code and concepts.
- Refactored `MarkersActivity` to use `lifecycleScope` for managing coroutines and to extract marker creation and click listener setup into separate functions.
- Updated `SampleBaseActivity` to extend `AppCompatActivity` for better support and consistency.
- Moved the `TAG` definition in `HelloMapActivity` to a `companion object` to follow common Kotlin idioms.
This commit refactors `ModelsActivity` for better code organization, readability, and lifecycle safety.

Key changes include:
- Replaced `CoroutineScope(Dispatchers.Main)` with `lifecycleScope` to tie coroutines to the activity's lifecycle, preventing potential leaks.
- Extracted logic into smaller, well-documented helper functions like `setupUI`, `addPlaneModel`, and `runAnimationSequence`.
- Used `kotlin.time.Duration` for more readable and type-safe time values in animations and flows.
- Added extensive KDoc comments to the class and methods to improve documentation.
This commit refactors the `PolygonsActivity` to improve code organization, clarity, and lifecycle management.

Key changes include:
- Extracting the logic for adding polygons and setting up click listeners into dedicated functions (`addMuseumPolygons`, `addZooPolygon`, `setupPolygonClickListener`).
- Switching from a manual `CoroutineScope` to `lifecycleScope` for safer coroutine handling that is tied to the activity's lifecycle.
- Adding extensive KDoc comments to the class, methods, and properties to better document the sample's functionality.
- Using `by lazy` to defer the initialization of polygon coordinate data until first use.
This commit refactors the `PolylinesActivity` to improve code quality, readability, and documentation.

Key changes include:
- Expanded the KDoc for the activity to better explain the sample's purpose and implementation details.
- Extracted logic for adding polylines and setting up click listeners into separate, focused functions.
- Switched from a manually created `CoroutineScope` to the lifecycle-aware `lifecycleScope`.
- Used `by lazy` for deferred initialization of polyline options and trail data, improving performance.
- Simplified the parsing of trail location data using more idiomatic Kotlin.
Loading the files locally left as comments for reference
Adds a click listener to the airplane model in the `ModelsActivity` sample. A toast message is shown when the model is clicked to demonstrate the feature.
This commit updates the Gradle version and refreshes various project dependencies across the sample applications.

Key changes:
- **Gradle Upgrade:** Upgraded the Gradle wrapper from version 8.11.1 to 9.1.0. This includes updating the `gradlew` and `gradlew.bat` scripts and the wrapper JAR to the versions generated by Gradle 9.1.
- **Dependency Updates:** Updated several key libraries to their latest versions, including:
    - Android Gradle Plugin to 8.13.0
    - Kotlin to 2.2.20
    - Compose BOM to 2025.09.00
    - Hilt to 2.57.1
    - Various AndroidX, KSP, and testing libraries.
- **Build Script Refactor:** In the `ApiDemos` project, the `play-services-maps3d` dependency is now referenced through the version catalog for consistency.
This commit introduces several cleanups and refactorings across the API Demos samples, primarily focusing on the Gradle build scripts and the Java sample application.

- **Gradle Build Scripts:**
    - The `sarifOutput` path for lint reports is now consistently configured using the modern `layout.buildDirectory` API across all modules.
    - In the `java-app`, SDK versions (`compileSdk`, `minSdk`, `targetSdk`) are now sourced from the version catalog (`libs.versions`) instead of being hardcoded.

- **Java Sample App (`java-app`):**
    - Removed Kotlin and Jetpack Compose plugins and dependencies, making it a pure Java-based sample.
    - Updated Javadoc comments to follow standard Java conventions, removing Kotlin-style syntax.

- **Kotlin Code:**
    - Corrected a `@StringRes` annotation target in `Units.kt` for better precision.
    - Removed an unused import in `MainActivity.kt`.
    - Enabled `buildConfig` in the `kotlin-app` module.
This commit updates the Java API Demos app to support edge-to-edge display, allowing the app's UI to draw behind the system status and navigation bars for a more immersive experience.

Key changes:

-   **Theme Updates (`themes.xml`):**
    -   The status and navigation bars are set to transparent.
    -   The theme is configured to allow drawing behind system bars (`windowDrawsSystemBarBackgrounds`) and to render in the display cutout area.

-   **Activity Changes (`MainActivity` & `SampleBaseActivity`):**
    -   `WindowCompat.setDecorFitsSystemWindows(false)` is called to enable edge-to-edge mode.
    -   An `OnApplyWindowInsetsListener` is used to get the system bar insets and apply them as padding to the root view. This ensures that interactive UI elements are not obscured by the system bars.

-   **Refinement:** The inset handling logic in `SampleBaseActivity` has been simplified to use `WindowInsetsCompat.Type.systemBars()` for a cleaner implementation.
This commit updates the project's dependencies to use version 0.0.3 of the Maps 3D SDK.

Key changes:
- The `play-services-maps3d` dependency is updated from version 0.0.2 to 0.0.3 in `libs.versions.toml`.
- The SDK is now included as a local AAR file (`play-services-maps3d-0.0.3.aar`) in the `common`, `java-app`, and `kotlin-app` modules.
- A new dependency on `play-services-base` has been added to all modules, as required by the updated SDK.
- The version catalog (`libs.versions.toml`) has been updated to include `play-services-base`, `truth`, and `uiautomator`.
- Implemented click listeners for markers, polygons, polylines, and models to demonstrate new interactive features.
- Updated Polygon and Polyline options to use the new `path` and `innerPaths` properties, aligning with the latest API.
- Refactored `MarkersActivity` to use a helper method for marker creation, improving code clarity and reducing repetition.
- Added a migration guide to assist users in updating to the new SDK version.
- Abstracted Toast notifications into a `showToast` helper method in `SampleBaseActivity` to reduce boilerplate in individual activities.
- Replaced hardcoded strings in click listeners with string resources for better maintainability and localization.
This commit refactors the Java API Demos sample app by moving shared resources to the `common` module and simplifying code.

Key changes:
-   **Code Simplification in `CameraControlsActivity`:**
    -   The `updateCameraPosition` method now uses a single formatted string resource (`camera_state_format`) instead of manual `StringBuilder` concatenation, making the code cleaner and more localizable.
    -   UI updates are now posted to the main thread using `runOnUiThread` and `view.postDelayed` instead of `new Handler(Looper.getMainLooper())`.

-   **Lifecycle Method Cleanup in `HelloMapActivity`:**
    -   Removed redundant null checks for `map3DView` in lifecycle callback methods (`onResume`, `onPause`, `onDestroy`, etc.), as the view is initialized in `onCreate`.
This commit updates the project's dependencies and build configuration.

Key changes:
- **Gradle Build Script:** The `sarifOutput` path in `build.gradle.kts` was updated to use the modern `layout.buildDirectory` API.
- **Lint Fix:** Added a `@param:StringRes` annotation target in `MainActivity.kt` to resolve a lint warning.
@dkhawk dkhawk requested a review from kikoso September 24, 2025 00:15
@dkhawk
Copy link
Collaborator Author

dkhawk commented Sep 24, 2025

Branched from pull/16

@dkhawk dkhawk marked this pull request as draft September 24, 2025 16:42
@kikoso kikoso changed the title Feat/add steady wait example feat: add steady wait example Sep 24, 2025
@tejbhansahu
Copy link

Hi @kikoso & @dkhawk, We are eagerly waiting for these fixes.
Hoping for an earlier release.

@dkhawk
Copy link
Collaborator Author

dkhawk commented Oct 6, 2025

Hi @kikoso & @dkhawk, We are eagerly waiting for these fixes. Hoping for an earlier release.

Thanks for the interest! We're excited for this release, too.

To make sure you get the most up-to-date and official information, please watch the Google Play Services release notes page, as that is where new versions are announced first:

https://developers.google.com/android/guides/releases

You can always check that page for the most current release information, like this example:

https://developers.google.com/android/guides/releases#june_11_2025

We appreciate your patience!

This commit updates the Maps 3D SDK from a local AAR file to the remote artifact version 0.1.0. It also includes updates to several other libraries.

Key changes:

-   **Maps 3D SDK Update:**
    -   The `libs.versions.toml` files in both `ApiDemos` and `advanced` samples are updated to use `playServicesMaps3d = "0.1.0"`.

-   **Other Dependency Updates:**
    -   In the `advanced` sample, the following dependencies were updated:
        -   `composeBom` to `2025.09.01`
        -   `hilt` to `2.57.2`
        -   `playServicesBase` to `18.9.0`
This commit introduces a new animation command, `waitUntilTheMapIsSteady`, which pauses a scenario's animation until the map is fully loaded and idle. This ensures animations start smoothly on a stable map view.

Key changes:

-   **New `waitUntilTheMapIsSteady` command:**
    -   A new `WaitUntilTheMapIsSteadyStep` animation class is added, which suspends execution until the map is steady.
    -   `ScenarioMapper` is updated to parse this new command from the animation string.
This commit enhances the `waitUntilTheMapIsSteady` animation step by adding an optional timeout parameter. This prevents an animation from getting stuck indefinitely if the map never reaches a steady state.

Key changes:

- **`WaitUntilTheMapIsSteadyStep`:** Converted from a `data object` to a `data class` to accept a `timeoutMillis` parameter. The animation string command is now `waitUntilTheMapIsSteady=timeout=<milliseconds>`.
- **`Map3dViewModel`:** The `awaitMapSteady()` function now takes a `timeoutMillis` argument and uses `withTimeout` to enforce the limit, logging a warning if the timeout is exceeded.
- **`ScenarioMapper`:** The animation parser is updated to read the optional `timeout` value for the `waitUntilTheMapIsSteady` command. The parameterless version is still supported and will wait indefinitely.
- **`ScenarioData`:** Updated existing scenarios to use a 1000ms timeout for the `waitUntilTheMapIsSteady` step.
@dkhawk dkhawk force-pushed the feat/add-steady-wait-example branch from c3e7993 to a3e45cf Compare October 23, 2025 23:02
@dkhawk dkhawk marked this pull request as ready for review October 23, 2025 23:05
Resolves an issue where `android:windowLayoutInDisplayCutoutMode` was used in a theme that supported API levels below 27, causing a build failure.

This attribute is only available on API level 27 and higher. To fix this, the attribute has been moved to a separate theme file in the `values-v27` resource directory.

Also fixes a warning about multiple substitutions in the `camera_state_format` string resource by adding `formatted="false"`.
@dkhawk dkhawk self-assigned this Oct 23, 2025
@kikoso
Copy link
Collaborator

kikoso commented Oct 24, 2025

Let's wait until #16 gets merged and rebase, since both PRs are based on similar commits.

import dagger.hilt.android.AndroidEntryPoint

data class MapSample(@StringRes val label: Int, val clazz: Class<*>)
data class MapSample(@param:StringRes val label: Int, val clazz: Class<*>)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we could just use the StringRes.

@dkhawk dkhawk marked this pull request as draft October 24, 2025 19:53
@tejbhansahu
Copy link

Hi @dkhawk and @kikoso,

I’ve been testing the latest Map and Advanced Map 3D Samples projects, but I’m currently unable to detect clicks on models or other map APIs. Could you please guide me on how to resolve this issue or point me in the right direction?

Thank you for your support.

@dkhawk
Copy link
Collaborator Author

dkhawk commented Nov 2, 2025

It's possible for there to be a delay in one or more of your devices getting the latest Google Play Services module. Double check this page https://support.google.com/googleplay/answer/9037938?hl=en

@tejbhansahu
Copy link

It's possible for there to be a delay in one or more of your devices getting the latest Google Play Services module. Double check this page https://support.google.com/googleplay/answer/9037938?hl=en

It’s working @dkhawk, thanks for the immediate response.

@dkhawk
Copy link
Collaborator Author

dkhawk commented Nov 3, 2025

Committed as #20

@dkhawk dkhawk closed this Nov 3, 2025
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.

4 participants