Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): Add immersive configuration to Splash #2425

Merged
merged 1 commit into from
Mar 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -56,11 +57,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