From a13109970de94414811f061142b2e81bdfa4f389 Mon Sep 17 00:00:00 2001 From: a1denvalu3 <43107113+a1denvalu3@users.noreply.github.com> Date: Thu, 15 Jan 2026 17:02:26 +0100 Subject: [PATCH] fix(ui): Show acquiring location state instead of unavailable (#621) * fix(ui): Show acquiring location state instead of unavailable This change updates the LocationNotesSheetPresenter to display an 'Acquiring Location' sheet when location permissions are granted but the location is still loading. This prevents the misleading 'Location Unavailable' error on devices with slow GPS start-up (e.g., GrapheneOS). Fixes #578 * Adjust text --------- Co-authored-by: a1denvalu3 <> --- .../android/ui/LocationNotesSheetPresenter.kt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/app/src/main/java/com/bitchat/android/ui/LocationNotesSheetPresenter.kt b/app/src/main/java/com/bitchat/android/ui/LocationNotesSheetPresenter.kt index 850fdfda..df86dbdc 100644 --- a/app/src/main/java/com/bitchat/android/ui/LocationNotesSheetPresenter.kt +++ b/app/src/main/java/com/bitchat/android/ui/LocationNotesSheetPresenter.kt @@ -28,6 +28,8 @@ fun LocationNotesSheetPresenter( val context = LocalContext.current val locationManager = remember { LocationChannelManager.getInstance(context) } val availableChannels by locationManager.availableChannels.collectAsStateWithLifecycle() + val permissionState by locationManager.permissionState.collectAsStateWithLifecycle() + val isLoadingLocation by locationManager.isLoadingLocation.collectAsStateWithLifecycle() val nickname by viewModel.nickname.collectAsStateWithLifecycle() // iOS pattern: notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash @@ -45,6 +47,8 @@ fun LocationNotesSheetPresenter( nickname = nickname, onDismiss = onDismiss ) + } else if (permissionState == LocationChannelManager.PermissionState.AUTHORIZED && isLoadingLocation) { + LocationNotesAcquiringSheet(onDismiss = onDismiss) } else { // No building geohash available - show error state (matches iOS) LocationNotesErrorSheet( @@ -54,6 +58,43 @@ fun LocationNotesSheetPresenter( } } +/** + * Loading sheet when location is being acquired + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +private fun LocationNotesAcquiringSheet( + onDismiss: () -> Unit +) { + BitchatBottomSheet( + onDismissRequest = onDismiss, + ) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(24.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text( + text = "Acquiring Location", + style = MaterialTheme.typography.titleMedium, + color = MaterialTheme.colorScheme.onSurface + ) + Spacer(modifier = Modifier.height(24.dp)) + CircularProgressIndicator( + modifier = Modifier.size(48.dp), + color = MaterialTheme.colorScheme.primary + ) + Spacer(modifier = Modifier.height(24.dp)) + Text( + text = "Please wait while your location is being determined", + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant + ) + } + } +} + /** * Error sheet when location is unavailable */