No need to select Start Automatically again after permission is allowed
Dependencies upgrade
This commit is contained in:
@ -82,6 +82,7 @@ dependencies {
|
|||||||
implementation(libs.androidx.navigation.compose)
|
implementation(libs.androidx.navigation.compose)
|
||||||
implementation(libs.androidx.navigation.runtime.android)
|
implementation(libs.androidx.navigation.runtime.android)
|
||||||
implementation(libs.androidx.lifecycle.process)
|
implementation(libs.androidx.lifecycle.process)
|
||||||
|
implementation(libs.androidx.lifecycle.runtime.compose)
|
||||||
implementation(libs.androidx.lifecycle.viewmodel.ktx)
|
implementation(libs.androidx.lifecycle.viewmodel.ktx)
|
||||||
implementation(libs.androidx.compose.material.icons.core)
|
implementation(libs.androidx.compose.material.icons.core)
|
||||||
implementation(libs.androidx.compose.material.icons.extended)
|
implementation(libs.androidx.compose.material.icons.extended)
|
||||||
|
|||||||
@ -58,6 +58,7 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@ -69,6 +70,7 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
@ -76,6 +78,8 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.core.app.ActivityCompat.shouldShowRequestPermissionRationale
|
import androidx.core.app.ActivityCompat.shouldShowRequestPermissionRationale
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.LifecycleEventObserver
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.NavGraphBuilder
|
import androidx.navigation.NavGraphBuilder
|
||||||
@ -239,6 +243,25 @@ private fun SettingsContent(
|
|||||||
activity: Activity,
|
activity: Activity,
|
||||||
onRestartApp: () -> Unit
|
onRestartApp: () -> Unit
|
||||||
) {
|
) {
|
||||||
|
val ctx = LocalContext.current
|
||||||
|
val lifecycleOwner = LocalLifecycleOwner.current
|
||||||
|
var pendingAutoStart by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
DisposableEffect(lifecycleOwner) {
|
||||||
|
val observer = LifecycleEventObserver { _, event ->
|
||||||
|
if (event == Lifecycle.Event.ON_RESUME) {
|
||||||
|
if (pendingAutoStart && isAppearOnTopPermissionGranted(ctx)) {
|
||||||
|
viewModel.autoStart.value = true
|
||||||
|
pendingAutoStart = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lifecycleOwner.lifecycle.addObserver(observer)
|
||||||
|
onDispose {
|
||||||
|
lifecycleOwner.lifecycle.removeObserver(observer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val alertTitleText = stringResource(R.string.alert)
|
val alertTitleText = stringResource(R.string.alert)
|
||||||
val errorTitleText = stringResource(R.string.error)
|
val errorTitleText = stringResource(R.string.error)
|
||||||
val noticeTitleText = stringResource(R.string.notice)
|
val noticeTitleText = stringResource(R.string.notice)
|
||||||
@ -303,6 +326,7 @@ private fun SettingsContent(
|
|||||||
lastButtonText.value = okButtonText
|
lastButtonText.value = okButtonText
|
||||||
onLastClicked.value = {
|
onLastClicked.value = {
|
||||||
val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
|
val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
|
||||||
|
pendingAutoStart = true
|
||||||
ctx.startActivity(intent)
|
ctx.startActivity(intent)
|
||||||
}
|
}
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
[versions]
|
[versions]
|
||||||
activityCompose = "1.13.0"
|
activityCompose = "1.13.0"
|
||||||
coilCompose = "2.7.0"
|
coilCompose = "2.7.0"
|
||||||
composeBom = "2026.03.01"
|
composeBom = "2026.04.01"
|
||||||
coreKtx = "1.18.0"
|
coreKtx = "1.18.0"
|
||||||
exifinterface = "1.4.2"
|
exifinterface = "1.4.2"
|
||||||
fragmentKtx = "1.8.9"
|
fragmentKtx = "1.8.9"
|
||||||
@ -12,19 +12,20 @@ kotlinSerializationPlugin = "2.3.20"
|
|||||||
kotlinxCoroutinesAndroid = "1.10.2"
|
kotlinxCoroutinesAndroid = "1.10.2"
|
||||||
kotlinxSerializationJson = "1.11.0"
|
kotlinxSerializationJson = "1.11.0"
|
||||||
lifecycleProcess = "2.10.0"
|
lifecycleProcess = "2.10.0"
|
||||||
|
lifecycleRuntimeCompose = "2.10.0"
|
||||||
lifecycleViewmodelKtx = "2.10.0"
|
lifecycleViewmodelKtx = "2.10.0"
|
||||||
material = "1.13.0"
|
material = "1.13.0"
|
||||||
media = "1.7.1"
|
media = "1.7.1"
|
||||||
navigationCompose = "2.9.7"
|
navigationCompose = "2.9.8"
|
||||||
preferenceKtx = "1.2.1"
|
preferenceKtx = "1.2.1"
|
||||||
ui = "1.10.6"
|
ui = "1.11.0"
|
||||||
foundationAndroid = "1.10.6"
|
foundationAndroid = "1.11.0"
|
||||||
runtimeLivedata = "1.10.6"
|
runtimeLivedata = "1.11.0"
|
||||||
composeMaterial3 = "1.4.0"
|
composeMaterial3 = "1.4.0"
|
||||||
navigationRuntimeAndroid = "2.9.7"
|
navigationRuntimeAndroid = "2.9.8"
|
||||||
composeMaterialIcons = "1.7.8"
|
composeMaterialIcons = "1.7.8"
|
||||||
runtime = "1.10.6"
|
runtime = "1.11.0"
|
||||||
uiText = "1.10.6"
|
uiText = "1.11.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
|
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
|
||||||
@ -34,6 +35,7 @@ androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx"
|
|||||||
androidx-exifinterface = { module = "androidx.exifinterface:exifinterface", version.ref = "exifinterface" }
|
androidx-exifinterface = { module = "androidx.exifinterface:exifinterface", version.ref = "exifinterface" }
|
||||||
androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragmentKtx" }
|
androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragmentKtx" }
|
||||||
androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycleProcess" }
|
androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycleProcess" }
|
||||||
|
androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycleRuntimeCompose" }
|
||||||
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" }
|
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" }
|
||||||
androidx-media = { module = "androidx.media:media", version.ref = "media" }
|
androidx-media = { module = "androidx.media:media", version.ref = "media" }
|
||||||
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
|
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
|
||||||
|
|||||||
Reference in New Issue
Block a user