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 cfd0bc0 commit 882c330
Show file tree
Hide file tree
Showing 18 changed files with 41,584 additions and 1,172 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You can use native camera to scan the documents or image from gallery for extrac

This repository contains the source code of the Document Reader API, and the sample application that demonstrates the _**API**_ calls you can use to interact with the Document Reader library.

# Content
# Contents
* [How to build demo application](#how-to-build-demo-application)
* [Troubleshooting license issues](#troubleshooting-license-issues)
* [Documentation](#documentation)
Expand Down Expand Up @@ -34,8 +34,8 @@ $ pod install

### Troubleshooting license issues
If you have issues with license verification when running the application, please verify that next is true:
1. The OS, which you use, is specified in the license (e.g., Android and/or iOS).
2. The application (Bundle) ID, which you use, is specified in the license.
1. The OS, which you use, is specified in the license (e.g., Android and/or iOS).
2. The application (Bundle) ID, which you use, is specified in the license.
3. The license is valid (not expired).
4. The date and time on the device, where you run the application, are valid.
5. You use the latest release version of the Document Reader SDK.
Expand Down
2 changes: 1 addition & 1 deletion RNDocumentReaderApi.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Pod::Spec.new do |s|
s.source = { :http => 'file:' + __dir__ }
s.ios.deployment_target = '9.0.0'
s.source_files = "ios/*.{h,m}"
s.dependency 'DocumentReader', '5.2.1331'
s.dependency 'DocumentReader', '5.3.1509'
s.dependency 'React'
end
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+'
//noinspection GradleDependency
implementation('com.regula.documentreader:api:5.2.2995') {
implementation('com.regula.documentreader:api:5.3.3597') {
transitive = true
}
}
Expand Down
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 @@ -681,25 +666,28 @@ static JSONArray generateByteArray(byte[] array) throws JSONException {
return result;
}

static JSONObject generateCompletion(int action, DocumentReaderResults results, Throwable error, Context context) throws JSONException {
static JSONObject generateCompletion(int action, DocumentReaderResults results, Throwable error, Context context) {
JSONObject result = new JSONObject();
result.put("action", action);
switch (action) {
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));
break;
try {
result.put("action", action);
switch (action) {
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));
break;
}
result.put("error", generateThrowable(error, context));
} catch (JSONException ignored) {
}
result.put("error", generateThrowable(error, context));

return result;
}
Expand All @@ -710,7 +698,7 @@ static JSONObject generateThrowable(Throwable throwable, Context context) throws
return result;
result.put("localizedMessage", throwable.getLocalizedMessage());
result.put("message", throwable.getMessage());
result.put("toString", throwable.toString());
result.put("string", throwable.toString());
result.put("stackTrace", generateArray(throwable.getStackTrace(), JSONConstructor::generateStackTraceElement, context));

return result;
Expand All @@ -725,7 +713,7 @@ static JSONObject generateStackTraceElement(StackTraceElement e, Context context
result.put("lineNumber", e.getLineNumber());
result.put("methodName", e.getMethodName());
result.put("isNativeMethod", e.isNativeMethod());
result.put("toString", e.toString());
result.put("string", e.toString());

return result;
}
Expand All @@ -734,14 +722,13 @@ static JSONObject generateStackTraceElement(StackTraceElement e, Context context

static Bitmap bitmapFromBase64(String base64) {
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
return BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
}

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;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
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);
return result;
}

static Drawable drawableFromBase64(String base64, Context context) {
Expand Down Expand Up @@ -827,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;
}
}
Loading

0 comments on commit 882c330

Please sign in to comment.