From 3712668eb0e70e46b7131c281ab12446bf6554d1 Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 9 Oct 2024 12:48:13 +0530 Subject: [PATCH 1/2] Camera: Fix gallery open intent --- app/build.gradle | 2 +- .../sourceforge/opencamera/MainActivity.java | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 61d228d03..fa96ab9e3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -73,7 +73,7 @@ android { defaultConfig { applicationId "foundation.e.camera" - minSdkVersion 26 + minSdkVersion 29 targetSdkVersion 34 //compileSdkVersion 31 // needed to support appcompat:1.4.0 (which we need for emoji policy support, and not yet ready to target SDK 30) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 222b911eb..0f0b8114f 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -5043,7 +5043,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen final String REVIEW_ACTION = "com.android.camera.action.REVIEW"; final String KEY_FROM_SNAPCAM = "from-snapcam"; boolean done = false; - if( !is_raw ) { + if( !is_raw || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) ) { // REVIEW_ACTION means we can view video files without autoplaying. // However, Google Photos at least has problems with going to a RAW photo (in RAW only mode), // unless we first pause and resume Open Camera. @@ -5052,8 +5052,15 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen if( MyDebug.LOG ) Log.d(TAG, "try REVIEW_ACTION"); try { - Intent intent = new Intent(REVIEW_ACTION, uri); - intent.putExtra(KEY_FROM_SNAPCAM, allowEdit); + Intent intent = new Intent(); + intent.setData(uri); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + intent.setAction(REVIEW_ACTION); + intent.putExtra(KEY_FROM_SNAPCAM, allowEdit); + } else { + intent.setAction(MediaStore.ACTION_REVIEW); + intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + } this.startActivity(intent); done = true; } @@ -5066,7 +5073,9 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen Log.d(TAG, "try ACTION_VIEW"); try { Intent intent = new Intent(Intent.ACTION_VIEW, uri); - intent.putExtra(KEY_FROM_SNAPCAM, allowEdit); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + intent.putExtra(KEY_FROM_SNAPCAM, allowEdit); + } this.startActivity(intent); } catch(ActivityNotFoundException e) { -- GitLab From 9b9b3989e91a4b03e5d0add6056aef1d3a7403c9 Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 9 Oct 2024 12:51:58 +0530 Subject: [PATCH 2/2] Camera: Catch a null exception --- .../main/java/net/sourceforge/opencamera/MainActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 0f0b8114f..f58967d2f 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -1504,7 +1504,10 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen for(Map.Entry entry : preloaded_bitmap_resources.entrySet()) { if( MyDebug.LOG ) Log.d(TAG, "recycle: " + entry.getKey()); - entry.getValue().recycle(); + Bitmap recycleValue = entry.getValue(); + if (recycleValue != null) { + recycleValue.recycle(); + } } preloaded_bitmap_resources.clear(); if( textToSpeech != null ) { -- GitLab