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,736 @@
|
|
|
1
|
+
package com.accurascankyc;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.content.pm.ActivityInfo;
|
|
6
|
+
import android.graphics.Bitmap;
|
|
7
|
+
import android.graphics.Color;
|
|
8
|
+
import android.os.Bundle;
|
|
9
|
+
import android.os.Handler;
|
|
10
|
+
import android.view.View;
|
|
11
|
+
import android.widget.ImageView;
|
|
12
|
+
import android.widget.Toast;
|
|
13
|
+
|
|
14
|
+
import androidx.annotation.Nullable;
|
|
15
|
+
|
|
16
|
+
import com.accurascan.facedetection.LivenessCustomization;
|
|
17
|
+
import com.accurascan.facedetection.SelfieCameraActivity;
|
|
18
|
+
import com.accurascan.facedetection.model.AccuraVerificationResult;
|
|
19
|
+
import com.accurascan.facematch.util.BitmapHelper;
|
|
20
|
+
import com.androidnetworking.AndroidNetworking;
|
|
21
|
+
import com.facedetection.FMCameraScreenCustomization;
|
|
22
|
+
import com.facedetection.SelfieFMCameraActivity;
|
|
23
|
+
import com.facedetection.model.AccuraFMCameraModel;
|
|
24
|
+
import com.inet.facelock.callback.FaceCallback;
|
|
25
|
+
import com.inet.facelock.callback.FaceDetectionResult;
|
|
26
|
+
import com.inet.facelock.callback.FaceHelper;
|
|
27
|
+
|
|
28
|
+
import org.json.JSONException;
|
|
29
|
+
import org.json.JSONObject;
|
|
30
|
+
|
|
31
|
+
import java.security.cert.CertificateException;
|
|
32
|
+
|
|
33
|
+
import javax.net.ssl.HostnameVerifier;
|
|
34
|
+
import javax.net.ssl.SSLContext;
|
|
35
|
+
import javax.net.ssl.SSLSession;
|
|
36
|
+
import javax.net.ssl.SSLSocketFactory;
|
|
37
|
+
import javax.net.ssl.TrustManager;
|
|
38
|
+
import javax.net.ssl.X509TrustManager;
|
|
39
|
+
|
|
40
|
+
import okhttp3.OkHttpClient;
|
|
41
|
+
|
|
42
|
+
public class OcrResultActivity extends Activity implements FaceCallback {
|
|
43
|
+
|
|
44
|
+
public static Bitmap face1 ,sface,detectFace1,detectFace2;
|
|
45
|
+
private final int ACCURA_LIVENESS_CAMERA = 101;
|
|
46
|
+
private final int ACCURA_FACEMATCH_CAMERA = 102;
|
|
47
|
+
|
|
48
|
+
public static JSONObject faceConfig;
|
|
49
|
+
public static JSONObject livenessConfig;
|
|
50
|
+
ImageView ivUserProfile2;
|
|
51
|
+
View loutImg2;
|
|
52
|
+
public static int which;
|
|
53
|
+
private FaceHelper faceHelper;
|
|
54
|
+
// private TextView
|
|
55
|
+
JSONObject results = new JSONObject();
|
|
56
|
+
|
|
57
|
+
private boolean isFaceMatch = false, isLiveness = false;
|
|
58
|
+
|
|
59
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
60
|
+
|
|
61
|
+
AndroidNetworking.initialize(this, getUnsafeOkHttpClient());
|
|
62
|
+
|
|
63
|
+
faceHelper = new FaceHelper(this);
|
|
64
|
+
faceHelper.setFaceMatchCallBack(this);
|
|
65
|
+
faceHelper.initEngine();
|
|
66
|
+
if (getIntent().getIntExtra("app_orientation", 1) != 0) {
|
|
67
|
+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
68
|
+
} else {
|
|
69
|
+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
70
|
+
}
|
|
71
|
+
super.onCreate(savedInstanceState);
|
|
72
|
+
// setContentView("activity_ocr_result","layout");
|
|
73
|
+
// setContentView(R.layout.activity_ocr_result);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@Override
|
|
79
|
+
protected void onStart() {
|
|
80
|
+
super.onStart();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public void handleVerificationSuccessResult(final AccuraVerificationResult result) {
|
|
84
|
+
if (result != null) {
|
|
85
|
+
// showProgressDialog();
|
|
86
|
+
|
|
87
|
+
if (face1 != null) {
|
|
88
|
+
faceHelper.setInputImage(face1);
|
|
89
|
+
if (result.getFaceBiometrics() != null) {
|
|
90
|
+
if (result.getLivenessResult() == null) {
|
|
91
|
+
AccurascanKycModule.onResult.invoke("101","Retry...", null);
|
|
92
|
+
finish();
|
|
93
|
+
}
|
|
94
|
+
if (result.getLivenessResult().getLivenessStatus()) {
|
|
95
|
+
String lvscore = result.getLivenessResult().getLivenessScore() * 100 + "";
|
|
96
|
+
try {
|
|
97
|
+
results.put("score",lvscore);
|
|
98
|
+
} catch (JSONException e) {
|
|
99
|
+
e.printStackTrace();
|
|
100
|
+
}
|
|
101
|
+
Bitmap face2 = sface = result.getFaceBiometrics();
|
|
102
|
+
// Glide.with(OcrResultActivity.this).load(face2).centerCrop().into(ivUserProfile2);
|
|
103
|
+
if (face2 != null) {
|
|
104
|
+
faceHelper.setMatchImage(face2);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public void handleVerificationSuccessResult(final AccuraFMCameraModel result) {
|
|
115
|
+
try {
|
|
116
|
+
if (result != null) {
|
|
117
|
+
if (faceHelper!=null && face1 != null) {
|
|
118
|
+
faceHelper.setInputImage(face1);
|
|
119
|
+
}
|
|
120
|
+
String fileDir = getFilesDir().getAbsolutePath();
|
|
121
|
+
if (result.getFaceBiometrics() != null) {
|
|
122
|
+
Bitmap nBmp = sface = result.getFaceBiometrics();
|
|
123
|
+
faceHelper.setMatchImage(nBmp);
|
|
124
|
+
results.put("detect", AccurascanKycModule.getImageUri(nBmp, "detect", fileDir));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} catch (JSONException e) {
|
|
128
|
+
e.printStackTrace();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
private void setLivenessData(String livenessScore) {
|
|
134
|
+
|
|
135
|
+
// tvLivenessScore.setText(String.format("%s %%", livenessScore.length() > 5 ? livenessScore.substring(0, 5) : livenessScore));
|
|
136
|
+
// tvLivenessScore.setVisibility(View.VISIBLE);
|
|
137
|
+
// tvFaceMatchScore.setVisibility(View.VISIBLE);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Override
|
|
141
|
+
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
142
|
+
super.onActivityResult(requestCode, resultCode, data);
|
|
143
|
+
// if (resultCode == RESULT_OK) {
|
|
144
|
+
if (requestCode == 201 && data != null) {
|
|
145
|
+
AccuraVerificationResult result = data.getParcelableExtra("Accura.liveness");
|
|
146
|
+
if (result == null) {
|
|
147
|
+
AccurascanKycModule.onResult.invoke("101","Retry...", null);
|
|
148
|
+
this.finish();
|
|
149
|
+
}
|
|
150
|
+
if (result.getStatus().equals("1")) {
|
|
151
|
+
handleVerificationSuccessResult(result);
|
|
152
|
+
} else {
|
|
153
|
+
Toast.makeText(this, result.getErrorMessage(), Toast.LENGTH_SHORT).show();
|
|
154
|
+
AccurascanKycModule.onResult.invoke("101",result.getErrorMessage(), null);
|
|
155
|
+
finish();
|
|
156
|
+
}
|
|
157
|
+
} else if (requestCode == 102 && data != null) {
|
|
158
|
+
AccuraFMCameraModel result = data.getParcelableExtra("Accura.fm");
|
|
159
|
+
if (result == null) {
|
|
160
|
+
AccurascanKycModule.onResult.invoke("101","Retry...", null);
|
|
161
|
+
this.finish();
|
|
162
|
+
}
|
|
163
|
+
if (result.getStatus().equals("1")) {
|
|
164
|
+
handleVerificationSuccessResult(result);
|
|
165
|
+
} else {
|
|
166
|
+
Toast.makeText(this,"Retry..." , Toast.LENGTH_SHORT).show();
|
|
167
|
+
AccurascanKycModule.onResult.invoke("101","Retry...", null);
|
|
168
|
+
this.finish();
|
|
169
|
+
}
|
|
170
|
+
} else{
|
|
171
|
+
Toast.makeText(this,"Retry..." , Toast.LENGTH_SHORT).show();
|
|
172
|
+
AccurascanKycModule.onResult.invoke("101","Retry...", null);
|
|
173
|
+
this.finish();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@Override
|
|
178
|
+
protected void onDestroy() {
|
|
179
|
+
super.onDestroy();
|
|
180
|
+
if (faceHelper != null) {
|
|
181
|
+
faceHelper.closeEngine();
|
|
182
|
+
}
|
|
183
|
+
Runtime.getRuntime().gc();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@Override
|
|
187
|
+
public void onBackPressed() {
|
|
188
|
+
AccurascanKycModule.onResult.invoke("Exit","Exit",results.toString());
|
|
189
|
+
finish();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// public void onCLickFaceMatch(View view) {
|
|
193
|
+
// if (view.getId() == R.id.btn_fm) {
|
|
194
|
+
// isFaceMatch = true;
|
|
195
|
+
// isLiveness = false;
|
|
196
|
+
// } else if (view.getId() == R.id.btn_liveness) {
|
|
197
|
+
// isFaceMatch = false;
|
|
198
|
+
// isLiveness = true;
|
|
199
|
+
// }
|
|
200
|
+
// if (faceHelper == null) {
|
|
201
|
+
// faceHelper = new FaceHelper(this);
|
|
202
|
+
// faceHelper.setFaceMatchCallBack(this);
|
|
203
|
+
// faceHelper.initEngine();
|
|
204
|
+
// } else {
|
|
205
|
+
// performClick(isFaceMatch, isLiveness);
|
|
206
|
+
// }
|
|
207
|
+
//
|
|
208
|
+
// }
|
|
209
|
+
|
|
210
|
+
// private void performClick(boolean isFaceMatch, boolean isLiveness) {
|
|
211
|
+
// if (isFaceMatch) openCamera();
|
|
212
|
+
// else if (isLiveness) openLivenessCamera();
|
|
213
|
+
// }
|
|
214
|
+
|
|
215
|
+
private void openLivenessCamera() {
|
|
216
|
+
LivenessCustomization livenessCustomization = new LivenessCustomization();
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
if(livenessConfig.has("backGroundColor")){
|
|
220
|
+
livenessCustomization.backGroundColor = Color.parseColor(livenessConfig.getString("backGroundColor"));
|
|
221
|
+
}
|
|
222
|
+
} catch (JSONException e) {
|
|
223
|
+
e.printStackTrace();
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
if(livenessConfig.has("closeIconColor")){
|
|
227
|
+
livenessCustomization.closeIconColor = Color.parseColor(livenessConfig.getString("closeIconColor"));
|
|
228
|
+
}
|
|
229
|
+
} catch (JSONException e) {
|
|
230
|
+
e.printStackTrace();
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
if(livenessConfig.has("feedbackBackGroundColor")){
|
|
234
|
+
livenessCustomization.feedbackBackGroundColor = Color.parseColor(livenessConfig.getString("feedbackBackGroundColor"));
|
|
235
|
+
}
|
|
236
|
+
} catch (JSONException e) {
|
|
237
|
+
e.printStackTrace();
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
if(livenessConfig.has("feedbackTextColor")){
|
|
241
|
+
livenessCustomization.feedbackTextColor = Color.parseColor(livenessConfig.getString("feedbackTextColor"));
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
} catch (JSONException e) {
|
|
245
|
+
e.printStackTrace();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (livenessConfig.has("setFeedbackTextSize")){
|
|
249
|
+
try {
|
|
250
|
+
livenessCustomization.feedbackTextSize = livenessConfig.getInt("setFeedbackTextSize");
|
|
251
|
+
} catch (JSONException e) {
|
|
252
|
+
e.printStackTrace();
|
|
253
|
+
}
|
|
254
|
+
}else{
|
|
255
|
+
livenessCustomization.feedbackTextSize = 18;
|
|
256
|
+
}
|
|
257
|
+
if (livenessConfig.has("setFeedBackframeMessage")){
|
|
258
|
+
try {
|
|
259
|
+
livenessCustomization.feedBackframeMessage = livenessConfig.getString("setFeedBackframeMessage");
|
|
260
|
+
} catch (JSONException e) {
|
|
261
|
+
e.printStackTrace();
|
|
262
|
+
}
|
|
263
|
+
}else {
|
|
264
|
+
livenessCustomization.feedBackframeMessage = "Frame Your Face";
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
if (livenessConfig.has("setFeedBackAwayMessage")){
|
|
268
|
+
try {
|
|
269
|
+
livenessCustomization.feedBackAwayMessage = livenessConfig.getString("setFeedBackAwayMessage");
|
|
270
|
+
} catch (JSONException e) {
|
|
271
|
+
e.printStackTrace();
|
|
272
|
+
}
|
|
273
|
+
}else {
|
|
274
|
+
livenessCustomization.feedBackAwayMessage = "Move Phone Away";
|
|
275
|
+
}
|
|
276
|
+
if (livenessConfig.has("setFeedBackOpenEyesMessage")){
|
|
277
|
+
try {
|
|
278
|
+
livenessCustomization.feedBackOpenEyesMessage = livenessConfig.getString("setFeedBackOpenEyesMessage");
|
|
279
|
+
} catch (JSONException e) {
|
|
280
|
+
e.printStackTrace();
|
|
281
|
+
}
|
|
282
|
+
}else {
|
|
283
|
+
livenessCustomization.feedBackOpenEyesMessage = "Keep Your Eyes Open";
|
|
284
|
+
}
|
|
285
|
+
if (livenessConfig.has("setFeedBackCloserMessage")){
|
|
286
|
+
try {
|
|
287
|
+
livenessCustomization.feedBackCloserMessage = livenessConfig.getString("setFeedBackCloserMessage");
|
|
288
|
+
} catch (JSONException e) {
|
|
289
|
+
e.printStackTrace();
|
|
290
|
+
}
|
|
291
|
+
}else {
|
|
292
|
+
livenessCustomization.feedBackCloserMessage = "Move Phone Closer";
|
|
293
|
+
}
|
|
294
|
+
if (livenessConfig.has("setFeedBackCenterMessage")){
|
|
295
|
+
try {
|
|
296
|
+
livenessCustomization.feedBackCenterMessage = livenessConfig.getString("setFeedBackCenterMessage");
|
|
297
|
+
} catch (JSONException e) {
|
|
298
|
+
e.printStackTrace();
|
|
299
|
+
}
|
|
300
|
+
}else {
|
|
301
|
+
livenessCustomization.feedBackCenterMessage = "Move Phone Center";
|
|
302
|
+
}
|
|
303
|
+
if (livenessConfig.has("setFeedbackMultipleFaceMessage")){
|
|
304
|
+
try {
|
|
305
|
+
livenessCustomization.feedBackMultipleFaceMessage = livenessConfig.getString("setFeedbackMultipleFaceMessage");
|
|
306
|
+
} catch (JSONException e) {
|
|
307
|
+
e.printStackTrace();
|
|
308
|
+
}
|
|
309
|
+
}else {
|
|
310
|
+
livenessCustomization.feedBackMultipleFaceMessage = "Multiple Face Detected";
|
|
311
|
+
}
|
|
312
|
+
if (livenessConfig.has("setFeedBackFaceSteadymessage")){
|
|
313
|
+
try {
|
|
314
|
+
livenessCustomization.feedBackHeadStraightMessage = livenessConfig.getString("setFeedBackFaceSteadymessage");
|
|
315
|
+
} catch (JSONException e) {
|
|
316
|
+
e.printStackTrace();
|
|
317
|
+
}
|
|
318
|
+
}else {
|
|
319
|
+
livenessCustomization.feedBackHeadStraightMessage = "Keep Your Head Straight";
|
|
320
|
+
}
|
|
321
|
+
if (livenessConfig.has("setFeedBackBlurFaceMessage")){
|
|
322
|
+
try {
|
|
323
|
+
livenessCustomization.feedBackBlurFaceMessage = livenessConfig.getString("setFeedBackBlurFaceMessage");
|
|
324
|
+
} catch (JSONException e) {
|
|
325
|
+
e.printStackTrace();
|
|
326
|
+
}
|
|
327
|
+
}else {
|
|
328
|
+
livenessCustomization.feedBackBlurFaceMessage = "Blur Detected Over Face";
|
|
329
|
+
}
|
|
330
|
+
if (livenessConfig.has("setFeedBackLowLightMessage")){
|
|
331
|
+
try {
|
|
332
|
+
livenessCustomization.feedBackLowLightMessage = livenessConfig.getString("setFeedBackLowLightMessage");
|
|
333
|
+
} catch (JSONException e) {
|
|
334
|
+
e.printStackTrace();
|
|
335
|
+
}
|
|
336
|
+
}else {
|
|
337
|
+
livenessCustomization.feedBackLowLightMessage = "Low light detected";
|
|
338
|
+
}
|
|
339
|
+
if (livenessConfig.has("setFeedBackGlareFaceMessage")){
|
|
340
|
+
try {
|
|
341
|
+
livenessCustomization.feedBackGlareFaceMessage = livenessConfig.getString("setFeedBackGlareFaceMessage");
|
|
342
|
+
} catch (JSONException e) {
|
|
343
|
+
e.printStackTrace();
|
|
344
|
+
}
|
|
345
|
+
}else {
|
|
346
|
+
livenessCustomization.feedBackGlareFaceMessage = "Glare Detected";
|
|
347
|
+
}
|
|
348
|
+
if (livenessConfig.has("setBlurPercentage")){
|
|
349
|
+
try {
|
|
350
|
+
livenessCustomization.setBlurPercentage(livenessConfig.getInt("setBlurPercentage"));
|
|
351
|
+
} catch (JSONException e) {
|
|
352
|
+
e.printStackTrace();
|
|
353
|
+
}
|
|
354
|
+
}else {
|
|
355
|
+
livenessCustomization.setBlurPercentage(80);
|
|
356
|
+
}
|
|
357
|
+
if (livenessConfig.has("setGlarePercentage_0") && livenessConfig.has("setGlarePercentage_1")){
|
|
358
|
+
try {
|
|
359
|
+
livenessCustomization.setGlarePercentage(livenessConfig.getInt("setGlarePercentage_0"),livenessConfig.getInt("setGlarePercentage_1"));
|
|
360
|
+
} catch (JSONException e) {
|
|
361
|
+
e.printStackTrace();
|
|
362
|
+
}
|
|
363
|
+
}else {
|
|
364
|
+
livenessCustomization.setGlarePercentage(-1, -1);
|
|
365
|
+
}
|
|
366
|
+
if (livenessConfig.has("feedbackLowLightTolerence")){
|
|
367
|
+
try {
|
|
368
|
+
livenessCustomization.setLowLightTolerence(livenessConfig.getInt("feedbackLowLightTolerence"));
|
|
369
|
+
} catch (JSONException e) {
|
|
370
|
+
e.printStackTrace();
|
|
371
|
+
}
|
|
372
|
+
}else {
|
|
373
|
+
livenessCustomization.setLowLightTolerence(-1/*lowLightTolerence*/);
|
|
374
|
+
}
|
|
375
|
+
if (livenessConfig.has("setfeedbackDialogMessage")){
|
|
376
|
+
try {
|
|
377
|
+
livenessCustomization.feedbackDialogMessage = livenessConfig.getString("setfeedbackDialogMessage");
|
|
378
|
+
} catch (JSONException e) {
|
|
379
|
+
e.printStackTrace();
|
|
380
|
+
}
|
|
381
|
+
}else {
|
|
382
|
+
livenessCustomization.feedbackDialogMessage = "Loading...";
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
if(livenessConfig.has("feedBackProcessingMessage")){
|
|
386
|
+
livenessCustomization.feedBackProcessingMessage = livenessConfig.getString("feedBackProcessingMessage");
|
|
387
|
+
}
|
|
388
|
+
} catch (JSONException e) {
|
|
389
|
+
e.printStackTrace();
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
if(livenessConfig.has("isShowLogo")){
|
|
393
|
+
livenessCustomization.showlogo = livenessConfig.getInt("isShowLogo"); // Set 0 to hide logo from selfie camera screen
|
|
394
|
+
}
|
|
395
|
+
} catch (JSONException e) {
|
|
396
|
+
e.printStackTrace();
|
|
397
|
+
}
|
|
398
|
+
//livenessCustomization.logoIcon = R.drawable.accura_liveness_logo; // To set your custom logo
|
|
399
|
+
//livenessCustomization.facing = LivenessCustomization.CAMERA_FACING_FRONT;
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
Intent intent = null;
|
|
403
|
+
try {
|
|
404
|
+
intent = SelfieCameraActivity.getCustomIntent(this, livenessCustomization, livenessConfig.getString("setLivenessURL"));
|
|
405
|
+
} catch (JSONException e) {
|
|
406
|
+
e.printStackTrace();
|
|
407
|
+
}
|
|
408
|
+
startActivityForResult(intent, 201);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private void openCamera() {
|
|
412
|
+
|
|
413
|
+
FMCameraScreenCustomization cameraScreenCustomization = new FMCameraScreenCustomization();
|
|
414
|
+
|
|
415
|
+
try {
|
|
416
|
+
if(faceConfig.has("backGroundColor")){
|
|
417
|
+
cameraScreenCustomization.backGroundColor = Color.parseColor(faceConfig.getString("backGroundColor"));
|
|
418
|
+
}
|
|
419
|
+
} catch (JSONException e) {
|
|
420
|
+
e.printStackTrace();
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
if(faceConfig.has("closeIconColor")){
|
|
424
|
+
cameraScreenCustomization.closeIconColor = Color.parseColor(faceConfig.getString("closeIconColor"));
|
|
425
|
+
}
|
|
426
|
+
} catch (JSONException e) {
|
|
427
|
+
e.printStackTrace();
|
|
428
|
+
}
|
|
429
|
+
try {
|
|
430
|
+
if(faceConfig.has("feedbackBackGroundColor")){
|
|
431
|
+
cameraScreenCustomization.feedbackBackGroundColor = Color.parseColor(faceConfig.getString("feedbackBackGroundColor"));
|
|
432
|
+
}
|
|
433
|
+
} catch (JSONException e) {
|
|
434
|
+
e.printStackTrace();
|
|
435
|
+
}
|
|
436
|
+
try {
|
|
437
|
+
if(faceConfig.has("feedbackTextColor")){
|
|
438
|
+
cameraScreenCustomization.feedbackTextColor = Color.parseColor(faceConfig.getString("feedbackTextColor"));
|
|
439
|
+
}
|
|
440
|
+
} catch (JSONException e) {
|
|
441
|
+
e.printStackTrace();
|
|
442
|
+
}
|
|
443
|
+
if (faceConfig.has("setFeedbackTextSize")){
|
|
444
|
+
try {
|
|
445
|
+
cameraScreenCustomization.feedbackTextSize = faceConfig.getInt("setFeedbackTextSize");
|
|
446
|
+
} catch (JSONException e) {
|
|
447
|
+
e.printStackTrace();
|
|
448
|
+
}
|
|
449
|
+
}else{
|
|
450
|
+
cameraScreenCustomization.feedbackTextSize = 18;
|
|
451
|
+
}
|
|
452
|
+
if (faceConfig.has("setFeedBackframeMessage")){
|
|
453
|
+
try {
|
|
454
|
+
cameraScreenCustomization.feedBackframeMessage = faceConfig.getString("setFeedBackframeMessage");
|
|
455
|
+
} catch (JSONException e) {
|
|
456
|
+
e.printStackTrace();
|
|
457
|
+
}
|
|
458
|
+
}else{
|
|
459
|
+
cameraScreenCustomization.feedBackframeMessage = "Frame Your Face";
|
|
460
|
+
}
|
|
461
|
+
if (faceConfig.has("setFeedBackAwayMessage")){
|
|
462
|
+
try {
|
|
463
|
+
cameraScreenCustomization.feedBackAwayMessage = faceConfig.getString("setFeedBackAwayMessage");
|
|
464
|
+
} catch (JSONException e) {
|
|
465
|
+
e.printStackTrace();
|
|
466
|
+
}
|
|
467
|
+
}else{
|
|
468
|
+
cameraScreenCustomization.feedBackAwayMessage = "Move Phone Away";
|
|
469
|
+
}
|
|
470
|
+
if (faceConfig.has("setFeedBackOpenEyesMessage")){
|
|
471
|
+
try {
|
|
472
|
+
cameraScreenCustomization.feedBackOpenEyesMessage = faceConfig.getString("setFeedBackOpenEyesMessage");
|
|
473
|
+
} catch (JSONException e) {
|
|
474
|
+
e.printStackTrace();
|
|
475
|
+
}
|
|
476
|
+
}else{
|
|
477
|
+
cameraScreenCustomization.feedBackOpenEyesMessage = "Keep Your Eyes Open";
|
|
478
|
+
}
|
|
479
|
+
if (faceConfig.has("setFeedBackCloserMessage")){
|
|
480
|
+
try {
|
|
481
|
+
cameraScreenCustomization.feedBackCloserMessage = faceConfig.getString("setFeedBackCloserMessage");
|
|
482
|
+
} catch (JSONException e) {
|
|
483
|
+
e.printStackTrace();
|
|
484
|
+
}
|
|
485
|
+
}else{
|
|
486
|
+
cameraScreenCustomization.feedBackCloserMessage = "Move Phone Closer";
|
|
487
|
+
}
|
|
488
|
+
if (faceConfig.has("setFeedBackCenterMessage")){
|
|
489
|
+
try {
|
|
490
|
+
cameraScreenCustomization.feedBackCenterMessage = faceConfig.getString("setFeedBackCenterMessage");
|
|
491
|
+
} catch (JSONException e) {
|
|
492
|
+
e.printStackTrace();
|
|
493
|
+
}
|
|
494
|
+
}else{
|
|
495
|
+
cameraScreenCustomization.feedBackCenterMessage = "Move Phone Center";
|
|
496
|
+
}
|
|
497
|
+
if (faceConfig.has("setFeedbackMultipleFaceMessage")){
|
|
498
|
+
try {
|
|
499
|
+
cameraScreenCustomization.feedBackMultipleFaceMessage = faceConfig.getString("setFeedbackMultipleFaceMessage");
|
|
500
|
+
} catch (JSONException e) {
|
|
501
|
+
e.printStackTrace();
|
|
502
|
+
}
|
|
503
|
+
}else{
|
|
504
|
+
cameraScreenCustomization.feedBackMultipleFaceMessage = "Multiple Face Detected";
|
|
505
|
+
}
|
|
506
|
+
if (faceConfig.has("setFeedBackFaceSteadymessage")){
|
|
507
|
+
try {
|
|
508
|
+
cameraScreenCustomization.feedBackHeadStraightMessage = faceConfig.getString("setFeedBackFaceSteadymessage");
|
|
509
|
+
} catch (JSONException e) {
|
|
510
|
+
e.printStackTrace();
|
|
511
|
+
}
|
|
512
|
+
}else{
|
|
513
|
+
cameraScreenCustomization.feedBackHeadStraightMessage = "Keep Your Head Straight";
|
|
514
|
+
|
|
515
|
+
}
|
|
516
|
+
if (faceConfig.has("setFeedBackLowLightMessage")){
|
|
517
|
+
try {
|
|
518
|
+
cameraScreenCustomization.feedBackLowLightMessage = faceConfig.getString("setFeedBackLowLightMessage");
|
|
519
|
+
} catch (JSONException e) {
|
|
520
|
+
e.printStackTrace();
|
|
521
|
+
}
|
|
522
|
+
}else{
|
|
523
|
+
cameraScreenCustomization.feedBackLowLightMessage = "Low light detected";
|
|
524
|
+
}
|
|
525
|
+
if (faceConfig.has("setFeedBackBlurFaceMessage")){
|
|
526
|
+
try {
|
|
527
|
+
cameraScreenCustomization.feedBackBlurFaceMessage = faceConfig.getString("setFeedBackBlurFaceMessage");
|
|
528
|
+
} catch (JSONException e) {
|
|
529
|
+
e.printStackTrace();
|
|
530
|
+
}
|
|
531
|
+
}else{
|
|
532
|
+
cameraScreenCustomization.feedBackBlurFaceMessage = "Blur Detected Over Face";
|
|
533
|
+
}
|
|
534
|
+
if (faceConfig.has("setFeedBackGlareFaceMessage")){
|
|
535
|
+
try {
|
|
536
|
+
cameraScreenCustomization.feedBackGlareFaceMessage = faceConfig.getString("setFeedBackGlareFaceMessage");
|
|
537
|
+
} catch (JSONException e) {
|
|
538
|
+
e.printStackTrace();
|
|
539
|
+
}
|
|
540
|
+
}else{
|
|
541
|
+
cameraScreenCustomization.feedBackGlareFaceMessage = "Glare Detected";
|
|
542
|
+
}
|
|
543
|
+
if (faceConfig.has("setBlurPercentage")){
|
|
544
|
+
try {
|
|
545
|
+
cameraScreenCustomization.setBlurPercentage(faceConfig.getInt("setBlurPercentage"));
|
|
546
|
+
} catch (JSONException e) {
|
|
547
|
+
e.printStackTrace();
|
|
548
|
+
}
|
|
549
|
+
}else{
|
|
550
|
+
cameraScreenCustomization.setBlurPercentage(80);
|
|
551
|
+
}
|
|
552
|
+
if (faceConfig.has("setGlarePercentage_0") && faceConfig.has("setGlarePercentage_1")){
|
|
553
|
+
try {
|
|
554
|
+
cameraScreenCustomization.setGlarePercentage(faceConfig.getInt("setGlarePercentage_0"),faceConfig.getInt("setGlarePercentage_1"));
|
|
555
|
+
} catch (JSONException e) {
|
|
556
|
+
e.printStackTrace();
|
|
557
|
+
}
|
|
558
|
+
}else{
|
|
559
|
+
cameraScreenCustomization.setGlarePercentage(-1, -1);
|
|
560
|
+
}
|
|
561
|
+
if (faceConfig.has("setfeedbackDialogMessage")){
|
|
562
|
+
try {
|
|
563
|
+
cameraScreenCustomization.feedbackDialogMessage = faceConfig.getString("setfeedbackDialogMessage");
|
|
564
|
+
} catch (JSONException e) {
|
|
565
|
+
e.printStackTrace();
|
|
566
|
+
}
|
|
567
|
+
}else {
|
|
568
|
+
cameraScreenCustomization.feedbackDialogMessage = "Loading...";
|
|
569
|
+
}
|
|
570
|
+
if (faceConfig.has("setfeedBackProcessingMessage")){
|
|
571
|
+
try {
|
|
572
|
+
cameraScreenCustomization.feedBackProcessingMessage = faceConfig.getString("setfeedBackProcessingMessage");
|
|
573
|
+
} catch (JSONException e) {
|
|
574
|
+
e.printStackTrace();
|
|
575
|
+
}
|
|
576
|
+
}else{
|
|
577
|
+
cameraScreenCustomization.feedBackProcessingMessage = "Processing...";
|
|
578
|
+
}
|
|
579
|
+
if (faceConfig.has("isshowlogo")){
|
|
580
|
+
try {
|
|
581
|
+
cameraScreenCustomization.showlogo = faceConfig.getInt("isshowlogo"); // Set 0 if hide logo
|
|
582
|
+
} catch (JSONException e) {
|
|
583
|
+
e.printStackTrace();
|
|
584
|
+
}
|
|
585
|
+
}else{
|
|
586
|
+
cameraScreenCustomization.showlogo = 1; // Set 0 if hide logo
|
|
587
|
+
}
|
|
588
|
+
if (faceConfig.has("setLowLightTolerence")){
|
|
589
|
+
try {
|
|
590
|
+
cameraScreenCustomization.setLowLightTolerence(faceConfig.getInt("setLowLightTolerence"));
|
|
591
|
+
} catch (JSONException e) {
|
|
592
|
+
e.printStackTrace();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
}else {
|
|
596
|
+
cameraScreenCustomization.setLowLightTolerence(-1);
|
|
597
|
+
}
|
|
598
|
+
//cameraScreenCustomization.logoIcon = R.drawable.accura_fm_logo; // To set your custom logo
|
|
599
|
+
|
|
600
|
+
//cameraScreenCustomization.facing = FMCameraScreenCustomization.CAMERA_FACING_FRONT;
|
|
601
|
+
Intent intent = SelfieFMCameraActivity.getCustomIntent(this, cameraScreenCustomization);
|
|
602
|
+
startActivityForResult(intent, ACCURA_FACEMATCH_CAMERA);
|
|
603
|
+
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
@Override
|
|
607
|
+
public void onFaceMatch(float score) {
|
|
608
|
+
if (which == 0) {
|
|
609
|
+
String fileDir = getFilesDir().getAbsolutePath();
|
|
610
|
+
if (face1 != null && sface != null) {
|
|
611
|
+
try {
|
|
612
|
+
results.put("score", score);
|
|
613
|
+
results.put("detect", AccurascanKycModule.getImageUri(sface, "detect", fileDir));
|
|
614
|
+
} catch (JSONException e) {
|
|
615
|
+
e.printStackTrace();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
AccurascanKycModule.onResult.invoke(null,results.toString());
|
|
619
|
+
sface = null;
|
|
620
|
+
face1 = null;
|
|
621
|
+
this.finish();
|
|
622
|
+
}
|
|
623
|
+
} else if (which == 1) {
|
|
624
|
+
String fileDir = getFilesDir().getAbsolutePath();
|
|
625
|
+
if (face1 != null && sface != null) {
|
|
626
|
+
try {
|
|
627
|
+
results.put("face_score", score);
|
|
628
|
+
results.put("detect", AccurascanKycModule.getImageUri(sface, "detect", fileDir));
|
|
629
|
+
} catch (JSONException e) {
|
|
630
|
+
e.printStackTrace();
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
AccurascanKycModule.onResult.invoke(null,results.toString());
|
|
634
|
+
sface = null;
|
|
635
|
+
face1 = null;
|
|
636
|
+
this.finish();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
// AccurascanKycModule.onResult.success(results.toString());
|
|
640
|
+
//
|
|
641
|
+
// finish();
|
|
642
|
+
// tvFaceMatchScore.setText(String.format(getString(R.string.score_formate), score));
|
|
643
|
+
// tvLivenessScore.setVisibility(View.VISIBLE);
|
|
644
|
+
// tvFaceMatchScore.setVisibility(View.VISIBLE);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
@Override
|
|
648
|
+
public void onSetInputImage(Bitmap bitmap) {
|
|
649
|
+
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
@Override
|
|
653
|
+
public void onSetMatchImage(Bitmap bitmap) {
|
|
654
|
+
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
@Override
|
|
658
|
+
public void onInitEngine(int i) {
|
|
659
|
+
if (i != -1) {
|
|
660
|
+
if (which == 0){
|
|
661
|
+
openCamera();
|
|
662
|
+
}else if (which == 1){
|
|
663
|
+
openLivenessCamera();
|
|
664
|
+
}
|
|
665
|
+
// performClick(isFaceMatch, isLiveness);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
@Override
|
|
670
|
+
public void onLeftDetect(FaceDetectionResult faceDetectionResult) {
|
|
671
|
+
Bitmap det = BitmapHelper.createFromARGB(faceDetectionResult.getNewImg(), faceDetectionResult.getNewWidth(), faceDetectionResult.getNewHeight());
|
|
672
|
+
detectFace1 = faceDetectionResult.getFaceImage(det);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
@Override
|
|
676
|
+
public void onRightDetect(FaceDetectionResult faceDetectionResult) {
|
|
677
|
+
if (faceDetectionResult != null) {
|
|
678
|
+
try {
|
|
679
|
+
Bitmap face2 = BitmapHelper.createFromARGB(faceDetectionResult.getNewImg(), faceDetectionResult.getNewWidth(), faceDetectionResult.getNewHeight());
|
|
680
|
+
detectFace2 = faceDetectionResult.getFaceImage(face2);
|
|
681
|
+
} catch (Exception e) {
|
|
682
|
+
e.printStackTrace();
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
//faceHelper.onRightDetect(faceDetectionResult);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
@Override
|
|
689
|
+
public void onExtractInit(int i) {
|
|
690
|
+
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
public static OkHttpClient getUnsafeOkHttpClient() {
|
|
694
|
+
try {
|
|
695
|
+
// Create a trust manager that does not validate certificate chains
|
|
696
|
+
final TrustManager[] trustAllCerts = new TrustManager[] {
|
|
697
|
+
new X509TrustManager() {
|
|
698
|
+
@Override
|
|
699
|
+
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
@Override
|
|
703
|
+
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
@Override
|
|
707
|
+
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
|
708
|
+
return new java.security.cert.X509Certificate[]{};
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
// Install the all-trusting trust manager
|
|
714
|
+
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
|
715
|
+
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
|
716
|
+
|
|
717
|
+
// Create an ssl socket factory with our all-trusting manager
|
|
718
|
+
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
|
|
719
|
+
|
|
720
|
+
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
|
721
|
+
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager)trustAllCerts[0]);
|
|
722
|
+
builder.hostnameVerifier(new HostnameVerifier() {
|
|
723
|
+
@Override
|
|
724
|
+
public boolean verify(String hostname, SSLSession session) {
|
|
725
|
+
return true;
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
OkHttpClient okHttpClient = builder.build();
|
|
730
|
+
return okHttpClient;
|
|
731
|
+
} catch (Exception e) {
|
|
732
|
+
throw new RuntimeException(e);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
}
|