Skip to content

Commit

Permalink
fix(android): only request permissions to the gallery for Android <= …
Browse files Browse the repository at this point in the history
…9 (API 28)

Context: For Android >= 10, we don't need to request permissions to save the photo to the gallery. More info here: https://developer.android.com/media/camera/camera-deprecated/photobasics#TaskPath

References: https://outsystemsrd.atlassian.net/browse/RMET-3767
  • Loading branch information
alexgerardojacinto committed Oct 24, 2024
1 parent 7280148 commit efc20e8
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,18 @@ private boolean checkCameraPermissions(PluginCall call) {
boolean hasGalleryPerms = getPermissionState(SAVE_GALLERY) == PermissionState.GRANTED;

// If we want to save to the gallery, we need two permissions
if (settings.isSaveToGallery() && !(hasCameraPerms && hasGalleryPerms) && isFirstRequest) {
// actually we only need permissions to save to gallery for Android <= 9 (API 28)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// we might still need to request permission for the camera
if (!hasCameraPerms) {
requestPermissionForAlias(CAMERA, call, "cameraPermissionsCallback");
return false;
}
return true;
}

// we need to request permissions to save to gallery for Android <= 9
else if (settings.isSaveToGallery() && !(hasCameraPerms && hasGalleryPerms) && isFirstRequest) {
isFirstRequest = false;
String[] aliases;
if (needCameraPerms) {
Expand Down

0 comments on commit efc20e8

Please sign in to comment.