fix(android-edge-to-edge-support): use Window color API when edge-to-edge is not enforced#839
Draft
robingenz wants to merge 2 commits into
Draft
fix(android-edge-to-edge-support): use Window color API when edge-to-edge is not enforced#839robingenz wants to merge 2 commits into
robingenz wants to merge 2 commits into
Conversation
…edge is not enforced
7 tasks
@capawesome/capacitor-age-signals
@capawesome-team/capacitor-android-battery-optimization
@capawesome/capacitor-android-dark-mode-support
@capawesome/capacitor-android-edge-to-edge-support
@capawesome-team/capacitor-android-foreground-service
@capawesome/capacitor-app-review
@capawesome/capacitor-app-shortcuts
@capawesome/capacitor-app-update
@capawesome/capacitor-apple-sign-in
@capawesome/capacitor-asset-manager
@capawesome/capacitor-background-task
@capawesome/capacitor-badge
@capawesome/capacitor-cloudinary
@capawesome-team/capacitor-datetime-picker
@capawesome-team/capacitor-file-opener
@capawesome/capacitor-file-picker
@capawesome/capacitor-google-sign-in
@capawesome/capacitor-libsql
@capawesome/capacitor-live-update
@capawesome/capacitor-managed-configurations
@capawesome/capacitor-photo-editor
@capawesome/capacitor-pixlive
@capawesome/capacitor-posthog
@capawesome/capacitor-realtimekit
@capawesome/capacitor-screen-orientation
@capawesome/capacitor-screenshot
@capawesome/capacitor-square-mobile-payments
@capawesome/capacitor-superwall
@capawesome/capacitor-torch
commit: |
56 tasks
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.
Summary
Restores setting the status bar and navigation bar colors on Android versions where edge-to-edge is not enforced (API <35, or API 35 with
windowOptOutEdgeToEdgeEnforcement=true). On those versions, the plugin now uses the platformWindow.setStatusBarColor/setNavigationBarColorAPIs (plusFLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) — the same approach@capacitor/status-baruses — instead of the overlay-view approach.The overlay approach is still used on API 35+ when edge-to-edge is enforced, because the legacy Window color APIs are ignored there.
Why
On API <35 with
decorFitsSystemWindows = true(the default), theDecorViewauto-consumes system bar insets as padding before they reach the plugin'sWebViewlistener. That made the plugin's overlay-positioning logic silently depend on another plugin (@capacitor/keyboard≤ 8.0.1) keeping a no-opsetOnApplyWindowInsetsListeneron the root view, which happened to disable the auto-consumption.When
@capacitor/keyboard8.0.2 addedViewCompat.onApplyWindowInsets(v, insets)inside that listener, insets started being re-applied as padding on the root view, shifting the nav bar overlay ABOVE the nav bar. When 8.0.3 moved the listener from root view to thecontentview, theDecorViewresumed auto-consuming insets, so the overlay got a height of 0 and became invisible.Using the platform Window color API on API <35 sidesteps the inset dispatch chain entirely, so the plugin no longer depends on any side effects of other plugins.
Changes
EdgeToEdge.java: runtimeisEdgeToEdgeEnforced()check branchesenable()/disable()between the overlay approach (enforced) and the legacy Window color API (not enforced). Split private color setters intosetXxxColor(int)(store + apply) andapplyXxxColor()(read current + branch).EdgeToEdgeConfig.java: color fields switched fromintdefaulting toTRANSPARENTto nullableInteger. Lets the legacy path avoid clobbering the theme default when the user has not configured a color.topInsetLikelyHandledBySystemheuristic inapplyInsetsInternal— that path now only runs when edge-to-edge is enforced.Test plan
@capacitor/keyboard@8.0.3—setNavigationBarColorandsetStatusBarColorwork.@capacitor/keyboard@8.0.1— no regression.windowOptOutEdgeToEdgeEnforcement=true— legacy path, bar colors set.Close #838