Skip to content

Commit

Permalink
perf(android): splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrk committed Nov 27, 2020
1 parent 3b35307 commit 3826337
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 3 deletions.
15 changes: 12 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true" />

<!-- for react-native-bootsplash -->
<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="@style/BootTheme"
android:launchMode="singleTask">
<!-- if you remove this activity pass <intent-filter> to .MainActivity -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

Expand Down
6 changes: 6 additions & 0 deletions android/app/src/main/java/com/appdoki/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

// for react-native-bootsplash
import com.zoontek.rnbootsplash.RNBootSplash;

public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
Expand All @@ -24,6 +27,9 @@ protected String getMainComponentName() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);

// for react-native-bootsplash
RNBootSplash.init(R.drawable.bootsplash, MainActivity.this);
}

// for react-native-gesture-handler
Expand Down
9 changes: 9 additions & 0 deletions android/app/src/main/res/drawable/bootsplash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<item android:drawable="@color/bootsplash_background" />

<item>
<bitmap android:src="@mipmap/bootsplash_logo" android:gravity="center" />
</item>
</layer-list>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<color name="bootsplash_background">#14283C</color>
</resources>
5 changes: 5 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
<item name="android:textColor">#000000</item>
</style>

<!-- form react-native-bootsplash -->
<style name="BootTheme" parent="AppTheme">
<!-- set the generated bootsplash.xml drawable as activity background -->
<item name="android:background">@drawable/bootsplash</item>
</style>
</resources>

0 comments on commit 3826337

Please sign in to comment.