From 87088138b13305bf95db7a5eee5a7dfb05b7ed69 Mon Sep 17 00:00:00 2001 From: Michael Stillwell Date: Thu, 13 Nov 2025 17:02:47 +0000 Subject: [PATCH] Snippets for /training/wearables/apps/splash-screen --- gradle/libs.versions.toml | 2 +- wear/src/main/AndroidManifest.xml | 17 +++++++++ .../wear/snippets/SplashScreenActivity.kt | 35 +++++++++++++++++++ wear/src/main/res/drawable/splash_screen.xml | 25 +++++++++++++ wear/src/main/res/values/dimens.xml | 22 ++++++++++++ wear/src/main/res/values/styles.xml | 31 ++++++++++++++++ wear/src/main/res_other/values/dimens.xml | 22 ++++++++++++ wear/src/main/res_other/values/styles.xml | 26 ++++++++++++++ 8 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 wear/src/main/java/com/example/wear/snippets/SplashScreenActivity.kt create mode 100644 wear/src/main/res/drawable/splash_screen.xml create mode 100644 wear/src/main/res/values/dimens.xml create mode 100644 wear/src/main/res/values/styles.xml create mode 100644 wear/src/main/res_other/values/dimens.xml create mode 100644 wear/src/main/res_other/values/styles.xml diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3a2de6ba9..7d108273d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -39,7 +39,7 @@ coil = "2.7.0" compileSdk = "36" compose-latest = "1.9.4" composeUiTooling = "1.5.4" -coreSplashscreen = "1.0.1" +coreSplashscreen = "1.2.0" coroutines = "1.10.2" dataStore = "1.1.7" datastoreCore = "1.1.7" diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 9fd910e5d..6b977a557 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -29,6 +29,23 @@ android:label="@string/app_name" android:supportsRtl="true" android:theme="@android:style/Theme.DeviceDefault"> + + + + + + + + + + + + + diff --git a/wear/src/main/java/com/example/wear/snippets/SplashScreenActivity.kt b/wear/src/main/java/com/example/wear/snippets/SplashScreenActivity.kt new file mode 100644 index 000000000..9b336ad39 --- /dev/null +++ b/wear/src/main/java/com/example/wear/snippets/SplashScreenActivity.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.wear.snippets + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen + +// [START android_wear_splash_activity] +class SplashScreenActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + installSplashScreen() + super.onCreate(savedInstanceState) + + setContent { + WearApp() + } + } +} +// [END android_wear_splash_activity] diff --git a/wear/src/main/res/drawable/splash_screen.xml b/wear/src/main/res/drawable/splash_screen.xml new file mode 100644 index 000000000..e449333d0 --- /dev/null +++ b/wear/src/main/res/drawable/splash_screen.xml @@ -0,0 +1,25 @@ + + + + + + + diff --git a/wear/src/main/res/values/dimens.xml b/wear/src/main/res/values/dimens.xml new file mode 100644 index 000000000..093fbc981 --- /dev/null +++ b/wear/src/main/res/values/dimens.xml @@ -0,0 +1,22 @@ + + + + + + 48dp + + diff --git a/wear/src/main/res/values/styles.xml b/wear/src/main/res/values/styles.xml new file mode 100644 index 000000000..30b394fd3 --- /dev/null +++ b/wear/src/main/res/values/styles.xml @@ -0,0 +1,31 @@ + + + + + + + diff --git a/wear/src/main/res_other/values/dimens.xml b/wear/src/main/res_other/values/dimens.xml new file mode 100644 index 000000000..2d1e73370 --- /dev/null +++ b/wear/src/main/res_other/values/dimens.xml @@ -0,0 +1,22 @@ + + + + + + 36dp + + diff --git a/wear/src/main/res_other/values/styles.xml b/wear/src/main/res_other/values/styles.xml new file mode 100644 index 000000000..d0bccfea6 --- /dev/null +++ b/wear/src/main/res_other/values/styles.xml @@ -0,0 +1,26 @@ + + + + + +