camera permissions routine

This commit is contained in:
andrekir 2021-11-19 01:20:54 -03:00
parent 14af474b71
commit 062dbbc47d
3 changed files with 28 additions and 7 deletions

View file

@ -28,6 +28,18 @@ fun Context.getMissingPermissions(perms: List<String>) = perms.filter {
) != PackageManager.PERMISSION_GRANTED
}
/**
* Camera permission (or empty if we already have what we need)
*/
fun Context.getCameraPermissions(): List<String> {
val perms = mutableListOf(Manifest.permission.CAMERA)
return getMissingPermissions(perms)
}
/** @return true if the user already has camera permission */
fun Context.hasCameraPermission() = getCameraPermissions().isEmpty()
/**
* A list of missing background location permissions (or empty if we already have what we need)
*/
@ -41,4 +53,4 @@ fun Context.getBackgroundPermissions(): List<String> {
}
/** @return true if the user already has background location permission */
fun Context.hasBackgroundPermission() = getBackgroundPermissions().isEmpty()
fun Context.hasBackgroundPermission() = getBackgroundPermissions().isEmpty()