From 14510f1d26653b7b4906f32c47a89f4902a176ca Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 7 Jan 2024 12:32:33 -0500 Subject: [PATCH] Avoid jank in extensions list if install permissions already granted --- .../java/eu/kanade/presentation/browse/ExtensionsScreen.kt | 4 ++-- app/src/main/java/eu/kanade/presentation/util/Permissions.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt index 44ba8167c..5b641235d 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt @@ -133,13 +133,13 @@ private fun ExtensionContent( ) { val context = LocalContext.current var trustState by remember { mutableStateOf(null) } - val installGranted = rememberRequestPackageInstallsPermissionState() + val installGranted = rememberRequestPackageInstallsPermissionState(initialValue = true) FastScrollLazyColumn( contentPadding = contentPadding + topSmallPaddingValues, ) { if (!installGranted && state.installer?.requiresSystemPermission == true) { - item { + item(key = "extension-permissions-warning") { WarningBanner( textRes = MR.strings.ext_permission_install_apps_warning, modifier = Modifier.clickable { diff --git a/app/src/main/java/eu/kanade/presentation/util/Permissions.kt b/app/src/main/java/eu/kanade/presentation/util/Permissions.kt index e3f2df2c8..b4f4f4bd3 100644 --- a/app/src/main/java/eu/kanade/presentation/util/Permissions.kt +++ b/app/src/main/java/eu/kanade/presentation/util/Permissions.kt @@ -14,11 +14,11 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner @Composable -fun rememberRequestPackageInstallsPermissionState(): Boolean { +fun rememberRequestPackageInstallsPermissionState(initialValue: Boolean = false): Boolean { val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current - var installGranted by remember { mutableStateOf(false) } + var installGranted by remember { mutableStateOf(initialValue) } DisposableEffect(lifecycleOwner.lifecycle) { val observer = object : DefaultLifecycleObserver {