google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.34k stars 593 forks source link

[Permissions] onPermissionResult could send the PermissionStatus instead of just Boolean #1690

Closed kingsleyadio closed 10 months ago

kingsleyadio commented 1 year ago

Description Currently, when using rememberPermissionState, the onPermissionResult callback is invoked with a boolean. Unfortunately, this doesn't help for the case where I want to know the value of shouldShowRationale. I also don't have access to the PermissionState yet within that callback. This makes it difficult to, for example show a message to the user that directs them to the system permission settings.

Steps to reproduce Current API use:

rememberPermissionState(PERMISSION) { result: Boolean ->
  // result doesn't have enough information
}

Expected behavior onPermissionResult should take the complete PermissionStatus instead

rememberPermissionState(PERMISSION) { result: PermissionStatus ->
  // use permission status here
}

For multiple permission request, the API could similarly use a Map<String, PermissionStatus> instead of just Map<String, Boolean>

Additional context My use case is that: when a requested permission gets denied and showRationale=false, I can safely assume that the permission has likely been denied permanently, which means the only way to enable it is to go to the app settings. I can of course check this value before launching the permission request, but at this point, a permission that was never requested is indistinguishable from a permission that was permanently denied.

malikbilal1997 commented 12 months ago

https://stackoverflow.com/questions/73898807/how-to-handle-runtime-permissions-in-jetpack-compose-properly-by-accompanist @kingsleyadio

github-actions[bot] commented 10 months ago

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.