From 43332e56c8dc3eb0d04e4bcbcc3ffa4fd9009801 Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Sun, 12 Nov 2023 12:24:20 +0100 Subject: [PATCH] 5.1.2 (#511) --- .../rnbootsplash/RNBootSplashDialog.java | 4 - .../rnbootsplash/RNBootSplashModuleImpl.java | 90 ++++++++++--------- .../res/drawable-v23/compat_splash_screen.xml | 20 +++++ .../compat_splash_screen_oneui_4.xml | 9 +- android/src/main/res/values-v23/styles.xml | 4 - android/src/main/res/values-v31/styles.xml | 2 +- android/src/main/res/values/styles.xml | 7 +- example/ios/Podfile.lock | 4 +- package.json | 2 +- 9 files changed, 80 insertions(+), 62 deletions(-) create mode 100644 android/src/main/res/drawable-v23/compat_splash_screen.xml diff --git a/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java b/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java index 374b2625..179a54cb 100644 --- a/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java +++ b/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java @@ -24,10 +24,6 @@ public RNBootSplashDialog(@NonNull Activity activity, @StyleRes int themeResId, setCanceledOnTouchOutside(false); } - public boolean getFade() { - return mFade; - } - @Override public void onBackPressed() { Activity activity = getOwnerActivity(); diff --git a/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java b/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java index bf543375..3c78cd7e 100644 --- a/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java +++ b/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java @@ -39,7 +39,9 @@ public class RNBootSplashModuleImpl { private static int mThemeResId = -1; @Nullable - private static RNBootSplashDialog mDialog = null; + private static RNBootSplashDialog mInitialDialog = null; + @Nullable + private static RNBootSplashDialog mFadeOutDialog = null; protected static void init( @Nullable final Activity activity, @@ -110,12 +112,12 @@ public void onSplashScreenExit(@NonNull SplashScreenView view) { .setOnExitAnimationListener(listener); } - mDialog = new RNBootSplashDialog(activity, mThemeResId, false); + mInitialDialog = new RNBootSplashDialog(activity, mThemeResId, false); UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { - mDialog.show(new Runnable() { + mInitialDialog.show(new Runnable() { @Override public void run() { mShouldKeepOnScreen = false; @@ -126,14 +128,20 @@ public void run() { } public static void onHostResume() { - if (mDialog != null) { - mDialog.show(); + if (mInitialDialog != null) { + mInitialDialog.show(); + } + if (mFadeOutDialog != null) { + mFadeOutDialog.show(); } } public static void onHostPause() { - if (mDialog != null) { - mDialog.dismiss(); + if (mInitialDialog != null) { + mInitialDialog.dismiss(); + } + if (mFadeOutDialog != null) { + mFadeOutDialog.dismiss(); } } @@ -174,53 +182,51 @@ public void run() { return; } - if (mDialog != null && mDialog.getFade()) { + if (mFadeOutDialog != null) { return; // wait until fade out end for clearPromiseQueue } - if (mDialog == null) { + if (mInitialDialog == null) { clearPromiseQueue(); return; // both initial and fade out dialog are hidden } - final RNBootSplashDialog[] tmp = {mDialog}; - - if (fade) { - // Create a new Dialog instance with fade out animation - mDialog = new RNBootSplashDialog(activity, mThemeResId, true); - - mDialog.show(new Runnable() { - - @Override - public void run() { - tmp[0].dismiss(new Runnable() { - - @Override - public void run() { - tmp[0] = null; - - mDialog.dismiss(new Runnable() { - @Override - public void run() { - mDialog = null; - clearPromiseQueue(); - } - }); - } - }); - } - }); - } else { - mDialog = null; - - tmp[0].dismiss(new Runnable() { + if (!fade) { + mInitialDialog.dismiss(new Runnable() { @Override public void run() { - tmp[0] = null; + mInitialDialog = null; clearPromiseQueue(); } }); + + return; } + + // Create a new Dialog instance with fade out animation + mFadeOutDialog = new RNBootSplashDialog(activity, mThemeResId, true); + + mFadeOutDialog.show(new Runnable() { + + @Override + public void run() { + mInitialDialog.dismiss(new Runnable() { + + @Override + public void run() { + mInitialDialog = null; + + mFadeOutDialog.dismiss(new Runnable() { + @Override + public void run() { + mFadeOutDialog = null; + clearPromiseQueue(); + } + }); + } + }); + } + }); } }); } @@ -274,6 +280,6 @@ public static void hide( } public static void isVisible(final Promise promise) { - promise.resolve(mShouldKeepOnScreen || mDialog != null); + promise.resolve(mShouldKeepOnScreen || mInitialDialog != null || mFadeOutDialog != null); } } diff --git a/android/src/main/res/drawable-v23/compat_splash_screen.xml b/android/src/main/res/drawable-v23/compat_splash_screen.xml new file mode 100644 index 00000000..d8eb7db9 --- /dev/null +++ b/android/src/main/res/drawable-v23/compat_splash_screen.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/android/src/main/res/drawable-v23/compat_splash_screen_oneui_4.xml b/android/src/main/res/drawable-v23/compat_splash_screen_oneui_4.xml index 95e0779a..8463898f 100644 --- a/android/src/main/res/drawable-v23/compat_splash_screen_oneui_4.xml +++ b/android/src/main/res/drawable-v23/compat_splash_screen_oneui_4.xml @@ -13,7 +13,10 @@ android:width="144dp" android:height="144dp" /> - - - + diff --git a/android/src/main/res/values-v23/styles.xml b/android/src/main/res/values-v23/styles.xml index 8eae61e3..738332ae 100644 --- a/android/src/main/res/values-v23/styles.xml +++ b/android/src/main/res/values-v23/styles.xml @@ -1,10 +1,6 @@ - - - - -