Skip to content

Commit

Permalink
Merge pull request #37 from BlinkID/release/v6.9.0
Browse files Browse the repository at this point in the history
Release/v6.9.0
  • Loading branch information
mparadina authored Jul 19, 2024
2 parents 8717457 + 37f3cee commit 69d6f93
Show file tree
Hide file tree
Showing 32 changed files with 1,260 additions and 523 deletions.
2 changes: 1 addition & 1 deletion BlinkID/MicroblinkBlinkidCapacitor.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '13.0'
s.dependency 'Capacitor'
s.swift_version = '5.5'
s.dependency 'PPBlinkID', '~> 6.7.1'
s.dependency 'PPBlinkID', '~> 6.9.0'
end
8 changes: 4 additions & 4 deletions BlinkID/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'com.android.tools.build:gradle:8.2.1'
}
}

apply plugin: 'com.android.library'

android {
namespace "com.microblink.blinkid.capacitor.blinkidcapacitor"
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
versionCode 1
versionName "1.0"
}
Expand Down Expand Up @@ -45,7 +45,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':capacitor-android')

implementation('com.microblink:blinkid:6.7.0@aar') {
implementation('com.microblink:blinkid:6.9.0@aar') {
transitive = true
}
}
Expand Down
Binary file modified BlinkID/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion BlinkID/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions BlinkID/android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.microblink.blinkid.metadata.recognition.FirstSideRecognitionCallback;
import com.microblink.blinkid.recognition.RecognitionSuccessType;
import com.microblink.blinkid.metadata.MetadataCallbacks;
import com.microblink.blinkid.licence.exception.LicenceKeyException;
import com.getcapacitor.annotation.ActivityCallback;
import com.getcapacitor.annotation.CapacitorPlugin;
import com.getcapacitor.JSObject;
Expand Down Expand Up @@ -53,14 +54,13 @@ public void scanWithCamera(PluginCall call) {
JSObject jsRecognizerCollection = call.getObject("recognizerCollection");
JSObject jsLicenses = call.getObject("license");

setLicense(jsLicenses);
setLanguage(jsOverlaySettings);
if(setLicense(jsLicenses, call)) {
setLanguage(jsOverlaySettings);
recognizerBundle = RecognizerSerializers.INSTANCE.deserializeRecognizerCollection(jsRecognizerCollection);
UISettings uiSettings = OverlaySettingsSerializers.INSTANCE.getOverlaySettings(getContext(), jsOverlaySettings, recognizerBundle);

recognizerBundle = RecognizerSerializers.INSTANCE.deserializeRecognizerCollection(jsRecognizerCollection);
UISettings uiSettings = OverlaySettingsSerializers.INSTANCE.getOverlaySettings(getContext(), jsOverlaySettings, recognizerBundle);


startActivityForResult(call, "handleScanResult", uiSettings);
startActivityForResult(call, "handleScanResult", uiSettings);
}
}

@PluginMethod
Expand All @@ -70,61 +70,63 @@ public void scanWithDirectApi(PluginCall call) {
JSObject jsLicenses = call.getObject("license");
String jsFrontImage = call.getString("frontImage");
String jsBackImage = call.getString("backImage");
setLicense(jsLicenses);
ScanResultListener mScanResultListenerBackSide = new ScanResultListener() {
@Override
public void onScanningDone(@NonNull RecognitionSuccessType recognitionSuccessType) {
mFirstSideScanned = false;
handleDirectApiResult(recognitionSuccessType, call);
}
@Override
public void onUnrecoverableError(@NonNull Throwable throwable) {
call.reject(throwable.getMessage());
}
};

FirstSideRecognitionCallback mFirstSideRecognitionCallback = new FirstSideRecognitionCallback() {
@Override
public void onFirstSideRecognitionFinished() {
mFirstSideScanned = true;
}
};
if (setLicense(jsLicenses, call)) {
ScanResultListener mScanResultListenerBackSide = new ScanResultListener() {
@Override
public void onScanningDone(@NonNull RecognitionSuccessType recognitionSuccessType) {
mFirstSideScanned = false;
handleDirectApiResult(recognitionSuccessType, call);
}
@Override
public void onUnrecoverableError(@NonNull Throwable throwable) {
call.reject(throwable.getMessage());
}
};

ScanResultListener mScanResultListenerFrontSide = new ScanResultListener() {
@Override
public void onScanningDone(@NonNull RecognitionSuccessType recognitionSuccessType) {
if (mFirstSideScanned) {
//multiside recognizer used
try {
if (!jsBackImage.isEmpty()) {
processImage(jsBackImage, mScanResultListenerBackSide, call);
} else if (recognitionSuccessType != RecognitionSuccessType.UNSUCCESSFUL){
handleDirectApiResult(recognitionSuccessType, call);
} else {
handleDirectApiError("Could not extract the information from the front side and back side is empty!", call);
FirstSideRecognitionCallback mFirstSideRecognitionCallback = new FirstSideRecognitionCallback() {
@Override
public void onFirstSideRecognitionFinished() {
mFirstSideScanned = true;
}
};

ScanResultListener mScanResultListenerFrontSide = new ScanResultListener() {
@Override
public void onScanningDone(@NonNull RecognitionSuccessType recognitionSuccessType) {
if (mFirstSideScanned) {
//multiside recognizer used
try {
if (!jsBackImage.isEmpty()) {
processImage(jsBackImage, mScanResultListenerBackSide, call);
} else if (recognitionSuccessType != RecognitionSuccessType.UNSUCCESSFUL){
handleDirectApiResult(recognitionSuccessType, call);
} else {
handleDirectApiError("Could not extract the information from the front side and back side is empty!", call);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} catch (Exception e) {
throw new RuntimeException(e);
} else if (!mFirstSideScanned && recognitionSuccessType != RecognitionSuccessType.UNSUCCESSFUL){
//singleside recognizer used
handleDirectApiResult(recognitionSuccessType, call);
} else {
mFirstSideScanned = false;
handleDirectApiError("Could not extract the information with DirectAPI!", call);
}
} else if (!mFirstSideScanned && recognitionSuccessType != RecognitionSuccessType.UNSUCCESSFUL){
//singleside recognizer used
handleDirectApiResult(recognitionSuccessType, call);
} else {
mFirstSideScanned = false;
handleDirectApiError("Could not extract the information with DirectAPI!", call);
}
}
@Override
public void onUnrecoverableError(@NonNull Throwable throwable) {
handleDirectApiError(throwable.getMessage(), call);
}
};
@Override
public void onUnrecoverableError(@NonNull Throwable throwable) {
handleDirectApiError(throwable.getMessage(), call);
}
};

setupRecognizerRunner(jsRecognizerCollection, mFirstSideRecognitionCallback, call);
if (!jsFrontImage.isEmpty()) {
processImage(jsFrontImage, mScanResultListenerFrontSide, call);
} else {
handleDirectApiError("The provided image for the 'frontImage' parameter is empty!", call);
setupRecognizerRunner(jsRecognizerCollection, mFirstSideRecognitionCallback, call);
if (!jsFrontImage.isEmpty()) {
processImage(jsFrontImage, mScanResultListenerFrontSide, call);
} else {
handleDirectApiError("The provided image for the 'frontImage' parameter is empty!", call);
}
}
}
private void setupRecognizerRunner(JSONObject jsonRecognizerCollection, FirstSideRecognitionCallback mFirstSideRecognitionCallback, PluginCall call) {
Expand Down Expand Up @@ -215,19 +217,30 @@ private void handleScanResult(PluginCall call, ActivityResult activityResult) {
}
}

private void setLicense(JSObject jsonLicense) {
private boolean setLicense(JSObject jsonLicense, PluginCall call) {
MicroblinkSDK.setShowTrialLicenseWarning(
jsonLicense.optBoolean("showTrialLicenseKeyWarning", true)
);
String androidLicense = jsonLicense.getString("android");
String licensee = jsonLicense.optString("licensee", null);
Context context = getContext();
if (licensee == null) {
MicroblinkSDK.setLicenseKey(androidLicense, context);
try {
MicroblinkSDK.setLicenseKey(androidLicense, context);
} catch (LicenceKeyException licenceKeyException) {
call.reject("Android license key error: " + licenceKeyException.toString());
return false;
}
} else {
MicroblinkSDK.setLicenseKey(androidLicense, licensee, context);
try {
MicroblinkSDK.setLicenseKey(androidLicense, licensee, context);
} catch (LicenceKeyException licenceKeyException) {
call.reject("Android license key error: " + licenceKeyException.toString());
return false;
}
}
MicroblinkSDK.setIntentDataTransferMode(IntentDataTransferMode.PERSISTED_OPTIMISED);
return true;
}

private void setLanguage(JSONObject jsonOverlaySettings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import com.microblink.blinkid.capacitor.SerializationUtils;
import com.microblink.blinkid.capacitor.overlays.OverlaySerializationUtils;
import com.microblink.blinkid.locale.LanguageUtils;

import com.microblink.blinkid.hardware.camera.VideoResolutionPreset;
import com.microblink.blinkid.uisettings.CameraSettings;

import org.json.JSONObject;

Expand Down Expand Up @@ -53,6 +54,15 @@ public UISettings createUISettings(Context context, JSONObject jsonUISettings, R
long backSideScanningTimeoutMilliseconds = jsonUISettings.optLong("backSideScanningTimeoutMilliseconds", 17000);
settings.setBackSideScanningTimeoutMs(backSideScanningTimeoutMilliseconds);

int videoResolutionPreset = jsonUISettings.optInt("androidCameraResolutionPreset", VideoResolutionPreset.VIDEO_RESOLUTION_DEFAULT.ordinal());

boolean androidLegacyCameraApi = jsonUISettings.optBoolean("setAndroidLegacyCameraApi", false);

settings.setCameraSettings(new CameraSettings.Builder()
.setVideoResolutionPreset(VideoResolutionPreset.values()[videoResolutionPreset])
.setForceLegacyApi(androidLegacyCameraApi)
.build());

ReticleOverlayStrings.Builder overlasStringsBuilder = new ReticleOverlayStrings.Builder(context);

String firstSideInstructionsText = getStringFromJSONObject(jsonUISettings, "firstSideInstructionsText");
Expand Down Expand Up @@ -107,7 +117,14 @@ public UISettings createUISettings(Context context, JSONObject jsonUISettings, R
if (errorDocumentTooCloseToEdge != null) {
overlasStringsBuilder.setErrorDocumentTooCloseToEdge(errorDocumentTooCloseToEdge);
}

String errorBlurDetected = getStringFromJSONObject(jsonUISettings, "errorBlurDetected");
if (errorBlurDetected != null) {
overlasStringsBuilder.setErrorBlurDetected(errorBlurDetected);
}
String errorGlareDetected = getStringFromJSONObject(jsonUISettings, "errorGlareDetected");
if (errorGlareDetected != null) {
overlasStringsBuilder.setErrorGlareDetected(errorGlareDetected);
}
String language = getStringFromJSONObject(jsonUISettings, "language");
if (language != null) {
String country = getStringFromJSONObject(jsonUISettings, "country");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import com.microblink.blinkid.entities.recognizers.blinkid.generic.Side;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.imageanalysis.CardRotation;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.DocumentNumberAnonymizationSettings;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.CustomClassRules;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.DetailedFieldType;


import org.json.JSONArray;
import org.json.JSONException;
Expand Down Expand Up @@ -126,7 +129,6 @@ public static JSONObject serializeClassInfo(ClassInfo classInfo) throws JSONExce

public static JSONObject serializeImageAnalysisResult(ImageAnalysisResult imageAnalysisResult) throws JSONException {
JSONObject jsonImageAnalysis = new JSONObject();
jsonImageAnalysis.put("blurred", imageAnalysisResult.isBlurred());
jsonImageAnalysis.put("documentImageColorStatus", SerializationUtils.serializeEnum(imageAnalysisResult.getDocumentImageColorStatus()));
jsonImageAnalysis.put("documentImageMoireStatus", SerializationUtils.serializeEnum(imageAnalysisResult.getDocumentImageMoireStatus()));
jsonImageAnalysis.put("faceDetectionStatus", SerializationUtils.serializeEnum(imageAnalysisResult.getFaceDetectionStatus()));
Expand All @@ -135,6 +137,8 @@ public static JSONObject serializeImageAnalysisResult(ImageAnalysisResult imageA
jsonImageAnalysis.put("cardRotation", BlinkIDSerializationUtils.serializeCardRotation(imageAnalysisResult.getCardRotation()));
jsonImageAnalysis.put("cardOrientation", SerializationUtils.serializeEnum(imageAnalysisResult.getCardOrientation()));
jsonImageAnalysis.put("realIdDetectionStatus", SerializationUtils.serializeEnum(imageAnalysisResult.getRealIdDetectionStatus()));
jsonImageAnalysis.put("blurDetected", imageAnalysisResult.isBlurDetected());
jsonImageAnalysis.put("glareDetected", imageAnalysisResult.isGlareDetected());
return jsonImageAnalysis;
}

Expand Down Expand Up @@ -382,4 +386,54 @@ private static DocumentNumberAnonymizationSettings deserializeDocumentNumberAnon
return null;
}
}

public static CustomClassRules[] deserializeCustomClassRules(JSONArray jsonArray) {
if (jsonArray != null && jsonArray.length() > 0) {
CustomClassRules[] customClassRulesArray = new CustomClassRules[jsonArray.length()];

for (int i = 0; i < jsonArray.length(); i++) {

DetailedFieldType[] detailedFieldTypes = new DetailedFieldType[0];
Country country = Country.NONE;
Region region = Region.NONE;
Type type = Type.NONE;

try {
JSONObject jsonCustomClassRulesArray = jsonArray.getJSONObject(i);

JSONArray detailedFieldTypeJsonArray = jsonCustomClassRulesArray.optJSONArray("detailedFieldTypes");
detailedFieldTypes = new DetailedFieldType[detailedFieldTypeJsonArray.length()];
for (int x = 0; x < detailedFieldTypeJsonArray.length(); x++) {
FieldType fieldType = FieldType.values()[detailedFieldTypeJsonArray.getJSONObject(x).getInt("fieldType")];
AlphabetType alphabetType = AlphabetType.values()[detailedFieldTypeJsonArray.getJSONObject(x).getInt("alphabetType")];
detailedFieldTypes[x] = new DetailedFieldType(fieldType, alphabetType);
}

try {
country = Country.values()[jsonCustomClassRulesArray.getInt("country")];
} catch (JSONException e) {
country = null;
}
try {
region = Region.values()[jsonCustomClassRulesArray.getInt("region")];
} catch (JSONException e) {
region = null;
}
try {
type = Type.values()[jsonCustomClassRulesArray.getInt("type")];
} catch (JSONException e) {
type = null;
}

CustomClassRules customClassRules = new CustomClassRules(country, region, type, detailedFieldTypes);
customClassRulesArray[i] = customClassRules;
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
return customClassRulesArray;
} else {
return new CustomClassRules[]{};
}
}
}
Loading

0 comments on commit 69d6f93

Please sign in to comment.