Skip to content

Commit

Permalink
Merge pull request #124 from Anyline/release/35
Browse files Browse the repository at this point in the history
Release/35
  • Loading branch information
renatoAnyline authored Nov 25, 2021
2 parents 584b3ae + d67b491 commit 83d9a65
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 50 deletions.
4 changes: 2 additions & 2 deletions example/RNExampleApp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ android {
applicationId "com.anyline.example.reactnative"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2
versionName "29.1"
versionCode 3
versionName "35.0.0"
multiDexEnabled true

}
Expand Down
8 changes: 1 addition & 7 deletions example/RNExampleApp/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:4.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down Expand Up @@ -41,9 +41,3 @@ allprojects {
}
}
}


//task wrapper(type: Wrapper) {
// gradleVersion = '5.4'
// distributionUrl = distributionUrl.replace("bin", "all")
//}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
6 changes: 3 additions & 3 deletions example/RNExampleApp/config/BarcodeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ license: 'ewogICJsaWNlbnNlS2V5VmVyc2lvbiI6IDIsCiAgImRlYnVnUmVwb3J0aW5nIjogIm9uIi
"plugin": {
"id": "Barcode_ID",
"barcodePlugin": {
"barcodeFormatOptions": ["UPC_E", "EAN_13", "UPC_A", "EAN_8", "AZTEC", "CODABAR", "CODE_11", "CODE_32", "CODE_39", "CODE_93", "CODE_128", "DATABAR", "DATA_MATRIX", "GS1_QR_CODE", "GS1_128", "ITF", "ISBT_128", "MSI", "MICRO_QR", "MICRO_PDF", "PDF_417", "POST_UK",
"QR_CODE", "RSS_14", "RSS_EXPANDED", "TRIOPTIC", "USPS_4CB", "US_PLANET", "US_POSTNET"]

"barcodeFormatOptions": ["UPC_E", "EAN_13", "UPC_A", "EAN_8", "AZTEC", "CODABAR", "CODE_11", "CODE_32", "CODE_39", "CODE_93", "CODE_128", "DATABAR", "DATA_MATRIX", "GS1_QR_CODE", "GS1_128", "ITF", "ISBT_128", "MSI", "MICRO_QR", "MICRO_PDF", "PDF_417", "POST_UK",
"QR_CODE", "RSS_14", "RSS_EXPANDED", "TRIOPTIC", "USPS_4CB", "US_PLANET", "US_POSTNET"],
"enablePDF417Parsing": true
}
},
"cutoutConfig": {
Expand Down
3 changes: 2 additions & 1 deletion example/RNExampleApp/config/Barcode_PDF417Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default {
"plugin": {
"id": "Barcode_ID",
"barcodePlugin": {
"barcodeFormatOptions": ["PDF_417"]
"barcodeFormatOptions": ["PDF_417"],
"enablePDF417Parsing": true
}
},
"cutoutConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RNExampleApp/Pods-RNExampleApp-resources.sh",
"${PODS_ROOT}/Anyline/AnylineSDK_iOS_34/Framework/AnylineResources.bundle",
"${PODS_ROOT}/Anyline/AnylineSDK_iOS_35/Framework/AnylineResources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
);
name = "[CP] Copy Pods Resources";
Expand Down
2 changes: 1 addition & 1 deletion example/RNExampleApp/ios/RNExampleApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>34.0.0</string>
<string>35.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion example/RNExampleApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "RNExampleApp",
"version": "34.0.1",
"version": "35.0.0",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
Expand Down
2 changes: 1 addition & 1 deletion plugin/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ repositories {

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'io.anyline:anylinesdk:34.0.0'
implementation 'io.anyline:anylinesdk:35.0.0'
implementation "com.facebook.react:react-native:+" // from node_modules
implementation("com.google.android.material:material:1.4.0-rc01")
implementation 'androidx.multidex:multidex:2.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import io.anyline.plugin.ScanResult;
import io.anyline.plugin.ScanResultListener;
import io.anyline.plugin.barcode.Barcode;
import io.anyline.plugin.barcode.BarcodeScanPlugin;
import io.anyline.plugin.barcode.BarcodeScanResult;
import io.anyline.plugin.barcode.BarcodeScanViewPlugin;
import io.anyline.plugin.barcode.PDF417;
import io.anyline.plugin.id.DrivingLicenseConfig;
import io.anyline.plugin.id.DrivingLicenseIdentification;
import io.anyline.plugin.id.GermanIdFrontConfig;
Expand Down Expand Up @@ -246,24 +248,7 @@ public void onResult(ScanResult result) {
e.printStackTrace();
}
} else if (subResult instanceof BarcodeScanResult) {
try {
List<Barcode> barcodeList = (List<Barcode>) subResult.getResult();

JSONArray barcodeArray = new JSONArray();
if (barcodeList.size() > 1) {
for (int i = 0; i < barcodeList.size(); i++) {
barcodeArray.put(barcodeList.get(i).toJSONObject());
}
JSONObject finalObject = new JSONObject();
finalObject.put("multiBarcodes", barcodeArray);
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, finalObject);
} else {
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, barcodeList.get(0).toJSONObject());

}
} catch (JSONException e) {
e.printStackTrace();
}
jsonResult = extractBarcodeResult(jsonResult, subResult);
} else if (subResult instanceof MeterScanResult) {
JSONObject jsonMeterResult = new JSONObject();
try {
Expand Down Expand Up @@ -424,6 +409,9 @@ public void onResult(OcrScanResult ocrScanResult) {

} else if (scanViewPlugin instanceof BarcodeScanViewPlugin) {

if (shouldEnablePDF417(json)) {
((BarcodeScanPlugin) ((BarcodeScanViewPlugin) scanViewPlugin).getScanPlugin()).enablePDF417Parsing();
}
scanViewPlugin.addScanResultListener(new ScanResultListener<BarcodeScanResult>() {
@Override
public void onResult(BarcodeScanResult barcodeScanResult) {
Expand All @@ -438,6 +426,11 @@ public void onResult(BarcodeScanResult barcodeScanResult) {
barcode.put("value", barcodeList.get(i).getValue());
barcode.put("barcodeFormat", barcodeList.get(i).getBarcodeFormat());

PDF417 pdf417 = barcodeList.get(i).getParsedPDF417();

if(pdf417 != null) {
barcode.put("parsedPDF417", pdf417.toJSONObject());
}
barcodeArray.put(barcode);
}
JSONObject finalObject = new JSONObject();
Expand Down Expand Up @@ -497,6 +490,42 @@ public void onResult(MeterScanResult meterScanResult) {

}

private boolean shouldEnablePDF417(JSONObject jsonObject) {
JSONObject viewPlugin = jsonObject.optJSONObject("viewPlugin");

if (viewPlugin != null) {
JSONObject plugin = viewPlugin.optJSONObject("plugin");

if (plugin != null) {
JSONObject barcodePlugin = plugin.optJSONObject("barcodePlugin");
return barcodePlugin != null && barcodePlugin.optBoolean("enablePDF417Parsing");
}
}
return false;
}

private JSONObject extractBarcodeResult(JSONObject jsonResult, ScanResult subResult) {
try {
List<Barcode> barcodeList = (List<Barcode>) subResult.getResult();

JSONArray barcodeArray = new JSONArray();
if (barcodeList.size() > 1) {
for (int i = 0; i < barcodeList.size(); i++) {
barcodeArray.put(barcodeList.get(i).toJSONObject());
}
JSONObject finalObject = new JSONObject();
finalObject.put("multiBarcodes", barcodeArray);
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, finalObject);
} else {
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, barcodeList.get(0).toJSONObject());

}
} catch (JSONException e) {
e.printStackTrace();
}
return jsonResult;
}

// this method is used only for the meter scanning which contains radio buttons
@Override
public void onCameraOpened(CameraController cameraController, int width, int height) {
Expand Down
12 changes: 7 additions & 5 deletions plugin/ios/ALPluginHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,13 @@ + (NSDictionary *)dictionaryForBarcodeResult:(ALBarcodeResult *)scanResult


for(ALBarcode *barcode in scanResult.result) {
NSString * value = barcode.value ? barcode.value : barcode.base64;
[barcodeArray addObject:@{
@"value" : value ? value : @"",
@"barcodeFormat" : [ALPluginHelper barcodeFormatFromString:barcode.barcodeFormat]
}];
NSMutableDictionary *barcodeDictionary = @{ @"value":barcode.value,
@"barcodeFormat": [ALPluginHelper barcodeFormatFromString:barcode.barcodeFormat]}.mutableCopy;
if (barcode.parsedPDF417 != nil) {
NSString *newValueWithPDF417 = [NSString stringWithFormat:@"{\"rawPDF417\" : \"%@\", \"parsedPDF417\" : \"%@\"}", barcode.value, [barcode.parsedPDF417[kPDF417ParsedBody] description]];
[barcodeDictionary setValue:newValueWithPDF417 forKey:@"value"];
}
[barcodeArray addObject:barcodeDictionary];
}

[dictResult setValue:barcodeArray forKey:@"barcodes"];
Expand Down
4 changes: 4 additions & 0 deletions plugin/ios/ALPluginScanViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ - (void)viewDidLoad {

self.scanView.cameraConfig = [ALCameraConfig defaultCameraConfig];
}

if ([self.scanView.scanViewPlugin isKindOfClass:[ALBarcodeScanViewPlugin class]] && self.anylineConfig[@"viewPlugin"][@"plugin"][@"barcodePlugin"][@"enablePDF417Parsing"]) {
((ALBarcodeScanViewPlugin*)self.scanView.scanViewPlugin).barcodeScanPlugin.parsePDF417 = YES;
}

if(!self.scanView) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not start scanning" message:error.localizedDescription delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
Expand Down
2 changes: 1 addition & 1 deletion plugin/ios/AnylineReact.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" }

s.source_files = "*.{h,m}"
s.dependency "Anyline", "~> 34"
s.dependency "Anyline", "~> 35"
s.dependency "React"
end
16 changes: 8 additions & 8 deletions plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"_from": "anyline-ocr-react-native-module@^34.0.1",
"_id": "anyline-ocr-react-native-module@34.0.1",
"_from": "anyline-ocr-react-native-module@^35.0.0",
"_id": "anyline-ocr-react-native-module@35.0.0",
"_inBundle": false,
"_integrity": "sha512-BGi9zNkSsoxXywDBIqzgBRvKUBniQOJHDKBrozZubKthZNRBAj8Ry5tW0Me0yLXt/fauME//hbC0wsenfPJZqw==",
"_location": "/anyline-ocr-react-native-module",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "anyline-ocr-react-native-module@^34.0.1",
"raw": "anyline-ocr-react-native-module@^35.0.0",
"name": "anyline-ocr-react-native-module",
"escapedName": "anyline-ocr-react-native-module",
"rawSpec": "^34.0.1",
"rawSpec": "^35.0.0",
"saveSpec": null,
"fetchSpec": "^34.0.1"
"fetchSpec": "^35.0.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-34.0.1.tgz",
"_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-35.0.0.tgz",
"_shasum": "bacbcd260cc662244f59393ed81a6edba009b52c",
"_spec": "anyline-ocr-react-native-module@^34.0.1",
"_spec": "anyline-ocr-react-native-module@^35.0.0",
"_where": "/Users/amiransari/Projects/anyline-ocr-react-native-module1/example/RNExampleApp",
"bugs": {
"url": "https://github.com/Anyline/anyline-ocr-react-native-module/issues"
Expand All @@ -47,5 +47,5 @@
"type": "git",
"url": "git+https://github.com/Anyline/anyline-ocr-react-native-module.git"
},
"version": "34.0.1"
"version": "35.0.0"
}

0 comments on commit 83d9a65

Please sign in to comment.