@regulaforensics/react-native-document-reader-api 7.1.0 → 7.2.1

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.
@@ -14,6 +14,6 @@ Pod::Spec.new do |s|
14
14
  s.source = { :http => 'file:' + __dir__ }
15
15
  s.ios.deployment_target = '11.0'
16
16
  s.source_files = "ios/*.{h,m}"
17
- s.dependency 'DocumentReader', '7.1.3379'
17
+ s.dependency 'DocumentReader', '7.2.3545'
18
18
  s.dependency 'React'
19
19
  end
@@ -41,7 +41,7 @@ dependencies {
41
41
  //noinspection GradleDynamicVersion
42
42
  implementation 'com.facebook.react:react-native:+'
43
43
  //noinspection GradleDependency
44
- implementation('com.regula.documentreader:api:7.1.9667') {
44
+ implementation('com.regula.documentreader:api:7.2.9835') {
45
45
  transitive = true
46
46
  }
47
47
  }
@@ -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
  }
@@ -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 com.regula.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))
@@ -998,9 +1009,8 @@ fun generateImageQualityGroup(temp: ImageQualityGroup?): JSONObject? {
998
1009
  }
999
1010
 
1000
1011
  fun cameraSizeFromJSON(input: JSONObject): Pair<Int, Int> {
1001
- val cameraSize = input.getJSONObject("cameraSize")
1002
- val width = cameraSize.getInt("width")
1003
- val height = cameraSize.getInt("height")
1012
+ val width = input.getInt("width")
1013
+ val height = input.getInt("height")
1004
1014
  return Pair(width, height)
1005
1015
  }
1006
1016
 
@@ -1962,7 +1972,7 @@ fun generateDocReaderDocumentsDatabase(temp: DocReaderDocumentsDatabase?): JSONO
1962
1972
  result.put("databaseDescription", input.databaseDescription)
1963
1973
  result.put("countriesNumber", input.countriesNumber)
1964
1974
  result.put("documentsNumber", input.documentsNumber)
1965
- result.put("size", input.size as Long?)
1975
+ result.put("size", input.size)
1966
1976
 
1967
1977
  return result
1968
1978
  }
@@ -27,7 +27,8 @@ import com.regula.documentreader.Convert.byteArrayFromBase64
27
27
  import com.regula.documentreader.api.DocumentReader.Instance
28
28
  import com.regula.documentreader.api.completions.IDocumentReaderCompletion
29
29
  import com.regula.documentreader.api.completions.IDocumentReaderInitCompletion
30
- import com.regula.documentreader.api.completions.IDocumentReaderPrepareCompletion
30
+ import com.regula.documentreader.api.completions.IDocumentReaderPrepareDbCompletion
31
+ import com.regula.documentreader.api.completions.model.PrepareProgress
31
32
  import com.regula.documentreader.api.completions.rfid.IRfidPKDCertificateCompletion
32
33
  import com.regula.documentreader.api.completions.rfid.IRfidReaderCompletion
33
34
  import com.regula.documentreader.api.completions.rfid.IRfidReaderRequest
@@ -89,6 +90,7 @@ fun <T> argsNullable(index: Int): T? {
89
90
  val intValue = value.toInt()
90
91
  return intValue as T
91
92
  }
93
+ if (args[index].toString() == "null") return null
92
94
  return args[index] as T
93
95
  }
94
96
 
@@ -121,6 +123,7 @@ fun exec(action: String?, arguments: ReadableArray, successCallback: com.faceboo
121
123
  "setCustomization" -> setCustomization(args(0))
122
124
  "getRfidScenario" -> getRfidScenario(callback)
123
125
  "setRfidScenario" -> setRfidScenario(args(0))
126
+ "resetConfiguration" -> resetConfiguration()
124
127
  "initializeReader" -> initializeReader(callback, args(0))
125
128
  "initializeReaderWithBleDeviceConfig" -> initializeReaderWithBleDeviceConfig(callback, args(0))
126
129
  "deinitializeReader" -> deinitializeReader(callback)
@@ -134,8 +137,8 @@ fun exec(action: String?, arguments: ReadableArray, successCallback: com.faceboo
134
137
  "startNewPage" -> startNewPage(callback)
135
138
  "stopScanner" -> stopScanner(callback)
136
139
  "startRFIDReader" -> startRFIDReader(args(0), args(1), args(2))
137
- "stopRFIDReader" -> stopRFIDReader(callback)
138
140
  "readRFID" -> readRFID(args(0), args(1), args(2))
141
+ "stopRFIDReader" -> stopRFIDReader(callback)
139
142
  "providePACertificates" -> providePACertificates(callback, argsNullable(0))
140
143
  "provideTACertificates" -> provideTACertificates(callback, argsNullable(0))
141
144
  "provideTASignature" -> provideTASignature(callback, args(0))
@@ -167,12 +170,12 @@ fun exec(action: String?, arguments: ReadableArray, successCallback: com.faceboo
167
170
  "graphicFieldImageByTypeSourcePageIndexLight" -> graphicFieldImageByTypeSourcePageIndexLight(callback, args(0), args(1), args(2), args(3), args(4))
168
171
  "containers" -> containers(callback, args(0), args(1))
169
172
  "encryptedContainers" -> encryptedContainers(callback, args(0))
170
- "getTranslation" -> getTranslation(callback, args(0), args(1))
171
173
  "finalizePackage" -> finalizePackage(callback)
174
+ "getTranslation" -> getTranslation(callback, args(0), args(1))
172
175
  }
173
176
  }
174
177
 
175
- fun <T> args(index: Int): T = argsNullable(index)!!
178
+ inline fun <reified T> args(index: Int) = argsNullable<T>(index)!!
176
179
  interface Callback {
177
180
  fun success(data: Any? = "")
178
181
  fun error(message: String)
@@ -237,6 +240,8 @@ fun getRfidScenario(callback: Callback) = callback.success(getRfidScenario(Insta
237
240
 
238
241
  fun setRfidScenario(rfidScenario: JSONObject) = setRfidScenario(Instance().rfidScenario(), rfidScenario)
239
242
 
243
+ fun resetConfiguration() = Instance().resetConfiguration()
244
+
240
245
  fun initializeReader(callback: Callback, config: JSONObject) = Instance().initializeReader(context, docReaderConfigFromJSON(config), getInitCompletion(callback))
241
246
 
242
247
  fun initializeReaderWithBleDeviceConfig(callback: Callback, config: JSONObject) = Instance().initializeReader(context, bleDeviceConfigFromJSON(config), getInitCompletion(callback))
@@ -344,9 +349,8 @@ fun startBluetoothService() = startBluetoothService(
344
349
  { sendEvent(bleOnDeviceReadyEvent) }
345
350
  )
346
351
 
347
- @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
348
352
  fun setLocalizationDictionary(dictionary: JSONObject) {
349
- localizationCallbacks = LocalizationCallbacks { dictionary.optString(it, null) }
353
+ localizationCallbacks = LocalizationCallbacks { if (dictionary.has(it)) dictionary.getString(it) else null }
350
354
  Instance().setLocalizationCallback(localizationCallbacks!!)
351
355
  }
352
356
 
@@ -427,15 +431,9 @@ val rfidReaderCompletion = object : IRfidReaderCompletion() {
427
431
  override fun onProgress(notification: DocumentReaderNotification) = sendEvent(rfidOnProgressEvent, generateDocumentReaderNotification(notification))
428
432
  }
429
433
 
430
- fun getPrepareCompletion(callback: Callback) = object : IDocumentReaderPrepareCompletion {
431
- override fun onPrepareProgressChanged(progress: Int) {
432
- if (progress != databaseDownloadProgress) {
433
- sendEvent(eventDatabaseProgress, progress)
434
- databaseDownloadProgress = progress
435
- }
436
- }
437
-
438
- override fun onPrepareCompleted(s: Boolean, e: DocumentReaderException?) = callback.success(generateSuccessCompletion(s, e))
434
+ fun getPrepareCompletion(callback: Callback) = object : IDocumentReaderPrepareDbCompletion() {
435
+ override fun onPrepareProgressChanged(progress: PrepareProgress) = sendEvent(eventDatabaseProgress, generatePrepareProgress(progress))
436
+ override fun onPrepareCompleted(success: Boolean, error: DocumentReaderException?) = callback.success(generateSuccessCompletion(success, error))
439
437
  }
440
438
 
441
439
  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("UNCHECKED_CAST")
9
8
 
10
9
  package com.regula.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() =
package/example/App.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { SafeAreaView, ScrollView, StyleSheet, Text, View, NativeEventEmitter, Platform, TouchableOpacity, Image, Button } from 'react-native'
3
- import DocumentReader, { Enum, DocumentReaderCompletion, DocumentReaderScenario, RNRegulaDocumentReader, DocumentReaderResults, DocumentReaderNotification, ScannerConfig, RecognizeConfig, DocReaderConfig } from '@regulaforensics/react-native-document-reader-api'
3
+ import DocumentReader, { Enum, DocumentReaderCompletion, DocumentReaderScenario, RNRegulaDocumentReader, DocumentReaderResults, DocumentReaderNotification, ScannerConfig, RecognizeConfig, DocReaderConfig, Functionality } from '@regulaforensics/react-native-document-reader-api'
4
4
  import * as RNFS from 'react-native-fs'
5
5
  import RadioGroup, { RadioButtonProps } from 'react-native-radio-buttons-group'
6
6
  import { CheckBox } from '@rneui/themed'
@@ -33,9 +33,9 @@ export default class App extends React.Component<IProps, IState> {
33
33
  onInitialized() {
34
34
  this.setState({ fullName: "Ready" })
35
35
 
36
- DocumentReader.setFunctionality({
37
- showCaptureButton: true
38
- }, _ => { }, _ => { })
36
+ var functionality = new Functionality()
37
+ functionality.showCaptureButton = true
38
+ DocumentReader.setFunctionality(functionality, _ => { }, _ => { })
39
39
  }
40
40
 
41
41
  constructor(props: {} | Readonly<{}>) {
@@ -103,7 +103,7 @@ export default class App extends React.Component<IProps, IState> {
103
103
  this.hideRfidUI()
104
104
  this.displayResults(completion.results!)
105
105
  }
106
- } else if (this.actionSuccess(completion.action!))
106
+ } else if (this.actionSuccess(completion.action!) || this.actionError(completion.action!))
107
107
  this.handleResults(completion.results!)
108
108
  }
109
109
 
@@ -41,4 +41,4 @@ newArchEnabled=false
41
41
 
42
42
  # Use this property to enable or disable the Hermes JS engine.
43
43
  # If set to false, you will be using JSC instead.
44
- hermesEnabled=true
44
+ hermesEnabled=false
@@ -8,17 +8,6 @@ require Pod::Executable.execute_command('node', ['-p',
8
8
  platform :ios, min_ios_version_supported
9
9
  prepare_react_native_project!
10
10
 
11
- # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
12
- # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
13
- #
14
- # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
15
- # ```js
16
- # module.exports = {
17
- # dependencies: {
18
- # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
19
- # ```
20
- flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
21
-
22
11
  linkage = ENV['USE_FRAMEWORKS']
23
12
  if linkage != nil
24
13
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
@@ -33,21 +22,14 @@ target 'DocumentReader' do
33
22
 
34
23
  use_react_native!(
35
24
  :path => config[:reactNativePath],
36
- # Hermes is now enabled by default. Disable by setting this flag to false.
37
- :hermes_enabled => flags[:hermes_enabled],
25
+ :hermes_enabled => false,
38
26
  :fabric_enabled => flags[:fabric_enabled],
39
- # Enables Flipper.
40
- #
41
- # Note that if you have use_frameworks! enabled, Flipper will not work and
42
- # you should disable the next line.
43
- :flipper_configuration => flipper_config,
44
- # An absolute path to your application root.
27
+ :flipper_configuration => FlipperConfiguration.disabled,
45
28
  :app_path => "#{Pod::Config.instance.installation_root}/.."
46
29
  )
47
30
 
48
31
  target 'DocumentReaderTests' do
49
32
  inherit! :complete
50
- # Pods for testing
51
33
  end
52
34
 
53
35
  post_install do |installer|