From cb1cf4dc8ee2e92bbeef76fa449deafbcc1dabc2 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 30 Mar 2021 01:55:16 -0400 Subject: [PATCH] fix(splashscreen): nav & title bar showing in fullscreen mode (#733) Co-authored-by: Daniel Stone Co-authored-by: distinctdan --- .../org/apache/cordova/CordovaActivity.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index f2f5619e..9b15e336 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -125,6 +125,9 @@ public class CordovaActivity extends Activity { // (as was the case in previous cordova versions) if (!preferences.getBoolean("FullscreenNotImmersive", false)) { immersiveMode = true; + // The splashscreen plugin needs the flags set before we're focused to prevent + // the nav and title bars from flashing in. + setImmersiveUiVisibility(); } else { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); @@ -321,22 +324,26 @@ public class CordovaActivity extends Activity { /** * Called when view focus is changed */ - @SuppressLint("InlinedApi") @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus && immersiveMode) { - final int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; - - getWindow().getDecorView().setSystemUiVisibility(uiOptions); + setImmersiveUiVisibility(); } } + @SuppressLint("InlinedApi") + protected void setImmersiveUiVisibility() { + final int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; + + getWindow().getDecorView().setSystemUiVisibility(uiOptions); + } + @SuppressLint("NewApi") @Override public void startActivityForResult(Intent intent, int requestCode, Bundle options) {