capacitor-camera-module 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -56,11 +56,8 @@ import android.graphics.Matrix;
|
|
|
56
56
|
strings = { Manifest.permission.CAMERA }
|
|
57
57
|
),
|
|
58
58
|
@Permission(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Manifest.permission.READ_MEDIA_IMAGES,
|
|
62
|
-
Manifest.permission.READ_EXTERNAL_STORAGE
|
|
63
|
-
}
|
|
59
|
+
alias = "gallery",
|
|
60
|
+
strings = { Manifest.permission.READ_MEDIA_IMAGES }
|
|
64
61
|
)
|
|
65
62
|
}
|
|
66
63
|
)
|
|
@@ -413,8 +410,27 @@ public class CameraModulePlugin extends Plugin {
|
|
|
413
410
|
|
|
414
411
|
@PluginMethod
|
|
415
412
|
public void requestGalleryPermission(PluginCall call) {
|
|
416
|
-
|
|
417
|
-
|
|
413
|
+
String[] permissionsToRequest;
|
|
414
|
+
|
|
415
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
416
|
+
permissionsToRequest = new String[]{ Manifest.permission.READ_MEDIA_IMAGES };
|
|
417
|
+
} else {
|
|
418
|
+
permissionsToRequest = new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE };
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Aquí haces la solicitud manual si no están concedidos
|
|
422
|
+
boolean granted = true;
|
|
423
|
+
for (String perm : permissionsToRequest) {
|
|
424
|
+
if (ContextCompat.checkSelfPermission(getContext(), perm) != PackageManager.PERMISSION_GRANTED) {
|
|
425
|
+
granted = false;
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (!granted) {
|
|
431
|
+
// Guardar el call y pedir permisos
|
|
432
|
+
savedCall = call;
|
|
433
|
+
requestPermissions(permissionsToRequest, "galleryPermissionCallback");
|
|
418
434
|
} else {
|
|
419
435
|
JSObject ret = new JSObject();
|
|
420
436
|
ret.put("granted", true);
|
|
@@ -427,7 +443,13 @@ public class CameraModulePlugin extends Plugin {
|
|
|
427
443
|
@PermissionCallback
|
|
428
444
|
private void galleryPermissionCallback(PluginCall call) {
|
|
429
445
|
JSObject ret = new JSObject();
|
|
430
|
-
|
|
446
|
+
|
|
447
|
+
boolean granted;
|
|
448
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
449
|
+
granted = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED;
|
|
450
|
+
} else {
|
|
451
|
+
granted = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
|
452
|
+
}
|
|
431
453
|
|
|
432
454
|
ret.put("granted", granted);
|
|
433
455
|
ret.put("status", granted ? "granted" : "denied");
|