Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement splash screen for older Android versions #7154

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ dependencies {
implementation(libs.androidx.activity)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.fragment)
implementation(libs.androidx.navigation.fragment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.appcompat.widget.SearchView
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.net.toUri
import androidx.core.os.bundleOf
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.allViews
import androidx.core.view.children
import androidx.core.view.isNotEmpty
Expand Down Expand Up @@ -95,6 +96,7 @@ class MainActivity : BaseActivity() {
}

override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)

// enable auto rotation if turned on
Expand Down
25 changes: 2 additions & 23 deletions app/src/main/res/drawable/splash_anim.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:width="64dp"
android:height="64dp"
android:tint="?attr/colorSecondary"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that this color has been intentionally removed for compatibility reasons?

With the default tint, the background contrast is quite bad on the dark theme with SDK >= 31.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that wasn't being used. Will revert that change and check again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried reverting the tint change, but the icon is always a black icon then, so I kept the change.

android:viewportWidth="1280"
android:viewportHeight="1280">
<group
android:name="scaleGroup"
android:pivotX="640"
android:pivotY="640">
<path
android:fillColor="#000"
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"
android:strokeWidth="30"
android:strokeColor="#000" />
<path
android:fillColor="#000"
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" />
</group>
</vector>
</aapt:attr>
xmlns:aapt="http://schemas.android.com/aapt"
android:drawable="@drawable/splash_icon">

<target android:name="scaleGroup">
<aapt:attr name="android:animation">
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/splash_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="1280"
android:viewportHeight="1280">

<group
android:name="scaleGroup"
android:scaleX="0.55"
android:scaleY="0.55"
android:pivotX="640"
android:pivotY="640">
<path
android:fillColor="#625B70"
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"
android:strokeWidth="30"
android:strokeColor="#625B70" />
<path
android:fillColor="#625B70"
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" />
</group>

</vector>
7 changes: 7 additions & 0 deletions app/src/main/res/values-night-v31/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="StartupTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_anim</item>
<item name="postSplashScreenTheme">@style/BaseTheme</item>
</style>
</resources>
14 changes: 5 additions & 9 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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

<item name="android:statusBarColor" tools:targetApi="m">@android:color/transparent</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">false</item>

Expand All @@ -13,16 +13,12 @@

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

<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">
@drawable/splash_anim
</item>

</style>

<style name="StartupTheme" parent="BaseTheme">
<style name="StartupTheme" parent="Theme.SplashScreen">

<item name="android:colorBackground">@android:color/black</item>
<item name="colorSurface">@android:color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
<item name="postSplashScreenTheme">@style/BaseTheme</item>

</style>

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values-v31/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="StartupTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_anim</item>
<item name="postSplashScreenTheme">@style/BaseTheme</item>
</style>
</resources>
14 changes: 5 additions & 9 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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

<item name="android:statusBarColor" tools:targetApi="m">@android:color/transparent</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">true</item>

Expand All @@ -13,16 +13,12 @@

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

<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">
@drawable/splash_anim
</item>

</style>

<style name="StartupTheme" parent="BaseTheme">
<style name="StartupTheme" parent="Theme.SplashScreen">

<item name="android:colorBackground">@android:color/white</item>
<item name="colorSurface">@android:color/white</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
<item name="postSplashScreenTheme">@style/BaseTheme</item>

</style>

Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ profileinstaller = "1.4.1"
paging = "3.3.6"
collection = "1.4.5"
swiperefreshlayout = "1.1.0"
splashscreen = "1.0.1"

[libraries]
androidx-activity = { group = "androidx.activity", name = "activity-ktx", version.ref = "activity" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
androidx-core = { group = "androidx.core", name = "core", version.ref = "core" }
androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashscreen" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
androidx-fragment = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "fragment" }
gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
Expand Down
Loading