Add splash screen animation
This commit is contained in:
parent
a44e48d1e1
commit
deff195d1f
7 changed files with 35 additions and 3 deletions
|
@ -15,7 +15,6 @@
|
|||
<option value="$PROJECT_DIR$/shared" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
<entry key="app/src/main/res/drawable-v26/ic_shortcut_pause.xml" value="0.27447916666666666" />
|
||||
<entry key="app/src/main/res/drawable/background_splash.xml" value="0.409375" />
|
||||
<entry key="app/src/main/res/drawable/horizontal_rule.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/drawable/ic_app_logo.xml" value="0.1065" />
|
||||
<entry key="app/src/main/res/drawable/ic_launcher_background.xml" value="0.27447916666666666" />
|
||||
<entry key="app/src/main/res/drawable/ic_pause.xml" value="0.409375" />
|
||||
<entry key="app/src/main/res/drawable/ic_play.xml" value="0.27447916666666666" />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileNotFoundException
|
||||
import java.util.*
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
|
@ -75,6 +75,7 @@ dependencies {
|
|||
kapt(libs.hilt.android.kapt)
|
||||
implementation(libs.androidx.core)
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.androidx.splash)
|
||||
implementation(libs.material)
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
|
||||
implementation("androidx.legacy:legacy-support-v4:1.0.0")
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/Theme.App.Starting">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.wbrawner.pihelper
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowInsetsController
|
||||
import android.view.animation.AnticipateInterpolator
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
@ -22,7 +24,9 @@ import androidx.compose.ui.graphics.ColorFilter
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
|
@ -41,6 +45,7 @@ class MainActivity : AppCompatActivity() {
|
|||
lateinit var store: Store
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
installSplashScreen()
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
val isDarkTheme = isSystemInDarkTheme()
|
||||
|
@ -117,6 +122,23 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
splashScreen.setOnExitAnimationListener { splashScreenView ->
|
||||
listOf(View.SCALE_X, View.SCALE_Y).forEach { axis ->
|
||||
ObjectAnimator.ofFloat(
|
||||
splashScreenView,
|
||||
axis,
|
||||
1f,
|
||||
0.45f
|
||||
).apply {
|
||||
interpolator = AnticipateInterpolator()
|
||||
duration = 200L
|
||||
doOnEnd {
|
||||
splashScreenView.remove()
|
||||
}
|
||||
start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
|
|
@ -10,4 +10,11 @@
|
|||
<style name="AppTheme" parent="BaseTheme">
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
|
||||
<item name="windowSplashScreenBackground">@color/colorSurface</item>
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_app_logo</item>
|
||||
<item name="postSplashScreenTheme">@style/AppTheme</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[versions]
|
||||
androidx-core = "1.3.2"
|
||||
androidx-appcompat = "1.2.0"
|
||||
androidx-splash = "1.0.0-beta02"
|
||||
compose = "1.1.1"
|
||||
coroutines = "1.4.3"
|
||||
espresso = "3.3.0"
|
||||
|
@ -24,6 +25,7 @@ versionName = "1.0"
|
|||
android-gradle = { module = "com.android.tools.build:gradle", version = "7.1.2"}
|
||||
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
|
||||
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
|
||||
androidx-splash = { module = "androidx.core:core-splashscreen", version.ref = "androidx-splash" }
|
||||
compose-activity = { module = "androidx.activity:activity-compose", version = "1.4.0" }
|
||||
compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
|
||||
compose-test = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
|
||||
|
|
Loading…
Reference in a new issue