Repository navigation
fix(Insets): remove manual status bar insets workaround and rely on native SDK WindowInsets support - #97
fix(Insets): remove manual status bar insets workaround and rely on native SDK WindowInsets support#97LoyalAbbas wants to merge 1 commit into
Conversation
…ative SDK WindowInsets support
| ViewCompat.setOnApplyWindowInsetsListener(this) { _, insets -> | ||
| updateTopMarginForUiControls() | ||
| applyStatusBarInsetsToSiblingMapView() | ||
| requestSiblingMapViewInsets() |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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) | |||
There was a problem hiding this comment.
nit: the comment now says the opposite of what the code does (same in the other Compose activities touched here).
| // 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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Can you take a look at the comments, @LoyalAbbas ? Thanks!
Summary
Removes the temporary client-side status bar inset and system-bar hiding workarounds introduced while waiting for native
WindowInsetssupport in the Maps 3D SDK (tracked in https://issuetracker.google.com/issues/575850758), and fixes initial placement of the Quick Settings button onUiControlsActivity.What Changed
Map3DSettings.applyStatusBarInsetsToMapView):ids.xml), and the temporary workaround test suite (Map3DStatusBarInsetsTest.kt).ViewCompat.requestApplyInsets(...)dispatch inSampleBaseActivity(Kotlin & Java),UiControlsActivity(Kotlin, Java, Compose),Map3DQuickSettingsButton,Map3DQuickSettingsWidget, andmaps3d-compose(GoogleMap3D).WindowInsetsCompatfromSampleBaseActivity's inset listener so siblingMap3DViewinstances receive system bar and display cutout insets natively.Utilities.enableImmersiveMode()to keep system bars visible (insetsController.show(WindowInsetsCompat.Type.systemBars())) under standard edge-to-edge rendering.UiControlsActivity:uiControlsOverridesupport toMap3DQuickSettingsButton(matchingMap3DQuickSettingsWidgetin Compose) so asynchronous window-inset passes andattachMap()refreshes preserve screen-level UI control overrides.updateTopMarginForUiControls(buildCurrentUiControls())duringonCreatein both Kotlin and JavaUiControlsActivityso the Quick Settings FAB clears the active trailing controls from the first frame.Verification
./gradlew spotlessCheckpasses across all modules.:Maps3DSamples:ApiDemos:kotlin-app:assembleDebug,:Maps3DSamples:ApiDemos:java-app:assembleDebug,:Maps3DSamples:ComposeDemos:app:assembleDebug, and:Maps3DSamples:ApiDemos:common:testDebugUnitTest.