Skip to content

Commit

Permalink
feat: Implement splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Gimbergsson committed Jan 9, 2025
1 parent 96ed159 commit 3d2af4f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ compose-compiler = "1.5.15"
material = "1.12.0"
playServicesWearable = "19.0.0"
playServicesTasks = "18.2.0"
splashscreen = "1.2.0-alpha02"

# KotlinX
corutines = "1.9.0"

[libraries]
androidx-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "ktx" }
androidx-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashscreen" }
androidx-activity = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" }
androidx-fragment = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "fragment" }
androidx-lifecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
Expand Down
1 change: 1 addition & 0 deletions wearos/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ dependencies {
implementation(libs.play.services.tasks)

implementation(libs.androidx.ktx)
implementation(libs.androidx.splashscreen)
implementation(libs.androidx.activity)
implementation(libs.androidx.fragment)
implementation(libs.androidx.lifecycle.runtime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.google.android.gms.wearable.DataClient
import com.google.android.gms.wearable.PutDataMapRequest.create
Expand All @@ -35,6 +36,9 @@ class MainActivity : ComponentActivity() {
private lateinit var dataClient: DataClient

override fun onCreate(savedInstanceState: Bundle?) {
// Handle the splash screen transition.
installSplashScreen()

super.onCreate(savedInstanceState)

dataClient = Wearable.getDataClient(this)
Expand Down
8 changes: 8 additions & 0 deletions wearos/src/main/res/drawable/splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="@dimen/splash_screen_icon_size"
android:height="@dimen/splash_screen_icon_size"
android:drawable="@mipmap/ic_launcher"
android:gravity="center" />
</layer-list>
5 changes: 5 additions & 0 deletions wearos/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="appPrimaryColor">#CCFF00</color>
<color name="appPrimaryColorDark">#AACC00</color>
</resources>
1 change: 1 addition & 0 deletions wearos/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<dimen name="inner_frame_layout_padding">16dp</dimen>
<dimen name="inner_frame_layout_top_padding">24dp</dimen>
<dimen name="spacing_small">4dp</dimen>
<dimen name="splash_screen_icon_size">48dp</dimen>
</resources>
14 changes: 14 additions & 0 deletions wearos/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TennisScoreboardTheme" parent="@android:style/Theme.DeviceDefault">
<item name="colorPrimary">@color/appPrimaryColor</item>
<item name="colorPrimaryDark">@color/appPrimaryColor</item>
<item name="android:colorBackground">@android:color/black</item>
</style>

<style name="Theme.App.Starting" parent="Theme.SplashScreen">">
<item name="windowSplashScreenBackground">@android:color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_screen</item>
<item name="postSplashScreenTheme">@style/TennisScoreboardTheme</item>
</style>
</resources>

0 comments on commit 3d2af4f

Please sign in to comment.