Skip to content

fix(Insets): remove manual status bar insets workaround and rely on native SDK WindowInsets support - #97

Draft
LoyalAbbas wants to merge 1 commit into
mainfrom
feat/start-support-windowinsets
Draft

LoyalAbbas wants to merge 1 commit into
mainfrom
feat/start-support-windowinsets

Conversation

@LoyalAbbas

Copy link
Copy Markdown
Collaborator

Summary

Removes the temporary client-side status bar inset and system-bar hiding workarounds introduced while waiting for native WindowInsets support in the Maps 3D SDK (tracked in https://issuetracker.google.com/issues/575850758), and fixes initial placement of the Quick Settings button on UiControlsActivity.

What Changed

  • Removed manual status bar inset workaround (Map3DSettings.applyStatusBarInsetsToMapView):
    • Deleted manual child-container margin traversal, layout change listeners, dedicated tag IDs (ids.xml), and the temporary workaround test suite (Map3DStatusBarInsetsTest.kt).
    • Replaced manual offset calls with standard ViewCompat.requestApplyInsets(...) dispatch in SampleBaseActivity (Kotlin & Java), UiControlsActivity (Kotlin, Java, Compose), Map3DQuickSettingsButton, Map3DQuickSettingsWidget, and maps3d-compose (GoogleMap3D).
    • Returned unconsumed WindowInsetsCompat from SampleBaseActivity's inset listener so sibling Map3DView instances receive system bar and display cutout insets natively.
  • Restored visible system bars on edge-to-edge screens:
    • Updated sample activities and Utilities.enableImmersiveMode() to keep system bars visible (insetsController.show(WindowInsetsCompat.Type.systemBars())) under standard edge-to-edge rendering.
  • Fixed initial Quick Settings FAB placement on UiControlsActivity:
    • Added uiControlsOverride support to Map3DQuickSettingsButton (matching Map3DQuickSettingsWidget in Compose) so asynchronous window-inset passes and attachMap() refreshes preserve screen-level UI control overrides.
    • Initialized updateTopMarginForUiControls(buildCurrentUiControls()) during onCreate in both Kotlin and Java UiControlsActivity so the Quick Settings FAB clears the active trailing controls from the first frame.

Verification

  • Verified ./gradlew spotlessCheck passes across all modules.
  • Built and verified :Maps3DSamples:ApiDemos:kotlin-app:assembleDebug, :Maps3DSamples:ApiDemos:java-app:assembleDebug, :Maps3DSamples:ComposeDemos:app:assembleDebug, and :Maps3DSamples:ApiDemos:common:testDebugUnitTest.
  • Verified on-device across Kotlin Views, Java Views, and Jetpack Compose samples that built-in 3D map UI controls, the Google Maps logo, and the Quick Settings button clear system bars and avoid overlap on initial load.

@LoyalAbbas
LoyalAbbas requested review from dkhawk and kikoso and removed request for dkhawk November 6, 2026 08:50
ViewCompat.setOnApplyWindowInsetsListener(this) { _, insets ->
updateTopMarginForUiControls()
applyStatusBarInsetsToSiblingMapView()
requestSiblingMapViewInsets()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I may be missing something, but calling requestSiblingMapViewInsets() from inside the insets listener asks for a new insets pass while one is being dispatched, which calls this listener again. I think we could end up re-dispatching insets on every frame. Could we drop it here, since onAttachedToWindow(), attachMap() and the settings change already request it?

* Configures system bar behavior for edge-to-edge 3D map rendering while keeping
* status and navigation bars visible so [WindowInsetsCompat.Type.systemBars] insets can be verified.
*/
fun Activity.enableImmersiveMode() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Being this function now showing the system bars, the name enableImmersiveMode() is a bit misleading, and BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE has no effect while the bars are visible. Should we rename it to something like enableEdgeToEdgeSystemBars() and drop the "so insets can be verified" bit from the KDoc, which reads like a debugging note?

@@ -58,7 +58,7 @@ class HelloMapActivity : ComponentActivity() {

// Hide system tray (immersive mode)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: the comment now says the opposite of what the code does (same in the other Compose activities touched here).

Suggested change
// Hide system tray (immersive mode)
// Keep the system bars visible while drawing edge-to-edge

}
if (::map3DView.isInitialized) {
Map3DSettings.applyStatusBarInsetsToMapView(map3DView, lastStatusBarTop)
ViewCompat.requestApplyInsets(map3DView)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason why we are not bumping playServicesMaps3d in this PR? It stays at 16.0.1, so if native WindowInsets support only ships in a newer SDK, removing the workaround would bring the status bar overlap back.

googleMap3D.setCamera(initialValidCamera)
Map3DRegistry.setInstance(googleMap3D)
ViewCompat.requestApplyInsets(map3dView)
map3dView.post {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, do we need the second request inside post { }? requestApplyInsets() already schedules the dispatch for the next layout pass, and since this is library code I would keep it as small as possible. What do you think?

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you take a look at the comments, @LoyalAbbas ? Thanks!

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