Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Updated Android SDK to v9.0.0. #22

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.5.0
* Updated Android SDK to v9.0.0.
* Bug fixes.

## 1.4.1
* Removed unused import: 'dart:html'.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The Flutter barcode SDK plugin is a wrapper for [Dynamsoft Barcode Reader SDK](h
## SDK Version Used for Different Platforms
| Dynamsoft Barcode Reader | Android | iOS | Windows | Linux | macOS | Web|
| ----------- | ----------- | ----------- | ----------- |----------- |----------- |----------- |
| Version | 8.9.3 | 8.9.3 | 9.0 | 9.0 |8.2 | 8.8.7 |
| Version | 9.0 | 8.9.3 | 9.0 | 9.0 |8.2 | 8.8.7 |


## API Compatibility
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ android {
}

dependencies {
implementation 'com.dynamsoft:dynamsoftbarcodereader:8.9.3@aar'
implementation 'com.dynamsoft:dynamsoftbarcodereader:9.0.0@aar'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import android.graphics.BitmapFactory;

import com.dynamsoft.dbr.BarcodeReaderException;
import com.dynamsoft.dbr.DBRLTSLicenseVerificationListener;
import com.dynamsoft.dbr.DMLTSConnectionParameters;
import com.dynamsoft.dbr.DBRLicenseVerificationListener;
import com.dynamsoft.dbr.EnumBarcodeFormat;
import com.dynamsoft.dbr.EnumConflictMode;
import com.dynamsoft.dbr.EnumImagePixelFormat;
Expand All @@ -21,33 +20,41 @@
import java.util.List;
import java.util.Map;

import io.flutter.plugin.common.MethodChannel.Result;

public class BarcodeManager {
private static final String TAG = "DynamsoftBarcodeReader";
private BarcodeReader mBarcodeReader;

public BarcodeManager() {
try {
mBarcodeReader = new BarcodeReader();
//Best Coverage settings
//mbarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestCoverage\",\"DeblurLevel\":9,\"ExpectedBarcodesCount\":512,\"ScaleDownThreshold\":100000,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"},{\"Mode\":\"LM_STATISTICS\"},{\"Mode\":\"LM_LINES\"},{\"Mode\":\"LM_STATISTICS_MARKS\"}],\"GrayscaleTransformationModes\":[{\"Mode\":\"GTM_ORIGINAL\"},{\"Mode\":\"GTM_INVERTED\"}]}}", EnumConflictMode.CM_OVERWRITE);
//Best Speed settings
//mbarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestSpeed\",\"DeblurLevel\":3,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_SCAN_DIRECTLY\"}],\"TextFilterModes\":[{\"MinImageDimension\":262144,\"Mode\":\"TFM_GENERAL_CONTOUR\"}]}}", EnumConflictMode.CM_OVERWRITE);
//Balance settings
mBarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"Balance\",\"DeblurLevel\":5,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"}]}}", EnumConflictMode.CM_OVERWRITE);
PublicRuntimeSettings settings = mBarcodeReader.getRuntimeSettings();
settings.intermediateResultTypes = EnumIntermediateResultType.IRT_TYPED_BARCODE_ZONE;
settings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_DATAMATRIX | EnumBarcodeFormat.BF_QR_CODE | EnumBarcodeFormat.BF_PDF417;
settings.barcodeFormatIds_2 = 0;
mBarcodeReader.updateRuntimeSettings(settings);
} catch (Exception e) {
e.printStackTrace();
}
}
// public BarcodeManager() {
// try {
// mBarcodeReader = new BarcodeReader();
// //Best Coverage settings
// //mbarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestCoverage\",\"DeblurLevel\":9,\"ExpectedBarcodesCount\":512,\"ScaleDownThreshold\":100000,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"},{\"Mode\":\"LM_STATISTICS\"},{\"Mode\":\"LM_LINES\"},{\"Mode\":\"LM_STATISTICS_MARKS\"}],\"GrayscaleTransformationModes\":[{\"Mode\":\"GTM_ORIGINAL\"},{\"Mode\":\"GTM_INVERTED\"}]}}",
// EnumConflictMode.CM_OVERWRITE);
// //Best Speed settings
// //mbarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestSpeed\",\"DeblurLevel\":3,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_SCAN_DIRECTLY\"}],\"TextFilterModes\":[{\"MinImageDimension\":262144,\"Mode\":\"TFM_GENERAL_CONTOUR\"}]}}",
// EnumConflictMode.CM_OVERWRITE);
// //Balance settings
// mBarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"Balance\",\"DeblurLevel\":5,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"}]}}",
// EnumConflictMode.CM_OVERWRITE);
// PublicRuntimeSettings settings = mBarcodeReader.getRuntimeSettings();
// settings.intermediateResultTypes =
// EnumIntermediateResultType.IRT_TYPED_BARCODE_ZONE;
// settings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED |
// EnumBarcodeFormat.BF_DATAMATRIX | EnumBarcodeFormat.BF_QR_CODE |
// EnumBarcodeFormat.BF_PDF417;
// settings.barcodeFormatIds_2 = 0;
// mBarcodeReader.updateRuntimeSettings(settings);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }

private void wrapResults(TextResult[] results, List<Map<String, Object>> out) {
if (results != null) {

for (TextResult result: results) {
for (TextResult result : results) {
Map<String, Object> data = new HashMap<>();
data.put("format", result.barcodeFormatString);
data.put("text", result.barcodeText);
Expand All @@ -69,15 +76,20 @@ public void init() {
if (mBarcodeReader == null) {
try {
mBarcodeReader = new BarcodeReader();
//Best Coverage settings
//mbarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestCoverage\",\"DeblurLevel\":9,\"ExpectedBarcodesCount\":512,\"ScaleDownThreshold\":100000,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"},{\"Mode\":\"LM_STATISTICS\"},{\"Mode\":\"LM_LINES\"},{\"Mode\":\"LM_STATISTICS_MARKS\"}],\"GrayscaleTransformationModes\":[{\"Mode\":\"GTM_ORIGINAL\"},{\"Mode\":\"GTM_INVERTED\"}]}}", EnumConflictMode.CM_OVERWRITE);
//Best Speed settings
//mbarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestSpeed\",\"DeblurLevel\":3,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_SCAN_DIRECTLY\"}],\"TextFilterModes\":[{\"MinImageDimension\":262144,\"Mode\":\"TFM_GENERAL_CONTOUR\"}]}}", EnumConflictMode.CM_OVERWRITE);
//Balance settings
mBarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"Balance\",\"DeblurLevel\":5,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"}]}}", EnumConflictMode.CM_OVERWRITE);
// Best Coverage settings
// mbarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestCoverage\",\"DeblurLevel\":9,\"ExpectedBarcodesCount\":512,\"ScaleDownThreshold\":100000,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"},{\"Mode\":\"LM_STATISTICS\"},{\"Mode\":\"LM_LINES\"},{\"Mode\":\"LM_STATISTICS_MARKS\"}],\"GrayscaleTransformationModes\":[{\"Mode\":\"GTM_ORIGINAL\"},{\"Mode\":\"GTM_INVERTED\"}]}}",
// EnumConflictMode.CM_OVERWRITE);
// Best Speed settings
// mbarcodeReader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestSpeed\",\"DeblurLevel\":3,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_SCAN_DIRECTLY\"}],\"TextFilterModes\":[{\"MinImageDimension\":262144,\"Mode\":\"TFM_GENERAL_CONTOUR\"}]}}",
// EnumConflictMode.CM_OVERWRITE);
// Balance settings
mBarcodeReader.initRuntimeSettingsWithString(
"{\"ImageParameter\":{\"Name\":\"Balance\",\"DeblurLevel\":5,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"}]}}",
EnumConflictMode.CM_OVERWRITE);
PublicRuntimeSettings settings = mBarcodeReader.getRuntimeSettings();
settings.intermediateResultTypes = EnumIntermediateResultType.IRT_TYPED_BARCODE_ZONE;
settings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_DATAMATRIX | EnumBarcodeFormat.BF_QR_CODE | EnumBarcodeFormat.BF_PDF417;
settings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_DATAMATRIX
| EnumBarcodeFormat.BF_QR_CODE | EnumBarcodeFormat.BF_PDF417;
settings.barcodeFormatIds_2 = 0;
mBarcodeReader.updateRuntimeSettings(settings);
} catch (Exception e) {
Expand All @@ -86,12 +98,15 @@ public void init() {
}
}

public void setLicense(String license) {
try {
mBarcodeReader.initLicense(license);
} catch (Exception e) {
e.printStackTrace();
}
public void setLicense(String license, final Result result) {
BarcodeReader.initLicense(
"DLS2eyJoYW5kc2hha2VDb2RlIjoiMjM0ODEwLVRYbE5iMkpwYkdWUWNtOXEiLCJvcmdhbml6YXRpb25JRCI6IjIzNDgxMCJ9",
new DBRLicenseVerificationListener() {
@Override
public void DBRLicenseVerificationCallback(boolean isSuccessful, Exception e) {
result.success("");
}
});
}

public List<Map<String, Object>> decodeFile(String filename) {
Expand All @@ -108,7 +123,7 @@ public List<Map<String, Object>> decodeFile(String filename) {

public List<Map<String, Object>> decodeFileBytes(byte[] bytes) {
List<Map<String, Object>> ret = new ArrayList<Map<String, Object>>();
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes , 0, bytes != null ? bytes.length : 0);
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes != null ? bytes.length : 0);
try {
TextResult[] results = mBarcodeReader.decodeBufferedImage(bitmap, "");
wrapResults(results, ret);
Expand All @@ -121,7 +136,7 @@ public List<Map<String, Object>> decodeFileBytes(byte[] bytes) {
public List<Map<String, Object>> decodeImageBuffer(byte[] bytes, int width, int height, int stride, int format) {
List<Map<String, Object>> ret = new ArrayList<Map<String, Object>>();
int pixelFormat = EnumImagePixelFormat.IPF_BGR_888;
switch(format) {
switch (format) {
case 0:
pixelFormat = EnumImagePixelFormat.IPF_GRAYSCALED;
break;
Expand All @@ -145,8 +160,7 @@ public int setBarcodeFormats(int formats) {
settings.barcodeFormatIds = formats;
mBarcodeReader.updateRuntimeSettings(settings);
return 0;
}
catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
return -1;
}
Expand All @@ -155,8 +169,7 @@ public int setBarcodeFormats(int formats) {
public String getParameters() {
try {
return mBarcodeReader.outputSettingsToString("currentRuntimeSettings");
}
catch(Exception e) {
} catch (Exception e) {
return e.toString();
}
}
Expand All @@ -166,8 +179,7 @@ public int setParameters(String params) {
PublicRuntimeSettings settings = mBarcodeReader.getRuntimeSettings();
mBarcodeReader.initRuntimeSettingsWithString(params, EnumConflictMode.CM_OVERWRITE);
return 0;
}
catch(Exception e) {
} catch (Exception e) {
return -1;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
break;
case "setLicense": {
final String license = call.argument("license");
mBarcodeManager.setLicense(license);
result.success("");
mBarcodeManager.setLicense(license, result);
}
break;
case "decodeFile": {
Expand Down
1 change: 0 additions & 1 deletion example/lib/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_barcode_sdk/dynamsoft_barcode.dart';
import 'package:flutter_barcode_sdk/flutter_barcode_sdk.dart';
import 'package:flutter_barcode_sdk/utils.dart';
import 'package:flutter_barcode_sdk_example/utils.dart';
import 'package:image_picker/image_picker.dart';

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.4.0"
version: "1.5.0"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_barcode_sdk
description: A Flutter plugin of Dynamsoft Barcode Reader SDK. It covers Android, iOS, Web, Windows, Linux and macOS, supporting linear barcode, QR Code, DataMatrix, MaxiCode, PDF417, etc.
version: 1.4.1
version: 1.5.0
homepage: https://www.dynamsoft.com/barcode-reader/overview/
repository: https://github.com/yushulx/flutter_barcode_sdk

Expand Down