Skip to content

Commit

Permalink
Implement splash screen using Core Splashscreen library
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Nov 21, 2024
1 parent 295f719 commit 9c83226
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 69 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ dependencies {
implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}"
implementation "androidx.work:work-rxjava3:${androidxWorkVersion}"
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.core:core-splashscreen:1.0.1'

/** Third-party libraries **/
// Instance state boilerplate elimination
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
android:label="@string/app_name"
android:logo="@mipmap/ic_launcher"
android:resizeableActivity="true"
android:theme="@style/OpeningTheme"
android:theme="@style/Base.SplashTheme"
tools:ignore="AllowBackup">
<activity
android:name=".MainActivity"
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.splashscreen.SplashScreen;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
Expand Down Expand Up @@ -131,11 +132,14 @@ protected void onCreate(final Bundle savedInstanceState) {
+ "savedInstanceState = [" + savedInstanceState + "]");
}

SplashScreen.installSplashScreen(this);

super.onCreate(savedInstanceState);

ThemeHelper.setDayNightMode(this);
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));

assureCorrectAppLanguage(this);
super.onCreate(savedInstanceState);

mainBinding = ActivityMainBinding.inflate(getLayoutInflater());
drawerLayoutBinding = mainBinding.drawerLayout;
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/res/drawable-night-v23/splash_background.xml

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/main/res/drawable-night/splash_background.xml

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/main/res/drawable-v23/splash_background.xml

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/main/res/drawable/splash_background.xml

This file was deleted.

16 changes: 11 additions & 5 deletions app/src/main/res/drawable/splash_foreground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
android:width="100dp"
android:height="100dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
android:fillColor="#ffffff"
android:pathData="m23.909,10.211v78.869c0,0 7.7,-4.556 12.4,-7.337V67.477,56.739 31.686c0,0 3.707,2.173 8.948,5.24 6.263,3.579 14.57,8.565 21.473,12.655 -9.358,5.483 -16.8,9.876 -22.496,13.234V77.053C57.974,68.927 75.176,58.762 90.762,49.581 75.551,40.634 57.144,29.768 43.467,21.715 31.963,14.94 23.909,10.211 23.909,10.211Z"
android:strokeWidth="1.2782383" />
android:viewportHeight="100"
android:gravity="center">
<group android:scaleX="0.57"
android:scaleY="0.57"
android:translateX="21.5"
android:translateY="21.5">
<path
android:fillColor="#ffffff"
android:pathData="m23.909,10.211v78.869c0,0 7.7,-4.556 12.4,-7.337V67.477,56.739 31.686c0,0 3.707,2.173 8.948,5.24 6.263,3.579 14.57,8.565 21.473,12.655 -9.358,5.483 -16.8,9.876 -22.496,13.234V77.053C57.974,68.927 75.176,58.762 90.762,49.581 75.551,40.634 57.144,29.768 43.467,21.715 31.963,14.94 23.909,10.211 23.909,10.211Z"
android:strokeWidth="1.2782383" />
</group>
</vector>
7 changes: 4 additions & 3 deletions app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- Opening Theme -->
<style name="Base.OpeningTheme" parent="Base.V21.OpeningTheme">
<item name="android:navigationBarColor">@color/dark_youtube_primary_color</item>
<style name="Base.SplashTheme" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenIconBackgroundColor">@color/dark_youtube_primary_color</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_foreground</item>
<item name="postSplashScreenTheme">@style/Base.DarkTheme</item>
</style>

</resources>
15 changes: 4 additions & 11 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
<resources>

<!-- Opening Theme -->
<style name="Base.V21.OpeningTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">@android:color/transparent</item>
<item name="colorPrimaryDark">@android:color/transparent</item>
<item name="colorAccent">@android:color/transparent</item>

<item name="android:windowBackground">@drawable/splash_background</item>
</style>
<style name="Base.OpeningTheme" parent="Base.V21.OpeningTheme">
<item name="android:navigationBarColor">@color/light_youtube_primary_color</item>
<style name="Base.SplashTheme" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenIconBackgroundColor">@color/light_youtube_primary_color</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_foreground</item>
<item name="postSplashScreenTheme">@style/Base.LightTheme</item>
</style>
<style name="OpeningTheme" parent="Base.OpeningTheme" />

<!-- Base Theme -->
<style name="Base.V21" parent="Theme.AppCompat.DayNight.NoActionBar">
Expand Down

0 comments on commit 9c83226

Please sign in to comment.