assentify-sdk-react-native 0.0.1

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 (195) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +65 -0
  3. package/android/build.gradle +111 -0
  4. package/android/gradle.properties +9 -0
  5. package/android/src/main/AndroidManifest.xml +55 -0
  6. package/android/src/main/java/com/assentifysdk/AndroidProgressBarModule.kt +33 -0
  7. package/android/src/main/java/com/assentifysdk/AssentifySdkBaseModule.kt +39 -0
  8. package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +432 -0
  9. package/android/src/main/java/com/assentifysdk/AssentifySdkPackage.kt +19 -0
  10. package/android/src/main/java/com/assentifysdk/FaceMatchActivity.kt +309 -0
  11. package/android/src/main/java/com/assentifysdk/ImageToBase64Converter.kt +40 -0
  12. package/android/src/main/java/com/assentifysdk/ReactApplicationContextObject.kt +14 -0
  13. package/android/src/main/java/com/assentifysdk/ScanIDActivity.kt +431 -0
  14. package/android/src/main/java/com/assentifysdk/ScanOtherActivity.kt +328 -0
  15. package/android/src/main/java/com/assentifysdk/ScanPassportActivity.kt +364 -0
  16. package/android/src/main/java/com/assentifysdk/StepsKeys.kt +91 -0
  17. package/android/src/main/res/drawable/back_icon.png +0 -0
  18. package/android/src/main/res/drawable/button_rounded_background.xml +6 -0
  19. package/android/src/main/res/drawable/card.gif +0 -0
  20. package/android/src/main/res/drawable/expire.png +0 -0
  21. package/android/src/main/res/drawable/id.gif +0 -0
  22. package/android/src/main/res/drawable/id_warning.png +0 -0
  23. package/android/src/main/res/drawable/info_icon.png +0 -0
  24. package/android/src/main/res/drawable/info_rounded_background.xml +6 -0
  25. package/android/src/main/res/drawable/passport.gif +0 -0
  26. package/android/src/main/res/drawable/rounded_background.xml +3 -0
  27. package/android/src/main/res/drawable/sending.png +0 -0
  28. package/android/src/main/res/drawable/warning.png +0 -0
  29. package/android/src/main/res/drawable/zoom_in.png +0 -0
  30. package/android/src/main/res/drawable/zoom_out.png +0 -0
  31. package/android/src/main/res/layout/activity_face_scan.xml +242 -0
  32. package/android/src/main/res/layout/activity_scan.xml +297 -0
  33. package/android/src/main/res/raw/sending_video.MP4 +0 -0
  34. package/android/src/main/res/values/colors.xml +8 -0
  35. package/android/src/main/res/values/strings.xml +3 -0
  36. package/android/src/main/res/values/styles.xml +4 -0
  37. package/assentify-sdk.podspec +43 -0
  38. package/ios/AssentifySdkBaseModule.swift +15 -0
  39. package/ios/Info.plist +27 -0
  40. package/ios/NativeAssentifySdk-Bridging-Header.h +3 -0
  41. package/ios/NativeAssentifySdk.mm +45 -0
  42. package/ios/NativeAssentifySdk.swift +460 -0
  43. package/ios/Resources/card.gif +0 -0
  44. package/ios/Resources/expire.png +0 -0
  45. package/ios/Resources/id.gif +0 -0
  46. package/ios/Resources/id_warning.png +0 -0
  47. package/ios/Resources/info_icon.png +0 -0
  48. package/ios/Resources/passport.gif +0 -0
  49. package/ios/Resources/sending.png +0 -0
  50. package/ios/Resources/warning.png +0 -0
  51. package/ios/Resources/zoom_in.png +0 -0
  52. package/ios/Resources/zoom_out.png +0 -0
  53. package/ios/UIComponents/RNIOSProgressBar.h +4 -0
  54. package/ios/UIComponents/RNIOSProgressBar.m +34 -0
  55. package/ios/UIComponents/RNPassportScanner.m +26 -0
  56. package/ios/UIComponents/RNPassportScanner.swift +245 -0
  57. package/ios/UIComponents/RNTMapManager.h +4 -0
  58. package/ios/UIComponents/RNTMapManager.m +19 -0
  59. package/ios/View/DataDecoder.swift +469 -0
  60. package/ios/View/FaceMatchController.swift +258 -0
  61. package/ios/View/IDCardController.swift +360 -0
  62. package/ios/View/OtherController.swift +283 -0
  63. package/ios/View/PassportController.swift +302 -0
  64. package/ios/View/UI.swift +298 -0
  65. package/lib/commonjs/AssentifyProvider.js +202 -0
  66. package/lib/commonjs/AssentifyProvider.js.map +1 -0
  67. package/lib/commonjs/AssentifyWrapper.js +76 -0
  68. package/lib/commonjs/AssentifyWrapper.js.map +1 -0
  69. package/lib/commonjs/Language.js +27 -0
  70. package/lib/commonjs/Language.js.map +1 -0
  71. package/lib/commonjs/helpers/index.js +2 -0
  72. package/lib/commonjs/helpers/index.js.map +1 -0
  73. package/lib/commonjs/helpers/parsers/FaceMatchParser.js +27 -0
  74. package/lib/commonjs/helpers/parsers/FaceMatchParser.js.map +1 -0
  75. package/lib/commonjs/helpers/parsers/IDCardParser.js +25 -0
  76. package/lib/commonjs/helpers/parsers/IDCardParser.js.map +1 -0
  77. package/lib/commonjs/helpers/parsers/OtherIDParser.js +29 -0
  78. package/lib/commonjs/helpers/parsers/OtherIDParser.js.map +1 -0
  79. package/lib/commonjs/helpers/parsers/PassportParser.js +25 -0
  80. package/lib/commonjs/helpers/parsers/PassportParser.js.map +1 -0
  81. package/lib/commonjs/index.js +49 -0
  82. package/lib/commonjs/index.js.map +1 -0
  83. package/lib/commonjs/types.js +42 -0
  84. package/lib/commonjs/types.js.map +1 -0
  85. package/lib/module/AssentifyProvider.js +193 -0
  86. package/lib/module/AssentifyProvider.js.map +1 -0
  87. package/lib/module/AssentifyWrapper.js +70 -0
  88. package/lib/module/AssentifyWrapper.js.map +1 -0
  89. package/lib/module/Language.js +21 -0
  90. package/lib/module/Language.js.map +1 -0
  91. package/lib/module/helpers/index.js +2 -0
  92. package/lib/module/helpers/index.js.map +1 -0
  93. package/lib/module/helpers/parsers/FaceMatchParser.js +21 -0
  94. package/lib/module/helpers/parsers/FaceMatchParser.js.map +1 -0
  95. package/lib/module/helpers/parsers/IDCardParser.js +19 -0
  96. package/lib/module/helpers/parsers/IDCardParser.js.map +1 -0
  97. package/lib/module/helpers/parsers/OtherIDParser.js +23 -0
  98. package/lib/module/helpers/parsers/OtherIDParser.js.map +1 -0
  99. package/lib/module/helpers/parsers/PassportParser.js +19 -0
  100. package/lib/module/helpers/parsers/PassportParser.js.map +1 -0
  101. package/lib/module/index.js +6 -0
  102. package/lib/module/index.js.map +1 -0
  103. package/lib/module/types.js +36 -0
  104. package/lib/module/types.js.map +1 -0
  105. package/lib/typescript/babel.config.d.ts +3 -0
  106. package/lib/typescript/babel.config.d.ts.map +1 -0
  107. package/lib/typescript/commitlint.config.d.ts +7 -0
  108. package/lib/typescript/commitlint.config.d.ts.map +1 -0
  109. package/lib/typescript/example/babel.config.d.ts +8 -0
  110. package/lib/typescript/example/babel.config.d.ts.map +1 -0
  111. package/lib/typescript/example/index.d.ts +2 -0
  112. package/lib/typescript/example/index.d.ts.map +1 -0
  113. package/lib/typescript/example/jest.config.d.ts +2 -0
  114. package/lib/typescript/example/jest.config.d.ts.map +1 -0
  115. package/lib/typescript/example/metro.config.d.ts +3 -0
  116. package/lib/typescript/example/metro.config.d.ts.map +1 -0
  117. package/lib/typescript/example/react-native.config.d.ts +6 -0
  118. package/lib/typescript/example/react-native.config.d.ts.map +1 -0
  119. package/lib/typescript/example/src/App.d.ts +3 -0
  120. package/lib/typescript/example/src/App.d.ts.map +1 -0
  121. package/lib/typescript/example/src/Home.d.ts +4 -0
  122. package/lib/typescript/example/src/Home.d.ts.map +1 -0
  123. package/lib/typescript/example/src/navigator.d.ts +4 -0
  124. package/lib/typescript/example/src/navigator.d.ts.map +1 -0
  125. package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts +3 -0
  126. package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -0
  127. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +11 -0
  128. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -0
  129. package/lib/typescript/lib/commonjs/Language.d.ts +22 -0
  130. package/lib/typescript/lib/commonjs/Language.d.ts.map +1 -0
  131. package/lib/typescript/lib/commonjs/helpers/index.d.ts +1 -0
  132. package/lib/typescript/lib/commonjs/helpers/index.d.ts.map +1 -0
  133. package/lib/typescript/lib/commonjs/helpers/parsers/FaceMatchParser.d.ts +12 -0
  134. package/lib/typescript/lib/commonjs/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
  135. package/lib/typescript/lib/commonjs/helpers/parsers/IDCardParser.d.ts +11 -0
  136. package/lib/typescript/lib/commonjs/helpers/parsers/IDCardParser.d.ts.map +1 -0
  137. package/lib/typescript/lib/commonjs/helpers/parsers/OtherIDParser.d.ts +13 -0
  138. package/lib/typescript/lib/commonjs/helpers/parsers/OtherIDParser.d.ts.map +1 -0
  139. package/lib/typescript/lib/commonjs/helpers/parsers/PassportParser.d.ts +11 -0
  140. package/lib/typescript/lib/commonjs/helpers/parsers/PassportParser.d.ts.map +1 -0
  141. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  142. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
  143. package/lib/typescript/lib/commonjs/types.d.ts +18 -0
  144. package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
  145. package/lib/typescript/lib/module/AssentifyProvider.d.ts +3 -0
  146. package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -0
  147. package/lib/typescript/lib/module/AssentifyWrapper.d.ts +10 -0
  148. package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -0
  149. package/lib/typescript/lib/module/Language.d.ts +21 -0
  150. package/lib/typescript/lib/module/Language.d.ts.map +1 -0
  151. package/lib/typescript/lib/module/helpers/index.d.ts +1 -0
  152. package/lib/typescript/lib/module/helpers/index.d.ts.map +1 -0
  153. package/lib/typescript/lib/module/helpers/parsers/FaceMatchParser.d.ts +11 -0
  154. package/lib/typescript/lib/module/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
  155. package/lib/typescript/lib/module/helpers/parsers/IDCardParser.d.ts +10 -0
  156. package/lib/typescript/lib/module/helpers/parsers/IDCardParser.d.ts.map +1 -0
  157. package/lib/typescript/lib/module/helpers/parsers/OtherIDParser.d.ts +12 -0
  158. package/lib/typescript/lib/module/helpers/parsers/OtherIDParser.d.ts.map +1 -0
  159. package/lib/typescript/lib/module/helpers/parsers/PassportParser.d.ts +10 -0
  160. package/lib/typescript/lib/module/helpers/parsers/PassportParser.d.ts.map +1 -0
  161. package/lib/typescript/lib/module/index.d.ts +12 -0
  162. package/lib/typescript/lib/module/index.d.ts.map +1 -0
  163. package/lib/typescript/lib/module/types.d.ts +17 -0
  164. package/lib/typescript/lib/module/types.d.ts.map +1 -0
  165. package/lib/typescript/src/AssentifyProvider.d.ts +4 -0
  166. package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -0
  167. package/lib/typescript/src/AssentifyWrapper.d.ts +12 -0
  168. package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -0
  169. package/lib/typescript/src/Language.d.ts +22 -0
  170. package/lib/typescript/src/Language.d.ts.map +1 -0
  171. package/lib/typescript/src/helpers/index.d.ts +1 -0
  172. package/lib/typescript/src/helpers/index.d.ts.map +1 -0
  173. package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts +4 -0
  174. package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
  175. package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts +4 -0
  176. package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts.map +1 -0
  177. package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts +4 -0
  178. package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts.map +1 -0
  179. package/lib/typescript/src/helpers/parsers/PassportParser.d.ts +4 -0
  180. package/lib/typescript/src/helpers/parsers/PassportParser.d.ts.map +1 -0
  181. package/lib/typescript/src/index.d.ts +12 -0
  182. package/lib/typescript/src/index.d.ts.map +1 -0
  183. package/lib/typescript/src/types.d.ts +308 -0
  184. package/lib/typescript/src/types.d.ts.map +1 -0
  185. package/package.json +201 -0
  186. package/src/AssentifyProvider.tsx +189 -0
  187. package/src/AssentifyWrapper.ts +142 -0
  188. package/src/Language.ts +22 -0
  189. package/src/helpers/index.ts +1 -0
  190. package/src/helpers/parsers/FaceMatchParser.ts +28 -0
  191. package/src/helpers/parsers/IDCardParser.ts +27 -0
  192. package/src/helpers/parsers/OtherIDParser.ts +31 -0
  193. package/src/helpers/parsers/PassportParser.ts +27 -0
  194. package/src/index.ts +6 -0
  195. package/src/types.ts +373 -0
@@ -0,0 +1,431 @@
1
+ package com.assentifysdk
2
+
3
+ import android.content.Context
4
+ import android.graphics.Color
5
+ import android.graphics.PorterDuff
6
+ import android.os.Bundle
7
+ import android.view.View
8
+ import android.widget.Button
9
+ import android.widget.ImageView
10
+ import android.widget.LinearLayout
11
+ import android.widget.RelativeLayout
12
+ import android.widget.TextView
13
+ import androidx.appcompat.app.AppCompatActivity
14
+ import com.assentify.sdk.AssentifySdk
15
+ import com.assentify.sdk.AssentifySdkObject
16
+ import com.assentify.sdk.Core.Constants.MotionType
17
+ import com.assentify.sdk.Core.Constants.ZoomType
18
+ import com.assentify.sdk.Models.BaseResponseDataModel
19
+ import com.assentify.sdk.Models.encodeBaseResponseDataModelToJson
20
+ import com.assentify.sdk.RemoteClient.Models.KycDocumentDetails
21
+ import com.assentify.sdk.ScanIDCard.IDCardCallback
22
+ import com.assentify.sdk.ScanIDCard.IDResponseModel
23
+ import com.assentify.sdk.ScanIDCard.IDExtractedModel
24
+ import com.assentify.sdk.ScanIDCard.ScanIDCard
25
+ import com.google.gson.Gson
26
+ import com.google.gson.reflect.TypeToken
27
+ import com.facebook.react.bridge.ReactApplicationContext
28
+ import pl.droidsonroids.gif.GifImageView
29
+ import com.assentify.sdk.RemoteClient.Models.StepDefinitions
30
+ import ImageToBase64Converter
31
+ import android.content.Intent
32
+ import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
33
+ import com.facebook.react.bridge.Arguments
34
+ import com.facebook.react.modules.core.DeviceEventManagerModule
35
+
36
+ class ScanIDActivity: AppCompatActivity(),
37
+ IDCardCallback {
38
+
39
+
40
+ private lateinit var reactApplicationContext: ReactApplicationContext
41
+ private lateinit var assentifySdk: AssentifySdk
42
+ private lateinit var scanID: ScanIDCard
43
+ private lateinit var infoText: TextView
44
+ private lateinit var infoIcon: ImageView
45
+ private lateinit var infoLayout: LinearLayout
46
+ private lateinit var popUpContainer: LinearLayout
47
+ private lateinit var popUpIcon: ImageView
48
+ private lateinit var flippingCard: GifImageView
49
+ private lateinit var popUpText: TextView
50
+ private lateinit var popUpSubText: TextView
51
+ private lateinit var idGif: LinearLayout
52
+ private lateinit var jsonStringKycDocumentDetails: String;
53
+ private lateinit var holdHandColor: String;
54
+ private lateinit var processingColor: String;
55
+ private lateinit var language: String;
56
+ private lateinit var title: String;
57
+ private var isFlippingCard: Boolean = false;
58
+ private lateinit var kycDocumentDetails: List<KycDocumentDetails>;
59
+ private lateinit var popUpButton: Button
60
+ private var start: Boolean = false;
61
+ private var frontModel: IDResponseModel? = null
62
+ private var showCountDown: Boolean = true;
63
+ private var apiKey: String = "";
64
+ val values: MutableMap<String, String> = mutableMapOf()
65
+
66
+ override fun onCreate(savedInstanceState: Bundle?) {
67
+ super.onCreate(savedInstanceState)
68
+ setContentView(R.layout.activity_scan)
69
+ reactApplicationContext = ReactApplicationContextObject.getReactApplicationContextObject()
70
+ val jsonStringKycDocumentDetails = intent.getSerializableExtra("kycDocumentDetails") as String
71
+ val gson = Gson()
72
+ val listType = object : TypeToken<List<KycDocumentDetails>>() {}.type
73
+ kycDocumentDetails = gson.fromJson(jsonStringKycDocumentDetails, listType)
74
+
75
+
76
+ holdHandColor = intent.getStringExtra("holdHandColor")!!
77
+ processingColor = intent.getStringExtra("processingColor")!!
78
+ language = intent.getStringExtra("language")!!
79
+ title = intent.getStringExtra("title")!!
80
+ isFlippingCard = intent.getBooleanExtra("flippingCard",false)!!
81
+ showCountDown = intent.getBooleanExtra("showCountDown",true)
82
+ apiKey = intent.getStringExtra("apiKey")!!
83
+ startAssentifySdk()
84
+
85
+
86
+
87
+ val backButton = findViewById<RelativeLayout>(R.id.backButton)
88
+ val drawable = getResources().getDrawable(R.drawable.rounded_background)
89
+ drawable?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
90
+ backButton.setBackground(drawable)
91
+
92
+ backButton.setOnClickListener {
93
+ runOnUiThread {
94
+ triggerEvent("onBackClick", null)
95
+ scanID.stopScanning();
96
+ finish()
97
+ }
98
+ }
99
+
100
+
101
+ infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
102
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
103
+ drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
104
+ infoLayout.setBackground(drawableInfo)
105
+
106
+
107
+ flippingCard = findViewById<GifImageView>(R.id.flippingCard)
108
+ flippingCard.visibility = View.GONE
109
+
110
+ val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
111
+ toolbarTitle.setText(title)
112
+ toolbarTitle.setTextColor(Color.parseColor(processingColor))
113
+
114
+
115
+ infoText = findViewById(R.id.infoText)
116
+ infoText.setText("Please present ID")
117
+ infoText.setTextColor(Color.parseColor(processingColor))
118
+
119
+ infoIcon = findViewById<ImageView>(R.id.info_icon)
120
+ infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
121
+
122
+
123
+
124
+ popUpContainer = findViewById<LinearLayout>(R.id.popUpContainer)
125
+ val drawablePopUpContainer = getResources().getDrawable(R.drawable.info_rounded_background)
126
+ drawablePopUpContainer?.setColorFilter(
127
+ Color.parseColor(holdHandColor),
128
+ PorterDuff.Mode.SRC_ATOP
129
+ )
130
+ popUpContainer.setBackground(drawablePopUpContainer)
131
+ popUpContainer.visibility = View.GONE
132
+ popUpContainer.setOnClickListener {
133
+ if(!start){
134
+ popUpContainer.visibility = View.GONE
135
+ }
136
+ }
137
+ }
138
+
139
+
140
+
141
+ fun showPopUpMessage(icon: Int, title: String, subTitle: String, isSending: Boolean) {
142
+ popUpContainer.visibility = View.VISIBLE
143
+
144
+ popUpIcon = findViewById<ImageView>(R.id.popUpIcon)
145
+ popUpIcon.setImageDrawable(getResources().getDrawable(icon))
146
+
147
+ idGif = findViewById<LinearLayout>(R.id.idGif)
148
+
149
+ popUpText = findViewById(R.id.popUpText)
150
+ popUpText.setText(title)
151
+ popUpText.setTextColor(Color.parseColor(processingColor))
152
+
153
+ popUpSubText = findViewById(R.id.popUpSubText)
154
+ popUpSubText.setText(subTitle)
155
+ popUpSubText.setTextColor(Color.parseColor(processingColor))
156
+
157
+ val drawablePopUpButton = getResources().getDrawable(R.drawable.button_rounded_background)
158
+ drawablePopUpButton?.setColorFilter(Color.parseColor(processingColor), PorterDuff.Mode.SRC_ATOP)
159
+ popUpButton= findViewById(R.id.popUpButton)
160
+ popUpButton.setBackground(drawablePopUpButton)
161
+ popUpButton.setTextColor(Color.parseColor(holdHandColor))
162
+
163
+ popUpButton.setOnClickListener {
164
+ if(!start){
165
+ popUpContainer.visibility = View.GONE
166
+ }
167
+ }
168
+
169
+ idGif.visibility = View.GONE
170
+ popUpIcon.visibility = View.GONE
171
+ popUpSubText.visibility = View.GONE
172
+ popUpButton.visibility = View.GONE
173
+
174
+
175
+ if (isSending) {
176
+ idGif.visibility = View.VISIBLE
177
+ } else {
178
+ popUpIcon.visibility = View.VISIBLE
179
+ popUpSubText.visibility = View.VISIBLE
180
+ popUpButton.visibility = View.VISIBLE
181
+ }
182
+
183
+
184
+ }
185
+
186
+ fun hidePopUpMessage() {
187
+ start = false;
188
+ popUpContainer.visibility = View.GONE
189
+ }
190
+
191
+ fun startAssentifySdk() {
192
+ assentifySdk = AssentifySdkObject.getAssentifySdkObject();
193
+ scanID = assentifySdk!!.startScanIDCard(
194
+ this@ScanIDActivity,kycDocumentDetails,language
195
+ );
196
+ Thread.sleep(500);
197
+ var fragmentManager = supportFragmentManager
198
+ var transaction = fragmentManager.beginTransaction()
199
+ transaction.replace(R.id.fragmentContainer, scanID)
200
+ transaction.commit()
201
+
202
+ }
203
+
204
+ override fun onError(dataModel: BaseResponseDataModel) {
205
+ triggerEvent("onError", dataModel)
206
+ runOnUiThread {
207
+ start = false;
208
+ showPopUpMessage(R.drawable.warning, "Unable to extract", "Let's try again", false)
209
+ }
210
+ }
211
+
212
+ override fun onSend() {
213
+ triggerEvent("onSend", null)
214
+ runOnUiThread {
215
+ start = true;
216
+ runOnUiThread {
217
+ showPopUpMessage(R.drawable.sending, "Transmitting", "Transmitting", true)
218
+ }
219
+ }
220
+ }
221
+
222
+ override fun onRetry(dataModel: BaseResponseDataModel) {
223
+ triggerEvent("onRetry", dataModel)
224
+ runOnUiThread {
225
+ start = false;
226
+ showPopUpMessage(R.drawable.warning, "Unable to extract", "Let's try again", false)
227
+ }
228
+ }
229
+
230
+
231
+ override fun onLivenessUpdate(dataModel: BaseResponseDataModel) {
232
+ triggerEvent("onLivenessUpdate", dataModel)
233
+ runOnUiThread {
234
+ start = false;
235
+ showPopUpMessage(
236
+ R.drawable.id_warning,
237
+ "Failed ID Check",
238
+ "Please real ID (Not copy)",
239
+ false
240
+ )
241
+ }
242
+ }
243
+
244
+
245
+ override fun onComplete(dataModel: IDResponseModel, order: Int) {
246
+
247
+ triggerCompleteEvent("onComplete",dataModel.iDExtractedModel!!)
248
+
249
+ values.putAll(convertMap(dataModel.iDExtractedModel!!.transformedProperties))
250
+
251
+
252
+ if(kycDocumentDetails.size > 1){
253
+ if(order == kycDocumentDetails.size -1 ){
254
+ scanID.stopScanning();
255
+ /** Data To Submit **/
256
+ val sharedStepDefinitions =
257
+ getSharedPreferences("StepDefinitions", Context.MODE_PRIVATE)
258
+ val gson = Gson()
259
+ val json: String = sharedStepDefinitions.getString("Steps", "")!!
260
+ val steps: List<StepDefinitions>? =
261
+ gson.fromJson(json, object : TypeToken<List<StepDefinitions>>() {}.type)
262
+ steps!!.forEach { item ->
263
+ if (item.stepDefinition == StepsName.DocumentCapture) {
264
+ val documentCaptureModel = SubmitRequestModel(
265
+ item.stepId!!, item.stepDefinition,
266
+ values
267
+ );
268
+ val documentCaptureSharedPreferences =
269
+ getSharedPreferences(
270
+ "DocumentCaptureStepModel",
271
+ Context.MODE_PRIVATE
272
+ )
273
+ val documentCaptureSharedPreferencesEditor =
274
+ documentCaptureSharedPreferences.edit()
275
+ val documentCaptureGson = Gson()
276
+ val documentCaptureStep: String =
277
+ documentCaptureGson.toJson(documentCaptureModel)
278
+ documentCaptureSharedPreferencesEditor.putString(
279
+ "DocumentCaptureStep",
280
+ documentCaptureStep
281
+ );
282
+ documentCaptureSharedPreferencesEditor.apply()
283
+ }
284
+ }
285
+ /** **/
286
+ runOnUiThread {
287
+ finish()
288
+ }
289
+ }else{
290
+ if(order==0){
291
+ frontModel = dataModel;
292
+ start = false;
293
+ }
294
+ hidePopUpMessage()
295
+ if(isFlippingCard){
296
+ flippingCard.visibility = View.VISIBLE
297
+ val backgroundThread = Thread {
298
+ try {
299
+ Thread.sleep(5000)
300
+ runOnUiThread{
301
+ flippingCard.visibility = View.GONE
302
+ }
303
+ } catch (e: InterruptedException) {
304
+ e.printStackTrace()
305
+ }
306
+ }
307
+ backgroundThread.start()
308
+ }
309
+ }
310
+ }else{
311
+ scanID.stopScanning();
312
+ /** Data To Submit **/
313
+ val sharedStepDefinitions =
314
+ getSharedPreferences("StepDefinitions", Context.MODE_PRIVATE)
315
+ val gson = Gson()
316
+ val json: String = sharedStepDefinitions.getString("Steps", "")!!
317
+ val steps: List<StepDefinitions>? =
318
+ gson.fromJson(json, object : TypeToken<List<StepDefinitions>>() {}.type)
319
+ steps!!.forEach { item ->
320
+ if (item.stepDefinition == StepsName.DocumentCapture) {
321
+ val documentCaptureModel = SubmitRequestModel(
322
+ item.stepId!!, item.stepDefinition,
323
+ values
324
+ );
325
+ val documentCaptureSharedPreferences =
326
+ getSharedPreferences(
327
+ "DocumentCaptureStepModel",
328
+ Context.MODE_PRIVATE
329
+ )
330
+ val documentCaptureSharedPreferencesEditor =
331
+ documentCaptureSharedPreferences.edit()
332
+ val documentCaptureGson = Gson()
333
+ val documentCaptureStep: String =
334
+ documentCaptureGson.toJson(documentCaptureModel)
335
+ documentCaptureSharedPreferencesEditor.putString(
336
+ "DocumentCaptureStep",
337
+ documentCaptureStep
338
+ );
339
+ documentCaptureSharedPreferencesEditor.apply()
340
+ }
341
+ }
342
+ /** **/
343
+ runOnUiThread {
344
+ finish()
345
+ }
346
+ }
347
+
348
+
349
+ }
350
+
351
+ override fun onWrongTemplate(dataModel: BaseResponseDataModel) {
352
+ triggerEvent("onWrongTemplate", dataModel);
353
+ runOnUiThread {
354
+ start = false;
355
+ showPopUpMessage(R.drawable.warning, "Wrong Template", "Let's try again", false)
356
+ }
357
+ }
358
+
359
+ override fun onEnvironmentalConditionsChange(
360
+ brightness: Double,
361
+ motion: MotionType,
362
+ zoomType: ZoomType
363
+ ) {
364
+ runOnUiThread {
365
+ if (start == false) {
366
+ infoLayout.visibility = View.VISIBLE
367
+ if (zoomType != ZoomType.SENDING && zoomType != ZoomType.NO_DETECT) {
368
+ if (zoomType == ZoomType.ZOOM_IN) {
369
+ infoText.setText("Move ID Closer")
370
+ infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.zoom_in))
371
+ }
372
+ if (zoomType == ZoomType.ZOOM_OUT) {
373
+ infoText.setText("Move ID Further")
374
+ infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.zoom_out))
375
+ }
376
+ } else if (motion == MotionType.HOLD_YOUR_HAND) {
377
+ infoText.setText("Please Hold Your Hand")
378
+ infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
379
+ } else {
380
+ if (motion == MotionType.SENDING && zoomType == ZoomType.SENDING) {
381
+ infoText.setText("Hold Steady")
382
+ infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
383
+ }
384
+ if (motion == MotionType.NO_DETECT && zoomType == ZoomType.NO_DETECT) {
385
+ infoText.setText("Please present ID")
386
+ infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
387
+ }
388
+
389
+ }
390
+ } else {
391
+ infoLayout.visibility = View.GONE
392
+ }
393
+
394
+
395
+ }
396
+ }
397
+
398
+
399
+ fun convertMap(map: Map<String, Any>?): Map<String, String> {
400
+ return map?.mapValues {
401
+ it.value.toString()
402
+ } ?: emptyMap()
403
+ }
404
+
405
+
406
+ private fun triggerCompleteEvent(eventName:String, dataModel: IDExtractedModel?){
407
+ val eventResultMap = Arguments.createMap().apply {
408
+ if(dataModel!=null){
409
+ val gson = Gson()
410
+ val jsonString = gson.toJson(dataModel!!)
411
+ putString("IdDataModel", jsonString)
412
+ }
413
+ }
414
+ reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
415
+ .emit(eventName, eventResultMap)
416
+
417
+
418
+ }
419
+ private fun triggerEvent(eventName:String, dataModel: BaseResponseDataModel?){
420
+ val eventResultMap = Arguments.createMap().apply {
421
+ if(dataModel!=null){
422
+ putString("IdDataModel", dataModel.response)
423
+ }
424
+ }
425
+ reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
426
+ .emit(eventName, eventResultMap)
427
+
428
+
429
+ }
430
+
431
+ }