react-native-scanbot-barcode-scanner-sdk 3.2.0-beta6 → 3.2.1-beta1

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
@@ -1,7 +1,7 @@
1
1
  // android/build.gradle
2
2
 
3
3
  def DEFAULT_COMPILE_SDK_VERSION = 29
4
- def DEFAULT_MIN_SDK_VERSION = 16
4
+ def DEFAULT_MIN_SDK_VERSION = 21
5
5
  def DEFAULT_TARGET_SDK_VERSION = 29
6
6
 
7
7
  def sdkVersion = '3.2.1'
@@ -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";
@@ -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
 
@@ -0,0 +1,17 @@
1
+ //
2
+ // UpcExtensionBarcodeFilter.h
3
+ // RNScanbotBarcodeSDK
4
+ //
5
+ // Created by Marco Saia on 08.07.22.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ @import ScanbotBarcodeScannerSDK;
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface UpcExtensionBarcodeFilter : SBSDKUIBarcodeExtensionsFilter
14
+
15
+ @end
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,12 @@
1
+ //
2
+ // UpcExtensionBarcodeFilter.m
3
+ // RNScanbotBarcodeSDK
4
+ //
5
+ // Created by Marco Saia on 08.07.22.
6
+ //
7
+
8
+ #import "UpcExtensionBarcodeFilter.h"
9
+
10
+ @implementation UpcExtensionBarcodeFilter
11
+
12
+ @end
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-beta6",
4
+ "version": "3.2.1-beta1",
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].