@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.
- package/android/src/main/java/app/capgo/capacitor/camera/preview/CameraPreview.java +155 -152
- package/android/src/main/java/app/capgo/capacitor/camera/preview/CameraXView.java +194 -189
- package/android/src/main/java/app/capgo/capacitor/camera/preview/GridOverlayView.java +5 -5
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
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
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
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
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
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
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
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
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
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
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
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
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
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
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
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()
|
|
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
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
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
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
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
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
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
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
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()
|
|
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
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
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
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
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
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
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
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
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
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
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
|
-
.
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
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
|
-
.
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
});
|
|
1687
|
+
getActivity().runOnUiThread(() -> {
|
|
1688
|
+
cameraXView.setGridMode(gridMode);
|
|
1689
|
+
call.resolve();
|
|
1690
|
+
});
|
|
1688
1691
|
}
|
|
1689
1692
|
|
|
1690
1693
|
@PluginMethod
|