Skip to content

Commit d9fe3c7

Browse files
author
Jenkins
committed
7.5.776
1 parent 75864fe commit d9fe3c7

21 files changed

Lines changed: 5996 additions & 6147 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository contains the source code of the Document Reader API, and the sam
88

99
## Documentation
1010

11-
You can find documentation [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/react-native).
11+
You can find documentation [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile).
1212

1313
## License
1414

RNDocumentReaderApi.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Pod::Spec.new do |s|
1212
s.homepage = 'https://regulaforensics.com'
1313

1414
s.source = { :http => 'file:' + __dir__ }
15-
s.ios.deployment_target = '11.0'
15+
s.ios.deployment_target = '12.0'
1616
s.source_files = "ios/*.{h,m}"
17-
s.dependency 'DocumentReader', '7.4.3900'
17+
s.dependency 'DocumentReader', '7.5.4211'
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.4.10181') {
44+
implementation('com.regula.documentreader:api:7.5.10400') {
4545
transitive = true
4646
}
4747
}

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

Lines changed: 95 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
// Created by Pavel Masiuk on 21.09.2023.
66
// Copyright © 2023 Regula. All rights reserved.
77
//
8+
@file:SuppressLint("MissingPermission")
89

910
package com.regula.documentreader
1011

11-
import android.Manifest.permission.*
12+
import android.Manifest.permission.ACCESS_FINE_LOCATION
13+
import android.Manifest.permission.BLUETOOTH_CONNECT
14+
import android.Manifest.permission.BLUETOOTH_SCAN
1215
import android.annotation.SuppressLint
1316
import android.app.Activity
1417
import android.bluetooth.BluetoothAdapter
@@ -19,7 +22,6 @@ import android.content.pm.PackageManager.PERMISSION_GRANTED
1922
import android.os.Build
2023
import android.os.IBinder
2124
import android.provider.Settings
22-
import androidx.annotation.RequiresPermission
2325
import androidx.core.app.ActivityCompat.requestPermissions
2426
import androidx.core.content.ContextCompat.checkSelfPermission
2527
import com.regula.documentreader.api.ble.BLEWrapper
@@ -28,37 +30,103 @@ import com.regula.documentreader.api.ble.RegulaBleService
2830
import com.regula.documentreader.api.internal.permission.BluetoothPermissionHelper.BLE_ACCESS_PERMISSION
2931
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isBluetoothEnabled
3032
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isLocationServiceEnabled
33+
import java.util.Timer
34+
import java.util.TimerTask
3135

32-
const val REQUEST_ENABLE_LOCATION = 196
33-
const val REQUEST_ENABLE_BT = 197
36+
const val SEARCHING_TIMEOUT: Long = 7000
37+
38+
const val INTENT_REQUEST_ENABLE_LOCATION = 196
39+
const val INTENT_REQUEST_ENABLE_BLUETOOTH = 197
3440

3541
@SuppressLint("StaticFieldLeak")
36-
var bleManager: BLEWrapper? = null
42+
lateinit var bluetooth: BLEWrapper
43+
lateinit var savedCallbackForPermissionResult: Callback
44+
var deviceConnected = false
3745

38-
@RequiresPermission("android.permission.BLUETOOTH_CONNECT")
39-
fun requestEnableBle(activity: Activity) {
40-
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
41-
activity.startActivityForResult(enableIntent, REQUEST_ENABLE_BT)
46+
fun connectBluetoothDevice(callback: Callback) {
47+
// return if already connected
48+
if (deviceConnected) return
49+
50+
// If some of the bluetooth permissions/settings don't match the requirements,
51+
// save callback for later and request the permissions/settings.
52+
// Callback will then be used in onRequestPermissionsResult for permission requests
53+
// and in onActivityResult for settings change requests.
54+
if (!isBluetoothSettingsReady(activity)) {
55+
savedCallbackForPermissionResult = callback
56+
return
57+
}
58+
59+
// set searching timeout
60+
val timer = object : TimerTask() {
61+
override fun run() {
62+
callback.success(false)
63+
bluetooth.stopDeviceScan()
64+
bluetooth.disconnect()
65+
}
66+
}
67+
Timer().schedule(timer, SEARCHING_TIMEOUT)
68+
69+
// start searching devices
70+
val bleIntent = Intent(activity, RegulaBleService::class.java)
71+
activity.startService(bleIntent)
72+
activity.bindService(bleIntent, object : ServiceConnection {
73+
override fun onServiceConnected(name: ComponentName, service: IBinder) {
74+
bluetooth = (service as RegulaBleService.LocalBinder).service.bleManager
75+
bluetooth.addCallback(object : BleWrapperCallback() {
76+
override fun onDeviceReady() {
77+
timer.cancel()
78+
bluetooth.removeCallback(this)
79+
deviceConnected = true
80+
callback.success(true)
81+
}
82+
})
83+
}
84+
85+
override fun onServiceDisconnected(name: ComponentName) {}
86+
}, 0)
4287
}
4388

44-
fun requestEnableLocationService(activity: Activity) {
45-
val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
46-
activity.startActivityForResult(myIntent, REQUEST_ENABLE_LOCATION)
89+
fun onRequestPermissionsResult(
90+
requestCode: Int,
91+
permissions: Array<out String>,
92+
grantResults: IntArray
93+
): Boolean {
94+
if (requestCode != BLE_ACCESS_PERMISSION || permissions.isEmpty()) return false
95+
if (grantResults.isEmpty() || grantResults[0] != PERMISSION_GRANTED) {
96+
savedCallbackForPermissionResult.success(false)
97+
return true
98+
}
99+
connectBluetoothDevice(savedCallbackForPermissionResult)
100+
return true
47101
}
48102

49-
// requestEnableBle() is called after a check for permission
50-
@SuppressLint("MissingPermission")
51-
fun isBlePermissionsGranted(activity: Activity): Boolean {
52-
if (!isLocationServiceEnabled(activity)) {
53-
requestEnableLocationService(activity)
54-
return false
103+
fun onActivityResult(requestCode: Int, rc: Int, @Suppress("UNUSED_PARAMETER") data: Intent?): Boolean {
104+
var resultCode = rc
105+
if (requestCode == INTENT_REQUEST_ENABLE_LOCATION)
106+
resultCode = if (isLocationServiceEnabled(activity)) Activity.RESULT_OK
107+
else requestCode
108+
109+
if (requestCode == INTENT_REQUEST_ENABLE_BLUETOOTH || requestCode == INTENT_REQUEST_ENABLE_LOCATION) {
110+
if (resultCode == Activity.RESULT_OK)
111+
connectBluetoothDevice(savedCallbackForPermissionResult)
112+
else
113+
savedCallbackForPermissionResult.success(false)
114+
return true
55115
}
116+
return false
117+
}
118+
119+
fun isBluetoothSettingsReady(activity: Activity): Boolean {
56120
deniedBluetoothPermissions(activity)?.let {
57121
requestPermissions(activity, it, BLE_ACCESS_PERMISSION)
58122
return false
59123
}
60124
if (!isBluetoothEnabled(activity)) {
61-
requestEnableBle(activity)
125+
requestEnableBluetooth(activity)
126+
return false
127+
}
128+
if (!isLocationServiceEnabled(activity)) {
129+
requestEnableLocationService(activity)
62130
return false
63131
}
64132
return true
@@ -83,30 +151,12 @@ fun deniedBluetoothPermission(
83151
return arrayOf()
84152
}
85153

86-
fun startBluetoothService(
87-
activity: Activity,
88-
onConnected: (Boolean) -> Unit,
89-
onDisconnected: () -> Unit,
90-
onReady: () -> Unit
91-
) {
92-
val bleIntent = Intent(activity, RegulaBleService::class.java)
93-
activity.startService(bleIntent)
94-
95-
activity.bindService(bleIntent, object : ServiceConnection {
96-
override fun onServiceConnected(name: ComponentName, service: IBinder) {
97-
bleManager = (service as RegulaBleService.LocalBinder).service.bleManager
98-
val isBleManagerConnected = bleManager?.isConnected == true
99-
onConnected(isBleManagerConnected)
100-
if (!isBleManagerConnected) {
101-
bleManager?.addCallback(object : BleWrapperCallback() {
102-
override fun onDeviceReady() {
103-
bleManager!!.removeCallback(this)
104-
onReady()
105-
}
106-
})
107-
}
108-
}
154+
fun requestEnableBluetooth(activity: Activity) {
155+
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
156+
activity.startActivityForResult(enableIntent, INTENT_REQUEST_ENABLE_BLUETOOTH)
157+
}
109158

110-
override fun onServiceDisconnected(name: ComponentName) = onDisconnected()
111-
}, 0)
112-
}
159+
fun requestEnableLocationService(activity: Activity) {
160+
val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
161+
activity.startActivityForResult(myIntent, INTENT_REQUEST_ENABLE_LOCATION)
162+
}

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

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Config.java
2+
// Config.kt
33
// DocumentReader
44
//
55
// Created by Pavel Masiuk on 21.09.2023.
@@ -26,6 +26,7 @@ import com.regula.documentreader.api.params.LivenessParams
2626
import com.regula.documentreader.api.params.ParamsCustomization
2727
import com.regula.documentreader.api.params.ProcessParam
2828
import com.regula.documentreader.api.params.RfidScenario
29+
import com.regula.documentreader.api.params.rfid.dg.DTCDataGroup
2930
import com.regula.documentreader.api.params.rfid.dg.DataGroups
3031
import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
3132
import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
@@ -129,12 +130,16 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
129130
"shouldReturnPackageForReprocess" -> processParams.shouldReturnPackageForReprocess = v as Boolean
130131
"disablePerforationOCR" -> processParams.disablePerforationOCR = v as Boolean
131132
"respectImageQuality" -> processParams.respectImageQuality = v as Boolean
133+
"strictImageQuality" -> processParams.strictImageQuality = v as Boolean
132134
"splitNames" -> processParams.splitNames = v as Boolean
133135
"doDetectCan" -> processParams.doDetectCan = v as Boolean
134136
"useFaceApi" -> processParams.useFaceApi = v as Boolean
135137
"useAuthenticityCheck" -> processParams.useAuthenticityCheck = v as Boolean
136138
"checkHologram" -> processParams.checkHologram = v as Boolean
137139
"generateNumericCodes" -> processParams.generateNumericCodes = v as Boolean
140+
"strictBarcodeDigitalSignatureCheck" -> processParams.strictBarcodeDigitalSignatureCheck = v as Boolean
141+
"selectLongestNames" -> processParams.selectLongestNames = v as Boolean
142+
"generateDTCVC" -> processParams.generateDTCVC = v as Boolean
138143
"measureSystem" -> processParams.measureSystem = v.toInt()
139144
"barcodeParserType" -> processParams.barcodeParserType = v.toInt()
140145
"perspectiveAngle" -> processParams.perspectiveAngle = v.toInt()
@@ -207,12 +212,16 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
207212
"shouldReturnPackageForReprocess" to processParams.shouldReturnPackageForReprocess,
208213
"disablePerforationOCR" to processParams.disablePerforationOCR,
209214
"respectImageQuality" to processParams.respectImageQuality,
215+
"strictImageQuality" to processParams.strictImageQuality,
210216
"splitNames" to processParams.splitNames,
211217
"doDetectCan" to processParams.doDetectCan,
212218
"useFaceApi" to processParams.useFaceApi,
213219
"useAuthenticityCheck" to processParams.useAuthenticityCheck,
214220
"checkHologram" to processParams.checkHologram,
215221
"generateNumericCodes" to processParams.generateNumericCodes,
222+
"strictBarcodeDigitalSignatureCheck" to processParams.strictBarcodeDigitalSignatureCheck,
223+
"selectLongestNames" to processParams.selectLongestNames,
224+
"generateDTCVC" to processParams.generateDTCVC,
216225
"measureSystem" to processParams.measureSystem,
217226
"barcodeParserType" to processParams.barcodeParserType,
218227
"perspectiveAngle" to processParams.perspectiveAngle,
@@ -278,6 +287,7 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject, conte
278287
"activityIndicatorColor" -> editor.setActivityIndicatorColor(v.toColor())
279288
"statusBackgroundColor" -> editor.setStatusBackgroundColor(v.toColor())
280289
"cameraPreviewBackgroundColor" -> editor.setCameraPreviewBackgroundColor(v.toColor())
290+
"backgroundMaskColor" -> editor.setBackgroundMaskColor(v.toColor())
281291
"statusPositionMultiplier" -> editor.setStatusPositionMultiplier(v.toFloat())
282292
"resultStatusPositionMultiplier" -> editor.setResultStatusPositionMultiplier(v.toFloat())
283293
"toolbarSize" -> editor.setToolbarSize(v.toFloat())
@@ -288,6 +298,8 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject, conte
288298
"cameraFramePortraitAspectRatio" -> editor.setCameraFramePortraitAspectRatio(v.toFloat())
289299
"cameraFrameCornerRadius" -> editor.setCameraFrameCornerRadius(v.toFloat())
290300
"livenessAnimationPositionMultiplier" -> editor.setLivenessAnimationPositionMultiplier(v.toFloat())
301+
"nextPageAnimationStartDelay" -> editor.setNextPageAnimationStartDelay(v.toFloat())
302+
"nextPageAnimationEndDelay" -> editor.setNextPageAnimationEndDelay(v.toFloat())
291303
"multipageAnimationFrontImage" -> editor.setMultipageAnimationFrontImage(v.toDrawable(context))
292304
"multipageAnimationBackImage" -> editor.setMultipageAnimationBackImage(v.toDrawable(context))
293305
"borderBackgroundImage" -> editor.setBorderBackgroundImage(v.toDrawable(context))
@@ -349,6 +361,7 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
349361
"activityIndicatorColor" to customization.activityIndicatorColor.toLong(),
350362
"statusBackgroundColor" to customization.statusBackgroundColor.toLong(),
351363
"cameraPreviewBackgroundColor" to customization.cameraPreviewBackgroundColor.toLong(),
364+
"backgroundMaskColor" to customization.backgroundMaskColor.toLong(),
352365
"statusPositionMultiplier" to customization.statusPositionMultiplier,
353366
"resultStatusPositionMultiplier" to customization.resultStatusPositionMultiplier,
354367
"backgroundMaskAlpha" to customization.backgroundMaskAlpha,
@@ -359,6 +372,8 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
359372
"cameraFramePortraitAspectRatio" to customization.cameraFramePortraitAspectRatio,
360373
"cameraFrameCornerRadius" to customization.cameraFrameCornerRadius,
361374
"livenessAnimationPositionMultiplier" to customization.livenessAnimationPositionMultiplier,
375+
"nextPageAnimationStartDelay" to customization.nextPageAnimationStartDelay,
376+
"nextPageAnimationEndDelay" to customization.nextPageAnimationEndDelay,
362377
"multipageAnimationFrontImage" to customization.multipageAnimationFrontImage.toString(),
363378
"multipageAnimationBackImage" to customization.multipageAnimationBackImage.toString(),
364379
"borderBackgroundImage" to customization.borderBackgroundImage.toString(),
@@ -422,6 +437,8 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
422437
"applyAmendments" -> rfidScenario.isApplyAmendments = v as Boolean
423438
"autoSettings" -> rfidScenario.isAutoSettings = v as Boolean
424439
"proceedReadingAlways" -> rfidScenario.proceedReadingAlways = v as Boolean
440+
"readDTC" -> rfidScenario.isReadDTC = v as Boolean
441+
"mrzStrictCheck" -> rfidScenario.isMrzStrictCheck = v as Boolean
425442
"signManagementAction" -> rfidScenario.signManagementAction = v.toInt()
426443
"readingBuffer" -> rfidScenario.readingBuffer = v.toInt()
427444
"onlineTAToSignDataType" -> rfidScenario.onlineTAToSignDataType = v.toInt()
@@ -437,9 +454,11 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
437454
"mrz" -> rfidScenario.mrz = v as String
438455
"eSignPINDefault" -> rfidScenario.seteSignPINDefault(v as String)
439456
"eSignPINNewValue" -> rfidScenario.seteSignPINNewValue(v as String)
457+
"cardAccess" -> rfidScenario.cardAccess = v as String
440458
"ePassportDataGroups" -> setDataGroups(rfidScenario.ePassportDataGroups(), v as JSONObject)
441459
"eIDDataGroups" -> setDataGroups(rfidScenario.eIDDataGroups(), v as JSONObject)
442460
"eDLDataGroups" -> setDataGroups(rfidScenario.eDLDataGroups(), v as JSONObject)
461+
"dtcDataGroups" -> setDataGroups(rfidScenario.DTCDataGroup(), v as JSONObject)
443462
}
444463
}
445464

@@ -478,6 +497,8 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
478497
"applyAmendments" to rfidScenario.isApplyAmendments,
479498
"autoSettings" to rfidScenario.isAutoSettings,
480499
"proceedReadingAlways" to rfidScenario.proceedReadingAlways,
500+
"readDTC" to rfidScenario.isReadDTC,
501+
"mrzStrictCheck" to rfidScenario.isMrzStrictCheck,
481502
"signManagementAction" to rfidScenario.signManagementAction,
482503
"readingBuffer" to rfidScenario.readingBuffer,
483504
"onlineTAToSignDataType" to rfidScenario.onlineTAToSignDataType,
@@ -493,9 +514,11 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
493514
"mrz" to rfidScenario.mrz,
494515
"eSignPINDefault" to rfidScenario.geteSignPINDefault(),
495516
"eSignPINNewValue" to rfidScenario.geteSignPINNewValue(),
517+
"cardAccess" to rfidScenario.cardAccess,
496518
"ePassportDataGroups" to getDataGroups(rfidScenario.ePassportDataGroups()),
497519
"eIDDataGroups" to getDataGroups(rfidScenario.eIDDataGroups()),
498-
"eDLDataGroups" to getDataGroups(rfidScenario.eDLDataGroups())
520+
"eDLDataGroups" to getDataGroups(rfidScenario.eDLDataGroups()),
521+
"dtcDataGroups" to getDataGroups(rfidScenario.DTCDataGroup())
499522
).toJsonObject()
500523

501524
fun setDataGroups(dataGroup: DataGroups, opts: JSONObject) = opts.forEach { k, v ->
@@ -529,6 +552,15 @@ fun setDataGroups(dataGroup: DataGroups, opts: JSONObject) = opts.forEach { k, v
529552
"DG20" -> dataGroup.isDG20 = value
530553
"DG21" -> dataGroup.isDG21 = value
531554
}
555+
if (dataGroup is DTCDataGroup) when (k) {
556+
"DG15" -> dataGroup.isDG15 = value
557+
"DG16" -> dataGroup.isDG16 = value
558+
"DG17" -> dataGroup.isDG17 = value
559+
"DG18" -> dataGroup.isDG18 = value
560+
"DG22" -> dataGroup.isDG22 = value
561+
"DG23" -> dataGroup.isDG23 = value
562+
"DG24" -> dataGroup.isDG24 = value
563+
}
532564
}
533565

534566
fun getDataGroups(dataGroup: DataGroups): JSONObject {
@@ -561,6 +593,15 @@ fun getDataGroups(dataGroup: DataGroups): JSONObject {
561593
result["DG20"] = dataGroup.isDG20
562594
result["DG21"] = dataGroup.isDG21
563595
}
596+
if (dataGroup is DTCDataGroup) {
597+
result["DG15"] = dataGroup.isDG15
598+
result["DG16"] = dataGroup.isDG16
599+
result["DG17"] = dataGroup.isDG17
600+
result["DG18"] = dataGroup.isDG18
601+
result["DG22"] = dataGroup.isDG22
602+
result["DG23"] = dataGroup.isDG23
603+
result["DG24"] = dataGroup.isDG24
604+
}
564605
return result.toJsonObject()
565606
}
566607

0 commit comments

Comments
 (0)