From 3cd637ac418eb8e7dc76135b9011bb87cf13f712 Mon Sep 17 00:00:00 2001 From: althafvly Date: Sat, 12 Nov 2022 10:37:02 +0530 Subject: [PATCH] camera: Fix wrong file uri sent in intent. - Delete option in gallery became unusable - Disable edit only if uri is not accessible at all. --- .../sourceforge/opencamera/MainActivity.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 3ac6dee0e..d96073feb 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -4156,8 +4156,9 @@ public class MainActivity extends AppCompatActivity { if( MyDebug.LOG ) Log.d(TAG, "openGallery"); //Intent intent = new Intent(Intent.ACTION_VIEW, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); - Uri uri = applicationInterface.getStorageUtils().getLastMediaScanned(); - boolean is_raw = uri != null && applicationInterface.getStorageUtils().getLastMediaScannedIsRaw(); + Uri primaryUri = applicationInterface.getStorageUtils().getLastMediaScanned(); + Uri uri = null; + boolean is_raw = false; if( MyDebug.LOG && uri != null ) { Log.d(TAG, "found cached most recent uri: " + uri); Log.d(TAG, " is_raw: " + is_raw); @@ -4208,6 +4209,14 @@ public class MainActivity extends AppCompatActivity { uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; is_raw = false; } + + boolean allowEdit = true; + if( uri == null ) { + uri = primaryUri; + is_raw = uri != null && applicationInterface.getStorageUtils().getLastMediaScannedIsRaw(); + allowEdit = false; + } + if( !is_test ) { // don't do if testing, as unclear how to exit activity to finish test (for testGallery()) if( MyDebug.LOG ) @@ -4225,7 +4234,7 @@ public class MainActivity extends AppCompatActivity { Log.d(TAG, "try REVIEW_ACTION"); try { Intent intent = new Intent(REVIEW_ACTION, uri); - intent.putExtra(KEY_FROM_SNAPCAM, true); + intent.putExtra(KEY_FROM_SNAPCAM, allowEdit); this.startActivity(intent); done = true; } @@ -4238,7 +4247,7 @@ public class MainActivity extends AppCompatActivity { Log.d(TAG, "try ACTION_VIEW"); try { Intent intent = new Intent(Intent.ACTION_VIEW, uri); - intent.putExtra(KEY_FROM_SNAPCAM, true); + intent.putExtra(KEY_FROM_SNAPCAM, allowEdit); this.startActivity(intent); } catch(ActivityNotFoundException e) { -- GitLab