Skip to content

Commit dad52f0

Browse files
author
Jenkins
committed
7.2.0
1 parent 1b054ca commit dad52f0

19 files changed

Lines changed: 3151 additions & 1818 deletions

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', '7.1.3379'
17+
s.dependency 'DocumentReader', '7.2.3545'
1818
s.dependency 'React'
1919
end

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies {
4141
//noinspection GradleDynamicVersion
4242
implementation 'com.facebook.react:react-native:+'
4343
//noinspection GradleDependency
44-
implementation('com.regula.documentreader:api:7.1.9667') {
44+
implementation('com.regula.documentreader:api:7.2.9835') {
4545
transitive = true
4646
}
4747
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fun setFunctionality(functionality: Functionality, opts: JSONObject) = opts.forE
5555
"showCaptureButtonDelayFromStart" -> editor.setShowCaptureButtonDelayFromStart(v.toLong())
5656
"orientation" -> editor.setOrientation(v.toInt())
5757
"captureMode" -> editor.setCaptureMode(v.toInt())
58-
"cameraPosition" -> editor.setCameraMode(v.toInt())
58+
"cameraMode" -> editor.setCameraMode(v.toInt())
5959
"rfidTimeout" -> editor.setRfidTimeout(v.toInt())
6060
"forcePagesCount" -> editor.setForcePagesCount(v.toInt())
6161
"cameraFrame" -> editor.setCameraFrame(v as String)
@@ -88,7 +88,7 @@ fun getFunctionality(functionality: Functionality) = mapOf(
8888
"showCaptureButtonDelayFromStart" to functionality.showCaptureButtonDelayFromStart,
8989
"orientation" to functionality.orientation,
9090
"captureMode" to functionality.captureMode,
91-
"cameraPosition" to functionality.cameraMode,
91+
"cameraMode" to functionality.cameraMode,
9292
"rfidTimeout" to functionality.rfidTimeout,
9393
"forcePagesCount" to functionality.forcePagesCount,
9494
"cameraFrame" to functionality.cameraFrame,
@@ -150,10 +150,10 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
150150
"scenario" -> processParams.scenario = v as String
151151
"captureButtonScenario" -> processParams.captureButtonScenario = v as String
152152
"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()
157157
"documentIDList" -> processParams.documentIDList = v.toIntArray()
158158
"fieldTypesFilter" -> processParams.fieldTypesFilter = v.toIntArray()
159159
"resultTypeOutput" -> processParams.resultTypeOutput = v.toIntArray()
@@ -412,6 +412,7 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
412412
"authorizedInstallQCert" -> rfidScenario.isAuthorizedInstallQCert = v as Boolean
413413
"applyAmendments" -> rfidScenario.isApplyAmendments = v as Boolean
414414
"autoSettings" -> rfidScenario.isAutoSettings = v as Boolean
415+
"proceedReadingAlways" -> rfidScenario.proceedReadingAlways = v as Boolean
415416
"signManagementAction" -> rfidScenario.signManagementAction = v.toInt()
416417
"readingBuffer" -> rfidScenario.readingBuffer = v.toInt()
417418
"onlineTAToSignDataType" -> rfidScenario.onlineTAToSignDataType = v.toInt()
@@ -467,6 +468,7 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
467468
"authorizedInstallQCert" to rfidScenario.isAuthorizedInstallQCert,
468469
"applyAmendments" to rfidScenario.isApplyAmendments,
469470
"autoSettings" to rfidScenario.isAutoSettings,
471+
"proceedReadingAlways" to rfidScenario.proceedReadingAlways,
470472
"signManagementAction" to rfidScenario.signManagementAction,
471473
"readingBuffer" to rfidScenario.readingBuffer,
472474
"onlineTAToSignDataType" to rfidScenario.onlineTAToSignDataType,
@@ -562,7 +564,7 @@ fun setImageQA(input: ImageQA, opts: JSONObject) = opts.forEach { k, v ->
562564
"dpiThreshold" -> input.dpiThreshold = v.toInt()
563565
"angleThreshold" -> input.angleThreshold = v.toInt()
564566
"documentPositionIndent" -> input.documentPositionIndent = v.toInt()
565-
"brightnessThreshold" -> input.brightnessThreshold = v as Double
567+
"brightnessThreshold" -> input.brightnessThreshold = v.toDouble()
566568
"expectedPass" -> input.expectedPass = v.toIntArray()
567569
"glaresCheckParams" -> input.glaresCheckParams = glaresCheckParamsFromJSON(v as JSONObject)
568570
}

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Created by Pavel Masiuk on 21.09.2023.
66
// Copyright © 2023 Regula. All rights reserved.
77
//
8-
@file:Suppress("USELESS_CAST")
98

109
package com.regula.documentreader
1110

@@ -16,6 +15,7 @@ import android.graphics.Typeface
1615
import android.util.Pair
1716
import com.regula.common.exception.RegulaException
1817
import com.regula.documentreader.api.License
18+
import com.regula.documentreader.api.completions.model.PrepareProgress
1919
import com.regula.documentreader.api.config.RecognizeConfig
2020
import com.regula.documentreader.api.config.ScannerConfig
2121
import com.regula.documentreader.api.enums.BarcodeType
@@ -123,6 +123,17 @@ fun generateSuccessCompletion(success: Boolean, error: RegulaException?) = objec
123123
}
124124
}
125125

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+
126137
fun generatePACertificateCompletion(serialNumber: ByteArray?, issuer: PAResourcesIssuer?) = object : JSONObject() { init {
127138
put("serialNumber", generateByteArray(serialNumber))
128139
put("issuer", generatePAResourcesIssuer(issuer))
@@ -998,9 +1009,8 @@ fun generateImageQualityGroup(temp: ImageQualityGroup?): JSONObject? {
9981009
}
9991010

10001011
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")
10041014
return Pair(width, height)
10051015
}
10061016

@@ -1962,7 +1972,7 @@ fun generateDocReaderDocumentsDatabase(temp: DocReaderDocumentsDatabase?): JSONO
19621972
result.put("databaseDescription", input.databaseDescription)
19631973
result.put("countriesNumber", input.countriesNumber)
19641974
result.put("documentsNumber", input.documentsNumber)
1965-
result.put("size", input.size as Long?)
1975+
result.put("size", input.size)
19661976

19671977
return result
19681978
}

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import com.regula.documentreader.Convert.byteArrayFromBase64
2727
import com.regula.documentreader.api.DocumentReader.Instance
2828
import com.regula.documentreader.api.completions.IDocumentReaderCompletion
2929
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
3132
import com.regula.documentreader.api.completions.rfid.IRfidPKDCertificateCompletion
3233
import com.regula.documentreader.api.completions.rfid.IRfidReaderCompletion
3334
import com.regula.documentreader.api.completions.rfid.IRfidReaderRequest
@@ -89,6 +90,7 @@ fun <T> argsNullable(index: Int): T? {
8990
val intValue = value.toInt()
9091
return intValue as T
9192
}
93+
if (args[index].toString() == "null") return null
9294
return args[index] as T
9395
}
9496

@@ -121,6 +123,7 @@ fun exec(action: String?, arguments: ReadableArray, successCallback: com.faceboo
121123
"setCustomization" -> setCustomization(args(0))
122124
"getRfidScenario" -> getRfidScenario(callback)
123125
"setRfidScenario" -> setRfidScenario(args(0))
126+
"resetConfiguration" -> resetConfiguration()
124127
"initializeReader" -> initializeReader(callback, args(0))
125128
"initializeReaderWithBleDeviceConfig" -> initializeReaderWithBleDeviceConfig(callback, args(0))
126129
"deinitializeReader" -> deinitializeReader(callback)
@@ -134,8 +137,8 @@ fun exec(action: String?, arguments: ReadableArray, successCallback: com.faceboo
134137
"startNewPage" -> startNewPage(callback)
135138
"stopScanner" -> stopScanner(callback)
136139
"startRFIDReader" -> startRFIDReader(args(0), args(1), args(2))
137-
"stopRFIDReader" -> stopRFIDReader(callback)
138140
"readRFID" -> readRFID(args(0), args(1), args(2))
141+
"stopRFIDReader" -> stopRFIDReader(callback)
139142
"providePACertificates" -> providePACertificates(callback, argsNullable(0))
140143
"provideTACertificates" -> provideTACertificates(callback, argsNullable(0))
141144
"provideTASignature" -> provideTASignature(callback, args(0))
@@ -167,12 +170,12 @@ fun exec(action: String?, arguments: ReadableArray, successCallback: com.faceboo
167170
"graphicFieldImageByTypeSourcePageIndexLight" -> graphicFieldImageByTypeSourcePageIndexLight(callback, args(0), args(1), args(2), args(3), args(4))
168171
"containers" -> containers(callback, args(0), args(1))
169172
"encryptedContainers" -> encryptedContainers(callback, args(0))
170-
"getTranslation" -> getTranslation(callback, args(0), args(1))
171173
"finalizePackage" -> finalizePackage(callback)
174+
"getTranslation" -> getTranslation(callback, args(0), args(1))
172175
}
173176
}
174177

175-
fun <T> args(index: Int): T = argsNullable(index)!!
178+
inline fun <reified T> args(index: Int) = argsNullable<T>(index)!!
176179
interface Callback {
177180
fun success(data: Any? = "")
178181
fun error(message: String)
@@ -237,6 +240,8 @@ fun getRfidScenario(callback: Callback) = callback.success(getRfidScenario(Insta
237240

238241
fun setRfidScenario(rfidScenario: JSONObject) = setRfidScenario(Instance().rfidScenario(), rfidScenario)
239242

243+
fun resetConfiguration() = Instance().resetConfiguration()
244+
240245
fun initializeReader(callback: Callback, config: JSONObject) = Instance().initializeReader(context, docReaderConfigFromJSON(config), getInitCompletion(callback))
241246

242247
fun initializeReaderWithBleDeviceConfig(callback: Callback, config: JSONObject) = Instance().initializeReader(context, bleDeviceConfigFromJSON(config), getInitCompletion(callback))
@@ -344,9 +349,8 @@ fun startBluetoothService() = startBluetoothService(
344349
{ sendEvent(bleOnDeviceReadyEvent) }
345350
)
346351

347-
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
348352
fun setLocalizationDictionary(dictionary: JSONObject) {
349-
localizationCallbacks = LocalizationCallbacks { dictionary.optString(it, null) }
353+
localizationCallbacks = LocalizationCallbacks { if (dictionary.has(it)) dictionary.getString(it) else null }
350354
Instance().setLocalizationCallback(localizationCallbacks!!)
351355
}
352356

@@ -427,15 +431,9 @@ val rfidReaderCompletion = object : IRfidReaderCompletion() {
427431
override fun onProgress(notification: DocumentReaderNotification) = sendEvent(rfidOnProgressEvent, generateDocumentReaderNotification(notification))
428432
}
429433

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))
439437
}
440438

441439
fun getInitCompletion(callback: Callback) = IDocumentReaderInitCompletion { success, error ->

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Created by Pavel Masiuk on 21.09.2023.
66
// Copyright © 2023 Regula. All rights reserved.
77
//
8-
@file:Suppress("UNCHECKED_CAST")
98

109
package com.regula.documentreader
1110

@@ -31,27 +30,26 @@ fun Any?.toSendable(): Any? = this?.let {
3130
else this
3231
}
3332

34-
fun arrayListToJSONArray(list: ArrayList<*>): JSONArray {
33+
fun List<*>.toJson(): JSONArray {
3534
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)
4241
}
43-
}
4442
return result
4543
}
4644

47-
fun hashMapToJSONObject(map: HashMap<String, *>): JSONObject {
45+
fun Map<*, *>.toJson(): JSONObject {
4846
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)
5553
}
5654
}
5755
return result
@@ -78,6 +76,7 @@ fun <T> listFromJSON(input: JSONArray?, fromJson: (JSONObject?) -> T) = input?.l
7876
result
7977
}
8078

79+
@Suppress("UNCHECKED_CAST")
8180
fun <T> listFromJSON(input: JSONArray): List<T> {
8281
val result: MutableList<T> = ArrayList()
8382
for (i in 0 until input.length()) result.add(input.opt(i) as T)
@@ -170,6 +169,12 @@ fun Any?.toLong() = when (this) {
170169
else -> this as Long
171170
}
172171

172+
fun Any?.toDouble() = when (this) {
173+
is Int -> toDouble()
174+
is Long -> toDouble()
175+
else -> this as Double
176+
}
177+
173178
fun Any?.toColor() = "#" + toLong().toString(16)
174179

175180
fun Any?.toFloat() =

example/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
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'
44
import * as RNFS from 'react-native-fs'
55
import RadioGroup, { RadioButtonProps } from 'react-native-radio-buttons-group'
66
import { CheckBox } from '@rneui/themed'
@@ -33,9 +33,9 @@ export default class App extends React.Component<IProps, IState> {
3333
onInitialized() {
3434
this.setState({ fullName: "Ready" })
3535

36-
DocumentReader.setFunctionality({
37-
showCaptureButton: true
38-
}, _ => { }, _ => { })
36+
var functionality = new Functionality()
37+
functionality.showCaptureButton = true
38+
DocumentReader.setFunctionality(functionality, _ => { }, _ => { })
3939
}
4040

4141
constructor(props: {} | Readonly<{}>) {
@@ -103,7 +103,7 @@ export default class App extends React.Component<IProps, IState> {
103103
this.hideRfidUI()
104104
this.displayResults(completion.results!)
105105
}
106-
} else if (this.actionSuccess(completion.action!))
106+
} else if (this.actionSuccess(completion.action!) || this.actionError(completion.action!))
107107
this.handleResults(completion.results!)
108108
}
109109

example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ newArchEnabled=false
4141

4242
# Use this property to enable or disable the Hermes JS engine.
4343
# If set to false, you will be using JSC instead.
44-
hermesEnabled=true
44+
hermesEnabled=false

example/ios/Podfile

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@ require Pod::Executable.execute_command('node', ['-p',
88
platform :ios, min_ios_version_supported
99
prepare_react_native_project!
1010

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-
2211
linkage = ENV['USE_FRAMEWORKS']
2312
if linkage != nil
2413
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
@@ -33,21 +22,14 @@ target 'DocumentReader' do
3322

3423
use_react_native!(
3524
: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,
3826
: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,
4528
:app_path => "#{Pod::Config.instance.installation_root}/.."
4629
)
4730

4831
target 'DocumentReaderTests' do
4932
inherit! :complete
50-
# Pods for testing
5133
end
5234

5335
post_install do |installer|

0 commit comments

Comments
 (0)