capacitor-camera-module 0.0.27 → 0.0.28

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.
@@ -4,8 +4,6 @@ import android.Manifest;
4
4
  import android.os.Build;
5
5
  import android.content.pm.PackageManager;
6
6
 
7
- import androidx.core.content.ContextCompat;
8
-
9
7
  import com.getcapacitor.JSObject;
10
8
  import com.getcapacitor.Plugin;
11
9
  import com.getcapacitor.PluginCall;
@@ -88,6 +86,9 @@ public class CameraModulePlugin extends Plugin {
88
86
 
89
87
  private ImageCapture imageCapture;
90
88
 
89
+ private PluginCall pendingCaptureCall;
90
+
91
+
91
92
  @Override
92
93
  public void load() {
93
94
  super.load();
@@ -464,7 +465,12 @@ public class CameraModulePlugin extends Plugin {
464
465
 
465
466
  @PluginMethod
466
467
  public void checkAndRequestGalleryPermission(PluginCall call) {
467
- if (getPermissionState("gallery") == PermissionState.GRANTED) {
468
+ String alias =
469
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
470
+ ? "gallery_13"
471
+ : "gallery_pre13";
472
+
473
+ if (getPermissionState(alias) == PermissionState.GRANTED) {
468
474
  JSObject ret = new JSObject();
469
475
  ret.put("granted", true);
470
476
  ret.put("status", "granted");
@@ -533,6 +539,8 @@ public class CameraModulePlugin extends Plugin {
533
539
  ) {
534
540
  try {
535
541
  Bitmap bitmap = imageProxyToBitmap(image);
542
+ int rotation = image.getImageInfo().getRotationDegrees();
543
+ bitmap = rotateBitmap(bitmap, rotation);
536
544
  image.close();
537
545
 
538
546
  Bitmap resized = resizeBitmap(bitmap, 1024);
@@ -599,21 +607,7 @@ public class CameraModulePlugin extends Plugin {
599
607
  );
600
608
  }
601
609
 
602
- @Override
603
- public void onCaptureSuccess(@NonNull ImageProxy image) {
604
- Bitmap bitmap = imageProxyToBitmap(image);
605
-
606
- int rotationDegrees = image.getImageInfo().getRotationDegrees();
607
- bitmap = rotateBitmap(bitmap, rotationDegrees);
608
610
 
609
- String base64 = bitmapToBase64(bitmap);
610
-
611
- JSObject ret = new JSObject();
612
- ret.put("base64", base64);
613
-
614
- image.close();
615
- call.resolve(ret);
616
- }
617
611
 
618
612
  private Bitmap mirrorBitmap(Bitmap bitmap) {
619
613
  Matrix matrix = new Matrix();
@@ -630,7 +624,12 @@ public class CameraModulePlugin extends Plugin {
630
624
  );
631
625
  }
632
626
 
633
-
627
+ private String bitmapToBase64(Bitmap bitmap) {
628
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
629
+ bitmap.compress(Bitmap.CompressFormat.JPEG, 80, outputStream);
630
+ byte[] bytes = outputStream.toByteArray();
631
+ return Base64.encodeToString(bytes, Base64.NO_WRAP);
632
+ }
634
633
 
635
634
 
636
635
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-camera-module",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "Plugin to request permissiones view camera take phots",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",