Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies {
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3:1.3.1")
implementation("androidx.core:core-splashscreen:1.0.1")

// Required for preview support
debugImplementation("androidx.compose.ui:ui-tooling")
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@android:style/Theme.Material.NoActionBar"
android:theme="@style/Theme.App.Starting"
android:enableOnBackInvokedCallback="true"
tools:targetApi="tiramisu">

<!-- Main activity -->
<activity
android:name="ru.hepolise.volumekeytrackcontrol.ui.SettingsActivity"
android:exported="true"
android:theme="@android:style/Theme.Material.NoActionBar">
android:theme="@style/Theme.App.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package ru.hepolise.volumekeytrackcontrol.ui

import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Vibrator
import android.view.View
import android.view.animation.AccelerateInterpolator
import android.view.animation.AnticipateInterpolator
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand Down Expand Up @@ -73,6 +78,8 @@ import androidx.compose.ui.text.withLink
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.animation.doOnEnd
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import ru.hepolise.volumekeytrackcontrol.util.Constants
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.LONG_PRESS_DURATION
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.LONG_PRESS_DURATION_DEFAULT_VALUE
Expand All @@ -95,7 +102,34 @@ import ru.hepolise.volumekeytrackcontrolmodule.R

class SettingsActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
val splashscreen = installSplashScreen()
var keepSplashScreen = true
super.onCreate(savedInstanceState)
splashscreen.setKeepOnScreenCondition { keepSplashScreen }
keepSplashScreen = false
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
splashScreen.setOnExitAnimationListener { splashScreenView ->
val scaleX = ObjectAnimator.ofFloat(splashScreenView, View.SCALE_X, 1f, 0.6f)
val scaleY = ObjectAnimator.ofFloat(splashScreenView, View.SCALE_Y, 1f, 0.6f)

val fadeOut = ObjectAnimator.ofFloat(splashScreenView, View.ALPHA, 1f, 0f)

scaleX.interpolator = AnticipateInterpolator()
scaleY.interpolator = AnticipateInterpolator()
fadeOut.interpolator = AccelerateInterpolator()

val duration = 400L
scaleX.duration = duration
scaleY.duration = duration
fadeOut.duration = duration

AnimatorSet().apply {
playTogether(scaleX, scaleY, fadeOut)
doOnEnd { splashScreenView.remove() }
start()
}
}
}
enableEdgeToEdge()
setContent {
MaterialTheme(
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher_foreground</item>
<item name="postSplashScreenTheme">@android:style/Theme.Material.NoActionBar</item>
</style>
</resources>