react-native-scanbot-barcode-scanner-sdk 3.2.0-beta7 → 3.2.1-beta2

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.
File without changes
@@ -0,0 +1,24 @@
1
+ package io.scanbot.barcodesdk.plugin.reactnative;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import java.util.List;
6
+
7
+ import io.scanbot.sdk.barcode.entity.BarcodeItem;
8
+ import io.scanbot.sdk.barcode.entity.BarcodeMetadataKey;
9
+ import io.scanbot.sdk.ui.view.barcode.configuration.IBarcodeFilter;
10
+
11
+ public class BarcodeExtensionsFilter implements IBarcodeFilter {
12
+ @Override
13
+ public boolean acceptsBarcode(@NonNull BarcodeItem barcodeItem) {
14
+ return barcodeItem.getMetadata().containsKey(BarcodeMetadataKey.UpcEanExtension);
15
+ }
16
+
17
+ @Override
18
+ public boolean shouldAdd(@NonNull BarcodeItem barcodeItem, @NonNull List<BarcodeItem> list) {
19
+ if (this.acceptsBarcode(barcodeItem)) {
20
+ return !list.contains(barcodeItem);
21
+ }
22
+ return false;
23
+ }
24
+ }
@@ -241,4 +241,11 @@ public final class JSONUtils {
241
241
  }
242
242
  return EngineMode.NextGen;
243
243
  }
244
+
245
+ public static boolean getBoolOrFalse(final ReadableMap map, final String key) {
246
+ if (!map.hasKey(key)) {
247
+ return false;
248
+ }
249
+ return map.getBoolean(key);
250
+ }
244
251
  }
@@ -63,6 +63,10 @@ public final class ObjectMapper {
63
63
  continue;
64
64
  }
65
65
 
66
+ if ("onlyAcceptCodesWithExtensions".equals(prop)) {
67
+ continue;
68
+ }
69
+
66
70
  // The default FRONT camera module should be FRONT_MIRRORED on Android
67
71
  if ("cameraModule".equals(prop) && "FRONT".equals(value)) {
68
72
  value = "FRONT_MIRRORED";
@@ -46,6 +46,7 @@ import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDKInitializer;
46
46
  import io.scanbot.sdk.ui.barcode_scanner.view.barcode.BarcodeScannerActivity;
47
47
  import io.scanbot.sdk.ui.barcode_scanner.view.barcode.batch.BatchBarcodeScannerActivity;
48
48
  import io.scanbot.sdk.ui.view.barcode.batch.configuration.BatchBarcodeScannerConfiguration;
49
+ import io.scanbot.sdk.ui.view.barcode.configuration.BarcodeExtensionsFilter;
49
50
  import io.scanbot.sdk.ui.view.barcode.configuration.BarcodeScannerAdditionalConfiguration;
50
51
  import io.scanbot.sdk.ui.view.barcode.configuration.BarcodeScannerConfiguration;
51
52
  import io.scanbot.sdk.ui.view.base.configuration.CameraOrientationMode;
@@ -306,6 +307,10 @@ public class ScanbotBarcodeSdkModule extends ReactContextBaseJavaModule implemen
306
307
  if (options.hasKey("replaceCancelButtonWithIcon") && options.getBoolean("replaceCancelButtonWithIcon")) {
307
308
  configuration.setCancelButtonIcon(R.drawable.ic_baseline_arrow_back_24);
308
309
  }
310
+
311
+ if (options.hasKey("onlyAcceptCodesWithExtensions") && options.getBoolean("onlyAcceptCodesWithExtensions")) {
312
+ configuration.setBarcodeFilter(new BarcodeExtensionsFilter());
313
+ }
309
314
  }
310
315
 
311
316
  @ReactMethod
@@ -400,6 +405,7 @@ public class ScanbotBarcodeSdkModule extends ReactContextBaseJavaModule implemen
400
405
  final WritableMap barcode = Arguments.createMap();
401
406
  barcode.putString("type", barcodeItem.getBarcodeFormat().name());
402
407
  barcode.putString("text", barcodeItem.getText());
408
+ barcode.putString("textWithExtension", barcodeItem.getTextWithExtension());
403
409
  barcodes.pushMap(barcode);
404
410
  }
405
411
  }
@@ -139,6 +139,12 @@ RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
139
139
  if (gs1Decoding != nil) {
140
140
  additionalParameters.enableGS1Decoding = [gs1Decoding boolValue];
141
141
  }
142
+
143
+ // UPC Extension filter
144
+ NSNumber* shouldApplyExtensionFilter = [configuration objectForKey:@"onlyAcceptCodesWithExtensions"];
145
+ if (shouldApplyExtensionFilter != nil && [shouldApplyExtensionFilter boolValue]) {
146
+ behaviorConfig.barcodeFilter = [[SBSDKUIBarcodeExtensionsFilter alloc] init];
147
+ }
142
148
 
143
149
  additionalParameters.msiPlesseyChecksumAlgorithm = extractPlesseyChecksumAlgorithmFromConfiguration(configuration);
144
150
 
@@ -203,6 +209,12 @@ RCT_EXPORT_METHOD(startBatchBarcodeScanner:(NSDictionary*)configuration
203
209
  if (gs1Decoding != nil) {
204
210
  additionalParameters.enableGS1Decoding = [gs1Decoding boolValue];
205
211
  }
212
+
213
+ // UPC Extension filter
214
+ NSNumber* shouldApplyExtensionFilter = [configuration objectForKey:@"onlyAcceptCodesWithExtensions"];
215
+ if (shouldApplyExtensionFilter != nil && [shouldApplyExtensionFilter boolValue]) {
216
+ behavior.barcodeFilter = [[SBSDKUIBarcodeExtensionsFilter alloc] init];
217
+ }
206
218
 
207
219
  additionalParameters.msiPlesseyChecksumAlgorithm = extractPlesseyChecksumAlgorithmFromConfiguration(configuration);
208
220
 
@@ -63,6 +63,7 @@ static inline NSDictionary<NSString*, NSObject*>* jsonFromBarcodeResult(SBSDKBar
63
63
  NSMutableDictionary* x = @{
64
64
  @"type": stringFromBarcodeType(result.type),
65
65
  @"text": result.rawTextString,
66
+ @"textWithExtension": result.rawTextStringWithExtension,
66
67
  }.mutableCopy;
67
68
  return x.copy;
68
69
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-scanbot-barcode-scanner-sdk",
3
3
  "title": "Scanbot Barcode Scanner SDK for React Native",
4
- "version": "3.2.0-beta7",
4
+ "version": "3.2.1-beta2",
5
5
  "description": "Scanbot Barcode Scanner SDK React Native Plugin for Android and iOS",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -88,6 +88,10 @@ export interface BarcodeScannerConfiguration {
88
88
  * NOTE: This feature works on ITF and MSI Plessey barcodes only.
89
89
  */
90
90
  minimum1DBarcodesQuietZone?: number
91
+ /**
92
+ * If 'true', only barcodes that have an extension will be accepted. Defaults to FALSE.
93
+ */
94
+ onlyAcceptCodesWithExtensions?: boolean;
91
95
  /**
92
96
  * Whether a sound should be played on successful barcode detection.
93
97
  */
@@ -296,12 +300,15 @@ export interface BatchBarcodeScannerConfiguration {
296
300
  * NOTE: This feature works on ITF and MSI Plessey barcodes only.
297
301
  */
298
302
  minimum1DBarcodesQuietZone?: number;
303
+ /**
304
+ * If 'true', only barcodes that have an extension will be accepted. Defaults to FALSE.
305
+ */
306
+ onlyAcceptCodesWithExtensions?: boolean;
299
307
  /**
300
308
  * The engine mode of the barcode recognizer. Defaults to NEXT_GEN.
301
309
  * To use the legacy recognizer, please specify LEGACY.
302
310
  */
303
311
  engineMode?: EngineMode;
304
-
305
312
  /**
306
313
  * When set to `true`, the scanner assumes that the barcode can be a GS1 barcode.
307
314
  * Turn it off if you don't want to see decoded FNC1 characters ("]C1" and ASCII char 29).
@@ -309,7 +316,6 @@ export interface BatchBarcodeScannerConfiguration {
309
316
  * NOTE: Currently works for CODE128 barcodes only!
310
317
  */
311
318
  gs1DecodingEnabled?: boolean;
312
-
313
319
  /**
314
320
  * The checksum algorithm for MSI Plessey barcodes.
315
321
  * The default value is [MSIPlesseyChecksumAlgorithm.Mod10].
package/src/result.ts CHANGED
@@ -10,6 +10,11 @@ export interface BarcodeResultField {
10
10
  * The raw text encoded in the barcode.
11
11
  */
12
12
  text: string;
13
+
14
+ /**
15
+ * The raw text encoded in the barcode that also includes the extension, if detected
16
+ */
17
+ textWithExtension: string;
13
18
  }
14
19
 
15
20
  export interface BarcodeResult {