Implement splash screen using Core Splashscreen library

This commit is contained in:
Isira Seneviratne 2024-10-16 22:04:37 +05:30
parent 13585ca0be
commit d424656dc8
10 changed files with 26 additions and 69 deletions

View File

@ -240,6 +240,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

View File

@ -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"

View File

@ -48,6 +48,7 @@ import androidx.appcompat.app.ActionBar;
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;
@ -131,11 +132,14 @@ public class MainActivity extends AppCompatActivity {
+ "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;

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/dark_youtube_primary_color"/>
<item
android:width="80dp"
android:height="80dp"
android:gravity="center"
android:drawable="@drawable/splash_foreground"/>
</layer-list>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/dark_youtube_primary_color"/>
<item>
<bitmap
android:src="@drawable/ic_newpipe_triangle_white"
android:gravity="center_vertical|center_horizontal" />
</item>
</layer-list>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/light_youtube_primary_color"/>
<item
android:width="80dp"
android:height="80dp"
android:gravity="center"
android:drawable="@drawable/splash_foreground"/>
</layer-list>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/light_youtube_primary_color"/>
<item>
<bitmap
android:src="@drawable/ic_newpipe_triangle_white"
android:gravity="center_vertical|center_horizontal" />
</item>
</layer-list>

View File

@ -2,9 +2,15 @@
android:width="100dp"
android:height="100dp"
android:viewportWidth="100"
android:viewportHeight="100">
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>

View File

@ -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>

View File

@ -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 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="Base.OpeningTheme" parent="Base.V21.OpeningTheme">
<item name="android:navigationBarColor">@color/light_youtube_primary_color</item>
</style>
<style name="OpeningTheme" parent="Base.OpeningTheme" />
<!-- Base Theme -->
<style name="Base.V21" parent="Theme.AppCompat.DayNight.NoActionBar">