dynamsoft-capture-vision-react-native 3.4.1300 → 3.4.3010
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/LICENSE +4 -4
- package/README.md +62 -62
- package/android/README.md +14 -14
- package/android/build.gradle +167 -163
- package/android/gradle.properties +20 -20
- package/android/settings.gradle +5 -5
- package/android/src/main/AndroidManifest.xml +6 -6
- package/android/src/main/AndroidManifest_noPackage.xml +5 -5
- package/android/src/main/cpp/CMakeLists.txt +21 -21
- package/android/src/main/cpp/ImgHO.cpp +94 -94
- package/android/src/main/cpp/ImgHO.h +34 -34
- package/android/src/main/cpp/JsiCore.cpp +296 -296
- package/android/src/main/cpp/JsiCore.h +51 -51
- package/android/src/main/cpp/JsiCvr.cpp +332 -332
- package/android/src/main/cpp/JsiCvr.h +54 -54
- package/android/src/main/cpp/JsiDbr.cpp +283 -283
- package/android/src/main/cpp/JsiDbr.h +26 -26
- package/android/src/main/cpp/JsiDce.cpp +59 -59
- package/android/src/main/cpp/JsiDce.h +17 -17
- package/android/src/main/cpp/JsiDcp.cpp +51 -51
- package/android/src/main/cpp/JsiDcp.h +31 -31
- package/android/src/main/cpp/JsiDdn.cpp +50 -50
- package/android/src/main/cpp/JsiDdn.h +28 -28
- package/android/src/main/cpp/JsiDlr.cpp +60 -60
- package/android/src/main/cpp/JsiDlr.h +26 -26
- package/android/src/main/cpp/JsiUtility.cpp +604 -604
- package/android/src/main/cpp/JsiUtility.h +26 -26
- package/android/src/main/cpp/RawBuffer.cpp +23 -23
- package/android/src/main/cpp/RawBuffer.h +24 -24
- package/android/src/main/cpp/android_log.h +14 -14
- package/android/src/main/dysJniLibsFor86/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/CVRModule.kt +137 -137
- package/android/src/main/java/com/dynamsoft/reactnativelib/CameraViewManager.kt +62 -62
- package/android/src/main/java/com/dynamsoft/reactnativelib/DCEModule.kt +125 -125
- package/android/src/main/java/com/dynamsoft/reactnativelib/DynamsoftBaseModule.kt +8 -8
- package/android/src/main/java/com/dynamsoft/reactnativelib/ISAModule.kt +73 -73
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +14 -14
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +35 -35
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageManagerModule.kt +15 -15
- package/android/src/main/java/com/dynamsoft/reactnativelib/LicenseModule.kt +29 -29
- package/android/src/main/java/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +83 -83
- package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +32 -32
- package/android/src/main/java/com/dynamsoft/reactnativelib/VersionsModule.kt +41 -41
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/Basic.kt +44 -44
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCore.kt +50 -50
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCvr.kt +129 -129
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDBR.kt +157 -157
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCE.kt +110 -110
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCP.kt +49 -49
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDDN.kt +85 -85
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDLR.kt +72 -72
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ImageUtil.kt +58 -58
- package/android/src/main/java/com/dynamsoft/reactnativelib/core/ImageSourceAdapterModuleImpl.kt +120 -120
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +306 -306
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +247 -247
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraLifeCycleOwner.java +14 -14
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraViewManagerImpl.kt +77 -77
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +15 -15
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +110 -110
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNCameraView.kt +20 -20
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNImageEditorView.kt +19 -19
- package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +39 -39
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +120 -120
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +111 -111
- package/app.plugin.js +21 -21
- package/dynamsoft-capture-vision-react-native.podspec +24 -24
- package/ios/CPP/DSImageData+HostObject.h +18 -18
- package/ios/CPP/DSImageData+HostObject.mm +38 -38
- package/ios/CPP/ImageDataHostObject.cpp +87 -87
- package/ios/CPP/ImageDataHostObject.hpp +35 -35
- package/ios/CPP/MutableRawBuffer.cpp +23 -23
- package/ios/CPP/MutableRawBuffer.hpp +23 -23
- package/ios/CPP/RNDynamsoft+JSI.h +22 -22
- package/ios/CPP/RNDynamsoft+JSI.mm +303 -303
- package/ios/CPP/RNDynamsoft+Json.h +93 -93
- package/ios/CPP/RNDynamsoft+Json.m +733 -733
- package/ios/CPP/YeetJSIUtils.h +56 -56
- package/ios/CPP/YeetJSIUtils.mm +208 -208
- package/ios/RNDynamsoftCameraView.h +31 -31
- package/ios/RNDynamsoftCameraView.m +108 -108
- package/ios/RNDynamsoftCameraViewManager.h +14 -14
- package/ios/RNDynamsoftCameraViewManager.m +195 -195
- package/ios/RNDynamsoftCaptureVisionRouter.h +18 -18
- package/ios/RNDynamsoftCaptureVisionRouter.mm +532 -532
- package/ios/RNDynamsoftImageEditorView.h +17 -17
- package/ios/RNDynamsoftImageEditorView.m +25 -25
- package/ios/RNDynamsoftImageEditorViewManager.h +14 -14
- package/ios/RNDynamsoftImageEditorViewManager.mm +183 -183
- package/ios/RNDynamsoftImageManager.h +14 -14
- package/ios/RNDynamsoftImageManager.mm +369 -369
- package/ios/RNDynamsoftImageSourceAdapter.h +19 -19
- package/ios/RNDynamsoftImageSourceAdapter.mm +255 -255
- package/ios/RNDynamsoftLicense.h +14 -14
- package/ios/RNDynamsoftLicense.m +62 -62
- package/ios/RNDynamsoftMultiCrossFilter.h +14 -14
- package/ios/RNDynamsoftMultiCrossFilter.m +145 -145
- package/ios/RNDynamsoftVersions.h +13 -13
- package/ios/RNDynamsoftVersions.m +27 -27
- package/package.json +48 -48
- package/src/NativeDynamsoftVersionsModule.tsx +20 -20
- package/src/VersionsModule.tsx +7 -7
- package/src/core/CapturedResultBase.tsx +18 -18
- package/src/core/CapturedResultItem.tsx +23 -23
- package/src/core/CoreModule.tsx +9 -9
- package/src/core/DSRect.tsx +29 -29
- package/src/core/EnumCaptureResultItemType.tsx +52 -52
- package/src/core/EnumColourChannelUsageType.tsx +26 -26
- package/src/core/EnumCrossVerificationStatus.tsx +46 -46
- package/src/core/EnumGrayscaleEnhancementMode.tsx +46 -46
- package/src/core/EnumGrayscaleTransformationMode.tsx +35 -35
- package/src/core/EnumImageFileFormat.tsx +6 -6
- package/src/core/EnumPixelFormat.tsx +53 -53
- package/src/core/ImageData.tsx +87 -87
- package/src/core/ImageSourceAdapter.tsx +160 -160
- package/src/core/NativeDynamsoftImageSourceAdapterModule.tsx +29 -29
- package/src/core/Point.tsx +13 -13
- package/src/core/Quadrilateral.tsx +12 -12
- package/src/core/index.tsx +18 -18
- package/src/cvr/CaptureVisionRouter.tsx +683 -683
- package/src/cvr/CaptureVisionRouterModule.tsx +9 -9
- package/src/cvr/CapturedResult.tsx +123 -123
- package/src/cvr/CapturedResultFilter.tsx +13 -13
- package/src/cvr/CapturedResultReceiver.tsx +71 -71
- package/src/cvr/EnumPresetTemplate.tsx +81 -81
- package/src/cvr/NativeDynamsoftCaptureVisionRouterModule.tsx +25 -25
- package/src/cvr/SimplifiedCaptureVisionSettings.tsx +61 -61
- package/src/cvr/index.tsx +11 -11
- package/src/dbr/BarcodeDetails.tsx +51 -51
- package/src/dbr/BarcodeReaderModule.tsx +9 -9
- package/src/dbr/BarcodeResultItem.tsx +65 -65
- package/src/dbr/DecodedBarcodesResult.tsx +14 -14
- package/src/dbr/ECISegment.tsx +23 -23
- package/src/dbr/EnumBarcodeFormat.tsx +112 -112
- package/src/dbr/EnumDeblurMode.tsx +29 -29
- package/src/dbr/EnumLocalizationMode.tsx +27 -27
- package/src/dbr/EnumQRCodeErrorCorrectionLevel.tsx +6 -6
- package/src/dbr/SimplifiedBarcodeReaderSettings.tsx +80 -80
- package/src/dbr/index.tsx +9 -9
- package/src/dce/CameraEnhancer.tsx +254 -254
- package/src/dce/CameraEnhancerModule.tsx +9 -9
- package/src/dce/CameraView.tsx +100 -100
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +96 -96
- package/src/dce/DynamsoftImageEditorViewNativeComponent.ts +9 -9
- package/src/dce/EnumCameraPosition.tsx +25 -25
- package/src/dce/EnumDrawingLayerId.tsx +17 -17
- package/src/dce/EnumEnhancedFeatures.tsx +24 -24
- package/src/dce/EnumFocusMode.tsx +6 -6
- package/src/dce/EnumResolution.tsx +8 -8
- package/src/dce/EnumTorchState.tsx +10 -10
- package/src/dce/FeedBack.tsx +28 -28
- package/src/dce/ImageEditorView.tsx +131 -131
- package/src/dce/NativeDynamsoftCameraViewModule.tsx +47 -47
- package/src/dce/NativeDynamsoftImageEditorViewModule.ts +9 -9
- package/src/dce/index.tsx +13 -13
- package/src/dcp/CodeParserDedicatorModule.tsx +9 -9
- package/src/dcp/CodeParserModule.tsx +9 -9
- package/src/dcp/EnumMappingStatus.tsx +14 -14
- package/src/dcp/EnumValidationStatus.tsx +14 -14
- package/src/dcp/ParsedResult.tsx +14 -14
- package/src/dcp/ParsedResultItem.tsx +50 -50
- package/src/dcp/index.tsx +8 -8
- package/src/ddn/DeskewedImageResultItem.tsx +40 -40
- package/src/ddn/DetectedQuadResultItem.tsx +31 -31
- package/src/ddn/DocumentNormalizerModule.tsx +9 -9
- package/src/ddn/EnhancedImageResultItem.tsx +20 -20
- package/src/ddn/EnumImageColourMode.tsx +14 -14
- package/src/ddn/ProcessedDocumentResult.tsx +27 -27
- package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +65 -65
- package/src/ddn/index.tsx +11 -11
- package/src/dip/ImageProcessingModule.tsx +9 -9
- package/src/dip/index.tsx +1 -1
- package/src/dlr/CharacterResult.tsx +28 -28
- package/src/dlr/LabelRecognizerModule.tsx +9 -9
- package/src/dlr/RecognizedTextLinesResult.tsx +19 -19
- package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +33 -33
- package/src/dlr/TextLineResultItem.tsx +41 -41
- package/src/dlr/index.tsx +8 -8
- package/src/index.tsx +13 -13
- package/src/license/LicenseManager.tsx +49 -49
- package/src/license/LicenseModule.tsx +9 -9
- package/src/license/NativeDynamsoftLicenseModule.tsx +7 -7
- package/src/license/index.tsx +7 -7
- package/src/utility/CrossVerificationCriteria.tsx +11 -11
- package/src/utility/EnumFilterType.tsx +5 -5
- package/src/utility/ImageManager.tsx +348 -348
- package/src/utility/MultiFrameResultCrossFilter.tsx +183 -183
- package/src/utility/NativeDynamsoftImageManagerModule.tsx +7 -7
- package/src/utility/NativeDynamsoftMultiCrossFilterModule.tsx +18 -18
- package/src/utility/UtilityModule.tsx +9 -9
- package/src/utility/index.tsx +4 -4
- package/android/.gitignore +0 -4
|
@@ -1,247 +1,247 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.dce
|
|
2
|
-
|
|
3
|
-
import android.graphics.PointF
|
|
4
|
-
import android.util.Log
|
|
5
|
-
import android.util.Size
|
|
6
|
-
import androidx.lifecycle.Lifecycle
|
|
7
|
-
import com.dynamsoft.dce.CameraEnhancer
|
|
8
|
-
import com.dynamsoft.dce.CameraView
|
|
9
|
-
import com.dynamsoft.dce.EnumCameraPosition
|
|
10
|
-
import com.dynamsoft.dce.EnumFocusMode
|
|
11
|
-
import com.dynamsoft.dce.EnumResolution
|
|
12
|
-
import com.dynamsoft.dce.Feedback
|
|
13
|
-
import com.dynamsoft.dce.utils.PermissionUtil
|
|
14
|
-
import com.dynamsoft.reactnativelib.basicutils.toScanRegion
|
|
15
|
-
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
16
|
-
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl.Companion.mapISA
|
|
17
|
-
import com.facebook.react.bridge.Arguments
|
|
18
|
-
import com.facebook.react.bridge.LifecycleEventListener
|
|
19
|
-
import com.facebook.react.bridge.Promise
|
|
20
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
21
|
-
import com.facebook.react.bridge.ReactMethod
|
|
22
|
-
import com.facebook.react.bridge.ReadableMap
|
|
23
|
-
import com.facebook.react.uimanager.UIManagerHelper
|
|
24
|
-
import kotlinx.coroutines.CoroutineName
|
|
25
|
-
import kotlinx.coroutines.CoroutineScope
|
|
26
|
-
import kotlinx.coroutines.Dispatchers
|
|
27
|
-
import kotlinx.coroutines.MainScope
|
|
28
|
-
import kotlinx.coroutines.isActive
|
|
29
|
-
import kotlinx.coroutines.launch
|
|
30
|
-
import kotlinx.coroutines.withContext
|
|
31
|
-
import kotlinx.coroutines.withTimeoutOrNull
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext) : LifecycleEventListener {
|
|
35
|
-
companion object {
|
|
36
|
-
const val NAME = "DynamsoftCameraView"
|
|
37
|
-
const val TAG = "CameraEnhancerModule"
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private var ifOpenCalled = false
|
|
41
|
-
private var cameraLifecycleOwner = CameraLifeCycleOwner()
|
|
42
|
-
private var camera: CameraEnhancer? = null
|
|
43
|
-
private var currentCameraViewId: Int? = null
|
|
44
|
-
|
|
45
|
-
init {
|
|
46
|
-
reactContext.addLifecycleEventListener(this)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
fun getName(): String = NAME
|
|
50
|
-
|
|
51
|
-
override fun onHostResume() {
|
|
52
|
-
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
53
|
-
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
54
|
-
if(ifOpenCalled) {
|
|
55
|
-
open()
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
override fun onHostPause() {
|
|
60
|
-
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
|
61
|
-
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
override fun onHostDestroy() {
|
|
65
|
-
//Don't handle ON_DESTROY, which can cause problems on some devices when some apps that have started background services return to the foreground
|
|
66
|
-
//cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@ReactMethod
|
|
70
|
-
fun requestCameraPermission() {
|
|
71
|
-
reactContext.currentActivity?.apply {
|
|
72
|
-
PermissionUtil.requestCameraPermission(this)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
77
|
-
fun createInstance(): String {
|
|
78
|
-
if(camera == null) {
|
|
79
|
-
camera = CameraEnhancer(cameraLifecycleOwner).apply {
|
|
80
|
-
mapISA[this.toString()] = this
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return camera.toString()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
87
|
-
fun destroyInstance(id: String): Boolean {
|
|
88
|
-
if(camera?.toString() == id) {
|
|
89
|
-
camera?.close()
|
|
90
|
-
camera?.cameraView = null
|
|
91
|
-
currentCameraViewId = null
|
|
92
|
-
camera = null
|
|
93
|
-
}
|
|
94
|
-
mapISA.remove(id)
|
|
95
|
-
return true
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@ReactMethod
|
|
99
|
-
fun open() {
|
|
100
|
-
ifOpenCalled = true
|
|
101
|
-
if (currentCameraViewId != null && (camera?.cameraView == null || camera?.cameraView?.id != currentCameraViewId)) {
|
|
102
|
-
findAndSetCameraView(currentCameraViewId!!) { camera?.open() }
|
|
103
|
-
} else {
|
|
104
|
-
camera?.open()
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@ReactMethod
|
|
109
|
-
fun close() {
|
|
110
|
-
ifOpenCalled = false
|
|
111
|
-
camera?.close()
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
@ReactMethod
|
|
115
|
-
fun setCameraView(viewTag: Int) {
|
|
116
|
-
if(viewTag == 0) {
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
currentCameraViewId = viewTag
|
|
120
|
-
findAndSetCameraView(viewTag)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@ReactMethod
|
|
124
|
-
fun selectCamera(@EnumCameraPosition position: Int) {
|
|
125
|
-
camera?.selectCamera(position)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@ReactMethod
|
|
129
|
-
fun getCameraPosition(promise: Promise) {
|
|
130
|
-
promise.resolve(camera?.cameraPosition)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@ReactMethod
|
|
134
|
-
fun setFocus(x: Float, y: Float, @EnumFocusMode focusMode: Int) {
|
|
135
|
-
camera?.setFocus(PointF(x, y), focusMode)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@ReactMethod
|
|
139
|
-
fun getFocusMode(promise: Promise) {
|
|
140
|
-
promise.resolve(camera?.focusMode)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
@ReactMethod
|
|
144
|
-
fun setZoomFactor(factor: Float) {
|
|
145
|
-
camera?.zoomFactor = factor
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
@ReactMethod
|
|
149
|
-
fun getZoomFactor(promise: Promise) {
|
|
150
|
-
promise.resolve(camera?.zoomFactor)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
@ReactMethod
|
|
154
|
-
fun enableEnhancedFeatures(features: Int) {
|
|
155
|
-
camera?.enableEnhancedFeatures(features)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
@ReactMethod
|
|
159
|
-
fun disableEnhancedFeatures(features: Int) {
|
|
160
|
-
camera?.disableEnhancedFeatures(features)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
@ReactMethod
|
|
164
|
-
fun setScanRegion(region: ReadableMap?) {
|
|
165
|
-
camera?.scanRegion = region?.toScanRegion()
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
@ReactMethod
|
|
169
|
-
fun getScanRegion(promise: Promise) {
|
|
170
|
-
promise.resolve(camera?.scanRegion?.toWritableMap())
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
@ReactMethod
|
|
174
|
-
fun turnOnTorch() {
|
|
175
|
-
camera?.turnOnTorch()
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@ReactMethod
|
|
179
|
-
fun turnOffTorch() {
|
|
180
|
-
camera?.turnOffTorch()
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
@ReactMethod
|
|
185
|
-
fun setResolution(resolution: Int) {
|
|
186
|
-
if(resolution == 4) {
|
|
187
|
-
camera?.setResolution(EnumResolution.RESOLUTION_4K)
|
|
188
|
-
} else if(resolution == 5) {
|
|
189
|
-
camera?.setResolution(EnumResolution.RESOLUTION_MAX)
|
|
190
|
-
} else {
|
|
191
|
-
camera?.setResolution(resolution)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
@ReactMethod
|
|
195
|
-
fun getResolution(promise: Promise) {
|
|
196
|
-
val resolution = camera?.resolution ?: Size(0,0)
|
|
197
|
-
promise.resolve(Arguments.createMap().apply {
|
|
198
|
-
putInt("width", resolution.width)
|
|
199
|
-
putInt("height", resolution.height)
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
@ReactMethod
|
|
204
|
-
fun beep() {
|
|
205
|
-
Feedback.beep()
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
@ReactMethod
|
|
209
|
-
fun vibrate() {
|
|
210
|
-
Feedback.vibrate()
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
private fun findAndSetCameraView(viewTag: Int, afterSetCameraView: () -> Unit = {}) {
|
|
214
|
-
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setCameraView")) {
|
|
215
|
-
val cameraView = findCameraView(viewTag)
|
|
216
|
-
if (cameraView == null) {
|
|
217
|
-
Log.e(TAG, "setCameraView: Can't not find cameraView!(viewId = $viewTag)")
|
|
218
|
-
return@launch
|
|
219
|
-
}
|
|
220
|
-
MainScope().launch {
|
|
221
|
-
Log.e(TAG, "findAndSetCameraView: before setCameraView $camera ${cameraView.id}", )
|
|
222
|
-
camera?.cameraView = cameraView
|
|
223
|
-
afterSetCameraView()
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
private suspend fun findCameraView(viewId: Int): CameraView? = withTimeoutOrNull(300) {
|
|
229
|
-
while (true) {
|
|
230
|
-
val view = withContext(Dispatchers.Main) {
|
|
231
|
-
try {
|
|
232
|
-
UIManagerHelper.getUIManager(reactContext, viewId)?.resolveView(viewId) as? CameraView
|
|
233
|
-
} catch (e: Exception) {
|
|
234
|
-
null
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (view != null) {
|
|
238
|
-
return@withTimeoutOrNull view
|
|
239
|
-
}
|
|
240
|
-
if (!isActive) {
|
|
241
|
-
break
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return@withTimeoutOrNull null
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
|
+
|
|
3
|
+
import android.graphics.PointF
|
|
4
|
+
import android.util.Log
|
|
5
|
+
import android.util.Size
|
|
6
|
+
import androidx.lifecycle.Lifecycle
|
|
7
|
+
import com.dynamsoft.dce.CameraEnhancer
|
|
8
|
+
import com.dynamsoft.dce.CameraView
|
|
9
|
+
import com.dynamsoft.dce.EnumCameraPosition
|
|
10
|
+
import com.dynamsoft.dce.EnumFocusMode
|
|
11
|
+
import com.dynamsoft.dce.EnumResolution
|
|
12
|
+
import com.dynamsoft.dce.Feedback
|
|
13
|
+
import com.dynamsoft.dce.utils.PermissionUtil
|
|
14
|
+
import com.dynamsoft.reactnativelib.basicutils.toScanRegion
|
|
15
|
+
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
16
|
+
import com.dynamsoft.reactnativelib.core.ImageSourceAdapterModuleImpl.Companion.mapISA
|
|
17
|
+
import com.facebook.react.bridge.Arguments
|
|
18
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
19
|
+
import com.facebook.react.bridge.Promise
|
|
20
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
21
|
+
import com.facebook.react.bridge.ReactMethod
|
|
22
|
+
import com.facebook.react.bridge.ReadableMap
|
|
23
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
24
|
+
import kotlinx.coroutines.CoroutineName
|
|
25
|
+
import kotlinx.coroutines.CoroutineScope
|
|
26
|
+
import kotlinx.coroutines.Dispatchers
|
|
27
|
+
import kotlinx.coroutines.MainScope
|
|
28
|
+
import kotlinx.coroutines.isActive
|
|
29
|
+
import kotlinx.coroutines.launch
|
|
30
|
+
import kotlinx.coroutines.withContext
|
|
31
|
+
import kotlinx.coroutines.withTimeoutOrNull
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class CameraEnhancerModuleImpl(private val reactContext: ReactApplicationContext) : LifecycleEventListener {
|
|
35
|
+
companion object {
|
|
36
|
+
const val NAME = "DynamsoftCameraView"
|
|
37
|
+
const val TAG = "CameraEnhancerModule"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private var ifOpenCalled = false
|
|
41
|
+
private var cameraLifecycleOwner = CameraLifeCycleOwner()
|
|
42
|
+
private var camera: CameraEnhancer? = null
|
|
43
|
+
private var currentCameraViewId: Int? = null
|
|
44
|
+
|
|
45
|
+
init {
|
|
46
|
+
reactContext.addLifecycleEventListener(this)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fun getName(): String = NAME
|
|
50
|
+
|
|
51
|
+
override fun onHostResume() {
|
|
52
|
+
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
53
|
+
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
54
|
+
if(ifOpenCalled) {
|
|
55
|
+
open()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override fun onHostPause() {
|
|
60
|
+
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
|
61
|
+
cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
override fun onHostDestroy() {
|
|
65
|
+
//Don't handle ON_DESTROY, which can cause problems on some devices when some apps that have started background services return to the foreground
|
|
66
|
+
//cameraLifecycleOwner.lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod
|
|
70
|
+
fun requestCameraPermission() {
|
|
71
|
+
reactContext.currentActivity?.apply {
|
|
72
|
+
PermissionUtil.requestCameraPermission(this)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
77
|
+
fun createInstance(): String {
|
|
78
|
+
if(camera == null) {
|
|
79
|
+
camera = CameraEnhancer(cameraLifecycleOwner).apply {
|
|
80
|
+
mapISA[this.toString()] = this
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return camera.toString()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
87
|
+
fun destroyInstance(id: String): Boolean {
|
|
88
|
+
if(camera?.toString() == id) {
|
|
89
|
+
camera?.close()
|
|
90
|
+
camera?.cameraView = null
|
|
91
|
+
currentCameraViewId = null
|
|
92
|
+
camera = null
|
|
93
|
+
}
|
|
94
|
+
mapISA.remove(id)
|
|
95
|
+
return true
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@ReactMethod
|
|
99
|
+
fun open() {
|
|
100
|
+
ifOpenCalled = true
|
|
101
|
+
if (currentCameraViewId != null && (camera?.cameraView == null || camera?.cameraView?.id != currentCameraViewId)) {
|
|
102
|
+
findAndSetCameraView(currentCameraViewId!!) { camera?.open() }
|
|
103
|
+
} else {
|
|
104
|
+
camera?.open()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@ReactMethod
|
|
109
|
+
fun close() {
|
|
110
|
+
ifOpenCalled = false
|
|
111
|
+
camera?.close()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@ReactMethod
|
|
115
|
+
fun setCameraView(viewTag: Int) {
|
|
116
|
+
if(viewTag == 0) {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
currentCameraViewId = viewTag
|
|
120
|
+
findAndSetCameraView(viewTag)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactMethod
|
|
124
|
+
fun selectCamera(@EnumCameraPosition position: Int) {
|
|
125
|
+
camera?.selectCamera(position)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@ReactMethod
|
|
129
|
+
fun getCameraPosition(promise: Promise) {
|
|
130
|
+
promise.resolve(camera?.cameraPosition)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@ReactMethod
|
|
134
|
+
fun setFocus(x: Float, y: Float, @EnumFocusMode focusMode: Int) {
|
|
135
|
+
camera?.setFocus(PointF(x, y), focusMode)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@ReactMethod
|
|
139
|
+
fun getFocusMode(promise: Promise) {
|
|
140
|
+
promise.resolve(camera?.focusMode)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@ReactMethod
|
|
144
|
+
fun setZoomFactor(factor: Float) {
|
|
145
|
+
camera?.zoomFactor = factor
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@ReactMethod
|
|
149
|
+
fun getZoomFactor(promise: Promise) {
|
|
150
|
+
promise.resolve(camera?.zoomFactor)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@ReactMethod
|
|
154
|
+
fun enableEnhancedFeatures(features: Int) {
|
|
155
|
+
camera?.enableEnhancedFeatures(features)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@ReactMethod
|
|
159
|
+
fun disableEnhancedFeatures(features: Int) {
|
|
160
|
+
camera?.disableEnhancedFeatures(features)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@ReactMethod
|
|
164
|
+
fun setScanRegion(region: ReadableMap?) {
|
|
165
|
+
camera?.scanRegion = region?.toScanRegion()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@ReactMethod
|
|
169
|
+
fun getScanRegion(promise: Promise) {
|
|
170
|
+
promise.resolve(camera?.scanRegion?.toWritableMap())
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@ReactMethod
|
|
174
|
+
fun turnOnTorch() {
|
|
175
|
+
camera?.turnOnTorch()
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@ReactMethod
|
|
179
|
+
fun turnOffTorch() {
|
|
180
|
+
camera?.turnOffTorch()
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@ReactMethod
|
|
185
|
+
fun setResolution(resolution: Int) {
|
|
186
|
+
if(resolution == 4) {
|
|
187
|
+
camera?.setResolution(EnumResolution.RESOLUTION_4K)
|
|
188
|
+
} else if(resolution == 5) {
|
|
189
|
+
camera?.setResolution(EnumResolution.RESOLUTION_MAX)
|
|
190
|
+
} else {
|
|
191
|
+
camera?.setResolution(resolution)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
@ReactMethod
|
|
195
|
+
fun getResolution(promise: Promise) {
|
|
196
|
+
val resolution = camera?.resolution ?: Size(0,0)
|
|
197
|
+
promise.resolve(Arguments.createMap().apply {
|
|
198
|
+
putInt("width", resolution.width)
|
|
199
|
+
putInt("height", resolution.height)
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@ReactMethod
|
|
204
|
+
fun beep() {
|
|
205
|
+
Feedback.beep()
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@ReactMethod
|
|
209
|
+
fun vibrate() {
|
|
210
|
+
Feedback.vibrate()
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private fun findAndSetCameraView(viewTag: Int, afterSetCameraView: () -> Unit = {}) {
|
|
214
|
+
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setCameraView")) {
|
|
215
|
+
val cameraView = findCameraView(viewTag)
|
|
216
|
+
if (cameraView == null) {
|
|
217
|
+
Log.e(TAG, "setCameraView: Can't not find cameraView!(viewId = $viewTag)")
|
|
218
|
+
return@launch
|
|
219
|
+
}
|
|
220
|
+
MainScope().launch {
|
|
221
|
+
Log.e(TAG, "findAndSetCameraView: before setCameraView $camera ${cameraView.id}", )
|
|
222
|
+
camera?.cameraView = cameraView
|
|
223
|
+
afterSetCameraView()
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private suspend fun findCameraView(viewId: Int): CameraView? = withTimeoutOrNull(300) {
|
|
229
|
+
while (true) {
|
|
230
|
+
val view = withContext(Dispatchers.Main) {
|
|
231
|
+
try {
|
|
232
|
+
UIManagerHelper.getUIManager(reactContext, viewId)?.resolveView(viewId) as? CameraView
|
|
233
|
+
} catch (e: Exception) {
|
|
234
|
+
null
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (view != null) {
|
|
238
|
+
return@withTimeoutOrNull view
|
|
239
|
+
}
|
|
240
|
+
if (!isActive) {
|
|
241
|
+
break
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return@withTimeoutOrNull null
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.dce;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
import androidx.lifecycle.LifecycleOwner;
|
|
5
|
-
import androidx.lifecycle.LifecycleRegistry;
|
|
6
|
-
|
|
7
|
-
public class CameraLifeCycleOwner implements LifecycleOwner {
|
|
8
|
-
private final LifecycleRegistry lifecycleRegistry = new LifecycleRegistry(this);
|
|
9
|
-
@NonNull
|
|
10
|
-
@Override
|
|
11
|
-
public LifecycleRegistry getLifecycle() {
|
|
12
|
-
return lifecycleRegistry;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.lifecycle.LifecycleOwner;
|
|
5
|
+
import androidx.lifecycle.LifecycleRegistry;
|
|
6
|
+
|
|
7
|
+
public class CameraLifeCycleOwner implements LifecycleOwner {
|
|
8
|
+
private final LifecycleRegistry lifecycleRegistry = new LifecycleRegistry(this);
|
|
9
|
+
@NonNull
|
|
10
|
+
@Override
|
|
11
|
+
public LifecycleRegistry getLifecycle() {
|
|
12
|
+
return lifecycleRegistry;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.dce
|
|
2
|
-
|
|
3
|
-
import com.dynamsoft.dce.CameraView
|
|
4
|
-
import com.dynamsoft.dce.DrawingLayer
|
|
5
|
-
import com.dynamsoft.reactnativelib.basicutils.setCameraToggleButtonState
|
|
6
|
-
import com.dynamsoft.reactnativelib.basicutils.setTorchButtonState
|
|
7
|
-
import com.dynamsoft.reactnativelib.basicutils.toCameraToggleButtonState
|
|
8
|
-
import com.dynamsoft.reactnativelib.basicutils.toTorchButtonState
|
|
9
|
-
import com.facebook.react.bridge.ReadableArray
|
|
10
|
-
import com.facebook.react.bridge.ReadableMap
|
|
11
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
12
|
-
import com.facebook.react.uimanager.annotations.ReactProp
|
|
13
|
-
|
|
14
|
-
class CameraViewManagerImpl {
|
|
15
|
-
companion object {
|
|
16
|
-
const val TAG = "DynamsoftCameraView"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
fun getName() = TAG
|
|
20
|
-
|
|
21
|
-
fun createViewInstance(context: ThemedReactContext): CameraView {
|
|
22
|
-
return RNCameraView(context)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
fun receiveCommand(root: CameraView, commandId: String, args: ReadableArray?) {
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@ReactProp(name = "scanRegionMaskVisible")
|
|
29
|
-
fun setScanRegionMaskVisible(view: CameraView, isVisible: Boolean) {
|
|
30
|
-
view.isScanRegionMaskVisible = isVisible
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@ReactProp(name = "scanLaserVisible")
|
|
34
|
-
fun setScanLaserVisible(view: CameraView, isVisible: Boolean) {
|
|
35
|
-
view.isScanLaserVisible = isVisible
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@ReactProp(name = "VisibleLayerIds")
|
|
40
|
-
fun setVisibleLayerIds(view: CameraView, invisibleLayerIds: ReadableArray) {
|
|
41
|
-
val ids = IntArray(invisibleLayerIds.size())
|
|
42
|
-
for (i in ids.indices) {
|
|
43
|
-
ids[i] = invisibleLayerIds.getInt(i)
|
|
44
|
-
}
|
|
45
|
-
intArrayOf(DrawingLayer.DBR_LAYER_ID, DrawingLayer.DDN_LAYER_ID, DrawingLayer.DLR_LAYER_ID).forEach {
|
|
46
|
-
view.getDrawingLayer(it).isVisible = ids.contains(it)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@ReactProp(name = "torchButton")
|
|
51
|
-
fun setTorchButton(view: CameraView, torchButton: ReadableMap) {
|
|
52
|
-
view.setTorchButtonState(torchButton.toTorchButtonState())
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@ReactProp(name = "torchButtonVisible")
|
|
56
|
-
fun setTorchButtonVisible(view: CameraView, isVisible: Boolean) {
|
|
57
|
-
view.torchButtonVisible = isVisible
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@ReactProp(name = "cameraToggleButton")
|
|
61
|
-
fun setCameraToggleButton(view: CameraView, cameraToggleButton: ReadableMap) {
|
|
62
|
-
view.setCameraToggleButtonState(cameraToggleButton.toCameraToggleButtonState())
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@ReactProp(name = "cameraToggleButtonVisible")
|
|
66
|
-
fun setCameraToggleButtonVisible(view: CameraView, isVisible: Boolean) {
|
|
67
|
-
view.cameraToggleButtonVisible = isVisible
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// private fun View.manuallyMeasureAndLayout() {
|
|
71
|
-
// measure(
|
|
72
|
-
// View.MeasureSpec.makeMeasureSpec(measuredWidth, View.MeasureSpec.EXACTLY),
|
|
73
|
-
// View.MeasureSpec.makeMeasureSpec(measuredHeight, View.MeasureSpec.EXACTLY)
|
|
74
|
-
// )
|
|
75
|
-
// layout(0, 0, measuredWidth, measuredHeight)
|
|
76
|
-
// }
|
|
77
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
|
+
|
|
3
|
+
import com.dynamsoft.dce.CameraView
|
|
4
|
+
import com.dynamsoft.dce.DrawingLayer
|
|
5
|
+
import com.dynamsoft.reactnativelib.basicutils.setCameraToggleButtonState
|
|
6
|
+
import com.dynamsoft.reactnativelib.basicutils.setTorchButtonState
|
|
7
|
+
import com.dynamsoft.reactnativelib.basicutils.toCameraToggleButtonState
|
|
8
|
+
import com.dynamsoft.reactnativelib.basicutils.toTorchButtonState
|
|
9
|
+
import com.facebook.react.bridge.ReadableArray
|
|
10
|
+
import com.facebook.react.bridge.ReadableMap
|
|
11
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
12
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
13
|
+
|
|
14
|
+
class CameraViewManagerImpl {
|
|
15
|
+
companion object {
|
|
16
|
+
const val TAG = "DynamsoftCameraView"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fun getName() = TAG
|
|
20
|
+
|
|
21
|
+
fun createViewInstance(context: ThemedReactContext): CameraView {
|
|
22
|
+
return RNCameraView(context)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun receiveCommand(root: CameraView, commandId: String, args: ReadableArray?) {
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@ReactProp(name = "scanRegionMaskVisible")
|
|
29
|
+
fun setScanRegionMaskVisible(view: CameraView, isVisible: Boolean) {
|
|
30
|
+
view.isScanRegionMaskVisible = isVisible
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@ReactProp(name = "scanLaserVisible")
|
|
34
|
+
fun setScanLaserVisible(view: CameraView, isVisible: Boolean) {
|
|
35
|
+
view.isScanLaserVisible = isVisible
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@ReactProp(name = "VisibleLayerIds")
|
|
40
|
+
fun setVisibleLayerIds(view: CameraView, invisibleLayerIds: ReadableArray) {
|
|
41
|
+
val ids = IntArray(invisibleLayerIds.size())
|
|
42
|
+
for (i in ids.indices) {
|
|
43
|
+
ids[i] = invisibleLayerIds.getInt(i)
|
|
44
|
+
}
|
|
45
|
+
intArrayOf(DrawingLayer.DBR_LAYER_ID, DrawingLayer.DDN_LAYER_ID, DrawingLayer.DLR_LAYER_ID).forEach {
|
|
46
|
+
view.getDrawingLayer(it).isVisible = ids.contains(it)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@ReactProp(name = "torchButton")
|
|
51
|
+
fun setTorchButton(view: CameraView, torchButton: ReadableMap) {
|
|
52
|
+
view.setTorchButtonState(torchButton.toTorchButtonState())
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactProp(name = "torchButtonVisible")
|
|
56
|
+
fun setTorchButtonVisible(view: CameraView, isVisible: Boolean) {
|
|
57
|
+
view.torchButtonVisible = isVisible
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@ReactProp(name = "cameraToggleButton")
|
|
61
|
+
fun setCameraToggleButton(view: CameraView, cameraToggleButton: ReadableMap) {
|
|
62
|
+
view.setCameraToggleButtonState(cameraToggleButton.toCameraToggleButtonState())
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@ReactProp(name = "cameraToggleButtonVisible")
|
|
66
|
+
fun setCameraToggleButtonVisible(view: CameraView, isVisible: Boolean) {
|
|
67
|
+
view.cameraToggleButtonVisible = isVisible
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// private fun View.manuallyMeasureAndLayout() {
|
|
71
|
+
// measure(
|
|
72
|
+
// View.MeasureSpec.makeMeasureSpec(measuredWidth, View.MeasureSpec.EXACTLY),
|
|
73
|
+
// View.MeasureSpec.makeMeasureSpec(measuredHeight, View.MeasureSpec.EXACTLY)
|
|
74
|
+
// )
|
|
75
|
+
// layout(0, 0, measuredWidth, measuredHeight)
|
|
76
|
+
// }
|
|
77
|
+
}
|