@@ -32,6 +32,7 @@ Licensed to the Apache Software Foundation (ASF) under one
32
32
import android .view .Gravity ;
33
33
import android .view .View ;
34
34
import android .view .ViewGroup .LayoutParams ;
35
+ import android .view .Window ;
35
36
import android .view .WindowManager ;
36
37
import android .view .animation .Animation ;
37
38
import android .view .animation .AlphaAnimation ;
@@ -315,16 +316,48 @@ public void run() {
315
316
316
317
// Create and show the dialog
317
318
splashDialog = new Dialog (context , android .R .style .Theme_Translucent_NoTitleBar );
318
- // check to see if the splash screen should be full screen
319
- if ((cordova .getActivity ().getWindow ().getAttributes ().flags & WindowManager .LayoutParams .FLAG_FULLSCREEN )
320
- == WindowManager .LayoutParams .FLAG_FULLSCREEN ) {
321
- splashDialog .getWindow ().setFlags (WindowManager .LayoutParams .FLAG_FULLSCREEN ,
319
+
320
+ // Check to see if the splash screen should be full screen.
321
+ // On first run, currently cordova hasn't set the window flags yet because it does it in
322
+ // onWindowFocusChanged instead of onCreate. If that's the case, we'll fall back to the
323
+ // Fullscreen preference. Hopefully it will get fixed so that cordova sets them in onCreate,
324
+ // so that this fallback can be removed.
325
+ boolean isFullscreen = false ;
326
+ int mainWindowFlags = cordova .getActivity ().getWindow ().getAttributes ().flags ;
327
+ boolean flagFullscreen = (mainWindowFlags & WindowManager .LayoutParams .FLAG_FULLSCREEN )
328
+ == WindowManager .LayoutParams .FLAG_FULLSCREEN ;
329
+ boolean flagForceNotFullscreen = (mainWindowFlags & WindowManager .LayoutParams .FLAG_FORCE_NOT_FULLSCREEN )
330
+ == WindowManager .LayoutParams .FLAG_FORCE_NOT_FULLSCREEN ;
331
+
332
+ // If cordova has set flags, one of these must be true.
333
+ if (flagFullscreen || flagForceNotFullscreen ) {
334
+ isFullscreen = flagFullscreen ;
335
+ } else {
336
+ // Cordova hasn't set flags, fall back to reading preference.
337
+ isFullscreen = preferences .getBoolean ("Fullscreen" , false );
338
+ }
339
+
340
+ Window dialogWindow = splashDialog .getWindow ();
341
+ if (isFullscreen ) {
342
+ dialogWindow .setFlags (WindowManager .LayoutParams .FLAG_FULLSCREEN ,
322
343
WindowManager .LayoutParams .FLAG_FULLSCREEN );
323
344
}
324
345
splashDialog .setContentView (splashImageView );
325
346
splashDialog .setCancelable (false );
326
347
splashDialog .show ();
327
348
349
+ if (isFullscreen ) {
350
+ // These must be set after .show() is called because they only work on visible views.
351
+ // When the splashscreen hides, the app will revert to whatever was set in CordovaActivity
352
+ dialogWindow .getDecorView ().setSystemUiVisibility (
353
+ View .SYSTEM_UI_FLAG_LAYOUT_STABLE
354
+ | View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
355
+ | View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
356
+ | View .SYSTEM_UI_FLAG_HIDE_NAVIGATION
357
+ | View .SYSTEM_UI_FLAG_FULLSCREEN
358
+ | View .SYSTEM_UI_FLAG_IMMERSIVE_STICKY );
359
+ }
360
+
328
361
if (preferences .getBoolean ("ShowSplashScreenSpinner" , true )) {
329
362
spinnerStart ();
330
363
}
0 commit comments