feat: add background location permission flow in Location Sharing settings#600
Conversation
Greptile SummaryThis PR introduces a background location permission management flow into the Location Sharing settings: a new Key observations:
Confidence Score: 3/5
Sequence DiagramsequenceDiagram
participant User
participant Indicator as Permission Indicator (LocationSharingCard)
participant Settings as SettingsScreen
participant FgSheet as LocationPermissionBottomSheet
participant BgSheet as BackgroundLocationPermissionBottomSheet
participant System as Android System Dialog
User->>Indicator: Tap row
Indicator->>Settings: onBackgroundPermissionClick()
alt Background already granted
Settings->>System: startActivity(ACTION_APPLICATION_DETAILS_SETTINGS)
Settings-->>User: Toast("Go to Permissions > Location")
else Foreground granted, background not granted
Settings->>BgSheet: showTelemetryBackgroundSheet = true
User->>BgSheet: "Continue"
BgSheet->>System: launch(ACCESS_BACKGROUND_LOCATION)
System-->>Settings: granted → hasBackgroundPermission = true
else No permission at all
Settings->>FgSheet: showTelemetryPermissionSheet = true (pendingTelemetryAction = null)
User->>FgSheet: "Grant Location Access"
FgSheet->>System: launch(ACCESS_FINE_LOCATION)
System-->>Settings: granted → (hasForegroundPermission NOT set here)
Settings->>BgSheet: showTelemetryBackgroundSheet = true
User->>BgSheet: "Continue"
BgSheet->>System: launch(ACCESS_BACKGROUND_LOCATION)
System-->>Settings: granted → hasBackgroundPermission = true
end
Note over Settings: ON_RESUME also refreshes both<br/>hasForegroundPermission &<br/>hasBackgroundPermission
|
app/src/main/java/com/lxmf/messenger/ui/screens/settings/cards/LocationSharingCard.kt
Show resolved
Hide resolved
app/src/main/java/com/lxmf/messenger/ui/screens/SettingsScreen.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/lxmf/messenger/ui/components/BackgroundLocationPermissionBottomSheet.kt
Show resolved
Hide resolved
beb12f0 to
22eecef
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
22eecef to
855e704
Compare
|
@greptile |
app/src/main/java/com/lxmf/messenger/ui/screens/SettingsScreen.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/lxmf/messenger/ui/screens/settings/cards/LocationSharingCard.kt
Show resolved
Hide resolved
…tings - Add BackgroundLocationPermissionBottomSheet component explaining why "Allow all the time" is needed and guiding the user through the two-step Android permission flow - Add clickable permission status indicator in LocationSharingCard showing "Always" or "While using" with tap-to-change - When not granted: show custom bottom sheet then system permission dialog - When granted: open app info with toast guiding to Permissions > Location - Refresh indicator on lifecycle resume (after returning from settings) - Remove background permission flow from MapScreen (foreground only) - Keep background permission flow only in SettingsScreen where location sharing context makes it relevant
855e704 to
9f44725
Compare
Problem
A previous PR resolved issues with background location sending for the Group Tracker feature. However, there was no way for the user to manage the background location permission from within the app. On Android 10+, background location ("Allow all the time") requires a separate permission grant from the standard foreground permission, and the system does not provide a direct intent to open the location permission settings page for an app.
This meant:
Solution
Custom bottom sheet for background permission
A new
BackgroundLocationPermissionBottomSheetcomponent explains to the user why "Allow all the time" is needed (encrypted location sharing in the background) and guides them through the two-step Android permission flow. The user explicitly chooses to proceed or dismiss.Permission status indicator in Location Sharing card
A clickable row in the Location Sharing settings card shows the current background permission state:
The indicator refreshes automatically when returning from system settings (lifecycle ON_RESUME).
Behavior matrix
Changes
BackgroundLocationPermissionBottomSheet.ktSettingsScreen.kt— permission flow wiring + lifecycle refreshLocationSharingCard.kt— clickable permission status indicatorLocationSharingCardTest.kt— added scrollable wrapper for viewport-sensitive tests