[Permissions] `MutableMultiplePermissionsState.shouldShowRationale` returns true despite some permissions being `Denied(shouldShowRationale=false)`
Description
The current implementation of MutableMultiplePermissionsState.shouldShowRationale does not consider cases where one or more permissions are Denied(shouldShowRationale=false). This causes issues in statements such as
val permissions = rememberMultiplePermissionsState(listOf(ACCESS_FINE_LOCATION, ACCESS_BACKGROUND_LOCATION))
when {
// Granted
permissions.allPermissionsGranted -> Unit,
// Denied, but I can ask the user
permissions.shouldShowRationale ->
// ERROR: Does not trigger!
permissions.launchMultiplePermissionRequest()
// Denied and I may not ask the user.
else -> Unit
}
The issue is located at
https://github.com/google/accompanist/blob/57907e1c9aadef1f70e51889c04048693e983f21/permissions/src/main/java/com/google/accompanist/permissions/MutableMultiplePermissionsState.kt#L130
Suggested fix:
override val shouldShowRationale: Boolean by derivedStateOf {
- permissions.any { it.status.shouldShowRationale }
+ permissions.any { it.status.shouldShowRationale } && permissions.none { !it.status.isGranted && !it.status.shouldShowRationale }
}
That does make sense. PR's welcome!
I'm also having this issue
However I have issue with this in which shouldShowRationale is never being trigger even I already click don't allow. Check report bugs I have made.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
@bentrengrove as far as I know this has not yet been resolved? Could you please reopen?