@idnow/react-idcheckio 7.2.2 → 8.0.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 (56) hide show
  1. package/.editorconfig +15 -0
  2. package/.gitattributes +2 -0
  3. package/README.md +236 -193
  4. package/android/build.gradle +95 -37
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +5 -4
  7. package/android/src/main/AndroidManifestNew.xml +9 -0
  8. package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioActivity.kt +67 -0
  9. package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioModule.kt +115 -0
  10. package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioPackage.kt +17 -0
  11. package/android/src/main/java/com/idnowreactidcheckio/bean/ExtractionEnum.kt +6 -0
  12. package/android/src/main/java/com/idnowreactidcheckio/bean/ExtractionReact.kt +20 -0
  13. package/android/src/main/java/com/idnowreactidcheckio/bean/IntegrityCheckEnum.kt +6 -0
  14. package/android/src/main/java/com/idnowreactidcheckio/bean/IntegrityCheckReact.kt +18 -0
  15. package/android/src/main/java/com/idnowreactidcheckio/bean/OnlineConfigEnum.kt +9 -0
  16. package/android/src/main/java/com/idnowreactidcheckio/bean/ParamsEnum.kt +19 -0
  17. package/android/src/main/java/com/idnowreactidcheckio/bean/Theme.kt +29 -0
  18. package/android/src/main/java/com/idnowreactidcheckio/bean/ThemeEnum.kt +13 -0
  19. package/android/src/main/java/com/idnowreactidcheckio/utils/Extension.kt +20 -0
  20. package/android/src/main/java/com/idnowreactidcheckio/utils/Mapper.kt +178 -0
  21. package/android/src/main/res/layout/activity_idnow_react_idcheckio.xml +9 -0
  22. package/idnow-react-idcheckio.podspec +43 -0
  23. package/ios/IdnowReactIdcheckio-Bridging-Header.h +2 -0
  24. package/ios/IdnowReactIdcheckio.mm +29 -0
  25. package/ios/IdnowReactIdcheckio.swift +131 -0
  26. package/ios/Models/ExtractionEnum.swift +13 -0
  27. package/ios/Models/ExtractionReact.swift +23 -0
  28. package/ios/Models/IntegrityCheckEnum.swift +13 -0
  29. package/ios/Models/IntegrityCheckReact.swift +24 -0
  30. package/ios/Models/OnlineConfigEnum.swift +16 -0
  31. package/ios/Models/ParamsEnum.swift +26 -0
  32. package/ios/Models/ThemeEnum.swift +20 -0
  33. package/ios/Models/ThemeReact.swift +32 -0
  34. package/ios/Utils/Mapper.swift +139 -0
  35. package/package.json +14 -11
  36. package/release-public.sh +4 -4
  37. package/src/index.d.ts +259 -0
  38. package/src/index.js +270 -0
  39. package/tsconfig.json +12 -0
  40. package/ReactIdcheckio.podspec +0 -15
  41. package/android/.project +0 -17
  42. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  43. package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioActivity.java +0 -133
  44. package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioConst.java +0 -39
  45. package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioModule.java +0 -189
  46. package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioPackage.java +0 -22
  47. package/android/src/main/java/com/ariadnext/idcheckio/ParameterUtils.java +0 -251
  48. package/idcheckio_params.js +0 -343
  49. package/index.js +0 -6
  50. package/ios/Idcheckio.h +0 -11
  51. package/ios/Idcheckio.m +0 -301
  52. package/ios/Idcheckio.xcodeproj/project.pbxproj +0 -340
  53. package/ios/Idcheckio.xcworkspace/contents.xcworkspacedata +0 -10
  54. package/ios/Idcheckio.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  55. package/ios/IdcheckioKeys.h +0 -49
  56. package/ios/IdcheckioSdk+Utils.swift +0 -35
@@ -1,133 +0,0 @@
1
- package com.ariadnext.idcheckio;
2
-
3
- import static com.ariadnext.idcheckio.IdcheckioConst.*;
4
- import android.content.Intent;
5
- import android.graphics.Color;
6
- import android.graphics.drawable.ColorDrawable;
7
- import android.os.Bundle;
8
- import android.view.Window;
9
- import android.widget.FrameLayout;
10
-
11
- import androidx.annotation.NonNull;
12
- import androidx.fragment.app.FragmentActivity;
13
- import com.ariadnext.idcheckio.sdk.bean.DayNightTheme;
14
- import com.ariadnext.idcheckio.sdk.bean.IpsCustomization;
15
- import com.ariadnext.idcheckio.sdk.bean.OnlineContext;
16
- import com.ariadnext.idcheckio.sdk.bean.Orientation;
17
- import com.ariadnext.idcheckio.sdk.component.Idcheckio;
18
- import com.ariadnext.idcheckio.sdk.component.IdcheckioView;
19
- import com.ariadnext.idcheckio.sdk.interfaces.ErrorMsg;
20
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioError;
21
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioErrorKt;
22
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioInteraction;
23
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioInteractionInterface;
24
- import com.ariadnext.idcheckio.sdk.interfaces.result.IdcheckioResult;
25
- import com.ariadnext.idcheckio.sdk.interfaces.result.ips.IpsResultCallback;
26
- import com.ariadnext.idcheckio.sdk.utils.extension.JsonExtensionKt;
27
-
28
- import org.json.JSONException;
29
-
30
- import java.util.HashMap;
31
-
32
-
33
- public class IdcheckioActivity extends FragmentActivity implements IdcheckioInteractionInterface, IpsResultCallback {
34
- private final static int CONTAINER_ID = 123481562;
35
-
36
- @Override
37
- protected void onCreate(@androidx.annotation.Nullable Bundle savedInstanceState) {
38
- super.onCreate(savedInstanceState);
39
- requestWindowFeature(Window.FEATURE_NO_TITLE);
40
- FrameLayout rootLayout = new FrameLayout(this);
41
- rootLayout.setId(CONTAINER_ID);
42
- rootLayout.setBackground(new ColorDrawable(Color.BLACK));
43
- setContentView(rootLayout);
44
-
45
- Intent intent = getIntent();
46
- boolean isOnline = intent.getBooleanExtra("isOnline", false);
47
- boolean isIps = intent.getBooleanExtra("isIps", false);
48
- if(isIps) {
49
- String folderUid = intent.getStringExtra(FOLDER_UID);
50
- folderUid = (folderUid != null)? folderUid : "";
51
- /*
52
- * You can update the IpsCustomization with a DayNightTheme to make update the colors of the sdk.
53
- * You will have more information about the DayNightTheme in the Developers Guide.
54
- */
55
- DayNightTheme dayNightTheme = new DayNightTheme(
56
- R.color.idcheckio_sdk_background_color,
57
- R.color.idcheckio_sdk_border_color,
58
- R.color.idcheckio_sdk_secondary_background_color,
59
- R.color.idcheckio_sdk_primary_color,
60
- // If you let the title and text color null, it will automatically switch between white and black depending on the background it is on.
61
- null,
62
- null
63
- );
64
- IpsCustomization ipsCustomization = new IpsCustomization(dayNightTheme, Orientation.AUTOMATIC);
65
- Idcheckio.startIps(this, folderUid, this, ipsCustomization, null);
66
- } else if(isOnline) {
67
- IdcheckioView idcheckioView = pushIdcheckioView((HashMap<String, Object>) intent.getSerializableExtra("PARAMS"));
68
- String online = intent.getStringExtra("ONLINE");
69
- OnlineContext onlineContext = null;
70
- if (online != null && !online.isEmpty()) {
71
- onlineContext = OnlineContext.createFrom(online);
72
- }
73
- idcheckioView.startOnline(onlineContext);
74
- } else {
75
- IdcheckioView idcheckioView = pushIdcheckioView((HashMap<String, Object>) intent.getSerializableExtra("PARAMS"));
76
- idcheckioView.start();
77
- }
78
- }
79
-
80
- /**
81
- * Retrieve the params from the json.
82
- * Create an [IdcheckioView], assign the parameters to the view
83
- * And then push the view in the fragment manager.
84
- * @param params a hashmap with all the sdk parameters
85
- * @return the created [IdcheckioView]
86
- */
87
- private IdcheckioView pushIdcheckioView(HashMap<String, Object> params){
88
- IdcheckioView idcheckioView = ParameterUtils.getIDCheckioViewFromCall(params)
89
- .listener(this)
90
- .build();
91
- getSupportFragmentManager().beginTransaction().replace(CONTAINER_ID, idcheckioView).commit();
92
- return idcheckioView;
93
- }
94
-
95
- @Override
96
- public void onBackPressed(){
97
- onIdcheckioInteraction(IdcheckioInteraction.ERROR, IdcheckioErrorKt.toErrorMsg(IdcheckioError.CANCELLED_BY_USER,
98
- "Session cancelled by user.", null));
99
- }
100
-
101
- @Override
102
- public void onIdcheckioInteraction(IdcheckioInteraction idcheckioInteraction, Object data) {
103
- switch (idcheckioInteraction) {
104
- case RESULT:
105
- Intent resultIntent = new Intent();
106
- resultIntent.putExtra("IDCHECKIO_RESULT", JsonExtensionKt.toJson((IdcheckioResult) data));
107
- setResult(RESULT_OK, resultIntent);
108
- finish();
109
- break;
110
- case ERROR:
111
- Intent errorIntent = new Intent();
112
- if (data != null) {
113
- errorIntent.putExtra("ERROR_MSG", JsonExtensionKt.toJson((ErrorMsg) data));
114
- }
115
- setResult(RESULT_CANCELED, errorIntent);
116
- finish();
117
- break;
118
- default:
119
- break;
120
- }
121
- }
122
-
123
- @Override
124
- public void onIpsSessionFailure(@NonNull ErrorMsg errorMsg) {
125
- onIdcheckioInteraction(IdcheckioInteraction.ERROR, errorMsg);
126
- }
127
-
128
- @Override
129
- public void onIpsSessionSuccess() {
130
- // Empty success (the sdk give no result on an ips session success)
131
- onIdcheckioInteraction(IdcheckioInteraction.RESULT, new IdcheckioResult());
132
- }
133
- }
@@ -1,39 +0,0 @@
1
- package com.ariadnext.idcheckio;
2
-
3
- public class IdcheckioConst {
4
- public static final String DOCUMENT_TYPE = "docType";
5
- public static final String CONFIRM_TYPE = "confirmationType";
6
- public static final String SIDE_1_EXTRACTION = "sideOneExtraction";
7
- public static final String SIDE_2_EXTRACTION = "sideTwoExtraction";
8
- public static final String DATA_REQUIREMENT = "codeline";
9
- public static final String FACE_DETECTION = "faceDetection";
10
- public static final String SCAN_BOTH_SIDES = "scanBothSides";
11
- public static final String USE_HD = "useHd";
12
- public static final String INTEGRITY_CHECK = "integrityCheck";
13
- public static final String READ_EMRTD = "readEmrtd";
14
- public static final String DOC_LIVENESS = "docLiveness";
15
- public static final String ORIENTATION = "orientation";
16
-
17
- public static final String ONLINE_CONFIG = "onlineConfig";
18
- public static final String IS_REFERENCE_DOC = "isReferenceDocument";
19
- public static final String CIS_TYPE = "cisType";
20
- public static final String FOLDER_UID = "folderUid";
21
- public static final String BIOMETRIC_CONSENT = "biometricConsent";
22
- public static final String ENABLE_MANUAL_ANALYSIS = "enableManualAnalysis";
23
-
24
- public static final String THEME = "theme";
25
- public static final String PRIMARY_COLOR = "primaryColor";
26
- public static final String FOREGROUND_COLOR = "foregroundColor";
27
- public static final String BACKGROUND_COLOR = "backgroundColor";
28
- public static final String BORDER_COLOR = "borderColor";
29
- public static final String TEXT_COLOR = "textColor";
30
- public static final String TITLE_COLOR = "titleColor";
31
-
32
- public static final String LANGUAGE = "language";
33
- public static final String MANUAL_BUTTON_TIMER = "manualButtonTimer";
34
- public static final String MAX_PICTURE_FILESIZE = "maxPictureFilesize";
35
- public static final String FEEDBACK_LEVEL = "feedbackLevel";
36
- public static final String ADJUST_CROP = "adjustCrop";
37
- public static final String CONFIRM_ABORT = "confirmAbort";
38
- public static final String CAPTURE_MODE = "captureMode";
39
- }
@@ -1,189 +0,0 @@
1
- package com.ariadnext.idcheckio;
2
-
3
- import static com.ariadnext.idcheckio.IdcheckioConst.FOLDER_UID;
4
-
5
- import android.app.Activity;
6
- import android.content.Intent;
7
- import android.net.Uri;
8
- import androidx.annotation.NonNull;
9
- import com.ariadnext.idcheckio.sdk.bean.CaptureParams;
10
- import com.ariadnext.idcheckio.sdk.bean.OnlineContext;
11
- import com.ariadnext.idcheckio.sdk.component.Idcheckio;
12
- import com.ariadnext.idcheckio.sdk.interfaces.ErrorMsg;
13
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioCallback;
14
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioError;
15
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioErrorCause;
16
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioErrorKt;
17
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioInteraction;
18
- import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioInteractionInterface;
19
- import com.ariadnext.idcheckio.sdk.interfaces.result.IdcheckioResult;
20
- import com.ariadnext.idcheckio.sdk.utils.extension.JsonExtensionKt;
21
- import com.facebook.react.bridge.ActivityEventListener;
22
- import com.facebook.react.bridge.BaseActivityEventListener;
23
- import com.facebook.react.bridge.Promise;
24
- import com.facebook.react.bridge.ReactApplicationContext;
25
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
26
- import com.facebook.react.bridge.ReactMethod;
27
- import com.facebook.react.bridge.ReadableMap;
28
-
29
- public class IdcheckioModule extends ReactContextBaseJavaModule implements IdcheckioCallback, IdcheckioInteractionInterface {
30
- /**
31
- * React context, used to start activity
32
- */
33
- private final ReactApplicationContext reactContext;
34
- /**
35
- * Promise to send results back to js
36
- */
37
- private Promise mPromise;
38
- /**
39
- * TAG
40
- */
41
- private static final String TAG = "IdcheckioModule";
42
- /**
43
- * Flag to retrieve activity result
44
- */
45
- private final static int START_REQUEST = 5;
46
-
47
- public IdcheckioModule(ReactApplicationContext reactContext) {
48
- super(reactContext);
49
- this.reactContext = reactContext;
50
- ActivityEventListener mActivityEventListener = new BaseActivityEventListener() {
51
- @Override
52
- public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent intent) {
53
- if (requestCode == START_REQUEST) {
54
- if (resultCode == Activity.RESULT_OK) {
55
- String result = intent.getExtras().getString("IDCHECKIO_RESULT", "{}");
56
- mPromise.resolve(result);
57
- } else if(resultCode == Activity.RESULT_CANCELED){
58
- if(intent != null){
59
- String error = intent.getExtras().getString("ERROR_MSG", "{}");
60
- mPromise.reject(TAG, error);
61
- }
62
- }
63
- }
64
- }
65
- };
66
- reactContext.addActivityEventListener(mActivityEventListener);
67
- }
68
-
69
- @NonNull
70
- @Override
71
- public String getName() {
72
- return TAG;
73
- }
74
-
75
- @ReactMethod
76
- public void preload(Boolean extractData){
77
- Idcheckio.preload(reactContext, extractData);
78
- }
79
-
80
- private boolean checkContext() {
81
- if(getCurrentActivity() == null) {
82
- onIdcheckioInteraction(IdcheckioInteraction.ERROR, IdcheckioErrorKt.toErrorMsg(IdcheckioError.CONTEXT_LOST,
83
- "Fail to find a usable activity to start the sdk.", null));
84
- return false;
85
- }
86
- return true;
87
- }
88
-
89
- @ReactMethod
90
- public void activate(String idToken, Boolean extractData, Promise promise){
91
- mPromise = promise;
92
- Idcheckio.activate(idToken, reactContext, this, extractData);
93
- }
94
-
95
- @ReactMethod
96
- public void start(ReadableMap map, Promise promise){
97
- mPromise = promise;
98
- if(!checkContext()) return;
99
- Intent intent = new Intent(getCurrentActivity(), IdcheckioActivity.class);
100
- intent.putExtra("PARAMS", map.toHashMap());
101
- intent.putExtra("isOnline", false);
102
- getCurrentActivity().startActivityForResult(intent, START_REQUEST);
103
- }
104
-
105
- @ReactMethod
106
- public void startOnline(ReadableMap params, ReadableMap onlineContext, Promise promise){
107
- mPromise = promise;
108
- if(!checkContext()) return;
109
- Intent intent = new Intent(this.getCurrentActivity(), IdcheckioActivity.class);
110
- intent.putExtra("PARAMS", params.toHashMap());
111
- intent.putExtra("isOnline", true);
112
- intent.putExtra("ONLINE", (onlineContext != null)? onlineContext.toHashMap().toString() : null);
113
- getCurrentActivity().startActivityForResult(intent, START_REQUEST);
114
- }
115
-
116
- @ReactMethod
117
- public void startIps(String folderUid, Promise promise){
118
- mPromise = promise;
119
- if(!checkContext()) return;
120
- if(folderUid == null || folderUid.isEmpty()) {
121
- onIdcheckioInteraction(IdcheckioInteraction.ERROR, new ErrorMsg(IdcheckioErrorCause.CUSTOMER_ERROR, "MISSING_FOLDER_UID",
122
- "The ips folderUid is mandatory to start an ips session.", null));
123
- } else {
124
- Intent intent = new Intent(getCurrentActivity(), IdcheckioActivity.class);
125
- intent.putExtra(FOLDER_UID, folderUid);
126
- intent.putExtra("isIps", true);
127
- getCurrentActivity().startActivityForResult(intent, START_REQUEST);
128
- }
129
- }
130
-
131
- @ReactMethod
132
- public void analyze(ReadableMap params, String side1ToUpload, String side2ToUpload, Boolean isOnline, ReadableMap context, Promise promise){
133
- mPromise = promise;
134
- Uri side1Uri, side2Uri = null;
135
- CaptureParams captureParams = ParameterUtils.getIDCheckioViewFromCall(params.toHashMap()).captureParams();
136
- OnlineContext onlineContext = null;
137
- if(context != null) {
138
- onlineContext = OnlineContext.createFrom(context.toHashMap().toString());
139
- }
140
- if(side1ToUpload != null){
141
- if(side1ToUpload.startsWith("/data")) {
142
- side1Uri = Uri.parse(side1ToUpload+"file://");
143
- } else {
144
- side1Uri = Uri.parse(side1ToUpload);
145
- }
146
- } else {
147
- onIdcheckioInteraction(IdcheckioInteraction.ERROR, IdcheckioErrorKt.toErrorMsg(IdcheckioError.FAILED_TO_RETRIEVE_IMAGE_FROM_GALLERY, "Image path is empty.", null));
148
- return;
149
- }
150
- if(side2ToUpload != null){
151
- if(side2ToUpload.startsWith("/data")) {
152
- side2Uri = Uri.parse(side2ToUpload+"file://");
153
- } else {
154
- side2Uri = Uri.parse(side2ToUpload);
155
- }
156
- }
157
- //Start in a custom thread
158
- Idcheckio.analyze(reactContext,
159
- this,
160
- captureParams,
161
- side1Uri,
162
- side2Uri,
163
- isOnline,
164
- onlineContext);
165
- }
166
-
167
- @Override
168
- public void onInitEnd(boolean success, ErrorMsg errorMsg) {
169
- if(success){
170
- mPromise.resolve(null);
171
- } else {
172
- mPromise.reject(TAG, JsonExtensionKt.toJson(errorMsg));
173
- }
174
- }
175
-
176
- @Override
177
- public void onIdcheckioInteraction(IdcheckioInteraction idcheckioInteraction, Object data) {
178
- switch (idcheckioInteraction) {
179
- case RESULT:
180
- mPromise.resolve(JsonExtensionKt.toJson((IdcheckioResult) data));
181
- break;
182
- case ERROR:
183
- mPromise.reject(TAG, JsonExtensionKt.toJson((ErrorMsg) data));
184
- break;
185
- default:
186
- break;
187
- }
188
- }
189
- }
@@ -1,22 +0,0 @@
1
- package com.ariadnext.idcheckio;
2
-
3
- import com.facebook.react.ReactPackage;
4
- import com.facebook.react.bridge.NativeModule;
5
- import com.facebook.react.bridge.ReactApplicationContext;
6
- import com.facebook.react.uimanager.ViewManager;
7
-
8
- import java.util.Arrays;
9
- import java.util.Collections;
10
- import java.util.List;
11
-
12
- public class IdcheckioPackage implements ReactPackage {
13
- @Override
14
- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
15
- return Arrays.<NativeModule>asList(new IdcheckioModule(reactContext));
16
- }
17
-
18
- @Override
19
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
20
- return Collections.emptyList();
21
- }
22
- }
@@ -1,251 +0,0 @@
1
- package com.ariadnext.idcheckio;
2
-
3
- import static com.ariadnext.idcheckio.IdcheckioConst.ADJUST_CROP;
4
- import static com.ariadnext.idcheckio.IdcheckioConst.BACKGROUND_COLOR;
5
- import static com.ariadnext.idcheckio.IdcheckioConst.BIOMETRIC_CONSENT;
6
- import static com.ariadnext.idcheckio.IdcheckioConst.BORDER_COLOR;
7
- import static com.ariadnext.idcheckio.IdcheckioConst.CAPTURE_MODE;
8
- import static com.ariadnext.idcheckio.IdcheckioConst.CIS_TYPE;
9
- import static com.ariadnext.idcheckio.IdcheckioConst.CONFIRM_ABORT;
10
- import static com.ariadnext.idcheckio.IdcheckioConst.CONFIRM_TYPE;
11
- import static com.ariadnext.idcheckio.IdcheckioConst.DATA_REQUIREMENT;
12
- import static com.ariadnext.idcheckio.IdcheckioConst.DOCUMENT_TYPE;
13
- import static com.ariadnext.idcheckio.IdcheckioConst.DOC_LIVENESS;
14
- import static com.ariadnext.idcheckio.IdcheckioConst.ENABLE_MANUAL_ANALYSIS;
15
- import static com.ariadnext.idcheckio.IdcheckioConst.FACE_DETECTION;
16
- import static com.ariadnext.idcheckio.IdcheckioConst.FEEDBACK_LEVEL;
17
- import static com.ariadnext.idcheckio.IdcheckioConst.FOLDER_UID;
18
- import static com.ariadnext.idcheckio.IdcheckioConst.FOREGROUND_COLOR;
19
- import static com.ariadnext.idcheckio.IdcheckioConst.INTEGRITY_CHECK;
20
- import static com.ariadnext.idcheckio.IdcheckioConst.IS_REFERENCE_DOC;
21
- import static com.ariadnext.idcheckio.IdcheckioConst.LANGUAGE;
22
- import static com.ariadnext.idcheckio.IdcheckioConst.MANUAL_BUTTON_TIMER;
23
- import static com.ariadnext.idcheckio.IdcheckioConst.MAX_PICTURE_FILESIZE;
24
- import static com.ariadnext.idcheckio.IdcheckioConst.ONLINE_CONFIG;
25
- import static com.ariadnext.idcheckio.IdcheckioConst.ORIENTATION;
26
- import static com.ariadnext.idcheckio.IdcheckioConst.PRIMARY_COLOR;
27
- import static com.ariadnext.idcheckio.IdcheckioConst.READ_EMRTD;
28
- import static com.ariadnext.idcheckio.IdcheckioConst.SCAN_BOTH_SIDES;
29
- import static com.ariadnext.idcheckio.IdcheckioConst.SIDE_1_EXTRACTION;
30
- import static com.ariadnext.idcheckio.IdcheckioConst.SIDE_2_EXTRACTION;
31
- import static com.ariadnext.idcheckio.IdcheckioConst.TEXT_COLOR;
32
- import static com.ariadnext.idcheckio.IdcheckioConst.THEME;
33
- import static com.ariadnext.idcheckio.IdcheckioConst.TITLE_COLOR;
34
- import static com.ariadnext.idcheckio.IdcheckioConst.USE_HD;
35
-
36
- import android.graphics.Color;
37
-
38
- import com.ariadnext.idcheckio.sdk.bean.CaptureMode;
39
- import com.ariadnext.idcheckio.sdk.bean.ConfirmationType;
40
- import com.ariadnext.idcheckio.sdk.bean.DataRequirement;
41
- import com.ariadnext.idcheckio.sdk.bean.DocumentType;
42
- import com.ariadnext.idcheckio.sdk.bean.Extraction;
43
- import com.ariadnext.idcheckio.sdk.bean.FaceDetection;
44
- import com.ariadnext.idcheckio.sdk.bean.FeedbackLevel;
45
- import com.ariadnext.idcheckio.sdk.bean.FileSize;
46
- import com.ariadnext.idcheckio.sdk.bean.Forceable;
47
- import com.ariadnext.idcheckio.sdk.bean.IntegrityCheck;
48
- import com.ariadnext.idcheckio.sdk.bean.Language;
49
- import com.ariadnext.idcheckio.sdk.bean.OnlineConfig;
50
- import com.ariadnext.idcheckio.sdk.bean.Orientation;
51
- import com.ariadnext.idcheckio.sdk.bean.Theme;
52
- import com.ariadnext.idcheckio.sdk.component.IdcheckioView;
53
- import com.ariadnext.idcheckio.sdk.interfaces.cis.CISType;
54
-
55
- import java.util.HashMap;
56
- import java.util.Map;
57
-
58
- public class ParameterUtils {
59
-
60
- public static IdcheckioView.Builder getIDCheckioViewFromCall(HashMap<String, Object> params) {
61
- IdcheckioView.Builder idcheckioView = new IdcheckioView.Builder();
62
- for (Map.Entry<String, Object> entries : params.entrySet()) {
63
- String key = entries.getKey();
64
- Object value = entries.getValue();
65
- switch (key) {
66
- case DOCUMENT_TYPE:
67
- idcheckioView.docType(DocumentType.valueOf(value.toString()));
68
- break;
69
- case ORIENTATION:
70
- idcheckioView.orientation(Orientation.valueOf(value.toString()));
71
- break;
72
- case CONFIRM_TYPE:
73
- idcheckioView.confirmType(ConfirmationType.valueOf(value.toString()));
74
- break;
75
- case INTEGRITY_CHECK:
76
- idcheckioView.integrityCheck(getIntegrityCheck((HashMap<String, Object>) value));
77
- break;
78
- case USE_HD:
79
- idcheckioView.useHd(Boolean.parseBoolean(value.toString()));
80
- break;
81
- case SCAN_BOTH_SIDES:
82
- idcheckioView.scanBothSides(Forceable.valueOf(value.toString()));
83
- break;
84
- case SIDE_1_EXTRACTION:
85
- idcheckioView.sideOneExtraction(getExtraction((HashMap<String, String>) value));
86
- break;
87
- case SIDE_2_EXTRACTION:
88
- idcheckioView.sideTwoExtraction(getExtraction((HashMap<String, String>) value));
89
- break;
90
- case ONLINE_CONFIG:
91
- idcheckioView.onlineConfig(getOnlineConfig((HashMap<String, Object>) value));
92
- break;
93
- case LANGUAGE:
94
- idcheckioView.language(Language.valueOf(value.toString()));
95
- break;
96
- case MANUAL_BUTTON_TIMER:
97
- double doubleValue = Double.parseDouble(value.toString());
98
- idcheckioView.manualButtonTimer((int) doubleValue);
99
- break;
100
- case FEEDBACK_LEVEL:
101
- idcheckioView.feedbackLevel(FeedbackLevel.valueOf(value.toString()));
102
- break;
103
- case ADJUST_CROP:
104
- idcheckioView.adjustCrop(Boolean.parseBoolean(value.toString()));
105
- break;
106
- case MAX_PICTURE_FILESIZE:
107
- idcheckioView.maxPictureFilesize(FileSize.valueOf(value.toString()));
108
- break;
109
- case CONFIRM_ABORT:
110
- idcheckioView.confirmAbort(Boolean.parseBoolean(value.toString()));
111
- break;
112
- case CAPTURE_MODE:
113
- idcheckioView.captureMode(CaptureMode.valueOf(value.toString()));
114
- break;
115
- case THEME:
116
- idcheckioView.theme(getTheme((HashMap<String, Object>) value));
117
- break;
118
- }
119
- }
120
- return idcheckioView;
121
- }
122
-
123
- private static IntegrityCheck getIntegrityCheck(HashMap<String, Object> integrityMap) {
124
- boolean readEmrtd = false;
125
- boolean docLiveness = false;
126
-
127
- if(integrityMap.containsKey(READ_EMRTD)) {
128
- Object readEmrtdOpt = integrityMap.get(READ_EMRTD);
129
- if(readEmrtdOpt != null) {
130
- readEmrtd = Boolean.parseBoolean(readEmrtdOpt.toString());
131
- }
132
- }
133
- if(integrityMap.containsKey(DOC_LIVENESS)) {
134
- Object docLivenessOpt = integrityMap.get(DOC_LIVENESS);
135
- if(docLivenessOpt != null) {
136
- docLiveness = Boolean.parseBoolean(docLivenessOpt.toString());
137
- }
138
- }
139
- return new IntegrityCheck(readEmrtd, docLiveness);
140
- }
141
-
142
- private static Extraction getExtraction(HashMap<String, String> integrityMap) {
143
- DataRequirement dataRequirement = DataRequirement.DISABLED;
144
- FaceDetection faceDetection = FaceDetection.DISABLED;
145
-
146
- if(integrityMap.containsKey(DATA_REQUIREMENT)) {
147
- String dataOpt = integrityMap.get(DATA_REQUIREMENT);
148
- if(dataOpt != null) {
149
- dataRequirement = DataRequirement.valueOf(dataOpt);
150
- }
151
- }
152
- if(integrityMap.containsKey(FACE_DETECTION)) {
153
- String faceOpt = integrityMap.get(FACE_DETECTION);
154
- if(faceOpt != null) {
155
- faceDetection = FaceDetection.valueOf(faceOpt);
156
- }
157
- }
158
- return new Extraction(dataRequirement, faceDetection);
159
- }
160
-
161
- private static OnlineConfig getOnlineConfig(HashMap<String, Object> configMap) {
162
- OnlineConfig onlineConfig = new OnlineConfig();
163
-
164
- if(configMap.containsKey(BIOMETRIC_CONSENT)) {
165
- Object bioOpt = configMap.get(BIOMETRIC_CONSENT);
166
- if(bioOpt != null) {
167
- onlineConfig.setBiometricConsent(Boolean.parseBoolean(bioOpt.toString()));
168
- }
169
- }
170
-
171
- if(configMap.containsKey(IS_REFERENCE_DOC)) {
172
- Object refDocOpt = configMap.get(IS_REFERENCE_DOC);
173
- if(refDocOpt != null) {
174
- onlineConfig.setReferenceDocument(Boolean.parseBoolean(refDocOpt.toString()));
175
- }
176
- }
177
-
178
- if(configMap.containsKey(ENABLE_MANUAL_ANALYSIS)) {
179
- Object manualOpt = configMap.get(ENABLE_MANUAL_ANALYSIS);
180
- if(manualOpt != null) {
181
- onlineConfig.setEnableManualAnalysis(Boolean.parseBoolean(manualOpt.toString()));
182
- }
183
- }
184
-
185
- if(configMap.containsKey(FOLDER_UID)) {
186
- Object folderOpt = configMap.get(FOLDER_UID);
187
- if(folderOpt != null) {
188
- onlineConfig.setFolderUid(folderOpt.toString());
189
- }
190
- }
191
-
192
- if(configMap.containsKey(CIS_TYPE)) {
193
- Object cisOpt = configMap.get(CIS_TYPE);
194
- if(cisOpt != null) {
195
- onlineConfig.setCisType(CISType.valueOf(cisOpt.toString()));
196
- }
197
- }
198
- return onlineConfig;
199
- }
200
-
201
- private static Theme getTheme(HashMap<String, Object> themeMap) {
202
- Integer primaryColor = null;
203
- Integer foregroundColor = null;
204
- Integer backgroundColor = null;
205
- Integer borderColor = null;
206
- Integer textColor = null;
207
- Integer titleColor = null;
208
- if(themeMap.containsKey(PRIMARY_COLOR)) {
209
- Object primaryColorOpt = themeMap.get(PRIMARY_COLOR);
210
- if(primaryColorOpt != null) {
211
- primaryColor = Color.parseColor(primaryColorOpt.toString());
212
- }
213
- }
214
-
215
- if(themeMap.containsKey(FOREGROUND_COLOR)) {
216
- Object foregroundColorOpt = themeMap.get(FOREGROUND_COLOR);
217
- if(foregroundColorOpt != null) {
218
- foregroundColor = Color.parseColor(foregroundColorOpt.toString());
219
- }
220
- }
221
-
222
- if(themeMap.containsKey(BACKGROUND_COLOR)) {
223
- Object backgroundColorOpt = themeMap.get(BACKGROUND_COLOR);
224
- if(backgroundColorOpt != null) {
225
- backgroundColor = Color.parseColor(backgroundColorOpt.toString());
226
- }
227
- }
228
-
229
- if(themeMap.containsKey(BORDER_COLOR)) {
230
- Object borderColorOpt = themeMap.get(BORDER_COLOR);
231
- if(borderColorOpt != null) {
232
- borderColor = Color.parseColor(borderColorOpt.toString());
233
- }
234
- }
235
-
236
- if(themeMap.containsKey(TEXT_COLOR)) {
237
- Object textColorOpt = themeMap.get(TEXT_COLOR);
238
- if(textColorOpt != null) {
239
- textColor = Color.parseColor(textColorOpt.toString());
240
- }
241
- }
242
-
243
- if(themeMap.containsKey(TITLE_COLOR)) {
244
- Object titleColorOpt = themeMap.get(TITLE_COLOR);
245
- if(titleColorOpt != null) {
246
- titleColor = Color.parseColor(titleColorOpt.toString());
247
- }
248
- }
249
- return new Theme(foregroundColor, borderColor, backgroundColor, primaryColor, titleColor, textColor);
250
- }
251
- }