assentify-sdk-react-native 0.0.41 → 1.0.0-Beta
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/README.md +11 -1
- package/android/build.gradle +28 -30
- package/android/gradle.properties +2 -2
- package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +81 -118
- package/android/src/main/java/com/assentifysdk/FaceMatchActivity.kt +27 -24
- package/android/src/main/java/com/assentifysdk/FlowActivity.kt +191 -0
- package/android/src/main/java/com/assentifysdk/QrActivity.kt +10 -11
- package/android/src/main/java/com/assentifysdk/ScanIDActivity.kt +83 -98
- package/android/src/main/java/com/assentifysdk/ScanOtherActivity.kt +7 -6
- package/android/src/main/java/com/assentifysdk/ScanPassportActivity.kt +8 -13
- package/android/src/main/res/layout/activity_face_scan.xml +1 -1
- package/android/src/main/res/layout/activity_flow.xml +9 -0
- package/android/src/main/res/layout/activity_scan.xml +1 -1
- package/assentify-sdk.podspec +2 -1
- package/ios/NativeAssentifySdk.mm +24 -4
- package/ios/NativeAssentifySdk.swift +229 -30
- package/ios/UIComponents/RNPassportScanner.swift +4 -3
- package/ios/View/FaceMatchController.swift +131 -124
- package/ios/View/IDCardController.swift +48 -35
- package/ios/View/OtherController.swift +9 -18
- package/ios/View/PassportController.swift +82 -121
- package/ios/View/QrController.swift +9 -6
- package/lib/commonjs/AssentifyProvider.js +88 -101
- package/lib/commonjs/AssentifyProvider.js.map +1 -1
- package/lib/commonjs/AssentifyWrapper.js +11 -17
- package/lib/commonjs/AssentifyWrapper.js.map +1 -1
- package/lib/commonjs/BackgroundType.js +11 -0
- package/lib/commonjs/BackgroundType.js.map +1 -0
- package/lib/commonjs/helpers/parsers/FlowCompletedModelParser.js +26 -0
- package/lib/commonjs/helpers/parsers/FlowCompletedModelParser.js.map +1 -0
- package/lib/commonjs/index.js +4 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/AssentifyProvider.js +86 -98
- package/lib/module/AssentifyProvider.js.map +1 -1
- package/lib/module/AssentifyWrapper.js +11 -17
- package/lib/module/AssentifyWrapper.js.map +1 -1
- package/lib/module/BackgroundType.js +5 -0
- package/lib/module/BackgroundType.js.map +1 -0
- package/lib/module/helpers/parsers/FlowCompletedModelParser.js +20 -0
- package/lib/module/helpers/parsers/FlowCompletedModelParser.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/example/babel.config.d.ts +153 -1
- package/lib/typescript/example/babel.config.d.ts.map +1 -1
- package/lib/typescript/example/metro.config.d.ts +2 -2
- package/lib/typescript/example/metro.config.d.ts.map +1 -1
- package/lib/typescript/example/react-native.config.d.ts +153 -1
- package/lib/typescript/example/react-native.config.d.ts.map +1 -1
- package/lib/typescript/example/src/App.d.ts.map +1 -1
- package/lib/typescript/example/src/Home.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts +3 -1
- package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +4 -6
- package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/BackgroundType.d.ts +6 -0
- package/lib/typescript/lib/commonjs/BackgroundType.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/FlowCompletedModelParser.d.ts +11 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/FlowCompletedModelParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/AssentifyProvider.d.ts +4 -2
- package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -1
- package/lib/typescript/lib/module/AssentifyWrapper.d.ts +4 -6
- package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -1
- package/lib/typescript/lib/module/BackgroundType.d.ts +5 -0
- package/lib/typescript/lib/module/BackgroundType.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/FlowCompletedModelParser.d.ts +10 -0
- package/lib/typescript/lib/module/helpers/parsers/FlowCompletedModelParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +5 -7
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/src/AssentifyProvider.d.ts +5 -2
- package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -1
- package/lib/typescript/src/AssentifyWrapper.d.ts +6 -7
- package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -1
- package/lib/typescript/src/BackgroundType.d.ts +6 -0
- package/lib/typescript/src/BackgroundType.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts.map +1 -1
- package/lib/typescript/src/helpers/parsers/FlowCompletedModelParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/FlowCompletedModelParser.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts.map +1 -1
- package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts.map +1 -1
- package/lib/typescript/src/helpers/parsers/PassportParser.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +11 -2
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +14 -11
- package/src/AssentifyProvider.tsx +196 -147
- package/src/AssentifyWrapper.ts +55 -27
- package/src/BackgroundType.ts +7 -0
- package/src/helpers/parsers/FlowCompletedModelParser.ts +31 -0
- package/src/index.ts +1 -1
- package/src/types.ts +13 -2
- package/lib/commonjs/DoneFlags.js +0 -14
- package/lib/commonjs/DoneFlags.js.map +0 -1
- package/lib/module/DoneFlags.js +0 -8
- package/lib/module/DoneFlags.js.map +0 -1
- package/lib/typescript/lib/commonjs/DoneFlags.d.ts +0 -9
- package/lib/typescript/lib/commonjs/DoneFlags.d.ts.map +0 -1
- package/lib/typescript/lib/module/DoneFlags.d.ts +0 -8
- package/lib/typescript/lib/module/DoneFlags.d.ts.map +0 -1
- package/lib/typescript/src/DoneFlags.d.ts +0 -9
- package/lib/typescript/src/DoneFlags.d.ts.map +0 -1
- package/src/DoneFlags.ts +0 -11
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
package com.assentifysdk
|
|
2
|
+
|
|
3
|
+
import android.content.Intent
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.util.Log
|
|
6
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
7
|
+
|
|
8
|
+
import com.assentify.sdk.AssentifySdk
|
|
9
|
+
import com.assentify.sdk.AssentifySdkObject
|
|
10
|
+
import com.assentify.sdk.Core.Constants.BackgroundType
|
|
11
|
+
import com.assentify.sdk.Core.Constants.BackgroundStyle
|
|
12
|
+
import com.assentify.sdk.Core.Constants.FlowEnvironmentalConditions
|
|
13
|
+
import com.assentify.sdk.Flow.Models.FlowCallBack
|
|
14
|
+
import com.assentify.sdk.Flow.Models.FlowCompletedModel
|
|
15
|
+
|
|
16
|
+
import com.facebook.react.bridge.Arguments
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
18
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
19
|
+
|
|
20
|
+
import com.google.gson.Gson
|
|
21
|
+
import com.google.gson.reflect.TypeToken
|
|
22
|
+
|
|
23
|
+
class FlowActivity : AppCompatActivity() , FlowCallBack {
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
private lateinit var reactApplicationContext: ReactApplicationContext
|
|
27
|
+
private lateinit var assentifySdk: AssentifySdk
|
|
28
|
+
|
|
29
|
+
private lateinit var language: String;
|
|
30
|
+
private var enableNfc: Boolean = false;
|
|
31
|
+
private var enableQr: Boolean = false;
|
|
32
|
+
private var blockLoaderCustomProperties: Map<String, Any> = emptyMap()
|
|
33
|
+
|
|
34
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
35
|
+
super.onCreate(savedInstanceState)
|
|
36
|
+
setContentView(R.layout.activity_flow)
|
|
37
|
+
|
|
38
|
+
reactApplicationContext = ReactApplicationContextObject.getReactApplicationContextObject()
|
|
39
|
+
assentifySdk = AssentifySdkObject.getAssentifySdkObject();
|
|
40
|
+
|
|
41
|
+
// ========= 2) Receive extras from Intent =========
|
|
42
|
+
val intent = intent
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
val logoUrl = intent.getStringExtra("logoUrl")
|
|
46
|
+
val svgBackgroundImageUrl = intent.getStringExtra("svgBackgroundImageUrl")
|
|
47
|
+
|
|
48
|
+
val textColor = intent.getStringExtra("textColor")
|
|
49
|
+
val secondaryTextColor = intent.getStringExtra("secondaryTextColor")
|
|
50
|
+
val backgroundCardColor = intent.getStringExtra("backgroundCardColor")
|
|
51
|
+
val accentColor = intent.getStringExtra("accentColor")
|
|
52
|
+
|
|
53
|
+
val backgroundType = intent.getStringExtra("backgroundType")
|
|
54
|
+
|
|
55
|
+
val backgroundColors = intent.getStringArrayListExtra("backgroundColors") ?: arrayListOf()
|
|
56
|
+
val angleDegreesBackgroundColors =
|
|
57
|
+
intent.getDoubleExtra("angleDegreesBackgroundColors", 90.0)
|
|
58
|
+
|
|
59
|
+
val holdUntilBackgroundColors =
|
|
60
|
+
intent.getDoubleExtra("holdUntilBackgroundColors", 0.4)
|
|
61
|
+
|
|
62
|
+
val clickColors = intent.getStringArrayListExtra("clickColors") ?: arrayListOf()
|
|
63
|
+
|
|
64
|
+
val angleDegreesClickColors =
|
|
65
|
+
intent.getDoubleExtra("angleDegreesClickColors", 90.0)
|
|
66
|
+
|
|
67
|
+
val holdUntilClickColors =
|
|
68
|
+
intent.getDoubleExtra("holdUntilClickColors", 0.4)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
language =
|
|
74
|
+
intent.getStringExtra("language") ?: language
|
|
75
|
+
|
|
76
|
+
enableNfc = intent.getBooleanExtra("enableNfc", false)
|
|
77
|
+
enableQr = intent.getBooleanExtra("enableQr", false)
|
|
78
|
+
val clear = intent.getBooleanExtra("clear", false)
|
|
79
|
+
|
|
80
|
+
// ========= 3) Receive & parse JSON for blockLoaderCustomProperties =========
|
|
81
|
+
val jsonBlockLoaderCustomProperties =
|
|
82
|
+
intent.getStringExtra("jsonBlockLoaderCustomProperties")!!
|
|
83
|
+
val type = object : TypeToken<Map<String, Any>>() {}.type
|
|
84
|
+
blockLoaderCustomProperties =
|
|
85
|
+
Gson().fromJson(jsonBlockLoaderCustomProperties, type) ?: emptyMap()
|
|
86
|
+
|
|
87
|
+
// ========= 4) DEBUG LOGGING =========
|
|
88
|
+
Log.d("FlowActivity", "===== Received Extras =====")
|
|
89
|
+
Log.d("FlowActivity", "logoUrl: $logoUrl")
|
|
90
|
+
Log.d("FlowActivity", "svgBackgroundImageUrl: $svgBackgroundImageUrl")
|
|
91
|
+
Log.d("FlowActivity", "textColor: $textColor")
|
|
92
|
+
Log.d("FlowActivity", "secondaryTextColor: $secondaryTextColor")
|
|
93
|
+
Log.d("FlowActivity", "backgroundCardColor: $backgroundCardColor")
|
|
94
|
+
Log.d("FlowActivity", "accentColor: $accentColor")
|
|
95
|
+
Log.d("FlowActivity", "backgroundType: $backgroundType")
|
|
96
|
+
Log.d("FlowActivity", "clear: $clear")
|
|
97
|
+
Log.d("FlowActivity", "backgroundColors: $backgroundColors")
|
|
98
|
+
Log.d("FlowActivity", "angleDegreesBackgroundColors: $angleDegreesBackgroundColors")
|
|
99
|
+
Log.d("FlowActivity", "holdUntilBackgroundColors: $holdUntilBackgroundColors")
|
|
100
|
+
Log.d("FlowActivity", "clickColors: $clickColors")
|
|
101
|
+
Log.d("FlowActivity", "angleDegreesClickColors: $angleDegreesClickColors")
|
|
102
|
+
Log.d("FlowActivity", "holdUntilClickColors: $holdUntilClickColors")
|
|
103
|
+
|
|
104
|
+
Log.d("FlowActivity", "language: $language")
|
|
105
|
+
Log.d("FlowActivity", "enableNfc: $enableNfc")
|
|
106
|
+
Log.d("FlowActivity", "enableQr: $enableQr")
|
|
107
|
+
Log.d("FlowActivity", "blockLoaderCustomProperties: $blockLoaderCustomProperties")
|
|
108
|
+
Log.d("FlowActivity", "================================")
|
|
109
|
+
|
|
110
|
+
val bType = BackgroundType.entries.firstOrNull {
|
|
111
|
+
it.type.equals(backgroundType, ignoreCase = true)
|
|
112
|
+
} ?: BackgroundType.Color
|
|
113
|
+
|
|
114
|
+
var backgroundColor: BackgroundStyle? = null
|
|
115
|
+
var clickColor: BackgroundStyle? = null
|
|
116
|
+
|
|
117
|
+
if (backgroundColors.isNotEmpty()) {
|
|
118
|
+
if (backgroundColors.size >= 2) {
|
|
119
|
+
backgroundColor = BackgroundStyle.Gradient(
|
|
120
|
+
colorsHex = backgroundColors,
|
|
121
|
+
angleDegrees = angleDegreesBackgroundColors.toFloat(),
|
|
122
|
+
holdUntil = holdUntilBackgroundColors.toFloat()
|
|
123
|
+
)
|
|
124
|
+
} else {
|
|
125
|
+
backgroundColor = BackgroundStyle.Solid(backgroundColors.firstOrNull()!!)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (clickColors.isNotEmpty()) {
|
|
130
|
+
if (clickColors.size >= 2) {
|
|
131
|
+
clickColor = BackgroundStyle.Gradient(
|
|
132
|
+
colorsHex = clickColors,
|
|
133
|
+
angleDegrees = angleDegreesClickColors.toFloat(),
|
|
134
|
+
holdUntil = holdUntilClickColors.toFloat()
|
|
135
|
+
)
|
|
136
|
+
} else {
|
|
137
|
+
clickColor = BackgroundStyle.Solid(clickColors.firstOrNull()!!)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if (clear) {
|
|
145
|
+
assentifySdk.clearFlow(this@FlowActivity);
|
|
146
|
+
}
|
|
147
|
+
val flowEnvironmentalConditions = FlowEnvironmentalConditions(
|
|
148
|
+
logoUrl = logoUrl!!,
|
|
149
|
+
svgBackgroundImageUrl = svgBackgroundImageUrl!!,
|
|
150
|
+
textColor = textColor!!,
|
|
151
|
+
secondaryTextColor = secondaryTextColor!!,
|
|
152
|
+
backgroundCardColor = backgroundCardColor!!,
|
|
153
|
+
accentColor = accentColor!!,
|
|
154
|
+
backgroundType = bType,
|
|
155
|
+
backgroundColor = backgroundColor,
|
|
156
|
+
clickColor = clickColor,
|
|
157
|
+
language = language,
|
|
158
|
+
enableNfc = enableNfc,
|
|
159
|
+
enableQr = enableQr,
|
|
160
|
+
blockLoaderCustomProperties = blockLoaderCustomProperties
|
|
161
|
+
);
|
|
162
|
+
assentifySdk.startFlow(
|
|
163
|
+
activityContext = this@FlowActivity,
|
|
164
|
+
flowCallback = this,
|
|
165
|
+
flowEnvironmentalConditions = flowEnvironmentalConditions
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
override fun onFlowCompleted(flowData: List<FlowCompletedModel>) {
|
|
172
|
+
triggerCompleteEvent("OnNativeFlowCompleted", flowData)
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
private fun triggerCompleteEvent(eventName: String, flowData: List<FlowCompletedModel>) {
|
|
178
|
+
val eventResultMap = Arguments.createMap().apply {
|
|
179
|
+
if (flowData != null) {
|
|
180
|
+
val gson = Gson()
|
|
181
|
+
val jsonString = gson.toJson(flowData!!)
|
|
182
|
+
putString("DataModel", jsonString)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
186
|
+
.emit(eventName, eventResultMap)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
}
|
|
@@ -23,14 +23,12 @@ import androidx.core.content.ContextCompat
|
|
|
23
23
|
import com.assentify.sdk.AssentifySdk
|
|
24
24
|
import com.assentify.sdk.AssentifySdkObject
|
|
25
25
|
import com.assentify.sdk.Core.Constants.ConstantsValues
|
|
26
|
-
import com.assentify.sdk.Core.Constants.DoneFlags
|
|
27
26
|
import com.assentify.sdk.Core.Constants.Language
|
|
28
27
|
import com.assentify.sdk.ScanPassport.PassportResponseModel
|
|
29
28
|
import com.assentify.sdk.ScanPassport.ScanPassportCallback
|
|
30
29
|
import com.google.gson.Gson
|
|
31
30
|
import com.assentify.sdk.ScanIDCard.IDResponseModel
|
|
32
31
|
import com.assentify.sdk.Models.BaseResponseDataModel
|
|
33
|
-
import com.assentify.sdk.RemoteClient.Models.KycDocumentDetails
|
|
34
32
|
import com.assentify.sdk.ScanIDCard.IDExtractedModel
|
|
35
33
|
import com.assentify.sdk.ScanPassport.ScanPassportResult
|
|
36
34
|
import com.assentify.sdk.ScanQr.ScanQrCallback
|
|
@@ -44,6 +42,8 @@ import com.facebook.react.bridge.Arguments
|
|
|
44
42
|
import android.content.Context
|
|
45
43
|
import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
|
|
46
44
|
|
|
45
|
+
import com.assentify.sdk.RemoteClient.Models.TemplatesByCountry
|
|
46
|
+
|
|
47
47
|
class QrActivity : AppCompatActivity() , ScanQrCallback {
|
|
48
48
|
private lateinit var language: String;
|
|
49
49
|
|
|
@@ -54,8 +54,9 @@ class QrActivity : AppCompatActivity() , ScanQrCallback {
|
|
|
54
54
|
private lateinit var holdHandColor: String;
|
|
55
55
|
private lateinit var processingColor: String;
|
|
56
56
|
|
|
57
|
-
private lateinit var
|
|
58
|
-
|
|
57
|
+
private lateinit var templatesByCountryObject: String;
|
|
58
|
+
private lateinit var templatesByCountry: TemplatesByCountry;
|
|
59
|
+
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
private lateinit var popUpContainer: LinearLayout
|
|
@@ -80,11 +81,9 @@ class QrActivity : AppCompatActivity() , ScanQrCallback {
|
|
|
80
81
|
setContentView(R.layout.activity_qr)
|
|
81
82
|
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
val listType = object : TypeToken<List<KycDocumentDetails>>() {}.type
|
|
87
|
-
kycDocumentDetails = gson.fromJson(jsonStringKycDocumentDetails, listType)
|
|
84
|
+
templatesByCountryObject = intent.getStringExtra("templatesByCountryObject")!!
|
|
85
|
+
val gson = Gson()
|
|
86
|
+
templatesByCountry = gson.fromJson(templatesByCountryObject, TemplatesByCountry::class.java)
|
|
88
87
|
|
|
89
88
|
|
|
90
89
|
reactApplicationContext = ReactApplicationContextObject.getReactApplicationContextObject()
|
|
@@ -209,7 +208,7 @@ class QrActivity : AppCompatActivity() , ScanQrCallback {
|
|
|
209
208
|
assentifySdk = AssentifySdkObject.getAssentifySdkObject();
|
|
210
209
|
when (val result = assentifySdk!!.startScanQr(
|
|
211
210
|
this@QrActivity,
|
|
212
|
-
|
|
211
|
+
templatesByCountry,
|
|
213
212
|
language,
|
|
214
213
|
stepId = stepID,
|
|
215
214
|
)) {
|
|
@@ -282,7 +281,7 @@ class QrActivity : AppCompatActivity() , ScanQrCallback {
|
|
|
282
281
|
}
|
|
283
282
|
}
|
|
284
283
|
|
|
285
|
-
override fun onErrorQrScan(message: String) {
|
|
284
|
+
override fun onErrorQrScan(message: String,dataModel: BaseResponseDataModel) {
|
|
286
285
|
runOnUiThread {
|
|
287
286
|
infoLayout.visibility = View.VISIBLE
|
|
288
287
|
start = false;
|
|
@@ -17,7 +17,6 @@ import com.assentify.sdk.Core.Constants.MotionType
|
|
|
17
17
|
import com.assentify.sdk.Core.Constants.ZoomType
|
|
18
18
|
import com.assentify.sdk.Models.BaseResponseDataModel
|
|
19
19
|
import com.assentify.sdk.Models.encodeBaseResponseDataModelToJson
|
|
20
|
-
import com.assentify.sdk.RemoteClient.Models.KycDocumentDetails
|
|
21
20
|
import com.assentify.sdk.ScanIDCard.IDCardCallback
|
|
22
21
|
import com.assentify.sdk.ScanIDCard.IDResponseModel
|
|
23
22
|
import com.assentify.sdk.ScanIDCard.IDExtractedModel
|
|
@@ -33,13 +32,13 @@ import ImageToBase64Converter
|
|
|
33
32
|
import android.content.Intent
|
|
34
33
|
import android.content.res.ColorStateList
|
|
35
34
|
import com.assentify.sdk.Core.Constants.BrightnessEvents
|
|
36
|
-
import com.assentify.sdk.Core.Constants.DoneFlags
|
|
37
35
|
import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
|
|
38
36
|
import com.assentify.sdk.ScanIDCard.ScanIDCardManual
|
|
39
37
|
import com.assentify.sdk.ScanIDCard.ScanIDCardResult
|
|
40
38
|
import com.facebook.react.bridge.Arguments
|
|
41
39
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
42
40
|
import com.squareup.picasso.Picasso
|
|
41
|
+
import com.assentify.sdk.RemoteClient.Models.TemplatesByCountry
|
|
43
42
|
|
|
44
43
|
class ScanIDActivity: AppCompatActivity(),
|
|
45
44
|
IDCardCallback {
|
|
@@ -59,13 +58,11 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
59
58
|
private lateinit var popUpText: TextView
|
|
60
59
|
private lateinit var popUpSubText: TextView
|
|
61
60
|
private lateinit var idGif: LinearLayout
|
|
62
|
-
private lateinit var jsonStringKycDocumentDetails: String;
|
|
63
61
|
private lateinit var holdHandColor: String;
|
|
64
62
|
private lateinit var processingColor: String;
|
|
65
63
|
private lateinit var language: String;
|
|
66
64
|
private lateinit var title: String;
|
|
67
65
|
private var isFlippingCard: Boolean = false;
|
|
68
|
-
private lateinit var kycDocumentDetails: List<KycDocumentDetails>;
|
|
69
66
|
private lateinit var popUpButton: Button
|
|
70
67
|
private var start: Boolean = false;
|
|
71
68
|
private var frontModel: IDResponseModel? = null
|
|
@@ -75,14 +72,17 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
75
72
|
private var stepID: Int = -1;
|
|
76
73
|
private lateinit var takePhotoButton: Button;
|
|
77
74
|
private lateinit var manualClickColor: String;
|
|
75
|
+
|
|
76
|
+
private lateinit var templatesByCountryObject: String;
|
|
77
|
+
private lateinit var templatesByCountry: TemplatesByCountry;
|
|
78
|
+
|
|
78
79
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
79
80
|
super.onCreate(savedInstanceState)
|
|
80
81
|
setContentView(R.layout.activity_scan)
|
|
81
82
|
reactApplicationContext = ReactApplicationContextObject.getReactApplicationContextObject()
|
|
82
|
-
|
|
83
|
+
templatesByCountryObject = intent.getStringExtra("templatesByCountryObject")!!
|
|
83
84
|
val gson = Gson()
|
|
84
|
-
|
|
85
|
-
kycDocumentDetails = gson.fromJson(jsonStringKycDocumentDetails, listType)
|
|
85
|
+
templatesByCountry = gson.fromJson(templatesByCountryObject, TemplatesByCountry::class.java)
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
holdHandColor = intent.getStringExtra("holdHandColor")!!
|
|
@@ -237,7 +237,7 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
237
237
|
assentifySdk = AssentifySdkObject.getAssentifySdkObject();
|
|
238
238
|
|
|
239
239
|
when (val result = assentifySdk!!.startScanIDCard(
|
|
240
|
-
this@ScanIDActivity,
|
|
240
|
+
this@ScanIDActivity,templatesByCountry,language,stepID!!
|
|
241
241
|
)) {
|
|
242
242
|
is ScanIDCardResult.Manual -> {
|
|
243
243
|
scanIDManual = result.data
|
|
@@ -294,6 +294,9 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
override fun onClipPreparationComplete(dataModel: BaseResponseDataModel) {
|
|
298
|
+
triggerEvent("onClipPreparationComplete", dataModel)
|
|
299
|
+
}
|
|
297
300
|
|
|
298
301
|
override fun onLivenessUpdate(dataModel: BaseResponseDataModel) {
|
|
299
302
|
triggerEvent("onLivenessUpdate", dataModel)
|
|
@@ -309,106 +312,71 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
309
312
|
}
|
|
310
313
|
|
|
311
314
|
|
|
312
|
-
override fun onComplete(dataModel: IDResponseModel,
|
|
315
|
+
override fun onComplete(dataModel: IDResponseModel,isFrontPage : Boolean,isLastPage : Boolean,classifiedTemplate: String){
|
|
313
316
|
|
|
314
|
-
|
|
317
|
+
|
|
318
|
+
triggerCompleteEvent("onComplete", dataModel,isFrontPage,isLastPage)
|
|
315
319
|
|
|
316
320
|
values.putAll(convertMap(dataModel.iDExtractedModel!!.transformedProperties))
|
|
317
321
|
|
|
322
|
+
if(isLastPage ){
|
|
323
|
+
if(isManual){
|
|
324
|
+
scanIDManual.stopScanning();
|
|
325
|
+
}else{
|
|
326
|
+
scanID.stopScanning();
|
|
327
|
+
}
|
|
328
|
+
/** Data To Submit **/
|
|
318
329
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
/** Data To Submit **/
|
|
330
|
+
val sharedPreferences = reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
|
|
331
|
+
val gson = Gson()
|
|
332
|
+
val existingJson = sharedPreferences.getString(stepID.toString(), null)
|
|
333
|
+
val updatedModel: SubmitRequestModel = if (existingJson != null) {
|
|
334
|
+
// Deserialize to object
|
|
335
|
+
val existingModel = gson.fromJson(existingJson, SubmitRequestModel::class.java)
|
|
327
336
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
val existingJson = sharedPreferences.getString(stepID.toString(), null)
|
|
331
|
-
val updatedModel: SubmitRequestModel = if (existingJson != null) {
|
|
332
|
-
// Deserialize to object
|
|
333
|
-
val existingModel = gson.fromJson(existingJson, SubmitRequestModel::class.java)
|
|
337
|
+
// Make a mutable copy of the existing map
|
|
338
|
+
val updatedInfo = existingModel.extractedInformation.toMutableMap()
|
|
334
339
|
|
|
335
|
-
|
|
336
|
-
|
|
340
|
+
// Merge new values (replace if exists, add if not)
|
|
341
|
+
for ((k, v) in values) {
|
|
342
|
+
updatedInfo[k] = v
|
|
343
|
+
}
|
|
337
344
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
345
|
+
// Create new model with updated map
|
|
346
|
+
existingModel.copy(extractedInformation = updatedInfo)
|
|
347
|
+
} else {
|
|
348
|
+
// If no existing model, just create a new one
|
|
349
|
+
SubmitRequestModel(stepID!!, StepsName.DocumentCapture, values)
|
|
350
|
+
}
|
|
351
|
+
sharedPreferences.edit()
|
|
352
|
+
.putString(stepID.toString(), gson.toJson(updatedModel))
|
|
353
|
+
.apply()
|
|
342
354
|
|
|
343
|
-
// Create new model with updated map
|
|
344
|
-
existingModel.copy(extractedInformation = updatedInfo)
|
|
345
|
-
} else {
|
|
346
|
-
// If no existing model, just create a new one
|
|
347
|
-
SubmitRequestModel(stepID!!, StepsName.DocumentCapture, values)
|
|
348
|
-
}
|
|
349
|
-
sharedPreferences.edit()
|
|
350
|
-
.putString(stepID.toString(), gson.toJson(updatedModel))
|
|
351
|
-
.apply()
|
|
352
355
|
|
|
353
356
|
|
|
357
|
+
/** **/
|
|
358
|
+
runOnUiThread {
|
|
359
|
+
finish()
|
|
360
|
+
}
|
|
354
361
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
hidePopUpMessage()
|
|
365
|
-
if(isFlippingCard){
|
|
366
|
-
showBackIDPage();
|
|
367
|
-
}else{
|
|
368
|
-
if(isManual){
|
|
369
|
-
scanIDManual.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
|
|
370
|
-
}else{
|
|
371
|
-
scanID.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
362
|
+
}else{
|
|
363
|
+
if(isFrontPage){
|
|
364
|
+
frontModel = dataModel;
|
|
365
|
+
start = false;
|
|
366
|
+
}
|
|
367
|
+
hidePopUpMessage()
|
|
368
|
+
if(isFlippingCard){
|
|
369
|
+
showBackIDPage(classifiedTemplate);
|
|
375
370
|
}else{
|
|
376
371
|
if(isManual){
|
|
377
|
-
scanIDManual.
|
|
372
|
+
scanIDManual.changeTemplateId();
|
|
378
373
|
}else{
|
|
379
|
-
scanID.
|
|
374
|
+
scanID.changeTemplateId();
|
|
380
375
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
val sharedPreferences = reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
|
|
384
|
-
val gson = Gson()
|
|
385
|
-
val existingJson = sharedPreferences.getString(stepID.toString(), null)
|
|
386
|
-
val updatedModel: SubmitRequestModel = if (existingJson != null) {
|
|
387
|
-
// Deserialize to object
|
|
388
|
-
val existingModel = gson.fromJson(existingJson, SubmitRequestModel::class.java)
|
|
389
|
-
|
|
390
|
-
// Make a mutable copy of the existing map
|
|
391
|
-
val updatedInfo = existingModel.extractedInformation.toMutableMap()
|
|
392
|
-
|
|
393
|
-
for ((k, v) in values) {
|
|
394
|
-
updatedInfo[k] = v
|
|
395
|
-
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
396
378
|
|
|
397
|
-
// Create new model with updated map
|
|
398
|
-
existingModel.copy(extractedInformation = updatedInfo)
|
|
399
|
-
} else {
|
|
400
|
-
// If no existing model, just create a new one
|
|
401
|
-
SubmitRequestModel(stepID!!, StepsName.DocumentCapture, values)
|
|
402
|
-
}
|
|
403
|
-
sharedPreferences.edit()
|
|
404
|
-
.putString(stepID.toString(), gson.toJson(updatedModel))
|
|
405
|
-
.apply()
|
|
406
379
|
|
|
407
|
-
/** **/
|
|
408
|
-
runOnUiThread {
|
|
409
|
-
finish()
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
380
|
|
|
413
381
|
|
|
414
382
|
}
|
|
@@ -421,7 +389,7 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
421
389
|
}
|
|
422
390
|
}
|
|
423
391
|
|
|
424
|
-
override fun onEnvironmentalConditionsChange(brightnessEvents:
|
|
392
|
+
override fun onEnvironmentalConditionsChange(brightnessEvents:BrightnessEvents, motion: MotionType,zoom: ZoomType,isCentered: Boolean){
|
|
425
393
|
runOnUiThread {
|
|
426
394
|
if(start == false){
|
|
427
395
|
infoLayout.visibility = View.VISIBLE
|
|
@@ -457,6 +425,9 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
457
425
|
if (motion == MotionType.NO_DETECT && zoom == ZoomType.NO_DETECT){
|
|
458
426
|
infoText.setText("Please present ID")
|
|
459
427
|
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
428
|
+
}else if(!isCentered){
|
|
429
|
+
infoText.setText("Please center your card")
|
|
430
|
+
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
460
431
|
}
|
|
461
432
|
}
|
|
462
433
|
}else {
|
|
@@ -467,6 +438,7 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
467
438
|
|
|
468
439
|
|
|
469
440
|
|
|
441
|
+
|
|
470
442
|
fun convertMap(map: Map<String, Any>?): Map<String, String> {
|
|
471
443
|
return map?.mapValues {
|
|
472
444
|
it.value.toString()
|
|
@@ -474,13 +446,14 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
474
446
|
}
|
|
475
447
|
|
|
476
448
|
|
|
477
|
-
private fun triggerCompleteEvent(eventName:String, dataModel:
|
|
449
|
+
private fun triggerCompleteEvent(eventName: String, dataModel: IDResponseModel?,isFrontPage:Boolean,isLastPage:Boolean) {
|
|
478
450
|
val eventResultMap = Arguments.createMap().apply {
|
|
479
451
|
if(dataModel!=null){
|
|
480
452
|
val gson = Gson()
|
|
481
|
-
val jsonString = gson.toJson(dataModel!!)
|
|
453
|
+
val jsonString = gson.toJson(dataModel.iDExtractedModel!!)
|
|
482
454
|
putString("IdDataModel", jsonString)
|
|
483
|
-
putString("
|
|
455
|
+
putString("isFrontPage", isFrontPage.toString())
|
|
456
|
+
putString("isLastPage", isLastPage.toString())
|
|
484
457
|
}
|
|
485
458
|
}
|
|
486
459
|
reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
@@ -519,7 +492,8 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
519
492
|
}
|
|
520
493
|
|
|
521
494
|
|
|
522
|
-
fun showBackIDPage(){
|
|
495
|
+
fun showBackIDPage(classifiedTemplate: String){
|
|
496
|
+
|
|
523
497
|
runOnUiThread{
|
|
524
498
|
|
|
525
499
|
takePhotoButton.visibility = View.GONE
|
|
@@ -536,9 +510,9 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
536
510
|
val nextTemplate = findViewById<Button>(R.id.nextTemplate)
|
|
537
511
|
nextTemplate.setOnClickListener {
|
|
538
512
|
if(isManual){
|
|
539
|
-
scanIDManual.changeTemplateId(
|
|
513
|
+
scanIDManual.changeTemplateId();
|
|
540
514
|
}else{
|
|
541
|
-
scanID.changeTemplateId(
|
|
515
|
+
scanID.changeTemplateId();
|
|
542
516
|
}
|
|
543
517
|
hidrBackIDPage();
|
|
544
518
|
}
|
|
@@ -547,9 +521,20 @@ class ScanIDActivity: AppCompatActivity(),
|
|
|
547
521
|
drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
|
|
548
522
|
nextTemplate.setBackground(drawableInfo)
|
|
549
523
|
|
|
524
|
+
var imageUrl = "";
|
|
525
|
+
if (classifiedTemplate.isNotEmpty()) {
|
|
526
|
+
for (it in templatesByCountry.templates) {
|
|
527
|
+
for (it1 in it.kycDocumentDetails) {
|
|
528
|
+
if (it1.templateProcessingKeyInformation == classifiedTemplate) {
|
|
529
|
+
imageUrl = it.kycDocumentDetails.first { it.templateProcessingKeyInformation != classifiedTemplate }.templateSpecimen;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
550
535
|
val ivSample = findViewById<ImageView>(R.id.ivSample)
|
|
551
536
|
Picasso.get()
|
|
552
|
-
.load(
|
|
537
|
+
.load(imageUrl)
|
|
553
538
|
.into(ivSample)
|
|
554
539
|
}
|
|
555
540
|
}
|
|
@@ -34,7 +34,6 @@ import android.graphics.PorterDuff
|
|
|
34
34
|
import android.widget.LinearLayout
|
|
35
35
|
import android.widget.RelativeLayout
|
|
36
36
|
import com.assentify.sdk.Core.Constants.BrightnessEvents
|
|
37
|
-
import com.assentify.sdk.Core.Constants.DoneFlags
|
|
38
37
|
import com.assentify.sdk.ScanOther.ScanOtherManual
|
|
39
38
|
import com.assentify.sdk.ScanOther.ScanOtherResult
|
|
40
39
|
import java.text.SimpleDateFormat
|
|
@@ -274,8 +273,8 @@ class ScanOtherActivity: AppCompatActivity(),
|
|
|
274
273
|
|
|
275
274
|
|
|
276
275
|
|
|
277
|
-
override fun onComplete(dataModel: OtherResponseModel
|
|
278
|
-
triggerCompleteEvent("onComplete",dataModel
|
|
276
|
+
override fun onComplete(dataModel: OtherResponseModel) {
|
|
277
|
+
triggerCompleteEvent("onComplete",dataModel)
|
|
279
278
|
/** Steps **/
|
|
280
279
|
|
|
281
280
|
/** Data To Submit **/
|
|
@@ -327,7 +326,7 @@ class ScanOtherActivity: AppCompatActivity(),
|
|
|
327
326
|
|
|
328
327
|
}
|
|
329
328
|
|
|
330
|
-
override fun onEnvironmentalConditionsChange(brightnessEvents:
|
|
329
|
+
override fun onEnvironmentalConditionsChange(brightnessEvents:BrightnessEvents, motion: MotionType,zoom: ZoomType, isCentered: Boolean,){
|
|
331
330
|
runOnUiThread {
|
|
332
331
|
if(start == false){
|
|
333
332
|
infoLayout.visibility = View.VISIBLE
|
|
@@ -363,6 +362,9 @@ class ScanOtherActivity: AppCompatActivity(),
|
|
|
363
362
|
if (motion == MotionType.NO_DETECT && zoom == ZoomType.NO_DETECT){
|
|
364
363
|
infoText.setText("Please present ID")
|
|
365
364
|
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
365
|
+
}else if(!isCentered){
|
|
366
|
+
infoText.setText("Please center your card")
|
|
367
|
+
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
366
368
|
}
|
|
367
369
|
}
|
|
368
370
|
}else {
|
|
@@ -379,13 +381,12 @@ class ScanOtherActivity: AppCompatActivity(),
|
|
|
379
381
|
} ?: emptyMap()
|
|
380
382
|
}
|
|
381
383
|
|
|
382
|
-
private fun triggerCompleteEvent(eventName:String, dataModel: OtherResponseModel
|
|
384
|
+
private fun triggerCompleteEvent(eventName:String, dataModel: OtherResponseModel?){
|
|
383
385
|
val eventResultMap = Arguments.createMap().apply {
|
|
384
386
|
if(dataModel!=null){
|
|
385
387
|
val gson = Gson()
|
|
386
388
|
val jsonString = gson.toJson(dataModel.otherExtractedModel!!)
|
|
387
389
|
putString("OtherDataModel", jsonString)
|
|
388
|
-
putString("DoneFlag", doneFlag.toString())
|
|
389
390
|
}
|
|
390
391
|
}
|
|
391
392
|
reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|