Skip to content

Commit

Permalink
Merge pull request #22 from blinkcard/release/2.10.0
Browse files Browse the repository at this point in the history
Release/2.10.0
  • Loading branch information
mparadina authored Oct 24, 2024
2 parents cc0577f + 8b80fa8 commit 0522e1e
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 71 deletions.
4 changes: 2 additions & 2 deletions BlinkCard/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:8.5.0'
}
}

Expand Down Expand Up @@ -39,7 +39,7 @@ android {
}

dependencies {
implementation('com.microblink:blinkcard:2.9.3@aar') {
implementation('com.microblink:blinkcard:2.10.0@aar') {
transitive = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import com.microblink.blinkcard.metadata.recognition.FirstSideRecognitionCallback;
import com.microblink.blinkcard.recognition.RecognitionSuccessType;
import com.microblink.blinkcard.view.recognition.ScanResultListener;

import com.microblink.blinkcard.licence.exception.LicenceKeyException;

import com.microblink.blinkcard.flutter.recognizers.RecognizerSerializers;
import com.microblink.blinkcard.flutter.overlays.OverlaySettingsSerializers;
Expand All @@ -61,7 +61,6 @@ public class BlinkCardFlutterPlugin implements FlutterPlugin, MethodCallHandler,
private static final String ARG_OVERLAY_SETTINGS = "overlaySettings";
private static final String ARG_FRONT_IMAGE = "frontImage";
private static final String ARG_BACK_IMAGE = "backImage";

private boolean mFirstSideScanned = false;
private RecognizerBundle mRecognizerBundle;
private RecognizerRunner mRecognizerRunner;
Expand Down Expand Up @@ -99,27 +98,29 @@ private void setupPlugin(Context context, BinaryMessenger messenger) {

@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
setLicense((Map)call.argument(ARG_LICENSE));

if (call.method.equals(METHOD_SCAN_CAMERA)) {
pendingResult = result;
boolean isLicenseKeyValid = setLicense((Map)call.argument(ARG_LICENSE));

JSONObject jsonOverlaySettings = new JSONObject((Map)call.argument(ARG_OVERLAY_SETTINGS));
JSONObject jsonRecognizerCollection = new JSONObject((Map)call.argument(ARG_RECOGNIZER_COLLECTION));
setLanguage(jsonOverlaySettings);
mRecognizerBundle = RecognizerSerializers.INSTANCE.deserializeRecognizerCollection(jsonRecognizerCollection);
UISettings uiSettings = OverlaySettingsSerializers.INSTANCE.getOverlaySettings(context, jsonOverlaySettings, mRecognizerBundle);

startScanning(SCAN_REQ_CODE, uiSettings);

} else if (call.method.equals(METHOD_SCAN_DIRECT_API)) {
if (isLicenseKeyValid) {
setLanguage(jsonOverlaySettings);
mRecognizerBundle = RecognizerSerializers.INSTANCE.deserializeRecognizerCollection(jsonRecognizerCollection);
UISettings uiSettings = OverlaySettingsSerializers.INSTANCE.getOverlaySettings(context, jsonOverlaySettings, mRecognizerBundle);
startScanning(SCAN_REQ_CODE, uiSettings);
}
} else if (call.method.equals(METHOD_SCAN_DIRECT_API)) {
pendingResult = result;
boolean isLicenseKeyValid = setLicense((Map)call.argument(ARG_LICENSE));

JSONObject jsonRecognizerCollection = new JSONObject((Map)call.argument(ARG_RECOGNIZER_COLLECTION));
String frontImage = call.argument(ARG_FRONT_IMAGE);
String backImage = call.argument(ARG_BACK_IMAGE);

scanWithDirectApi(jsonRecognizerCollection, frontImage, backImage);
if (isLicenseKeyValid) {
scanWithDirectApi(jsonRecognizerCollection, frontImage, backImage);
}

} else {
result.notImplemented();
Expand All @@ -128,7 +129,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {


@SuppressWarnings("unchecked")
private void setLicense(Map licenseMap) {
private boolean setLicense(Map licenseMap) {
boolean isLicenseKeyValid = true;
if (licenseMap.get(ARG_SHOW_LICENSE_WARNING) != null) {
MicroblinkSDK.setShowTrialLicenseWarning((boolean) licenseMap.get(ARG_SHOW_LICENSE_WARNING));
} else {
Expand All @@ -139,12 +141,22 @@ private void setLicense(Map licenseMap) {
String licensee = (String) licenseMap.get(ARG_LICENSEE);

if (licensee == null) {
MicroblinkSDK.setLicenseKey(licenseKey, context);
try {
MicroblinkSDK.setLicenseKey(licenseKey, context);
} catch (LicenceKeyException licenceKeyException) {
isLicenseKeyValid = false;
pendingResult.error("Android license key error", licenceKeyException.getMessage(), null);
}
} else {
MicroblinkSDK.setLicenseKey(licenseKey, licensee, context);
try {
MicroblinkSDK.setLicenseKey(licenseKey, licensee, context);
} catch (LicenceKeyException licenceKeyException) {
isLicenseKeyValid = false;
pendingResult.error("Android license key error", licenceKeyException.getMessage(), null);
}
}

MicroblinkSDK.setIntentDataTransferMode(IntentDataTransferMode.PERSISTED_OPTIMISED);
MicroblinkSDK.setIntentDataTransferMode(IntentDataTransferMode.PERSISTED_OPTIMISED);
return isLicenseKeyValid;
}

private void setLanguage(JSONObject jsonOverlaySettings) {
Expand Down
51 changes: 46 additions & 5 deletions BlinkCard/ios/Classes/BlinkCardFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,27 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
NSDictionary *overlaySettingsDict = call.arguments[@"overlaySettings"];
NSDictionary *licenseKeyDict = call.arguments[@"license"];

[self setLicenseKey:licenseKeyDict];
[self scanWith:recognizerCollectionDict overlaySettingsDict:overlaySettingsDict];
if ([self setLicenseKey:licenseKeyDict]) {
[self scanWith:recognizerCollectionDict overlaySettingsDict:overlaySettingsDict];
}
}
else if ([kScanWithDirectApiMethodName isEqualToString:call.method]) {
NSDictionary *recognizerCollectionDict = call.arguments[@"recognizerCollection"];
NSString *frontImageBase64String = call.arguments[@"frontImage"];
self.backImageBase64String = call.arguments[@"backImage"];
NSDictionary *licenseKeyDict = call.arguments[@"license"];

[self setLicenseKey:licenseKeyDict];
[self scanWithDirectApi:recognizerCollectionDict frontImageString:frontImageBase64String];
if ([self setLicenseKey:licenseKeyDict]) {
[self scanWithDirectApi:recognizerCollectionDict frontImageString:frontImageBase64String];
}
}
else {
result(FlutterMethodNotImplemented);
}
}

- (void)setLicenseKey:(NSDictionary *)licenseKeyDict {
- (BOOL)setLicenseKey:(NSDictionary *)licenseKeyDict {
__block BOOL isLicenseKeyValid = YES;
licenseKeyDict = [self sanitizeDictionary:licenseKeyDict];

if ([licenseKeyDict objectForKey:@"showTrialLicenseWarning"] != nil) {
Expand All @@ -88,11 +91,17 @@ - (void)setLicenseKey:(NSDictionary *)licenseKeyDict {
if ([licenseKeyDict objectForKey:@"licensee"] != nil) {
NSString *licensee = [licenseKeyDict objectForKey:@"licensee"];
[[MBCMicroblinkSDK sharedInstance] setLicenseKey:iosLicense andLicensee:licensee errorCallback:^(MBCLicenseError licenseError) {
self.result([FlutterError errorWithCode:@"" message:[self licenseErrorToString:licenseError] details:nil]);
isLicenseKeyValid = NO;
}];
} else {
[[MBCMicroblinkSDK sharedInstance] setLicenseKey:iosLicense errorCallback:^(MBCLicenseError licenseError) {
self.result([FlutterError errorWithCode:@"" message:[self licenseErrorToString:licenseError] details:nil]);
isLicenseKeyValid = NO;
}];
}

return isLicenseKeyValid;
}

-(void)setLanguage:(NSDictionary *)overlaySettingsDict {
Expand Down Expand Up @@ -250,4 +259,36 @@ - (void) handleDirectApiError:(FlutterError*) flutterError {
self.recognizerRunner = nil;
}

- (NSString *)licenseErrorToString:(MBCLicenseError)licenseError {
switch(licenseError) {
case MBCLicenseErrorNetworkRequired:
return @"iOS license error: Network required";
break;
case MBCLicenseErrorUnableToDoRemoteLicenceCheck:
return @"iOS license error: Unable to do remote licence check";
break;
case MBCLicenseErrorLicenseIsLocked:
return @"iOS license error: License is locked";
break;
case MBCLicenseErrorLicenseCheckFailed:
return @"iOS license error: License check failed";
break;
case MBCLicenseErrorInvalidLicense:
return @"iOS license error: Invalid license";
break;
case MBCLicenseErrorPermissionExpired:
return @"iOS license error: Permission expired";
break;
case MBCLicenseErrorPayloadCorrupted:
return @"iOS license error: Payload corrupted";
break;
case MBCLicenseErrorPayloadSignatureVerificationFailed:
return @"iOS license error: Payload signature verification failed";
break;
case MBCLicenseErrorIncorrectTokenState:
return @"iOS license error: Incorrect token state";
break;
}
}

@end
4 changes: 2 additions & 2 deletions BlinkCard/ios/blinkcard_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'blinkcard_flutter'
s.version = '2.9.3'
s.version = '2.10.0'
s.summary = 'Flutter plugin for BlinkCard, SDK for scanning and OCR of various credit cards.'
s.description = <<-DESC
Flutter plugin for BlinkCard, SDK for scanning and OCR of various credit cards.
Expand All @@ -18,7 +18,7 @@ Flutter plugin for BlinkCard, SDK for scanning and OCR of various credit cards.
s.dependency 'Flutter'
s.platform = :ios, '13.0'

s.dependency 'MBBlinkCard', '~> 2.9.1'
s.dependency 'MBBlinkCard', '~> 2.10.0'

# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
Expand Down
2 changes: 1 addition & 1 deletion BlinkCard/lib/overlays/blinkcard_overlays.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BlinkCard/lib/recognizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RecognizerCollection {

bool allowMultipleResults = false;

int milisecondsBeforeTimeout = 10000;
int milisecondsBeforeTimeout = 0;

RecognizerCollection(this.recognizerArray);

Expand Down
3 changes: 2 additions & 1 deletion BlinkCard/lib/recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BlinkCard/lib/recognizers/blink_card_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions BlinkCard/lib/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,38 @@ enum DataMatchState {
Failed,
/// Data match.
Success
}

/// Defines possible Android device camera video resolution preset
enum AndroidCameraResolutionPreset {
/// Will choose camera video resolution which is best for current device.
@JsonValue(0) PresetDefault,
/// Attempts to choose camera video resolution as closely as 480p.
@JsonValue(1) Preset480p,
/// Attempts to choose camera video resolution as closely as 720p.
@JsonValue(2) Preset720p,
/// Attempts to choose camera video resolution as closely as 1080p.
@JsonValue(3) Preset1080p,
/// Attempts to choose camera video resolution as closely as 2160p.
@JsonValue(4) Preset2160p,
/// Will choose max available camera video resolution.
@JsonValue(5) PresetMaxAvailable
}

/// Define possible iOS device camera video resolution preset
enum iOSCameraResolutionPreset {
/// 480p video will always be used.
@JsonValue(0) Preset480p,
/// 720p video will always be used.
@JsonValue(1) Preset720p,
/// 1080p video will always be used.
@JsonValue(2) Preset1080p,
/// 4K video will always be used.
@JsonValue(3) Preset4K,
/// The library will calculate optimal resolution based on the use case and device used.
@JsonValue(4) PresetOptimal,
/// Device's maximal video resolution will be used.
@JsonValue(5) PresetMax,
/// Device's photo preview resolution will be used.
@JsonValue(6) PresetPhoto
}
4 changes: 2 additions & 2 deletions BlinkCard/lib/types.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions BlinkCard/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
name: blinkcard_flutter
description: Flutter plugin for BlinkCard, SDK for scanning and OCR of various credit cards.
version: 2.9.3
version: 2.10.0
author: Microblink
homepage: https://microblink.com

environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.12.0"
sdk: ">=2.12.0 <4.0.0"
flutter: "1.12.0 <3.24.2"

dependencies:
flutter:
sdk: flutter
json_annotation: ^4.1.0

dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.3.3
json_serializable: ^6.6.1
analyzer: ^5.11.1

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
15 changes: 15 additions & 0 deletions Release notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## 2.10.0

- Updated to [Android SDK v2.10.0](https://github.com/blinkcard/blinkcard-android/releases/tag/v2.10.0) and [iOS SDK v2.10.0](https://github.com/BlinkCard/blinkcard-ios/releases/tag/v2.10.0)

**Improvements**

- Significant improvements in photocopy detection.
- Both the False Rejection Rate and False Acceptance Rate are reduced by ~50% as measured on the default match level.

**Bug fixes**

- Android specific:
- Removed `libc++_shared.so` from the SDK
- Fix for duplicate attrs resource: `attr/mb_onboardingImageColor` when combining multiple Microblink's SDKs in the same app

## 2.9.3

### Bug fixes
Expand Down
15 changes: 5 additions & 10 deletions initFlutterSample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ else
echo "Using blinkcard_flutter from flutter pub"
fi

#update sdk version to 2.12 to support null safety.
sed -in 's/sdk: ">=[0-9.]*/sdk: ">=2.12.0/' pubspec.yaml

flutter pub get

# enter into android project folder
Expand Down Expand Up @@ -58,13 +55,11 @@ popd

cp ../sample_files/main.dart lib/

#update compile and target sdk versions to 31, add android:exported="true" to manifest
sed -i '' 's#compileSdkVersion flutter.compileSdkVersion#compileSdkVersion 34#g' ./android/app/build.gradle
sed -i '' 's#targetSdkVersion flutter.targetSdkVersion#targetSdkVersion 34#g' ./android/app/build.gradle
sed -i '' 's#minSdkVersion flutter.minSdkVersion#minSdkVersion 21#g' ./android/app/build.gradle
#sed -i '' 's#android:name=".MainActivity"#android:name=".MainActivity" android:exported="true"#g' ./android/app/src/main/AndroidManifest.xml

echo ""
echo "Go to Flutter project folder: cd $appName"
echo "To run on Android type: flutter run"
echo "To run on iOS: go to $appName/ios and open Runner.xcworkspace; set your development team and add Privacy - Camera Usage Description & Privacy - Photo Library Usage Description keys to Runner/Info.plist file and press run"
echo "To run on iOS:
1. Open $appName/ios/Runner.xcworkspace
2. Set your development team
3. Add Privacy - Camera Usage Description & Privacy - Photo Library Usage Description keys to Runner/Info.plist file
4. Press run"
Loading

0 comments on commit 0522e1e

Please sign in to comment.