scandit-capacitor-datacapture-barcode 7.4.1 → 7.5.0-beta.2
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/ScanditCapacitorDatacaptureBarcode.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.kt +225 -148
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/count/BarcodeCountViewHandler.kt +4 -4
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/find/BarcodeFindViewHandler.kt +90 -71
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/utils/AdvancedOverlayViewSerialization.kt +7 -4
- package/dist/barcode.js +2878 -1364
- package/dist/barcode.js.map +1 -1
- package/dist/dts/definitions.d.ts +0 -35
- package/dist/dts/ts/BarcodeCountView.d.ts +1 -0
- package/dist/dts/ts/BarcodePickView.d.ts +3 -0
- package/dist/dts/ts/Capacitor/Capacitor.d.ts +0 -14
- package/dist/dts/web.d.ts +1 -2
- package/dist/index.js +40 -373
- package/dist/index.js.map +1 -1
- package/ios/Plugin/BarcodeCountViewHandler.swift +4 -4
- package/ios/Plugin/BarcodePickViewHandler.swift +4 -4
- package/ios/Plugin/CommandJSONArgument+ScanditBarcodeCapture.swift +12 -9
- package/ios/Plugin/Plugin.m +11 -8
- package/ios/Plugin/ScanditBarcodeCapture.swift +493 -169
- package/package.json +4 -4
- package/dist/dts/ts/Capacitor/BarcodeBatchAdvancedOverlayProxy.d.ts +0 -23
- package/dist/dts/ts/Capacitor/BarcodeBatchBasicOverlayProxy.d.ts +0 -14
- package/dist/dts/ts/Capacitor/BarcodeBatchListenerProxy.d.ts +0 -15
- package/dist/dts/ts/Capacitor/BarcodeCountViewProxy.d.ts +0 -7
- package/dist/dts/ts/Capacitor/BarcodeFindListenerProxy.d.ts +0 -18
- package/dist/dts/ts/Capacitor/BarcodeFindViewProxy.d.ts +0 -18
|
@@ -26,14 +26,14 @@ internal class BarcodeCountViewHandler (
|
|
|
26
26
|
private var barcodeCountViewReference: WeakReference<BarcodeCountView>? = null
|
|
27
27
|
private var webViewReference: WeakReference<View>? = null
|
|
28
28
|
|
|
29
|
-
val
|
|
29
|
+
val currentBarcodeCountView: BarcodeCountView?
|
|
30
30
|
get() = barcodeCountViewReference?.get()
|
|
31
31
|
|
|
32
32
|
private val webView: View?
|
|
33
33
|
get() = webViewReference?.get()
|
|
34
34
|
|
|
35
35
|
fun attachBarcodeCountView(barcodeCountView: BarcodeCountView, activity: AppCompatActivity) {
|
|
36
|
-
if (this.
|
|
36
|
+
if (this.currentBarcodeCountView != barcodeCountView) {
|
|
37
37
|
disposeCurrentView()
|
|
38
38
|
addBarcodeCountView(barcodeCountView, activity)
|
|
39
39
|
}
|
|
@@ -68,7 +68,7 @@ internal class BarcodeCountViewHandler (
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
fun disposeCurrentView() {
|
|
71
|
-
val view =
|
|
71
|
+
val view = currentBarcodeCountView ?: return
|
|
72
72
|
removeBarcodeCountView(view)
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -111,7 +111,7 @@ internal class BarcodeCountViewHandler (
|
|
|
111
111
|
|
|
112
112
|
// Update the view visibility, position and size.
|
|
113
113
|
fun render() {
|
|
114
|
-
val view =
|
|
114
|
+
val view = currentBarcodeCountView ?: return
|
|
115
115
|
renderNoAnimate(view)
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -12,72 +12,101 @@ import android.view.View
|
|
|
12
12
|
import android.view.ViewGroup
|
|
13
13
|
import android.widget.FrameLayout
|
|
14
14
|
import androidx.appcompat.app.AppCompatActivity
|
|
15
|
-
import androidx.core.view.children
|
|
16
|
-
import com.scandit.capacitor.datacapture.core.data.ResizeAndMoveInfo
|
|
17
|
-
import com.scandit.capacitor.datacapture.core.utils.pxFromDp
|
|
18
15
|
import com.scandit.capacitor.datacapture.core.utils.removeFromParent
|
|
19
|
-
import com.scandit.datacapture.barcode.find.ui.BarcodeFindView
|
|
20
16
|
import com.scandit.datacapture.frameworks.core.utils.DefaultMainThread
|
|
21
17
|
import com.scandit.datacapture.frameworks.core.utils.MainThread
|
|
22
18
|
import java.lang.ref.WeakReference
|
|
19
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
23
20
|
|
|
24
21
|
class BarcodeFindViewHandler(
|
|
25
22
|
private val mainThread: MainThread = DefaultMainThread.getInstance()
|
|
26
23
|
) {
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private var barcodeFindViewContainerReference: WeakReference<FrameLayout>? = null
|
|
30
|
-
private var webViewReference: WeakReference<View>? = null
|
|
24
|
+
private val containers: MutableMap<Int, WeakReference<FrameLayout>> = ConcurrentHashMap()
|
|
25
|
+
private val containerVisibility: MutableMap<Int, Boolean> = ConcurrentHashMap()
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
get() = barcodeFindViewContainerReference?.get()
|
|
27
|
+
private var webViewReference: WeakReference<View>? = null
|
|
34
28
|
|
|
35
29
|
private val webView: View?
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
get() = webViewReference?.get()
|
|
38
31
|
|
|
39
|
-
fun prepareContainer(context: Context)
|
|
40
|
-
return FrameLayout(
|
|
32
|
+
fun prepareContainer(context: Context): FrameLayout {
|
|
33
|
+
return FrameLayout(
|
|
34
|
+
context
|
|
35
|
+
)
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
fun addBarcodeFindViewContainer(container: FrameLayout, activity: AppCompatActivity) {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
fun addBarcodeFindViewContainer(viewId: Int, container: FrameLayout, activity: AppCompatActivity) {
|
|
39
|
+
if (containers.containsKey(viewId)) {
|
|
40
|
+
val existingContainer = containers.remove(viewId)?.get()
|
|
41
|
+
if (existingContainer != null) {
|
|
42
|
+
removeView(existingContainer)
|
|
43
|
+
}
|
|
47
44
|
}
|
|
45
|
+
|
|
46
|
+
containers[viewId] = WeakReference(container)
|
|
47
|
+
containerVisibility[viewId] = true
|
|
48
|
+
|
|
49
|
+
addContainer(
|
|
50
|
+
viewId,
|
|
51
|
+
container,
|
|
52
|
+
activity
|
|
53
|
+
)
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
fun attachWebView(webView: View) {
|
|
51
57
|
if (this.webView != webView) {
|
|
52
58
|
webViewReference = WeakReference(webView)
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
mainThread.runOnMainThread {
|
|
60
|
+
webView.bringToFront()
|
|
61
|
+
webView.setBackgroundColor(Color.TRANSPARENT)
|
|
62
|
+
}
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
|
|
58
|
-
fun setVisible() {
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
fun setVisible(viewId: Int) {
|
|
67
|
+
mainThread.runOnMainThread {
|
|
68
|
+
containerVisibility[viewId] = true
|
|
69
|
+
renderNoAnimate(
|
|
70
|
+
containers[viewId]?.get() ?: return@runOnMainThread,
|
|
71
|
+
containerVisibility[viewId] == true
|
|
72
|
+
)
|
|
73
|
+
}
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
fun setInvisible() {
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
fun setInvisible(viewId: Int) {
|
|
77
|
+
mainThread.runOnMainThread {
|
|
78
|
+
containerVisibility[viewId] = false
|
|
79
|
+
renderNoAnimate(
|
|
80
|
+
containers[viewId]?.get() ?: return@runOnMainThread,
|
|
81
|
+
containerVisibility[viewId] == true
|
|
82
|
+
)
|
|
83
|
+
}
|
|
66
84
|
}
|
|
67
85
|
|
|
68
|
-
fun
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
fun disposeContainer(viewId: Int) {
|
|
87
|
+
mainThread.runOnMainThread {
|
|
88
|
+
containers.remove(viewId)?.get()?.also {
|
|
89
|
+
removeView(it)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
93
|
+
containerVisibility.remove(viewId)
|
|
94
|
+
|
|
95
|
+
if (containers.isEmpty()) {
|
|
96
|
+
mainThread.runOnMainThread {
|
|
97
|
+
setWebViewVisible()
|
|
98
|
+
}
|
|
99
|
+
}
|
|
76
100
|
}
|
|
77
101
|
|
|
78
|
-
fun
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
fun disposeAll() {
|
|
103
|
+
mainThread.runOnMainThread {
|
|
104
|
+
for (viewId in containers.keys) {
|
|
105
|
+
disposeContainer(viewId)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
disposeCurrentWebView()
|
|
109
|
+
}
|
|
81
110
|
}
|
|
82
111
|
|
|
83
112
|
private fun disposeCurrentWebView() {
|
|
@@ -85,60 +114,50 @@ class BarcodeFindViewHandler(
|
|
|
85
114
|
}
|
|
86
115
|
|
|
87
116
|
private fun addContainer(
|
|
88
|
-
|
|
117
|
+
viewId: Int,
|
|
118
|
+
container: FrameLayout,
|
|
89
119
|
activity: AppCompatActivity
|
|
90
120
|
) {
|
|
91
|
-
barcodeFindViewContainerReference = WeakReference(barcodeFindViewContainer)
|
|
92
|
-
|
|
93
121
|
mainThread.runOnMainThread {
|
|
94
122
|
activity.addContentView(
|
|
95
|
-
|
|
123
|
+
container,
|
|
96
124
|
ViewGroup.LayoutParams(
|
|
97
125
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
98
126
|
ViewGroup.LayoutParams.MATCH_PARENT
|
|
99
127
|
)
|
|
100
128
|
)
|
|
101
|
-
|
|
129
|
+
renderNoAnimate(container, containerVisibility[viewId] == true)
|
|
102
130
|
}
|
|
103
131
|
}
|
|
104
132
|
|
|
105
|
-
private fun
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(barcodeFindViewContainer.children.firstOrNull() as? BarcodeFindView)?.setListener(null)
|
|
133
|
+
private fun removeView(view: View) {
|
|
134
|
+
mainThread.runOnMainThread {
|
|
135
|
+
view.removeFromParent()
|
|
109
136
|
}
|
|
110
137
|
}
|
|
111
138
|
|
|
112
|
-
private fun
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
139
|
+
private fun renderNoAnimate(container: FrameLayout, isVisible: Boolean) {
|
|
140
|
+
container.visibility = if (isVisible) View.VISIBLE else View.GONE
|
|
141
|
+
container.layoutParams.apply {
|
|
142
|
+
width = ViewGroup.LayoutParams.MATCH_PARENT
|
|
143
|
+
height = ViewGroup.LayoutParams.MATCH_PARENT
|
|
144
|
+
}
|
|
145
|
+
if (isVisible) {
|
|
146
|
+
container.bringToFront()
|
|
147
|
+
setWebViewInvisible()
|
|
148
|
+
} else {
|
|
149
|
+
setWebViewVisible()
|
|
116
150
|
}
|
|
151
|
+
container.requestLayout()
|
|
152
|
+
|
|
117
153
|
}
|
|
118
154
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
renderNoAnimate(view)
|
|
155
|
+
private fun setWebViewVisible() {
|
|
156
|
+
webView?.bringToFront()
|
|
157
|
+
(webView?.parent as View).translationZ = 1F
|
|
123
158
|
}
|
|
124
159
|
|
|
125
|
-
private fun
|
|
126
|
-
|
|
127
|
-
barcodeFindViewContainer.visibility = if (isVisible) View.VISIBLE else View.GONE
|
|
128
|
-
barcodeFindViewContainer.x = latestInfo.left.pxFromDp()
|
|
129
|
-
barcodeFindViewContainer.y = latestInfo.top.pxFromDp()
|
|
130
|
-
barcodeFindViewContainer.layoutParams.apply {
|
|
131
|
-
width = ViewGroup.LayoutParams.MATCH_PARENT
|
|
132
|
-
height = ViewGroup.LayoutParams.MATCH_PARENT
|
|
133
|
-
}
|
|
134
|
-
if (latestInfo.shouldBeUnderWebView) {
|
|
135
|
-
webView?.bringToFront()
|
|
136
|
-
(webView?.parent as View).translationZ = 1F
|
|
137
|
-
} else {
|
|
138
|
-
barcodeFindViewContainer.bringToFront()
|
|
139
|
-
(webView?.parent as View).translationZ = -1F
|
|
140
|
-
}
|
|
141
|
-
barcodeFindViewContainer.requestLayout()
|
|
142
|
-
}
|
|
160
|
+
private fun setWebViewInvisible() {
|
|
161
|
+
(webView?.parent as View).translationZ = -1F
|
|
143
162
|
}
|
|
144
163
|
}
|
|
@@ -6,7 +6,8 @@ import org.json.JSONObject
|
|
|
6
6
|
data class SerializableAdvancedOverlayViewData(
|
|
7
7
|
val view: SerializableAdvancedOverlayView?,
|
|
8
8
|
val trackedBarcodeId: Int,
|
|
9
|
-
val sessionFrameSequenceId: Long
|
|
9
|
+
val sessionFrameSequenceId: Long?,
|
|
10
|
+
val dataCaptureViewId: Int
|
|
10
11
|
) {
|
|
11
12
|
constructor(json: JSONObject) : this(
|
|
12
13
|
view = SerializableAdvancedOverlayView.fromJson(json.optJSONObject(FIELD_VIEW)),
|
|
@@ -15,7 +16,8 @@ data class SerializableAdvancedOverlayViewData(
|
|
|
15
16
|
json[FIELD_FRAME_SEQUENCE_ID] is Long
|
|
16
17
|
) {
|
|
17
18
|
json.getLong(FIELD_FRAME_SEQUENCE_ID)
|
|
18
|
-
} else null
|
|
19
|
+
} else null,
|
|
20
|
+
dataCaptureViewId = json.getInt(FIELD_DATA_CAPTURE_VIEW_ID),
|
|
19
21
|
)
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -79,6 +81,7 @@ data class SerializableAdvancedOverlayViewOptions(
|
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
private const val FIELD_VIEW = "
|
|
83
|
-
private const val FIELD_TRACKED_BARCODE_ID = "
|
|
84
|
+
private const val FIELD_VIEW = "viewJson"
|
|
85
|
+
private const val FIELD_TRACKED_BARCODE_ID = "trackedBarcodeIdentifier"
|
|
86
|
+
private const val FIELD_DATA_CAPTURE_VIEW_ID = "dataCaptureViewId"
|
|
84
87
|
private const val FIELD_FRAME_SEQUENCE_ID = "sessionFrameSequenceID"
|