From 65b4885a926dc8017650b788cf349b7b999f9050 Mon Sep 17 00:00:00 2001 From: adrenaline15 <1596013+adrenaline15@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:53:52 +0100 Subject: [PATCH 1/3] fix(SystemBars): keep the system bar backgrounds and navigation bar scrim The window insets listener is registered on the DecorView, which replaces DecorView#onApplyWindowInsets. That method lays out the system bar backgrounds, including the contrast scrim behind the 3-button navigation bar, so since 8.5.2 the scrim is never drawn, and on windows that are not edge-to-edge the navigation bar loses its background. Call the DecorView's own onApplyWindowInsets first, as the View.OnApplyWindowInsetsListener docs describe, and continue with the insets it returns. --- .../src/main/java/com/getcapacitor/plugin/SystemBars.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java index 4fff13f19..f8e9e77bf 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java @@ -189,7 +189,12 @@ private void initWindowInsetsListener() { View view = getActivity().getWindow().getDecorView(); - ViewCompat.setOnApplyWindowInsetsListener(view, (v, insets) -> { + ViewCompat.setOnApplyWindowInsetsListener(view, (v, windowInsets) -> { + // A listener replaces the DecorView's own onApplyWindowInsets, which is what draws the system bar + // backgrounds and the 3-button navigation bar scrim. Let it run, and continue with the insets it + // leaves, so the space it already reserves for the system bars is not padded a second time. + WindowInsetsCompat insets = WindowInsetsCompat.toWindowInsetsCompat(v.onApplyWindowInsets(windowInsets.toWindowInsets()), v); + boolean shouldPassthroughInsets = getWebViewMajorVersion() >= WEBVIEW_VERSION_WITH_SAFE_AREA_FIX && hasViewportCover; Insets systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()); From 5b92c5134db494dec2932e19b732cd3a7a87cfbc Mon Sep 17 00:00:00 2001 From: adrenaline15 <1596013+adrenaline15@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:55:50 +0100 Subject: [PATCH 2/3] fix(SystemBars): pad the WebView's parent instead of the DecorView The DecorView is the FrameLayout that holds the system bar background views. Now that its own onApplyWindowInsets runs again, those views exist, and padding the DecorView moves them into the content: with the keyboard open, or when the insets are not passed through (no viewport-fit=cover or WebView < 140), the navigation bar scrim is drawn above the keyboard or the navigation bar. Pad the WebView's parent, as before 8.5.2, so the bar backgrounds stay at the screen edges. --- .../src/main/java/com/getcapacitor/plugin/SystemBars.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java index f8e9e77bf..4be63b440 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java @@ -194,6 +194,9 @@ private void initWindowInsetsListener() { // backgrounds and the 3-button navigation bar scrim. Let it run, and continue with the insets it // leaves, so the space it already reserves for the system bars is not padded a second time. WindowInsetsCompat insets = WindowInsetsCompat.toWindowInsetsCompat(v.onApplyWindowInsets(windowInsets.toWindowInsets()), v); + // Pad the WebView's parent rather than the DecorView: the DecorView also holds the system bar + // background views, and padding it would move them away from the screen edges into the content. + View content = (View) getBridge().getWebView().getParent(); boolean shouldPassthroughInsets = getWebViewMajorVersion() >= WEBVIEW_VERSION_WITH_SAFE_AREA_FIX && hasViewportCover; @@ -207,7 +210,7 @@ private void initWindowInsetsListener() { if (shouldPassthroughInsets) { // We need to correct for a possible shown IME - v.setPadding(0, 0, 0, keyboardVisible ? imeInsets.bottom : 0); + content.setPadding(0, 0, 0, keyboardVisible ? imeInsets.bottom : 0); WindowInsetsCompat newInsets = withoutOverlayingKeyboard( new WindowInsetsCompat.Builder(insets).setInsets( @@ -228,7 +231,7 @@ private void initWindowInsetsListener() { } // We need to correct for a possible shown IME - v.setPadding( + content.setPadding( systemBarsInsets.left, systemBarsInsets.top, systemBarsInsets.right, From 168eeafd9a00292df0fb91a8a88fe154a098c31f Mon Sep 17 00:00:00 2001 From: adrenaline15 <1596013+adrenaline15@users.noreply.github.com> Date: Wed, 18 Nov 2026 09:40:34 +0100 Subject: [PATCH 3/3] fix(SystemBars): skip the padding while the WebView is detached The listener now pads the WebView's parent, which is null once the WebView has been removed from its layout (for example a Fragment-hosted bridge whose view was destroyed). Return the insets unchanged in that case instead of throwing a NullPointerException. --- .../src/main/java/com/getcapacitor/plugin/SystemBars.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java index 4be63b440..0a254d316 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java @@ -197,6 +197,11 @@ private void initWindowInsetsListener() { // Pad the WebView's parent rather than the DecorView: the DecorView also holds the system bar // background views, and padding it would move them away from the screen edges into the content. View content = (View) getBridge().getWebView().getParent(); + if (content == null) { + // The WebView is not attached (e.g. a Fragment-hosted bridge whose view was destroyed), + // so there is nothing to pad. + return insets; + } boolean shouldPassthroughInsets = getWebViewMajorVersion() >= WEBVIEW_VERSION_WITH_SAFE_AREA_FIX && hasViewportCover;