@regulaforensics/cordova-plugin-document-reader-api 7.1.0 → 7.3.483-nightly

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.
@@ -13,8 +13,8 @@
13
13
  "author": "Regula Forensics Inc.",
14
14
  "license": "commercial",
15
15
  "dependencies": {
16
- "@regulaforensics/cordova-plugin-document-reader-api": "7.1.0",
17
- "@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "7.1.0",
16
+ "@regulaforensics/cordova-plugin-document-reader-api": "7.3.483-nightly",
17
+ "@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "7.3.439-nightly",
18
18
  "cordova-android": "12.0.1",
19
19
  "cordova-ios": "7.0.1",
20
20
  "cordova-plugin-add-swift-support": "2.0.2",
@@ -7,10 +7,10 @@ var app = {
7
7
  function onInitialized() {
8
8
  document.getElementById("status").innerHTML = "Ready"
9
9
  document.getElementById("status").style.backgroundColor = "green"
10
-
11
- DocumentReader.setFunctionality({
12
- showCaptureButton: true
13
- }, function (s) { }, function (e) { })
10
+
11
+ var functionality = new Functionality()
12
+ functionality.showCaptureButton = true
13
+ DocumentReader.setFunctionality(functionality, function (s) { }, function (e) { })
14
14
  }
15
15
 
16
16
  this.receivedEvent('deviceready')
@@ -27,6 +27,7 @@ var app = {
27
27
  var ScannerConfig = DocumentReaderPlugin.ScannerConfig
28
28
  var RecognizeConfig = DocumentReaderPlugin.RecognizeConfig
29
29
  var DocReaderConfig = DocumentReaderPlugin.DocReaderConfig
30
+ var Functionality = DocumentReaderPlugin.Functionality
30
31
  var Enum = DocumentReaderPlugin.Enum
31
32
 
32
33
  var selectedScenario = "Mrz"
@@ -113,7 +114,7 @@ var app = {
113
114
  hideRfidUI()
114
115
  displayResults(completion.results)
115
116
  }
116
- } else if (actionSuccess(completion.action))
117
+ } else if (actionSuccess(completion.action) || actionError(completion.action))
117
118
  handleResults(completion.results)
118
119
  }
119
120
 
@@ -184,7 +185,7 @@ var app = {
184
185
 
185
186
  function handleResults(results) {
186
187
  clearResults()
187
- if (doRfid && !isReadingRfid && results != null) {
188
+ if (doRfid && !isReadingRfid && results != null && results.chipPage != 0) {
188
189
  // customRFID()
189
190
  usualRFID()
190
191
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regulaforensics/cordova-plugin-document-reader-api",
3
- "version": "7.1.0",
3
+ "version": "7.3.483-nightly",
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="7.1.0"
2
+ <plugin id="cordova-plugin-document-reader-api" version="7.3.483"
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>
@@ -26,7 +26,7 @@
26
26
  <config>
27
27
  </config>
28
28
  <pods>
29
- <pod name="DocumentReader" spec="7.1.3379" />
29
+ <pod name="DocumentReaderNightly" spec="7.3.9216" />
30
30
  </pods>
31
31
  </podspec>
32
32
  </platform>
@@ -55,7 +55,7 @@ fun setFunctionality(functionality: Functionality, opts: JSONObject) = opts.forE
55
55
  "showCaptureButtonDelayFromStart" -> editor.setShowCaptureButtonDelayFromStart(v.toLong())
56
56
  "orientation" -> editor.setOrientation(v.toInt())
57
57
  "captureMode" -> editor.setCaptureMode(v.toInt())
58
- "cameraPosition" -> editor.setCameraMode(v.toInt())
58
+ "cameraMode" -> editor.setCameraMode(v.toInt())
59
59
  "rfidTimeout" -> editor.setRfidTimeout(v.toInt())
60
60
  "forcePagesCount" -> editor.setForcePagesCount(v.toInt())
61
61
  "cameraFrame" -> editor.setCameraFrame(v as String)
@@ -88,7 +88,7 @@ fun getFunctionality(functionality: Functionality) = mapOf(
88
88
  "showCaptureButtonDelayFromStart" to functionality.showCaptureButtonDelayFromStart,
89
89
  "orientation" to functionality.orientation,
90
90
  "captureMode" to functionality.captureMode,
91
- "cameraPosition" to functionality.cameraMode,
91
+ "cameraMode" to functionality.cameraMode,
92
92
  "rfidTimeout" to functionality.rfidTimeout,
93
93
  "forcePagesCount" to functionality.forcePagesCount,
94
94
  "cameraFrame" to functionality.cameraFrame,
@@ -150,10 +150,10 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
150
150
  "scenario" -> processParams.scenario = v as String
151
151
  "captureButtonScenario" -> processParams.captureButtonScenario = v as String
152
152
  "sessionLogFolder" -> processParams.sessionLogFolder = v as String
153
- "timeout" -> processParams.timeout = v as Double
154
- "timeoutFromFirstDetect" -> processParams.timeoutFromFirstDetect = v as Double
155
- "timeoutFromFirstDocType" -> processParams.timeoutFromFirstDocType = v as Double
156
- "documentAreaMin" -> processParams.documentAreaMin = v as Double
153
+ "timeout" -> processParams.timeout = v.toDouble()
154
+ "timeoutFromFirstDetect" -> processParams.timeoutFromFirstDetect = v.toDouble()
155
+ "timeoutFromFirstDocType" -> processParams.timeoutFromFirstDocType = v.toDouble()
156
+ "documentAreaMin" -> processParams.documentAreaMin = v.toDouble()
157
157
  "documentIDList" -> processParams.documentIDList = v.toIntArray()
158
158
  "fieldTypesFilter" -> processParams.fieldTypesFilter = v.toIntArray()
159
159
  "resultTypeOutput" -> processParams.resultTypeOutput = v.toIntArray()
@@ -298,7 +298,7 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject, conte
298
298
  "borderBackgroundImageMatrix" -> editor.setBorderBackgroundImageMatrix(v.toMatrix()).setBorderBackgroundImageScaleType(ImageView.ScaleType.MATRIX)
299
299
  "customLabelStatus" -> editor.setCustomLabelStatus(SpannableString(v as String))
300
300
  "cameraFrameLineCap" -> editor.setCameraFrameLineCap(Paint.Cap.values()[v.toInt()])
301
- "uiCustomizationLayer" -> editor.setUiCustomizationLayer(v as JSONObject)
301
+ "uiCustomizationLayer" -> editor.setUiCustomizationLayer(JSONObject(v.toString()))
302
302
  "colors" -> setColors(editor, v as JSONObject)
303
303
  "fonts" -> setFonts(editor, v as JSONObject)
304
304
  "images" -> setImages(editor, v as JSONObject, context)
@@ -412,6 +412,7 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
412
412
  "authorizedInstallQCert" -> rfidScenario.isAuthorizedInstallQCert = v as Boolean
413
413
  "applyAmendments" -> rfidScenario.isApplyAmendments = v as Boolean
414
414
  "autoSettings" -> rfidScenario.isAutoSettings = v as Boolean
415
+ "proceedReadingAlways" -> rfidScenario.proceedReadingAlways = v as Boolean
415
416
  "signManagementAction" -> rfidScenario.signManagementAction = v.toInt()
416
417
  "readingBuffer" -> rfidScenario.readingBuffer = v.toInt()
417
418
  "onlineTAToSignDataType" -> rfidScenario.onlineTAToSignDataType = v.toInt()
@@ -467,6 +468,7 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
467
468
  "authorizedInstallQCert" to rfidScenario.isAuthorizedInstallQCert,
468
469
  "applyAmendments" to rfidScenario.isApplyAmendments,
469
470
  "autoSettings" to rfidScenario.isAutoSettings,
471
+ "proceedReadingAlways" to rfidScenario.proceedReadingAlways,
470
472
  "signManagementAction" to rfidScenario.signManagementAction,
471
473
  "readingBuffer" to rfidScenario.readingBuffer,
472
474
  "onlineTAToSignDataType" to rfidScenario.onlineTAToSignDataType,
@@ -562,7 +564,7 @@ fun setImageQA(input: ImageQA, opts: JSONObject) = opts.forEach { k, v ->
562
564
  "dpiThreshold" -> input.dpiThreshold = v.toInt()
563
565
  "angleThreshold" -> input.angleThreshold = v.toInt()
564
566
  "documentPositionIndent" -> input.documentPositionIndent = v.toInt()
565
- "brightnessThreshold" -> input.brightnessThreshold = v as Double
567
+ "brightnessThreshold" -> input.brightnessThreshold = v.toDouble()
566
568
  "expectedPass" -> input.expectedPass = v.toIntArray()
567
569
  "glaresCheckParams" -> input.glaresCheckParams = glaresCheckParamsFromJSON(v as JSONObject)
568
570
  }
@@ -15,7 +15,8 @@ import com.regula.common.LocalizationCallbacks
15
15
  import com.regula.documentreader.api.DocumentReader.Instance
16
16
  import com.regula.documentreader.api.completions.IDocumentReaderCompletion
17
17
  import com.regula.documentreader.api.completions.IDocumentReaderInitCompletion
18
- import com.regula.documentreader.api.completions.IDocumentReaderPrepareCompletion
18
+ import com.regula.documentreader.api.completions.IDocumentReaderPrepareDbCompletion
19
+ import com.regula.documentreader.api.completions.model.PrepareProgress
19
20
  import com.regula.documentreader.api.completions.rfid.IRfidPKDCertificateCompletion
20
21
  import com.regula.documentreader.api.completions.rfid.IRfidReaderCompletion
21
22
  import com.regula.documentreader.api.completions.rfid.IRfidReaderRequest
@@ -77,7 +78,9 @@ fun sendEvent(event: String, data: Any? = "") {
77
78
  }
78
79
 
79
80
  @Suppress("UNCHECKED_CAST")
80
- private fun <T> argsNullable(index: Int): T? = args.get(index) as T?
81
+ fun <T> argsNullable(index: Int): T? = if (args.get(index).toString() != "null") {
82
+ args.get(index) as T
83
+ } else null
81
84
 
82
85
  lateinit var args: JSONArray
83
86
  lateinit var callbackContext: CallbackContext
@@ -109,6 +112,7 @@ fun exec(arguments: JSONArray, tempContext: CallbackContext) {
109
112
  "setCustomization" -> setCustomization(args(0))
110
113
  "getRfidScenario" -> getRfidScenario(callback)
111
114
  "setRfidScenario" -> setRfidScenario(args(0))
115
+ "resetConfiguration" -> resetConfiguration()
112
116
  "initializeReader" -> initializeReader(callback, args(0))
113
117
  "initializeReaderWithBleDeviceConfig" -> initializeReaderWithBleDeviceConfig(callback, args(0))
114
118
  "deinitializeReader" -> deinitializeReader(callback)
@@ -122,8 +126,8 @@ fun exec(arguments: JSONArray, tempContext: CallbackContext) {
122
126
  "startNewPage" -> startNewPage(callback)
123
127
  "stopScanner" -> stopScanner(callback)
124
128
  "startRFIDReader" -> startRFIDReader(args(0), args(1), args(2))
125
- "stopRFIDReader" -> stopRFIDReader(callback)
126
129
  "readRFID" -> readRFID(args(0), args(1), args(2))
130
+ "stopRFIDReader" -> stopRFIDReader(callback)
127
131
  "providePACertificates" -> providePACertificates(callback, argsNullable(0))
128
132
  "provideTACertificates" -> provideTACertificates(callback, argsNullable(0))
129
133
  "provideTASignature" -> provideTASignature(callback, args(0))
@@ -155,12 +159,12 @@ fun exec(arguments: JSONArray, tempContext: CallbackContext) {
155
159
  "graphicFieldImageByTypeSourcePageIndexLight" -> graphicFieldImageByTypeSourcePageIndexLight(callback, args(0), args(1), args(2), args(3), args(4))
156
160
  "containers" -> containers(callback, args(0), args(1))
157
161
  "encryptedContainers" -> encryptedContainers(callback, args(0))
158
- "getTranslation" -> getTranslation(callback, args(0), args(1))
159
162
  "finalizePackage" -> finalizePackage(callback)
163
+ "getTranslation" -> getTranslation(callback, args(0), args(1))
160
164
  }
161
165
  }
162
166
 
163
- fun <T> args(index: Int): T = argsNullable(index)!!
167
+ inline fun <reified T> args(index: Int) = argsNullable<T>(index)!!
164
168
  interface Callback {
165
169
  fun success(data: Any? = "")
166
170
  fun error(message: String)
@@ -225,6 +229,8 @@ fun getRfidScenario(callback: Callback) = callback.success(getRfidScenario(Insta
225
229
 
226
230
  fun setRfidScenario(rfidScenario: JSONObject) = setRfidScenario(Instance().rfidScenario(), rfidScenario)
227
231
 
232
+ fun resetConfiguration() = Instance().resetConfiguration()
233
+
228
234
  fun initializeReader(callback: Callback, config: JSONObject) = Instance().initializeReader(context, docReaderConfigFromJSON(config), getInitCompletion(callback))
229
235
 
230
236
  fun initializeReaderWithBleDeviceConfig(callback: Callback, config: JSONObject) = Instance().initializeReader(context, bleDeviceConfigFromJSON(config), getInitCompletion(callback))
@@ -332,9 +338,8 @@ fun startBluetoothService() = startBluetoothService(
332
338
  { sendEvent(bleOnDeviceReadyEvent) }
333
339
  )
334
340
 
335
- @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
336
341
  fun setLocalizationDictionary(dictionary: JSONObject) {
337
- localizationCallbacks = LocalizationCallbacks { dictionary.optString(it, null) }
342
+ localizationCallbacks = LocalizationCallbacks { if (dictionary.has(it)) dictionary.getString(it) else null }
338
343
  Instance().setLocalizationCallback(localizationCallbacks!!)
339
344
  }
340
345
 
@@ -415,15 +420,9 @@ val rfidReaderCompletion = object : IRfidReaderCompletion() {
415
420
  override fun onProgress(notification: DocumentReaderNotification) = sendEvent(rfidOnProgressEvent, generateDocumentReaderNotification(notification))
416
421
  }
417
422
 
418
- fun getPrepareCompletion(callback: Callback) = object : IDocumentReaderPrepareCompletion {
419
- override fun onPrepareProgressChanged(progress: Int) {
420
- if (progress != databaseDownloadProgress) {
421
- sendEvent(eventDatabaseProgress, progress)
422
- databaseDownloadProgress = progress
423
- }
424
- }
425
-
426
- override fun onPrepareCompleted(s: Boolean, e: DocumentReaderException?) = callback.success(generateSuccessCompletion(s, e))
423
+ fun getPrepareCompletion(callback: Callback) = object : IDocumentReaderPrepareDbCompletion() {
424
+ override fun onPrepareProgressChanged(progress: PrepareProgress) = sendEvent(eventDatabaseProgress, generatePrepareProgress(progress))
425
+ override fun onPrepareCompleted(success: Boolean, error: DocumentReaderException?) = callback.success(generateSuccessCompletion(success, error))
427
426
  }
428
427
 
429
428
  fun getInitCompletion(callback: Callback) = IDocumentReaderInitCompletion { success, error ->
@@ -5,7 +5,6 @@
5
5
  // Created by Pavel Masiuk on 21.09.2023.
6
6
  // Copyright © 2023 Regula. All rights reserved.
7
7
  //
8
- @file:Suppress("USELESS_CAST")
9
8
 
10
9
  package cordova.plugin.documentreader
11
10
 
@@ -16,6 +15,7 @@ import android.graphics.Typeface
16
15
  import android.util.Pair
17
16
  import com.regula.common.exception.RegulaException
18
17
  import com.regula.documentreader.api.License
18
+ import com.regula.documentreader.api.completions.model.PrepareProgress
19
19
  import com.regula.documentreader.api.config.RecognizeConfig
20
20
  import com.regula.documentreader.api.config.ScannerConfig
21
21
  import com.regula.documentreader.api.enums.BarcodeType
@@ -123,6 +123,17 @@ fun generateSuccessCompletion(success: Boolean, error: RegulaException?) = objec
123
123
  }
124
124
  }
125
125
 
126
+ fun prepareProgressFromJSON(it: JSONObject) = PrepareProgress(
127
+ it.getInt("downloadedBytes"),
128
+ it.getInt("totalBytes")
129
+ )
130
+
131
+ fun generatePrepareProgress(it: PrepareProgress) = mapOf(
132
+ "downloadedBytes" to it.downloadedBytes,
133
+ "totalBytes" to it.totalBytes,
134
+ "progress" to it.progress
135
+ ).toJson()
136
+
126
137
  fun generatePACertificateCompletion(serialNumber: ByteArray?, issuer: PAResourcesIssuer?) = object : JSONObject() { init {
127
138
  put("serialNumber", generateByteArray(serialNumber))
128
139
  put("issuer", generatePAResourcesIssuer(issuer))
@@ -1961,7 +1972,7 @@ fun generateDocReaderDocumentsDatabase(temp: DocReaderDocumentsDatabase?): JSONO
1961
1972
  result.put("databaseDescription", input.databaseDescription)
1962
1973
  result.put("countriesNumber", input.countriesNumber)
1963
1974
  result.put("documentsNumber", input.documentsNumber)
1964
- result.put("size", input.size as Long?)
1975
+ result.put("size", input.size)
1965
1976
 
1966
1977
  return result
1967
1978
  }
@@ -5,7 +5,6 @@
5
5
  // Created by Pavel Masiuk on 21.09.2023.
6
6
  // Copyright © 2023 Regula. All rights reserved.
7
7
  //
8
- @file:Suppress("UNCHECKED_CAST")
9
8
 
10
9
  package cordova.plugin.documentreader
11
10
 
@@ -31,27 +30,26 @@ fun Any?.toSendable(): Any? = this?.let {
31
30
  else this
32
31
  }
33
32
 
34
- fun arrayListToJSONArray(list: ArrayList<*>): JSONArray {
33
+ fun List<*>.toJson(): JSONArray {
35
34
  val result = JSONArray()
36
- for (i in list.indices) {
37
- when {
38
- list[i] == null -> result.put(null)
39
- list[i].javaClass == HashMap::class.java -> result.put(hashMapToJSONObject(list[i] as HashMap<String, *>))
40
- list[i].javaClass == ArrayList::class.java -> result.put(arrayListToJSONArray(list[i] as ArrayList<*>))
41
- else -> result.put(list[i])
35
+ for (i in indices)
36
+ when (val v = this[i]) {
37
+ null -> result.put(null)
38
+ is Map<*, *> -> result.put(v.toJson())
39
+ is List<*> -> result.put(v.toJson())
40
+ else -> result.put(v)
42
41
  }
43
- }
44
42
  return result
45
43
  }
46
44
 
47
- fun hashMapToJSONObject(map: HashMap<String, *>): JSONObject {
45
+ fun Map<*, *>.toJson(): JSONObject {
48
46
  val result = JSONObject()
49
- for ((key, value) in map) {
50
- when {
51
- value == null -> result.put(key, null)
52
- value.javaClass == HashMap::class.java -> result.put(key, hashMapToJSONObject(value as HashMap<String, *>))
53
- value.javaClass == ArrayList::class.java -> result.put(key, arrayListToJSONArray(value as ArrayList<*>))
54
- else -> result.put(key, value)
47
+ for ((k, v) in this) {
48
+ when (v) {
49
+ null -> result.put(k as String, null)
50
+ is Map<*, *> -> result.put(k as String, v.toJson())
51
+ is List<*> -> result.put(k as String, v.toJson())
52
+ else -> result.put(k as String, v)
55
53
  }
56
54
  }
57
55
  return result
@@ -78,6 +76,7 @@ fun <T> listFromJSON(input: JSONArray?, fromJson: (JSONObject?) -> T) = input?.l
78
76
  result
79
77
  }
80
78
 
79
+ @Suppress("UNCHECKED_CAST")
81
80
  fun <T> listFromJSON(input: JSONArray): List<T> {
82
81
  val result: MutableList<T> = ArrayList()
83
82
  for (i in 0 until input.length()) result.add(input.opt(i) as T)
@@ -170,6 +169,12 @@ fun Any?.toLong() = when (this) {
170
169
  else -> this as Long
171
170
  }
172
171
 
172
+ fun Any?.toDouble() = when (this) {
173
+ is Int -> toDouble()
174
+ is Long -> toDouble()
175
+ else -> this as Double
176
+ }
177
+
173
178
  fun Any?.toColor() = "#" + toLong().toString(16)
174
179
 
175
180
  fun Any?.toFloat() =
@@ -10,13 +10,13 @@ android {
10
10
 
11
11
  repositories {
12
12
  maven {
13
- url "https://maven.regulaforensics.com/RegulaDocumentReader"
13
+ url "https://maven.regulaforensics.com/RegulaDocumentReader/Nightly"
14
14
  }
15
15
  }
16
16
 
17
17
  dependencies {
18
18
  //noinspection GradleDependency
19
- implementation ('com.regula.documentreader:api:7.1.9667'){
19
+ implementation ('com.regula.documentreader:api:7.3.10996'){
20
20
  transitive = true
21
21
  }
22
22
  }
@@ -53,8 +53,8 @@
53
53
  functionality.orientation = [self interfaceOrientationMaskWithNumber:[options valueForKey:@"orientation"]];
54
54
  if([options valueForKey:@"captureMode"] != nil)
55
55
  functionality.captureMode = [[options valueForKey:@"captureMode"] integerValue];
56
- if([options valueForKey:@"cameraPosition"] != nil)
57
- functionality.cameraPosition = [self captureDevicePositionWithNumber:[options valueForKey:@"cameraPosition"]];
56
+ if(options[@"cameraPositionIOS"])
57
+ functionality.cameraPosition = [options[@"cameraPositionIOS"] integerValue];
58
58
 
59
59
  // String
60
60
  if([options valueForKey:@"cameraFrame"] != nil)
@@ -105,7 +105,7 @@
105
105
  result[@"forcePagesCount"] = functionality.forcePagesCount;
106
106
  result[@"orientation"] = [self generateInterfaceOrientationMask:functionality.orientation];
107
107
  result[@"captureMode"] = [NSNumber numberWithInteger:functionality.captureMode];
108
- result[@"cameraPosition"] = [self generateCaptureDevicePosition:functionality.cameraPosition];
108
+ result[@"cameraPositionIOS"] = @(functionality.cameraPosition);
109
109
 
110
110
  // String
111
111
  result[@"cameraFrame"] = [self generateDocReaderFrame:functionality.cameraFrame];
@@ -641,6 +641,8 @@
641
641
  rfidScenario.applyAmendments = [[options valueForKey:@"applyAmendments"] boolValue];
642
642
  if([options valueForKey:@"autoSettings"] != nil)
643
643
  rfidScenario.autoSettings = [[options valueForKey:@"autoSettings"] boolValue];
644
+ if([options valueForKey:@"proceedReadingAlways"] != nil)
645
+ rfidScenario.proceedReadingAlways = [[options valueForKey:@"proceedReadingAlways"] boolValue];
644
646
 
645
647
  // Int
646
648
  if([options valueForKey:@"signManagementAction"] != nil)
@@ -722,6 +724,7 @@
722
724
  result[@"authorizedInstallQCert"] = [NSNumber numberWithBool:rfidScenario.authorizedInstallQCert];
723
725
  result[@"applyAmendments"] = [NSNumber numberWithBool:rfidScenario.applyAmendments];
724
726
  result[@"autoSettings"] = [NSNumber numberWithBool:rfidScenario.autoSettings];
727
+ result[@"proceedReadingAlways"] = [NSNumber numberWithBool:rfidScenario.proceedReadingAlways];
725
728
 
726
729
  // Int
727
730
  result[@"signManagementAction"] = [NSNumber numberWithInteger:rfidScenario.signManagementAction];
@@ -861,10 +864,9 @@
861
864
  result.colornessCheck = [input valueForKey:@"colornessCheck"];
862
865
  if([input valueForKey:@"screenCapture"] != nil)
863
866
  result.screenCapture = [input valueForKey:@"screenCapture"];
864
- if([input valueForKey:@"expectedPass"] != nil){
865
- NSMutableArray<RGLImageQualityCheckType> *expectedPass = [NSMutableArray new];
866
- for(NSString* str in [input valueForKey:@"expectedPass"])
867
- [expectedPass addObject:str];
867
+ if (input[@"expectedPass"]) {
868
+ NSMutableArray<RGLImageQualityCheckType>* expectedPass = @[].mutableCopy;
869
+ for(NSNumber* item in input[@"expectedPass"]) [expectedPass addObject:[self imageQualityCheckTypeWithNumber:item]];
868
870
  result.expectedPass = expectedPass;
869
871
  }
870
872
  if([input valueForKey:@"documentPositionIndent"] != nil)
@@ -884,7 +886,11 @@
884
886
  result[@"glaresCheck"] = input.glaresCheck;
885
887
  result[@"colornessCheck"] = input.colornessCheck;
886
888
  result[@"screenCapture"] = input.screenCapture;
887
- result[@"expectedPass"] = input.expectedPass;
889
+ if (input.expectedPass) {
890
+ NSMutableArray<NSNumber*>* expectedPass = @[].mutableCopy;
891
+ for(RGLImageQualityCheckType item in input.expectedPass) [expectedPass addObject:[self generateImageQualityCheckType:item]];
892
+ result[@"expectedPass"] = expectedPass;
893
+ }
888
894
  result[@"documentPositionIndent"] = input.documentPositionIndent;
889
895
  result[@"glaresCheckParams"] = [RGLWJSONConstructor generateGlaresCheckParams:input.glaresCheckParams];
890
896
  result[@"brightnessThreshold"] = input.brightnessThreshold;
@@ -1172,39 +1178,20 @@
1172
1178
 
1173
1179
  +(UIInterfaceOrientationMask)interfaceOrientationMaskWithNumber:(NSNumber*)value {
1174
1180
  int input = [value intValue];
1175
- if(input == 0) return UIInterfaceOrientationMaskPortrait;
1176
- if(input == 1) return UIInterfaceOrientationMaskLandscapeLeft;
1177
- if(input == 2) return UIInterfaceOrientationMaskLandscapeRight;
1178
- if(input == 3) return UIInterfaceOrientationMaskPortraitUpsideDown;
1179
- if(input == 4) return UIInterfaceOrientationMaskLandscape;
1180
- if(input == 5) return UIInterfaceOrientationMaskAll;
1181
- if(input == 6) return UIInterfaceOrientationMaskAllButUpsideDown;
1181
+ if(input == 0) return UIInterfaceOrientationMaskAll;
1182
+ if(input == 1) return UIInterfaceOrientationMaskPortrait;
1183
+ if(input == 2) return UIInterfaceOrientationMaskLandscape;
1184
+ if(input == 3) return UIInterfaceOrientationMaskLandscapeLeft;
1185
+ if(input == 4) return UIInterfaceOrientationMaskLandscapeRight;
1182
1186
  return UIInterfaceOrientationMaskPortrait;
1183
1187
  }
1184
1188
 
1185
1189
  +(NSNumber*)generateInterfaceOrientationMask:(UIInterfaceOrientationMask)value {
1186
- if(value == UIInterfaceOrientationMaskPortrait) return @0;
1187
- if(value == UIInterfaceOrientationMaskLandscapeLeft) return @1;
1188
- if(value == UIInterfaceOrientationMaskLandscapeRight) return @2;
1189
- if(value == UIInterfaceOrientationMaskPortraitUpsideDown) return @3;
1190
- if(value == UIInterfaceOrientationMaskLandscape) return @4;
1191
- if(value == UIInterfaceOrientationMaskAll) return @5;
1192
- if(value == UIInterfaceOrientationMaskAllButUpsideDown) return @6;
1193
- return @0;
1194
- }
1195
-
1196
- +(AVCaptureDevicePosition)captureDevicePositionWithNumber:(NSNumber*)value {
1197
- int input = [value intValue];
1198
- if(input == 0) return AVCaptureDevicePositionUnspecified;
1199
- if(input == 1) return AVCaptureDevicePositionBack;
1200
- if(input == 2) return AVCaptureDevicePositionFront;
1201
- return AVCaptureDevicePositionUnspecified;
1202
- }
1203
-
1204
- +(NSNumber*)generateCaptureDevicePosition:(AVCaptureDevicePosition)value {
1205
- if(value == AVCaptureDevicePositionUnspecified) return @0;
1206
- if(value == AVCaptureDevicePositionBack) return @1;
1207
- if(value == AVCaptureDevicePositionFront) return @2;
1190
+ if(value == UIInterfaceOrientationMaskAll) return @0;
1191
+ if(value == UIInterfaceOrientationMaskPortrait) return @1;
1192
+ if(value == UIInterfaceOrientationMaskLandscape) return @2;
1193
+ if(value == UIInterfaceOrientationMaskLandscapeLeft) return @3;
1194
+ if(value == UIInterfaceOrientationMaskLandscapeRight) return @4;
1208
1195
  return @0;
1209
1196
  }
1210
1197
 
@@ -11,11 +11,11 @@ typedef void (^RGLWEventSender)(NSString* _Nonnull event, id _Nullable data);
11
11
  typedef void (^RGLWRFIDSignatureCallback)(NSData * _Nonnull signature);
12
12
 
13
13
  @interface RGLWDocumentReader : CDVPlugin<RGLRecordScanningProcessDelegate,
14
- RGLDocReaderRFIDDelegate,
15
- RGLCustomizationActionDelegate>
14
+ RGLDocReaderRFIDDelegate,
15
+ RGLCustomizationActionDelegate,
16
+ RGLDocReaderDatabaseFetchDelegate>
16
17
 
17
18
  @property (class) CDVInvokedUrlCommand* _Nullable command;
18
- @property (class) NSNumber* _Nullable databasePercentageDownloaded;
19
19
  @property NSNumber* _Nonnull doRequestPACertificates;
20
20
  @property NSNumber* _Nonnull doRequestTACertificates;
21
21
  @property NSNumber* _Nonnull doRequestTASignature;
@@ -71,8 +71,6 @@ RGLWEventSender sendEvent = ^(NSString* _Nonnull event, id _Nullable data) {
71
71
  [self resetConfiguration :successCallback :errorCallback];
72
72
  else if([action isEqualToString:@"initializeReader"])
73
73
  [self initializeReader :[args objectAtIndex:0] :successCallback :errorCallback];
74
- else if([action isEqualToString:@"initializeReaderAutomatically"])
75
- [self initializeReaderAutomatically :successCallback :errorCallback];
76
74
  else if([action isEqualToString:@"initializeReaderWithBleDeviceConfig"])
77
75
  [self initializeReaderWithBleDeviceConfig :[args objectAtIndex:0] :successCallback :errorCallback];
78
76
  else if([action isEqualToString:@"deinitializeReader"])
@@ -163,18 +161,14 @@ RGLWEventSender sendEvent = ^(NSString* _Nonnull event, id _Nullable data) {
163
161
  [self containers :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
164
162
  else if([action isEqualToString:@"encryptedContainers"])
165
163
  [self encryptedContainers :[args objectAtIndex:0] :successCallback :errorCallback];
166
- else if([action isEqualToString:@"getTranslation"])
167
- [self getTranslation :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
168
164
  else if([action isEqualToString:@"finalizePackage"])
169
165
  [self finalizePackage :successCallback :errorCallback];
166
+ else if([action isEqualToString:@"getTranslation"])
167
+ [self getTranslation :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
170
168
  else
171
169
  errorCallback([NSString stringWithFormat:@"%@/%@", @"method not implemented: ", action]);
172
170
  }
173
171
 
174
- static NSNumber * _databasePercentageDownloaded;
175
- + (NSNumber*)databasePercentageDownloaded{ return _databasePercentageDownloaded; }
176
- + (void)setDatabasePercentageDownloaded:(NSNumber *)value { _databasePercentageDownloaded = value; }
177
-
178
172
  NSString* RGLWCompletionEvent = @"completion";
179
173
  NSString* RGLWDatabaseProgressEvent = @"database_progress";
180
174
 
@@ -265,20 +259,12 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
265
259
  RGLDocReader.shared.processParams = [RGLProcessParams new];
266
260
  RGLDocReader.shared.customization = [RGLCustomization new];
267
261
  RGLDocReader.shared.rfidScenario = [RGLRFIDScenario new];
268
- RGLDocReader.shared.functionality.recordScanningProcessDelegate = self;
269
- RGLDocReader.shared.customization.actionDelegate = self;
270
262
  }
271
263
 
272
264
  - (void) initializeReader:(NSDictionary*)config :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
273
265
  [RGLDocReader.shared initializeReaderWithConfig:[RGLWJSONConstructor configFromJson:config] completion:[self getInitCompletion :successCallback :errorCallback]];
274
266
  }
275
267
 
276
- - (void) initializeReaderAutomatically:(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
277
- NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"regula.license" ofType:nil];
278
- NSData *licenseData = [NSData dataWithContentsOfFile:dataPath];
279
- [RGLDocReader.shared initializeReaderWithConfig:[RGLConfig configWithLicenseData:licenseData] completion:[self getInitCompletion :successCallback :errorCallback]];
280
- }
281
-
282
268
  - (void) initializeReaderWithBleDeviceConfig:(NSDictionary*)config :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
283
269
  errorCallback(@"initializeReaderWithBleDeviceConfig() is an android-only method");
284
270
  }
@@ -289,7 +275,7 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
289
275
  }
290
276
 
291
277
  - (void) prepareDatabase:(NSString*)databaseID :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
292
- [RGLDocReader.shared prepareDatabase:databaseID progressHandler:[self getProgressHandler] completion:[self getPrepareCompletion :successCallback :errorCallback]];
278
+ [RGLDocReader.shared prepareDatabase:databaseID progressHandler:nil completion:[self getPrepareCompletion :successCallback :errorCallback]];
293
279
  }
294
280
 
295
281
  - (void) removeDatabase:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
@@ -299,7 +285,7 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
299
285
  }
300
286
 
301
287
  -(void) runAutoUpdate:(NSString*)databaseID :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
302
- [RGLDocReader.shared runAutoUpdate:databaseID progressHandler:[self getProgressHandler] completion:[self getPrepareCompletion :successCallback :errorCallback]];
288
+ [RGLDocReader.shared runAutoUpdate:databaseID progressHandler:nil completion:[self getPrepareCompletion :successCallback :errorCallback]];
303
289
  }
304
290
 
305
291
  - (void) cancelDBUpdate:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
@@ -593,20 +579,12 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
593
579
  }
594
580
 
595
581
  -(RGLDocumentReaderPrepareCompletion _Nonnull)getPrepareCompletion:(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
582
+ RGLDocReader.shared.databaseFetchDelegate = self;
596
583
  return ^(BOOL success, NSError * _Nullable error) {
597
584
  successCallback([RGLWJSONConstructor generateSuccessCompletion:success :error]);
598
585
  };
599
586
  }
600
587
 
601
- -(void (^_Nullable)(NSProgress * _Nonnull progress))getProgressHandler {
602
- return ^(NSProgress * _Nonnull progress) {
603
- if(RGLWDocumentReader.databasePercentageDownloaded != [NSNumber numberWithDouble:progress.fractionCompleted * 100]){
604
- sendEvent(RGLWDatabaseProgressEvent, [NSNumber numberWithInt:(int)(progress.fractionCompleted * 100)]);
605
- [RGLWDocumentReader setDatabasePercentageDownloaded:[NSNumber numberWithDouble:progress.fractionCompleted * 100]];
606
- }
607
- };
608
- }
609
-
610
588
  -(RGLDocumentReaderInitializationCompletion)getInitCompletion:(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
611
589
  return ^(BOOL success, NSError * _Nullable error ) {
612
590
  if (success) {
@@ -618,9 +596,24 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
618
596
  };
619
597
  }
620
598
 
599
+ // RGLDocReaderDatabaseFetchDelegate
600
+ - (void)onProgressChanged:(NSNumber *)downloadedBytes totalBytes:(NSNumber *)totalBytes {
601
+ int progress = 0;
602
+ if (downloadedBytes > 0 && totalBytes > 0) {
603
+ double percent = [downloadedBytes doubleValue] / [totalBytes doubleValue];
604
+ progress = (int) (percent * 100);
605
+ }
606
+ NSDictionary* result = @{
607
+ @"downloadedBytes":downloadedBytes,
608
+ @"totalBytes":totalBytes,
609
+ @"progress":@(progress)
610
+ };
611
+ sendEvent(RGLWDatabaseProgressEvent, [RGLWJSONConstructor dictToString: result]);
612
+ }
613
+
621
614
  // RGLCustomizationActionDelegate
622
615
  - (void)onCustomButtonTappedWithTag:(NSInteger)tag {
623
- sendEvent(RGLWOnCustomButtonTappedEvent, [NSNumber numberWithInteger:tag]);
616
+ sendEvent(RGLWOnCustomButtonTappedEvent, @(tag));
624
617
  }
625
618
 
626
619
  // RGLRecordScanningProcessDelegate