@regulaforensics/cordova-plugin-document-reader-api 6.4.0 → 6.6.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 +7 -0
- package/example/package.json +5 -5
- package/example/www/index.html +109 -111
- package/example/www/js/index.js +86 -85
- package/package.json +1 -1
- package/plugin.xml +5 -3
- package/src/android/BluetoothUtil.kt +108 -0
- package/src/android/DocumentReader.java +112 -21
- package/src/android/Helpers.java +5 -6
- package/src/android/JSONConstructor.java +171 -1389
- package/src/android/RegulaConfig.java +68 -7
- package/src/android/build.gradle +5 -11
- package/src/ios/RGLDocumentReader.m +78 -34
- package/src/ios/RGLWJSONConstructor.h +7 -0
- package/src/ios/RGLWJSONConstructor.m +124 -4
- package/src/ios/RegulaConfig.m +62 -7
- package/www/DocumentReader.js +3296 -3182
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regulaforensics/cordova-plugin-document-reader-api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Cordova plugin for reading and validation of identification documents (API framework)",
|
|
5
5
|
"cordova": {
|
|
6
6
|
"id": "@regulaforensics/cordova-plugin-document-reader-api",
|
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="cordova-plugin-document-reader-api" version="6.
|
|
2
|
+
<plugin id="cordova-plugin-document-reader-api" version="6.6.0"
|
|
3
3
|
xmlns="http://apache.org/cordova/ns/plugins/1.0">
|
|
4
4
|
<name>DocumentReaderApi</name>
|
|
5
5
|
<description>Cordova plugin Document reader api</description>
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
<header-file src="src/ios/RegulaConfig.h" />
|
|
24
24
|
<source-file src="src/ios/RegulaConfig.m" />
|
|
25
25
|
<podspec>
|
|
26
|
-
|
|
26
|
+
<config>
|
|
27
|
+
</config>
|
|
27
28
|
<pods>
|
|
28
|
-
<pod name="DocumentReader" spec="~> 6.
|
|
29
|
+
<pod name="DocumentReader" spec="~> 6.6.2753" />
|
|
29
30
|
</pods>
|
|
30
31
|
</podspec>
|
|
31
32
|
</platform>
|
|
@@ -41,5 +42,6 @@
|
|
|
41
42
|
<source-file src="src/android/JSONConstructor.java" target-dir="src/cordova.plugin.documentreader" />
|
|
42
43
|
<source-file src="src/android/RegulaConfig.java" target-dir="src/cordova.plugin.documentreader" />
|
|
43
44
|
<source-file src="src/android/Helpers.java" target-dir="src/cordova.plugin.documentreader" />
|
|
45
|
+
<source-file src="src/android/BluetoothUtil.kt" target-dir="java/cordova.plugin.documentreader" />
|
|
44
46
|
</platform>
|
|
45
47
|
</plugin>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
package cordova.plugin.documentreader
|
|
2
|
+
|
|
3
|
+
import android.Manifest.permission.*
|
|
4
|
+
import android.annotation.SuppressLint
|
|
5
|
+
import android.app.Activity
|
|
6
|
+
import android.bluetooth.BluetoothAdapter
|
|
7
|
+
import android.content.ComponentName
|
|
8
|
+
import android.content.Intent
|
|
9
|
+
import android.content.ServiceConnection
|
|
10
|
+
import android.content.pm.PackageManager.PERMISSION_GRANTED
|
|
11
|
+
import android.os.Build
|
|
12
|
+
import android.os.IBinder
|
|
13
|
+
import android.provider.Settings
|
|
14
|
+
import androidx.annotation.RequiresPermission
|
|
15
|
+
import androidx.core.app.ActivityCompat.requestPermissions
|
|
16
|
+
import androidx.core.content.ContextCompat.checkSelfPermission
|
|
17
|
+
import com.regula.documentreader.api.ble.BLEWrapper
|
|
18
|
+
import com.regula.documentreader.api.ble.BleWrapperCallback
|
|
19
|
+
import com.regula.documentreader.api.ble.RegulaBleService
|
|
20
|
+
import com.regula.documentreader.api.internal.permission.BluetoothPermissionHelper.BLE_ACCESS_PERMISSION
|
|
21
|
+
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isBluetoothEnabled
|
|
22
|
+
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isLocationServiceEnabled
|
|
23
|
+
|
|
24
|
+
class BluetoothUtil {
|
|
25
|
+
companion object {
|
|
26
|
+
private const val REQUEST_ENABLE_LOCATION = 196
|
|
27
|
+
private const val REQUEST_ENABLE_BT = 197
|
|
28
|
+
|
|
29
|
+
@SuppressLint("StaticFieldLeak")
|
|
30
|
+
var bleManager: BLEWrapper? = null
|
|
31
|
+
|
|
32
|
+
@RequiresPermission("android.permission.BLUETOOTH_CONNECT")
|
|
33
|
+
private fun requestEnableBle(activity: Activity) {
|
|
34
|
+
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
|
|
35
|
+
activity.startActivityForResult(enableIntent, REQUEST_ENABLE_BT)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private fun requestEnableLocationService(activity: Activity) {
|
|
39
|
+
val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
|
|
40
|
+
activity.startActivityForResult(myIntent, REQUEST_ENABLE_LOCATION)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// requestEnableBle() is called after a check for permission
|
|
44
|
+
@SuppressLint("MissingPermission")
|
|
45
|
+
fun isBlePermissionsGranted(activity: Activity): Boolean {
|
|
46
|
+
if (!isLocationServiceEnabled(activity)) {
|
|
47
|
+
requestEnableLocationService(activity)
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
deniedBluetoothPermissions(activity)?.let {
|
|
51
|
+
requestPermissions(activity, it, BLE_ACCESS_PERMISSION)
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
if (!isBluetoothEnabled(activity)) {
|
|
55
|
+
requestEnableBle(activity)
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private fun deniedBluetoothPermissions(activity: Activity): Array<String>? {
|
|
62
|
+
val result = mutableListOf<String>()
|
|
63
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
64
|
+
result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_SCAN))
|
|
65
|
+
result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_CONNECT))
|
|
66
|
+
} else
|
|
67
|
+
result.addAll(deniedBluetoothPermission(activity, ACCESS_FINE_LOCATION))
|
|
68
|
+
return result.let { if (it.size > 0) it.toTypedArray() else null }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private fun deniedBluetoothPermission(
|
|
72
|
+
activity: Activity,
|
|
73
|
+
permission: String
|
|
74
|
+
): Array<String> {
|
|
75
|
+
if (checkSelfPermission(activity, permission) != PERMISSION_GRANTED)
|
|
76
|
+
return arrayOf(permission)
|
|
77
|
+
return arrayOf()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fun startBluetoothService(
|
|
81
|
+
activity: Activity,
|
|
82
|
+
onConnected: (Boolean) -> Unit,
|
|
83
|
+
onDisconnected: () -> Unit,
|
|
84
|
+
onReady: () -> Unit,
|
|
85
|
+
) {
|
|
86
|
+
val bleIntent = Intent(activity, RegulaBleService::class.java)
|
|
87
|
+
activity.startService(bleIntent)
|
|
88
|
+
|
|
89
|
+
activity.bindService(bleIntent, object : ServiceConnection {
|
|
90
|
+
override fun onServiceConnected(name: ComponentName, service: IBinder) {
|
|
91
|
+
bleManager = (service as RegulaBleService.LocalBinder).service.bleManager
|
|
92
|
+
val isBleManagerConnected = bleManager?.isConnected == true
|
|
93
|
+
onConnected(isBleManagerConnected)
|
|
94
|
+
if (!isBleManagerConnected) {
|
|
95
|
+
bleManager?.addCallback(object : BleWrapperCallback() {
|
|
96
|
+
override fun onDeviceReady() {
|
|
97
|
+
bleManager!!.removeCallback(this)
|
|
98
|
+
onReady()
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
override fun onServiceDisconnected(name: ComponentName) = onDisconnected()
|
|
105
|
+
}, 0)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -9,10 +9,12 @@ import android.content.IntentFilter;
|
|
|
9
9
|
import android.graphics.Bitmap;
|
|
10
10
|
import android.nfc.NfcAdapter;
|
|
11
11
|
import android.nfc.tech.IsoDep;
|
|
12
|
-
import androidx.annotation.NonNull;
|
|
13
12
|
import android.os.Bundle;
|
|
14
13
|
import android.util.Base64;
|
|
15
14
|
|
|
15
|
+
import androidx.annotation.NonNull;
|
|
16
|
+
|
|
17
|
+
import com.regula.documentreader.api.completions.ICheckDatabaseUpdate;
|
|
16
18
|
import com.regula.documentreader.api.completions.IDocumentReaderCompletion;
|
|
17
19
|
import com.regula.documentreader.api.completions.IDocumentReaderInitCompletion;
|
|
18
20
|
import com.regula.documentreader.api.completions.IDocumentReaderPrepareCompletion;
|
|
@@ -23,14 +25,15 @@ import com.regula.documentreader.api.completions.ITccParamsCompletion;
|
|
|
23
25
|
import com.regula.documentreader.api.enums.DocReaderAction;
|
|
24
26
|
import com.regula.documentreader.api.errors.DocumentReaderException;
|
|
25
27
|
import com.regula.documentreader.api.internal.core.CoreScenarioUtil;
|
|
28
|
+
import com.regula.documentreader.api.params.BleDeviceConfig;
|
|
26
29
|
import com.regula.documentreader.api.params.DocReaderConfig;
|
|
27
30
|
import com.regula.documentreader.api.params.ImageInputData;
|
|
28
|
-
import com.regula.documentreader.api.params.ImageInputParam;
|
|
31
|
+
import com.regula.documentreader.api.internal.params.ImageInputParam;
|
|
29
32
|
import com.regula.documentreader.api.params.rfid.PKDCertificate;
|
|
30
33
|
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
|
|
31
34
|
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
|
|
32
35
|
import com.regula.documentreader.api.results.DocumentReaderResults;
|
|
33
|
-
import com.regula.documentreader.api.parser.DocReaderResultsJsonParser;
|
|
36
|
+
import com.regula.documentreader.api.internal.parser.DocReaderResultsJsonParser;
|
|
34
37
|
|
|
35
38
|
import org.apache.cordova.CallbackContext;
|
|
36
39
|
import org.apache.cordova.CordovaPlugin;
|
|
@@ -57,9 +60,15 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
57
60
|
private IRfidPKDCertificateCompletion taCertificateCompletion;
|
|
58
61
|
private IRfidTASignatureCompletion taSignatureCompletion;
|
|
59
62
|
private final static String rfidNotificationCompletionEvent = "rfidNotificationCompletionEvent";
|
|
63
|
+
|
|
60
64
|
private final static String paCertificateCompletionEvent = "paCertificateCompletionEvent";
|
|
61
65
|
private final static String taCertificateCompletionEvent = "taCertificateCompletionEvent";
|
|
62
66
|
private final static String taSignatureCompletionEvent = "taSignatureCompletionEvent";
|
|
67
|
+
|
|
68
|
+
private final static String bleOnServiceConnectedEvent = "bleOnServiceConnectedEvent";
|
|
69
|
+
private final static String bleOnServiceDisconnectedEvent = "bleOnServiceDisconnectedEvent";
|
|
70
|
+
private final static String bleOnDeviceReadyEvent = "bleOnDeviceReadyEvent";
|
|
71
|
+
|
|
63
72
|
private static int databaseDownloadProgress = 0;
|
|
64
73
|
|
|
65
74
|
private Context getContext() {
|
|
@@ -118,13 +127,13 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
118
127
|
}
|
|
119
128
|
|
|
120
129
|
private void sendIRfidNotificationCompletion(int notification, Bundle value) {
|
|
121
|
-
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, rfidNotificationCompletionEvent + JSONConstructor.generateRfidNotificationCompletion(notification, value)
|
|
130
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, rfidNotificationCompletionEvent + JSONConstructor.generateRfidNotificationCompletion(notification, value));
|
|
122
131
|
pluginResult.setKeepCallback(true);
|
|
123
132
|
callbackContext.sendPluginResult(pluginResult);
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
private void sendPACertificateCompletion(byte[] serialNumber, PAResourcesIssuer issuer) {
|
|
127
|
-
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, paCertificateCompletionEvent + JSONConstructor.generatePACertificateCompletion(serialNumber, issuer)
|
|
136
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, paCertificateCompletionEvent + JSONConstructor.generatePACertificateCompletion(serialNumber, issuer));
|
|
128
137
|
pluginResult.setKeepCallback(true);
|
|
129
138
|
callbackContext.sendPluginResult(pluginResult);
|
|
130
139
|
}
|
|
@@ -135,7 +144,23 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
135
144
|
callbackContext.sendPluginResult(pluginResult);
|
|
136
145
|
}
|
|
137
146
|
private void sendTASignatureCompletion(TAChallenge challenge) {
|
|
138
|
-
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, taSignatureCompletionEvent + JSONConstructor.generateTAChallenge(challenge)
|
|
147
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, taSignatureCompletionEvent + JSONConstructor.generateTAChallenge(challenge));
|
|
148
|
+
pluginResult.setKeepCallback(true);
|
|
149
|
+
callbackContext.sendPluginResult(pluginResult);
|
|
150
|
+
}
|
|
151
|
+
private void sendBleOnServiceConnectedEvent(boolean isBleManagerConnected) {
|
|
152
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, bleOnServiceConnectedEvent + isBleManagerConnected);
|
|
153
|
+
pluginResult.setKeepCallback(true);
|
|
154
|
+
callbackContext.sendPluginResult(pluginResult);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private void sendBleOnServiceDisconnectedEvent() {
|
|
158
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, bleOnServiceDisconnectedEvent);
|
|
159
|
+
pluginResult.setKeepCallback(true);
|
|
160
|
+
callbackContext.sendPluginResult(pluginResult);
|
|
161
|
+
}
|
|
162
|
+
private void sendBleOnDeviceReadyEvent() {
|
|
163
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, bleOnDeviceReadyEvent);
|
|
139
164
|
pluginResult.setKeepCallback(true);
|
|
140
165
|
callbackContext.sendPluginResult(pluginResult);
|
|
141
166
|
}
|
|
@@ -168,6 +193,18 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
168
193
|
case "initializeReaderAutomatically":
|
|
169
194
|
initializeReaderAutomatically(callback);
|
|
170
195
|
break;
|
|
196
|
+
case "isBlePermissionsGranted":
|
|
197
|
+
isBlePermissionsGranted(callback);
|
|
198
|
+
break;
|
|
199
|
+
case "startBluetoothService":
|
|
200
|
+
startBluetoothService(callback);
|
|
201
|
+
break;
|
|
202
|
+
case "initializeReaderBleDeviceConfig":
|
|
203
|
+
initializeReaderBleDeviceConfig(callback);
|
|
204
|
+
break;
|
|
205
|
+
case "getTag":
|
|
206
|
+
getTag(callback);
|
|
207
|
+
break;
|
|
171
208
|
case "getAPIVersion":
|
|
172
209
|
getAPIVersion(callback);
|
|
173
210
|
break;
|
|
@@ -288,6 +325,12 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
288
325
|
case "setCameraSessionIsPaused":
|
|
289
326
|
setCameraSessionIsPaused(callback, args(0));
|
|
290
327
|
break;
|
|
328
|
+
case "setTag":
|
|
329
|
+
setTag(callback, args(0));
|
|
330
|
+
break;
|
|
331
|
+
case "checkDatabaseUpdate":
|
|
332
|
+
checkDatabaseUpdate(callback, args(0));
|
|
333
|
+
break;
|
|
291
334
|
case "getScenario":
|
|
292
335
|
getScenario(callback, args(0));
|
|
293
336
|
break;
|
|
@@ -315,6 +358,9 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
315
358
|
case "recognizeImage":
|
|
316
359
|
recognizeImage(callback, args(0));
|
|
317
360
|
break;
|
|
361
|
+
case "recognizeData":
|
|
362
|
+
recognizeData(callback, args(0));
|
|
363
|
+
break;
|
|
318
364
|
case "setRfidSessionStatus":
|
|
319
365
|
setRfidSessionStatus(callback, args(0));
|
|
320
366
|
break;
|
|
@@ -333,9 +379,6 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
333
379
|
case "setTCCParams":
|
|
334
380
|
setTCCParams(callback, args(0));
|
|
335
381
|
break;
|
|
336
|
-
case "initializeReaderWithDatabase":
|
|
337
|
-
initializeReaderWithDatabase(callback, args(0), args(1));
|
|
338
|
-
break;
|
|
339
382
|
case "recognizeImageWithOpts":
|
|
340
383
|
recognizeImageWithOpts(callback, args(0), args(1));
|
|
341
384
|
break;
|
|
@@ -352,7 +395,8 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
352
395
|
recognizeImagesWithImageInputs(callback, args(0));
|
|
353
396
|
break;
|
|
354
397
|
}
|
|
355
|
-
} catch (Exception
|
|
398
|
+
} catch (Exception e) {
|
|
399
|
+
e.printStackTrace();
|
|
356
400
|
}
|
|
357
401
|
return true;
|
|
358
402
|
}
|
|
@@ -396,6 +440,37 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
396
440
|
callback.success("already initialized");
|
|
397
441
|
}
|
|
398
442
|
|
|
443
|
+
private void isBlePermissionsGranted(Callback callback) {
|
|
444
|
+
callback.success(BluetoothUtil.Companion.isBlePermissionsGranted(getActivity()));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
private void startBluetoothService(Callback callback) {
|
|
448
|
+
BluetoothUtil.Companion.startBluetoothService(
|
|
449
|
+
getActivity(),
|
|
450
|
+
isBleManagerConnected -> {
|
|
451
|
+
sendBleOnServiceConnectedEvent(isBleManagerConnected);
|
|
452
|
+
return null;
|
|
453
|
+
},
|
|
454
|
+
() -> {
|
|
455
|
+
sendBleOnServiceDisconnectedEvent();
|
|
456
|
+
return null;
|
|
457
|
+
},
|
|
458
|
+
() -> {
|
|
459
|
+
sendBleOnDeviceReadyEvent();
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
callback.success();
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
private void initializeReaderBleDeviceConfig(Callback callback) {
|
|
467
|
+
if (BluetoothUtil.Companion.getBleManager() == null) callback.error("bleManager is null");
|
|
468
|
+
if (!Instance().isReady())
|
|
469
|
+
Instance().initializeReader(getContext(), new BleDeviceConfig(BluetoothUtil.Companion.getBleManager()), getInitCompletion(callback));
|
|
470
|
+
else
|
|
471
|
+
callback.success("already initialized");
|
|
472
|
+
}
|
|
473
|
+
|
|
399
474
|
private void getAvailableScenarios(Callback callback) throws JSONException {
|
|
400
475
|
callback.success(JSONConstructor.generateList(Instance().availableScenarios, JSONConstructor::generateDocumentReaderScenario).toString());
|
|
401
476
|
}
|
|
@@ -500,16 +575,9 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
500
575
|
callback.success(Instance().isRFIDAvailableForUse());
|
|
501
576
|
}
|
|
502
577
|
|
|
503
|
-
private void initializeReader(Callback callback,
|
|
578
|
+
private void initializeReader(Callback callback, JSONObject config) {
|
|
504
579
|
if (!Instance().isReady())
|
|
505
|
-
Instance().initializeReader(getContext(),
|
|
506
|
-
else
|
|
507
|
-
callback.success("already initialized");
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
private void initializeReaderWithDatabase(Callback callback, Object license, Object db) {
|
|
511
|
-
if (!Instance().isReady())
|
|
512
|
-
Instance().initializeReader(getContext(), new DocReaderConfig(Base64.decode(license.toString(), Base64.DEFAULT), Base64.decode(db.toString(), Base64.DEFAULT)), getInitCompletion(callback));
|
|
580
|
+
Instance().initializeReader(getContext(), JSONConstructor.DocReaderConfigFromJSON(config), getInitCompletion(callback));
|
|
513
581
|
else
|
|
514
582
|
callback.success("already initialized");
|
|
515
583
|
}
|
|
@@ -519,6 +587,20 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
519
587
|
callback.success();
|
|
520
588
|
}
|
|
521
589
|
|
|
590
|
+
private void getTag(Callback callback) {
|
|
591
|
+
callback.success(Instance().tag);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
private void setTag(Callback callback, String tag) {
|
|
595
|
+
Instance().tag = tag;
|
|
596
|
+
callback.success();
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
private void checkDatabaseUpdate(Callback callback, String databaseId) {
|
|
600
|
+
Instance().checkDatabaseUpdate(getContext(), databaseId, getCheckDatabaseUpdateCompletion(callback));
|
|
601
|
+
callback.success();
|
|
602
|
+
}
|
|
603
|
+
|
|
522
604
|
private void startNewPage(Callback callback) {
|
|
523
605
|
Instance().startNewPage();
|
|
524
606
|
callback.success();
|
|
@@ -534,6 +616,11 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
534
616
|
Instance().recognizeImage(Helpers.bitmapFromBase64(base64Image), getCompletion());
|
|
535
617
|
}
|
|
536
618
|
|
|
619
|
+
private void recognizeData(@SuppressWarnings("unused") Callback callback, Object data) {
|
|
620
|
+
stopBackgroundRFID();
|
|
621
|
+
Instance().recognizeImage(Base64.decode(data.toString(), Base64.DEFAULT), getCompletion());
|
|
622
|
+
}
|
|
623
|
+
|
|
537
624
|
private void recognizeImages(@SuppressWarnings("unused") Callback callback, JSONArray base64Images) throws JSONException {
|
|
538
625
|
stopBackgroundRFID();
|
|
539
626
|
Bitmap[] images = new Bitmap[base64Images.length()];
|
|
@@ -555,7 +642,7 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
555
642
|
}
|
|
556
643
|
|
|
557
644
|
private void cancelDBUpdate(Callback callback) {
|
|
558
|
-
callback.success(Instance().cancelDBUpdate());
|
|
645
|
+
callback.success(Instance().cancelDBUpdate(getContext()));
|
|
559
646
|
}
|
|
560
647
|
|
|
561
648
|
private void resetConfiguration(Callback callback) {
|
|
@@ -701,7 +788,7 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
701
788
|
callback.error("getCameraSessionIsPaused() is an ios-only method");
|
|
702
789
|
}
|
|
703
790
|
|
|
704
|
-
private void stopRFIDReaderWithErrorMessage(Callback callback, String message) {
|
|
791
|
+
private void stopRFIDReaderWithErrorMessage(Callback callback, @SuppressWarnings("unused") String message) {
|
|
705
792
|
callback.error("stopRFIDReaderWithErrorMessage() is an ios-only method");
|
|
706
793
|
}
|
|
707
794
|
|
|
@@ -757,6 +844,10 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
757
844
|
};
|
|
758
845
|
}
|
|
759
846
|
|
|
847
|
+
private ICheckDatabaseUpdate getCheckDatabaseUpdateCompletion(Callback callback) {
|
|
848
|
+
return (database) -> callback.success(JSONConstructor.generateDocReaderDocumentsDatabase(database));
|
|
849
|
+
}
|
|
850
|
+
|
|
760
851
|
private ITccParamsCompletion getTCCParamsCompletion(Callback callback) {
|
|
761
852
|
return (success, error) -> {
|
|
762
853
|
if (success)
|
package/src/android/Helpers.java
CHANGED
|
@@ -10,7 +10,7 @@ import android.graphics.drawable.Drawable;
|
|
|
10
10
|
import android.util.Base64;
|
|
11
11
|
|
|
12
12
|
import com.regula.documentreader.api.enums.BarcodeType;
|
|
13
|
-
import com.regula.documentreader.api.params.FaceMetaData;
|
|
13
|
+
import com.regula.documentreader.api.internal.params.FaceMetaData;
|
|
14
14
|
import com.regula.documentreader.api.results.Bounds;
|
|
15
15
|
|
|
16
16
|
import org.json.JSONArray;
|
|
@@ -31,13 +31,12 @@ class Helpers {
|
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
static BitmapDrawable drawableFromBase64(String base64, Context context)
|
|
35
|
-
{
|
|
34
|
+
static BitmapDrawable drawableFromBase64(String base64, Context context) {
|
|
36
35
|
byte[] decodedByte = Base64.decode(base64, 0);
|
|
37
|
-
Bitmap bitmap =
|
|
36
|
+
Bitmap bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
|
|
38
37
|
float density = context.getResources().getDisplayMetrics().density;
|
|
39
|
-
int width = (int)(bitmap.getWidth()*density);
|
|
40
|
-
int height = (int)(bitmap.getHeight()*density);
|
|
38
|
+
int width = (int) (bitmap.getWidth() * density);
|
|
39
|
+
int height = (int) (bitmap.getHeight() * density);
|
|
41
40
|
return new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap, width, height, false));
|
|
42
41
|
}
|
|
43
42
|
|