Skip to content

Commit 74da82c

Browse files
feat: implement new splash screen static version
Signed-off-by: Brian Sztamfater <brian@status.im>
1 parent b70dd2f commit 74da82c

File tree

23 files changed

+115
-25
lines changed

23 files changed

+115
-25
lines changed

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ dependencies {
310310
implementation "com.facebook.react:react-native:+" // From node_modules
311311

312312
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
313+
implementation "androidx.core:core-splashscreen:1.0.0"
313314

314315
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
315316
exclude group:'com.facebook.fbjni'

android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
android:allowBackup="false"
3030
android:label="@string/app_name"
3131
android:icon="@mipmap/ic_launcher"
32-
android:theme="@style/AppTheme"
32+
android:theme="@style/Theme.AppSplash"
3333
android:name=".MainApplication"
3434
android:largeHeap="true"
3535
android:usesCleartextTraffic="true">
@@ -38,6 +38,7 @@
3838
android:name=".MainActivity"
3939
android:exported="true"
4040
android:label="@string/app_name"
41+
android:theme="@style/Theme.AppSplash"
4142
android:screenOrientation="portrait"
4243
android:windowSoftInputMode="adjustResize"
4344
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"

android/app/src/main/java/im/status/ethereum/MainActivity.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.content.res.Configuration;
2222
import android.provider.Settings;
2323
import android.os.Bundle;
24+
import android.os.Handler;
2425
import com.facebook.react.ReactActivityDelegate;
2526
import com.facebook.react.ReactRootView;
2627
import com.facebook.react.modules.core.DeviceEventManagerModule;
@@ -31,7 +32,7 @@
3132
import com.facebook.react.ReactFragmentActivity;
3233
import com.reactnativenavigation.NavigationActivity;
3334
import com.facebook.react.modules.core.PermissionListener;
34-
import org.devio.rn.splashscreen.SplashScreen;
35+
import androidx.core.splashscreen.SplashScreen;
3536

3637
import java.util.Properties;
3738
import im.status.ethereum.module.StatusThreadPoolExecutor;
@@ -42,6 +43,8 @@ public class MainActivity extends NavigationActivity
4243

4344

4445
@Nullable private PermissionListener mPermissionListener;
46+
private boolean keepSplash = true;
47+
private final int SPLASH_DELAY = 3200;
4548

4649
private static void registerUncaughtExceptionHandler(final Context context) {
4750
final Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
@@ -121,21 +124,8 @@ public void onNewIntent(final Intent intent) {
121124

122125
@Override
123126
protected void onCreate(Bundle savedInstanceState) {
124-
125-
switch (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) {
126-
case Configuration.UI_MODE_NIGHT_YES:
127-
setTheme(R.style.DarkTheme);
128-
SplashScreen.show(this, R.style.DarkTheme, R.id.lottie);
129-
break;
130-
case Configuration.UI_MODE_NIGHT_NO:
131-
setTheme(R.style.LightTheme);
132-
SplashScreen.show(this, R.style.LightTheme, R.id.lottie);
133-
break;
134-
default:
135-
setTheme(R.style.LightTheme);
136-
SplashScreen.show(this, R.style.LightTheme, R.id.lottie);
137-
}
138-
SplashScreen.setAnimationFinished(true);
127+
SplashScreen splashScreen = SplashScreen.installSplashScreen(this);
128+
setTheme(R.style.DarkTheme);
139129
// Make sure we get an Alert for every uncaught exceptions
140130
registerUncaughtExceptionHandler(MainActivity.this);
141131

@@ -197,6 +187,11 @@ public void run() {
197187
}
198188
};
199189

190+
splashScreen.setKeepOnScreenCondition(() -> keepSplash);
191+
192+
Handler handler = new Handler();
193+
handler.postDelayed(() -> keepSplash = false, SPLASH_DELAY);
194+
200195
StatusThreadPoolExecutor.getInstance().execute(r);
201196
}
202197

Loading
Loading
Loading
Loading
Loading

android/app/src/main/res/values/colors.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
<resources>
33
<color name="alert_background">#ffffff</color>
44
<color name="alert_text">#000000</color>
5+
<color name="splash_background">#09101C</color>
6+
<color name="splash_status_bar_color">#ffffff</color>
57
</resources>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<resources xmlns:tools="http://schemas.android.com/tools">
2+
<style name="Theme.AppSplash" parent="Theme.SplashScreen">
3+
<item name="windowSplashScreenBackground">@color/splash_background</item>
4+
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_logo</item>
5+
<item name="windowSplashScreenAnimationDuration">1000</item>
6+
7+
<!-- Status bar and Nav bar configs -->
8+
<item name="android:statusBarColor" tools:targetApi="l">@color/splash_background</item>
9+
<item name="android:windowLightStatusBar">false</item>
10+
11+
<item name="postSplashScreenTheme">@style/DarkTheme</item>
12+
</style>
13+
</resources>

0 commit comments

Comments
 (0)