capacitor-camera-module 0.0.18 → 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.
|
@@ -34,7 +34,11 @@ import android.net.Uri;
|
|
|
34
34
|
import android.provider.MediaStore;
|
|
35
35
|
import android.util.Base64;
|
|
36
36
|
|
|
37
|
-
import androidx.activity.result.
|
|
37
|
+
import androidx.activity.result.ActivityResultLauncher;
|
|
38
|
+
import androidx.activity.result.contract.ActivityResultContracts;
|
|
39
|
+
|
|
40
|
+
import android.database.Cursor;
|
|
41
|
+
import android.content.ContentUris;
|
|
38
42
|
|
|
39
43
|
import java.io.ByteArrayOutputStream;
|
|
40
44
|
import java.io.InputStream;
|
|
@@ -52,11 +56,8 @@ import android.graphics.Matrix;
|
|
|
52
56
|
strings = { Manifest.permission.CAMERA }
|
|
53
57
|
),
|
|
54
58
|
@Permission(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
Manifest.permission.READ_MEDIA_IMAGES,
|
|
58
|
-
Manifest.permission.READ_EXTERNAL_STORAGE
|
|
59
|
-
}
|
|
59
|
+
alias = "gallery",
|
|
60
|
+
strings = { Manifest.permission.READ_MEDIA_IMAGES }
|
|
60
61
|
)
|
|
61
62
|
}
|
|
62
63
|
)
|
|
@@ -409,8 +410,27 @@ public class CameraModulePlugin extends Plugin {
|
|
|
409
410
|
|
|
410
411
|
@PluginMethod
|
|
411
412
|
public void requestGalleryPermission(PluginCall call) {
|
|
412
|
-
|
|
413
|
-
|
|
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");
|
|
414
434
|
} else {
|
|
415
435
|
JSObject ret = new JSObject();
|
|
416
436
|
ret.put("granted", true);
|
|
@@ -423,7 +443,13 @@ public class CameraModulePlugin extends Plugin {
|
|
|
423
443
|
@PermissionCallback
|
|
424
444
|
private void galleryPermissionCallback(PluginCall call) {
|
|
425
445
|
JSObject ret = new JSObject();
|
|
426
|
-
|
|
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
|
+
}
|
|
427
453
|
|
|
428
454
|
ret.put("granted", granted);
|
|
429
455
|
ret.put("status", granted ? "granted" : "denied");
|