react-native-scanbot-barcode-scanner-sdk 3.3.0-alpha1 → 3.3.0-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.
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java +2 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/RNScanbotBarcodeCameraComponent.java +0 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.java +6 -10
- package/ios/Components/BarcodeCameraView/RNScanbotBarcodeCameraView.m +1 -2
- package/ios/ScanbotBarcodeSdk.m +2 -2
- package/ios/Utils/BarcodeMapping.h +56 -9
- package/ios/Utils/ObjectMapper.h +0 -1
- package/ios/Utils/ObjectMapper.m +0 -52
- package/package.json +1 -1
- package/src/enum.ts +2 -0
package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java
CHANGED
|
@@ -57,6 +57,7 @@ import io.scanbot.sdk.ui.view.barcode.batch.configuration.BatchBarcodeScannerCon
|
|
|
57
57
|
import io.scanbot.sdk.barcode.BarcodeFilter;
|
|
58
58
|
import io.scanbot.sdk.ui.view.barcode.configuration.BarcodeScannerAdditionalConfiguration;
|
|
59
59
|
import io.scanbot.sdk.ui.view.barcode.configuration.BarcodeScannerConfiguration;
|
|
60
|
+
import io.scanbot.sdk.ui.view.barcode.configuration.CommonBarcodeScannerConfiguration;
|
|
60
61
|
import io.scanbot.sdk.ui.view.base.configuration.CameraOrientationMode;
|
|
61
62
|
import kotlin.Unit;
|
|
62
63
|
|
|
@@ -265,7 +266,7 @@ public class ScanbotBarcodeSdkModule extends ReactContextBaseJavaModule implemen
|
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
268
|
|
|
268
|
-
private void setCustomBarcodeScannerConfiguration(final ReadableMap options,
|
|
269
|
+
private void setCustomBarcodeScannerConfiguration(final ReadableMap options, CommonBarcodeScannerConfiguration configuration) {
|
|
269
270
|
CameraOrientationMode orientationMode = JSONUtils.extractCameraOrientationMode(options);
|
|
270
271
|
if (orientationMode != null) {
|
|
271
272
|
configuration.setOrientationLockMode(orientationMode);
|
|
@@ -131,7 +131,6 @@ public class RNScanbotBarcodeCameraComponent extends RNScanbotNativeComponent im
|
|
|
131
131
|
final FinderOverlayView finderOverlayView = barcodeCameraUi.getFinderOverlayView();
|
|
132
132
|
final ScanbotCameraXView cameraView = barcodeCameraUi.getCameraView();
|
|
133
133
|
|
|
134
|
-
finderOverlayView.setVisibility(configuration.shouldUseFinderView() ? View.VISIBLE : View.INVISIBLE);
|
|
135
134
|
finderOverlayView.setVisibility(configuration.shouldUseFinderView() ? View.VISIBLE : View.INVISIBLE);
|
|
136
135
|
finderOverlayView.setStrokeWidth(configuration.getFinderLineWidth());
|
|
137
136
|
finderOverlayView.setStrokeColor(configuration.getFinderLineColor());
|
|
@@ -333,7 +333,7 @@ public final class JSONUtils {
|
|
|
333
333
|
return jsonArray;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
for (byte b: rawBytes) {
|
|
336
|
+
for (byte b : rawBytes) {
|
|
337
337
|
jsonArray.pushInt(b);
|
|
338
338
|
}
|
|
339
339
|
|
|
@@ -354,33 +354,29 @@ public final class JSONUtils {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
BarcodeOverlayTextFormat textFormat = BarcodeOverlayTextFormat.CODE_AND_TYPE;
|
|
357
|
-
// TODO
|
|
358
|
-
// if (configuration.hasKey("textFormat")){
|
|
359
|
-
// overlayEnabled = configuration.getBoolean("textFormat");
|
|
360
|
-
// }
|
|
361
357
|
|
|
362
358
|
int polygonColor = Color.BLACK;
|
|
363
|
-
if (configuration.hasKey("polygonColor")){
|
|
359
|
+
if (configuration.hasKey("polygonColor")) {
|
|
364
360
|
polygonColor = Color.parseColor(configuration.getString("polygonColor"));
|
|
365
361
|
}
|
|
366
362
|
|
|
367
363
|
int textColor = Color.BLACK;
|
|
368
|
-
if (configuration.hasKey("textColor")){
|
|
364
|
+
if (configuration.hasKey("textColor")) {
|
|
369
365
|
textColor = Color.parseColor(configuration.getString("textColor"));
|
|
370
366
|
}
|
|
371
367
|
|
|
372
368
|
int textContainerColor = Color.BLACK;
|
|
373
|
-
if (configuration.hasKey("textContainerColor")){
|
|
369
|
+
if (configuration.hasKey("textContainerColor")) {
|
|
374
370
|
textContainerColor = Color.parseColor(configuration.getString("textContainerColor"));
|
|
375
371
|
}
|
|
376
372
|
|
|
377
373
|
Integer highlightedPolygonColor = null;
|
|
378
|
-
if (configuration.hasKey("highlightedPolygonColor")){
|
|
374
|
+
if (configuration.hasKey("highlightedPolygonColor")) {
|
|
379
375
|
highlightedPolygonColor = Color.parseColor(configuration.getString("highlightedPolygonColor"));
|
|
380
376
|
}
|
|
381
377
|
|
|
382
378
|
Integer highlightedTextColor = null;
|
|
383
|
-
if (configuration.hasKey("highlightedTextColor")){
|
|
379
|
+
if (configuration.hasKey("highlightedTextColor")) {
|
|
384
380
|
highlightedTextColor = Color.parseColor(configuration.getString("highlightedTextColor"));
|
|
385
381
|
}
|
|
386
382
|
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
}
|
|
117
117
|
configuration.viewFinderEnabled = self.shouldUseFinderView;
|
|
118
118
|
viewController.viewFinderConfiguration = configuration;
|
|
119
|
-
|
|
119
|
+
if (_cameraViewConfiguration.barcodeFormats) {
|
|
120
120
|
viewController.acceptedBarcodeTypes = _cameraViewConfiguration.barcodeFormats;
|
|
121
121
|
}
|
|
122
122
|
if (_cameraViewConfiguration.acceptedDocumentFormats) {
|
|
@@ -194,7 +194,6 @@
|
|
|
194
194
|
|
|
195
195
|
- (void)sendScanResults:(NSArray<SBSDKBarcodeScannerResult*>*) results onImage:(UIImage*)image {
|
|
196
196
|
if(!self.onBarcodeScannerResult) {
|
|
197
|
-
// hello
|
|
198
197
|
return;
|
|
199
198
|
}
|
|
200
199
|
|
package/ios/ScanbotBarcodeSdk.m
CHANGED
|
@@ -128,7 +128,7 @@ RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
|
|
|
128
128
|
[ObjectMapper populateInstance:uiConfig fromDictionary:configuration];
|
|
129
129
|
[ObjectMapper populateInstance:behaviorConfig fromDictionary:configuration];
|
|
130
130
|
[ObjectMapper populateInstance:textConfig fromDictionary:configuration];
|
|
131
|
-
selectionOverlayConfig =
|
|
131
|
+
selectionOverlayConfig = extractSelectionOverlayConfig(configuration);
|
|
132
132
|
}
|
|
133
133
|
@catch (NSException* ex) {
|
|
134
134
|
reject(@"Property error", [ex reason], nil);
|
|
@@ -186,7 +186,7 @@ RCT_EXPORT_METHOD(startBatchBarcodeScanner:(NSDictionary*)configuration
|
|
|
186
186
|
[ObjectMapper populateInstance:uiConfig fromDictionary:configuration];
|
|
187
187
|
[ObjectMapper populateInstance:behaviorConfig fromDictionary:configuration];
|
|
188
188
|
[ObjectMapper populateInstance:textConfig fromDictionary:configuration];
|
|
189
|
-
selectionOverlayConfig =
|
|
189
|
+
selectionOverlayConfig = extractSelectionOverlayConfig(configuration);
|
|
190
190
|
}
|
|
191
191
|
@catch (NSException* ex) {
|
|
192
192
|
reject(@"Property error", [ex reason], nil);
|
|
@@ -28,6 +28,8 @@ static inline SBSDKBarcodeType* barcodeTypeFromString(NSString* string) {
|
|
|
28
28
|
if ([string isEqualToString:@"MSI_PLESSEY"]) return SBSDKBarcodeTypeMSIPlessey;
|
|
29
29
|
if ([string isEqualToString:@"RSS_14"]) return SBSDKBarcodeTypeRSS14;
|
|
30
30
|
if ([string isEqualToString:@"RSS_EXPANDED"]) return SBSDKBarcodeTypeRSSExpanded;
|
|
31
|
+
if ([string isEqualToString:@"IATA_2_OF_5"]) return SBSDKBarcodeTypeIATA2Of5;
|
|
32
|
+
if ([string isEqualToString:@"INDUSTRIAL_2_OF_5"]) return SBSDKBarcodeTypeIndustrial2Of5;
|
|
31
33
|
return nil;
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -63,7 +65,7 @@ static inline NSString* stringFromBarcodeType(SBSDKBarcodeType* type) {
|
|
|
63
65
|
if ([type.name isEqualToString:@"RSSExpanded"]) {
|
|
64
66
|
return @"RSS_EXPANDED";
|
|
65
67
|
}
|
|
66
|
-
|
|
68
|
+
|
|
67
69
|
NSString* result = [type.name uppercaseString];
|
|
68
70
|
result = [result stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
|
|
69
71
|
result = [result stringByReplacingOccurrencesOfString:@" " withString:@"_"];
|
|
@@ -85,7 +87,7 @@ static inline NSArray<NSDictionary<NSString*, NSObject*>*>* jsonFromBarcodeResul
|
|
|
85
87
|
for (int i = 0; i < results.count; ++i) {
|
|
86
88
|
[jsonResults addObject:jsonFromBarcodeResult([results objectAtIndex:i])];
|
|
87
89
|
}
|
|
88
|
-
|
|
90
|
+
|
|
89
91
|
return [jsonResults copy];
|
|
90
92
|
}
|
|
91
93
|
|
|
@@ -94,13 +96,13 @@ static inline NSArray<NSDictionary<NSString*, NSObject*>*>* jsonFromMappedBarcod
|
|
|
94
96
|
for (int i = 0; i < results.count; ++i) {
|
|
95
97
|
[jsonResults addObject:jsonFromBarcodeResult([results objectAtIndex:i].barcode)];
|
|
96
98
|
}
|
|
97
|
-
|
|
99
|
+
|
|
98
100
|
return [jsonResults copy];
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
static inline SBSDKBarcodeMSIPlesseyChecksumAlgorithm extractPlesseyChecksumAlgorithmFromConfiguration(NSDictionary* configuration) {
|
|
102
104
|
NSString* algorithm = [configuration objectForKey:@"msiPlesseyChecksumAlgorithm"];
|
|
103
|
-
|
|
105
|
+
|
|
104
106
|
if (algorithm != nil) {
|
|
105
107
|
if ([algorithm isEqualToString:@"None"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmNone;
|
|
106
108
|
if ([algorithm isEqualToString:@"Mod10"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod10;
|
|
@@ -110,7 +112,7 @@ static inline SBSDKBarcodeMSIPlesseyChecksumAlgorithm extractPlesseyChecksumAlgo
|
|
|
110
112
|
if ([algorithm isEqualToString:@"Mod1110IBM"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod1110IBM;
|
|
111
113
|
if ([algorithm isEqualToString:@"Mod1110NCR"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod1110NCR;
|
|
112
114
|
}
|
|
113
|
-
|
|
115
|
+
|
|
114
116
|
return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod10;
|
|
115
117
|
}
|
|
116
118
|
|
|
@@ -133,18 +135,18 @@ static inline SBSDKUIBarcodeFilter* extractBarcodeFilter(NSDictionary* configura
|
|
|
133
135
|
|
|
134
136
|
static inline NSArray* filterBarcodeResults(NSArray<SBSDKBarcodeScannerResult *>* barcodeResults, SBSDKUIBarcodeFilter* filter) {
|
|
135
137
|
NSMutableArray<SBSDKBarcodeScannerResult *>* outResults = [[NSMutableArray alloc] init];
|
|
136
|
-
|
|
138
|
+
|
|
137
139
|
if (barcodeResults == nil) {
|
|
138
140
|
return outResults;
|
|
139
141
|
}
|
|
140
|
-
|
|
142
|
+
|
|
141
143
|
for (SBSDKBarcodeScannerResult* result in barcodeResults) {
|
|
142
144
|
if (![filter acceptsBarcode:result]) {
|
|
143
145
|
continue;
|
|
144
146
|
}
|
|
145
147
|
[outResults addObject:result];
|
|
146
148
|
}
|
|
147
|
-
|
|
149
|
+
|
|
148
150
|
return outResults;
|
|
149
151
|
}
|
|
150
152
|
|
|
@@ -221,7 +223,7 @@ static inline SBSDKBarcodeAdditionalParameters* extractAdditionalParameters(NSDi
|
|
|
221
223
|
additionalParameters.msiPlesseyChecksumAlgorithm = extractPlesseyChecksumAlgorithmFromConfiguration(configuration);
|
|
222
224
|
|
|
223
225
|
additionalParameters.codeDensity = extractBarcodeDensity(configuration);
|
|
224
|
-
|
|
226
|
+
|
|
225
227
|
return additionalParameters;
|
|
226
228
|
}
|
|
227
229
|
|
|
@@ -243,4 +245,49 @@ static inline SBSDKUICameraConfiguration* extractCameraConfiguration(NSDictionar
|
|
|
243
245
|
}
|
|
244
246
|
|
|
245
247
|
|
|
248
|
+
/**
|
|
249
|
+
Extracts the selection overlay configuration values from the JSON dictionary.
|
|
250
|
+
*/
|
|
251
|
+
static inline SBSDKUIBarcodeSelectionOverlayConfiguration* extractSelectionOverlayConfig(NSDictionary *dictionary) {
|
|
252
|
+
SBSDKUIBarcodeSelectionOverlayConfiguration *overlayConfig = [[SBSDKUIBarcodeSelectionOverlayConfiguration alloc] init];
|
|
253
|
+
NSDictionary *selectionOverlayDictionary = [dictionary objectForKey:@"overlayConfiguration"];
|
|
254
|
+
if (selectionOverlayDictionary != nil) {
|
|
255
|
+
NSNumber *overlayEnabled = [selectionOverlayDictionary objectForKey:@"overlayEnabled"];
|
|
256
|
+
if (overlayEnabled != nil) {
|
|
257
|
+
overlayConfig.overlayEnabled = overlayEnabled.boolValue;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
NSString *polygonColor = [selectionOverlayDictionary objectForKey:@"polygonColor"];
|
|
261
|
+
if (polygonColor != nil) {
|
|
262
|
+
overlayConfig.polygonColor = [UIColor colorFromHexString:polygonColor];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
NSString *textColor = [selectionOverlayDictionary objectForKey:@"textColor"];
|
|
266
|
+
if (textColor != nil) {
|
|
267
|
+
overlayConfig.textColor = [UIColor colorFromHexString:textColor];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
NSString *textContainerColor = [selectionOverlayDictionary objectForKey:@"textContainerColor"];
|
|
271
|
+
if (textContainerColor != nil) {
|
|
272
|
+
overlayConfig.textContainerColor = [UIColor colorFromHexString:textContainerColor];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
NSString *highlightedPolygonColor = [selectionOverlayDictionary objectForKey:@"highlightedPolygonColor"];
|
|
276
|
+
if (highlightedPolygonColor != nil) {
|
|
277
|
+
overlayConfig.highlightedPolygonColor = [UIColor colorFromHexString:highlightedPolygonColor];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
NSString *highlightedTextColor = [selectionOverlayDictionary objectForKey:@"highlightedTextColor"];
|
|
281
|
+
if (highlightedTextColor != nil) {
|
|
282
|
+
overlayConfig.highlightedTextColor = [UIColor colorFromHexString:highlightedTextColor];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
NSString *highlightedTextContainerColor = [selectionOverlayDictionary objectForKey:@"highlightedTextContainerColor"];
|
|
286
|
+
if (highlightedTextContainerColor != nil) {
|
|
287
|
+
overlayConfig.highlightedTextContainerColor = [UIColor colorFromHexString:highlightedTextContainerColor];
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return overlayConfig;
|
|
291
|
+
}
|
|
292
|
+
|
|
246
293
|
#endif /* BarcodeMapping_h */
|
package/ios/Utils/ObjectMapper.h
CHANGED
|
@@ -22,6 +22,5 @@
|
|
|
22
22
|
+ (NSString *) normalizeJsonString:(NSString *)strValue;
|
|
23
23
|
+ (NSURL *) normalizeJsonFileURL:(NSString *)fileUrl;
|
|
24
24
|
+ (NSString *)normalizeJsonFileURLAsString:(NSString *)fileUrl;
|
|
25
|
-
+ (SBSDKUIBarcodeSelectionOverlayConfiguration *)extractSelectionOverlayConfig:(NSDictionary*)dictionary;
|
|
26
25
|
|
|
27
26
|
@end
|
package/ios/Utils/ObjectMapper.m
CHANGED
|
@@ -140,56 +140,4 @@ static NSDictionary<NSString*, NSDictionary<NSString*, NSNumber*>*>* _enumeratio
|
|
|
140
140
|
return url.absoluteString;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/**
|
|
144
|
-
Extracts the selection overlay configuration values from the JSON dictionary.
|
|
145
|
-
*/
|
|
146
|
-
+ (SBSDKUIBarcodeSelectionOverlayConfiguration *) extractSelectionOverlayConfig:(NSDictionary*) dictionary {
|
|
147
|
-
SBSDKUIBarcodeSelectionOverlayConfiguration* overlayConfig = [[SBSDKUIBarcodeSelectionOverlayConfiguration alloc] init];
|
|
148
|
-
NSDictionary *selectionOverlayDictionary = [dictionary objectForKey: @"selectionOverlay"];
|
|
149
|
-
if (selectionOverlayDictionary != nil) {
|
|
150
|
-
|
|
151
|
-
NSNumber *overlayEnabled = [selectionOverlayDictionary objectForKey:@"overlayEnabled"];
|
|
152
|
-
if (overlayEnabled != nil) {
|
|
153
|
-
overlayConfig.overlayEnabled = overlayEnabled.boolValue;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// TODO: currently not available
|
|
157
|
-
// NSNumber *overlayTextFormat = [selectionOverlayDictionary objectForKey:@"overlayTextFormat"];
|
|
158
|
-
// if (overlayTextFormat != nil) {
|
|
159
|
-
// overlayConfig.overlayEnabled = overlayTextFormat;
|
|
160
|
-
// }
|
|
161
|
-
|
|
162
|
-
NSString *polygonColor = [selectionOverlayDictionary objectForKey:@"polygonColor"];
|
|
163
|
-
if (polygonColor != nil) {
|
|
164
|
-
overlayConfig.polygonColor = [UIColor colorFromHexString: polygonColor];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
NSString *textColor = [selectionOverlayDictionary objectForKey:@"textColor"];
|
|
168
|
-
if (textColor != nil) {
|
|
169
|
-
overlayConfig.textColor = [UIColor colorFromHexString: textColor];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
NSString *textContainerColor = [selectionOverlayDictionary objectForKey:@"textContainerColor"];
|
|
173
|
-
if (textContainerColor != nil) {
|
|
174
|
-
overlayConfig.textContainerColor = [UIColor colorFromHexString: textContainerColor];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
NSString *highlightedPolygonColor = [selectionOverlayDictionary objectForKey:@"highlightedPolygonColor"];
|
|
178
|
-
if (highlightedPolygonColor != nil) {
|
|
179
|
-
overlayConfig.highlightedPolygonColor = [UIColor colorFromHexString: highlightedPolygonColor];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
NSString *highlightedTextColor = [selectionOverlayDictionary objectForKey:@"highlightedTextColor"];
|
|
183
|
-
if (highlightedTextColor != nil) {
|
|
184
|
-
overlayConfig.highlightedTextColor = [UIColor colorFromHexString: highlightedTextColor];
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
NSString *highlightedTextContainerColor = [selectionOverlayDictionary objectForKey:@"highlightedTextContainerColor"];
|
|
188
|
-
if (highlightedTextContainerColor != nil) {
|
|
189
|
-
overlayConfig.highlightedTextContainerColor = [UIColor colorFromHexString: highlightedTextContainerColor];
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return overlayConfig;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
143
|
@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.3.0-
|
|
4
|
+
"version": "3.3.0-beta2",
|
|
5
5
|
"description": "Scanbot Barcode Scanner SDK React Native Plugin for Android and iOS",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|