capacitor-camera-module 0.0.26 → 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);
@@ -582,5 +590,46 @@ public class CameraModulePlugin extends Plugin {
582
590
  }
583
591
 
584
592
 
593
+ private Bitmap rotateBitmap(Bitmap bitmap, int rotationDegrees) {
594
+ if (rotationDegrees == 0) return bitmap;
595
+
596
+ Matrix matrix = new Matrix();
597
+ matrix.postRotate(rotationDegrees);
598
+
599
+ return Bitmap.createBitmap(
600
+ bitmap,
601
+ 0,
602
+ 0,
603
+ bitmap.getWidth(),
604
+ bitmap.getHeight(),
605
+ matrix,
606
+ true
607
+ );
608
+ }
609
+
610
+
611
+
612
+ private Bitmap mirrorBitmap(Bitmap bitmap) {
613
+ Matrix matrix = new Matrix();
614
+ matrix.preScale(-1, 1);
615
+
616
+ return Bitmap.createBitmap(
617
+ bitmap,
618
+ 0,
619
+ 0,
620
+ bitmap.getWidth(),
621
+ bitmap.getHeight(),
622
+ matrix,
623
+ true
624
+ );
625
+ }
626
+
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
+ }
633
+
585
634
 
586
635
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-camera-module",
3
- "version": "0.0.26",
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",