A fully functional Android app built entirely with Kotlin and Jetpack Compose
Add splashscreen integration
Alex Vanyo063965c9cd26
diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex ed7d996b1..0ce7872b3 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -115,6 +115,7 @@ dependencies {implementation(libs.androidx.activity.compose)implementation(libs.androidx.appcompat)implementation(libs.androidx.core.ktx)+ implementation(libs.androidx.core.splashscreen)implementation(libs.androidx.compose.material3.windowSizeClass)implementation(libs.androidx.window.manager)implementation(libs.androidx.profileinstaller)diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xmlindex f21692f5f..821bc605e 100644--- a/app/src/main/AndroidManifest.xml+++ b/app/src/main/AndroidManifest.xml@@ -27,7 +27,7 @@android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"- android:theme="@style/Theme.Nia">+ android:theme="@style/Theme.Nia.Splash"><profileable android:shell="true" tools:targetApi="q" /><activitydiff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.ktindex 19ec44ad2..e5b86f910 100644--- a/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt+++ b/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt@@ -21,6 +21,7 @@ import androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApiimport androidx.compose.material3.windowsizeclass.calculateWindowSizeClass+import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreenimport androidx.core.view.WindowCompatimport androidx.metrics.performance.JankStatsimport com.google.samples.apps.nowinandroid.ui.NiaApp@@ -38,6 +39,7 @@ class MainActivity : ComponentActivity() {lateinit var lazyStats: dagger.Lazy<JankStats>override fun onCreate(savedInstanceState: Bundle?) {+ installSplashScreen()super.onCreate(savedInstanceState)// Turn off the decor fitting system windows, which allows us to handle insets,diff --git a/app/src/main/res/drawable/ic_splash.xml b/app/src/main/res/drawable/ic_splash.xmlnew file mode 100644index 000000000..291d88677--- /dev/null+++ b/app/src/main/res/drawable/ic_splash.xml@@ -0,0 +1,34 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Copyright 2022 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++ http://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.+-->+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="108dp"+ android:height="108dp"+ android:viewportWidth="108"+ android:viewportHeight="108">++ <path+ android:pathData="M0,0h108v108h-108z"+ android:fillColor="#000000"/>+ <path+ android:pathData="M65.08,84.13C64.01,84.13 63.13,83.26 63.13,82.18C63.13,81.11 64,80.24 65.08,80.24C66.15,80.24 67.02,81.11 67.02,82.18C67.02,83.26 66.15,84.13 65.08,84.13ZM43.6,84.13C42.53,84.13 41.65,83.26 41.65,82.18C41.65,81.11 42.52,80.24 43.6,80.24C44.66,80.24 45.54,81.11 45.54,82.18C45.54,83.26 44.67,84.13 43.6,84.13ZM65.77,72.44L69.66,65.73C69.88,65.35 69.74,64.85 69.36,64.63C68.97,64.41 68.48,64.54 68.25,64.93L64.32,71.73C61.31,70.36 57.94,69.59 54.33,69.59C50.73,69.59 47.35,70.36 44.34,71.73L40.41,64.93C40.19,64.54 39.69,64.41 39.31,64.63C38.92,64.85 38.79,65.35 39.01,65.73L42.89,72.44C36.22,76.07 31.67,82.81 31,90.77H77.67C77,82.8 72.44,76.06 65.77,72.44Z"+ android:fillColor="#FCFCFC"/>+ <path+ android:pathData="M46.57,35H46.57C46.1,35 45.72,35.38 45.72,35.85L45.72,43.15H44.19C43.35,43.15 42.67,43.83 42.67,44.68C42.67,45.52 43.35,46.2 44.19,46.2H45.72V43.15H47.42C48.17,43.15 48.78,42.54 48.78,41.79L48.78,37.72H49.97C50.43,37.72 50.81,37.34 50.81,36.87V35.85C50.81,35.38 50.43,35 49.97,35H47.42H46.57ZM46.57,54.35H46.57H47.42H49.97C50.43,54.35 50.81,53.97 50.81,53.5V52.48C50.81,52.02 50.43,51.64 49.97,51.64H48.78L48.78,47.56C48.78,46.81 48.17,46.2 47.42,46.2H45.72L45.72,53.5C45.72,53.97 46.1,54.35 46.57,54.35ZM61.54,35H61.54C62.01,35 62.39,35.38 62.39,35.85V43.15H63.92C64.76,43.15 65.44,43.83 65.44,44.68C65.44,45.52 64.76,46.2 63.92,46.2H62.39V43.15H60.69C59.94,43.15 59.33,42.54 59.33,41.79V37.72H58.15C57.68,37.72 57.3,37.34 57.3,36.87V35.85C57.3,35.38 57.68,35 58.15,35H60.69H61.54ZM61.54,54.35H61.54H60.69H58.15C57.68,54.35 57.3,53.97 57.3,53.5V52.48C57.3,52.02 57.68,51.64 58.15,51.64H59.33V47.56C59.33,46.81 59.94,46.2 60.69,46.2H62.39V53.5C62.39,53.97 62.01,54.35 61.54,54.35Z"+ android:fillColor="#FCFCFC"+ android:fillType="evenOdd"/>++</vector>\ No newline at end of filediff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xmlindex 461c21cd5..aacfc32bc 100644--- a/app/src/main/res/values-night/themes.xml+++ b/app/src/main/res/values-night/themes.xml@@ -21,4 +21,9 @@<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item></style>+ <style name="NightAdjusted.Splash" parent="Theme.SplashScreen">+ <item name="android:windowLightStatusBar" tools:targetApi="23">false</item>+ <item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>+ </style>+</resources>diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xmlindex 8c7705178..c304f8d16 100644--- a/app/src/main/res/values/themes.xml+++ b/app/src/main/res/values/themes.xml@@ -32,4 +32,14 @@<!-- The final theme we use --><style name="Theme.Nia" parent="PlatformAdjusted.Theme.Nia" />+ <style name="NightAdjusted.Splash" parent="Theme.SplashScreen">+ <item name="android:windowLightStatusBar" tools:targetApi="23">true</item>+ <item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>+ </style>++ <style name="Theme.Nia.Splash" parent="NightAdjusted.Splash">+ <item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash</item>+ <item name="postSplashScreenTheme">@style/Theme.Nia</item>+ </style>+</resources>diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex 0f399c7c1..ecae60313 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -8,6 +8,7 @@ androidxCompose = "1.2.0-rc03"androidxComposeCompiler = "1.2.0"androidxComposeMaterial3 = "1.0.0-alpha13"androidxCore = "1.8.0"+androidxCoreSplashscreen = "1.0.0"androidxCustomView = "1.0.0-rc01"androidxDataStore = "1.0.0"androidxEspresso = "3.4.0"@@ -67,6 +68,7 @@ androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-toolinandroidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview", version.ref = "androidxCompose" }androidx-compose-ui-util = { group = "androidx.compose.ui", name = "ui-util", version.ref = "androidxCompose" }androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" }+androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "androidxCoreSplashscreen" }androidx-customview-poolingcontainer = { group = "androidx.customview", name = "customview-poolingcontainer", version.ref = "androidxCustomView"}androidx-dataStore-core = { group = "androidx.datastore", name = "datastore", version.ref = "androidxDataStore" }androidx-dataStore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "androidxDataStore" }