react-native-scanbot-barcode-scanner-sdk 3.2.1-beta1 → 3.2.1-beta4

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 (24) hide show
  1. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/JSONUtils.java +21 -0
  2. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ObjectMapper.java +22 -6
  3. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter.java +61 -0
  4. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java +54 -65
  5. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorAdditionalConfigBuilder.java +36 -0
  6. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorConfigBuilder.java +45 -0
  7. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment.java +23 -28
  8. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +1 -1
  9. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/filters/ReactBarcodeExtensionsFilter.java +59 -0
  10. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/BitmapHelper.java +30 -0
  11. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.java +286 -0
  12. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/LogUtils.java +40 -0
  13. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ResponseUtils.java +41 -0
  14. package/ios/ScanbotBarcodeSdk.m +41 -49
  15. package/ios/Utils/BarcodeMapping.h +69 -13
  16. package/ios/Utils/ReactBarcodeExtensionsFilter.h +22 -0
  17. package/ios/Utils/ReactBarcodeExtensionsFilter.m +55 -0
  18. package/package.json +1 -1
  19. package/src/configuration.ts +6 -5
  20. package/src/enum.ts +5 -0
  21. package/src/result.ts +5 -0
  22. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/BarcodeExtensionsFilter.java +0 -24
  23. package/ios/Utils/UpcExtensionBarcodeFilter.h +0 -17
  24. package/ios/Utils/UpcExtensionBarcodeFilter.m +0 -12
@@ -0,0 +1,55 @@
1
+ //
2
+ // ReactBarcodeExtensionsFilter.m
3
+ // RNScanbotBarcodeSDK
4
+ //
5
+ // Created by Marco Saia on 13.07.22.
6
+ //
7
+
8
+ #import "ReactBarcodeExtensionsFilter.h"
9
+
10
+ @implementation ReactBarcodeExtensionsFilter {
11
+ BarcodeFilterType mFilterType;
12
+ }
13
+
14
+ -(id)init:(BarcodeFilterType)filterType
15
+ {
16
+ if(self = [super init]) {
17
+ mFilterType = filterType;
18
+ }
19
+
20
+ return self;
21
+ }
22
+
23
+ - (BOOL)acceptsBarcode:(nonnull SBSDKBarcodeScannerResult *)barcode {
24
+ if (![super acceptsBarcode: barcode]) {
25
+ return false;
26
+ }
27
+
28
+ NSString* extension = barcode.metadata[SBSDKBarcodeMetadataEANUPCExtensionKey];
29
+ if (extension == nil || [extension length] == 0) {
30
+ return false;
31
+ }
32
+
33
+ switch (mFilterType) {
34
+ case ReactBarcodeExtensionsFilterWithExtension:
35
+ return true;
36
+ case ReactBarcodeExtensionsFilterWithEAN2Extension:
37
+ return trim(extension).length == 2;
38
+ case ReactBarcodeExtensionsFilterWithEAN5Extension:
39
+ return trim(extension).length == 5;
40
+ default:
41
+ return false;
42
+ }
43
+ }
44
+
45
+ - (BOOL)shouldAdd:(nonnull SBSDKBarcodeScannerResult *)barcode
46
+ toBarcodes:(nonnull NSArray<SBSDKBarcodeScannerResult *>*)codes
47
+ {
48
+ return [super shouldAdd:barcode toBarcodes:codes];
49
+ }
50
+
51
+ static inline NSString* trim(NSString* text) {
52
+ return [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
53
+ }
54
+
55
+ @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.1-beta1",
4
+ "version": "3.2.1-beta4",
5
5
  "description": "Scanbot Barcode Scanner SDK React Native Plugin for Android and iOS",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -10,7 +10,8 @@ import {
10
10
  BarcodeImageGenerationType,
11
11
  UIInterfaceOrientationMask,
12
12
  EngineMode,
13
- CameraModule
13
+ CameraModule,
14
+ BarcodeFilter
14
15
  } from "./enum";
15
16
  import { MSIPlesseyChecksumAlgorithm } from "./enum";
16
17
 
@@ -89,9 +90,9 @@ export interface BarcodeScannerConfiguration {
89
90
  */
90
91
  minimum1DBarcodesQuietZone?: number
91
92
  /**
92
- * If 'true', only barcodes that have an extension will be accepted. Defaults to FALSE.
93
+ * Use a filter to determine which type of barcode can be detected; see `BarcodeFilter`
93
94
  */
94
- onlyAcceptCodesWithExtensions?: boolean;
95
+ barcodeFilter?: BarcodeFilter;
95
96
  /**
96
97
  * Whether a sound should be played on successful barcode detection.
97
98
  */
@@ -301,9 +302,9 @@ export interface BatchBarcodeScannerConfiguration {
301
302
  */
302
303
  minimum1DBarcodesQuietZone?: number;
303
304
  /**
304
- * If 'true', only barcodes that have an extension will be accepted. Defaults to FALSE.
305
+ * Use a filter to determine which type of barcode can be detected; see `BarcodeFilter`
305
306
  */
306
- onlyAcceptCodesWithExtensions?: boolean;
307
+ barcodeFilter?: BarcodeFilter;
307
308
  /**
308
309
  * The engine mode of the barcode recognizer. Defaults to NEXT_GEN.
309
310
  * To use the legacy recognizer, please specify LEGACY.
package/src/enum.ts CHANGED
@@ -77,3 +77,8 @@ export type MSIPlesseyChecksumAlgorithm =
77
77
  ;
78
78
 
79
79
  export type CameraModule = 'FRONT' | 'BACK';
80
+
81
+ export type BarcodeFilter =
82
+ 'WithExtension' |
83
+ 'WithEAN2Extension' |
84
+ 'WithEAN5Extension';
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 {
@@ -1,24 +0,0 @@
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
- }
@@ -1,17 +0,0 @@
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
@@ -1,12 +0,0 @@
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