scandit-capacitor-datacapture-barcode 7.5.0 → 7.6.0-beta.1

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.
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
17
17
 
18
18
  s.dependency "Capacitor"
19
19
  s.dependency "ScanditCapacitorDatacaptureCore", "= #{version}"
20
- s.dependency "scandit-datacapture-frameworks-barcode", '= 7.5.0'
20
+ s.dependency "scandit-datacapture-frameworks-barcode", '= 7.6.0-beta.1'
21
21
  end
@@ -89,7 +89,7 @@ repositories {
89
89
  }
90
90
 
91
91
  dependencies {
92
- def sdk_version = "7.5.0"
92
+ def sdk_version = "7.6.0-beta.1"
93
93
 
94
94
  implementation fileTree(dir: 'libs', include: ['*.jar'])
95
95
  implementation fileTree(dir: 'library', include: ['*.aar'])
@@ -75,7 +75,7 @@ class ScanditBarcodeNative :
75
75
 
76
76
  private var corePlugin: PluginHandle? = null
77
77
  private val barcodeModule = BarcodeModule()
78
- private val barcodeCaptureModule = BarcodeCaptureModule(FrameworksBarcodeCaptureListener(this))
78
+ private val barcodeCaptureModule = BarcodeCaptureModule.create(this)
79
79
  private val barcodeBatchModule = BarcodeBatchModule.create(this)
80
80
  private val barcodeSelectionModule = BarcodeSelectionModule(
81
81
  FrameworksBarcodeSelectionListener(this),
@@ -214,24 +214,72 @@ class ScanditBarcodeNative :
214
214
  call.resolve(defaults)
215
215
  }
216
216
 
217
+ //region Barcode Capture Methods
218
+
217
219
  @PluginMethod
218
220
  fun registerBarcodeCaptureListenerForEvents(call: PluginCall) {
219
- barcodeCaptureModule.addListener()
221
+ barcodeCaptureModule.addListener(getModeId(call))
220
222
  call.resolve()
221
223
  }
222
224
 
223
225
  @PluginMethod
224
226
  fun unregisterBarcodeCaptureListenerForEvents(call: PluginCall) {
225
- barcodeCaptureModule.removeListener()
227
+ barcodeCaptureModule.removeListener(getModeId(call))
226
228
  call.resolve()
227
229
  }
228
230
 
229
231
  @PluginMethod
230
232
  fun setBarcodeCaptureModeEnabledState(call: PluginCall) {
231
- barcodeCaptureModule.setModeEnabled(call.data.getBoolean("enabled"))
233
+ barcodeCaptureModule.setModeEnabled(getModeId(call), call.data.getBoolean("enabled"))
234
+ call.resolve()
235
+ }
236
+
237
+ @PluginMethod
238
+ fun finishBarcodeCaptureDidUpdateSession(call: PluginCall) {
239
+ barcodeCaptureModule.finishDidUpdateSession(getModeId(call), call.data.getBoolean("enabled"))
240
+ call.resolve()
241
+ }
242
+
243
+ @PluginMethod
244
+ fun finishBarcodeCaptureDidScan(call: PluginCall) {
245
+ barcodeCaptureModule.finishDidScan(getModeId(call), call.data.getBoolean("enabled"))
246
+ call.resolve()
247
+ }
248
+
249
+ @PluginMethod
250
+ fun resetBarcodeCaptureSession(call: PluginCall) {
251
+ barcodeCaptureModule.resetSession(call.data.getLong("frameSequenceId"))
232
252
  call.resolve()
233
253
  }
234
254
 
255
+ @PluginMethod
256
+ fun updateBarcodeCaptureOverlay(call: PluginCall) {
257
+ val overlayJson = call.data.getString("overlayJson")
258
+ ?: return call.reject(WRONG_INPUT)
259
+ barcodeCaptureModule.updateOverlay(
260
+ getViewId(call),
261
+ overlayJson,
262
+ CapacitorResult(call)
263
+ )
264
+ }
265
+
266
+ @PluginMethod
267
+ fun updateBarcodeCaptureMode(call: PluginCall) {
268
+ val modeJson = call.data.getString("modeJson")
269
+ ?: return call.reject(WRONG_INPUT)
270
+ barcodeCaptureModule.updateModeFromJson(modeJson, CapacitorResult(call))
271
+ }
272
+
273
+ @PluginMethod
274
+ fun applyBarcodeCaptureModeSettings(call: PluginCall) {
275
+ val modeId = getModeId(call)
276
+ val modeSettingsJson = call.data.getString("modeSettingsJson")
277
+ ?: return call.reject(WRONG_INPUT)
278
+ barcodeCaptureModule.applyModeSettings(modeId, modeSettingsJson, CapacitorResult(call))
279
+ }
280
+
281
+ //endregion
282
+
235
283
  @PluginMethod
236
284
  fun registerBarcodeBatchListenerForEvents(call: PluginCall) {
237
285
  barcodeBatchModule.addBarcodeBatchListener(getModeId(call))
@@ -247,7 +295,7 @@ class ScanditBarcodeNative :
247
295
  @PluginMethod
248
296
  fun finishBarcodeBatchDidUpdateSessionCallback(call: PluginCall) {
249
297
  barcodeBatchModule.finishDidUpdateSession(
250
- call.data.getInt("modeId"),
298
+ getModeId(call),
251
299
  call.data.getBoolean("enabled")
252
300
  )
253
301
  call.resolve()
@@ -442,6 +490,12 @@ class ScanditBarcodeNative :
442
490
  call.resolve()
443
491
  }
444
492
 
493
+ @PluginMethod
494
+ fun resetBarcodeBatchSession(call: PluginCall) {
495
+ barcodeBatchModule.resetSession(null)
496
+ call.resolve()
497
+ }
498
+
445
499
  @PluginMethod
446
500
  fun setViewForTrackedBarcode(call: PluginCall) {
447
501
  try {
@@ -544,18 +598,6 @@ class ScanditBarcodeNative :
544
598
  )
545
599
  }
546
600
 
547
- @PluginMethod
548
- fun resetBarcodeCaptureSession(call: PluginCall) {
549
- barcodeCaptureModule.resetSession(null)
550
- call.resolve()
551
- }
552
-
553
- @PluginMethod
554
- fun resetBarcodeBatchSession(call: PluginCall) {
555
- barcodeBatchModule.resetSession(null)
556
- call.resolve()
557
- }
558
-
559
601
  @PluginMethod
560
602
  fun resetBarcodeSelectionSession(call: PluginCall) {
561
603
  barcodeSelectionModule.resetLatestSession(null)
@@ -603,50 +645,30 @@ class ScanditBarcodeNative :
603
645
  call.reject(JsonParseError(error.message).toString())
604
646
  }
605
647
 
606
- @PluginMethod
607
- fun finishBarcodeCaptureDidScan(call: PluginCall) {
608
- barcodeCaptureModule.finishDidScan(call.data.getBoolean("enabled"))
609
- call.resolve()
610
- }
611
-
612
- @PluginMethod
613
- fun finishBarcodeCaptureDidUpdateSession(call: PluginCall) {
614
- barcodeCaptureModule.finishDidUpdateSession(call.data.getBoolean("enabled"))
615
- call.resolve()
616
- }
617
-
618
- @PluginMethod
619
- fun setBarcodeSelectionModeEnabledState(call: PluginCall) {
620
- barcodeSelectionModule.setModeEnabled(call.data.getBoolean("enabled"))
621
- call.resolve()
622
- }
623
-
624
648
  //region BarcodeCount
625
649
 
626
- //region Barcode Count Listener
627
- @PluginMethod
628
- fun finishBarcodeCountOnScan(call: PluginCall) {
629
- barcodeCountModule.finishOnScan(getViewId(call), true)
630
- call.resolve(null)
631
- }
632
-
633
- //endregion
634
-
635
650
  @PluginMethod
636
651
  fun createBarcodeCountView(call: PluginCall) {
637
- val viewJson = call.data.getString("viewJson")!!
652
+ val viewJson = call.data.getString("viewJson")
653
+ if (viewJson == null) {
654
+ call.reject(WRONG_INPUT, "Missing or invalid viewJson")
655
+ return
656
+ }
657
+
638
658
  val barcodeCountView = barcodeCountModule.getViewFromJson(viewJson)
639
659
  if (barcodeCountView == null) {
640
660
  call.reject("Unable to create the BarcodeCountView from the given json=$viewJson")
641
661
  return
642
662
  }
643
663
 
644
- barcodeCountViewHandler.attachBarcodeCountView(
645
- barcodeCountView,
646
- bridge.activity
647
- )
648
- barcodeCountViewHandler.render()
649
- call.resolve()
664
+ mainThread.runOnMainThread {
665
+ barcodeCountViewHandler.attachBarcodeCountView(
666
+ barcodeCountView,
667
+ bridge.activity
668
+ )
669
+ barcodeCountViewHandler.render()
670
+ call.resolve()
671
+ }
650
672
  }
651
673
 
652
674
  @PluginMethod
@@ -658,24 +680,40 @@ class ScanditBarcodeNative :
658
680
 
659
681
  @PluginMethod
660
682
  fun updateBarcodeCountView(call: PluginCall) {
661
- val view = barcodeCountViewHandler.currentBarcodeCountView
662
- if (view == null) {
683
+ val currentView = barcodeCountViewHandler.currentBarcodeCountView
684
+ if (currentView == null) {
663
685
  call.reject("The barcode count view has not been initialized yet.")
664
686
  return
665
687
  }
666
688
 
667
- val viewJson = call.data.getString("viewJson")!!
689
+ val viewJson = call.data.getString("viewJson")
690
+ if (viewJson.isNullOrEmpty()) {
691
+ call.reject("viewJson is required", WRONG_INPUT)
692
+ return
693
+ }
694
+
668
695
  barcodeCountModule.updateBarcodeCountView(getViewId(call), viewJson)
669
696
  call.resolve()
670
697
  }
671
698
 
672
699
  @PluginMethod
673
700
  fun updateBarcodeCountMode(call: PluginCall) {
674
- val barcodeCountJson = call.data.getString("barcodeCountJson")!!
701
+ val barcodeCountJson = call.data.getString("barcodeCountJson")
702
+ if (barcodeCountJson == null) {
703
+ call.reject(WRONG_INPUT, "barcodeCountJson is required")
704
+ return
705
+ }
706
+
675
707
  barcodeCountModule.updateBarcodeCount(getViewId(call), barcodeCountJson)
676
708
  call.resolve()
677
709
  }
678
710
 
711
+ @PluginMethod
712
+ fun finishBarcodeCountOnScan(call: PluginCall) {
713
+ barcodeCountModule.finishOnScan(getViewId(call), true)
714
+ call.resolve(null)
715
+ }
716
+
679
717
  @PluginMethod
680
718
  fun registerBarcodeCountListener(call: PluginCall) {
681
719
  barcodeCountModule.addBarcodeCountListener(getViewId(call))
@@ -826,8 +864,6 @@ class ScanditBarcodeNative :
826
864
  barcodeCountModule.updateFeedback(getViewId(call), feedbackJson, CapacitorResult(call))
827
865
  }
828
866
 
829
- //endregion
830
-
831
867
  @PluginMethod
832
868
  fun finishBarcodeCountBrushForRecognizedBarcode(call: PluginCall) {
833
869
  val brushJson = call.data.optString("brushJson", "")
@@ -1267,27 +1303,6 @@ class ScanditBarcodeNative :
1267
1303
 
1268
1304
  //endregion
1269
1305
 
1270
- @PluginMethod
1271
- fun updateBarcodeCaptureOverlay(call: PluginCall) {
1272
- val overlayJson = call.data.getString("overlayJson")
1273
- ?: return call.reject(WRONG_INPUT)
1274
- barcodeCaptureModule.updateOverlay(overlayJson, CapacitorResult(call))
1275
- }
1276
-
1277
- @PluginMethod
1278
- fun updateBarcodeCaptureMode(call: PluginCall) {
1279
- val modeJson = call.data.getString("modeJson")
1280
- ?: return call.reject(WRONG_INPUT)
1281
- barcodeCaptureModule.updateModeFromJson(modeJson, CapacitorResult(call))
1282
- }
1283
-
1284
- @PluginMethod
1285
- fun applyBarcodeCaptureModeSettings(call: PluginCall) {
1286
- val modeSettingsJson = call.data.getString("modeSettingsJson")
1287
- ?: return call.reject(WRONG_INPUT)
1288
- barcodeCaptureModule.applyModeSettings(modeSettingsJson, CapacitorResult(call))
1289
- }
1290
-
1291
1306
  @PluginMethod
1292
1307
  fun updateBarcodeSelectionBasicOverlay(call: PluginCall) {
1293
1308
  val overlayJson = call.data.getString("overlayJson")