Skip to content

Commit

Permalink
5.1.2 (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek authored Nov 12, 2023
1 parent b562063 commit 43332e5
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -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();
}
});
}
});
}
});
}
});
}
Expand Down Expand Up @@ -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);
}
}
20 changes: 20 additions & 0 deletions android/src/main/res/drawable-v23/compat_splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<item android:gravity="fill">
<color android:color="?attr/bootSplashBackground" />
</item>

<item
android:drawable="?bootSplashLogo"
android:gravity="center"
android:width="288dp"
android:height="288dp" />

<item
android:drawable="?bootSplashBrand"
android:gravity="bottom|center_horizontal"
android:width="200dp"
android:height="80dp"
android:bottom="60dp" />
</layer-list>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
android:width="144dp"
android:height="144dp" />

<item android:gravity="fill" android:bottom="60dp">
<bitmap android:src="?bootSplashBrand" android:gravity="bottom|center_horizontal" />
</item>
<item
android:drawable="?bootSplashBrand"
android:gravity="bottom|center_horizontal"
android:width="200dp"
android:height="80dp"
android:bottom="60dp" />
</layer-list>
4 changes: 0 additions & 4 deletions android/src/main/res/values-v23/styles.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>
<style name="Theme.BootSplash.Branded" parent="Theme.BootSplash.DayNight">
<item name="bootSplashBrand">@null</item>
</style>

<style name="Theme.BootSplash.EdgeToEdge" parent="Theme.BootSplash.EdgeToEdge.Common">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/res/values-v31/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>
<style name="Theme.BootSplash" parent="Theme.BootSplash.Branded">
<style name="Theme.BootSplash" parent="Theme.BootSplash.DayNight">
<item name="android:windowSplashScreenBackground">?bootSplashBackground</item>
<item name="android:windowSplashScreenAnimatedIcon">?bootSplashLogo</item>
<item name="android:windowSplashScreenBrandingImage">?bootSplashBrand</item>
Expand Down
7 changes: 2 additions & 5 deletions android/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@
<style name="Theme.BootSplash.Common" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:opacity">opaque</item>
<item name="android:windowBackground">@drawable/compat_splash_screen</item>
<item name="bootSplashBrand">@drawable/transparent_pixel</item>
</style>

<style name="Theme.BootSplash.DayNight" parent="Theme.BootSplash.Common">
</style>

<style name="Theme.BootSplash.Branded" parent="Theme.BootSplash.DayNight">
<item name="bootSplashBrand">@drawable/transparent_pixel</item>
</style>

<style name="Theme.BootSplash" parent="Theme.BootSplash.Branded">
<style name="Theme.BootSplash" parent="Theme.BootSplash.DayNight">
<item name="bootSplashBackground">?android:colorBackground</item>
<item name="bootSplashLogo">@android:drawable/sym_def_app_icon</item>
<item name="postBootSplashTheme">?android:attr/theme</item>
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ PODS:
- React-jsi (= 0.72.6)
- React-logger (= 0.72.6)
- React-perflogger (= 0.72.6)
- RNBootSplash (5.1.1):
- RNBootSplash (5.1.2):
- React-Core
- SocketRocket (0.6.1)
- Yoga (1.14.0)
Expand Down Expand Up @@ -709,7 +709,7 @@ SPEC CHECKSUMS:
React-runtimescheduler: f23e337008403341177fc52ee4ca94e442c17ede
React-utils: fa59c9a3375fb6f4aeb66714fd3f7f76b43a9f16
ReactCommon: dd03c17275c200496f346af93a7b94c53f3093a4
RNBootSplash: b1af20a3759c440ca1ecb5dfdee2120f2ee1804b
RNBootSplash: e5534cb3ab82a525da2930b3cd377099e4dbc89e
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: b76f1acfda8212aa16b7e26bcce3983230c82603
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-bootsplash",
"version": "5.1.1",
"version": "5.1.2",
"license": "MIT",
"description": "Display a bootsplash on your app starts. Hide it when you want.",
"author": "Mathieu Acthernoene <[email protected]>",
Expand Down

0 comments on commit 43332e5

Please sign in to comment.