From 87387cc2b8f08c8e85d78e30c54bcf4140507b1d Mon Sep 17 00:00:00 2001 From: Raghav Aggarwal Date: Fri, 17 Nov 2023 15:56:35 +0530 Subject: [PATCH] implement Splash Screen --- app/build.gradle.kts | 4 + app/src/main/AndroidManifest.xml | 4 +- .../com/raghav/spacedawnv2/ui/MainActivity.kt | 6 +- .../res/drawable/ic_launcher_background.xml | 170 ------------------ app/src/main/res/values-v31/themes.xml | 8 + app/src/main/res/values/themes.xml | 6 +- gradle/libs.versions.toml | 8 +- 7 files changed, 30 insertions(+), 176 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/values-v31/themes.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c6021e4..0931820 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -107,6 +107,10 @@ dependencies { // Navigation with Hilt and Compose implementation(libs.hilt.navigation) + // Splash Screen + implementation(libs.splashscreen.core) + + // Test Dependencies testImplementation(libs.test.junit) androidTestImplementation(libs.androidx.test.extensions) androidTestImplementation(libs.androidx.expresso.core) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index efafdd7..5e0e229 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,12 +16,12 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.SpaceDawn" + android:theme="@style/Theme.SpaceDawn.Splash" tools:targetApi="31"> + android:theme="@style/Theme.SpaceDawn.Splash"> diff --git a/app/src/main/java/com/raghav/spacedawnv2/ui/MainActivity.kt b/app/src/main/java/com/raghav/spacedawnv2/ui/MainActivity.kt index 233c6d5..c9c350d 100644 --- a/app/src/main/java/com/raghav/spacedawnv2/ui/MainActivity.kt +++ b/app/src/main/java/com/raghav/spacedawnv2/ui/MainActivity.kt @@ -8,7 +8,6 @@ import androidx.compose.animation.AnimatedContentTransitionScope import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.NavigationBar @@ -29,6 +28,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.navigation.NavDestination import androidx.navigation.NavDestination.Companion.hierarchy import androidx.navigation.NavHostController @@ -52,6 +52,7 @@ import kotlinx.coroutines.launch class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + installSplashScreen() setContent { SpaceDawnTheme { // A surface container using the 'background' color from the theme @@ -66,7 +67,6 @@ class MainActivity : ComponentActivity() { } } -@OptIn(ExperimentalMaterial3Api::class) @Composable fun SpaceDawnApp(modifier: Modifier = Modifier) { val navController = rememberNavController() @@ -86,6 +86,7 @@ fun SpaceDawnApp(modifier: Modifier = Modifier) { startDestination = LaunchesScreen.route, modifier = Modifier.padding(innerPadding) ) { + // Launches Screen composable( LaunchesScreen.route, enterTransition = { @@ -128,6 +129,7 @@ fun SpaceDawnApp(modifier: Modifier = Modifier) { } ) } + // Reminders Screen composable( RemindersScreen.route, enterTransition = { diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/values-v31/themes.xml b/app/src/main/res/values-v31/themes.xml new file mode 100644 index 0000000..5265d5d --- /dev/null +++ b/app/src/main/res/values-v31/themes.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 3e6bb34..e5bf71d 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,5 +1,9 @@ - \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c1ec92f..8ede02f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -41,6 +41,9 @@ coil = "2.4.0" # WorkManager workmanager = "2.8.1" +# Splash Screen +splashscreen_core = "1.0.1" + # Quality ktlint = "11.5.0" @@ -100,6 +103,9 @@ coil = { module = "io.coil-kt:coil-compose", version.ref = "coil" } # WorkManager workmanager = { module = "androidx.work:work-runtime-ktx", version.ref = "workmanager" } +# Splash Screen +splashscreen_core = { module = "androidx.core:core-splashscreen", version.ref = "splashscreen_core" } + # General dependencies kotlin_immutable_collections = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.5" } androidx_annotations = { module = "androidx.annotation:annotation", version = "1.6.0" } @@ -124,7 +130,7 @@ kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin_jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } kotlin_kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } -hilt= { id = "com.google.dagger.hilt.android", version.ref = "hilt" } +hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" }