Skip to content

Commit 882c330

Browse files
author
Jenkins
committed
5.3.0
1 parent cfd0bc0 commit 882c330

18 files changed

Lines changed: 41584 additions & 1172 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ You can use native camera to scan the documents or image from gallery for extrac
55

66
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.
77

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

3535
### Troubleshooting license issues
3636
If you have issues with license verification when running the application, please verify that next is true:
37-
1. The OS, which you use, is specified in the license (e.g., Android and/or iOS).
38-
2. The application (Bundle) ID, which you use, is specified in the license.
37+
1. The OS, which you use, is specified in the license (e.g., Android and/or iOS).
38+
2. The application (Bundle) ID, which you use, is specified in the license.
3939
3. The license is valid (not expired).
4040
4. The date and time on the device, where you run the application, are valid.
4141
5. You use the latest release version of the Document Reader SDK.

RNDocumentReaderApi.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Pod::Spec.new do |s|
1414
s.source = { :http => 'file:' + __dir__ }
1515
s.ios.deployment_target = '9.0.0'
1616
s.source_files = "ios/*.{h,m}"
17-
s.dependency 'DocumentReader', '5.2.1331'
17+
s.dependency 'DocumentReader', '5.3.1509'
1818
s.dependency 'React'
1919
end

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies {
3939
//noinspection GradleDynamicVersion
4040
implementation 'com.facebook.react:react-native:+'
4141
//noinspection GradleDependency
42-
implementation('com.regula.documentreader:api:5.2.2995') {
42+
implementation('com.regula.documentreader:api:5.3.3597') {
4343
transitive = true
4444
}
4545
}

android/src/main/java/com/regula/documentreader/JSONConstructor.java

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import com.regula.documentreader.api.results.DocumentReaderDocumentType;
2020
import com.regula.documentreader.api.results.DocumentReaderGraphicField;
2121
import com.regula.documentreader.api.results.DocumentReaderGraphicResult;
22-
import com.regula.documentreader.api.results.DocumentReaderJsonResult;
23-
import com.regula.documentreader.api.results.DocumentReaderJsonResultGroup;
2422
import com.regula.documentreader.api.results.DocumentReaderNotification;
2523
import com.regula.documentreader.api.results.DocumentReaderResults;
2624
import com.regula.documentreader.api.results.DocumentReaderScenarioFull;
@@ -63,6 +61,7 @@
6361

6462
import java.io.ByteArrayInputStream;
6563
import java.io.ByteArrayOutputStream;
64+
import java.util.ArrayList;
6665
import java.util.List;
6766
import java.util.Map;
6867
import java.util.Objects;
@@ -133,8 +132,8 @@ static JSONObject resultsToJsonObject(DocumentReaderResults results, Context con
133132
jsonObject.put("graphicResult", generateDocumentReaderGraphicResult(results.graphicResult, context));
134133
if (results.imageQuality != null)
135134
jsonObject.put("imageQuality", generateImageQualityGroup(results.imageQuality, context));
136-
if (results.jsonResult != null)
137-
jsonObject.put("jsonResult", generateDocumentReaderJsonResult(results.jsonResult, context));
135+
if (results.rawResult != null)
136+
jsonObject.put("rawResult", results.rawResult);
138137
if (results.mrzPosition != null)
139138
jsonObject.put("mrzPosition", generateElementPosition(results.mrzPosition));
140139
if (results.rfidSessionData != null)
@@ -257,8 +256,8 @@ static private JSONObject generateDocumentReaderGraphicField(DocumentReaderGraph
257256
result.put("lightName", eRPRM_Lights.getTranslation(context, documentReaderGraphicField.light));
258257
result.put("pageIndex", documentReaderGraphicField.pageIndex);
259258
result.put("value", documentReaderGraphicField.imageBase64());
260-
if (documentReaderGraphicField.getRect() != null)
261-
result.put("fieldRect", generateDocReaderFieldRect(documentReaderGraphicField.getRect()));
259+
if (documentReaderGraphicField.boundRect != null)
260+
result.put("fieldRect", generateDocReaderFieldRect(documentReaderGraphicField.boundRect));
262261

263262
return result;
264263
}
@@ -299,20 +298,6 @@ static private JSONObject generateImageQuality(ImageQuality imageQuality, Contex
299298
return result;
300299
}
301300

302-
static private JSONObject generateDocumentReaderJsonResult(DocumentReaderJsonResult documentReaderJsonResult, Context context) throws JSONException {
303-
return new JSONObject().put("results", generateList(documentReaderJsonResult.results, JSONConstructor::generateDocumentReaderJsonResultGroup, context));
304-
}
305-
306-
static private JSONObject generateDocumentReaderJsonResultGroup(DocumentReaderJsonResultGroup documentReaderJsonResultGroup, Context context) throws JSONException {
307-
JSONObject result = new JSONObject();
308-
result.put("lightType", documentReaderJsonResultGroup.lightType);
309-
result.put("pageIdx", documentReaderJsonResultGroup.pageIdx);
310-
result.put("resultType", documentReaderJsonResultGroup.resultType);
311-
result.put("jsonResult", documentReaderJsonResultGroup.jsonResult);
312-
313-
return result;
314-
}
315-
316301
static private JSONObject generateRfidSessionData(RFIDSessionData rfidSessionData, Context context) throws JSONException {
317302
JSONObject result = new JSONObject();
318303
result.put("totalBytesSent", rfidSessionData.totalBytesSent);
@@ -681,25 +666,28 @@ static JSONArray generateByteArray(byte[] array) throws JSONException {
681666
return result;
682667
}
683668

684-
static JSONObject generateCompletion(int action, DocumentReaderResults results, Throwable error, Context context) throws JSONException {
669+
static JSONObject generateCompletion(int action, DocumentReaderResults results, Throwable error, Context context) {
685670
JSONObject result = new JSONObject();
686-
result.put("action", action);
687-
switch (action) {
688-
case DocReaderAction.PROCESS:
689-
case DocReaderAction.PROCESS_WHITE_UV_IMAGES:
690-
result.put("results", "");
691-
break;
692-
case DocReaderAction.NOTIFICATION:
693-
result.put("results", resultsToJsonObjectNotification(results));
694-
break;
695-
case DocReaderAction.COMPLETE:
696-
case DocReaderAction.MORE_PAGES_AVAILABLE:
697-
case DocReaderAction.CANCEL:
698-
case DocReaderAction.ERROR:
699-
result.put("results", resultsToJsonObject(results, context));
700-
break;
671+
try {
672+
result.put("action", action);
673+
switch (action) {
674+
case DocReaderAction.PROCESS:
675+
case DocReaderAction.PROCESS_WHITE_UV_IMAGES:
676+
result.put("results", "");
677+
break;
678+
case DocReaderAction.NOTIFICATION:
679+
result.put("results", resultsToJsonObjectNotification(results));
680+
break;
681+
case DocReaderAction.COMPLETE:
682+
case DocReaderAction.MORE_PAGES_AVAILABLE:
683+
case DocReaderAction.CANCEL:
684+
case DocReaderAction.ERROR:
685+
result.put("results", resultsToJsonObject(results, context));
686+
break;
687+
}
688+
result.put("error", generateThrowable(error, context));
689+
} catch (JSONException ignored) {
701690
}
702-
result.put("error", generateThrowable(error, context));
703691

704692
return result;
705693
}
@@ -710,7 +698,7 @@ static JSONObject generateThrowable(Throwable throwable, Context context) throws
710698
return result;
711699
result.put("localizedMessage", throwable.getLocalizedMessage());
712700
result.put("message", throwable.getMessage());
713-
result.put("toString", throwable.toString());
701+
result.put("string", throwable.toString());
714702
result.put("stackTrace", generateArray(throwable.getStackTrace(), JSONConstructor::generateStackTraceElement, context));
715703

716704
return result;
@@ -725,7 +713,7 @@ static JSONObject generateStackTraceElement(StackTraceElement e, Context context
725713
result.put("lineNumber", e.getLineNumber());
726714
result.put("methodName", e.getMethodName());
727715
result.put("isNativeMethod", e.isNativeMethod());
728-
result.put("toString", e.toString());
716+
result.put("string", e.toString());
729717

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

735723
static Bitmap bitmapFromBase64(String base64) {
736724
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
737-
return BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
738-
}
739-
740-
static byte[] byteArrayFromJson(JSONArray array) throws JSONException {
741-
byte[] bytes = new byte[array.length()];
742-
for (int i = 0; i < array.length(); i++)
743-
bytes[i] = (byte) array.getInt(i);
744-
return bytes;
725+
BitmapFactory.Options options = new BitmapFactory.Options();
726+
options.inPreferredConfig = Bitmap.Config.RGB_565;
727+
Bitmap result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length, options);
728+
int sizeMultiplier = result.getByteCount() / 5000000;
729+
if (result.getByteCount() > 5000000)
730+
result = Bitmap.createScaledBitmap(result, result.getWidth() / (int) Math.sqrt(sizeMultiplier), result.getHeight() / (int) Math.sqrt(sizeMultiplier), false);
731+
return result;
745732
}
746733

747734
static Drawable drawableFromBase64(String base64, Context context) {
@@ -827,4 +814,11 @@ static Bounds boundsFromJson(JSONObject object) throws JSONException {
827814

828815
return result;
829816
}
817+
818+
static List<String> stringListFromJson(JSONArray jsonArray) {
819+
List<String> result = new ArrayList<>();
820+
for (int i = 0; i < jsonArray.length(); i++)
821+
result.add(jsonArray.optString(i));
822+
return result;
823+
}
830824
}

0 commit comments

Comments
 (0)