You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/08/11 07:48:47 UTC
(cordova-android) 01/01: fix(statusbar): hide status bar correctly
This is an automated email from the ASF dual-hosted git repository.
GitToTheHub pushed a commit to branch pr-fix-hide-statusbar
in repository https://gitbox.apache.org/repos/asf/cordova-android.git
commit 05191daa77209875924f2adf0716c416660c826f
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Tue Aug 11 09:48:37 2026 +0200
fix(statusbar): hide status bar correctly
- Hide the real Android status bar through the built-in API and allow it to be temporarily revealed by swipe. Respect the system status-bar visibility when calculating Cordova's faux status-bar inset, preserving compatibility with cordova-plugin-statusbar.
- Fixes #592
Generated-By: GPT-5.6 Terra
---
framework/src/org/apache/cordova/CordovaActivity.java | 3 ++-
framework/src/org/apache/cordova/SystemBarPlugin.java | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index a8d4379e..496a606b 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -223,7 +223,8 @@ public class CordovaActivity extends AppCompatActivity {
WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()
);
- boolean isStatusBarVisible = statusBarView.getVisibility() != View.GONE;
+ boolean isStatusBarVisible = statusBarView.getVisibility() != View.GONE
+ && insets.isVisible(WindowInsetsCompat.Type.statusBars());
int top = isStatusBarVisible && !canEdgeToEdge && !isFullScreen ? bars.top : 0;
int left = !canEdgeToEdge && !isFullScreen ? bars.left : 0;
int right = !canEdgeToEdge && !isFullScreen ? bars.right : 0;
diff --git a/framework/src/org/apache/cordova/SystemBarPlugin.java b/framework/src/org/apache/cordova/SystemBarPlugin.java
index ebcc87da..00b0f483 100644
--- a/framework/src/org/apache/cordova/SystemBarPlugin.java
+++ b/framework/src/org/apache/cordova/SystemBarPlugin.java
@@ -34,6 +34,7 @@ import android.widget.FrameLayout;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
+import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import org.json.JSONArray;
@@ -101,6 +102,16 @@ public class SystemBarPlugin extends CordovaPlugin {
* @param visible should the status bar be visible?
*/
private void setStatusBarVisible(final boolean visible) {
+ Window window = cordova.getActivity().getWindow();
+ WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(window, window.getDecorView());
+ if (visible) {
+ controller.show(WindowInsetsCompat.Type.statusBars());
+ } else {
+ // Reveal the hidden bar temporarily as an overlay when swiped from the top.
+ controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
+ controller.hide(WindowInsetsCompat.Type.statusBars());
+ }
+
View statusBar = getStatusBarView(webView);
if (statusBar != null) {
statusBar.setVisibility(visible ? View.VISIBLE : View.GONE);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org