Skip to content

Commit

Permalink
feat(res): Add splash screen
Browse files Browse the repository at this point in the history
#18
* The background color is dynamic, the logo colors cannot be dynamic yet
* https://developer.android.com/develop/ui/views/launch/splash-screen
  • Loading branch information
xLexip committed Nov 9, 2024
1 parent 252ae0d commit 8921ee6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ android {
}

dependencies {
implementation(libs.androidx.core.splashscreen.v100)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.ktx)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Hecate"
android:theme="@style/Theme.App.Starting"
android:usesCleartextTraffic="false"
android:windowSoftInputMode="adjustResize">
<activity
android:name="MainActivity"
android:exported="true"
android:theme="@style/Theme.Hecate">
android:theme="@style/Theme.App.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/dev/lexip/hecate/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import dev.lexip.hecate.ui.theme.HecateTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
enableEdgeToEdge()
setContent {
HecateTheme {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:tint="#C2C6D6"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#C2C6D6">
android:viewportHeight="24">
<group
android:scaleX="0.493"
android:scaleY="0.493"
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.Hecate" parent="android:Theme.Material.Light.NoActionBar" />
<style name="Theme.Hecate" parent="android:Theme.Material.NoActionBar" />

<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="android:windowSplashScreenAnimationDuration">0</item>
<item name="postSplashScreenTheme">@style/Theme.Hecate</item>
<item name="android:windowSplashScreenIconBackgroundColor">#424654</item>
</style>

</resources>
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ agp = "8.7.2"
appcompat = "1.7.0"
composeBom = "2024.10.01"
coreKtx = "1.15.0"
coreSplashscreenVersion = "1.0.1"
espressoCore = "3.6.1"
junit = "4.13.2"
junitVersion = "1.2.1"
Expand All @@ -18,6 +19,7 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-core-splashscreen-v100 = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreenVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
Expand Down

0 comments on commit 8921ee6

Please sign in to comment.