Skip to content

Commit

Permalink
5.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Nov 18, 2020
1 parent f128109 commit 471eec9
Show file tree
Hide file tree
Showing 14 changed files with 41,236 additions and 542 deletions.
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"cordova-android": "^9.0.0",
"cordova-ios": "^6.1.1",
"cordova-plugin-add-swift-support": "^2.0.2",
"@regulaforensics/cordova-plugin-document-reader-api": "^5.2.1",
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "^5.2.0",
"@regulaforensics/cordova-plugin-document-reader-api": "^5.3.0",
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "^5.3.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-image-picker": "^1.1.3",
"cordova-plugin-android-permissions": "1.1.0"
Expand All @@ -44,4 +44,4 @@
"devDependencies": {
"cordova-plugin-whitelist": "^1.3.4"
}
}
}
40,593 changes: 40,593 additions & 0 deletions example/www/certificates/icaopkd-002-ml-000131.ldif

Large diffs are not rendered by default.

199 changes: 118 additions & 81 deletions example/www/js/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@regulaforensics/cordova-plugin-document-reader-api",
"version": "5.2.1",
"version": "5.3.0",
"description": "Cordova plugin for reading and validation of identification documents (API framework)",
"cordova": {
"id": "@regulaforensics/cordova-plugin-document-reader-api",
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-document-reader-api" version="5.2.1"
<plugin id="cordova-plugin-document-reader-api" version="5.3.0"
xmlns="http://apache.org/cordova/ns/plugins/1.0">
<name>DocumentReaderApi</name>
<description>Cordova plugin Document reader api</description>
Expand All @@ -25,7 +25,7 @@
<podspec>
<config/>
<pods>
<pod name="DocumentReader" spec="~> 5.2.1331" />
<pod name="DocumentReader" spec="~> 5.3.1509" />
</pods>
</podspec>
</platform>
Expand Down
2 changes: 1 addition & 1 deletion src/android/DocumentReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private void addPKDCertificates(Callback callback, JSONArray certificatesJSON) t
List<PKDCertificate> certificates = new ArrayList<>();
for (int i = 0; i < certificatesJSON.length(); i++) {
JSONObject certificate = certificatesJSON.getJSONObject(i);
certificates.add(new PKDCertificate(JSONConstructor.byteArrayFromJson(certificate.getJSONArray("binaryData")), certificate.getInt("resourceType"), certificate.has("certificate") ? JSONConstructor.byteArrayFromJson(certificate.getJSONArray("privateKey")) : null));
certificates.add(new PKDCertificate(Base64.decode(certificate.get("binaryData").toString(), Base64.DEFAULT), certificate.getInt("resourceType"), certificate.has("privateKey") ? Base64.decode(certificate.get("privateKey").toString(), Base64.DEFAULT) : null));
}
Instance().addPKDCertificates(certificates);
callback.success();
Expand Down
44 changes: 15 additions & 29 deletions src/android/JSONConstructor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import com.regula.documentreader.api.results.DocumentReaderDocumentType;
import com.regula.documentreader.api.results.DocumentReaderGraphicField;
import com.regula.documentreader.api.results.DocumentReaderGraphicResult;
import com.regula.documentreader.api.results.DocumentReaderJsonResult;
import com.regula.documentreader.api.results.DocumentReaderJsonResultGroup;
import com.regula.documentreader.api.results.DocumentReaderNotification;
import com.regula.documentreader.api.results.DocumentReaderResults;
import com.regula.documentreader.api.results.DocumentReaderScenarioFull;
Expand Down Expand Up @@ -63,6 +61,7 @@

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -133,8 +132,8 @@ static JSONObject resultsToJsonObject(DocumentReaderResults results, Context con
jsonObject.put("graphicResult", generateDocumentReaderGraphicResult(results.graphicResult, context));
if (results.imageQuality != null)
jsonObject.put("imageQuality", generateImageQualityGroup(results.imageQuality, context));
if (results.jsonResult != null)
jsonObject.put("jsonResult", generateDocumentReaderJsonResult(results.jsonResult, context));
if (results.rawResult != null)
jsonObject.put("rawResult", results.rawResult);
if (results.mrzPosition != null)
jsonObject.put("mrzPosition", generateElementPosition(results.mrzPosition));
if (results.rfidSessionData != null)
Expand Down Expand Up @@ -257,8 +256,8 @@ static private JSONObject generateDocumentReaderGraphicField(DocumentReaderGraph
result.put("lightName", eRPRM_Lights.getTranslation(context, documentReaderGraphicField.light));
result.put("pageIndex", documentReaderGraphicField.pageIndex);
result.put("value", documentReaderGraphicField.imageBase64());
if (documentReaderGraphicField.getRect() != null)
result.put("fieldRect", generateDocReaderFieldRect(documentReaderGraphicField.getRect()));
if (documentReaderGraphicField.boundRect != null)
result.put("fieldRect", generateDocReaderFieldRect(documentReaderGraphicField.boundRect));

return result;
}
Expand Down Expand Up @@ -299,20 +298,6 @@ static private JSONObject generateImageQuality(ImageQuality imageQuality, Contex
return result;
}

static private JSONObject generateDocumentReaderJsonResult(DocumentReaderJsonResult documentReaderJsonResult, Context context) throws JSONException {
return new JSONObject().put("results", generateList(documentReaderJsonResult.results, JSONConstructor::generateDocumentReaderJsonResultGroup, context));
}

static private JSONObject generateDocumentReaderJsonResultGroup(DocumentReaderJsonResultGroup documentReaderJsonResultGroup, Context context) throws JSONException {
JSONObject result = new JSONObject();
result.put("lightType", documentReaderJsonResultGroup.lightType);
result.put("pageIdx", documentReaderJsonResultGroup.pageIdx);
result.put("resultType", documentReaderJsonResultGroup.resultType);
result.put("jsonResult", documentReaderJsonResultGroup.jsonResult);

return result;
}

static private JSONObject generateRfidSessionData(RFIDSessionData rfidSessionData, Context context) throws JSONException {
JSONObject result = new JSONObject();
result.put("totalBytesSent", rfidSessionData.totalBytesSent);
Expand Down Expand Up @@ -686,14 +671,15 @@ static JSONObject generateCompletion(int action, DocumentReaderResults results,
try {
result.put("action", action);
switch (action) {
case DocReaderAction.MORE_PAGES_AVAILABLE:
case DocReaderAction.PROCESS:
case DocReaderAction.PROCESS_WHITE_UV_IMAGES:
result.put("results", "");
break;
case DocReaderAction.NOTIFICATION:
result.put("results", resultsToJsonObjectNotification(results));
break;
case DocReaderAction.COMPLETE:
case DocReaderAction.MORE_PAGES_AVAILABLE:
case DocReaderAction.CANCEL:
case DocReaderAction.ERROR:
result.put("results", resultsToJsonObject(results, context));
Expand Down Expand Up @@ -741,17 +727,10 @@ static Bitmap bitmapFromBase64(String base64) {
Bitmap result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length, options);
int sizeMultiplier = result.getByteCount() / 5000000;
if (result.getByteCount() > 5000000)
result = Bitmap.createScaledBitmap(result, result.getWidth() / (int)Math.sqrt(sizeMultiplier), result.getHeight() / (int)Math.sqrt(sizeMultiplier), false);
result = Bitmap.createScaledBitmap(result, result.getWidth() / (int) Math.sqrt(sizeMultiplier), result.getHeight() / (int) Math.sqrt(sizeMultiplier), false);
return result;
}

static byte[] byteArrayFromJson(JSONArray array) throws JSONException {
byte[] bytes = new byte[array.length()];
for (int i = 0; i < array.length(); i++)
bytes[i] = (byte) array.getInt(i);
return bytes;
}

static Drawable drawableFromBase64(String base64, Context context) {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(Base64.decode(base64.getBytes(), Base64.DEFAULT));
return Drawable.createFromResourceStream(context.getResources(), null, byteArrayInputStream, null);
Expand Down Expand Up @@ -835,4 +814,11 @@ static Bounds boundsFromJson(JSONObject object) throws JSONException {

return result;
}

static List<String> stringListFromJson(JSONArray jsonArray) {
List<String> result = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++)
result.add(jsonArray.optString(i));
return result;
}
}
75 changes: 47 additions & 28 deletions src/android/RegulaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@

import java.math.BigDecimal;

import static cordova.plugin.documentreader.JSONConstructor.drawableFromBase64;
import static cordova.plugin.documentreader.JSONConstructor.bitmapFromDrawable;
import static cordova.plugin.documentreader.JSONConstructor.barcodeTypeArrayFromJson;
import static cordova.plugin.documentreader.JSONConstructor.faceMetaDataArrayFromJson;
import static cordova.plugin.documentreader.JSONConstructor.floatArrayFromJson;
import static cordova.plugin.documentreader.JSONConstructor.intArrayFromJson;
import static cordova.plugin.documentreader.JSONConstructor.generateIntArray;
import static cordova.plugin.documentreader.JSONConstructor.matrixFromFloatArray;
import static cordova.plugin.documentreader.JSONConstructor.*;

class RegulaConfig {
static void setConfig(DocumentReader reader, JSONObject opts, Context context) throws JSONException {
Expand Down Expand Up @@ -90,8 +83,17 @@ private static void setFunctionality(Functionality functionality, JSONObject opt
editor.setCaptureMode(opts.getInt("captureMode"));
if (opts.has("displayMetadata"))
editor.setDisplayMetadata(opts.getBoolean("displayMetadata"));
// if (opts.has("cameraSize"))
// editor.setCameraSize();
if (opts.has("cameraSize"))
editor.setCameraSize(opts.getJSONObject("cameraSize").getInt("width"), opts.getJSONObject("cameraSize").getInt("height"));
if (opts.has("cameraMode"))
editor.setCameraMode(opts.getInt("cameraMode"));
if (opts.has("excludedCamera2Models"))
editor.setExcludedCamera2Models(stringListFromJson(opts.getJSONArray("excludedCamera2Models")));
if (opts.has("isZoomEnabled"))
editor.setZoomEnabled(opts.getBoolean("isZoomEnabled"));
if (opts.has("zoomFactor"))
editor.setZoomFactor(BigDecimal.valueOf(opts.getDouble("zoomFactor")).floatValue());

editor.apply();
}

Expand Down Expand Up @@ -150,6 +152,10 @@ private static void setProcessParams(ProcessParam processParams, JSONObject opts
processParams.integralImage = opts.getBoolean("integralImage");
if (opts.has("minDPI"))
processParams.minDPI = opts.getInt("minDPI");
if (opts.has("returnCroppedBarcode"))
processParams.returnCroppedBarcode = opts.getBoolean("returnCroppedBarcode");
if (opts.has("checkHologram"))
processParams.checkHologram = opts.getBoolean("checkHologram");
}

private static void setCustomization(ParamsCustomization customization, JSONObject opts, Context context) throws JSONException {
Expand Down Expand Up @@ -262,6 +268,9 @@ private static void setCustomization(ParamsCustomization customization, JSONObje
editor.setChangeFrameExpandButtonImage(drawableFromBase64(opts.getString("changeFrameButtonExpandImage"), context));
if (opts.has("changeFrameButtonCollapseImage"))
editor.setChangeFrameCollapseButtonImage(drawableFromBase64(opts.getString("changeFrameButtonCollapseImage"), context));
if (opts.has("toolbarSize"))
editor.setToolbarSize(BigDecimal.valueOf(opts.getDouble("toolbarSize")).floatValue());

editor.apply();
}

Expand Down Expand Up @@ -289,7 +298,14 @@ private static JSONObject getFunctionality(Functionality functionality) throws J
object.put("startDocReaderForResult", functionality.getStartDocReaderForResult());
object.put("captureMode", functionality.getCaptureMode());
object.put("displayMetadata", functionality.isDisplayMetaData());
// object.put("cameraSize", functionality.getCameraSize());
object.put("cameraSize", new JSONObject() {{
put("width", functionality.getCameraWidth());
put("height", functionality.getCameraHeight());
}});
object.put("cameraMode", functionality.getCameraMode());
object.put("excludedCamera2Models", generateList(functionality.getExcludedCamera2Models()));
object.put("isZoomEnabled", functionality.isZoomEnabled());
object.put("zoomFactor", functionality.getZoomFactor());

return object;
}
Expand All @@ -316,9 +332,9 @@ private static JSONObject getCustomization(ParamsCustomization customization) th
object.put("cameraFrameLineLength", customization.getCameraFrameLineLength());
object.put("cameraFrameShapeType", customization.getCameraFrameShapeType());
object.put("resultStatusTextSize", customization.getResultStatusTextSize());
object.put("multipageAnimationFrontImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getMultipageAnimationFrontImage())));
object.put("multipageAnimationBackImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getMultipageAnimationBackImage())));
object.put("borderBackgroundImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getBorderBackgroundImage())));
object.put("multipageAnimationFrontImage", bitmapToBase64String(bitmapFromDrawable(customization.getMultipageAnimationFrontImage())));
object.put("multipageAnimationBackImage", bitmapToBase64String(bitmapFromDrawable(customization.getMultipageAnimationBackImage())));
object.put("borderBackgroundImage", bitmapToBase64String(bitmapFromDrawable(customization.getBorderBackgroundImage())));
object.put("helpAnimationImageScaleType", customization.getHelpAnimationImageScaleType());
object.put("multipageAnimationFrontImageScaleType", customization.getMultipageAnimationFrontImageScaleType());
object.put("multipageAnimationBackImageScaleType", customization.getMultipageAnimationBackImageScaleType());
Expand All @@ -330,7 +346,7 @@ private static JSONObject getCustomization(ParamsCustomization customization) th
object.put("statusPositionMultiplier", customization.getStatusPositionMultiplier());
object.put("resultStatusPositionMultiplier", customization.getResultStatusPositionMultiplier());
object.put("backgroundMaskAlpha", customization.getBackgroundMaskAlpha());
object.put("helpAnimationImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getHelpAnimationImageDrawable())));
object.put("helpAnimationImage", bitmapToBase64String(bitmapFromDrawable(customization.getHelpAnimationImageDrawable())));
object.put("cameraFrameOffsetWidth", customization.getCameraFrameOffsetWidth());
object.put("customLabelStatus", customization.getCustomLabelStatus().toString());
object.put("customStatusPositionMultiplier", customization.getCustomStatusPositionMultiplier());
Expand All @@ -339,17 +355,18 @@ private static JSONObject getCustomization(ParamsCustomization customization) th
object.put("cameraFramePortraitAspectRatio", customization.getCameraFramePortraitAspectRatio());
object.put("cameraFrameCornerRadius", customization.getCameraFrameCornerRadius());
object.put("cameraFrameLineCap", customization.getCameraFrameLineCap().toString());
object.put("torchImageOnImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOnDrawable())));
object.put("torchImageOffImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOffDrawable())));
object.put("closeButtonImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getCloseButtonDrawable())));
object.put("captureButtonImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getCaptureButtonDrawable())));
object.put("changeFrameCollapseButtonImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameCollapseButtonDrawable())));
object.put("changeFrameExpandButtonImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameExpandButtonDrawable())));
object.put("cameraSwitchButtonImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getCameraSwitchButtonDrawable())));
object.put("torchButtonOnImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOnDrawable())));
object.put("torchButtonOffImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOffDrawable())));
object.put("changeFrameButtonExpandImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameExpandButtonDrawable())));
object.put("changeFrameButtonCollapseImage", JSONConstructor.bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameCollapseButtonDrawable())));
object.put("torchImageOnImage", bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOnDrawable())));
object.put("torchImageOffImage", bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOffDrawable())));
object.put("closeButtonImage", bitmapToBase64String(bitmapFromDrawable(customization.getCloseButtonDrawable())));
object.put("captureButtonImage", bitmapToBase64String(bitmapFromDrawable(customization.getCaptureButtonDrawable())));
object.put("changeFrameCollapseButtonImage", bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameCollapseButtonDrawable())));
object.put("changeFrameExpandButtonImage", bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameExpandButtonDrawable())));
object.put("cameraSwitchButtonImage", bitmapToBase64String(bitmapFromDrawable(customization.getCameraSwitchButtonDrawable())));
object.put("torchButtonOnImage", bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOnDrawable())));
object.put("torchButtonOffImage", bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOffDrawable())));
object.put("changeFrameButtonExpandImage", bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameExpandButtonDrawable())));
object.put("changeFrameButtonCollapseImage", bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameCollapseButtonDrawable())));
object.put("toolbarSize", customization.getToolbarSize());

return object;
}
Expand Down Expand Up @@ -380,14 +397,16 @@ private static JSONObject getProcessParams(ProcessParam processParams, Context c
object.put("integralImage", processParams.integralImage);
object.put("minDPI", processParams.minDPI);
object.put("logs", processParams.isLogEnable());
object.put("returnCroppedBarcode", processParams.returnCroppedBarcode);
object.put("checkHologram", processParams.checkHologram);
if (processParams.documentIDList != null)
object.put("documentIDList", generateIntArray(processParams.documentIDList));
if (processParams.doBarcodes != null)
object.put("barcodeTypes", JSONConstructor.generateArray(processParams.doBarcodes));
object.put("barcodeTypes", generateArray(processParams.doBarcodes));
if (processParams.fieldTypesFilter != null)
object.put("fieldTypesFilter", generateIntArray(processParams.fieldTypesFilter));
if (processParams.faceMetaData != null)
object.put("faceMetaData", JSONConstructor.generateArray(processParams.faceMetaData, JSONConstructor::generateFaceMetaData, context));
object.put("faceMetaData", generateArray(processParams.faceMetaData, JSONConstructor::generateFaceMetaData, context));

return object;
}
Expand Down
Loading

0 comments on commit 471eec9

Please sign in to comment.