From 5429de4d5d8c2e904343a57249aa8491283d1148 Mon Sep 17 00:00:00 2001 From: Manuel Vivo Date: Wed, 2 Nov 2022 09:52:11 +0100 Subject: [PATCH 1/2] Fix Permissions docs --- docs/permissions.md | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/docs/permissions.md b/docs/permissions.md index 052710143..cf4b5f38c 100644 --- a/docs/permissions.md +++ b/docs/permissions.md @@ -28,6 +28,7 @@ Both APIs expose properties for you to follow the workflow as described in the The following code exercises the [permission request workflow](https://developer.android.com/training/permissions/requesting#workflow_for_requesting_permissions). ```kotlin +@OptIn(ExperimentalPermissionsApi::class) @Composable private fun FeatureThatRequiresCameraPermission() { @@ -36,28 +37,24 @@ private fun FeatureThatRequiresCameraPermission() { android.Manifest.permission.CAMERA ) - when (cameraPermissionState.status) { - // If the camera permission is granted, then show screen with the feature enabled - PermissionStatus.Granted -> { - Text("Camera permission Granted") - } - is PermissionStatus.Denied -> { - Column { - val textToShow = if (cameraPermissionState.status.shouldShowRationale) { - // If the user has denied the permission but the rationale can be shown, - // then gently explain why the app requires this permission - "The camera is important for this app. Please grant the permission." - } else { - // If it's the first time the user lands on this feature, or the user - // doesn't want to be asked again for this permission, explain that the - // permission is required - "Camera permission required for this feature to be available. " + - "Please grant the permission" - } - Text(textToShow) - Button(onClick = { cameraPermissionState.launchPermissionRequest() }) { - Text("Request permission") - } + if (cameraPermissionState.status.isGranted) { + Text("Camera permission Granted") + } else { + Column { + val textToShow = if (cameraPermissionState.status.shouldShowRationale) { + // If the user has denied the permission but the rationale can be shown, + // then gently explain why the app requires this permission + "The camera is important for this app. Please grant the permission." + } else { + // If it's the first time the user lands on this feature, or the user + // doesn't want to be asked again for this permission, explain that the + // permission is required + "Camera permission required for this feature to be available. " + + "Please grant the permission" + } + Text(textToShow) + Button(onClick = { cameraPermissionState.launchPermissionRequest() }) { + Text("Request permission") } } } From 941f744da14559918b89b7767341fa55c1202dfa Mon Sep 17 00:00:00 2001 From: Manuel Vivo Date: Wed, 2 Nov 2022 10:02:39 +0100 Subject: [PATCH 2/2] Add limitations section --- docs/permissions.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/permissions.md b/docs/permissions.md index cf4b5f38c..d4a6c1f70 100644 --- a/docs/permissions.md +++ b/docs/permissions.md @@ -63,6 +63,13 @@ private fun FeatureThatRequiresCameraPermission() { For more examples, refer to the [samples](https://github.com/google/accompanist/tree/main/sample/src/main/java/com/google/accompanist/sample/permissions). +## Limitations + +This permissions wrapper is built on top of the available Android platform APIs. We cannot extend +the platform's capabilities. For example, it's not possible to differentiate the between the +_it's the first time requesting the permission_ vs _the user doesn't want to be asked again_ +use cases. + ## Download [![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-permissions)](https://search.maven.org/search?q=g:com.google.accompanist)