From 7e3405f3fd83a970441dfabc2ada225f79175fe0 Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Tue, 13 Aug 2024 16:55:14 -0400 Subject: [PATCH] fix: location disclosure missing --- .../ui/screens/settings/SettingsScreen.kt | 22 +++-- .../BackgroundLocationDisclosure.kt | 95 +++++++++---------- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt index 77bdec4..9b944c3 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt @@ -269,17 +269,19 @@ fun SettingsScreen( if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) { checkFineLocationGranted() } + if(!uiState.isLocationDisclosureShown) { + BackgroundLocationDisclosure( + onDismiss = { viewModel.setLocationDisclosureShown() }, + onAttest = { + context.launchAppSettings() + viewModel.setLocationDisclosureShown() + }, + scrollState, + focusRequester, + ) + return + } - BackgroundLocationDisclosure( - !uiState.isLocationDisclosureShown, - onDismiss = { viewModel.setLocationDisclosureShown() }, - onAttest = { - context.launchAppSettings() - viewModel.setLocationDisclosureShown() - }, - scrollState, - focusRequester, - ) BackgroundLocationDialog( showLocationDialog, diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/components/BackgroundLocationDisclosure.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/components/BackgroundLocationDisclosure.kt index a111437..6f52ec8 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/components/BackgroundLocationDisclosure.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/components/BackgroundLocationDisclosure.kt @@ -29,67 +29,64 @@ import com.zaneschepke.wireguardautotunnel.util.extensions.isRunningOnTv @Composable fun BackgroundLocationDisclosure( - show: Boolean, onDismiss: () -> Unit, onAttest: () -> Unit, scrollState: ScrollState, focusRequester: FocusRequester, ) { val context = LocalContext.current - if (show) { - Column( - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Top, + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Top, + modifier = + Modifier + .fillMaxSize() + .verticalScroll(scrollState), + ) { + Icon( + Icons.Rounded.LocationOff, + contentDescription = stringResource(id = R.string.map), modifier = Modifier - .fillMaxSize() - .verticalScroll(scrollState), - ) { - Icon( - Icons.Rounded.LocationOff, - contentDescription = stringResource(id = R.string.map), - modifier = + .padding(30.dp) + .size(128.dp), + ) + Text( + stringResource(R.string.prominent_background_location_title), + textAlign = TextAlign.Center, + modifier = Modifier.padding(30.dp), + fontSize = 20.sp, + ) + Text( + stringResource(R.string.prominent_background_location_message), + textAlign = TextAlign.Center, + modifier = Modifier.padding(30.dp), + fontSize = 15.sp, + ) + Row( + modifier = + if (context.isRunningOnTv()) { Modifier + .fillMaxWidth() + .padding(10.dp) + } else { + Modifier + .fillMaxWidth() .padding(30.dp) - .size(128.dp), - ) - Text( - stringResource(R.string.prominent_background_location_title), - textAlign = TextAlign.Center, - modifier = Modifier.padding(30.dp), - fontSize = 20.sp, - ) - Text( - stringResource(R.string.prominent_background_location_message), - textAlign = TextAlign.Center, - modifier = Modifier.padding(30.dp), - fontSize = 15.sp, - ) - Row( - modifier = - if (context.isRunningOnTv()) { - Modifier - .fillMaxWidth() - .padding(10.dp) - } else { - Modifier - .fillMaxWidth() - .padding(30.dp) + }, + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceEvenly, + ) { + TextButton(onClick = { onDismiss() }) { + Text(stringResource(id = R.string.no_thanks)) + } + TextButton( + modifier = Modifier.focusRequester(focusRequester), + onClick = { + onAttest() }, - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceEvenly, ) { - TextButton(onClick = { onDismiss() }) { - Text(stringResource(id = R.string.no_thanks)) - } - TextButton( - modifier = Modifier.focusRequester(focusRequester), - onClick = { - onAttest() - }, - ) { - Text(stringResource(id = R.string.turn_on)) - } + Text(stringResource(id = R.string.turn_on)) } } }