diff --git a/src/android/SplashScreen.java b/src/android/SplashScreen.java index 16bc769..aa35b2d 100644 --- a/src/android/SplashScreen.java +++ b/src/android/SplashScreen.java @@ -30,6 +30,9 @@ import android.view.Display; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; +import android.view.animation.Animation; +import android.view.animation.AlphaAnimation; +import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; import android.widget.LinearLayout; @@ -197,9 +200,39 @@ public class SplashScreen extends CordovaPlugin { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { if (splashDialog != null && splashDialog.isShowing()) { - splashDialog.dismiss(); - splashDialog = null; - splashImageView = null; + if (preferences.getBoolean("FadeSplashScreen", true)) { + final int splashscreenDuration = (int)(preferences.getDouble("FadeSplashScreenDuration", 2) * 1000); + + AlphaAnimation fadeOut = new AlphaAnimation(1, 0); + fadeOut.setInterpolator(new DecelerateInterpolator()); //add this + fadeOut.setDuration(splashscreenDuration); + + splashImageView.setAnimation(fadeOut); + splashImageView.startAnimation(fadeOut); + + fadeOut.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + } + + @Override + public void onAnimationEnd(Animation animation) { + if (splashDialog != null && splashDialog.isShowing()) { + splashDialog.dismiss(); + splashDialog = null; + splashImageView = null; + } + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + }); + } else { + splashDialog.dismiss(); + splashDialog = null; + splashImageView = null; + } } } });