You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ni...@apache.org on 2022/04/03 18:05:02 UTC

[cordova-plugin-splashscreen] branch master updated: GH-180 (android): Fixes nav and title bars still appearing when app is fullscreen (#213)

This is an automated email from the ASF dual-hosted git repository.

niklasmerz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-splashscreen.git


The following commit(s) were added to refs/heads/master by this push:
     new d780b0d  GH-180 (android): Fixes nav and title bars still appearing when app is fullscreen (#213)
d780b0d is described below

commit d780b0d9d68702ebef6081a36b0acf7c34eb3eb8
Author: Daniel Stone <fr...@gmail.com>
AuthorDate: Sun Apr 3 11:04:56 2022 -0700

    GH-180 (android): Fixes nav and title bars still appearing when app is fullscreen (#213)
    
    Co-authored-by: Daniel Stone <da...@powerdms.com>
    Co-authored-by: distinctdan <di...@users.noreply.github.com>
---
 src/android/SplashScreen.java | 41 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 4 deletions(-)

diff --git a/src/android/SplashScreen.java b/src/android/SplashScreen.java
index 6f2252c..ea9e38d 100644
--- a/src/android/SplashScreen.java
+++ b/src/android/SplashScreen.java
@@ -32,6 +32,7 @@ import android.view.Display;
 import android.view.Gravity;
 import android.view.View;
 import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
 import android.view.WindowManager;
 import android.view.animation.Animation;
 import android.view.animation.AlphaAnimation;
@@ -315,16 +316,48 @@ public class SplashScreen extends CordovaPlugin {
 
                 // Create and show the dialog
                 splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar);
-                // check to see if the splash screen should be full screen
-                if ((cordova.getActivity().getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
-                        == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
-                    splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+
+                // Check to see if the splash screen should be full screen.
+                // On first run, currently cordova hasn't set the window flags yet because it does it in
+                //  onWindowFocusChanged instead of onCreate. If that's the case, we'll fall back to the
+                //  Fullscreen preference. Hopefully it will get fixed so that cordova sets them in onCreate,
+                //  so that this fallback can be removed.
+                boolean isFullscreen = false;
+                int mainWindowFlags = cordova.getActivity().getWindow().getAttributes().flags;
+                boolean flagFullscreen = (mainWindowFlags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
+                        == WindowManager.LayoutParams.FLAG_FULLSCREEN;
+                boolean flagForceNotFullscreen = (mainWindowFlags & WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
+                        == WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
+
+                // If cordova has set flags, one of these must be true.
+                if (flagFullscreen || flagForceNotFullscreen) {
+                    isFullscreen = flagFullscreen;
+                } else {
+                    // Cordova hasn't set flags, fall back to reading preference.
+                    isFullscreen = preferences.getBoolean("Fullscreen", false);
+                }
+
+                Window dialogWindow = splashDialog.getWindow();
+                if (isFullscreen) {
+                    dialogWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                             WindowManager.LayoutParams.FLAG_FULLSCREEN);
                 }
                 splashDialog.setContentView(splashImageView);
                 splashDialog.setCancelable(false);
                 splashDialog.show();
 
+                if (isFullscreen) {
+                    // These must be set after .show() is called because they only work on visible views.
+                    // When the splashscreen hides, the app will revert to whatever was set in CordovaActivity
+                    dialogWindow.getDecorView().setSystemUiVisibility(
+                        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);
+                }
+
                 if (preferences.getBoolean("ShowSplashScreenSpinner", true)) {
                     spinnerStart();
                 }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org