react-native-rectangle-doc-scanner 3.166.0 → 3.168.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.
|
@@ -53,7 +53,9 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
|
|
|
53
53
|
// Create preview view
|
|
54
54
|
previewView = PreviewView(context).apply {
|
|
55
55
|
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
56
|
-
|
|
56
|
+
// Keep the preview visible on devices where the TextureView based mode
|
|
57
|
+
// renders black frames by forcing the SurfaceView implementation.
|
|
58
|
+
implementationMode = PreviewView.ImplementationMode.PERFORMANCE
|
|
57
59
|
}
|
|
58
60
|
addView(previewView)
|
|
59
61
|
|
|
@@ -77,10 +77,19 @@ 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
|
-
|
|
80
|
+
// Some MediaTek based devices render a black TextureView preview when
|
|
81
|
+
// using the COMPATIBLE implementation. Forcing the SurfaceView backed
|
|
82
|
+
// PERFORMANCE mode keeps the preview visible while still allowing us
|
|
83
|
+
// to draw our overlay on top.
|
|
84
|
+
implementationMode = PreviewView.ImplementationMode.PERFORMANCE
|
|
85
|
+
// Force visibility to ensure the view is rendered
|
|
86
|
+
visibility = View.VISIBLE
|
|
87
|
+
// Request layout to ensure proper sizing
|
|
88
|
+
requestLayout()
|
|
81
89
|
}
|
|
82
90
|
Log.d(TAG, "[INIT] PreviewView created: $previewView")
|
|
83
91
|
Log.d(TAG, "[INIT] PreviewView implementationMode: ${previewView.implementationMode}")
|
|
92
|
+
Log.d(TAG, "[INIT] PreviewView visibility: ${previewView.visibility}")
|
|
84
93
|
|
|
85
94
|
Log.d(TAG, "[INIT] Adding PreviewView to parent...")
|
|
86
95
|
addView(previewView)
|
|
@@ -109,15 +118,26 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
109
118
|
Log.d(TAG, "This view: width=$width, height=$height")
|
|
110
119
|
Log.d(TAG, "========================================")
|
|
111
120
|
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
// Update lifecycle
|
|
122
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
|
|
123
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
124
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
125
|
+
|
|
126
|
+
// Wait for view to be laid out before starting camera
|
|
127
|
+
viewTreeObserver.addOnGlobalLayoutListener(object : android.view.ViewTreeObserver.OnGlobalLayoutListener {
|
|
128
|
+
override fun onGlobalLayout() {
|
|
129
|
+
viewTreeObserver.removeOnGlobalLayoutListener(this)
|
|
130
|
+
|
|
131
|
+
if (width > 0 && height > 0 && previewView.width > 0 && previewView.height > 0) {
|
|
132
|
+
Log.d(TAG, "[LAYOUT] View laid out: width=$width, height=$height")
|
|
133
|
+
Log.d(TAG, "[LAYOUT] PreviewView: width=${previewView.width}, height=${previewView.height}")
|
|
134
|
+
setupCamera()
|
|
135
|
+
startCamera()
|
|
136
|
+
} else {
|
|
137
|
+
Log.e(TAG, "[LAYOUT] View or PreviewView has invalid dimensions")
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
})
|
|
121
141
|
}
|
|
122
142
|
|
|
123
143
|
private fun setupCamera() {
|
package/package.json
CHANGED