From 04e43e3363b7cdf3529c90e81867100703eed879 Mon Sep 17 00:00:00 2001 From: kokitax <122539068+kokitax@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:19:54 +0200 Subject: [PATCH 1/2] Added support for Android SDK 33 and prior versions - Added support for Android SDK 33 and higher - Compatibility with versions prior to Android SDK 33 is maintained - Usage of AndroidX packages --- .../synconset/ImagePicker/ImagePicker.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/android/com/synconset/ImagePicker/ImagePicker.java b/src/android/com/synconset/ImagePicker/ImagePicker.java index b534736a..4e3e4e2a 100644 --- a/src/android/com/synconset/ImagePicker/ImagePicker.java +++ b/src/android/com/synconset/ImagePicker/ImagePicker.java @@ -20,8 +20,8 @@ import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; public class ImagePicker extends CordovaPlugin { @@ -77,13 +77,13 @@ public boolean execute(String action, final JSONArray args, final CallbackContex // some day, when everybody uses a cordova version supporting 'hasPermission', enable this: /* if (cordova != null) { - if (cordova.hasPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) { + if (cordova.hasPermission(Manifest.permission.READ_MEDIA_IMAGES)) { cordova.startActivityForResult(this, imagePickerIntent, 0); } else { cordova.requestPermission( this, PERMISSION_REQUEST_CODE, - Manifest.permission.READ_EXTERNAL_STORAGE + Manifest.permission.READ_MEDIA_IMAGES ); } } @@ -104,17 +104,27 @@ public boolean execute(String action, final JSONArray args, final CallbackContex @SuppressLint("InlinedApi") private boolean hasReadPermission() { - return Build.VERSION.SDK_INT < 23 || - PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this.cordova.getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE); + return (Build.VERSION.SDK_INT < 23 || ( + Build.VERSION.SDK_INT >= 33 + ? PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this.cordova.getActivity(), Manifest.permission.READ_MEDIA_IMAGES) + : PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this.cordova.getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) + )); } @SuppressLint("InlinedApi") private void requestReadPermission() { if (!hasReadPermission()) { - ActivityCompat.requestPermissions( - this.cordova.getActivity(), - new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, - PERMISSION_REQUEST_CODE); + if (Build.VERSION.SDK_INT >= 33) { + ActivityCompat.requestPermissions( + this.cordova.getActivity(), + new String[] {Manifest.permission.READ_MEDIA_IMAGES}, + PERMISSION_REQUEST_CODE); + } else { + ActivityCompat.requestPermissions( + this.cordova.getActivity(), + new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, + PERMISSION_REQUEST_CODE); + } } // This method executes async and we seem to have no known way to receive the result // (that's why these methods were later added to Cordova), so simply returning ok now. @@ -125,9 +135,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && data != null) { int sync = data.getIntExtra("bigdata:synccode", -1); final Bundle bigData = ResultIPC.get().getLargeData(sync); - + ArrayList fileNames = bigData.getStringArrayList("MULTIPLEFILENAMES"); - + JSONArray res = new JSONArray(fileNames); callbackContext.success(res); From 70e0ff24fc715c799a70c669a18bb17ead41b54d Mon Sep 17 00:00:00 2001 From: kokitax <122539068+kokitax@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:27:43 +0200 Subject: [PATCH 2/2] Fix: Overwrite Themes.xml of Android 12 During platform adding --- plugin.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin.xml b/plugin.xml index e9d0e62c..e8fe15ce 100644 --- a/plugin.xml +++ b/plugin.xml @@ -38,7 +38,7 @@ - + @@ -108,6 +108,7 @@ + @@ -139,7 +140,10 @@ - + + +