From cef9f6e62bcf698e1b849268fb14750a7427f9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Fri, 13 Oct 2023 11:34:50 +0200 Subject: [PATCH] Remove `getCameraPermissionLauncher` --- .../flashlight/activities/MainActivity.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt index 57d5afb..4318d3e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt @@ -64,8 +64,14 @@ class MainActivity : ComponentActivity() { setContent { AppThemeSurface { val showMoreApps = onEventValue { !resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations) } - val sosPermissionLauncher = getCameraPermissionLauncher(onResult = getPermissionResultHandler(true)) - val stroboscopePermissionLauncher = getCameraPermissionLauncher(onResult = getPermissionResultHandler(false)) + val sosPermissionLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.RequestPermission(), + onResult = getPermissionResultHandler(true) + ) + val stroboscopePermissionLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.RequestPermission(), + onResult = getPermissionResultHandler(false) + ) val sleepTimerCustomDialogState = getSleepTimerCustomDialogState() val sleepTimerDialogState = getSleepTimerDialogState(showCustomSleepTimerDialog = sleepTimerCustomDialogState::show) @@ -235,14 +241,6 @@ class MainActivity : ComponentActivity() { } } - @Composable - private fun getCameraPermissionLauncher( - onResult: (Boolean) -> Unit - ) = rememberLauncherForActivityResult( - contract = ActivityResultContracts.RequestPermission(), - onResult = onResult - ) - @Composable private fun getSleepTimerCustomDialogState() = rememberAlertDialogState().apply { DialogMember {