@capgo/camera-preview 8.1.3 → 8.1.4
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.
|
@@ -1520,6 +1520,31 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
|
|
|
1520
1520
|
|
|
1521
1521
|
@Override
|
|
1522
1522
|
public void onCameraStarted(int width, int height, int x, int y) {
|
|
1523
|
+
// Always transition window and WebView backgrounds to transparent when the camera starts,
|
|
1524
|
+
// regardless of whether there is a pending JS call. This is critical for the
|
|
1525
|
+
// background/foreground resume cycle: on resume, handleOnResume() sets backgrounds to
|
|
1526
|
+
// black (to prevent flicker) and then restarts the camera session, but
|
|
1527
|
+
// cameraStartCallbackId is null at that point. Without this unconditional block the
|
|
1528
|
+
// window and WebView stay black after every background/foreground transition.
|
|
1529
|
+
// Both backgrounds are set together in the same UI thread operation to avoid race
|
|
1530
|
+
// conditions and compositor layering issues.
|
|
1531
|
+
if (isToBackMode()) {
|
|
1532
|
+
getBridge()
|
|
1533
|
+
.getActivity()
|
|
1534
|
+
.runOnUiThread(() -> {
|
|
1535
|
+
try {
|
|
1536
|
+
// Set window background to transparent
|
|
1537
|
+
getBridge().getActivity().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
|
1538
|
+
// Set webview background to almost-transparent for MIUI compatibility
|
|
1539
|
+
// Use alpha=1 instead of 0 to work around MIUI/Xiaomi rendering issues
|
|
1540
|
+
// where Color.TRANSPARENT (alpha=0) is not rendered correctly
|
|
1541
|
+
getBridge().getWebView().setBackgroundColor(Color.argb(1, 255, 255, 255));
|
|
1542
|
+
} catch (Exception e) {
|
|
1543
|
+
Log.w(TAG, "Failed to set backgrounds to transparent", e);
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1523
1548
|
PluginCall call = bridge.getSavedCall(cameraStartCallbackId);
|
|
1524
1549
|
if (call != null) {
|
|
1525
1550
|
// Convert pixel values back to logical units
|
|
@@ -1650,26 +1675,6 @@ public class CameraPreview extends Plugin implements CameraXView.CameraXViewList
|
|
|
1650
1675
|
")"
|
|
1651
1676
|
);
|
|
1652
1677
|
|
|
1653
|
-
// Transition window and webview backgrounds to transparent now that camera is ready
|
|
1654
|
-
// This prevents flickering during camera initialization
|
|
1655
|
-
// Both are set together in the same UI thread operation to avoid race conditions
|
|
1656
|
-
if (isToBackMode()) {
|
|
1657
|
-
getBridge()
|
|
1658
|
-
.getActivity()
|
|
1659
|
-
.runOnUiThread(() -> {
|
|
1660
|
-
try {
|
|
1661
|
-
// Set window background to transparent
|
|
1662
|
-
getBridge().getActivity().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
|
1663
|
-
// Set webview background to almost-transparent for MIUI compatibility
|
|
1664
|
-
// Use alpha=1 instead of 0 to work around MIUI/Xiaomi rendering issues
|
|
1665
|
-
// where Color.TRANSPARENT (alpha=0) is not rendered correctly
|
|
1666
|
-
getBridge().getWebView().setBackgroundColor(Color.argb(1, 255, 255, 255));
|
|
1667
|
-
} catch (Exception e) {
|
|
1668
|
-
Log.w(TAG, "Failed to set backgrounds to transparent", e);
|
|
1669
|
-
}
|
|
1670
|
-
});
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
1678
|
call.resolve(result);
|
|
1674
1679
|
bridge.releaseCall(call);
|
|
1675
1680
|
cameraStartCallbackId = null; // Prevent re-use
|
|
@@ -34,7 +34,7 @@ extension UIWindow {
|
|
|
34
34
|
*/
|
|
35
35
|
@objc(CameraPreview)
|
|
36
36
|
public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
|
|
37
|
-
private let pluginVersion: String = "8.1.
|
|
37
|
+
private let pluginVersion: String = "8.1.4"
|
|
38
38
|
public let identifier = "CameraPreviewPlugin"
|
|
39
39
|
public let jsName = "CameraPreview"
|
|
40
40
|
public let pluginMethods: [CAPPluginMethod] = [
|