11package ru.hepolise.volumekeytrackcontrol.ui
22
3+ import android.animation.AnimatorSet
4+ import android.animation.ObjectAnimator
35import android.annotation.SuppressLint
46import android.content.Context
57import android.content.Intent
68import android.net.Uri
79import android.os.Build
810import android.os.Bundle
911import android.os.Vibrator
12+ import android.view.View
13+ import android.view.animation.AccelerateInterpolator
14+ import android.view.animation.AnticipateInterpolator
1015import android.widget.Toast
1116import androidx.activity.ComponentActivity
1217import androidx.activity.compose.setContent
@@ -73,6 +78,8 @@ import androidx.compose.ui.text.withLink
7378import androidx.compose.ui.tooling.preview.Preview
7479import androidx.compose.ui.unit.dp
7580import androidx.compose.ui.unit.sp
81+ import androidx.core.animation.doOnEnd
82+ import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
7683import ru.hepolise.volumekeytrackcontrol.util.Constants
7784import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.LONG_PRESS_DURATION
7885import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.LONG_PRESS_DURATION_DEFAULT_VALUE
@@ -95,7 +102,34 @@ import ru.hepolise.volumekeytrackcontrolmodule.R
95102
96103class SettingsActivity : ComponentActivity () {
97104 override fun onCreate (savedInstanceState : Bundle ? ) {
105+ val splashscreen = installSplashScreen()
106+ var keepSplashScreen = true
98107 super .onCreate(savedInstanceState)
108+ splashscreen.setKeepOnScreenCondition { keepSplashScreen }
109+ keepSplashScreen = false
110+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .S ) {
111+ splashScreen.setOnExitAnimationListener { splashScreenView ->
112+ val scaleX = ObjectAnimator .ofFloat(splashScreenView, View .SCALE_X , 1f , 0.6f )
113+ val scaleY = ObjectAnimator .ofFloat(splashScreenView, View .SCALE_Y , 1f , 0.6f )
114+
115+ val fadeOut = ObjectAnimator .ofFloat(splashScreenView, View .ALPHA , 1f , 0f )
116+
117+ scaleX.interpolator = AnticipateInterpolator ()
118+ scaleY.interpolator = AnticipateInterpolator ()
119+ fadeOut.interpolator = AccelerateInterpolator ()
120+
121+ val duration = 400L
122+ scaleX.duration = duration
123+ scaleY.duration = duration
124+ fadeOut.duration = duration
125+
126+ AnimatorSet ().apply {
127+ playTogether(scaleX, scaleY, fadeOut)
128+ doOnEnd { splashScreenView.remove() }
129+ start()
130+ }
131+ }
132+ }
99133 enableEdgeToEdge()
100134 setContent {
101135 MaterialTheme (
0 commit comments