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 @@
-
+
+
+
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);