Skip to content

Commit

Permalink
feat(android): Add immersive configuration to Splash (#2425)
Browse files Browse the repository at this point in the history
  • Loading branch information
iljadaderko authored Mar 20, 2020
1 parent ac55d63 commit 2605ad6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/Splash.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public interface SplashListener {
public static final int DEFAULT_SHOW_DURATION = 3000;
public static final boolean DEFAULT_AUTO_HIDE = true;
public static final boolean DEFAULT_SPLASH_FULL_SCREEN = false;
public static final boolean DEFAULT_SPLASH_IMMERSIVE = false;

private static ImageView splashImage;
private static ProgressBar spinnerBar;
Expand All @@ -58,11 +59,22 @@ private static void buildViews(Context c) {

// Hide status bar during splash screen.
Boolean splashFullScreen = Config.getBoolean(CONFIG_KEY_PREFIX + "splashFullScreen", DEFAULT_SPLASH_FULL_SCREEN);
if(splashFullScreen){
if(splashFullScreen) {
splashImage.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
}


// Enable immersive mode (hides status bar and navbar) during splash screen.
Boolean splashImmersive = Config.getBoolean(CONFIG_KEY_PREFIX + "splashImmersive", DEFAULT_SPLASH_IMMERSIVE);
if (splashImmersive) {
final int flags = 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;
splashImage.setSystemUiVisibility(flags);
}

// Stops flickers dead in their tracks
// https://stackoverflow.com/a/21847579/32140
splashImage.setDrawingCacheEnabled(true);
Expand Down

0 comments on commit 2605ad6

Please sign in to comment.