Skip to content

Commit

Permalink
feat: add compat splash screen implementation in the Android app (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeyls authored Mar 6, 2025
1 parent ba2643e commit 30b10ad
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ dependencies {
implementation(libs.kotlinx.coroutines.play.services)

// Support
implementation(libs.androidx.core)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.activity.compose)
implementation(libs.jetbrains.lifecycle.runtime)

Expand Down
1 change: 1 addition & 0 deletions androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
android:launchMode="singleTask"
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AndroidMakers.Starting"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.util.Consumer
import androidx.credentials.ClearCredentialStateRequest
import androidx.credentials.CredentialManager
Expand Down Expand Up @@ -39,6 +40,7 @@ class MainActivity : ComponentActivity() {
}

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

enableEdgeToEdge()
Expand Down
6 changes: 6 additions & 0 deletions androidApp/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.AndroidMakers.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/backgroundDark</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher_foreground</item>
<item name="postSplashScreenTheme">@style/Theme.AndroidMakers</item>
</style>

<style name="Theme.AndroidMakers" parent="android:Theme.Material.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
Expand Down
8 changes: 8 additions & 0 deletions androidApp/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="Theme.AndroidMakers.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/backgroundLight</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher_foreground</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
<item name="postSplashScreenTheme">@style/Theme.AndroidMakers</item>
</style>

<style name="Theme.AndroidMakers" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ androidDesugarJdkLibs = "2.1.5"
androidGradlePlugin = "8.9.0"
androidx-activity = "1.10.1"
androidx-core = "1.15.0"
androidx-core-splashscreen = "1.2.0-beta01"
androidx-credentials = "1.3.0"
androidx-datastore = "1.1.3"
androidx-lifecycle = "2.8.7" # Used by the Wear OS app only
Expand Down Expand Up @@ -40,6 +41,7 @@ playServices-wearable = "19.0.0"
[libraries]
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidx-activity" }
androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core" }
androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "androidx-core-splashscreen" }
androidx-credentials = { group = "androidx.credentials", name = "credentials", version.ref = "androidx-credentials" }
androidx-credentials-playServicesAuth = { group = "androidx.credentials", name = "credentials-play-services-auth", version.ref = "androidx-credentials" }
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "androidx-datastore" }
Expand Down Expand Up @@ -89,7 +91,6 @@ kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-pl
desugar-jdk-libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" }

# Wear dependencies
androidx-splashscreen = "androidx.core:core-splashscreen:1.0.1"
play-services-wearable = { group = "com.google.android.gms", name = "play-services-wearable", version.ref = "playServices-wearable" }
wear-compose-material = { module = "androidx.wear.compose:compose-material", version.ref = "androidx-wear-compose" }
wear-compose-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "androidx-wear-compose" }
Expand Down
2 changes: 1 addition & 1 deletion wearApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ dependencies {
implementation(libs.play.services.wearable)
implementation(libs.play.services.auth)
implementation(libs.androidx.core)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.splashscreen)
implementation(libs.wear.compose.material)
implementation(libs.wear.compose.foundation)
implementation(libs.compose.ui.tooling.preview)
Expand Down

0 comments on commit 30b10ad

Please sign in to comment.