accurascan_kyc 0.1.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/LICENSE +20 -0
- package/README.md +635 -0
- package/accurascan-kyc.podspec +38 -0
- package/android/build.gradle +118 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +18 -0
- package/android/src/main/java/com/accurascankyc/AccurascanKycModule.java +507 -0
- package/android/src/main/java/com/accurascankyc/AccurascanKycPackage.java +28 -0
- package/android/src/main/java/com/accurascankyc/ActivityFaceMatch.java +533 -0
- package/android/src/main/java/com/accurascankyc/BorderTextView.java +82 -0
- package/android/src/main/java/com/accurascankyc/OcrActivity.java +1263 -0
- package/android/src/main/java/com/accurascankyc/OcrResultActivity.java +736 -0
- package/android/src/main/java/com/accurascankyc/ReactNativeJson.java +123 -0
- package/android/src/main/java/com/accurascankyc/UnsafeOkHttpClient.java +57 -0
- package/android/src/main/res/drawable/btn_bg_gray.xml +6 -0
- package/android/src/main/res/drawable/btn_bg_red.xml +6 -0
- package/android/src/main/res/drawable/btn_bg_trasparent_bottom.xml +6 -0
- package/android/src/main/res/drawable/flip_camera_icon.png +0 -0
- package/android/src/main/res/drawable/ic_close.xml +5 -0
- package/android/src/main/res/drawable/round_border_rect.xml +12 -0
- package/android/src/main/res/drawable/splash.png +0 -0
- package/android/src/main/res/drawable-v24/ic_launcher_foreground.png +0 -0
- package/android/src/main/res/drawable-xhdpi/bg_home.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_barcode.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_biometric.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_check.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_liveness.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_result.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_scan.png +0 -0
- package/android/src/main/res/drawable-xhdpi/img_button_overlay.png +0 -0
- package/android/src/main/res/layout/activity_ocr_result.xml +18 -0
- package/android/src/main/res/layout/activity_splash.xml +26 -0
- package/android/src/main/res/layout/custom_frame_layout.xml +144 -0
- package/android/src/main/res/layout/ocr_activity.xml +28 -0
- package/android/src/main/res/layout-land/custom_frame_layout.xml +144 -0
- package/android/src/main/res/layout-land/ocr_activity.xml +41 -0
- package/android/src/main/res/menu/menu_land_port.xml +7 -0
- package/android/src/main/res/mipmap-hdpi/logo_loign.png +0 -0
- package/android/src/main/res/mipmap-mdpi/logo_loign.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_document_verified.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/logo_loign.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/logo_loign.png +0 -0
- package/android/src/main/res/values/colors.xml +31 -0
- package/android/src/main/res/values/strings.xml +42 -0
- package/android/src/main/res/values/styles.xml +191 -0
- package/ios/AccurascanKyc-Bridging-Header.h +2 -0
- package/ios/AccurascanKyc.m +34 -0
- package/ios/AccurascanKyc.swift +649 -0
- package/ios/AccurascanKyc.xcodeproj/project.pbxproj +283 -0
- package/ios/AccurascanKyc.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/FMController.swift +587 -0
- package/ios/LVController.swift +346 -0
- package/ios/MainStoryboard_iPhone.storyboard +338 -0
- package/ios/ViewController.swift +2686 -0
- package/ios/resources/back_icon.png +0 -0
- package/ios/resources/flip_camera_icon.png +0 -0
- package/ios/resources/flip_document_icon.png +0 -0
- package/ios/resources/ic_logo.png +0 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +161 -0
- package/src/index.tsx +5 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenLocal()
|
|
5
|
+
mavenCentral()
|
|
6
|
+
jcenter()
|
|
7
|
+
maven { url 'https://jitpack.io' }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
def isNewArchitectureEnabled() {
|
|
16
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
23
|
+
|
|
24
|
+
if (isNewArchitectureEnabled()) {
|
|
25
|
+
apply plugin: "com.facebook.react"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def getExtOrDefault(name) {
|
|
29
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["AccurascanKyc_" + name]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getExtOrIntegerDefault(name) {
|
|
33
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AccurascanKyc_" + name]).toInteger()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
android {
|
|
37
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
38
|
+
|
|
39
|
+
defaultConfig {
|
|
40
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
41
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
42
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
43
|
+
}
|
|
44
|
+
buildTypes {
|
|
45
|
+
release {
|
|
46
|
+
minifyEnabled true
|
|
47
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
48
|
+
}
|
|
49
|
+
debug {
|
|
50
|
+
minifyEnabled true
|
|
51
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
lintOptions {
|
|
56
|
+
disable "GradleCompatible"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
compileOptions {
|
|
60
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
61
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
packagingOptions {
|
|
65
|
+
pickFirst 'lib/arm64-v8a/libcrypto.so'
|
|
66
|
+
pickFirst 'lib/arm64-v8a/libssl.so'
|
|
67
|
+
|
|
68
|
+
pickFirst 'lib/armeabi-v7a/libcrypto.so'
|
|
69
|
+
pickFirst 'lib/armeabi-v7a/libssl.so'
|
|
70
|
+
|
|
71
|
+
pickFirst 'lib/x86/libcrypto.so'
|
|
72
|
+
pickFirst 'lib/x86/libssl.so'
|
|
73
|
+
|
|
74
|
+
pickFirst 'lib/x86_64/libcrypto.so'
|
|
75
|
+
pickFirst 'lib/x86_64/libssl.so'
|
|
76
|
+
}
|
|
77
|
+
splits {
|
|
78
|
+
abi {
|
|
79
|
+
reset()
|
|
80
|
+
universalApk false // If true, also generate a universal APK
|
|
81
|
+
// include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
|
|
82
|
+
include "armeabi-v7a", "x86"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
repositories {
|
|
89
|
+
mavenCentral()
|
|
90
|
+
google()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
dependencies {
|
|
95
|
+
// For < 0.71, this will be from the local maven repo
|
|
96
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
97
|
+
//noinspection GradleDynamicVersion
|
|
98
|
+
implementation "com.facebook.react:react-native:+"
|
|
99
|
+
|
|
100
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
101
|
+
|
|
102
|
+
implementation 'androidx.appcompat:appcompat:1.6.0'
|
|
103
|
+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
|
104
|
+
// For Accura OCR SDK
|
|
105
|
+
implementation 'com.github.accurascan:AccuraOCR:5.1.0'
|
|
106
|
+
// For Accura Face match
|
|
107
|
+
implementation 'com.github.accurascan:AccuraFaceMatch:3.2.0'
|
|
108
|
+
// for liveness
|
|
109
|
+
implementation 'com.github.accurascan:Liveness-Android:3.2.0'
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (isNewArchitectureEnabled()) {
|
|
113
|
+
react {
|
|
114
|
+
jsRootDir = file("../src/")
|
|
115
|
+
libraryName = "AccurascanKyc"
|
|
116
|
+
codegenJavaPackageName = "com.accurascankyc"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
package="com.accurascankyc">
|
|
3
|
+
|
|
4
|
+
<application>
|
|
5
|
+
|
|
6
|
+
<activity android:name="com.accurascankyc.ActivityFaceMatch"
|
|
7
|
+
android:theme="@style/FaceMatchTheme"/>
|
|
8
|
+
|
|
9
|
+
<activity android:name="com.accurascankyc.OcrActivity"
|
|
10
|
+
android:theme="@style/AppTheme"
|
|
11
|
+
android:screenOrientation="locked"/>
|
|
12
|
+
|
|
13
|
+
<activity android:name="com.accurascankyc.OcrResultActivity"
|
|
14
|
+
android:screenOrientation="locked"
|
|
15
|
+
android:theme="@style/AppThemeActionBar"/>
|
|
16
|
+
</application>
|
|
17
|
+
|
|
18
|
+
</manifest>
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
package com.accurascankyc;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.core.app.ActivityCompat;
|
|
5
|
+
|
|
6
|
+
import android.os.Build;
|
|
7
|
+
import android.content.Context;
|
|
8
|
+
import com.accurascan.ocr.mrz.model.BarcodeFormat;
|
|
9
|
+
import com.accurascan.ocr.mrz.model.ContryModel;
|
|
10
|
+
import com.accurascan.ocr.mrz.util.AccuraLog;
|
|
11
|
+
import com.androidnetworking.AndroidNetworking;
|
|
12
|
+
import com.docrecog.scan.MRZDocumentType;
|
|
13
|
+
import com.docrecog.scan.RecogEngine;
|
|
14
|
+
import com.docrecog.scan.RecogType;
|
|
15
|
+
import com.facebook.react.bridge.Promise;
|
|
16
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
18
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
19
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
20
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
21
|
+
import com.facebook.react.bridge.Callback;
|
|
22
|
+
|
|
23
|
+
import android.Manifest;
|
|
24
|
+
import android.content.ContentResolver;
|
|
25
|
+
import android.content.Intent;
|
|
26
|
+
import android.content.pm.PackageManager;
|
|
27
|
+
import android.graphics.Bitmap;
|
|
28
|
+
import android.graphics.BitmapFactory;
|
|
29
|
+
import android.net.Uri;
|
|
30
|
+
import android.util.Base64;
|
|
31
|
+
|
|
32
|
+
import org.json.JSONArray;
|
|
33
|
+
import org.json.JSONException;
|
|
34
|
+
import org.json.JSONObject;
|
|
35
|
+
|
|
36
|
+
import java.io.File;
|
|
37
|
+
import java.io.FileNotFoundException;
|
|
38
|
+
import java.io.FileOutputStream;
|
|
39
|
+
import java.io.IOException;
|
|
40
|
+
import java.io.InputStream;
|
|
41
|
+
import java.io.OutputStream;
|
|
42
|
+
import java.util.HashMap;
|
|
43
|
+
import java.util.List;
|
|
44
|
+
import java.util.Map;
|
|
45
|
+
import java.util.Objects;
|
|
46
|
+
import java.util.Random;
|
|
47
|
+
|
|
48
|
+
@ReactModule(name = AccurascanKycModule.NAME)
|
|
49
|
+
public class AccurascanKycModule extends ReactContextBaseJavaModule {
|
|
50
|
+
public static final String NAME = "AccurascanKyc";
|
|
51
|
+
public static Bitmap face1 = null;
|
|
52
|
+
public static Bitmap face2 = null;
|
|
53
|
+
public static Callback onResult = null;
|
|
54
|
+
|
|
55
|
+
public static JSONObject accuraErrorConfg = new JSONObject();
|
|
56
|
+
public static JSONObject accuraTitleMsg = new JSONObject();
|
|
57
|
+
public static JSONObject accuraConfigs = new JSONObject();
|
|
58
|
+
private String bType;
|
|
59
|
+
|
|
60
|
+
public AccurascanKycModule(ReactApplicationContext reactContext) {
|
|
61
|
+
super(reactContext);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Override
|
|
65
|
+
@NonNull
|
|
66
|
+
public String getName() {
|
|
67
|
+
return NAME;
|
|
68
|
+
}
|
|
69
|
+
public static String getSaltString() {
|
|
70
|
+
String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
|
71
|
+
StringBuilder salt = new StringBuilder();
|
|
72
|
+
Random rnd = new Random();
|
|
73
|
+
while (salt.length() < 18) { // length of the random string.
|
|
74
|
+
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
|
|
75
|
+
salt.append(SALTCHARS.charAt(index));
|
|
76
|
+
}
|
|
77
|
+
return salt.toString();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public static Bitmap getBitmap(ContentResolver cr, Uri url)
|
|
81
|
+
throws FileNotFoundException, IOException {
|
|
82
|
+
InputStream input = cr.openInputStream(url);
|
|
83
|
+
Bitmap bitmap = BitmapFactory.decodeStream(input);
|
|
84
|
+
input.close();
|
|
85
|
+
return bitmap;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public static Bitmap getBase64ToBitmap(String base64Image) {
|
|
89
|
+
|
|
90
|
+
byte[] decodedString = Base64.decode(base64Image, Base64.DEFAULT);
|
|
91
|
+
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
|
|
92
|
+
return decodedByte;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public static String getImageUri(Bitmap bitmap, String name, String path) {
|
|
96
|
+
OutputStream fOut = null;
|
|
97
|
+
File file = new File(path, getSaltString() + "_" + name + ".jpg");
|
|
98
|
+
try {
|
|
99
|
+
fOut = new FileOutputStream(file);
|
|
100
|
+
} catch (FileNotFoundException e) {
|
|
101
|
+
e.printStackTrace();
|
|
102
|
+
}
|
|
103
|
+
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
|
|
104
|
+
try {
|
|
105
|
+
fOut.flush(); // Not really required
|
|
106
|
+
fOut.close();
|
|
107
|
+
} catch (IOException e) {
|
|
108
|
+
e.printStackTrace();
|
|
109
|
+
}
|
|
110
|
+
return "file://"+file.getAbsolutePath();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Example method
|
|
114
|
+
// See https://reactnative.dev/docs/native-modules-android
|
|
115
|
+
@ReactMethod
|
|
116
|
+
public void multiply(double a, double b, Promise promise) {
|
|
117
|
+
promise.resolve(a * b);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@ReactMethod
|
|
121
|
+
public boolean getMetaData( Callback callbackContext ) throws JSONException {
|
|
122
|
+
|
|
123
|
+
onResult = callbackContext;
|
|
124
|
+
RecogEngine recogEngine = new RecogEngine();
|
|
125
|
+
AccuraLog.enableLogs(false);
|
|
126
|
+
recogEngine.setDialog(false);
|
|
127
|
+
JSONObject results = new JSONObject();
|
|
128
|
+
RecogEngine.SDKModel sdkModel = recogEngine.initEngine(getReactApplicationContext());
|
|
129
|
+
if (sdkModel.i >= 0) {
|
|
130
|
+
AndroidNetworking.initialize(getReactApplicationContext(), UnsafeOkHttpClient.getUnsafeOkHttpClient());
|
|
131
|
+
results.put("sdk_version", recogEngine.getVersion());
|
|
132
|
+
|
|
133
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !isPermissionsGranted(getCurrentActivity())) {
|
|
134
|
+
requestCameraPermission();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
results.put("isValid", true);
|
|
138
|
+
// if OCR enable then get card list
|
|
139
|
+
if (sdkModel.isOCREnable) {
|
|
140
|
+
results.put("isOCR", true);
|
|
141
|
+
List<ContryModel> modelList = recogEngine.getCardList(getCurrentActivity());
|
|
142
|
+
JSONArray countries = new JSONArray();
|
|
143
|
+
for (int i = 0; i < modelList.size(); i++) {
|
|
144
|
+
JSONObject country = new JSONObject();
|
|
145
|
+
country.put("name", modelList.get(i).getCountry_name());
|
|
146
|
+
country.put("id", modelList.get(i).getCountry_id());
|
|
147
|
+
JSONArray cards = new JSONArray();
|
|
148
|
+
List<ContryModel.CardModel> cardList = modelList.get(i).getCards();
|
|
149
|
+
for (int j = 0; j < cardList.size(); j++) {
|
|
150
|
+
JSONObject card = new JSONObject();
|
|
151
|
+
card.put("name", cardList.get(j).getCard_name());
|
|
152
|
+
card.put("id", cardList.get(j).getCard_id());
|
|
153
|
+
card.put("type", cardList.get(j).getCard_type());
|
|
154
|
+
cards.put(card);
|
|
155
|
+
}
|
|
156
|
+
country.put("cards", cards);
|
|
157
|
+
countries.put(country);
|
|
158
|
+
}
|
|
159
|
+
results.put("countries", countries);
|
|
160
|
+
}
|
|
161
|
+
results.put("isOCREnable", sdkModel.isOCREnable);
|
|
162
|
+
results.put("isBarcode", sdkModel.isAllBarcodeEnable);
|
|
163
|
+
if (sdkModel.isAllBarcodeEnable) {
|
|
164
|
+
List<BarcodeFormat> CODE_NAMES = BarcodeFormat.getList();
|
|
165
|
+
JSONArray barcodes = new JSONArray();
|
|
166
|
+
for (int i = 0; i < CODE_NAMES.size(); i++) {
|
|
167
|
+
JSONObject barcode = new JSONObject();
|
|
168
|
+
barcode.put("name", CODE_NAMES.get(i).barcodeTitle);
|
|
169
|
+
barcode.put("type", CODE_NAMES.get(i).formatsType);
|
|
170
|
+
barcodes.put(barcode);
|
|
171
|
+
}
|
|
172
|
+
results.put("barcodes", barcodes);
|
|
173
|
+
}
|
|
174
|
+
results.put("isBankCard", sdkModel.isBankCardEnable);
|
|
175
|
+
results.put("isMRZ", sdkModel.isMRZEnable);
|
|
176
|
+
|
|
177
|
+
} else {
|
|
178
|
+
results.put("isValid", false);
|
|
179
|
+
}
|
|
180
|
+
callbackContext.invoke(null, results.toString());
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@ReactMethod
|
|
185
|
+
public boolean setupAccuraConfig(ReadableArray argsNew, Callback result) throws JSONException {
|
|
186
|
+
|
|
187
|
+
JSONArray args = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
188
|
+
RecogEngine recogEngine = new RecogEngine();
|
|
189
|
+
|
|
190
|
+
accuraConfigs = args.getJSONObject(0);
|
|
191
|
+
accuraErrorConfg = args.getJSONObject(1);
|
|
192
|
+
accuraTitleMsg = args.getJSONObject(2);
|
|
193
|
+
|
|
194
|
+
OcrActivity.accuraErrorConfg = accuraErrorConfg;
|
|
195
|
+
OcrActivity.accuraTitleMsg = accuraTitleMsg;
|
|
196
|
+
if (accuraConfigs.has("setFaceBlurPercentage")){
|
|
197
|
+
recogEngine.setFaceBlurPercentage(getCurrentActivity(), accuraConfigs.getInt("setFaceBlurPercentage"));
|
|
198
|
+
}else{
|
|
199
|
+
recogEngine.setFaceBlurPercentage(getCurrentActivity(),70);
|
|
200
|
+
}
|
|
201
|
+
if (accuraConfigs.has("setHologramDetection")){
|
|
202
|
+
recogEngine.SetHologramDetection(getCurrentActivity(),accuraConfigs.getBoolean("setHologramDetection"));
|
|
203
|
+
}else {
|
|
204
|
+
recogEngine.SetHologramDetection(getCurrentActivity(),true);
|
|
205
|
+
}
|
|
206
|
+
if (accuraConfigs.has("setLowLightTolerance")){
|
|
207
|
+
recogEngine.setLowLightTolerance(getCurrentActivity(),accuraConfigs.getInt("setLowLightTolerance"));
|
|
208
|
+
}else {
|
|
209
|
+
recogEngine.setLowLightTolerance(getCurrentActivity(),39);
|
|
210
|
+
}if (accuraConfigs.has("setMotionThreshold")){
|
|
211
|
+
recogEngine.setMotionThreshold(getCurrentActivity(),accuraConfigs.getInt("setMotionThreshold"));
|
|
212
|
+
}else {
|
|
213
|
+
recogEngine.setMotionThreshold(getCurrentActivity(),18);
|
|
214
|
+
}if (accuraConfigs.has("setMinGlarePercentage") &&
|
|
215
|
+
accuraConfigs.has("setMaxGlarePercentage")){
|
|
216
|
+
recogEngine.setGlarePercentage(getCurrentActivity(),accuraConfigs.getInt("setMinGlarePercentage"),
|
|
217
|
+
accuraConfigs.getInt("setMaxGlarePercentage") );
|
|
218
|
+
}else {
|
|
219
|
+
recogEngine.setGlarePercentage(getCurrentActivity(),6,98);
|
|
220
|
+
} if (accuraConfigs.has("setBlurPercentage")){
|
|
221
|
+
recogEngine.setBlurPercentage(getCurrentActivity(), accuraConfigs.getInt("setBlurPercentage"));
|
|
222
|
+
} else {
|
|
223
|
+
recogEngine.setBlurPercentage(getCurrentActivity(), 62);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// recogEngine.isCheckPhotoCopy(getCurrentActivity(),accuraConfigs.getBoolean("isCheckPhotoCopy"));
|
|
227
|
+
result.invoke(null, "Configs setup sucessfully");
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@ReactMethod
|
|
232
|
+
public boolean startFaceMatch2(ReadableArray argsNew, Callback callbackContext) throws JSONException {
|
|
233
|
+
JSONArray args = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
234
|
+
|
|
235
|
+
onResult = callbackContext;
|
|
236
|
+
ActivityFaceMatch.which = 3;
|
|
237
|
+
|
|
238
|
+
ActivityFaceMatch.No = 2;
|
|
239
|
+
JSONObject accuraConf = args.getJSONObject(0);
|
|
240
|
+
ActivityFaceMatch.faceMatchConfig = args.getJSONObject(1);
|
|
241
|
+
ActivityFaceMatch.sface = accuraConf.getString("face1");
|
|
242
|
+
ActivityFaceMatch.mface = accuraConf.getString("face2");
|
|
243
|
+
Intent intent = new Intent(getCurrentActivity(), ActivityFaceMatch.class);
|
|
244
|
+
getCurrentActivity().startActivity(intent);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@ReactMethod
|
|
249
|
+
public boolean openGallery1(ReadableArray argsNew, Callback callbackContext) throws JSONException {
|
|
250
|
+
JSONArray args = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
251
|
+
|
|
252
|
+
onResult = callbackContext;
|
|
253
|
+
ActivityFaceMatch.which = 2;
|
|
254
|
+
ActivityFaceMatch.No = 1;
|
|
255
|
+
JSONObject accuraConf = args.getJSONObject(0);
|
|
256
|
+
ActivityFaceMatch.sface = accuraConf.getString("face1");
|
|
257
|
+
ActivityFaceMatch.mface = accuraConf.getString("face2");
|
|
258
|
+
// JSONObject config = args.getJSONObject(1);
|
|
259
|
+
Intent intent = new Intent(getCurrentActivity(), ActivityFaceMatch.class);
|
|
260
|
+
// intent = addDefaultConfigs(intent, accuraConf);
|
|
261
|
+
// intent = addDefaultConfigs(intent, config);
|
|
262
|
+
Objects.requireNonNull(getCurrentActivity()).startActivity(intent);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@ReactMethod
|
|
267
|
+
public boolean openGallery2(ReadableArray argsNew, Callback callbackContext) throws JSONException {
|
|
268
|
+
JSONArray args = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
269
|
+
onResult = callbackContext;
|
|
270
|
+
ActivityFaceMatch.No = 2;
|
|
271
|
+
ActivityFaceMatch.which = 4;
|
|
272
|
+
JSONObject accuraConf = args.getJSONObject(0);
|
|
273
|
+
ActivityFaceMatch.sface = accuraConf.getString("face1");
|
|
274
|
+
ActivityFaceMatch.mface = accuraConf.getString("face2");
|
|
275
|
+
// JSONObject config = args.getJSONObject(1);
|
|
276
|
+
Intent intent = new Intent(getCurrentActivity(), ActivityFaceMatch.class);
|
|
277
|
+
// intent = ActivityFaceMatch(intent, accuraConf);
|
|
278
|
+
// intent = addDefaultConfigs(intent, config);
|
|
279
|
+
getCurrentActivity().startActivity(intent);
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
@ReactMethod
|
|
285
|
+
public boolean startFaceMatch1(ReadableArray argsNew, Callback callbackContext) throws JSONException {
|
|
286
|
+
JSONArray args = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
287
|
+
|
|
288
|
+
onResult = callbackContext;
|
|
289
|
+
ActivityFaceMatch.No = 1;
|
|
290
|
+
ActivityFaceMatch.which = 1;
|
|
291
|
+
JSONObject accuraConf = args.getJSONObject(0);
|
|
292
|
+
ActivityFaceMatch.faceMatchConfig = args.getJSONObject(1);
|
|
293
|
+
ActivityFaceMatch.sface = accuraConf.getString("face1");
|
|
294
|
+
ActivityFaceMatch.mface = accuraConf.getString("face2");
|
|
295
|
+
// JSONObject config = args.getJSONObject(1);
|
|
296
|
+
Intent intent = new Intent(getCurrentActivity(), ActivityFaceMatch.class);
|
|
297
|
+
// intent = addDefaultConfigs(intent, accuraConf);
|
|
298
|
+
// intent = addDefaultConfigs(intent, config);
|
|
299
|
+
getCurrentActivity().startActivity(intent);
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@ReactMethod
|
|
304
|
+
public boolean startOcrWithCard(ReadableArray argsNew, Callback callbackContext) throws JSONException {
|
|
305
|
+
JSONArray args = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
306
|
+
|
|
307
|
+
onResult = callbackContext;
|
|
308
|
+
OcrActivity.accuraErrorConfg = accuraErrorConfg;
|
|
309
|
+
OcrActivity.accuraTitleMsg = accuraTitleMsg;
|
|
310
|
+
|
|
311
|
+
int countryId = args.getInt(0);
|
|
312
|
+
int cardId = args.getInt(1);
|
|
313
|
+
String cardSelected = args.getString(2);
|
|
314
|
+
int cardType = args.getInt(3);
|
|
315
|
+
|
|
316
|
+
Intent intent = new Intent(getCurrentActivity(),OcrActivity.class);
|
|
317
|
+
intent.putExtra("country_id",countryId);
|
|
318
|
+
intent.putExtra("card_id",cardId);
|
|
319
|
+
intent.putExtra("card_name",cardSelected);
|
|
320
|
+
|
|
321
|
+
if (cardType == 1){
|
|
322
|
+
RecogType.PDF417.attachTo(intent);
|
|
323
|
+
OcrActivity.recogType = RecogType.PDF417;
|
|
324
|
+
}
|
|
325
|
+
else if (cardType == 2) {
|
|
326
|
+
RecogType.DL_PLATE.attachTo(intent);
|
|
327
|
+
OcrActivity.recogType = RecogType.DL_PLATE;
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
RecogType.OCR.attachTo(intent);
|
|
331
|
+
OcrActivity.recogType = RecogType.OCR;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
Objects.requireNonNull(getCurrentActivity()).startActivity(intent);
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
@ReactMethod
|
|
339
|
+
public boolean startMRZ( ReadableArray argsNew, Callback callbackContext ) throws JSONException {
|
|
340
|
+
JSONArray args = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
341
|
+
|
|
342
|
+
String mrzType = args.getString(0);
|
|
343
|
+
Intent intent = new Intent(getCurrentActivity(),OcrActivity.class);
|
|
344
|
+
RecogType.MRZ.attachTo(intent);
|
|
345
|
+
OcrActivity.recogType = RecogType.MRZ;
|
|
346
|
+
if (mrzType.equals("passport_mrz")) {
|
|
347
|
+
MRZDocumentType.PASSPORT_MRZ.attachTo(intent);
|
|
348
|
+
}else if (mrzType.equals("id_mrz")){
|
|
349
|
+
MRZDocumentType.ID_CARD_MRZ.attachTo(intent);
|
|
350
|
+
}else if (mrzType.equals("visa_card")){
|
|
351
|
+
MRZDocumentType.VISA_MRZ.attachTo(intent);
|
|
352
|
+
}else{
|
|
353
|
+
MRZDocumentType.NONE.attachTo(intent);
|
|
354
|
+
}
|
|
355
|
+
OcrActivity.accuraErrorConfg = accuraErrorConfg;
|
|
356
|
+
OcrActivity.accuraTitleMsg = accuraTitleMsg;
|
|
357
|
+
intent.putExtra("card_name",mrzType);
|
|
358
|
+
intent.putExtra("app_orientation", Objects.requireNonNull(getCurrentActivity()).getRequestedOrientation());
|
|
359
|
+
onResult = callbackContext;
|
|
360
|
+
|
|
361
|
+
getCurrentActivity().startActivity(intent);
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@ReactMethod
|
|
366
|
+
public boolean startBankCard(Callback callbackContext) throws JSONException {
|
|
367
|
+
onResult = callbackContext;
|
|
368
|
+
OcrActivity.accuraErrorConfg = accuraErrorConfg;
|
|
369
|
+
OcrActivity.accuraTitleMsg = accuraTitleMsg;
|
|
370
|
+
|
|
371
|
+
Intent intent = new Intent(getCurrentActivity(),OcrActivity.class);
|
|
372
|
+
intent.putExtra("card_name","Bank Card");
|
|
373
|
+
intent.putExtra("app_orientation", Objects.requireNonNull(getCurrentActivity()).getRequestedOrientation());
|
|
374
|
+
|
|
375
|
+
RecogType.BANKCARD.attachTo(intent);
|
|
376
|
+
OcrActivity.recogType = RecogType.BANKCARD;
|
|
377
|
+
|
|
378
|
+
getCurrentActivity().startActivity(intent);
|
|
379
|
+
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
@ReactMethod
|
|
384
|
+
public boolean startFaceMatch(ReadableArray argsNew, Callback callbackContext) throws JSONException {
|
|
385
|
+
onResult = callbackContext;
|
|
386
|
+
|
|
387
|
+
JSONArray arg = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
388
|
+
|
|
389
|
+
JSONObject uriL = arg.getJSONObject(0);
|
|
390
|
+
String uri = uriL.getString("face_uri");
|
|
391
|
+
OcrResultActivity.face1 = BitmapFactory.decodeFile(uri.replace("file://",""));
|
|
392
|
+
OcrResultActivity.which = 0;
|
|
393
|
+
OcrResultActivity.faceConfig = arg.getJSONObject(1);
|
|
394
|
+
Intent intent = new Intent(getCurrentActivity(),OcrResultActivity.class);
|
|
395
|
+
Objects.requireNonNull(getCurrentActivity()).startActivity(intent);
|
|
396
|
+
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
@ReactMethod
|
|
401
|
+
public boolean startLiveness(ReadableArray argsNew, Callback callbackContext) throws JSONException {
|
|
402
|
+
onResult = callbackContext;
|
|
403
|
+
|
|
404
|
+
JSONArray arg = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
405
|
+
JSONObject uriL = arg.getJSONObject(0);
|
|
406
|
+
String uri = uriL.getString("face_uri");
|
|
407
|
+
OcrResultActivity.face1 = BitmapFactory.decodeFile(uri.replace("file://",""));
|
|
408
|
+
OcrResultActivity.which = 1;
|
|
409
|
+
OcrResultActivity.livenessConfig = arg.getJSONObject(1);
|
|
410
|
+
Intent intent = new Intent(getCurrentActivity(),OcrResultActivity.class);
|
|
411
|
+
getCurrentActivity().startActivity(intent);
|
|
412
|
+
|
|
413
|
+
return true;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
@ReactMethod
|
|
419
|
+
public boolean startBarcode(ReadableArray argsNew, Callback callbackContext) throws JSONException {
|
|
420
|
+
onResult = callbackContext;
|
|
421
|
+
JSONArray args = ReactNativeJSON.convertArrayToJson(argsNew);
|
|
422
|
+
|
|
423
|
+
bType = args.getString(0);
|
|
424
|
+
OcrActivity.accuraErrorConfg = accuraErrorConfg;
|
|
425
|
+
OcrActivity.accuraTitleMsg = accuraTitleMsg;
|
|
426
|
+
OcrActivity.barcodeFormat = getBarcodeFormat(bType);
|
|
427
|
+
OcrActivity.recogType = RecogType.BARCODE;
|
|
428
|
+
Intent intent = new Intent(getCurrentActivity(),OcrActivity.class);
|
|
429
|
+
RecogType.BARCODE.attachTo(intent);
|
|
430
|
+
Objects.requireNonNull(getCurrentActivity()).startActivity(intent);
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
public static boolean isPermissionsGranted(Context context) {
|
|
435
|
+
String[] permissions = new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
|
436
|
+
for (String permission : permissions) {
|
|
437
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
|
438
|
+
if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
public void requestCameraPermission() {
|
|
447
|
+
int currentapiVersion = Build.VERSION.SDK_INT;
|
|
448
|
+
if (currentapiVersion >= Build.VERSION_CODES.M) {
|
|
449
|
+
if (ActivityCompat.checkSelfPermission(getCurrentActivity(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED
|
|
450
|
+
|| ActivityCompat.checkSelfPermission(getCurrentActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
451
|
+
if (ActivityCompat.shouldShowRequestPermissionRationale(getCurrentActivity(), Manifest.permission.CAMERA)
|
|
452
|
+
|| ActivityCompat.shouldShowRequestPermissionRationale(getCurrentActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
|
453
|
+
getCurrentActivity().requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
|
454
|
+
} else {
|
|
455
|
+
getCurrentActivity().requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
public int getBarcodeFormat(String barcode){
|
|
462
|
+
int resultOf = 0;
|
|
463
|
+
switch (bType) {
|
|
464
|
+
case "0.0": //"ALL FORMATS":
|
|
465
|
+
resultOf = 0;
|
|
466
|
+
break;
|
|
467
|
+
case "64.0": //"EAN-8":
|
|
468
|
+
resultOf = 64;
|
|
469
|
+
break;
|
|
470
|
+
case "32.0": //"EAN-13":
|
|
471
|
+
resultOf = 32;
|
|
472
|
+
break;
|
|
473
|
+
case "2048.0": //"PDF417":
|
|
474
|
+
resultOf = 2048;
|
|
475
|
+
break;
|
|
476
|
+
case "4096.0": //"AZTEC":
|
|
477
|
+
resultOf = 4096;
|
|
478
|
+
break;
|
|
479
|
+
case "1.0": //"CODE 128":
|
|
480
|
+
resultOf = 1;
|
|
481
|
+
break;
|
|
482
|
+
case "4.0": //"CODE 93":
|
|
483
|
+
resultOf = 4;
|
|
484
|
+
break;
|
|
485
|
+
case "2.0": //"CODE 39":
|
|
486
|
+
resultOf = 2;
|
|
487
|
+
break;
|
|
488
|
+
case "16.0": //"DATA MATRIX":
|
|
489
|
+
resultOf = 16;
|
|
490
|
+
break;
|
|
491
|
+
case "256.0": //"QR CODE":
|
|
492
|
+
resultOf = 256;
|
|
493
|
+
break;
|
|
494
|
+
case "8.0": //"CODABAR":
|
|
495
|
+
resultOf = 8;
|
|
496
|
+
break;
|
|
497
|
+
case "1024.0": //"UPC-E":
|
|
498
|
+
resultOf = 1024;
|
|
499
|
+
break;
|
|
500
|
+
case "512.0": //"UPC-A":
|
|
501
|
+
resultOf = 512;
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
return resultOf;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.accurascankyc;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.ReactPackage;
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
+
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
import java.util.Collections;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
|
|
14
|
+
public class AccurascanKycPackage implements ReactPackage {
|
|
15
|
+
@NonNull
|
|
16
|
+
@Override
|
|
17
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
18
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
19
|
+
modules.add(new AccurascanKycModule(reactContext));
|
|
20
|
+
return modules;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@NonNull
|
|
24
|
+
@Override
|
|
25
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
26
|
+
return Collections.emptyList();
|
|
27
|
+
}
|
|
28
|
+
}
|