Repository navigation
feat(UIControlsScreen): add dedicated UI controls sample and snippets across Kotlin, Java, and Compose - #80
Conversation
… across Kotlin, Java, and Compose
kikoso
left a comment
There was a problem hiding this comment.
Thanks @LoyalAbbas ! The snippets look good and are a nice addition for the docs. My main comment is about the activity going through the shared controller instead of calling the SDK. Since this is stacked on #79, let's merge it after that one.
|
|
||
| chipZoom?.setOnCheckedChangeListener { _, isChecked -> | ||
| if (isSyncingUi) return@setOnCheckedChangeListener | ||
| val updated = Map3DSettingsController.shared.updateUiControl(zoom = isChecked) |
There was a problem hiding this comment.
Being this a dedicated UI controls sample, I would expect to see the SDK call here (getUiControlSettings()?.setUiControlsPlacement(...)). Right now everything goes through Map3DSettingsController.shared and applyTo, so the code the sample is about lives in common/Map3DSettings.kt. Could we call the SDK directly in the three activities, like the snippets do?
| } | ||
|
|
||
| btnHideAll?.setOnClickListener { | ||
| val updated = Map3DSettingsController.shared.setAllUiControls(false) |
There was a problem hiding this comment.
Since this writes to Map3DSettingsController.shared, tapping "Hide all" here also hides the controls in every other sample for the rest of the session. Is that intended? Also, the controller already notifies the quick settings button, which calls applyTo, so the map gets the settings applied twice (same as Dale's comment in the dialog).
| * Visibility state for built-in 3D camera UI controls. | ||
| * Placement edge constant alias for [ControlPlacement] ([ControlPlacement.TRAILING] vs [ControlPlacement.LEADING]). | ||
| */ | ||
| typealias UiControlsPlacementPosition = ControlPlacement |
There was a problem hiding this comment.
nit: Could we use ControlPlacement directly instead of the UiControlsPlacementPosition alias? It adds a second name for the same SDK type, and people reading the sample will look for it in the docs.
|
|
||
| fun getUiControlSettings(): UiControlSettings? { | ||
| val settings = delegate.getUiControlSettings() | ||
| if (settings != null) items.add(settings) |
There was a problem hiding this comment.
nit: every call adds the same UiControlSettings instance to items, so the cleanup resets it several times.
| if (settings != null) items.add(settings) | |
| if (settings != null && settings !in items) items.add(settings) |
| // [START maps_android_3d_ui_controls_swap_edges_kt] | ||
| map.getUiControlSettings()?.let { uiSettings -> | ||
| val leadingControls = listOf( | ||
| ZoomControl(null), |
There was a problem hiding this comment.
nit: snippet 1 passes ControlOrientation.VERTICAL and this one passes null. Since both end up in the docs, could we use the same in both? The explicit VERTICAL reads better to me.
…ols showcase Consolidates the stacked 3D Maps camera UI control improvements (PR #78, PR #79, and PR #80) into a single cohesive branch with 100% 3-way parity across Kotlin Views, Java Views, and Jetpack Compose. - Quick Settings Overlay: Map3DQuickSettingsButton (Views) and Map3DQuickSettingsWidget (Compose) with session-scoped Map3DSettingsController. - Dedicated UI Controls Showcase: Introduces UiControlsActivity across Kotlin, Java, and Compose calling the Maps 3D SDK directly (getUiControlSettings().setUiControlsPlacement(...)) with local UI state. - SDK Standards: Removed internal reflection hacks into GoogleMap3D and LinearLayout layout mutations; standardized on ControlPlacement and ControlOrientation.VERTICAL. - Stability & Robustness: Prevents Compose NoSuchFieldError on stripped fields, fixes top control clipping under toolbars, and adds comprehensive JVM unit tests in Map3DSettingsControllerTest.
…ols showcase Consolidates the stacked 3D Maps camera UI control improvements (PR #78, PR #79, and PR #80) into a single cohesive branch with 100% 3-way parity across Kotlin Views, Java Views, and Jetpack Compose. - Quick Settings Overlay: Map3DQuickSettingsButton (Views) and Map3DQuickSettingsWidget (Compose) with session-scoped Map3DSettingsController. - Dedicated UI Controls Showcase: Introduces UiControlsActivity across Kotlin, Java, and Compose calling the Maps 3D SDK directly (getUiControlSettings().setUiControlsPlacement(...)) with local UI state. - SDK Standards: Removed internal reflection hacks into GoogleMap3D and LinearLayout layout mutations; standardized on ControlPlacement and ControlOrientation.VERTICAL. - Stability & Robustness: Prevents Compose NoSuchFieldError on stripped fields, fixes top control clipping under toolbars, and adds comprehensive JVM unit tests in Map3DSettingsControllerTest.
|
Closing as superseded: all changes and review comment resolutions from this PR have been consolidated directly into #78 on a rebased, single-branch history. |
…ols showcase (#78) * feat(settings): add 3D map quick settings widget with camera controls toggle - Introduce Map3DQuickSettingsButton for Kotlin and Java Views - Introduce Map3DQuickSettingsWidget for Jetpack Compose - Support live switching of Map Mode (Satellite, Hybrid, Roadmap) - Support live switching of Color Scheme (System, Light, Dark) - Support master and granular toggling of Maps 3D camera UI controls - Protect top camera controls and settings FAB from status bar insets - Add Map3DSettingsControllerTest with 100% passing JVM unit tests * fix(compose): prevent Compose stability crash in Map3DQuickSettingsWidget and fix GoogleMap3D syntax * fix(controls): ensure 3D map camera UI controls persist and attach reliably across Kotlin, Java, and Compose * feat(settings): unify 3D quick settings widget and dedicated UI controls showcase Consolidates the stacked 3D Maps camera UI control improvements (PR #78, PR #79, and PR #80) into a single cohesive branch with 100% 3-way parity across Kotlin Views, Java Views, and Jetpack Compose. - Quick Settings Overlay: Map3DQuickSettingsButton (Views) and Map3DQuickSettingsWidget (Compose) with session-scoped Map3DSettingsController. - Dedicated UI Controls Showcase: Introduces UiControlsActivity across Kotlin, Java, and Compose calling the Maps 3D SDK directly (getUiControlSettings().setUiControlsPlacement(...)) with local UI state. - SDK Standards: Removed internal reflection hacks into GoogleMap3D and LinearLayout layout mutations; standardized on ControlPlacement and ControlOrientation.VERTICAL. - Stability & Robustness: Prevents Compose NoSuchFieldError on stripped fields, fixes top control clipping under toolbars, and adds comprehensive JVM unit tests in Map3DSettingsControllerTest. * fix(compose): add stability config for 3D SDK types to resolve NoSuchFieldError () - Add root compose_stability.conf treating com.google.android.gms.maps3d.** as stable - Configure composeCompiler { stabilityConfigurationFiles } in ComposeDemos, common, and maps3d-compose - Update DisposableEffect key in GoogleMap3D to boolean condition to avoid synthetic field lookups - Apply spotless formatting across compose modules * chore(java): defer Java Map3DControl sample and snippets pending SDK 16.0.1 fix * feat(ui): enforce sticky immersive mode across 3D map samples and quick settings * fix(snippets): specify valid mapMode and enable immersive mode for SDK 16.0.0
Summary
Adds a dedicated UI Controls (
UiControlsActivity) sample with 3-way parity across Kotlin Views, Java Views, and Jetpack Compose (defaulting toMap3DMode.ROADMAP), along with comprehensive Kotlin and Java documentation snippets (UiControlSnippets).Key Changes
:commonUI Controls & Controller Support:control_panel_ui_controls.xmlandbindUiControlButtonsPanel(panelRootView: View)inMap3DSettingsController.ktto allow interactive configuration of built-in 3D camera controls (ZoomControl,TiltControl,RotateControl,PanVerticalControl,PanHorizontalControl,CompassControl) and edge placement (ControlPlacement.LEADINGvsControlPlacement.TRAILING).CompassControlwith the secondary pan controls (PanVerticalControl,PanHorizontalControl) on the opposite edge from the primary camera controls (ZoomControl,TiltControl,RotateControl) to prevent screen edge overlap.UiControlsActivity):UiControlsActivity.ktand registered it inMainActivity.ktandAndroidManifest.xml.UiControlsActivity.javaand registered it inMainActivity.javaandAndroidManifest.xml.UiControlsActivity.ktwithUiControlsBottomSheetand registered it inMainActivity.ktandAndroidManifest.xml.:snippets:kotlin-app&:snippets:java-app):UiControlSnippets.ktandUiControlSnippets.javacovering:ControlPlacement.TRAILING&ControlPlacement.LEADING)ControlOrientation.HORIZONTAL),Spacer(), andControlPlacement.TOP/ControlPlacement.BOTTOMplacementTrackedMap3DandSnippetRegistry(Kotlin & Java) to automatically reset UI control placements across all edges when switching snippets.Map3DSettingsControllerTest.ktto verify default and swapped edge placements for all 6 UI controls.Verification
:Maps3DSamples:ApiDemos:kotlin-app,:Maps3DSamples:ApiDemos:java-app,:Maps3DSamples:ComposeDemos:app,:snippets:kotlin-app, and:snippets:java-app.:Maps3DSamples:ApiDemos:common:testDebugUnitTest.