react-native-rectangle-doc-scanner 7.0.0 → 7.1.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.
- package/android/build.gradle +6 -4
- package/android/src/main/kotlin/com/reactnativerectangledocscanner/DocumentScannerModule.kt +16 -9
- package/android/src/main/kotlin/com/reactnativerectangledocscanner/DocumentScannerPackage.kt +15 -5
- package/package.json +1 -1
- /package/android/src/{camera2 → common}/kotlin/com/reactnativerectangledocscanner/ImageProxyExt.kt +0 -0
package/android/build.gradle
CHANGED
|
@@ -77,13 +77,15 @@ dependencies {
|
|
|
77
77
|
implementation 'androidx.core:core-ktx:1.10.1'
|
|
78
78
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
79
79
|
|
|
80
|
+
// CameraX core is needed for ImageProxy in VisionCamera frame processor
|
|
81
|
+
def camerax_version = "1.3.0"
|
|
82
|
+
implementation "androidx.camera:camera-core:${camerax_version}"
|
|
83
|
+
|
|
80
84
|
if (hasVisionCamera) {
|
|
81
|
-
// VisionCamera mode -
|
|
85
|
+
// VisionCamera mode - include VisionCamera dependency
|
|
82
86
|
implementation project(':react-native-vision-camera')
|
|
83
87
|
} else {
|
|
84
|
-
// Camera2 mode - include CameraX and ML Kit dependencies
|
|
85
|
-
def camerax_version = "1.3.0"
|
|
86
|
-
implementation "androidx.camera:camera-core:${camerax_version}"
|
|
88
|
+
// Camera2 mode - include additional CameraX and ML Kit dependencies
|
|
87
89
|
implementation "androidx.camera:camera-camera2:${camerax_version}"
|
|
88
90
|
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
|
|
89
91
|
implementation "androidx.camera:camera-view:${camerax_version}"
|
|
@@ -43,15 +43,22 @@ class DocumentScannerModule(reactContext: ReactApplicationContext) :
|
|
|
43
43
|
try {
|
|
44
44
|
val view = uiManager.resolveView(tag)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
// Use reflection to avoid compile-time dependency on DocumentScannerView
|
|
47
|
+
try {
|
|
48
|
+
val docScannerViewClass = Class.forName("com.reactnativerectangledocscanner.DocumentScannerView")
|
|
49
|
+
if (docScannerViewClass.isInstance(view)) {
|
|
50
|
+
Log.d(TAG, "Found DocumentScannerView, triggering capture with promise")
|
|
51
|
+
|
|
52
|
+
// Pass promise to view so it can be resolved when capture completes
|
|
53
|
+
val captureMethod = docScannerViewClass.getMethod("captureWithPromise", Promise::class.java)
|
|
54
|
+
captureMethod.invoke(view, promise)
|
|
55
|
+
} else {
|
|
56
|
+
Log.e(TAG, "View with tag $tag is not DocumentScannerView: ${view?.javaClass?.simpleName}")
|
|
57
|
+
promise.reject("INVALID_VIEW", "View is not a DocumentScannerView")
|
|
58
|
+
}
|
|
59
|
+
} catch (e: ClassNotFoundException) {
|
|
60
|
+
Log.e(TAG, "DocumentScannerView not available (VisionCamera mode)", e)
|
|
61
|
+
promise.reject("VIEW_NOT_AVAILABLE", "Camera2 views not available in VisionCamera mode")
|
|
55
62
|
}
|
|
56
63
|
} catch (e: Exception) {
|
|
57
64
|
Log.e(TAG, "Error resolving view", e)
|
package/android/src/main/kotlin/com/reactnativerectangledocscanner/DocumentScannerPackage.kt
CHANGED
|
@@ -25,11 +25,21 @@ class DocumentScannerPackage : ReactPackage {
|
|
|
25
25
|
// VisionCamera is available, no need to register Camera2 view managers
|
|
26
26
|
emptyList()
|
|
27
27
|
} catch (e: ClassNotFoundException) {
|
|
28
|
-
// VisionCamera not available, register Camera2 view managers
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
// VisionCamera not available, register Camera2 view managers using reflection
|
|
29
|
+
try {
|
|
30
|
+
val viewManagers = mutableListOf<ViewManager<*, *>>()
|
|
31
|
+
|
|
32
|
+
val docScannerViewManagerClass = Class.forName("com.reactnativerectangledocscanner.DocumentScannerViewManager")
|
|
33
|
+
val cameraViewManagerClass = Class.forName("com.reactnativerectangledocscanner.CameraViewManager")
|
|
34
|
+
|
|
35
|
+
viewManagers.add(docScannerViewManagerClass.newInstance() as ViewManager<*, *>)
|
|
36
|
+
viewManagers.add(cameraViewManagerClass.newInstance() as ViewManager<*, *>)
|
|
37
|
+
|
|
38
|
+
viewManagers
|
|
39
|
+
} catch (e: Exception) {
|
|
40
|
+
Log.e(TAG, "Failed to instantiate Camera2 view managers", e)
|
|
41
|
+
emptyList()
|
|
42
|
+
}
|
|
33
43
|
}
|
|
34
44
|
}
|
|
35
45
|
|
package/package.json
CHANGED
/package/android/src/{camera2 → common}/kotlin/com/reactnativerectangledocscanner/ImageProxyExt.kt
RENAMED
|
File without changes
|