Skip to content

Commit 8f04fee

Browse files
authored
Merge pull request libre-tube#7154 from Isira-Seneviratne/Splash-screen
feat: Implement splash screen for older Android versions
2 parents 51bc88d + e2494e8 commit 8f04fee

11 files changed

Lines changed: 61 additions & 41 deletions

File tree

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ dependencies {
9797
implementation(libs.androidx.activity)
9898
implementation(libs.androidx.appcompat)
9999
implementation(libs.androidx.core)
100+
implementation(libs.androidx.core.splashscreen)
100101
implementation(libs.androidx.constraintlayout)
101102
implementation(libs.androidx.fragment)
102103
implementation(libs.androidx.navigation.fragment)

app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.appcompat.widget.SearchView
1818
import androidx.core.content.pm.ShortcutManagerCompat
1919
import androidx.core.net.toUri
2020
import androidx.core.os.bundleOf
21+
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
2122
import androidx.core.view.allViews
2223
import androidx.core.view.children
2324
import androidx.core.view.isNotEmpty
@@ -95,6 +96,7 @@ class MainActivity : BaseActivity() {
9596
}
9697

9798
override fun onCreate(savedInstanceState: Bundle?) {
99+
installSplashScreen()
98100
super.onCreate(savedInstanceState)
99101

100102
// enable auto rotation if turned on

app/src/main/res/drawable/splash_anim.xml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:aapt="http://schemas.android.com/aapt">
3-
<aapt:attr name="android:drawable">
4-
<vector
5-
android:width="64dp"
6-
android:height="64dp"
7-
android:tint="?attr/colorSecondary"
8-
android:viewportWidth="1280"
9-
android:viewportHeight="1280">
10-
<group
11-
android:name="scaleGroup"
12-
android:pivotX="640"
13-
android:pivotY="640">
14-
<path
15-
android:fillColor="#000"
16-
android:pathData="M1130.145 639.54c0-6.202-3.236-11.865-8.358-14.831L225.77 93.247c-15.64-9.168-35.324 2.157-35.324 20.493v229.194c0 8.629 4.584 16.449 11.864 20.762l446.525 255.619c15.91 9.169 15.91 32.358 0 41.525L202.31 916.46c-7.28 4.315-11.864 12.135-11.864 20.763v228.925c0 18.336 19.684 29.93 35.324 20.493l895.747-532.271c5.122-3.236 8.359-8.898 8.359-14.83h0.269Z"
17-
android:strokeWidth="30"
18-
android:strokeColor="#000" />
19-
<path
20-
android:fillColor="#000"
21-
android:pathData="M373.802 625.518c11.325 6.471 11.325 22.92 0 29.391L174.807 769.507c-11.055 6.47-24.807-1.619-24.807-14.561V525.482c0-12.944 13.752-21.033 24.807-14.562l198.995 114.598Z" />
22-
</group>
23-
</vector>
24-
</aapt:attr>
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:drawable="@drawable/splash_icon">
254

265
<target android:name="scaleGroup">
276
<aapt:attr name="android:animation">
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="64dp"
4+
android:height="64dp"
5+
android:tint="@color/splash_screen_icon_color"
6+
android:viewportWidth="1280"
7+
android:viewportHeight="1280">
8+
9+
<group
10+
android:name="scaleGroup"
11+
android:scaleX="0.55"
12+
android:scaleY="0.55"
13+
android:pivotX="640"
14+
android:pivotY="640">
15+
<path
16+
android:fillColor="#000"
17+
android:pathData="M1130.145 639.54c0-6.202-3.236-11.865-8.358-14.831L225.77 93.247c-15.64-9.168-35.324 2.157-35.324 20.493v229.194c0 8.629 4.584 16.449 11.864 20.762l446.525 255.619c15.91 9.169 15.91 32.358 0 41.525L202.31 916.46c-7.28 4.315-11.864 12.135-11.864 20.763v228.925c0 18.336 19.684 29.93 35.324 20.493l895.747-532.271c5.122-3.236 8.359-8.898 8.359-14.83h0.269Z"
18+
android:strokeWidth="30"
19+
android:strokeColor="#000" />
20+
<path
21+
android:fillColor="#000"
22+
android:pathData="M373.802 625.518c11.325 6.471 11.325 22.92 0 29.391L174.807 769.507c-11.055 6.47-24.807-1.619-24.807-14.561V525.482c0-12.944 13.752-21.033 24.807-14.562l198.995 114.598Z" />
23+
</group>
24+
25+
</vector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="StartupTheme" parent="Theme.SplashScreen">
4+
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_anim</item>
5+
<item name="postSplashScreenTheme">@style/BaseTheme</item>
6+
</style>
7+
</resources>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="splash_screen_icon_color">#ccc</color>
4+
</resources>

app/src/main/res/values-night/themes.xml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<style name="BaseTheme" parent="Theme.Material3.Dark.NoActionBar">
44

5-
<item name="android:statusBarColor" tools:targetApi="m">@android:color/transparent</item>
6-
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
5+
<item name="android:statusBarColor">@android:color/transparent</item>
6+
<item name="android:windowLightStatusBar">false</item>
77
<item name="android:navigationBarColor">@android:color/transparent</item>
88
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">false</item>
99

@@ -13,16 +13,12 @@
1313

1414
<item name="snackbarStyle">@style/snackBarStyle</item>
1515

16-
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">
17-
@drawable/splash_anim
18-
</item>
19-
2016
</style>
2117

22-
<style name="StartupTheme" parent="BaseTheme">
18+
<style name="StartupTheme" parent="Theme.SplashScreen">
2319

24-
<item name="android:colorBackground">@android:color/black</item>
25-
<item name="colorSurface">@android:color/black</item>
20+
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
21+
<item name="postSplashScreenTheme">@style/BaseTheme</item>
2622

2723
</style>
2824

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="StartupTheme" parent="Theme.SplashScreen">
4+
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_anim</item>
5+
<item name="postSplashScreenTheme">@style/BaseTheme</item>
6+
</style>
7+
</resources>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<color name="duration_background_color">#AA000000</color>
44
<color name="duration_text_color">#EEFFFFFF</color>
55
<color name="shortcut_color">#0061A6</color>
6+
<color name="splash_screen_icon_color">#222</color>
67

78
<color name="blue_md_theme_light_primary">#0058CB</color>
89
<color name="blue_md_theme_light_onPrimary">#FFFFFF</color>

app/src/main/res/values/themes.xml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<style name="BaseTheme" parent="Theme.Material3.Light.NoActionBar">
44

5-
<item name="android:statusBarColor" tools:targetApi="m">@android:color/transparent</item>
6-
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
5+
<item name="android:statusBarColor">@android:color/transparent</item>
6+
<item name="android:windowLightStatusBar">true</item>
77
<item name="android:navigationBarColor">@android:color/transparent</item>
88
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">true</item>
99

@@ -13,16 +13,12 @@
1313

1414
<item name="snackbarStyle">@style/snackBarStyle</item>
1515

16-
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">
17-
@drawable/splash_anim
18-
</item>
19-
2016
</style>
2117

22-
<style name="StartupTheme" parent="BaseTheme">
18+
<style name="StartupTheme" parent="Theme.SplashScreen">
2319

24-
<item name="android:colorBackground">@android:color/white</item>
25-
<item name="colorSurface">@android:color/white</item>
20+
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
21+
<item name="postSplashScreenTheme">@style/BaseTheme</item>
2622

2723
</style>
2824

0 commit comments

Comments
 (0)