Skip to content

Commit 59b41f0

Browse files
author
Jenkins
committed
6.9.0
1 parent 8467c48 commit 59b41f0

76 files changed

Lines changed: 15887 additions & 8365 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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 = '11.0'
1616
s.source_files = "ios/*.{h,m}"
17-
s.dependency 'DocumentReader', '6.8.2981'
17+
s.dependency 'DocumentReader', '6.9.3102'
1818
s.dependency 'React'
1919
end

android/build.gradle

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
buildscript {
2+
ext {
3+
kotlinVersion = '1.8.22'
4+
gradleVersion = '8.0.2'
5+
}
6+
7+
repositories {
8+
google()
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
classpath "com.android.tools.build:gradle:${project.ext.gradleVersion}"
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${project.ext.kotlinVersion}"
15+
}
16+
}
17+
118
apply plugin: 'com.android.library'
219
apply plugin: 'kotlin-android'
320

@@ -24,7 +41,7 @@ dependencies {
2441
//noinspection GradleDynamicVersion
2542
implementation 'com.facebook.react:react-native:+'
2643
//noinspection GradleDependency
27-
implementation('com.regula.documentreader:api:6.8.8742') {
44+
implementation('com.regula.documentreader:api:6.9.9346') {
2845
transitive = true
2946
}
3047
}

android/src/main/java/com/regula/documentreader/BluetoothUtil.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ class BluetoothUtil {
6969
}
7070

7171
private fun deniedBluetoothPermission(
72-
activity: Activity,
73-
permission: String
72+
activity: Activity,
73+
permission: String
7474
): Array<String> {
7575
if (checkSelfPermission(activity, permission) != PERMISSION_GRANTED)
7676
return arrayOf(permission)
7777
return arrayOf()
7878
}
7979

8080
fun startBluetoothService(
81-
activity: Activity,
82-
onConnected: (Boolean) -> Unit,
83-
onDisconnected: () -> Unit,
84-
onReady: () -> Unit,
81+
activity: Activity,
82+
onConnected: (Boolean) -> Unit,
83+
onDisconnected: () -> Unit,
84+
onReady: () -> Unit
8585
) {
8686
val bleIntent = Intent(activity, RegulaBleService::class.java)
8787
activity.startService(bleIntent)

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

Lines changed: 117 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,114 @@
1919

2020
import java.io.ByteArrayOutputStream;
2121
import java.util.ArrayList;
22+
import java.util.HashMap;
23+
import java.util.Iterator;
2224
import java.util.List;
25+
import java.util.Map;
2326

2427
class Helpers {
28+
interface JSONObjectGeneratorWithContext<T> {
29+
JSONObject generateJSONObject(T param, Context context) throws JSONException;
30+
}
31+
32+
interface JSONObjectGenerator<T> {
33+
JSONObject generateJSONObject(T param) throws JSONException;
34+
}
35+
36+
static <T> JSONArray generateList(List<T> list) {
37+
JSONArray result = new JSONArray();
38+
if (list == null) return result;
39+
for (T t : list)
40+
if (t != null)
41+
result.put(t);
42+
43+
return result;
44+
}
45+
46+
static <T> JSONArray generateList(List<T> list, JSONObjectGenerator<T> generator) throws JSONException {
47+
JSONArray result = new JSONArray();
48+
if (list == null) return result;
49+
for (T t : list)
50+
if (t != null)
51+
result.put(generator.generateJSONObject(t));
52+
53+
return result;
54+
}
55+
56+
static <T> JSONArray generateList(List<T> list, JSONObjectGeneratorWithContext<T> generator, Context context) throws JSONException {
57+
JSONArray result = new JSONArray();
58+
if (list == null) return result;
59+
for (T t : list)
60+
if (t != null)
61+
result.put(generator.generateJSONObject(t, context));
62+
63+
return result;
64+
}
65+
66+
static <T> JSONArray generateArray(T[] array) throws JSONException {
67+
JSONArray result = new JSONArray();
68+
if (array == null) return result;
69+
for (int i = 0; i < array.length; i++)
70+
result.put(i, array[i]);
71+
72+
return result;
73+
}
74+
75+
static <T> JSONArray generateArray(T[] array, JSONObjectGenerator<T> generator) throws JSONException {
76+
JSONArray result = new JSONArray();
77+
if (array == null) return result;
78+
for (int i = 0; i < array.length; i++)
79+
result.put(i, generator.generateJSONObject(array[i]));
80+
81+
return result;
82+
}
83+
84+
static <T, V> JSONObject generateMap(Map<T, V> map) throws JSONException {
85+
JSONObject result = new JSONObject();
86+
if (map == null) return result;
87+
for (Map.Entry<T, V> entry : map.entrySet())
88+
if (entry != null)
89+
result.put(entry.getKey().toString(), entry.getValue());
90+
return result;
91+
}
92+
93+
static JSONArray generateIntArray(int[] array) throws JSONException {
94+
JSONArray result = new JSONArray();
95+
if (array == null) return result;
96+
for (int i = 0; i < array.length; i++)
97+
result.put(i, array[i]);
98+
99+
return result;
100+
}
101+
102+
static int[] intArrayFromJSON(JSONArray input) throws JSONException {
103+
int[] result = new int[input.length()];
104+
for (int i = 0; i < input.length(); i++)
105+
result[i] = input.getInt(i);
106+
107+
return result;
108+
}
109+
110+
static JSONArray generateByteArray(byte[] array) throws JSONException {
111+
JSONArray result = new JSONArray();
112+
if (array == null) return result;
113+
for (int i = 0; i < array.length; i++)
114+
result.put(i, array[i]);
115+
116+
return result;
117+
}
118+
119+
static JSONArray generateLongArray(long[] array) throws JSONException {
120+
JSONArray result = new JSONArray();
121+
if (array == null) return result;
122+
for (int i = 0; i < array.length; i++)
123+
result.put(i, array[i]);
124+
125+
return result;
126+
}
127+
25128
static Bitmap bitmapFromBase64(String base64) {
26-
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
129+
byte[] decodedString = Base64.decode(base64, Base64.NO_WRAP);
27130
Bitmap result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
28131
int sizeMultiplier = result.getByteCount() / 5000000;
29132
if (result.getByteCount() > 5000000)
@@ -63,13 +166,13 @@ static Bitmap bitmapFromDrawable(Drawable drawable) {
63166
}
64167

65168
static String bitmapToBase64String(Bitmap bitmap) {
66-
if(bitmap == null) return null;
169+
if (bitmap == null) return null;
67170

68171
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
69172
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
70173
byte[] byteArray = byteArrayOutputStream.toByteArray();
71174

72-
return Base64.encodeToString(byteArray, Base64.DEFAULT);
175+
return Base64.encodeToString(byteArray, Base64.NO_WRAP);
73176
}
74177

75178
static Matrix matrixFromFloatArray(float[] floats) {
@@ -142,4 +245,15 @@ static String[] stringArrayFromJson(JSONArray jsonArray) {
142245
result[i] = jsonArray.optString(i);
143246
return result;
144247
}
248+
249+
static Map<String, String> stringMapFromJson(JSONObject input) throws JSONException {
250+
Map<String, String> result = new HashMap<>();
251+
Iterator<String> keys = input.keys();
252+
while (keys.hasNext()) {
253+
String key = keys.next();
254+
String value = input.getString(key);
255+
result.put(key, value);
256+
}
257+
return result;
258+
}
145259
}

0 commit comments

Comments
 (0)