react-native-rectangle-doc-scanner 3.182.0 → 3.184.0
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.
|
@@ -315,6 +315,11 @@ class CameraController(
|
|
|
315
315
|
|
|
316
316
|
override fun onError(exception: ImageCaptureException) {
|
|
317
317
|
Log.e(TAG, "Photo capture failed", exception)
|
|
318
|
+
if (exception.imageCaptureError == ImageCapture.ERROR_CAMERA_CLOSED) {
|
|
319
|
+
Log.w(TAG, "Camera was closed during capture, attempting restart")
|
|
320
|
+
stopCamera()
|
|
321
|
+
startCamera(useFrontCamera, true)
|
|
322
|
+
}
|
|
318
323
|
onError(exception)
|
|
319
324
|
}
|
|
320
325
|
}
|
|
@@ -77,12 +77,14 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
77
77
|
previewView = PreviewView(context).apply {
|
|
78
78
|
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
79
79
|
scaleType = PreviewView.ScaleType.FILL_CENTER
|
|
80
|
-
// Use
|
|
81
|
-
implementationMode = PreviewView.ImplementationMode.
|
|
80
|
+
// Use COMPATIBLE (TextureView) for better React Native compatibility
|
|
81
|
+
implementationMode = PreviewView.ImplementationMode.COMPATIBLE
|
|
82
82
|
visibility = View.VISIBLE
|
|
83
83
|
keepScreenOn = true
|
|
84
84
|
// Force view to be drawn
|
|
85
85
|
setWillNotDraw(false)
|
|
86
|
+
// Set a higher z-order to ensure it's visible
|
|
87
|
+
z = 0f
|
|
86
88
|
requestLayout()
|
|
87
89
|
}
|
|
88
90
|
Log.d(TAG, "[INIT] PreviewView created: $previewView")
|
|
@@ -95,7 +97,11 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
95
97
|
|
|
96
98
|
// Create overlay view for drawing rectangle
|
|
97
99
|
Log.d(TAG, "[INIT] Creating OverlayView...")
|
|
98
|
-
overlayView = OverlayView(context)
|
|
100
|
+
overlayView = OverlayView(context).apply {
|
|
101
|
+
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
102
|
+
// Set higher z-order than preview to be drawn on top
|
|
103
|
+
z = 1f
|
|
104
|
+
}
|
|
99
105
|
Log.d(TAG, "[INIT] OverlayView created: $overlayView")
|
|
100
106
|
|
|
101
107
|
Log.d(TAG, "[INIT] Adding OverlayView to parent...")
|
|
@@ -269,6 +275,13 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
269
275
|
return
|
|
270
276
|
}
|
|
271
277
|
|
|
278
|
+
// Ensure lifecycle is active before attempting capture to avoid camera closed errors
|
|
279
|
+
if (lifecycleRegistry.currentState < Lifecycle.State.STARTED) {
|
|
280
|
+
Log.d(TAG, "Lifecycle not STARTED, current state: ${lifecycleRegistry.currentState}")
|
|
281
|
+
promise?.reject("LIFECYCLE_INACTIVE", "Camera preview not ready")
|
|
282
|
+
return
|
|
283
|
+
}
|
|
284
|
+
|
|
272
285
|
isCapturing = true
|
|
273
286
|
Log.d(TAG, "Capture initiated with promise: ${promise != null}")
|
|
274
287
|
|
package/package.json
CHANGED