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.
Files changed (66) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +635 -0
  3. package/accurascan-kyc.podspec +38 -0
  4. package/android/build.gradle +118 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +18 -0
  7. package/android/src/main/java/com/accurascankyc/AccurascanKycModule.java +507 -0
  8. package/android/src/main/java/com/accurascankyc/AccurascanKycPackage.java +28 -0
  9. package/android/src/main/java/com/accurascankyc/ActivityFaceMatch.java +533 -0
  10. package/android/src/main/java/com/accurascankyc/BorderTextView.java +82 -0
  11. package/android/src/main/java/com/accurascankyc/OcrActivity.java +1263 -0
  12. package/android/src/main/java/com/accurascankyc/OcrResultActivity.java +736 -0
  13. package/android/src/main/java/com/accurascankyc/ReactNativeJson.java +123 -0
  14. package/android/src/main/java/com/accurascankyc/UnsafeOkHttpClient.java +57 -0
  15. package/android/src/main/res/drawable/btn_bg_gray.xml +6 -0
  16. package/android/src/main/res/drawable/btn_bg_red.xml +6 -0
  17. package/android/src/main/res/drawable/btn_bg_trasparent_bottom.xml +6 -0
  18. package/android/src/main/res/drawable/flip_camera_icon.png +0 -0
  19. package/android/src/main/res/drawable/ic_close.xml +5 -0
  20. package/android/src/main/res/drawable/round_border_rect.xml +12 -0
  21. package/android/src/main/res/drawable/splash.png +0 -0
  22. package/android/src/main/res/drawable-v24/ic_launcher_foreground.png +0 -0
  23. package/android/src/main/res/drawable-xhdpi/bg_home.png +0 -0
  24. package/android/src/main/res/drawable-xhdpi/ic_barcode.png +0 -0
  25. package/android/src/main/res/drawable-xhdpi/ic_biometric.png +0 -0
  26. package/android/src/main/res/drawable-xhdpi/ic_check.png +0 -0
  27. package/android/src/main/res/drawable-xhdpi/ic_liveness.png +0 -0
  28. package/android/src/main/res/drawable-xhdpi/ic_result.png +0 -0
  29. package/android/src/main/res/drawable-xhdpi/ic_scan.png +0 -0
  30. package/android/src/main/res/drawable-xhdpi/img_button_overlay.png +0 -0
  31. package/android/src/main/res/layout/activity_ocr_result.xml +18 -0
  32. package/android/src/main/res/layout/activity_splash.xml +26 -0
  33. package/android/src/main/res/layout/custom_frame_layout.xml +144 -0
  34. package/android/src/main/res/layout/ocr_activity.xml +28 -0
  35. package/android/src/main/res/layout-land/custom_frame_layout.xml +144 -0
  36. package/android/src/main/res/layout-land/ocr_activity.xml +41 -0
  37. package/android/src/main/res/menu/menu_land_port.xml +7 -0
  38. package/android/src/main/res/mipmap-hdpi/logo_loign.png +0 -0
  39. package/android/src/main/res/mipmap-mdpi/logo_loign.png +0 -0
  40. package/android/src/main/res/mipmap-xhdpi/ic_document_verified.png +0 -0
  41. package/android/src/main/res/mipmap-xhdpi/logo_loign.png +0 -0
  42. package/android/src/main/res/mipmap-xxhdpi/logo_loign.png +0 -0
  43. package/android/src/main/res/values/colors.xml +31 -0
  44. package/android/src/main/res/values/strings.xml +42 -0
  45. package/android/src/main/res/values/styles.xml +191 -0
  46. package/ios/AccurascanKyc-Bridging-Header.h +2 -0
  47. package/ios/AccurascanKyc.m +34 -0
  48. package/ios/AccurascanKyc.swift +649 -0
  49. package/ios/AccurascanKyc.xcodeproj/project.pbxproj +283 -0
  50. package/ios/AccurascanKyc.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  51. package/ios/FMController.swift +587 -0
  52. package/ios/LVController.swift +346 -0
  53. package/ios/MainStoryboard_iPhone.storyboard +338 -0
  54. package/ios/ViewController.swift +2686 -0
  55. package/ios/resources/back_icon.png +0 -0
  56. package/ios/resources/flip_camera_icon.png +0 -0
  57. package/ios/resources/flip_document_icon.png +0 -0
  58. package/ios/resources/ic_logo.png +0 -0
  59. package/lib/commonjs/index.js +13 -0
  60. package/lib/commonjs/index.js.map +1 -0
  61. package/lib/module/index.js +6 -0
  62. package/lib/module/index.js.map +1 -0
  63. package/lib/typescript/index.d.ts +3 -0
  64. package/lib/typescript/index.d.ts.map +1 -0
  65. package/package.json +161 -0
  66. package/src/index.tsx +5 -0
@@ -0,0 +1,533 @@
1
+ package com.accurascankyc;
2
+
3
+ import android.app.Activity;
4
+ import android.content.Intent;
5
+ import android.graphics.Bitmap;
6
+ import android.graphics.Color;
7
+ import android.net.Uri;
8
+ import android.os.Bundle;
9
+ import android.provider.MediaStore;
10
+ import android.util.Log;
11
+ import android.widget.Toast;
12
+
13
+ import com.accurascan.facematch.customview.FaceImageview;
14
+ import com.accurascan.facematch.util.BitmapHelper;
15
+ import com.accurascankyc.AccurascanKycModule;
16
+ import com.accurascankyc.R;
17
+ import com.facedetection.FMCameraScreenCustomization;
18
+ import com.facedetection.SelfieFMCameraActivity;
19
+ import com.facedetection.model.AccuraFMCameraModel;
20
+ import com.inet.facelock.callback.FaceCallback;
21
+ import com.inet.facelock.callback.FaceDetectionResult;
22
+ import com.inet.facelock.callback.FaceHelper;
23
+
24
+ import org.json.JSONException;
25
+ import org.json.JSONObject;
26
+
27
+ import java.io.IOException;
28
+ import java.text.NumberFormat;
29
+
30
+ public class ActivityFaceMatch extends Activity implements FaceCallback {
31
+ FaceHelper helper;
32
+ Bitmap face1, detectFace1, detectFace2, face2;
33
+ Bundle bundle;
34
+ FaceImageview image1;
35
+ FaceImageview image2;
36
+
37
+ int ind;
38
+
39
+ public static String sface;
40
+ public static String mface;
41
+ JSONObject results = new JSONObject();
42
+ final private int PICK_IMAGE = 1;
43
+ private static final int ACCURA_FACEMATCH_CAMERA = 3;
44
+ public static int which;
45
+ public static int No;
46
+ public static JSONObject faceMatchConfig;
47
+
48
+
49
+ @Override
50
+ protected void onCreate(Bundle savedInstanceState) {
51
+ super.onCreate(savedInstanceState);
52
+
53
+
54
+ helper = new FaceHelper(this);
55
+ helper.setFaceMatchCallBack(this);
56
+ helper.initEngine();
57
+ image1 = new FaceImageview(this); //initialize the view of front image
58
+ image2 = new FaceImageview(this);
59
+ bundle = getIntent().getExtras();
60
+ // sface = bundle.getString("face1", "");
61
+ // mface = bundle.getString("face2", "");
62
+
63
+
64
+ if(!sface.equals("")){
65
+ try {
66
+ face1 = MediaStore.Images.Media.getBitmap(this.getContentResolver() , Uri.parse(sface));
67
+ helper.setInputImage(face1);
68
+ } catch (IOException e) {
69
+ e.printStackTrace();
70
+ }
71
+ }
72
+ if(!mface.equals("")){
73
+ try {
74
+ face2 = MediaStore.Images.Media.getBitmap(this.getContentResolver() , Uri.parse(mface));
75
+ helper.setMatchImage(face2);
76
+ } catch (IOException e) {
77
+ e.printStackTrace();
78
+ }
79
+ }
80
+
81
+ if (which == 2){
82
+ AccurascanKycModule.face1 = null;
83
+ face1 = null;
84
+ startGallery();
85
+ }else if (which == 4){
86
+ AccurascanKycModule.face2 = null;
87
+ face2 = null;
88
+ startGallery2();
89
+ } else if (which == 1){
90
+ AccurascanKycModule.face1 = null;
91
+ face1 = null;
92
+ ind = No;
93
+ openFaceMatchCamera();
94
+ } else if (which == 3){
95
+ AccurascanKycModule.face2 = null;
96
+ face2 = null;
97
+ ind = No;
98
+ openFaceMatchCamera();
99
+ }
100
+ }
101
+
102
+ public void startGallery(){
103
+ ind = No;
104
+ Intent intent = new Intent();
105
+ intent.setType("image/*");
106
+ intent.setAction(Intent.ACTION_GET_CONTENT);
107
+ startActivityForResult(Intent.createChooser(intent, ""), PICK_IMAGE);
108
+ }
109
+
110
+ public void startGallery2(){
111
+ ind = No;
112
+ Intent intent = new Intent();
113
+ intent.setType("image/*");
114
+ intent.setAction(Intent.ACTION_GET_CONTENT);
115
+ startActivityForResult(Intent.createChooser(intent, ""), PICK_IMAGE);
116
+ }
117
+
118
+
119
+
120
+ private void openFaceMatchCamera() {
121
+
122
+
123
+ FMCameraScreenCustomization cameraScreenCustomization = new FMCameraScreenCustomization();
124
+
125
+ // cameraScreenCustomization.backGroundColor = getResources().getColor(R.color.fm_camera_Background);
126
+ // cameraScreenCustomization.closeIconColor = getResources().getColor(R.color.fm_camera_CloseIcon);
127
+ // cameraScreenCustomization.feedbackBackGroundColor = getResources().getColor(R.color.fm_camera_feedbackBg);
128
+ // cameraScreenCustomization.feedbackTextColor = getResources().getColor(R.color.fm_camera_feedbackText);
129
+ try {
130
+ if (faceMatchConfig.has("backGroundColor")){
131
+ cameraScreenCustomization.backGroundColor = Color.parseColor(faceMatchConfig.getString("backGroundColor"));
132
+ }
133
+ } catch (JSONException e) {
134
+ e.printStackTrace();
135
+ }
136
+ try {
137
+ if (faceMatchConfig.has("closeIconColor")){
138
+ cameraScreenCustomization.closeIconColor = Color.parseColor(faceMatchConfig.getString("closeIconColor"));
139
+ }
140
+ } catch (JSONException e) {
141
+ e.printStackTrace();
142
+ }
143
+ try {
144
+ if (faceMatchConfig.has("feedbackBackGroundColor")){
145
+ cameraScreenCustomization.feedbackBackGroundColor = Color.parseColor(faceMatchConfig.getString("feedbackBackGroundColor"));
146
+ }
147
+ } catch (JSONException e) {
148
+ e.printStackTrace();
149
+ }
150
+ try {
151
+ if (faceMatchConfig.has("feedbackTextColor")){
152
+ cameraScreenCustomization.feedbackTextColor = Color.parseColor(faceMatchConfig.getString("feedbackTextColor"));
153
+ }
154
+ } catch (JSONException e) {
155
+ e.printStackTrace();
156
+ }
157
+ if (faceMatchConfig.has("setFeedbackTextSize")){
158
+ try {
159
+ cameraScreenCustomization.feedbackTextSize = faceMatchConfig.getInt("setFeedbackTextSize");
160
+ } catch (JSONException e) {
161
+ e.printStackTrace();
162
+ }
163
+ }else{
164
+ cameraScreenCustomization.feedbackTextSize = 18;
165
+ }
166
+ if (faceMatchConfig.has("setFeedBackframeMessage")){
167
+ try {
168
+ cameraScreenCustomization.feedBackframeMessage = faceMatchConfig.getString("setFeedBackframeMessage");
169
+ } catch (JSONException e) {
170
+ e.printStackTrace();
171
+ }
172
+ }else{
173
+ cameraScreenCustomization.feedBackframeMessage = "Frame Your Face";
174
+ }
175
+ if (faceMatchConfig.has("setFeedBackAwayMessage")){
176
+ try {
177
+ cameraScreenCustomization.feedBackAwayMessage = faceMatchConfig.getString("setFeedBackAwayMessage");
178
+ } catch (JSONException e) {
179
+ e.printStackTrace();
180
+ }
181
+ }else{
182
+ cameraScreenCustomization.feedBackAwayMessage = "Move Phone Away";
183
+ }
184
+ if (faceMatchConfig.has("setFeedBackOpenEyesMessage")){
185
+ try {
186
+ cameraScreenCustomization.feedBackOpenEyesMessage = faceMatchConfig.getString("setFeedBackOpenEyesMessage");
187
+ } catch (JSONException e) {
188
+ e.printStackTrace();
189
+ }
190
+ }else{
191
+ cameraScreenCustomization.feedBackOpenEyesMessage = "Keep Your Eyes Open";
192
+ }
193
+ if (faceMatchConfig.has("setFeedBackCloserMessage")){
194
+ try {
195
+ cameraScreenCustomization.feedBackCloserMessage = faceMatchConfig.getString("setFeedBackCloserMessage");
196
+ } catch (JSONException e) {
197
+ e.printStackTrace();
198
+ }
199
+ }else{
200
+ cameraScreenCustomization.feedBackCloserMessage = "Move Phone Closer";
201
+ }
202
+ if (faceMatchConfig.has("setFeedBackCenterMessage")){
203
+ try {
204
+ cameraScreenCustomization.feedBackCenterMessage = faceMatchConfig.getString("setFeedBackCenterMessage");
205
+ } catch (JSONException e) {
206
+ e.printStackTrace();
207
+ }
208
+ }else{
209
+ cameraScreenCustomization.feedBackCenterMessage = "Move Phone Center";
210
+ }
211
+ if (faceMatchConfig.has("setFeedbackMultipleFaceMessage")){
212
+ try {
213
+ cameraScreenCustomization.feedBackMultipleFaceMessage = faceMatchConfig.getString("setFeedbackMultipleFaceMessage");
214
+ } catch (JSONException e) {
215
+ e.printStackTrace();
216
+ }
217
+ }else{
218
+ cameraScreenCustomization.feedBackMultipleFaceMessage = "Multiple Face Detected";
219
+ }
220
+ if (faceMatchConfig.has("setFeedBackFaceSteadymessage")){
221
+ try {
222
+ cameraScreenCustomization.feedBackHeadStraightMessage = faceMatchConfig.getString("setFeedBackFaceSteadymessage");
223
+ } catch (JSONException e) {
224
+ e.printStackTrace();
225
+ }
226
+ }else{
227
+ cameraScreenCustomization.feedBackHeadStraightMessage = "Keep Your Head Straight";
228
+
229
+ }
230
+ if (faceMatchConfig.has("setFeedBackLowLightMessage")){
231
+ try {
232
+ cameraScreenCustomization.feedBackLowLightMessage = faceMatchConfig.getString("setFeedBackLowLightMessage");
233
+ } catch (JSONException e) {
234
+ e.printStackTrace();
235
+ }
236
+ }else{
237
+ cameraScreenCustomization.feedBackLowLightMessage = "Low light detected";
238
+ }
239
+ if (faceMatchConfig.has("setFeedBackBlurFaceMessage")){
240
+ try {
241
+ cameraScreenCustomization.feedBackBlurFaceMessage = faceMatchConfig.getString("setFeedBackBlurFaceMessage");
242
+ } catch (JSONException e) {
243
+ e.printStackTrace();
244
+ }
245
+ }else{
246
+ cameraScreenCustomization.feedBackBlurFaceMessage = "Blur Detected Over Face";
247
+ }
248
+ if (faceMatchConfig.has("setFeedBackGlareFaceMessage")){
249
+ try {
250
+ cameraScreenCustomization.feedBackGlareFaceMessage = faceMatchConfig.getString("setFeedBackGlareFaceMessage");
251
+ } catch (JSONException e) {
252
+ e.printStackTrace();
253
+ }
254
+ }else{
255
+ cameraScreenCustomization.feedBackGlareFaceMessage = "Glare Detected";
256
+ }
257
+ if (faceMatchConfig.has("setBlurPercentage")){
258
+ try {
259
+ cameraScreenCustomization.setBlurPercentage(faceMatchConfig.getInt("setBlurPercentage"));
260
+ } catch (JSONException e) {
261
+ e.printStackTrace();
262
+ }
263
+ }else{
264
+ cameraScreenCustomization.setBlurPercentage(80);
265
+ }
266
+ if (faceMatchConfig.has("setGlarePercentage_0") && faceMatchConfig.has("setGlarePercentage_1")){
267
+ try {
268
+ cameraScreenCustomization.setGlarePercentage(faceMatchConfig.getInt("setGlarePercentage_0"),faceMatchConfig.getInt("setGlarePercentage_1"));
269
+ } catch (JSONException e) {
270
+ e.printStackTrace();
271
+ }
272
+ }else{
273
+ cameraScreenCustomization.setGlarePercentage(-1, -1);
274
+ }
275
+ if (faceMatchConfig.has("setfeedbackDialogMessage")){
276
+ try {
277
+ cameraScreenCustomization.feedbackDialogMessage = faceMatchConfig.getString("setfeedbackDialogMessage");
278
+ } catch (JSONException e) {
279
+ e.printStackTrace();
280
+ }
281
+ }else {
282
+ cameraScreenCustomization.feedbackDialogMessage = "Loading...";
283
+ }
284
+ if (faceMatchConfig.has("setfeedBackProcessingMessage")){
285
+ try {
286
+ cameraScreenCustomization.feedBackProcessingMessage = faceMatchConfig.getString("setfeedBackProcessingMessage");
287
+ } catch (JSONException e) {
288
+ e.printStackTrace();
289
+ }
290
+ }else{
291
+ cameraScreenCustomization.feedBackProcessingMessage = "Processing...";
292
+ }
293
+ if (faceMatchConfig.has("isshowlogo")){
294
+ try {
295
+ cameraScreenCustomization.showlogo = faceMatchConfig.getInt("isshowlogo"); // Set 0 if hide logo
296
+ } catch (JSONException e) {
297
+ e.printStackTrace();
298
+ }
299
+ }else{
300
+ cameraScreenCustomization.showlogo = 1; // Set 0 if hide logo
301
+ }
302
+ if (faceMatchConfig.has("setLowLightTolerence")){
303
+ try {
304
+ cameraScreenCustomization.setLowLightTolerence(faceMatchConfig.getInt("setLowLightTolerence"));
305
+ } catch (JSONException e) {
306
+ e.printStackTrace();
307
+ }
308
+
309
+ }else {
310
+ cameraScreenCustomization.setLowLightTolerence(-1);
311
+ }
312
+ cameraScreenCustomization.logoIcon = R.drawable.accura_fm_logo; // To set your custom logo
313
+
314
+ cameraScreenCustomization.facing = FMCameraScreenCustomization.CAMERA_FACING_FRONT;
315
+ Intent intent = SelfieFMCameraActivity.getCustomIntent(this, cameraScreenCustomization);
316
+ startActivityForResult(intent, ACCURA_FACEMATCH_CAMERA);
317
+
318
+ }
319
+
320
+
321
+ @Override
322
+ public void onActivityResult(int requestCode, int resultCode,Intent data) {
323
+ super.onActivityResult(requestCode, resultCode, data);
324
+
325
+ if (resultCode == Activity.RESULT_OK) {
326
+
327
+ if (requestCode == PICK_IMAGE) { //handle request code PICK_IMAGE used for selecting image from gallery
328
+
329
+ if (data == null) // data contain result of selected image from gallery and other
330
+ {
331
+ Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show();
332
+ // AccurascanKycModule.onResult.error("101", "Retry...", null);
333
+ this.finish();
334
+ }
335
+
336
+ Uri uri = data.getData();
337
+ String fileDir = getFilesDir().getAbsolutePath();
338
+
339
+ if(ind == 1){
340
+ try {
341
+ AccurascanKycModule.face1 =
342
+ face1 = MediaStore.Images.Media.getBitmap(this.getContentResolver() , uri);
343
+ } catch (IOException e) {
344
+ e.printStackTrace();
345
+ }
346
+ }else if(ind == 2){
347
+ try {
348
+ AccurascanKycModule.face2 =
349
+ face2 = MediaStore.Images.Media.getBitmap(this.getContentResolver() , uri);
350
+ } catch (IOException e) {
351
+ e.printStackTrace();
352
+ }
353
+ }
354
+
355
+ if(ind == 1){
356
+
357
+ try {
358
+ results.put("Image", AccurascanKycModule.getImageUri(AccurascanKycModule.face1, "Image", fileDir));
359
+ } catch (JSONException e) {
360
+ e.printStackTrace();
361
+ }
362
+ if(mface.equals("")) {
363
+ AccurascanKycModule.onResult.invoke(null,results.toString());
364
+ this.finish();
365
+ return;
366
+ }
367
+ helper.setInputImage(uri);
368
+
369
+ }else if(ind == 2) {
370
+ try {
371
+ results.put("Image", AccurascanKycModule.getImageUri(AccurascanKycModule.face2, "Image", fileDir));
372
+ } catch (JSONException e) {
373
+ e.printStackTrace();
374
+ }
375
+ if (sface.equals("")) {
376
+ AccurascanKycModule.onResult.invoke(null,results.toString());
377
+ this.finish();
378
+ return;
379
+ }
380
+ helper.setMatchImage(uri);
381
+
382
+ }
383
+
384
+ } else if (requestCode == ACCURA_FACEMATCH_CAMERA) { // handle request code CAPTURE_IMAGE used for capture image in camera
385
+ AccuraFMCameraModel result = data.getParcelableExtra("Accura.fm");
386
+ if (result == null) {
387
+ Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show();
388
+ // AccurascanKycModule.onResult.error("101","Retry...", null);
389
+ this.finish();
390
+ }
391
+ if (result.getStatus().equals("1")) {
392
+ handleVerificationSuccessResult(result);
393
+ } else {
394
+ Toast.makeText(this, result.getStatus() + "Retry...", Toast.LENGTH_SHORT).show();
395
+ }
396
+ }
397
+ } else {
398
+ // Toast.makeText(this, "Cancelled", Toast.LENGTH_SHORT).show();
399
+ AccurascanKycModule.onResult.invoke("Cancelled", null);
400
+ this.finish();
401
+ }
402
+ }
403
+
404
+ public void handleVerificationSuccessResult(final AccuraFMCameraModel result) {
405
+ String fileDir = getFilesDir().getAbsolutePath();
406
+ if (result != null) {
407
+ if (result.getFaceBiometrics() != null) {
408
+ Bitmap nBmp = result.getFaceBiometrics();
409
+
410
+ if(ind == 1){
411
+ AccurascanKycModule.face1 =
412
+ face1 = nBmp;
413
+ try {
414
+ results.put("Image", AccurascanKycModule.getImageUri(AccurascanKycModule.face1, "Image", fileDir));
415
+
416
+ } catch (JSONException e) {
417
+ e.printStackTrace();
418
+ }
419
+ if(mface.equals("")) {
420
+ AccurascanKycModule.onResult.invoke(null,results.toString());
421
+ this.finish();
422
+ return;
423
+ }
424
+ helper.setInputImage(face1);
425
+
426
+ }else if(ind == 2) {
427
+ AccurascanKycModule.face2 =
428
+ face2 = nBmp;
429
+ try {
430
+ results.put("Image", AccurascanKycModule.getImageUri(AccurascanKycModule.face2, "Image", fileDir));
431
+ } catch (JSONException e) {
432
+ e.printStackTrace();
433
+ }
434
+ if (sface.equals("")) {
435
+ AccurascanKycModule.onResult.invoke(null,results.toString());
436
+ this.finish();
437
+ return;
438
+ }
439
+ helper.setMatchImage(face2);
440
+
441
+ }
442
+ }
443
+ }
444
+ }
445
+
446
+ @Override
447
+ public void onInitEngine(int i) {
448
+ }
449
+
450
+ @Override
451
+ public void onLeftDetect(FaceDetectionResult faceResult) {
452
+ if (faceResult != null) {
453
+ image1.setFaceDetectionResult(faceResult);
454
+ if (image1.getImage() != null && !image1.getImage().isRecycled()) image1.getImage().recycle();
455
+ image1.setImage(BitmapHelper.createFromARGB(faceResult.getNewImg(), faceResult.getNewWidth(), faceResult.getNewHeight()));
456
+ image1.requestLayout();
457
+ } else {
458
+ if (image1 != null && image1.getImage() != null) {
459
+ image1.setImage(image1.getImage());
460
+ image1.setFaceDetectionResult(null);
461
+ }
462
+
463
+ }
464
+ }
465
+
466
+ @Override
467
+ public void onRightDetect(FaceDetectionResult faceResult) {
468
+ if (faceResult != null) {
469
+ if (image2 != null) {
470
+ image2.setFaceDetectionResult(faceResult);
471
+ if (image2.getImage() != null && !image2.getImage().isRecycled())
472
+ image2.getImage().recycle();
473
+ image2.setImage(BitmapHelper.createFromARGB(faceResult.getNewImg(), faceResult.getNewWidth(), faceResult.getNewHeight()));
474
+ image2.requestLayout();
475
+ }
476
+ } else {
477
+ if (image2 != null && image2.getImage() != null) {
478
+ image2.setImage(image2.getImage());
479
+ image2.setFaceDetectionResult(null);
480
+ }
481
+ }
482
+ }
483
+
484
+ @Override
485
+ public void onExtractInit(int i) {
486
+
487
+ }
488
+
489
+ @Override
490
+ public void onFaceMatch(float score) {
491
+ NumberFormat nf = NumberFormat.getNumberInstance();
492
+ nf.setMaximumFractionDigits(1);
493
+ String ss = nf.format(score);
494
+ if((ind == 1) && (!mface.equals(""))){
495
+ try {
496
+ results.put("score", ss);
497
+ } catch (JSONException e) {
498
+ e.printStackTrace();
499
+ }
500
+ try {
501
+ AccurascanKycModule.onResult.invoke(null,results.toString());
502
+ this.finish();
503
+ }catch (Exception e){
504
+ Log.i("Error",e.toString());
505
+ }
506
+ }else if ((ind == 2) && (!sface.equals(""))){
507
+ try {
508
+ results.put("score", ss);
509
+ } catch (JSONException e) {
510
+ e.printStackTrace();
511
+ }
512
+ try {
513
+ AccurascanKycModule.onResult.invoke(null,results.toString());
514
+ this.finish();
515
+ }catch (Exception e){
516
+ Log.i("Error",e.toString());
517
+ }
518
+ }
519
+ }
520
+
521
+ @Override
522
+ public void onSetInputImage(Bitmap src1) {
523
+ if (image1.getImage() != null && !image1.getImage().isRecycled()) image1.getImage().recycle();
524
+ image1.setImage(src1);
525
+ }
526
+
527
+ @Override
528
+ public void onSetMatchImage(Bitmap src2) {
529
+ if (image2.getImage() != null && !image2.getImage().isRecycled()) image2.getImage().recycle();
530
+ image2.setImage(src2);
531
+
532
+ }
533
+ }
@@ -0,0 +1,82 @@
1
+ package com.accurascankyc;
2
+
3
+ import android.content.Context;
4
+ import android.graphics.Canvas;
5
+ import android.graphics.Paint;
6
+ import android.text.TextPaint;
7
+ import android.util.AttributeSet;
8
+
9
+ public class BorderTextView extends androidx.appcompat.widget.AppCompatTextView {
10
+
11
+ private float strokeWidth;
12
+ private Integer strokeColor;
13
+ private Paint.Join strokeJoin;
14
+ private float strokeMiter;
15
+
16
+
17
+ public BorderTextView(Context context) {
18
+ super(context);
19
+ init(null);
20
+ }
21
+
22
+ public BorderTextView(Context context, AttributeSet attrs) {
23
+ super(context, attrs);
24
+ init(attrs);
25
+ }
26
+
27
+ public BorderTextView(Context context, AttributeSet attrs, int defStyle) {
28
+ super(context, attrs, defStyle);
29
+ init(attrs);
30
+ }
31
+
32
+ public void init(AttributeSet attrs) {
33
+
34
+ // if (attrs != null) {
35
+ // TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CoustomTextView);
36
+ //
37
+ // if (a.hasValue(R.styleable.CoustomTextView_strokeColor)) {
38
+ // float strokeWidth = a.getDimensionPixelSize(R.styleable.CoustomTextView_strokeWidth, 1);
39
+ // int strokeColor = a.getColor(R.styleable.CoustomTextView_strokeColor, 0xff000000);
40
+ // float strokeMiter = a.getDimensionPixelSize(R.styleable.CoustomTextView_strokeMiter, 10);
41
+ // Paint.Join strokeJoin = null;
42
+ // switch (a.getInt(R.styleable.CoustomTextView_strokeJoinStyle, 0)) {
43
+ // case (0):
44
+ // strokeJoin = Paint.Join.MITER;
45
+ // break;
46
+ // case (1):
47
+ // strokeJoin = Paint.Join.BEVEL;
48
+ // break;
49
+ // case (2):
50
+ // strokeJoin = Paint.Join.ROUND;
51
+ // break;
52
+ // }
53
+ // this.setStroke(strokeWidth, strokeColor, strokeJoin, strokeMiter);
54
+ // }
55
+ // }
56
+ }
57
+
58
+ public void setStroke(float width, int color, Paint.Join join, float miter) {
59
+ strokeWidth = width;
60
+ strokeColor = color;
61
+ strokeJoin = join;
62
+ strokeMiter = miter;
63
+ }
64
+
65
+ @Override
66
+ public void onDraw(Canvas canvas) {
67
+ super.onDraw(canvas);
68
+
69
+ int restoreColor = this.getCurrentTextColor();
70
+ if (strokeColor != null) {
71
+ TextPaint paint = this.getPaint();
72
+ paint.setStyle(Paint.Style.STROKE);
73
+ paint.setStrokeJoin(strokeJoin);
74
+ paint.setStrokeMiter(strokeMiter);
75
+ this.setTextColor(strokeColor);
76
+ paint.setStrokeWidth(strokeWidth);
77
+ super.onDraw(canvas);
78
+ paint.setStyle(Paint.Style.FILL);
79
+ this.setTextColor(restoreColor);
80
+ }
81
+ }
82
+ }