@regulaforensics/cordova-plugin-document-reader-api 6.8.0 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/config.xml +1 -8
- package/example/package.json +8 -12
- package/example/www/js/index.js +21 -10
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/src/android/BluetoothUtil.kt +6 -6
- package/src/android/DocumentReader.java +147 -136
- package/src/android/Helpers.java +117 -3
- package/src/android/JSONConstructor.java +182 -261
- package/src/android/RegulaConfig.java +114 -26
- package/src/android/build.gradle +9 -1
- package/src/ios/RGLWDocumentReader.m +42 -36
- package/src/ios/RGLWJSONConstructor.h +8 -6
- package/src/ios/RGLWJSONConstructor.m +109 -92
- package/src/ios/RGLWRegulaConfig.h +2 -1
- package/src/ios/RGLWRegulaConfig.m +139 -41
- package/www/DocumentReader.js +263 -2958
package/src/android/Helpers.java
CHANGED
|
@@ -19,11 +19,114 @@ import org.json.JSONObject;
|
|
|
19
19
|
|
|
20
20
|
import java.io.ByteArrayOutputStream;
|
|
21
21
|
import java.util.ArrayList;
|
|
22
|
+
import java.util.HashMap;
|
|
23
|
+
import java.util.Iterator;
|
|
22
24
|
import java.util.List;
|
|
25
|
+
import java.util.Map;
|
|
23
26
|
|
|
24
27
|
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
|
+
|
|
25
128
|
static Bitmap bitmapFromBase64(String base64) {
|
|
26
|
-
byte[] decodedString = Base64.decode(base64, Base64.
|
|
129
|
+
byte[] decodedString = Base64.decode(base64, Base64.NO_WRAP);
|
|
27
130
|
Bitmap result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
|
|
28
131
|
int sizeMultiplier = result.getByteCount() / 5000000;
|
|
29
132
|
if (result.getByteCount() > 5000000)
|
|
@@ -63,13 +166,13 @@ class Helpers {
|
|
|
63
166
|
}
|
|
64
167
|
|
|
65
168
|
static String bitmapToBase64String(Bitmap bitmap) {
|
|
66
|
-
if(bitmap == null) return null;
|
|
169
|
+
if (bitmap == null) return null;
|
|
67
170
|
|
|
68
171
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
69
172
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
|
|
70
173
|
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
|
71
174
|
|
|
72
|
-
return Base64.encodeToString(byteArray, Base64.
|
|
175
|
+
return Base64.encodeToString(byteArray, Base64.NO_WRAP);
|
|
73
176
|
}
|
|
74
177
|
|
|
75
178
|
static Matrix matrixFromFloatArray(float[] floats) {
|
|
@@ -142,4 +245,15 @@ class Helpers {
|
|
|
142
245
|
result[i] = jsonArray.optString(i);
|
|
143
246
|
return result;
|
|
144
247
|
}
|
|
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
|
+
}
|
|
145
259
|
}
|