@regulaforensics/react-native-document-reader-api 6.5.0 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNDocumentReaderApi.podspec +1 -1
- package/android/build.gradle +4 -29
- package/android/src/main/AndroidManifest.xml +5 -1
- package/android/src/main/java/com/regula/documentreader/BluetoothUtil.kt +108 -0
- package/android/src/main/java/com/regula/documentreader/Helpers.java +4 -5
- package/android/src/main/java/com/regula/documentreader/JSONConstructor.java +150 -1345
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.java +99 -12
- package/android/src/main/java/com/regula/documentreader/RegulaConfig.java +22 -1
- package/example/App.js +2 -0
- package/example/android/app/build.gradle +0 -6
- package/example/android/app/src/main/AndroidManifest.xml +2 -0
- package/example/android/build.gradle +5 -10
- package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/example/ios/Podfile +8 -0
- package/example/metro.config.js +4 -1
- package/example/package.json +2 -2
- package/index.d.ts +165 -127
- package/index.js +113 -78
- package/ios/RGLWJSONConstructor.h +6 -0
- package/ios/RGLWJSONConstructor.m +102 -1
- package/ios/RNRegulaDocumentReader.m +77 -27
- package/ios/RegulaConfig.m +25 -1
- package/package.json +1 -1
- package/core/.gitkeep +0 -0
package/android/build.gradle
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
buildscript {
|
|
2
|
-
repositories {
|
|
3
|
-
google()
|
|
4
|
-
jcenter()
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
dependencies {
|
|
8
|
-
classpath 'com.android.tools.build:gradle:4.0.1'
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
1
|
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
13
3
|
|
|
14
4
|
android {
|
|
15
|
-
compileSdkVersion
|
|
16
|
-
buildToolsVersion "30.0.0"
|
|
5
|
+
compileSdkVersion 33
|
|
17
6
|
|
|
18
7
|
defaultConfig {
|
|
19
8
|
minSdkVersion 21
|
|
20
|
-
targetSdkVersion
|
|
9
|
+
targetSdkVersion 33
|
|
21
10
|
versionCode 1
|
|
22
11
|
versionName "1.0"
|
|
23
12
|
}
|
|
24
|
-
lintOptions {
|
|
25
|
-
abortOnError false
|
|
26
|
-
}
|
|
27
|
-
compileOptions {
|
|
28
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
29
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
repositories {
|
|
34
|
-
mavenCentral()
|
|
35
13
|
}
|
|
36
14
|
|
|
37
15
|
rootProject.allprojects {
|
|
@@ -39,9 +17,6 @@ rootProject.allprojects {
|
|
|
39
17
|
maven {
|
|
40
18
|
url "https://maven.regulaforensics.com/RegulaDocumentReader"
|
|
41
19
|
}
|
|
42
|
-
maven {
|
|
43
|
-
url "https://maven.regulaforensics.com/RegulaDocumentReader/Beta"
|
|
44
|
-
}
|
|
45
20
|
}
|
|
46
21
|
}
|
|
47
22
|
|
|
@@ -49,7 +24,7 @@ dependencies {
|
|
|
49
24
|
//noinspection GradleDynamicVersion
|
|
50
25
|
implementation 'com.facebook.react:react-native:+'
|
|
51
26
|
//noinspection GradleDependency
|
|
52
|
-
implementation('com.regula.documentreader:api:6.
|
|
27
|
+
implementation('com.regula.documentreader:api:6.6.8072') {
|
|
53
28
|
transitive = true
|
|
54
29
|
}
|
|
55
30
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
2
|
package="com.regula.documentreader">
|
|
3
3
|
|
|
4
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
5
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
6
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
7
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
4
8
|
<uses-permission android:name="android.permission.NFC" />
|
|
5
9
|
</manifest>
|
|
6
|
-
|
|
10
|
+
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
package com.regula.documentreader
|
|
2
|
+
|
|
3
|
+
import android.Manifest.permission.*
|
|
4
|
+
import android.annotation.SuppressLint
|
|
5
|
+
import android.app.Activity
|
|
6
|
+
import android.bluetooth.BluetoothAdapter
|
|
7
|
+
import android.content.ComponentName
|
|
8
|
+
import android.content.Intent
|
|
9
|
+
import android.content.ServiceConnection
|
|
10
|
+
import android.content.pm.PackageManager.PERMISSION_GRANTED
|
|
11
|
+
import android.os.Build
|
|
12
|
+
import android.os.IBinder
|
|
13
|
+
import android.provider.Settings
|
|
14
|
+
import androidx.annotation.RequiresPermission
|
|
15
|
+
import androidx.core.app.ActivityCompat.requestPermissions
|
|
16
|
+
import androidx.core.content.ContextCompat.checkSelfPermission
|
|
17
|
+
import com.regula.documentreader.api.ble.BLEWrapper
|
|
18
|
+
import com.regula.documentreader.api.ble.BleWrapperCallback
|
|
19
|
+
import com.regula.documentreader.api.ble.RegulaBleService
|
|
20
|
+
import com.regula.documentreader.api.internal.permission.BluetoothPermissionHelper.BLE_ACCESS_PERMISSION
|
|
21
|
+
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isBluetoothEnabled
|
|
22
|
+
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isLocationServiceEnabled
|
|
23
|
+
|
|
24
|
+
class BluetoothUtil {
|
|
25
|
+
companion object {
|
|
26
|
+
private const val REQUEST_ENABLE_LOCATION = 196
|
|
27
|
+
private const val REQUEST_ENABLE_BT = 197
|
|
28
|
+
|
|
29
|
+
@SuppressLint("StaticFieldLeak")
|
|
30
|
+
var bleManager: BLEWrapper? = null
|
|
31
|
+
|
|
32
|
+
@RequiresPermission("android.permission.BLUETOOTH_CONNECT")
|
|
33
|
+
private fun requestEnableBle(activity: Activity) {
|
|
34
|
+
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
|
|
35
|
+
activity.startActivityForResult(enableIntent, REQUEST_ENABLE_BT)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private fun requestEnableLocationService(activity: Activity) {
|
|
39
|
+
val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
|
|
40
|
+
activity.startActivityForResult(myIntent, REQUEST_ENABLE_LOCATION)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// requestEnableBle() is called after a check for permission
|
|
44
|
+
@SuppressLint("MissingPermission")
|
|
45
|
+
fun isBlePermissionsGranted(activity: Activity): Boolean {
|
|
46
|
+
if (!isLocationServiceEnabled(activity)) {
|
|
47
|
+
requestEnableLocationService(activity)
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
deniedBluetoothPermissions(activity)?.let {
|
|
51
|
+
requestPermissions(activity, it, BLE_ACCESS_PERMISSION)
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
if (!isBluetoothEnabled(activity)) {
|
|
55
|
+
requestEnableBle(activity)
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private fun deniedBluetoothPermissions(activity: Activity): Array<String>? {
|
|
62
|
+
val result = mutableListOf<String>()
|
|
63
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
64
|
+
result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_SCAN))
|
|
65
|
+
result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_CONNECT))
|
|
66
|
+
} else
|
|
67
|
+
result.addAll(deniedBluetoothPermission(activity, ACCESS_FINE_LOCATION))
|
|
68
|
+
return result.let { if (it.size > 0) it.toTypedArray() else null }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private fun deniedBluetoothPermission(
|
|
72
|
+
activity: Activity,
|
|
73
|
+
permission: String
|
|
74
|
+
): Array<String> {
|
|
75
|
+
if (checkSelfPermission(activity, permission) != PERMISSION_GRANTED)
|
|
76
|
+
return arrayOf(permission)
|
|
77
|
+
return arrayOf()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fun startBluetoothService(
|
|
81
|
+
activity: Activity,
|
|
82
|
+
onConnected: (Boolean) -> Unit,
|
|
83
|
+
onDisconnected: () -> Unit,
|
|
84
|
+
onReady: () -> Unit,
|
|
85
|
+
) {
|
|
86
|
+
val bleIntent = Intent(activity, RegulaBleService::class.java)
|
|
87
|
+
activity.startService(bleIntent)
|
|
88
|
+
|
|
89
|
+
activity.bindService(bleIntent, object : ServiceConnection {
|
|
90
|
+
override fun onServiceConnected(name: ComponentName, service: IBinder) {
|
|
91
|
+
bleManager = (service as RegulaBleService.LocalBinder).service.bleManager
|
|
92
|
+
val isBleManagerConnected = bleManager?.isConnected == true
|
|
93
|
+
onConnected(isBleManagerConnected)
|
|
94
|
+
if (!isBleManagerConnected) {
|
|
95
|
+
bleManager?.addCallback(object : BleWrapperCallback() {
|
|
96
|
+
override fun onDeviceReady() {
|
|
97
|
+
bleManager!!.removeCallback(this)
|
|
98
|
+
onReady()
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
override fun onServiceDisconnected(name: ComponentName) = onDisconnected()
|
|
105
|
+
}, 0)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -31,13 +31,12 @@ class Helpers {
|
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
static BitmapDrawable drawableFromBase64(String base64, Context context)
|
|
35
|
-
{
|
|
34
|
+
static BitmapDrawable drawableFromBase64(String base64, Context context) {
|
|
36
35
|
byte[] decodedByte = Base64.decode(base64, 0);
|
|
37
|
-
Bitmap bitmap =
|
|
36
|
+
Bitmap bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
|
|
38
37
|
float density = context.getResources().getDisplayMetrics().density;
|
|
39
|
-
int width = (int)(bitmap.getWidth()*density);
|
|
40
|
-
int height = (int)(bitmap.getHeight()*density);
|
|
38
|
+
int width = (int) (bitmap.getWidth() * density);
|
|
39
|
+
int height = (int) (bitmap.getHeight() * density);
|
|
41
40
|
return new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap, width, height, false));
|
|
42
41
|
}
|
|
43
42
|
|