diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index a8d4379ee..496a606b1 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -223,7 +223,8 @@ protected void createViews() { 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 ebcc87dae..00b0f4833 100644 --- a/framework/src/org/apache/cordova/SystemBarPlugin.java +++ b/framework/src/org/apache/cordova/SystemBarPlugin.java @@ -34,6 +34,7 @@ Licensed to the Apache Software Foundation (ASF) under one 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 boolean execute(String action, JSONArray args, CallbackContext callbackCo * @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);