barkoder-nativescript 0.0.3 → 0.0.5

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.
@@ -0,0 +1,840 @@
1
+ import { BarkoderConstants } from './barkoder-nativescript.common';
2
+ import * as application from "@nativescript/core/application";
3
+ import { View } from '@nativescript/core';
4
+ import { BarkoderView } from './barkoder-nativescript.common';
5
+
6
+ const androidSupport = global.androidx && global.androidx.appcompat ? global.androidx.core.app : android.support.v4.app;
7
+ declare const com, global: any;
8
+
9
+ const context = application.android.context;
10
+ const Manifest = android.Manifest;
11
+
12
+
13
+ export class BarkoderViewAndroid extends View {
14
+ public bkdView : any
15
+ public bkd : any
16
+ public bkdConfig : any
17
+ public bkdHelper : any
18
+
19
+ constructor() {
20
+ super();
21
+ this.bkdConfig = com.barkoder.BarkoderConfig
22
+ this.bkd = new com.barkoder.Barkoder()
23
+ this.bkdView = new com.barkoder.BarkoderView(context, true)
24
+ this.bkdView.config = new com.barkoder.BarkoderConfig(context, "asdad", null);
25
+ this.bkdHelper = new com.barkoder.BarkoderHelper()
26
+ // console.log(this._licenseKey)
27
+ this.nativeView = this.bkdView
28
+
29
+ }
30
+
31
+ startScanning(callback: BarkoderConstants.BarkoderResultCallback): void {
32
+ const resultCallback = new com.barkoder.interfaces.BarkoderResultCallback({
33
+ scanningFinished: (results: any[], thumbnails: any[], resultImage: any) => {
34
+ callback.scanningFinished(results, thumbnails, resultImage);
35
+ }
36
+ });
37
+ this.bkdView.startScanning(resultCallback);
38
+ }
39
+
40
+ stopScanning(): void {
41
+ this.bkdView.stopScanning()
42
+ }
43
+
44
+ pauseScanning() : void {
45
+ this.bkdView.pauseScanning()
46
+ }
47
+
48
+ isFlashAvailable(callback : BarkoderConstants.FlashAvailableCallback) {
49
+ const isFlashAvailableCallback = new com.barkoder.interfaces.FlashAvailableCallback({
50
+ onFlashAvailable: (isFlashAvailable: any) => {
51
+ callback.onFlashAvailable(isFlashAvailable)
52
+ }
53
+ });
54
+ this.bkdView.isFlashAvailable(isFlashAvailableCallback)
55
+ }
56
+
57
+ setFlashEnabled(value : boolean) : void {
58
+ this.bkdView.setFlashEnabled(value)
59
+ }
60
+
61
+ getMaxZoomFactor(callback : BarkoderConstants.MaxZoomAvailableCallback) {
62
+ const MaxZoomCallback = new com.barkoder.interfaces.MaxZoomAvailableCallback({
63
+ onMaxZoomAvailable: (maxZoomFacttor: any) => {
64
+ callback.onMaxZoomAvailable(maxZoomFacttor)
65
+ }
66
+ });
67
+ this.bkdView.getMaxZoomFactor(MaxZoomCallback)
68
+ }
69
+
70
+ setZoomFactor(value : number) : void {
71
+ this.bkdView.setZoomFactor(value)
72
+ }
73
+
74
+ getLocationLineColorHex() : any {
75
+ return this.bkdView.config.getLocationLineColor()
76
+ }
77
+
78
+ setLocationLineColor(locationLineColor : string) : void {
79
+ const locationColor = this.hexToAndroidColor(locationLineColor)
80
+ this.bkdView.config.setLocationLineColor(locationColor)
81
+ }
82
+
83
+ setRoiLineColor(roiLineColor: string) : void {
84
+ const roiLineColorHex = this.hexToAndroidColor(roiLineColor)
85
+ this.bkdView.config.setRoiLineColor(roiLineColorHex)
86
+ }
87
+
88
+ setRoiLineWidth(roiLineWidth : number) : void {
89
+ this.bkdView.config.setRoiLineWidth(roiLineWidth)
90
+ }
91
+
92
+ setRoiOverlayBackgroundColor(roiOverlayBackgroundColor) : void {
93
+ const roiOberlayBackgroundColor = this.hexToAndroidColor(roiOverlayBackgroundColor)
94
+ this.bkdView.config.setRoiOverlayBackgroundColor(roiOberlayBackgroundColor)
95
+ }
96
+
97
+ setCloseSessionOnResultEnabled(enabled : boolean) : void {
98
+ this.bkdView.config.setCloseSessionOnResultEnabled(enabled)
99
+ }
100
+
101
+ setImageResultEnabled(enabled : boolean): void {
102
+ this.bkdView.config.setImageResultEnabled(enabled);
103
+ }
104
+
105
+ setLocationInImageResultEnabled(enabled : boolean) : void {
106
+ this.bkdView.config.setLocationInImageResultEnabled(enabled)
107
+ }
108
+
109
+ setLocationInPreviewEnabled(enabled : boolean) : void {
110
+ this.bkdView.config.setLocationInPreviewEnabled(enabled)
111
+ }
112
+
113
+ setPinchToZoomEnabled(enabled : boolean) : void {
114
+ this.bkdView.config.setPinchToZoomEnabled(enabled)
115
+ }
116
+
117
+ setRegionOfInterestVisible(enabled : boolean) : void {
118
+ this.bkdView.config.setRegionOfInterestVisible(enabled)
119
+ }
120
+
121
+ setRegionOfInterest(
122
+ left : number, top : number, width : number, height : number
123
+ ) : void {
124
+ this.bkdView.config.setRegionOfInterest(
125
+ left, top, width, height
126
+ );
127
+ }
128
+
129
+ setBeepOnSuccessEnabled(enabled : boolean) : void {
130
+ this.bkdView.config.setBeepOnSuccessEnabled(enabled)
131
+ }
132
+
133
+ setVibrateOnSuccessEnabled(enabled: boolean) : void {
134
+ this.bkdView.config.setVibrateOnSuccessEnabled(enabled)
135
+ }
136
+
137
+ getEncodingCharacterSet() : any {
138
+ return this.bkdView.config.getDecoderConfig().encodingCharacterSet
139
+ }
140
+
141
+ getDecodingSpeed(): any {
142
+ return this.bkdView.config.getDecoderConfig().decodingSpeed
143
+ }
144
+
145
+ getFormattingType() : any {
146
+ return this.bkdView.config.getDecoderConfig().formattingType
147
+ }
148
+
149
+ setLocationLineWidth(value : number) : void {
150
+ const roundedValue = Math.round(value * 100) / 100;
151
+ this.bkdView.config.setLocationLineWidth(roundedValue);
152
+ }
153
+
154
+ getLocationLineWidth(): any {
155
+ return this.bkdView.config.getLocationLineWidth();
156
+ }
157
+
158
+ getRoiLineWidth() : any {
159
+ return this.bkdView.config.getRoiLineWidth()
160
+ }
161
+
162
+ getRoiOverlayBackgroundColorHex() : any {
163
+ return this.bkdView.config.getRoiOverlayBackgroundColor()
164
+ }
165
+
166
+ isCloseSessionOnResultEnabled() : any {
167
+ return this.bkdView.config.isCloseSessionOnResultEnabled()
168
+ }
169
+
170
+ isImageResultEnabled() : any {
171
+ return this.bkdView.config.isImageResultEnabled()
172
+ }
173
+
174
+ isLocationInImageResultEnabled() : any {
175
+ return this.bkdView.config.isLocationInImageResultEnabled()
176
+ }
177
+
178
+ getRegionOfInterest() : any {
179
+ return this.bkdView.config.getRegionOfInterest()
180
+ }
181
+
182
+ getThreadsLimit() : any {
183
+ return this.bkdConfig.GetThreadsLimit()
184
+ }
185
+
186
+ setThreadsLimit(value : number) : void {
187
+ this.bkdConfig.SetThreadsLimit(value)
188
+ }
189
+
190
+ isLocationInPreviewEnabled() : Promise <any> {
191
+ return this.bkdView.config.isLocationInPreviewEnabled()
192
+ }
193
+
194
+ isPinchToZoomEnabled() : Promise <any> {
195
+ return this.bkdView.config.isPinchToZoomEnabled()
196
+ }
197
+
198
+ isRegionOfInterestVisible() : Promise <any> {
199
+ return this.bkdView.config.isRegionOfInterestVisible()
200
+ }
201
+
202
+ isBeepOnSuccessEnabled() : Promise <any> {
203
+ return this.bkdView.config.isBeepOnSuccessEnabled()
204
+ }
205
+
206
+ isVibrateOnSuccessEnabled() : Promise <any> {
207
+ return this.bkdView.config.isVibrateOnSuccessEnabled()
208
+ }
209
+
210
+ getVersion() : any {
211
+ return com.barkoder.Barkoder.GetVersion()
212
+ }
213
+
214
+ getMsiCheckSumType() : any {
215
+ return this.bkdView.config.getDecoderConfig().Msi.checksumType
216
+ }
217
+
218
+ getCode39CheckSumType() : any {
219
+ return this.bkdView.config.getDecoderConfig().Code39.checksumType
220
+ }
221
+
222
+ getCode11CheckSumType() : any {
223
+ return this.bkdView.config.getDecoderConfig().Code11.checksumType
224
+ }
225
+
226
+ setBarkoderResolution(barkoderResolution : BarkoderConstants.BarkoderResolution) : void {
227
+ if(barkoderResolution == BarkoderConstants.BarkoderResolution.NORMAL) {
228
+ this.bkdView.config.setBarkoderResolution(com.barkoder.enums.BarkoderResolution.Normal);
229
+ ;
230
+ } else if (barkoderResolution == BarkoderConstants.BarkoderResolution.HIGH) {
231
+ this.bkdView.config.setBarkoderResolution(com.barkoder.enums.BarkoderResolution.HIGH);
232
+ }
233
+ }
234
+
235
+ getBarkoderResolution() : any {
236
+ return this.bkdView.config.getBarkoderResolution()
237
+ }
238
+
239
+ setEncodingCharacterSet(encodingCharSet : any) : void {
240
+ this.bkdView.config.getDecoderConfig().encodingCharacterSet = encodingCharSet
241
+ }
242
+
243
+ setDecodingSpeed(decodingSpeed: BarkoderConstants.DecodingSpeed): void {
244
+ if(decodingSpeed == BarkoderConstants.DecodingSpeed.Slow) {
245
+ this.bkdView.config.getDecoderConfig().decodingSpeed =
246
+ com.barkoder.Barkoder.DecodingSpeed.Slow;
247
+ } else if (decodingSpeed == BarkoderConstants.DecodingSpeed.Fast){
248
+ this.bkdView.config.getDecoderConfig().decodingSpeed =
249
+ com.barkoder.Barkoder.DecodingSpeed.Fast;
250
+ } else if(decodingSpeed == BarkoderConstants.DecodingSpeed.Normal){
251
+ this.bkdView.config.getDecoderConfig().decodingSpeed =
252
+ com.barkoder.Barkoder.DecodingSpeed.Normal;
253
+ } else {
254
+ console.log("Not avilbilable Decoding Speed")
255
+ }
256
+ }
257
+
258
+ setFormattingType(formattingType: BarkoderConstants.FormattingType) {
259
+ switch (formattingType) {
260
+ case BarkoderConstants.FormattingType.Disabled:
261
+ this.bkdView.config.getDecoderConfig().formattingType
262
+ = com.barkoder.Barkoder.FormattingType.Disabled
263
+ break;
264
+ case BarkoderConstants.FormattingType.Automatic:
265
+ this.bkdView.config.getDecoderConfig().formattingType
266
+ = com.barkoder.Barkoder.FormattingType.Automatic
267
+ break;
268
+ case BarkoderConstants.FormattingType.GS1:
269
+ this.bkdView.config.getDecoderConfig().formattingType
270
+ = com.barkoder.Barkoder.FormattingType.GS1
271
+ break;
272
+ case BarkoderConstants.FormattingType.AAMVA:
273
+ this.bkdView.config.getDecoderConfig().formattingType
274
+ = com.barkoder.Barkoder.FormattingType.AAMVA
275
+ break;
276
+ }
277
+ }
278
+
279
+ setMsiCheckSumType(msiCheckSumType : BarkoderConstants.MsiCheckSumType) {
280
+ switch (msiCheckSumType) {
281
+ case BarkoderConstants.MsiCheckSumType.Disabled:
282
+ this.bkdView.config.getDecoderConfig().Msi.checksumType = com.barkoder.Barkoder.MsiChecksumType.Disabled
283
+ break;
284
+ case BarkoderConstants.MsiCheckSumType.Mod10:
285
+ this.bkdView.config.getDecoderConfig().Msi.checksumType = com.barkoder.Barkoder.MsiChecksumType.Mod10
286
+ break;
287
+ case BarkoderConstants.MsiCheckSumType.Mod11:
288
+ this.bkdView.config.getDecoderConfig().Msi.checksumType = com.barkoder.Barkoder.MsiChecksumType.Mod11
289
+ break;
290
+ case BarkoderConstants.MsiCheckSumType.Mod1010:
291
+ this.bkdView.config.getDecoderConfig().Msi.checksumType = com.barkoder.Barkoder.MsiChecksumType.Mod1010
292
+ break;
293
+ case BarkoderConstants.MsiCheckSumType.Mod1110:
294
+ this.bkdView.config.getDecoderConfig().Msi.checksumType = com.barkoder.Barkoder.MsiChecksumType.Mod1110
295
+ break;
296
+ case BarkoderConstants.MsiCheckSumType.Mod11IBM:
297
+ this.bkdView.config.getDecoderConfig().Msi.checksumType = com.barkoder.Barkoder.MsiChecksumType.Mod11IBM
298
+ break;
299
+ case BarkoderConstants.MsiCheckSumType.Mod1110IBM:
300
+ this.bkdView.config.getDecoderConfig().Msi.checksumType = com.barkoder.Barkoder.MsiChecksumType.Mod1110IBM
301
+ break;
302
+ }
303
+ }
304
+
305
+ setCode39CheckSumType(code39ChecksumType : BarkoderConstants.Code39CheckSumType) {
306
+ switch(code39ChecksumType) {
307
+ case BarkoderConstants.Code39CheckSumType.Disabled:
308
+ this.bkdView.config.getDecoderConfig().Code39.checksumType = com.barkoder.Barkoder.Code39ChecksumType.Disabled
309
+ break;
310
+ case BarkoderConstants.Code39CheckSumType.Enabled:
311
+ this.bkdView.config.getDecoderConfig().Code39.checksumType = com.barkoder.Barkoder.Code39ChecksumType.Enabled
312
+ break;
313
+ }
314
+ }
315
+
316
+ setCode11CheckSumType(code11CheckSumType : BarkoderConstants.Code11CheckSumType) {
317
+ switch(code11CheckSumType) {
318
+ case BarkoderConstants.Code11CheckSumType.Disabled:
319
+ this.bkdView.config.getDecoderConfig().Code11.checksumType = com.barkoder.Barkoder.Code11ChecksumType.Disabled
320
+ break;
321
+ case BarkoderConstants.Code11CheckSumType.Single:
322
+ this.bkdView.config.getDecoderConfig().Code11.checksumType = com.barkoder.Barkoder.Code11ChecksumType.Single
323
+ break;
324
+ case BarkoderConstants.Code11CheckSumType.Double:
325
+ this.bkdView.config.getDecoderConfig().Code11.checksumType = com.barkoder.Barkoder.Code11ChecksumType.Double
326
+ break;
327
+ }
328
+ }
329
+
330
+ isBarcodeTypeEnabled(decoder: BarkoderConstants.DecoderType) : boolean {
331
+ switch (decoder) {
332
+ case BarkoderConstants.DecoderType.Aztec:
333
+ return this.bkdView.config.getDecoderConfig().Aztec.enabled;
334
+ case BarkoderConstants.DecoderType.AztecCompact:
335
+ return this.bkdView.config.getDecoderConfig().AztecCompact.enabled;
336
+ case BarkoderConstants.DecoderType.QR:
337
+ return this.bkdView.config.getDecoderConfig().QR.enabled;
338
+ case BarkoderConstants.DecoderType.QRMicro:
339
+ return this.bkdView.config.getDecoderConfig().QRMicro.enabled;
340
+ case BarkoderConstants.DecoderType.Code128:
341
+ return this.bkdView.config.getDecoderConfig().Code128.enabled;
342
+ case BarkoderConstants.DecoderType.Code93:
343
+ return this.bkdView.config.getDecoderConfig().Code93.enabled;
344
+ case BarkoderConstants.DecoderType.Code39:
345
+ return this.bkdView.config.getDecoderConfig().Code39.enabled;
346
+ case BarkoderConstants.DecoderType.Telepen:
347
+ return this.bkdView.config.getDecoderConfig().Telepen.enabled;
348
+ case BarkoderConstants.DecoderType.Code11:
349
+ return this.bkdView.config.getDecoderConfig().Code11.enabled;
350
+ case BarkoderConstants.DecoderType.Msi:
351
+ return this.bkdView.config.getDecoderConfig().Msi.enabled;
352
+ case BarkoderConstants.DecoderType.UpcA:
353
+ return this.bkdView.config.getDecoderConfig().UpcA.enabled;
354
+ case BarkoderConstants.DecoderType.UpcE:
355
+ return this.bkdView.config.getDecoderConfig().UpcE.enabled;
356
+ case BarkoderConstants.DecoderType.UpcE1:
357
+ return this.bkdView.config.getDecoderConfig().UpcE1.enabled;
358
+ case BarkoderConstants.DecoderType.Ean13:
359
+ return this.bkdView.config.getDecoderConfig().Ean13.enabled;
360
+ case BarkoderConstants.DecoderType.Ean8:
361
+ return this.bkdView.config.getDecoderConfig().Ean8.enabled;
362
+ case BarkoderConstants.DecoderType.PDF417:
363
+ return this.bkdView.config.getDecoderConfig().PDF417.enabled;
364
+ case BarkoderConstants.DecoderType.PDF417Micro:
365
+ return this.bkdView.config.getDecoderConfig().PDF417Micro.enabled;
366
+ case BarkoderConstants.DecoderType.Datamatrix:
367
+ return this.bkdView.config.getDecoderConfig().Datamatrix.enabled;
368
+ case BarkoderConstants.DecoderType.Code25:
369
+ return this.bkdView.config.getDecoderConfig().Code25.enabled;
370
+ case BarkoderConstants.DecoderType.Interleaved25:
371
+ return this.bkdView.config.getDecoderConfig().Interleaved25.enabled;
372
+ case BarkoderConstants.DecoderType.ITF14:
373
+ return this.bkdView.config.getDecoderConfig().ITF14.enabled;
374
+ case BarkoderConstants.DecoderType.IATA25:
375
+ return this.bkdView.config.getDecoderConfig().IATA25.enabled;
376
+ case BarkoderConstants.DecoderType.Matrix25:
377
+ return this.bkdView.config.getDecoderConfig().Matrix25.enabled;
378
+ case BarkoderConstants.DecoderType.Datalogic25:
379
+ return this.bkdView.config.getDecoderConfig().Datalogic25.enabled;
380
+ case BarkoderConstants.DecoderType.COOP25:
381
+ return this.bkdView.config.getDecoderConfig().COOP25.enabled;
382
+ case BarkoderConstants.DecoderType.Dotcode:
383
+ return this.bkdView.config.getDecoderConfig().Dotcode.enabled;
384
+ }
385
+ }
386
+
387
+ setBarcodeTypeEnabled(decoders: BarkoderConstants.DecoderType[]): void {
388
+ this.bkdView.config.getDecoderConfig().Aztec.enabled = false;
389
+ this.bkdView.config.getDecoderConfig().AztecCompact.enabled = false;
390
+ this.bkdView.config.getDecoderConfig().QR.enabled = false;
391
+ this.bkdView.config.getDecoderConfig().QRMicro.enabled = false;
392
+ this.bkdView.config.getDecoderConfig().Code128.enabled = false;
393
+ this.bkdView.config.getDecoderConfig().Code93.enabled = false;
394
+ this.bkdView.config.getDecoderConfig().Code39.enabled = false;
395
+ this.bkdView.config.getDecoderConfig().Telepen.enabled = false;
396
+ this.bkdView.config.getDecoderConfig().Code11.enabled = false;
397
+ this.bkdView.config.getDecoderConfig().Codabar.enabled = false;
398
+ this.bkdView.config.getDecoderConfig().Msi.enabled = false;
399
+ this.bkdView.config.getDecoderConfig().UpcA.enabled = false;
400
+ this.bkdView.config.getDecoderConfig().UpcE.enabled = false;
401
+ this.bkdView.config.getDecoderConfig().UpcE1.enabled = false;
402
+ this.bkdView.config.getDecoderConfig().Ean13.enabled = false;
403
+ this.bkdView.config.getDecoderConfig().Ean8.enabled = false;
404
+ this.bkdView.config.getDecoderConfig().PDF417.enabled = false;
405
+ this.bkdView.config.getDecoderConfig().PDF417Micro.enabled = false;
406
+ this.bkdView.config.getDecoderConfig().Datamatrix.enabled = false;
407
+ this.bkdView.config.getDecoderConfig().Code25.enabled = false;
408
+ this.bkdView.config.getDecoderConfig().Interleaved25.enabled = false;
409
+ this.bkdView.config.getDecoderConfig().ITF14.enabled = false;
410
+ this.bkdView.config.getDecoderConfig().IATA25.enabled = false;
411
+ this.bkdView.config.getDecoderConfig().Matrix25.enabled = false;
412
+ this.bkdView.config.getDecoderConfig().Datalogic25.enabled = false;
413
+ this.bkdView.config.getDecoderConfig().COOP25.enabled = false;
414
+ this.bkdView.config.getDecoderConfig().Dotcode.enabled = false;
415
+ decoders.forEach((dt: BarkoderConstants.DecoderType) => {
416
+ switch (dt) {
417
+ case BarkoderConstants.DecoderType.Aztec:
418
+ this.bkdView.config.getDecoderConfig().Aztec.enabled = true;
419
+ break;
420
+ case BarkoderConstants.DecoderType.AztecCompact:
421
+ this.bkdView.config.getDecoderConfig().AztecCompact.enabled = true;
422
+ break;
423
+ case BarkoderConstants.DecoderType.QR:
424
+ this.bkdView.config.getDecoderConfig().QR.enabled = true;
425
+ break;
426
+ case BarkoderConstants.DecoderType.QRMicro:
427
+ this.bkdView.config.getDecoderConfig().QRMicro.enabled = true;
428
+ break;
429
+ case BarkoderConstants.DecoderType.Code128:
430
+ this.bkdView.config.getDecoderConfig().Code128.enabled = true;
431
+ break;
432
+ case BarkoderConstants.DecoderType.Code93:
433
+ this.bkdView.config.getDecoderConfig().Code93.enabled = true;
434
+ break;
435
+ case BarkoderConstants.DecoderType.Code39:
436
+ this.bkdView.config.getDecoderConfig().Code39.enabled = true;
437
+ break;
438
+ case BarkoderConstants.DecoderType.Telepen:
439
+ this.bkdView.config.getDecoderConfig().Telepen.enabled = true;
440
+ break;
441
+ case BarkoderConstants.DecoderType.Code11:
442
+ this.bkdView.config.getDecoderConfig().Code11.enabled = true;
443
+ break;
444
+ case BarkoderConstants.DecoderType.Msi:
445
+ this.bkdView.config.getDecoderConfig().Msi.enabled = true;
446
+ break;
447
+ case BarkoderConstants.DecoderType.UpcA:
448
+ this.bkdView.config.getDecoderConfig().UpcA.enabled = true;
449
+ break;
450
+ case BarkoderConstants.DecoderType.UpcE:
451
+ this.bkdView.config.getDecoderConfig().UpcE.enabled = true;
452
+ break;
453
+ case BarkoderConstants.DecoderType.UpcE1:
454
+ this.bkdView.config.getDecoderConfig().UpcE1.enabled = true;
455
+ break;
456
+ case BarkoderConstants.DecoderType.Ean13:
457
+ this.bkdView.config.getDecoderConfig().Ean13.enabled = true;
458
+ break;
459
+ case BarkoderConstants.DecoderType.Ean8:
460
+ this.bkdView.config.getDecoderConfig().Ean8.enabled = true;
461
+ break;
462
+ case BarkoderConstants.DecoderType.PDF417:
463
+ this.bkdView.config.getDecoderConfig().PDF417.enabled = true;
464
+ break;
465
+ case BarkoderConstants.DecoderType.PDF417Micro:
466
+ this.bkdView.config.getDecoderConfig().PDF417Micro.enabled = true;
467
+ break;
468
+ case BarkoderConstants.DecoderType.Datamatrix:
469
+ this.bkdView.config.getDecoderConfig().Datamatrix.enabled = true;
470
+ break;
471
+ case BarkoderConstants.DecoderType.Code25:
472
+ this.bkdView.config.getDecoderConfig().Code25.enabled = true;
473
+ break;
474
+ case BarkoderConstants.DecoderType.Interleaved25:
475
+ this.bkdView.config.getDecoderConfig().Interleaved25.enabled = true;
476
+ break;
477
+ case BarkoderConstants.DecoderType.ITF14:
478
+ this.bkdView.config.getDecoderConfig().ITF14.enabled = true;
479
+ break;
480
+ case BarkoderConstants.DecoderType.IATA25:
481
+ this.bkdView.config.getDecoderConfig().IATA25.enabled = true;
482
+ break;
483
+ case BarkoderConstants.DecoderType.Matrix25:
484
+ this.bkdView.config.getDecoderConfig().Matrix25.enabled = true;
485
+ break;
486
+ case BarkoderConstants.DecoderType.Datalogic25:
487
+ this.bkdView.config.getDecoderConfig().Datalogic25.enabled = true;
488
+ break;
489
+ case BarkoderConstants.DecoderType.COOP25:
490
+ this.bkdView.config.getDecoderConfig().COOP25.enabled = true;
491
+ break;
492
+ case BarkoderConstants.DecoderType.Dotcode:
493
+ this.bkdView.config.getDecoderConfig().Dotcode.enabled = true;
494
+ break;
495
+ default:
496
+ break;
497
+ }
498
+ });
499
+ }
500
+
501
+ setBarcodeTypeLengthRange(decoder: BarkoderConstants.DecoderType, minimumLength:number, maximumLength: number) {
502
+ switch (decoder) {
503
+ case BarkoderConstants.DecoderType.Aztec:
504
+ this.bkdView.config.getDecoderConfig().Aztec.minimumLength = minimumLength
505
+ this.bkdView.config.getDecoderConfig().Aztec.maximumLength = maximumLength
506
+ break;
507
+ case BarkoderConstants.DecoderType.AztecCompact:
508
+ this.bkdView.config.getDecoderConfig().AztecCompact.minimumLength = minimumLength
509
+ this.bkdView.config.getDecoderConfig().AztecCompact.maximumLength = maximumLength
510
+ break;
511
+ case BarkoderConstants.DecoderType.QR:
512
+ this.bkdView.config.getDecoderConfig().QR.minimumLength = minimumLength
513
+ this.bkdView.config.getDecoderConfig().QR.maximumLength = maximumLength
514
+ break;
515
+ case BarkoderConstants.DecoderType.QRMicro:
516
+ this.bkdView.config.getDecoderConfig().QRMicro.minimumLength = minimumLength
517
+ this.bkdView.config.getDecoderConfig().QRMicro.maximumLength = maximumLength
518
+ break;
519
+ case BarkoderConstants.DecoderType.Code128:
520
+ this.bkdView.config.getDecoderConfig().Code128.minimumLength = minimumLength
521
+ this.bkdView.config.getDecoderConfig().Code128.maximumLength = maximumLength
522
+ break;
523
+ case BarkoderConstants.DecoderType.Code93:
524
+ this.bkdView.config.getDecoderConfig().Code93.minimumLength = minimumLength
525
+ this.bkdView.config.getDecoderConfig().Code93.maximumLength = maximumLength
526
+ break;
527
+ case BarkoderConstants.DecoderType.Code39:
528
+ this.bkdView.config.getDecoderConfig().Code39.minimumLength = minimumLength
529
+ this.bkdView.config.getDecoderConfig().Code39.maximumLength = maximumLength
530
+ break;
531
+ case BarkoderConstants.DecoderType.Telepen:
532
+ this.bkdView.config.getDecoderConfig().Telepen.minimumLength = minimumLength
533
+ this.bkdView.config.getDecoderConfig().Telepen.maximumLength = maximumLength
534
+ break;
535
+ case BarkoderConstants.DecoderType.Code11:
536
+ this.bkdView.config.getDecoderConfig().Code11.minimumLength = minimumLength
537
+ this.bkdView.config.getDecoderConfig().Code11.maximumLength = maximumLength
538
+ break;
539
+ case BarkoderConstants.DecoderType.Msi:
540
+ this.bkdView.config.getDecoderConfig().Msi.minimumLength = minimumLength
541
+ this.bkdView.config.getDecoderConfig().Msi.maximumLength = maximumLength
542
+ break;
543
+ case BarkoderConstants.DecoderType.UpcA:
544
+ this.bkdView.config.getDecoderConfig().UpcA.minimumLength = minimumLength
545
+ this.bkdView.config.getDecoderConfig().UpcA.maximumLength = maximumLength
546
+ break;
547
+ case BarkoderConstants.DecoderType.UpcE:
548
+ this.bkdView.config.getDecoderConfig().UpcE.minimumLength = minimumLength
549
+ this.bkdView.config.getDecoderConfig().UpcE.maximumLength = maximumLength
550
+ break;
551
+ case BarkoderConstants.DecoderType.UpcE1:
552
+ this.bkdView.config.getDecoderConfig().UpcE1.minimumLength = minimumLength
553
+ this.bkdView.config.getDecoderConfig().UpcE1.maximumLength = maximumLength
554
+ break;
555
+ case BarkoderConstants.DecoderType.Ean13:
556
+ this.bkdView.config.getDecoderConfig().Ean13.minimumLength = minimumLength
557
+ this.bkdView.config.getDecoderConfig().Ean13.maximumLength = maximumLength
558
+ break;
559
+ case BarkoderConstants.DecoderType.Ean8:
560
+ this.bkdView.config.getDecoderConfig().Ean8.minimumLength = minimumLength
561
+ this.bkdView.config.getDecoderConfig().Ean8.maximumLength = maximumLength
562
+ break;
563
+ case BarkoderConstants.DecoderType.PDF417:
564
+ this.bkdView.config.getDecoderConfig().PDF417.minimumLength = minimumLength
565
+ this.bkdView.config.getDecoderConfig().PDF417.maximumLength = maximumLength
566
+ break;
567
+ case BarkoderConstants.DecoderType.PDF417Micro:
568
+ this.bkdView.config.getDecoderConfig().PDF417Micro.minimumLength = minimumLength
569
+ this.bkdView.config.getDecoderConfig().PDF417Micro.maximumLength = maximumLength
570
+ break;
571
+ case BarkoderConstants.DecoderType.Datamatrix:
572
+ this.bkdView.config.getDecoderConfig().Datamatrix.minimumLength = minimumLength
573
+ this.bkdView.config.getDecoderConfig().Datamatrix.maximumLength = maximumLength
574
+ break;
575
+ case BarkoderConstants.DecoderType.Code25:
576
+ this.bkdView.config.getDecoderConfig().Code25.minimumLength = minimumLength
577
+ this.bkdView.config.getDecoderConfig().Code25.maximumLength = maximumLength
578
+ break;
579
+ case BarkoderConstants.DecoderType.Interleaved25:
580
+ this.bkdView.config.getDecoderConfig().Interleaved25.minimumLength = minimumLength
581
+ this.bkdView.config.getDecoderConfig().Interleaved25.maximumLength = maximumLength
582
+ break;
583
+ case BarkoderConstants.DecoderType.ITF14:
584
+ this.bkdView.config.getDecoderConfig().ITF14.minimumLength = minimumLength
585
+ this.bkdView.config.getDecoderConfig().ITF14.maximumLength = maximumLength
586
+ break;
587
+ case BarkoderConstants.DecoderType.IATA25:
588
+ this.bkdView.config.getDecoderConfig().IATA25.minimumLength = minimumLength
589
+ this.bkdView.config.getDecoderConfig().IATA25.maximumLength = maximumLength
590
+ break;
591
+ case BarkoderConstants.DecoderType.Matrix25:
592
+ this.bkdView.config.getDecoderConfig().Matrix25.minimumLength = minimumLength
593
+ this.bkdView.config.getDecoderConfig().Matrix25.maximumLength = maximumLength
594
+ break;
595
+ case BarkoderConstants.DecoderType.Datalogic25:
596
+ this.bkdView.config.getDecoderConfig().Datalogic25.minimumLength = minimumLength
597
+ this.bkdView.config.getDecoderConfig().Datalogic25.maximumLength = maximumLength
598
+ break;
599
+ case BarkoderConstants.DecoderType.COOP25:
600
+ this.bkdView.config.getDecoderConfig().COOP25.minimumLength = minimumLength
601
+ this.bkdView.config.getDecoderConfig().COOP25.maximumLength = maximumLength
602
+ break;
603
+ case BarkoderConstants.DecoderType.Dotcode:
604
+ this.bkdView.config.getDecoderConfig().Dotcode.minimumLength = minimumLength
605
+ this.bkdView.config.getDecoderConfig().Dotcode.maximumLength = maximumLength
606
+ break;
607
+ default:
608
+ break;
609
+ }
610
+ }
611
+
612
+ getBarcodeTypeMaximumLenght(decoder: BarkoderConstants.DecoderType) : any {
613
+ switch (decoder) {
614
+ case BarkoderConstants.DecoderType.Aztec:
615
+ return this.bkdView.config.getDecoderConfig().Aztec.maximumLength
616
+ case BarkoderConstants.DecoderType.AztecCompact:
617
+ return this.bkdView.config.getDecoderConfig().AztecCompact.maximumLength
618
+ case BarkoderConstants.DecoderType.QR:
619
+ return this.bkdView.config.getDecoderConfig().QR.maximumLength
620
+ case BarkoderConstants.DecoderType.QRMicro:
621
+ return this.bkdView.config.getDecoderConfig().QRMicro.maximumLength
622
+ case BarkoderConstants.DecoderType.Code128:
623
+ return this.bkdView.config.getDecoderConfig().Code128.maximumLength
624
+ case BarkoderConstants.DecoderType.Code93:
625
+ return this.bkdView.config.getDecoderConfig().Code93.maximumLength
626
+ case BarkoderConstants.DecoderType.Code39:
627
+ return this.bkdView.config.getDecoderConfig().Code39.maximumLength
628
+ case BarkoderConstants.DecoderType.Telepen:
629
+ return this.bkdView.config.getDecoderConfig().Telepen.maximumLength
630
+ case BarkoderConstants.DecoderType.Code11:
631
+ return this.bkdView.config.getDecoderConfig().Code11.maximumLength
632
+ case BarkoderConstants.DecoderType.Msi:
633
+ return this.bkdView.config.getDecoderConfig().Msi.maximumLength
634
+ case BarkoderConstants.DecoderType.UpcA:
635
+ return this.bkdView.config.getDecoderConfig().UpcA.maximumLength
636
+ case BarkoderConstants.DecoderType.UpcE:
637
+ return this.bkdView.config.getDecoderConfig().UpcE.maximumLength
638
+ case BarkoderConstants.DecoderType.UpcE1:
639
+ return this.bkdView.config.getDecoderConfig().UpcE1.maximumLength
640
+ case BarkoderConstants.DecoderType.Ean13:
641
+ return this.bkdView.config.getDecoderConfig().Ean13.maximumLength
642
+ case BarkoderConstants.DecoderType.Ean8:
643
+ return this.bkdView.config.getDecoderConfig().Ean8.maximumLength
644
+ case BarkoderConstants.DecoderType.PDF417:
645
+ return this.bkdView.config.getDecoderConfig().PDF417.maximumLength
646
+ case BarkoderConstants.DecoderType.PDF417Micro:
647
+ return this.bkdView.config.getDecoderConfig().PDF417Micro.maximumLength
648
+ case BarkoderConstants.DecoderType.Datamatrix:
649
+ return this.bkdView.config.getDecoderConfig().Datamatrix.maximumLength
650
+ case BarkoderConstants.DecoderType.Code25:
651
+ return this.bkdView.config.getDecoderConfig().Code25.maximumLength
652
+ case BarkoderConstants.DecoderType.Interleaved25:
653
+ return this.bkdView.config.getDecoderConfig().Interleaved25.maximumLength
654
+ case BarkoderConstants.DecoderType.ITF14:
655
+ return this.bkdView.config.getDecoderConfig().ITF14.maximumLength
656
+ case BarkoderConstants.DecoderType.IATA25:
657
+ return this.bkdView.config.getDecoderConfig().IATA25.maximumLength
658
+ case BarkoderConstants.DecoderType.Matrix25:
659
+ return this.bkdView.config.getDecoderConfig().Matrix25.maximumLength
660
+ case BarkoderConstants.DecoderType.Datalogic25:
661
+ return this.bkdView.config.getDecoderConfig().Datalogic25.maximumLength
662
+ case BarkoderConstants.DecoderType.COOP25:
663
+ return this.bkdView.config.getDecoderConfig().COOP25.maximumLength
664
+ case BarkoderConstants.DecoderType.Dotcode:
665
+ return this.bkdView.config.getDecoderConfig().Dotcode.maximumLength
666
+ }
667
+ }
668
+
669
+ getBarcodeTypeMinimumLenght(decoder: BarkoderConstants.DecoderType) : any {
670
+ switch (decoder) {
671
+ case BarkoderConstants.DecoderType.Aztec:
672
+ return this.bkdView.config.getDecoderConfig().Aztec.minimumLength
673
+ case BarkoderConstants.DecoderType.AztecCompact:
674
+ return this.bkdView.config.getDecoderConfig().AztecCompact.minimumLength
675
+ case BarkoderConstants.DecoderType.QR:
676
+ return this.bkdView.config.getDecoderConfig().QR.minimumLength
677
+ case BarkoderConstants.DecoderType.QRMicro:
678
+ return this.bkdView.config.getDecoderConfig().QRMicro.minimumLength
679
+ case BarkoderConstants.DecoderType.Code128:
680
+ return this.bkdView.config.getDecoderConfig().Code128.minimumLength
681
+ case BarkoderConstants.DecoderType.Code93:
682
+ return this.bkdView.config.getDecoderConfig().Code93.minimumLength
683
+ case BarkoderConstants.DecoderType.Code39:
684
+ return this.bkdView.config.getDecoderConfig().Code39.minimumLength
685
+ case BarkoderConstants.DecoderType.Telepen:
686
+ return this.bkdView.config.getDecoderConfig().Telepen.minimumLength
687
+ case BarkoderConstants.DecoderType.Code11:
688
+ return this.bkdView.config.getDecoderConfig().Code11.minimumLength
689
+ case BarkoderConstants.DecoderType.Msi:
690
+ return this.bkdView.config.getDecoderConfig().Msi.minimumLength
691
+ case BarkoderConstants.DecoderType.UpcA:
692
+ return this.bkdView.config.getDecoderConfig().UpcA.minimumLength
693
+ case BarkoderConstants.DecoderType.UpcE:
694
+ return this.bkdView.config.getDecoderConfig().UpcE.minimumLength
695
+ case BarkoderConstants.DecoderType.UpcE1:
696
+ return this.bkdView.config.getDecoderConfig().UpcE1.minimumLength
697
+ case BarkoderConstants.DecoderType.Ean13:
698
+ return this.bkdView.config.getDecoderConfig().Ean13.minimumLength
699
+ case BarkoderConstants.DecoderType.Ean8:
700
+ return this.bkdView.config.getDecoderConfig().Ean8.minimumLength
701
+ case BarkoderConstants.DecoderType.PDF417:
702
+ return this.bkdView.config.getDecoderConfig().PDF417.minimumLength
703
+ case BarkoderConstants.DecoderType.PDF417Micro:
704
+ return this.bkdView.config.getDecoderConfig().PDF417Micro.minimumLength
705
+ case BarkoderConstants.DecoderType.Datamatrix:
706
+ return this.bkdView.config.getDecoderConfig().Datamatrix.minimumLength
707
+ case BarkoderConstants.DecoderType.Code25:
708
+ return this.bkdView.config.getDecoderConfig().Code25.minimumLength
709
+ case BarkoderConstants.DecoderType.Interleaved25:
710
+ return this.bkdView.config.getDecoderConfig().Interleaved25.minimumLength
711
+ case BarkoderConstants.DecoderType.ITF14:
712
+ return this.bkdView.config.getDecoderConfig().ITF14.minimumLength
713
+ case BarkoderConstants.DecoderType.IATA25:
714
+ return this.bkdView.config.getDecoderConfig().IATA25.minimumLength
715
+ case BarkoderConstants.DecoderType.Matrix25:
716
+ return this.bkdView.config.getDecoderConfig().Matrix25.minimumLength
717
+ case BarkoderConstants.DecoderType.Datalogic25:
718
+ return this.bkdView.config.getDecoderConfig().Datalogic25.minimumLength
719
+ case BarkoderConstants.DecoderType.COOP25:
720
+ return this.bkdView.config.getDecoderConfig().COOP25.minimumLength
721
+ case BarkoderConstants.DecoderType.Dotcode:
722
+ return this.bkdView.config.getDecoderConfig().Dotcode.minimumLength
723
+ }
724
+ }
725
+
726
+ setMaximumResultsCount(maximumResultsCount : number): void {
727
+ this.bkdView.config.getDecoderConfig().maximumResultsCount = maximumResultsCount
728
+ }
729
+
730
+ setDuplicatesDelayMs(duplicateDelayMs : number) : void {
731
+ this.bkdView.config.getDecoderConfig().duplicatesDelayMs = duplicateDelayMs
732
+ }
733
+
734
+ setMulticodeCachingDuration(multicodeCachingDuration : number) : void {
735
+ this.bkdConfig.SetMulticodeCachingDuration(multicodeCachingDuration)
736
+ }
737
+
738
+ setMulticodeCachingEnabled(multiCodeCachingEnabled : boolean) : void {
739
+ this.bkdConfig.SetMulticodeCachingEnabled(multiCodeCachingEnabled)
740
+ }
741
+
742
+ getMaximumResultsCount() : any {
743
+ return this.bkdView.config.getDecoderConfig().maximumResultsCount
744
+ }
745
+
746
+ getDuplicatesDelayMs() : any {
747
+ return this.bkdView.config.getDecoderConfig().duplicatesDelayMs
748
+ }
749
+
750
+ setDatamatrixDpmModeEnabled(dpmModeEnabled : boolean) : void {
751
+ this.bkdView.config.getDecoderConfig().Datamatrix.dpmMode = dpmModeEnabled
752
+ }
753
+
754
+ setUpcEanDeblurEnabled(value : boolean) : void {
755
+ this.bkdView.config.getDecoderConfig().upcEanDeblur = value
756
+ }
757
+
758
+ setEnableMisshaped1DEnabled(value : boolean) : void {
759
+ this.bkdView.config.getDecoderConfig().enableMisshaped1D = value
760
+ }
761
+
762
+ setBarcodeThumbnailOnResultEnabled(enabled : boolean) : void{
763
+ this.bkdView.config.setThumbnailOnResultEnabled(enabled)
764
+ }
765
+
766
+ isBarcodeThumbnailOnResultEnabled() : any{
767
+ return this.bkdView.config.getThumbnailOnResulEnabled()
768
+ }
769
+
770
+ setThresholdBetweenDuplicatesScans(value : number) : void {
771
+ this.bkdView.config.setThresholdBetweenDuplicatesScans(value)
772
+ }
773
+
774
+ getThresholdBetweenDuplicatesScans() : Promise <any> {
775
+ return this.bkdView.config.getThresholdBetweenDuplicatesScans()
776
+ }
777
+
778
+ getMulticodeCachingEnabled() : any {
779
+ return this.bkdConfig.IsMulticodeCachingEnabled()
780
+ }
781
+
782
+ getMulticodeCachingDuration() : any {
783
+ return this.bkdConfig.GetMulticodeCachingDuration()
784
+ }
785
+
786
+ isUpcEanDeblurEnabled() : any {
787
+ return this.bkdView.config.getDecoderConfig().upcEanDeblur
788
+ }
789
+
790
+ isMisshaped1DEnabled() : any {
791
+ return this.bkdView.config.getDecoderConfig().enableMisshaped1D
792
+ }
793
+
794
+ isVINRestrictionsEnabled() : any {
795
+ return this.bkdView.config.getDecoderConfig().enableVINRestrictions
796
+ }
797
+
798
+ setEnableVINRestrictions(vinRestrictionsEnabled: boolean) : void {
799
+ this.bkdView.config.getDecoderConfig().enableVINRestrictions = vinRestrictionsEnabled
800
+ }
801
+
802
+ setLicenseKey(licenseKey: string): void {
803
+ this.bkdView.config = new com.barkoder.BarkoderConfig(context, licenseKey, null);
804
+ }
805
+
806
+ configureBarkoder(config: BarkoderConstants.BarkoderConfig): void {
807
+ const BarkoderHelper = com.barkoder.BarkoderHelper;
808
+ const JSONObject = org.json.JSONObject;
809
+
810
+ try {
811
+ const jsonString = config.toJsonString();
812
+
813
+ const javaJSONObject = new JSONObject(jsonString);
814
+
815
+ BarkoderHelper.applyJsonToConfig(this.bkdView.config, javaJSONObject);
816
+ } catch (e) {
817
+ console.error("Error applying JSON to BarkoderConfig:", e);
818
+ }
819
+ }
820
+
821
+ private hexToAndroidColor(hexColor: string): number {
822
+ hexColor = hexColor.replace("#", "");
823
+ const red = parseInt(hexColor.substring(0, 2), 16);
824
+ const green = parseInt(hexColor.substring(2, 4), 16);
825
+ const blue = parseInt(hexColor.substring(4, 6), 16);
826
+ const androidColor = android.graphics.Color.rgb(red, green, blue);
827
+
828
+ return androidColor;
829
+ }
830
+
831
+ getPropertiesAndMethods(obj: any): void {
832
+ const propertiesAndMethods: string[] = [];
833
+
834
+ for (let key in obj) {
835
+ console.log(`Key: ${key}, Value: ${obj[key]}`);
836
+ }
837
+ }
838
+
839
+ }
840
+