diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4f548b53..2c3c7dd4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -19,7 +19,13 @@
-
+
+
+
+
+
+
diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt
index 5e79ecb4..d13f74e2 100644
--- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt
@@ -222,7 +222,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun tryInitCamera() {
handlePermission(PERMISSION_CAMERA) { grantedCameraPermission ->
if (grantedCameraPermission) {
- handlePermission(PERMISSION_WRITE_STORAGE) { grantedStoragePermission ->
+ handleStoragePermission { grantedStoragePermission ->
if (grantedStoragePermission) {
if (mIsInPhotoMode) {
initializeCamera()
@@ -249,6 +249,20 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
}
+ private fun handleStoragePermission(callback: (granted: Boolean) -> Unit) {
+ if (isTiramisuPlus()) {
+ handlePermission(PERMISSION_READ_MEDIA_IMAGES) { grantedReadImages ->
+ if (grantedReadImages) {
+ handlePermission(PERMISSION_READ_MEDIA_VIDEO) { grantedReadVideos ->
+ callback.invoke(grantedReadVideos)
+ }
+ }
+ }
+ } else {
+ handlePermission(PERMISSION_WRITE_STORAGE, callback)
+ }
+ }
+
private fun is3rdPartyIntent() = isVideoCaptureIntent() || isImageCaptureIntent()
private fun isImageCaptureIntent(): Boolean = intent?.action == MediaStore.ACTION_IMAGE_CAPTURE || intent?.action == MediaStore.ACTION_IMAGE_CAPTURE_SECURE