Skip to content
Permalink
Browse files
CB-9094: Smarter autohide logic on Android
When the plugin is initialized, the splash screen is shown with an
auto-hide delay. If a subsequent call to show() comes in while the
splashscreen is visible, it will still be automatically hidden, even
though the user expectation is that it wouldn't be.

This fix tracks the "hideAfterDelay" setting of the most recent call to
show() -- and when the auto hide timer goes off, if the most recent call
to show() did not set hideAfterDelay, then the splashscreen will not be
automatically hidden.

This provides a more consistent -- and expected -- behavior based on
user action.

https://issues.apache.org/jira/browse/CB-9094

Github: close #49
  • Loading branch information
dpolivy authored and daserge committed Jan 22, 2016
1 parent 7a12204 commit 5b3c2c8b1423eb1f17adf1c89da50edfc46c2406
Showing 1 changed file with 7 additions and 2 deletions.
@@ -51,6 +51,7 @@ public class SplashScreen extends CordovaPlugin {
private static Dialog splashDialog;
private static ProgressDialog spinnerDialog;
private static boolean firstShow = true;
private static boolean lastHideAfterDelay; // https://issues.apache.org/jira/browse/CB-9094

/**
* Displays the splash drawable.
@@ -112,7 +113,7 @@ private boolean isMaintainAspectRatio () {
}

private int getFadeDuration () {
int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) == true ?
int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ?
preferences.getInteger("FadeSplashScreenDuration", DEFAULT_SPLASHSCREEN_DURATION) : 0;

if (fadeSplashScreenDuration < 30) {
@@ -265,6 +266,8 @@ private void showSplashScreen(final boolean hideAfterDelay) {
final int fadeSplashScreenDuration = getFadeDuration();
final int effectiveSplashDuration = splashscreenTime - fadeSplashScreenDuration;

lastHideAfterDelay = hideAfterDelay;

// If the splash dialog is showing don't try to show it again
if (splashDialog != null && splashDialog.isShowing()) {
return;
@@ -317,7 +320,9 @@ public void run() {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
removeSplashScreen();
if (lastHideAfterDelay) {
removeSplashScreen();
}
}
}, effectiveSplashDuration);
}

0 comments on commit 5b3c2c8

Please sign in to comment.