Skip to content

Commit

Permalink
Add splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Super12138 committed Sep 8, 2024
1 parent 7954ea4 commit 028a434
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies {
// Android X
implementation(libs.androidx.core)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.core.core.splashscreen)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.activity)
implementation(libs.androidx.activity.ktx)
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 @@ -13,7 +13,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ToDo"
android:theme="@style/Theme.ToDo.Starting"
tools:targetApi="35">

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.ComponentCaller
import android.content.Intent
import android.os.Bundle
import android.view.WindowManager
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
import cn.super12138.todo.R
Expand All @@ -15,6 +16,7 @@ import cn.super12138.todo.views.fragments.welcome.WelcomeFragment

class MainActivity : BaseActivity<ActivityMainBinding>() {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)

if (!GlobalValues.welcomePage) {
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="70dp"
android:height="70dp"
android:drawable="@drawable/ic_launcher"
android:gravity="center" />
</layer-list>
10 changes: 10 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
</style>


<style name="Theme.ToDo.Starting" parent="Theme.SplashScreen">
<!-- Splash Screen 背景颜色 -->
<item name="windowSplashScreenBackground">#0061A4</item>
<!-- Splash Screen 图标 -->
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_screen</item>
<!-- 应用默认主题 -->
<item name="postSplashScreenTheme">@style/Theme.ToDo</item>
</style>

<style name="AppPreferenceThemeOverlay" parent="@style/PreferenceThemeOverlay">
<item name="switchPreferenceCompatStyle">@style/AppSwitchPreference</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 @@ -14,6 +14,7 @@ recyclerview = "1.3.2"
fragment = "1.8.3"
fragmentKtx = "1.8.3"
roomRuntime = "2.6.1"
splashScreen = "1.2.0-alpha02"
# Material
material = "1.13.0-alpha05"
# Fast Scroll
Expand All @@ -33,6 +34,7 @@ ksp = "2.0.20-1.0.25"
# Android X
androidx-core = { group = "androidx.core", name = "core", version.ref = "core" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-core-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashScreen" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
androidx-activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activityKtx" }
Expand Down

0 comments on commit 028a434

Please sign in to comment.