react-native-rectangle-doc-scanner 3.167.0 → 3.169.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.
|
@@ -77,14 +77,17 @@ 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
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
// to
|
|
84
|
-
|
|
80
|
+
// Use COMPATIBLE (TextureView) mode instead of PERFORMANCE (SurfaceView)
|
|
81
|
+
// Some devices have issues with SurfaceView not creating the surface in time
|
|
82
|
+
implementationMode = PreviewView.ImplementationMode.COMPATIBLE
|
|
83
|
+
// Force visibility to ensure the view is rendered
|
|
84
|
+
visibility = View.VISIBLE
|
|
85
|
+
// Request layout to ensure proper sizing
|
|
86
|
+
requestLayout()
|
|
85
87
|
}
|
|
86
88
|
Log.d(TAG, "[INIT] PreviewView created: $previewView")
|
|
87
89
|
Log.d(TAG, "[INIT] PreviewView implementationMode: ${previewView.implementationMode}")
|
|
90
|
+
Log.d(TAG, "[INIT] PreviewView visibility: ${previewView.visibility}")
|
|
88
91
|
|
|
89
92
|
Log.d(TAG, "[INIT] Adding PreviewView to parent...")
|
|
90
93
|
addView(previewView)
|
|
@@ -113,15 +116,26 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
|
|
|
113
116
|
Log.d(TAG, "This view: width=$width, height=$height")
|
|
114
117
|
Log.d(TAG, "========================================")
|
|
115
118
|
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
// Update lifecycle
|
|
120
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
|
|
121
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
122
|
+
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
123
|
+
|
|
124
|
+
// Wait for view to be laid out before starting camera
|
|
125
|
+
viewTreeObserver.addOnGlobalLayoutListener(object : android.view.ViewTreeObserver.OnGlobalLayoutListener {
|
|
126
|
+
override fun onGlobalLayout() {
|
|
127
|
+
viewTreeObserver.removeOnGlobalLayoutListener(this)
|
|
128
|
+
|
|
129
|
+
if (width > 0 && height > 0 && previewView.width > 0 && previewView.height > 0) {
|
|
130
|
+
Log.d(TAG, "[LAYOUT] View laid out: width=$width, height=$height")
|
|
131
|
+
Log.d(TAG, "[LAYOUT] PreviewView: width=${previewView.width}, height=${previewView.height}")
|
|
132
|
+
setupCamera()
|
|
133
|
+
startCamera()
|
|
134
|
+
} else {
|
|
135
|
+
Log.e(TAG, "[LAYOUT] View or PreviewView has invalid dimensions")
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
})
|
|
125
139
|
}
|
|
126
140
|
|
|
127
141
|
private fun setupCamera() {
|
package/package.json
CHANGED