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.
Files changed (27) hide show
  1. package/ScanditCapacitorDatacaptureBarcode.podspec +1 -1
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.kt +225 -148
  4. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/count/BarcodeCountViewHandler.kt +4 -4
  5. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/find/BarcodeFindViewHandler.kt +90 -71
  6. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/utils/AdvancedOverlayViewSerialization.kt +7 -4
  7. package/dist/barcode.js +2878 -1364
  8. package/dist/barcode.js.map +1 -1
  9. package/dist/dts/definitions.d.ts +0 -35
  10. package/dist/dts/ts/BarcodeCountView.d.ts +1 -0
  11. package/dist/dts/ts/BarcodePickView.d.ts +3 -0
  12. package/dist/dts/ts/Capacitor/Capacitor.d.ts +0 -14
  13. package/dist/dts/web.d.ts +1 -2
  14. package/dist/index.js +40 -373
  15. package/dist/index.js.map +1 -1
  16. package/ios/Plugin/BarcodeCountViewHandler.swift +4 -4
  17. package/ios/Plugin/BarcodePickViewHandler.swift +4 -4
  18. package/ios/Plugin/CommandJSONArgument+ScanditBarcodeCapture.swift +12 -9
  19. package/ios/Plugin/Plugin.m +11 -8
  20. package/ios/Plugin/ScanditBarcodeCapture.swift +493 -169
  21. package/package.json +4 -4
  22. package/dist/dts/ts/Capacitor/BarcodeBatchAdvancedOverlayProxy.d.ts +0 -23
  23. package/dist/dts/ts/Capacitor/BarcodeBatchBasicOverlayProxy.d.ts +0 -14
  24. package/dist/dts/ts/Capacitor/BarcodeBatchListenerProxy.d.ts +0 -15
  25. package/dist/dts/ts/Capacitor/BarcodeCountViewProxy.d.ts +0 -7
  26. package/dist/dts/ts/Capacitor/BarcodeFindListenerProxy.d.ts +0 -18
  27. package/dist/dts/ts/Capacitor/BarcodeFindViewProxy.d.ts +0 -18
@@ -34,21 +34,10 @@ import com.scandit.capacitor.datacapture.core.utils.CapacitorResult
34
34
  import com.scandit.datacapture.core.ui.style.BrushDeserializer
35
35
  import com.scandit.datacapture.frameworks.barcode.BarcodeModule
36
36
  import com.scandit.datacapture.frameworks.barcode.batch.BarcodeBatchModule
37
- import com.scandit.datacapture.frameworks.barcode.batch.listeners.FrameworksBarcodeBatchAdvancedOverlayListener
38
- import com.scandit.datacapture.frameworks.barcode.batch.listeners.FrameworksBarcodeBatchBasicOverlayListener
39
- import com.scandit.datacapture.frameworks.barcode.batch.listeners.FrameworksBarcodeBatchListener
40
37
  import com.scandit.datacapture.frameworks.barcode.capture.BarcodeCaptureModule
41
38
  import com.scandit.datacapture.frameworks.barcode.capture.listeners.FrameworksBarcodeCaptureListener
42
39
  import com.scandit.datacapture.frameworks.barcode.count.BarcodeCountModule
43
- import com.scandit.datacapture.frameworks.barcode.count.listeners.FrameworksBarcodeCountCaptureListListener
44
- import com.scandit.datacapture.frameworks.barcode.count.listeners.FrameworksBarcodeCountListener
45
- import com.scandit.datacapture.frameworks.barcode.count.listeners.FrameworksBarcodeCountStatusProvider
46
- import com.scandit.datacapture.frameworks.barcode.count.listeners.FrameworksBarcodeCountViewListener
47
- import com.scandit.datacapture.frameworks.barcode.count.listeners.FrameworksBarcodeCountViewUiListener
48
40
  import com.scandit.datacapture.frameworks.barcode.find.BarcodeFindModule
49
- import com.scandit.datacapture.frameworks.barcode.find.listeners.FrameworksBarcodeFindListener
50
- import com.scandit.datacapture.frameworks.barcode.find.listeners.FrameworksBarcodeFindViewUiListener
51
- import com.scandit.datacapture.frameworks.barcode.find.transformer.FrameworksBarcodeFindTransformer
52
41
  import com.scandit.datacapture.frameworks.barcode.generator.BarcodeGeneratorModule
53
42
  import com.scandit.datacapture.frameworks.barcode.pick.BarcodePickModule
54
43
  import com.scandit.datacapture.frameworks.barcode.selection.BarcodeSelectionModule
@@ -87,28 +76,15 @@ class ScanditBarcodeNative :
87
76
  private var corePlugin: PluginHandle? = null
88
77
  private val barcodeModule = BarcodeModule()
89
78
  private val barcodeCaptureModule = BarcodeCaptureModule(FrameworksBarcodeCaptureListener(this))
90
- private val barcodeBatchModule = BarcodeBatchModule(
91
- FrameworksBarcodeBatchListener(this),
92
- FrameworksBarcodeBatchBasicOverlayListener(this),
93
- FrameworksBarcodeBatchAdvancedOverlayListener(this)
94
- )
79
+ private val barcodeBatchModule = BarcodeBatchModule.create(this)
95
80
  private val barcodeSelectionModule = BarcodeSelectionModule(
96
81
  FrameworksBarcodeSelectionListener(this),
97
82
  FrameworksBarcodeSelectionAimedBrushProvider(this),
98
83
  FrameworksBarcodeSelectionTrackedBrushProvider(this)
99
84
  )
100
- private val barcodeCountModule = BarcodeCountModule(
101
- FrameworksBarcodeCountListener(this),
102
- FrameworksBarcodeCountCaptureListListener(this),
103
- FrameworksBarcodeCountViewListener(this),
104
- FrameworksBarcodeCountViewUiListener(this),
105
- FrameworksBarcodeCountStatusProvider(this)
106
- )
107
- private val barcodeFindModule = BarcodeFindModule(
108
- FrameworksBarcodeFindListener(this),
109
- FrameworksBarcodeFindViewUiListener(this),
110
- FrameworksBarcodeFindTransformer(this)
111
- )
85
+ private val barcodeCountModule = BarcodeCountModule.create(this)
86
+
87
+ private val barcodeFindModule = BarcodeFindModule.create(this)
112
88
  private val barcodePickModule = BarcodePickModule(
113
89
  this
114
90
  )
@@ -257,38 +233,41 @@ class ScanditBarcodeNative :
257
233
  }
258
234
 
259
235
  @PluginMethod
260
- fun subscribeBarcodeBatchListener(call: PluginCall) {
261
- barcodeBatchModule.addBarcodeBatchListener()
236
+ fun registerBarcodeBatchListenerForEvents(call: PluginCall) {
237
+ barcodeBatchModule.addBarcodeBatchListener(getModeId(call))
262
238
  call.resolve()
263
239
  }
264
240
 
265
241
  @PluginMethod
266
- fun unsubscribeBarcodeBatchListener(call: PluginCall) {
267
- barcodeBatchModule.removeBarcodeBatchListener()
242
+ fun unregisterBarcodeBatchListenerForEvents(call: PluginCall) {
243
+ barcodeBatchModule.removeBarcodeBatchListener(getModeId(call))
268
244
  call.resolve()
269
245
  }
270
246
 
271
247
  @PluginMethod
272
- fun finishBarcodeBatchDidUpdateSession(call: PluginCall) {
273
- barcodeBatchModule.finishDidUpdateSession(call.data.getBoolean("enabled"))
248
+ fun finishBarcodeBatchDidUpdateSessionCallback(call: PluginCall) {
249
+ barcodeBatchModule.finishDidUpdateSession(
250
+ call.data.getInt("modeId"),
251
+ call.data.getBoolean("enabled")
252
+ )
274
253
  call.resolve()
275
254
  }
276
255
 
277
256
  @PluginMethod
278
257
  fun setBarcodeBatchModeEnabledState(call: PluginCall) {
279
- barcodeBatchModule.setModeEnabled(call.data.getBoolean("enabled"))
258
+ barcodeBatchModule.setModeEnabled(getModeId(call), call.data.getBoolean("enabled"))
280
259
  call.resolve()
281
260
  }
282
261
 
283
262
  @PluginMethod
284
- fun subscribeBarcodeBatchBasicOverlayListener(call: PluginCall) {
285
- barcodeBatchModule.addBasicOverlayListener()
263
+ fun registerListenerForBasicOverlayEvents(call: PluginCall) {
264
+ barcodeBatchModule.addBasicOverlayListener(getDataCaptureViewId(call))
286
265
  call.resolve()
287
266
  }
288
267
 
289
268
  @PluginMethod
290
- fun unsubscribeBarcodeBatchBasicOverlayListener(call: PluginCall) {
291
- barcodeBatchModule.removeBasicOverlayListener()
269
+ fun unregisterListenerForBasicOverlayEvents(call: PluginCall) {
270
+ barcodeBatchModule.removeBasicOverlayListener(getDataCaptureViewId(call))
292
271
  call.resolve()
293
272
  }
294
273
 
@@ -416,14 +395,27 @@ class ScanditBarcodeNative :
416
395
 
417
396
  @PluginMethod
418
397
  fun clearTrackedBarcodeBrushes(call: PluginCall) {
419
- barcodeBatchModule.clearBasicOverlayTrackedBarcodeBrushes()
398
+ barcodeBatchModule.clearBasicOverlayTrackedBarcodeBrushes(getDataCaptureViewId(call))
420
399
  call.resolve()
421
400
  }
422
401
 
423
402
  @PluginMethod
424
403
  fun setBrushForTrackedBarcode(call: PluginCall) {
425
404
  try {
426
- barcodeBatchModule.setBasicOverlayBrushForTrackedBarcode(call.data.toString())
405
+ val brushJson = call.data.getString("brushJson")
406
+ val trackedBarcodeId = call.data.getInteger("trackedBarcodeIdentifier")
407
+ val sessionFrameSequenceId = call.data.optLong("sessionFrameSequenceID")
408
+
409
+ if (brushJson == null || trackedBarcodeId == null) {
410
+ call.reject("Invalid brushJson or trackedBarcodeIdentifier received in setBrushForTrackedBarcode.")
411
+ return
412
+ }
413
+ barcodeBatchModule.setBasicOverlayBrushForTrackedBarcode(
414
+ getDataCaptureViewId(call),
415
+ brushJson,
416
+ trackedBarcodeId,
417
+ sessionFrameSequenceId
418
+ )
427
419
  call.resolve()
428
420
  } catch (e: JSONException) {
429
421
  call.reject(JsonParseError(e.message).toString())
@@ -433,20 +425,20 @@ class ScanditBarcodeNative :
433
425
  }
434
426
 
435
427
  @PluginMethod
436
- fun subscribeBarcodeBatchAdvancedOverlayListener(call: PluginCall) {
437
- barcodeBatchModule.addAdvancedOverlayListener()
428
+ fun registerListenerForAdvancedOverlayEvents(call: PluginCall) {
429
+ barcodeBatchModule.addAdvancedOverlayListener(getDataCaptureViewId(call))
438
430
  call.resolve()
439
431
  }
440
432
 
441
433
  @PluginMethod
442
- fun unsubscribeBarcodeBatchAdvancedOverlayListener(call: PluginCall) {
443
- barcodeBatchModule.removeAdvancedOverlayListener()
434
+ fun unregisterListenerForAdvancedOverlayEvents(call: PluginCall) {
435
+ barcodeBatchModule.removeAdvancedOverlayListener(getDataCaptureViewId(call))
444
436
  call.resolve()
445
437
  }
446
438
 
447
439
  @PluginMethod
448
440
  fun clearTrackedBarcodeViews(call: PluginCall) {
449
- barcodeBatchModule.clearAdvancedOverlayTrackedBarcodeViews()
441
+ barcodeBatchModule.clearAdvancedOverlayTrackedBarcodeViews(getDataCaptureViewId(call))
450
442
  call.resolve()
451
443
  }
452
444
 
@@ -470,6 +462,7 @@ class ScanditBarcodeNative :
470
462
  )
471
463
 
472
464
  barcodeBatchModule.setViewForTrackedBarcode(
465
+ serializationData.dataCaptureViewId,
473
466
  view,
474
467
  serializationData.trackedBarcodeId,
475
468
  serializationData.sessionFrameSequenceId
@@ -485,14 +478,29 @@ class ScanditBarcodeNative :
485
478
  call.resolve()
486
479
  }
487
480
 
481
+ @PluginMethod
482
+ fun updateSizeOfTrackedBarcodeView(@Suppress("UNUSED_PARAMETER") call: PluginCall) {
483
+ // https://scandit.atlassian.net/browse/SDC-26621
484
+ }
485
+
488
486
  @PluginMethod
489
487
  fun setOffsetForTrackedBarcode(call: PluginCall) {
490
488
  try {
489
+ val offsetJson = call.data.getString("offsetJson")
490
+ val trackedBarcodeId = call.data.getInteger("trackedBarcodeIdentifier")
491
+ val sessionFrameSequenceId = call.data.optLong("sessionFrameSequenceID")
492
+
493
+ if (offsetJson == null || trackedBarcodeId == null) {
494
+ call.reject("Invalid offsetJson or trackedBarcodeIdentifier received in setOffsetForTrackedBarcode.")
495
+ return
496
+ }
497
+
491
498
  barcodeBatchModule.setOffsetForTrackedBarcode(
492
- hashMapOf(
493
- "offset" to call.data.getString("offset"),
494
- "identifier" to call.data.getInt("trackedBarcodeID")
495
- )
499
+ offsetJson,
500
+ trackedBarcodeId,
501
+ sessionFrameSequenceId,
502
+ getDataCaptureViewId(call)
503
+
496
504
  )
497
505
  call.resolve()
498
506
  } catch (e: JSONException) {
@@ -505,11 +513,20 @@ class ScanditBarcodeNative :
505
513
  @PluginMethod
506
514
  fun setAnchorForTrackedBarcode(call: PluginCall) {
507
515
  try {
516
+ val anchorJson = call.data.getString("anchor")
517
+ val trackedBarcodeId = call.data.getInteger("trackedBarcodeIdentifier")
518
+ val sessionFrameSequenceId = call.data.optLong("sessionFrameSequenceID")
519
+
520
+ if (anchorJson == null || trackedBarcodeId == null) {
521
+ call.reject("Invalid anchorJson or trackedBarcodeIdentifier received in setAnchorForTrackedBarcode.")
522
+ return
523
+ }
524
+
508
525
  barcodeBatchModule.setAnchorForTrackedBarcode(
509
- hashMapOf(
510
- "anchor" to call.data.getString("anchor"),
511
- "identifier" to call.data.getInt("trackedBarcodeID")
512
- )
526
+ anchorJson,
527
+ trackedBarcodeId,
528
+ sessionFrameSequenceId,
529
+ getDataCaptureViewId(call)
513
530
  )
514
531
  call.resolve()
515
532
  } catch (e: JSONException) {
@@ -609,7 +626,7 @@ class ScanditBarcodeNative :
609
626
  //region Barcode Count Listener
610
627
  @PluginMethod
611
628
  fun finishBarcodeCountOnScan(call: PluginCall) {
612
- barcodeCountModule.finishOnScan(true)
629
+ barcodeCountModule.finishOnScan(getViewId(call), true)
613
630
  call.resolve(null)
614
631
  }
615
632
 
@@ -634,94 +651,94 @@ class ScanditBarcodeNative :
634
651
 
635
652
  @PluginMethod
636
653
  fun removeBarcodeCountView(call: PluginCall) {
637
- barcodeCountModule.viewDisposed()
654
+ barcodeCountModule.viewDisposed(getViewId(call))
638
655
  barcodeCountViewHandler.disposeCurrentView()
639
656
  call.resolve()
640
657
  }
641
658
 
642
659
  @PluginMethod
643
660
  fun updateBarcodeCountView(call: PluginCall) {
644
- val view = barcodeCountViewHandler.barcodeCountView
661
+ val view = barcodeCountViewHandler.currentBarcodeCountView
645
662
  if (view == null) {
646
663
  call.reject("The barcode count view has not been initialized yet.")
647
664
  return
648
665
  }
649
666
 
650
667
  val viewJson = call.data.getString("viewJson")!!
651
- barcodeCountModule.updateBarcodeCountView(viewJson)
668
+ barcodeCountModule.updateBarcodeCountView(getViewId(call), viewJson)
652
669
  call.resolve()
653
670
  }
654
671
 
655
672
  @PluginMethod
656
673
  fun updateBarcodeCountMode(call: PluginCall) {
657
674
  val barcodeCountJson = call.data.getString("barcodeCountJson")!!
658
- barcodeCountModule.updateBarcodeCount(barcodeCountJson)
675
+ barcodeCountModule.updateBarcodeCount(getViewId(call), barcodeCountJson)
659
676
  call.resolve()
660
677
  }
661
678
 
662
679
  @PluginMethod
663
680
  fun registerBarcodeCountListener(call: PluginCall) {
664
- barcodeCountModule.addBarcodeCountListener()
681
+ barcodeCountModule.addBarcodeCountListener(getViewId(call))
665
682
  call.resolve()
666
683
  }
667
684
 
668
685
  @PluginMethod
669
686
  fun unregisterBarcodeCountListener(call: PluginCall) {
670
- barcodeCountModule.removeBarcodeCountListener()
687
+ barcodeCountModule.removeBarcodeCountListener(getViewId(call))
671
688
  call.resolve()
672
689
  }
673
690
 
674
691
  @PluginMethod
675
692
  fun registerBarcodeCountViewListener(call: PluginCall) {
676
- barcodeCountModule.addBarcodeCountViewListener()
693
+ barcodeCountModule.addBarcodeCountViewListener(getViewId(call))
677
694
  call.resolve()
678
695
  }
679
696
 
680
697
  @PluginMethod
681
698
  fun unregisterBarcodeCountViewListener(call: PluginCall) {
682
- barcodeCountModule.removeBarcodeCountViewListener()
699
+ barcodeCountModule.removeBarcodeCountViewListener(getViewId(call))
683
700
  call.resolve()
684
701
  }
685
702
 
686
703
  @PluginMethod
687
704
  fun registerBarcodeCountViewUiListener(call: PluginCall) {
688
- barcodeCountModule.addBarcodeCountViewUiListener()
705
+ barcodeCountModule.addBarcodeCountViewUiListener(getViewId(call))
689
706
  call.resolve()
690
707
  }
691
708
 
692
709
  @PluginMethod
693
710
  fun unregisterBarcodeCountViewUiListener(call: PluginCall) {
694
- barcodeCountModule.removeBarcodeCountViewUiListener()
711
+ barcodeCountModule.removeBarcodeCountViewUiListener(getViewId(call))
695
712
  call.resolve()
696
713
  }
697
714
 
698
715
  @PluginMethod
699
716
  fun resetBarcodeCountSession(call: PluginCall) {
700
- barcodeCountModule.resetBarcodeCountSession(null)
717
+ barcodeCountModule.resetBarcodeCountSession(getViewId(call), null)
701
718
  call.resolve()
702
719
  }
703
720
 
704
721
  @PluginMethod
705
722
  fun resetBarcodeCount(call: PluginCall) {
706
- barcodeCountModule.resetBarcodeCount()
723
+ barcodeCountModule.resetBarcodeCount(getViewId(call))
707
724
  call.resolve()
708
725
  }
709
726
 
710
727
  @PluginMethod
711
728
  fun startBarcodeCountScanningPhase(call: PluginCall) {
712
- barcodeCountModule.startScanningPhase()
729
+ barcodeCountModule.startScanningPhase(getViewId(call))
713
730
  call.resolve()
714
731
  }
715
732
 
716
733
  @PluginMethod
717
734
  fun endBarcodeCountScanningPhase(call: PluginCall) {
718
- barcodeCountModule.endScanningPhase()
735
+ barcodeCountModule.endScanningPhase(getViewId(call))
719
736
  call.resolve()
720
737
  }
721
738
 
722
739
  @PluginMethod
723
740
  fun clearBarcodeCountViewHighlights(call: PluginCall) {
724
- barcodeCountModule.clearHighlights()
741
+ barcodeCountModule.clearHighlights(getViewId(call))
725
742
  call.resolve()
726
743
  }
727
744
 
@@ -735,7 +752,7 @@ class ScanditBarcodeNative :
735
752
  }
736
753
 
737
754
  val barcodes = call.data.getJSONArray("TargetBarcodes")
738
- barcodeCountModule.setBarcodeCountCaptureList(barcodes)
755
+ barcodeCountModule.setBarcodeCountCaptureList(getViewId(call), barcodes)
739
756
  call.resolve()
740
757
  }
741
758
 
@@ -765,19 +782,19 @@ class ScanditBarcodeNative :
765
782
 
766
783
  @PluginMethod
767
784
  fun showBarcodeCountView(call: PluginCall) {
768
- barcodeCountViewHandler.setVisible()
785
+ barcodeCountModule.showView(getViewId(call))
769
786
  call.resolve()
770
787
  }
771
788
 
772
789
  @PluginMethod
773
790
  fun hideBarcodeCountView(call: PluginCall) {
774
- barcodeCountViewHandler.setInvisible()
791
+ barcodeCountModule.hideView(getViewId(call))
775
792
  call.resolve()
776
793
  }
777
794
 
778
795
  @PluginMethod
779
796
  fun getBarcodeCountSpatialMap(call: PluginCall) {
780
- barcodeCountModule.submitSpatialMap(CapacitorResult(call))
797
+ barcodeCountModule.submitSpatialMap(getViewId(call), CapacitorResult(call))
781
798
  }
782
799
 
783
800
  @PluginMethod
@@ -785,6 +802,7 @@ class ScanditBarcodeNative :
785
802
  val expectedNumberOfRows = call.data.getInteger("expectedNumberOfRows")!!
786
803
  val expectedNumberOfColumns = call.data.getInteger("expectedNumberOfColumns")!!
787
804
  barcodeCountModule.submitSpatialMap(
805
+ getViewId(call),
788
806
  expectedNumberOfRows,
789
807
  expectedNumberOfColumns,
790
808
  CapacitorResult(call)
@@ -794,7 +812,7 @@ class ScanditBarcodeNative :
794
812
  @PluginMethod
795
813
  fun setBarcodeCountModeEnabledState(call: PluginCall) {
796
814
  val isEnabled = call.data.getBoolean("isEnabled")
797
- barcodeCountModule.setModeEnabled(isEnabled)
815
+ barcodeCountModule.setModeEnabled(getViewId(call), isEnabled)
798
816
  call.resolve()
799
817
  }
800
818
 
@@ -805,7 +823,7 @@ class ScanditBarcodeNative :
805
823
  call.reject("No feedbackJson was provided for the function.")
806
824
  return
807
825
  }
808
- barcodeCountModule.updateFeedback(feedbackJson, CapacitorResult(call))
826
+ barcodeCountModule.updateFeedback(getViewId(call), feedbackJson, CapacitorResult(call))
809
827
  }
810
828
 
811
829
  //endregion
@@ -815,7 +833,11 @@ class ScanditBarcodeNative :
815
833
  val brushJson = call.data.optString("brushJson", "")
816
834
  val brush = if (brushJson.isNullOrBlank()) null else BrushDeserializer.fromJson(brushJson)
817
835
  val trackedBarcodeId = call.data.getInt("trackedBarcodeId")
818
- barcodeCountModule.finishBrushForRecognizedBarcodeEvent(brush, trackedBarcodeId)
836
+ barcodeCountModule.finishBrushForRecognizedBarcodeEvent(
837
+ getViewId(call),
838
+ brush,
839
+ trackedBarcodeId
840
+ )
819
841
  call.resolve()
820
842
  }
821
843
 
@@ -824,7 +846,11 @@ class ScanditBarcodeNative :
824
846
  val brushJson = call.data.optString("brushJson", "")
825
847
  val brush = if (brushJson.isNullOrBlank()) null else BrushDeserializer.fromJson(brushJson)
826
848
  val trackedBarcodeId = call.data.getInt("trackedBarcodeId")
827
- barcodeCountModule.finishBrushForRecognizedBarcodeNotInListEvent(brush, trackedBarcodeId)
849
+ barcodeCountModule.finishBrushForRecognizedBarcodeNotInListEvent(
850
+ getViewId(call),
851
+ brush,
852
+ trackedBarcodeId
853
+ )
828
854
  call.resolve()
829
855
  }
830
856
 
@@ -833,7 +859,11 @@ class ScanditBarcodeNative :
833
859
  val brushJson = call.data.optString("brushJson", "")
834
860
  val brush = if (brushJson.isNullOrBlank()) null else BrushDeserializer.fromJson(brushJson)
835
861
  val trackedBarcodeId = call.data.getInt("trackedBarcodeId")
836
- barcodeCountModule.finishBrushForAcceptedBarcodeEvent(brush, trackedBarcodeId)
862
+ barcodeCountModule.finishBrushForAcceptedBarcodeEvent(
863
+ getViewId(call),
864
+ brush,
865
+ trackedBarcodeId
866
+ )
837
867
  call.resolve()
838
868
  }
839
869
 
@@ -842,7 +872,11 @@ class ScanditBarcodeNative :
842
872
  val brushJson = call.data.optString("brushJson", "")
843
873
  val brush = if (brushJson.isNullOrBlank()) null else BrushDeserializer.fromJson(brushJson)
844
874
  val trackedBarcodeId = call.data.getInt("trackedBarcodeId")
845
- barcodeCountModule.finishBrushForRejectedBarcodeEvent(brush, trackedBarcodeId)
875
+ barcodeCountModule.finishBrushForRejectedBarcodeEvent(
876
+ getViewId(call),
877
+ brush,
878
+ trackedBarcodeId
879
+ )
846
880
  call.resolve()
847
881
  }
848
882
 
@@ -852,6 +886,7 @@ class ScanditBarcodeNative :
852
886
  call.data.getInteger("hardwareTriggerKeyCode")
853
887
  } else null
854
888
  barcodeCountModule.enableHardwareTrigger(
889
+ getViewId(call),
855
890
  hardwareTriggerKeyCode,
856
891
  CapacitorResult(call)
857
892
  )
@@ -911,136 +946,137 @@ class ScanditBarcodeNative :
911
946
  fun createFindView(
912
947
  call: PluginCall
913
948
  ) {
914
- val viewJson = call.data
949
+ val viewJson = call.data.getString("json")
950
+ ?: return call.reject("missing parameter for createFindView()")
915
951
 
916
- if (viewJson.has("View")) {
917
- val container = barcodeFindViewHandler.prepareContainer(this.context)
918
-
919
- val result = barcodeFindModule.getView(container, viewJson.toString())
920
- if (result.isFailure) {
921
- call.reject(
922
- result.exceptionOrNull()?.message
923
- ?: "Unable to create the BarcodeFindView from the given json=$viewJson"
924
- )
925
- return
926
- }
952
+ val container = barcodeFindViewHandler.prepareContainer(this.context)
927
953
 
928
- barcodeFindViewHandler.addBarcodeFindViewContainer(container, bridge.activity)
929
- barcodeFindViewHandler.render()
930
- call.resolve()
931
- } else {
932
- call.reject("missing parameter for createFindView()")
933
- }
954
+ barcodeFindModule.addViewToContainer(container, viewJson, CapacitorResult(call))
955
+ barcodeFindViewHandler.addBarcodeFindViewContainer(getViewId(call), container, bridge.activity)
934
956
  }
935
957
 
936
958
  @PluginMethod
937
959
  fun updateFindView(call: PluginCall) {
938
960
  barcodeFindModule.updateBarcodeFindView(
939
- call.data["View"].toString(),
961
+ getViewId(call),
962
+ call.data["barcodeFindViewJson"].toString(),
940
963
  CapacitorResult(call)
941
964
  )
942
965
  }
943
966
 
944
967
  @PluginMethod
945
968
  fun removeFindView(call: PluginCall) {
946
- barcodeFindModule.viewDisposed()
947
- barcodeFindViewHandler.disposeCurrentView()
969
+ val viewId = getViewId(call)
970
+ barcodeFindModule.viewDisposed(viewId)
971
+ barcodeFindViewHandler.disposeContainer(viewId)
948
972
  call.resolve()
949
973
  }
950
974
 
951
975
  @PluginMethod
952
976
  fun updateFindMode(call: PluginCall) {
953
977
  barcodeFindModule.updateBarcodeFindMode(
954
- call.data["BarcodeFind"].toString(),
978
+ getViewId(call),
979
+ call.data["barcodeFindJson"].toString(),
955
980
  CapacitorResult(call)
956
981
  )
957
982
  }
958
983
 
959
984
  @PluginMethod
960
985
  fun registerBarcodeFindListener(call: PluginCall) {
961
- barcodeFindModule.addBarcodeFindListener(CapacitorResult(call))
986
+ barcodeFindModule.addBarcodeFindListener(getViewId(call), CapacitorResult(call))
962
987
  }
963
988
 
964
989
  @PluginMethod
965
990
  fun unregisterBarcodeFindListener(call: PluginCall) {
966
- barcodeFindModule.removeBarcodeFindListener(CapacitorResult(call))
991
+ barcodeFindModule.removeBarcodeFindListener(getViewId(call), CapacitorResult(call))
967
992
  }
968
993
 
969
994
  @PluginMethod
970
995
  fun registerBarcodeFindViewListener(call: PluginCall) {
971
- barcodeFindModule.addBarcodeFindViewListener(CapacitorResult(call))
996
+ barcodeFindModule.addBarcodeFindViewListener(getViewId(call), CapacitorResult(call))
972
997
  }
973
998
 
974
999
  @PluginMethod
975
1000
  fun unregisterBarcodeFindViewListener(call: PluginCall) {
976
- barcodeFindModule.removeBarcodeFindViewListener(CapacitorResult(call))
1001
+ barcodeFindModule.removeBarcodeFindViewListener(getViewId(call), CapacitorResult(call))
977
1002
  }
978
1003
 
979
1004
  @PluginMethod
980
1005
  fun barcodeFindSetItemList(call: PluginCall) {
981
1006
  barcodeFindModule.setItemList(
982
- call.data["BarcodeFindItemList"].toString(),
1007
+ getViewId(call),
1008
+ call.data["itemsJson"].toString(),
983
1009
  CapacitorResult(call)
984
1010
  )
985
1011
  }
986
1012
 
987
1013
  @PluginMethod
988
1014
  fun barcodeFindViewStopSearching(call: PluginCall) {
989
- barcodeFindModule.viewStopSearching(CapacitorResult(call))
1015
+ barcodeFindModule.viewStopSearching(getViewId(call), CapacitorResult(call))
990
1016
  }
991
1017
 
992
1018
  @PluginMethod
993
1019
  fun barcodeFindViewStartSearching(call: PluginCall) {
994
- barcodeFindModule.viewStartSearching(CapacitorResult(call))
1020
+ barcodeFindModule.viewStartSearching(getViewId(call), CapacitorResult(call))
995
1021
  }
996
1022
 
997
1023
  @PluginMethod
998
1024
  fun barcodeFindViewPauseSearching(call: PluginCall) {
999
- barcodeFindModule.viewPauseSearching(CapacitorResult(call))
1025
+ barcodeFindModule.viewPauseSearching(getViewId(call), CapacitorResult(call))
1000
1026
  }
1001
1027
 
1002
1028
  @PluginMethod
1003
1029
  fun barcodeFindModeStart(call: PluginCall) {
1004
- barcodeFindModule.modeStart(CapacitorResult(call))
1030
+ barcodeFindModule.modeStart(getViewId(call), CapacitorResult(call))
1005
1031
  }
1006
1032
 
1007
1033
  @PluginMethod
1008
1034
  fun barcodeFindModePause(call: PluginCall) {
1009
- barcodeFindModule.modePause(CapacitorResult(call))
1035
+ barcodeFindModule.modePause(getViewId(call), CapacitorResult(call))
1010
1036
  }
1011
1037
 
1012
1038
  @PluginMethod
1013
1039
  fun barcodeFindModeStop(call: PluginCall) {
1014
- barcodeFindModule.modeStop(CapacitorResult(call))
1040
+ barcodeFindModule.modeStop(getViewId(call), CapacitorResult(call))
1015
1041
  }
1016
1042
 
1017
1043
  @PluginMethod
1018
1044
  fun showFindView(call: PluginCall) {
1019
- barcodeFindViewHandler.setVisible()
1045
+ val viewId = getViewId(call)
1046
+ barcodeFindViewHandler.setVisible(viewId)
1047
+ barcodeFindModule.showView(viewId)
1020
1048
  call.resolve()
1021
1049
  }
1022
1050
 
1023
1051
  @PluginMethod
1024
1052
  fun hideFindView(call: PluginCall) {
1025
- barcodeFindViewHandler.setInvisible()
1053
+ val viewId = getViewId(call)
1054
+ barcodeFindViewHandler.setInvisible(viewId)
1055
+ barcodeFindModule.hideView(viewId)
1026
1056
  call.resolve()
1027
1057
  }
1028
1058
 
1029
1059
  @PluginMethod
1030
1060
  fun setBarcodeFindModeEnabledState(call: PluginCall) {
1031
- barcodeFindModule.setModeEnabled(call.data.getBoolean("enabled"))
1061
+ barcodeFindModule.setModeEnabled(getViewId(call), call.data.getBoolean("enabled"))
1032
1062
  call.resolve()
1033
1063
  }
1034
1064
 
1035
1065
  @PluginMethod
1036
1066
  fun setBarcodeTransformer(call: PluginCall) {
1037
- barcodeFindModule.setBarcodeFindTransformer(CapacitorResult(call))
1067
+ barcodeFindModule.setBarcodeFindTransformer(getViewId(call), CapacitorResult(call))
1068
+ }
1069
+
1070
+ @PluginMethod
1071
+ fun unsetBarcodeTransformer(call: PluginCall) {
1072
+ barcodeFindModule.unsetBarcodeFindTransformer(getViewId(call), CapacitorResult(call))
1038
1073
  }
1039
1074
 
1040
1075
  @PluginMethod
1041
1076
  fun submitBarcodeFindTransformerResult(call: PluginCall) {
1042
1077
  val transformedBarcode = call.data.getString("transformedBarcode", null)
1043
1078
  barcodeFindModule.submitBarcodeFindTransformerResult(
1079
+ getViewId(call),
1044
1080
  transformedBarcode,
1045
1081
  CapacitorResult(call)
1046
1082
  )
@@ -1053,7 +1089,7 @@ class ScanditBarcodeNative :
1053
1089
  call.reject("No feedbackJson was provided for the function.")
1054
1090
  return
1055
1091
  }
1056
- barcodeFindModule.updateFeedback(feedbackJson, CapacitorResult(call))
1092
+ barcodeFindModule.updateFeedback(getViewId(call), feedbackJson, CapacitorResult(call))
1057
1093
  }
1058
1094
 
1059
1095
  //endregion
@@ -1079,16 +1115,14 @@ class ScanditBarcodeNative :
1079
1115
 
1080
1116
  @PluginMethod
1081
1117
  fun removePickView(call: PluginCall) {
1082
- barcodePickModule.viewDisposed()
1118
+ barcodePickModule.releasePickView(getViewId(call), CapacitorResult(call))
1083
1119
  barcodePickViewHandler.disposeCurrentView()
1084
- call.resolve()
1085
1120
  }
1086
1121
 
1087
1122
  @PluginMethod
1088
1123
  fun updatePickView(call: PluginCall) {
1089
1124
  val viewJson = call.data.toString()
1090
- barcodePickModule.updateView(viewJson, CapacitorResult(call))
1091
- call.resolve()
1125
+ barcodePickModule.updateView(getViewId(call), viewJson, CapacitorResult(call))
1092
1126
  }
1093
1127
 
1094
1128
  @PluginMethod
@@ -1116,54 +1150,65 @@ class ScanditBarcodeNative :
1116
1150
 
1117
1151
  @PluginMethod
1118
1152
  fun addPickActionListener(call: PluginCall) {
1119
- barcodePickModule.addActionListener()
1120
- call.resolve()
1153
+ barcodePickModule.addActionListener(getViewId(call), CapacitorResult(call))
1121
1154
  }
1122
1155
 
1123
1156
  @PluginMethod
1124
1157
  fun removePickActionListener(call: PluginCall) {
1125
- barcodePickModule.removeActionListener()
1126
- call.resolve()
1158
+ barcodePickModule.removeActionListener(getViewId(call), CapacitorResult(call))
1127
1159
  }
1128
1160
 
1129
1161
  @PluginMethod
1130
1162
  fun addBarcodePickScanningListener(call: PluginCall) {
1131
- barcodePickModule.addScanningListener(CapacitorResult(call))
1163
+ barcodePickModule.addScanningListener(getViewId(call), CapacitorResult(call))
1132
1164
  }
1133
1165
 
1134
1166
  @PluginMethod
1135
1167
  fun removeBarcodePickScanningListener(call: PluginCall) {
1136
- barcodePickModule.removeScanningListener(CapacitorResult(call))
1168
+ barcodePickModule.removeScanningListener(getViewId(call), CapacitorResult(call))
1137
1169
  }
1138
1170
 
1139
1171
  @PluginMethod
1140
1172
  fun addPickViewListener(call: PluginCall) {
1141
- barcodePickModule.addViewListener(CapacitorResult(call))
1173
+ barcodePickModule.addViewListener(getViewId(call), CapacitorResult(call))
1142
1174
  }
1143
1175
 
1144
1176
  @PluginMethod
1145
1177
  fun removePickViewListener(call: PluginCall) {
1146
- barcodePickModule.removeViewListener(CapacitorResult(call))
1178
+ barcodePickModule.removeViewListener(getViewId(call), CapacitorResult(call))
1179
+ }
1180
+
1181
+ @PluginMethod
1182
+ fun addBarcodePickListener(call: PluginCall) {
1183
+ barcodePickModule.addBarcodePickListener(getViewId(call), CapacitorResult(call))
1184
+ }
1185
+
1186
+ @PluginMethod
1187
+ fun removeBarcodePickListener(call: PluginCall) {
1188
+ barcodePickModule.removeBarcodePickListener(getViewId(call), CapacitorResult(call))
1147
1189
  }
1148
1190
 
1149
1191
  @PluginMethod
1150
1192
  fun registerBarcodePickViewUiListener(call: PluginCall) {
1151
- barcodePickModule.addViewUiListener(CapacitorResult(call))
1193
+ barcodePickModule.addViewUiListener(getViewId(call), CapacitorResult(call))
1152
1194
  }
1153
1195
 
1154
1196
  @PluginMethod
1155
1197
  fun unregisterBarcodePickViewUiListener(call: PluginCall) {
1156
- barcodePickModule.removeViewUiListener(CapacitorResult(call))
1198
+ barcodePickModule.removeViewUiListener(getViewId(call), CapacitorResult(call))
1157
1199
  }
1158
1200
 
1159
1201
  @PluginMethod
1160
1202
  fun finishOnProductIdentifierForItems(call: PluginCall) {
1161
- val barcodePickProductProviderCallbackItemsJson =
1162
- JSONArray(call.getString("itemsJson")).toString()
1203
+ val itemsJson = call.data.getString("itemsJson") ?: ""
1204
+ val response = hashMapOf<String, Any?>(
1205
+ "viewId" to getViewId(call),
1206
+ "data" to itemsJson
1207
+ )
1163
1208
  barcodePickModule.finishOnProductIdentifierForItems(
1164
- barcodePickProductProviderCallbackItemsJson
1209
+ response,
1210
+ CapacitorResult(call)
1165
1211
  )
1166
- call.resolve()
1167
1212
  }
1168
1213
 
1169
1214
  @PluginMethod
@@ -1180,31 +1225,43 @@ class ScanditBarcodeNative :
1180
1225
 
1181
1226
  @PluginMethod
1182
1227
  fun pickViewStart(call: PluginCall) {
1183
- barcodePickModule.viewStart()
1184
- call.resolve()
1228
+ barcodePickModule.startPickView(getViewId(call), CapacitorResult(call))
1185
1229
  }
1186
1230
 
1187
1231
  @PluginMethod
1188
1232
  fun pickViewFreeze(call: PluginCall) {
1189
- barcodePickModule.viewFreeze(CapacitorResult(call))
1233
+ barcodePickModule.freezePickView(getViewId(call), CapacitorResult(call))
1190
1234
  }
1191
1235
 
1192
1236
  @PluginMethod
1193
1237
  fun pickViewStop(call: PluginCall) {
1194
- barcodePickModule.viewStop()
1195
- call.resolve()
1238
+ barcodePickModule.stopPickView(getViewId(call), CapacitorResult(call))
1239
+ }
1240
+
1241
+ @PluginMethod
1242
+ fun pickViewPause(call: PluginCall) {
1243
+ barcodePickModule.pausePickView(getViewId(call), CapacitorResult(call))
1244
+ }
1245
+
1246
+ @PluginMethod
1247
+ fun pickViewResume(call: PluginCall) {
1248
+ barcodePickModule.resumePickView(getViewId(call), CapacitorResult(call))
1196
1249
  }
1197
1250
 
1198
1251
  @PluginMethod
1199
1252
  fun finishPickAction(call: PluginCall) {
1200
- val itemDataJson = call.getString("code")
1201
1253
  val result = call.getBoolean("result")
1202
1254
 
1203
- if (itemDataJson == null || result == null) {
1255
+ if (result == null) {
1204
1256
  call.reject("failed to parse finishPickAction JSON.")
1205
1257
  } else {
1206
- barcodePickModule.finishPickAction(itemDataJson, result)
1207
- call.resolve()
1258
+ val itemData = call.data.getString("code") ?: ""
1259
+ val response = hashMapOf<String, Any?>(
1260
+ "viewId" to getViewId(call),
1261
+ "itemData" to itemData,
1262
+ "result" to result
1263
+ )
1264
+ barcodePickModule.finishPickAction(response, CapacitorResult(call))
1208
1265
  }
1209
1266
  }
1210
1267
 
@@ -1263,14 +1320,22 @@ class ScanditBarcodeNative :
1263
1320
  fun updateBarcodeBatchBasicOverlay(call: PluginCall) {
1264
1321
  val overlayJson = call.data.getString("overlayJson")
1265
1322
  ?: return call.reject(WRONG_INPUT)
1266
- barcodeBatchModule.updateBasicOverlay(overlayJson, CapacitorResult(call))
1323
+ barcodeBatchModule.updateBasicOverlay(
1324
+ getDataCaptureViewId(call),
1325
+ overlayJson,
1326
+ CapacitorResult(call)
1327
+ )
1267
1328
  }
1268
1329
 
1269
1330
  @PluginMethod
1270
1331
  fun updateBarcodeBatchAdvancedOverlay(call: PluginCall) {
1271
1332
  val overlayJson = call.data.getString("overlayJson")
1272
1333
  ?: return call.reject(WRONG_INPUT)
1273
- barcodeBatchModule.updateAdvancedOverlay(overlayJson, CapacitorResult(call))
1334
+ barcodeBatchModule.updateAdvancedOverlay(
1335
+ getDataCaptureViewId(call),
1336
+ overlayJson,
1337
+ CapacitorResult(call)
1338
+ )
1274
1339
  }
1275
1340
 
1276
1341
  @PluginMethod
@@ -1284,7 +1349,11 @@ class ScanditBarcodeNative :
1284
1349
  fun applyBarcodeBatchModeSettings(call: PluginCall) {
1285
1350
  val modeSettingsJson = call.data.getString("modeSettingsJson")
1286
1351
  ?: return call.reject(WRONG_INPUT)
1287
- barcodeBatchModule.applyModeSettings(modeSettingsJson, CapacitorResult(call))
1352
+ barcodeBatchModule.applyModeSettings(
1353
+ getModeId(call),
1354
+ modeSettingsJson,
1355
+ CapacitorResult(call)
1356
+ )
1288
1357
  }
1289
1358
 
1290
1359
  @PluginMethod
@@ -1449,6 +1518,14 @@ class ScanditBarcodeNative :
1449
1518
  return call.data.getInt("viewId")
1450
1519
  }
1451
1520
 
1521
+ private fun getModeId(call: PluginCall): Int {
1522
+ return call.data.getInt("modeId")
1523
+ }
1524
+
1525
+ private fun getDataCaptureViewId(call: PluginCall): Int {
1526
+ return call.data.getInt("dataCaptureViewId")
1527
+ }
1528
+
1452
1529
  @PluginMethod
1453
1530
  fun createBarcodeGenerator(call: PluginCall) {
1454
1531
  val barcodeGeneratorJson = call.data.getString("barcodeGeneratorJson")