@capgo/camera-preview 7.23.11 → 7.23.13

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.
@@ -322,11 +322,11 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
322
322
  }
323
323
  fusedLocationClient
324
324
  .getLastLocation()
325
- .addOnSuccessListener(getActivity(), location -> {
325
+ .addOnSuccessListener(getActivity(), (location) -> {
326
326
  lastLocation = location;
327
327
  proceedWithCapture(call, lastLocation);
328
328
  })
329
- .addOnFailureListener(e -> {
329
+ .addOnFailureListener((e) -> {
330
330
  Logger.error("Failed to get location: " + e.getMessage());
331
331
  proceedWithCapture(call, null);
332
332
  });
@@ -557,15 +557,14 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
557
557
  return;
558
558
  }
559
559
 
560
- getActivity()
561
- .runOnUiThread(() -> {
562
- try {
563
- cameraXView.setFocus(x, y);
564
- call.resolve();
565
- } catch (Exception e) {
566
- call.reject("Failed to set focus: " + e.getMessage());
567
- }
568
- });
560
+ getActivity().runOnUiThread(() -> {
561
+ try {
562
+ cameraXView.setFocus(x, y);
563
+ call.resolve();
564
+ } catch (Exception e) {
565
+ call.reject("Failed to set focus: " + e.getMessage());
566
+ }
567
+ });
569
568
  }
570
569
 
571
570
  @PluginMethod
@@ -707,7 +706,7 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
707
706
  activity.startActivity(intent);
708
707
  isCameraPermissionDialogShowing = false;
709
708
  })
710
- .setOnDismissListener(d -> isCameraPermissionDialogShowing = false)
709
+ .setOnDismissListener((d) -> isCameraPermissionDialogShowing = false)
711
710
  .create();
712
711
 
713
712
  isCameraPermissionDialogShowing = true;
@@ -976,13 +975,13 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
976
975
  Log.d(
977
976
  "CameraPreview",
978
977
  " - webView margins: left=" +
979
- marginParams.leftMargin +
980
- ", top=" +
981
- marginParams.topMargin +
982
- ", right=" +
983
- marginParams.rightMargin +
984
- ", bottom=" +
985
- marginParams.bottomMargin
978
+ marginParams.leftMargin +
979
+ ", top=" +
980
+ marginParams.topMargin +
981
+ ", right=" +
982
+ marginParams.rightMargin +
983
+ ", bottom=" +
984
+ marginParams.bottomMargin
986
985
  );
987
986
  }
988
987
 
@@ -990,13 +989,13 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
990
989
  Log.d(
991
990
  "CameraPreview",
992
991
  " - webView padding: left=" +
993
- webView.getPaddingLeft() +
994
- ", top=" +
995
- webView.getPaddingTop() +
996
- ", right=" +
997
- webView.getPaddingRight() +
998
- ", bottom=" +
999
- webView.getPaddingBottom()
992
+ webView.getPaddingLeft() +
993
+ ", top=" +
994
+ webView.getPaddingTop() +
995
+ ", right=" +
996
+ webView.getPaddingRight() +
997
+ ", bottom=" +
998
+ webView.getPaddingBottom()
1000
999
  );
1001
1000
 
1002
1001
  Log.d("CameraPreview", " - Using webViewTopInset: " + webViewTopInset);
@@ -1029,11 +1028,11 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1029
1028
  Log.d(
1030
1029
  "CameraPreview",
1031
1030
  "Centering horizontally: screenWidth=" +
1032
- screenWidth +
1033
- ", computedWidth=" +
1034
- computedWidth +
1035
- ", computedX=" +
1036
- computedX
1031
+ screenWidth +
1032
+ ", computedWidth=" +
1033
+ computedWidth +
1034
+ ", computedX=" +
1035
+ computedX
1037
1036
  );
1038
1037
  } else {
1039
1038
  computedX = (int) (x * pixelRatio);
@@ -1054,11 +1053,11 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1054
1053
  Log.d(
1055
1054
  "CameraPreview",
1056
1055
  "Positioning at bottom: screenHeight=" +
1057
- screenHeight +
1058
- ", computedHeight=" +
1059
- computedHeight +
1060
- ", computedY=" +
1061
- computedY
1056
+ screenHeight +
1057
+ ", computedHeight=" +
1058
+ computedHeight +
1059
+ ", computedY=" +
1060
+ computedY
1062
1061
  );
1063
1062
  break;
1064
1063
  case "center":
@@ -1071,13 +1070,13 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1071
1070
  Log.d(
1072
1071
  "CameraPreview",
1073
1072
  "Centering vertically with WebView offset: screenHeight=" +
1074
- screenHeight +
1075
- ", webViewTop=" +
1076
- webViewTopInset +
1077
- ", computedHeight=" +
1078
- computedHeight +
1079
- ", computedY=" +
1080
- computedY
1073
+ screenHeight +
1074
+ ", webViewTop=" +
1075
+ webViewTopInset +
1076
+ ", computedHeight=" +
1077
+ computedHeight +
1078
+ ", computedY=" +
1079
+ computedY
1081
1080
  );
1082
1081
  } else {
1083
1082
  // Normal mode - use full screen height
@@ -1085,11 +1084,11 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1085
1084
  Log.d(
1086
1085
  "CameraPreview",
1087
1086
  "Centering vertically (normal): screenHeight=" +
1088
- screenHeight +
1089
- ", computedHeight=" +
1090
- computedHeight +
1091
- ", computedY=" +
1092
- computedY
1087
+ screenHeight +
1088
+ ", computedHeight=" +
1089
+ computedHeight +
1090
+ ", computedY=" +
1091
+ computedY
1093
1092
  );
1094
1093
  }
1095
1094
  break;
@@ -1103,22 +1102,22 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1103
1102
  Log.d(
1104
1103
  "CameraPreview",
1105
1104
  "Edge-to-edge adjustment: Y position " +
1106
- (int) (y * pixelRatio) +
1107
- " + inset " +
1108
- webViewTopInset +
1109
- " = " +
1110
- computedY
1105
+ (int) (y * pixelRatio) +
1106
+ " + inset " +
1107
+ webViewTopInset +
1108
+ " = " +
1109
+ computedY
1111
1110
  );
1112
1111
  }
1113
1112
  Log.d(
1114
1113
  "CameraPreview",
1115
1114
  "Using provided Y position: " +
1116
- y +
1117
- " * " +
1118
- pixelRatio +
1119
- " = " +
1120
- computedY +
1121
- (isEdgeToEdgeActive ? " (adjusted for edge-to-edge)" : "")
1115
+ y +
1116
+ " * " +
1117
+ pixelRatio +
1118
+ " = " +
1119
+ computedY +
1120
+ (isEdgeToEdgeActive ? " (adjusted for edge-to-edge)" : "")
1122
1121
  );
1123
1122
  }
1124
1123
 
@@ -1190,7 +1189,11 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1190
1189
  lastOrientation = current;
1191
1190
  lastOrientationStr = currentStr;
1192
1191
  // Post to next frame so WebView has updated bounds before we recompute layout
1193
- getBridge().getActivity().getWindow().getDecorView().post(() -> handleOrientationChange());
1192
+ getBridge()
1193
+ .getActivity()
1194
+ .getWindow()
1195
+ .getDecorView()
1196
+ .post(() -> handleOrientationChange());
1194
1197
  }
1195
1198
  }
1196
1199
  };
@@ -1219,15 +1222,15 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1219
1222
  Log.d(
1220
1223
  TAG,
1221
1224
  "Screen dimensions - Pixels: " +
1222
- screenWidthPx +
1223
- "x" +
1224
- screenHeightPx +
1225
- ", DP: " +
1226
- screenWidthDp +
1227
- "x" +
1228
- screenHeightDp +
1229
- ", Density: " +
1230
- density
1225
+ screenWidthPx +
1226
+ "x" +
1227
+ screenHeightPx +
1228
+ ", DP: " +
1229
+ screenWidthDp +
1230
+ "x" +
1231
+ screenHeightDp +
1232
+ ", Density: " +
1233
+ density
1231
1234
  );
1232
1235
 
1233
1236
  // Get WebView dimensions before rotation
@@ -1241,13 +1244,13 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1241
1244
  Log.d(
1242
1245
  TAG,
1243
1246
  "Current preview bounds before rotation: x=" +
1244
- oldBounds[0] +
1245
- ", y=" +
1246
- oldBounds[1] +
1247
- ", width=" +
1248
- oldBounds[2] +
1249
- ", height=" +
1250
- oldBounds[3]
1247
+ oldBounds[0] +
1248
+ ", y=" +
1249
+ oldBounds[1] +
1250
+ ", width=" +
1251
+ oldBounds[2] +
1252
+ ", height=" +
1253
+ oldBounds[3]
1251
1254
  );
1252
1255
 
1253
1256
  getBridge()
@@ -1291,24 +1294,24 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1291
1294
  Log.d(
1292
1295
  TAG,
1293
1296
  "New bounds after orientation change: x=" +
1294
- bounds[0] +
1295
- ", y=" +
1296
- bounds[1] +
1297
- ", width=" +
1298
- bounds[2] +
1299
- ", height=" +
1300
- bounds[3]
1297
+ bounds[0] +
1298
+ ", y=" +
1299
+ bounds[1] +
1300
+ ", width=" +
1301
+ bounds[2] +
1302
+ ", height=" +
1303
+ bounds[3]
1301
1304
  );
1302
1305
  Log.d(
1303
1306
  TAG,
1304
1307
  "Bounds change: deltaX=" +
1305
- (bounds[0] - oldBounds[0]) +
1306
- ", deltaY=" +
1307
- (bounds[1] - oldBounds[1]) +
1308
- ", deltaWidth=" +
1309
- (bounds[2] - oldBounds[2]) +
1310
- ", deltaHeight=" +
1311
- (bounds[3] - oldBounds[3])
1308
+ (bounds[0] - oldBounds[0]) +
1309
+ ", deltaY=" +
1310
+ (bounds[1] - oldBounds[1]) +
1311
+ ", deltaWidth=" +
1312
+ (bounds[2] - oldBounds[2]) +
1313
+ ", deltaHeight=" +
1314
+ (bounds[3] - oldBounds[3])
1312
1315
  );
1313
1316
 
1314
1317
  JSObject data = new JSObject();
@@ -1446,7 +1449,9 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1446
1449
  if (queuedCall != null) {
1447
1450
  PluginCall finalQueuedCall = queuedCall;
1448
1451
  Log.d(TAG, "onCameraStopped: replaying pending start request");
1449
- getBridge().getActivity().runOnUiThread(() -> start(finalQueuedCall));
1452
+ getBridge()
1453
+ .getActivity()
1454
+ .runOnUiThread(() -> start(finalQueuedCall));
1450
1455
  }
1451
1456
  }
1452
1457
 
@@ -1498,13 +1503,13 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1498
1503
  Log.d(
1499
1504
  "CameraPreview",
1500
1505
  "11. RETURNED (logical) - x=" +
1501
- (x / pixelRatio) +
1502
- ", y=" +
1503
- (relativeY / pixelRatio) +
1504
- ", width=" +
1505
- (width / pixelRatio) +
1506
- ", height=" +
1507
- (height / pixelRatio)
1506
+ (x / pixelRatio) +
1507
+ ", y=" +
1508
+ (relativeY / pixelRatio) +
1509
+ ", width=" +
1510
+ (width / pixelRatio) +
1511
+ ", height=" +
1512
+ (height / pixelRatio)
1508
1513
  );
1509
1514
  Log.d("CameraPreview", "12. PIXEL RATIO - " + pixelRatio);
1510
1515
  Log.d("CameraPreview", "========================");
@@ -1529,13 +1534,13 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1529
1534
  Log.d(
1530
1535
  "CameraPreview",
1531
1536
  "Logical values (rounded): x=" +
1532
- Math.round(logicalX) +
1533
- ", y=" +
1534
- Math.round(logicalY) +
1535
- ", width=" +
1536
- Math.round(logicalWidth) +
1537
- ", height=" +
1538
- Math.round(logicalHeight)
1537
+ Math.round(logicalX) +
1538
+ ", y=" +
1539
+ Math.round(logicalY) +
1540
+ ", width=" +
1541
+ Math.round(logicalWidth) +
1542
+ ", height=" +
1543
+ Math.round(logicalHeight)
1539
1544
  );
1540
1545
 
1541
1546
  // Check if previewContainer has any padding or margin that might cause offset
@@ -1545,13 +1550,13 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1545
1550
  Log.d(
1546
1551
  "CameraPreview",
1547
1552
  "PreviewContainer padding: left=" +
1548
- previewContainer.getPaddingLeft() +
1549
- ", top=" +
1550
- previewContainer.getPaddingTop() +
1551
- ", right=" +
1552
- previewContainer.getPaddingRight() +
1553
- ", bottom=" +
1554
- previewContainer.getPaddingBottom()
1553
+ previewContainer.getPaddingLeft() +
1554
+ ", top=" +
1555
+ previewContainer.getPaddingTop() +
1556
+ ", right=" +
1557
+ previewContainer.getPaddingRight() +
1558
+ ", bottom=" +
1559
+ previewContainer.getPaddingBottom()
1555
1560
  );
1556
1561
  ViewGroup.LayoutParams params = previewContainer.getLayoutParams();
1557
1562
  if (params instanceof ViewGroup.MarginLayoutParams) {
@@ -1559,13 +1564,13 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1559
1564
  Log.d(
1560
1565
  "CameraPreview",
1561
1566
  "PreviewContainer margins: left=" +
1562
- marginParams.leftMargin +
1563
- ", top=" +
1564
- marginParams.topMargin +
1565
- ", right=" +
1566
- marginParams.rightMargin +
1567
- ", bottom=" +
1568
- marginParams.bottomMargin
1567
+ marginParams.leftMargin +
1568
+ ", top=" +
1569
+ marginParams.topMargin +
1570
+ ", right=" +
1571
+ marginParams.rightMargin +
1572
+ ", bottom=" +
1573
+ marginParams.bottomMargin
1569
1574
  );
1570
1575
  }
1571
1576
  }
@@ -1576,22 +1581,22 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1576
1581
  Log.d(
1577
1582
  "CameraPreview",
1578
1583
  "Returning to JS - x: " +
1579
- logicalX +
1580
- " (from " +
1581
- logicalX +
1582
- "), y: " +
1583
- logicalY +
1584
- " (from " +
1585
- logicalY +
1586
- "), width: " +
1587
- logicalWidth +
1588
- " (from " +
1589
- logicalWidth +
1590
- "), height: " +
1591
- logicalHeight +
1592
- " (from " +
1593
- logicalHeight +
1594
- ")"
1584
+ logicalX +
1585
+ " (from " +
1586
+ logicalX +
1587
+ "), y: " +
1588
+ logicalY +
1589
+ " (from " +
1590
+ logicalY +
1591
+ "), width: " +
1592
+ logicalWidth +
1593
+ " (from " +
1594
+ logicalWidth +
1595
+ "), height: " +
1596
+ logicalHeight +
1597
+ " (from " +
1598
+ logicalHeight +
1599
+ ")"
1595
1600
  );
1596
1601
 
1597
1602
  call.resolve(result);
@@ -1646,19 +1651,18 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1646
1651
  Float x = call.getFloat("x");
1647
1652
  Float y = call.getFloat("y");
1648
1653
 
1649
- getActivity()
1650
- .runOnUiThread(() -> {
1651
- cameraXView.setAspectRatio(aspectRatio, x, y, () -> {
1652
- // Return the actual preview bounds after layout and camera operations are complete
1653
- int[] bounds = cameraXView.getCurrentPreviewBounds();
1654
- JSObject ret = new JSObject();
1655
- ret.put("x", bounds[0]);
1656
- ret.put("y", bounds[1]);
1657
- ret.put("width", bounds[2]);
1658
- ret.put("height", bounds[3]);
1659
- call.resolve(ret);
1660
- });
1654
+ getActivity().runOnUiThread(() -> {
1655
+ cameraXView.setAspectRatio(aspectRatio, x, y, () -> {
1656
+ // Return the actual preview bounds after layout and camera operations are complete
1657
+ int[] bounds = cameraXView.getCurrentPreviewBounds();
1658
+ JSObject ret = new JSObject();
1659
+ ret.put("x", bounds[0]);
1660
+ ret.put("y", bounds[1]);
1661
+ ret.put("width", bounds[2]);
1662
+ ret.put("height", bounds[3]);
1663
+ call.resolve(ret);
1661
1664
  });
1665
+ });
1662
1666
  }
1663
1667
 
1664
1668
  @PluginMethod
@@ -1680,11 +1684,10 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
1680
1684
  return;
1681
1685
  }
1682
1686
  String gridMode = call.getString("gridMode", "none");
1683
- getActivity()
1684
- .runOnUiThread(() -> {
1685
- cameraXView.setGridMode(gridMode);
1686
- call.resolve();
1687
- });
1687
+ getActivity().runOnUiThread(() -> {
1688
+ cameraXView.setGridMode(gridMode);
1689
+ call.resolve();
1690
+ });
1688
1691
  }
1689
1692
 
1690
1693
  @PluginMethod