assentify-sdk-react-native 0.0.32 → 0.0.34

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 (60) hide show
  1. package/README.md +7 -0
  2. package/android/build.gradle +3 -1
  3. package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +26 -3
  4. package/android/src/main/java/com/assentifysdk/FaceMatchActivity.kt +78 -20
  5. package/android/src/main/java/com/assentifysdk/ScanIDActivity.kt +194 -67
  6. package/android/src/main/java/com/assentifysdk/ScanOtherActivity.kt +80 -19
  7. package/android/src/main/java/com/assentifysdk/ScanPassportActivity.kt +79 -23
  8. package/android/src/main/res/drawable/button_rounded_background.xml +4 -4
  9. package/android/src/main/res/layout/activity_face_scan.xml +234 -219
  10. package/android/src/main/res/layout/activity_scan.xml +116 -0
  11. package/assentify-sdk.podspec +1 -1
  12. package/ios/NativeAssentifySdk.mm +6 -0
  13. package/ios/NativeAssentifySdk.swift +24 -7
  14. package/ios/UIComponents/RNPassportScanner.swift +4 -0
  15. package/ios/View/FaceMatchController.swift +49 -8
  16. package/ios/View/IDCardController.swift +104 -25
  17. package/ios/View/OtherController.swift +49 -11
  18. package/ios/View/PassportController.swift +57 -13
  19. package/ios/View/UI.swift +192 -36
  20. package/lib/commonjs/AssentifyProvider.js +12 -4
  21. package/lib/commonjs/AssentifyProvider.js.map +1 -1
  22. package/lib/commonjs/AssentifyWrapper.js +2 -2
  23. package/lib/commonjs/AssentifyWrapper.js.map +1 -1
  24. package/lib/commonjs/DoneFlags.js +14 -0
  25. package/lib/commonjs/DoneFlags.js.map +1 -0
  26. package/lib/commonjs/index.js +12 -0
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/module/AssentifyProvider.js +12 -4
  29. package/lib/module/AssentifyProvider.js.map +1 -1
  30. package/lib/module/AssentifyWrapper.js +2 -2
  31. package/lib/module/AssentifyWrapper.js.map +1 -1
  32. package/lib/module/DoneFlags.js +8 -0
  33. package/lib/module/DoneFlags.js.map +1 -0
  34. package/lib/module/index.js +1 -0
  35. package/lib/module/index.js.map +1 -1
  36. package/lib/typescript/example/src/Home.d.ts.map +1 -1
  37. package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -1
  38. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +1 -1
  39. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -1
  40. package/lib/typescript/lib/commonjs/DoneFlags.d.ts +9 -0
  41. package/lib/typescript/lib/commonjs/DoneFlags.d.ts.map +1 -0
  42. package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -1
  43. package/lib/typescript/lib/module/AssentifyWrapper.d.ts +1 -1
  44. package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -1
  45. package/lib/typescript/lib/module/DoneFlags.d.ts +8 -0
  46. package/lib/typescript/lib/module/DoneFlags.d.ts.map +1 -0
  47. package/lib/typescript/lib/module/index.d.ts +2 -1
  48. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  49. package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -1
  50. package/lib/typescript/src/AssentifyWrapper.d.ts +1 -1
  51. package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -1
  52. package/lib/typescript/src/DoneFlags.d.ts +9 -0
  53. package/lib/typescript/src/DoneFlags.d.ts.map +1 -0
  54. package/lib/typescript/src/index.d.ts +2 -1
  55. package/lib/typescript/src/index.d.ts.map +1 -1
  56. package/package.json +1 -1
  57. package/src/AssentifyProvider.tsx +11 -4
  58. package/src/AssentifyWrapper.ts +13 -1
  59. package/src/DoneFlags.ts +11 -0
  60. package/src/index.ts +1 -0
@@ -31,10 +31,15 @@ import com.assentify.sdk.RemoteClient.Models.StepDefinitions
31
31
  import com.assentify.sdk.RemoteClient.Models.StepMap
32
32
  import ImageToBase64Converter
33
33
  import android.content.Intent
34
+ import android.content.res.ColorStateList
34
35
  import com.assentify.sdk.Core.Constants.BrightnessEvents
36
+ import com.assentify.sdk.Core.Constants.DoneFlags
35
37
  import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
38
+ import com.assentify.sdk.ScanIDCard.ScanIDCardManual
39
+ import com.assentify.sdk.ScanIDCard.ScanIDCardResult
36
40
  import com.facebook.react.bridge.Arguments
37
41
  import com.facebook.react.modules.core.DeviceEventManagerModule
42
+ import com.squareup.picasso.Picasso
38
43
 
39
44
  class ScanIDActivity: AppCompatActivity(),
40
45
  IDCardCallback {
@@ -43,6 +48,8 @@ class ScanIDActivity: AppCompatActivity(),
43
48
  private lateinit var reactApplicationContext: ReactApplicationContext
44
49
  private lateinit var assentifySdk: AssentifySdk
45
50
  private lateinit var scanID: ScanIDCard
51
+ private lateinit var scanIDManual: ScanIDCardManual
52
+ private var isManual: Boolean = false;
46
53
  private lateinit var infoText: TextView
47
54
  private lateinit var infoIcon: ImageView
48
55
  private lateinit var infoLayout: LinearLayout
@@ -66,6 +73,8 @@ class ScanIDActivity: AppCompatActivity(),
66
73
  private var apiKey: String = "";
67
74
  val values: MutableMap<String, String> = mutableMapOf()
68
75
  private var stepID: Int = -1;
76
+ private lateinit var takePhotoButton: Button;
77
+ private lateinit var manualClickColor: String;
69
78
  override fun onCreate(savedInstanceState: Bundle?) {
70
79
  super.onCreate(savedInstanceState)
71
80
  setContentView(R.layout.activity_scan)
@@ -83,7 +92,28 @@ class ScanIDActivity: AppCompatActivity(),
83
92
  isFlippingCard = intent.getBooleanExtra("flippingCard",false)!!
84
93
  showCountDown = intent.getBooleanExtra("showCountDown",true)
85
94
  apiKey = intent.getStringExtra("apiKey")!!
95
+ manualClickColor = intent.getStringExtra("manualClickColor")!!
86
96
  stepID = intent.getIntExtra("stepID",-1)!!
97
+
98
+ takePhotoButton = findViewById<Button>(R.id.takePhoto)
99
+ takePhotoButton.visibility = View.GONE
100
+ takePhotoButton.setTextColor(Color.parseColor(processingColor))
101
+ takePhotoButton.backgroundTintList = ColorStateList.valueOf(
102
+ Color.parseColor(manualClickColor)
103
+ )
104
+ takePhotoButton.setOnClickListener {
105
+ scanIDManual.takePicture();
106
+ }
107
+
108
+ infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
109
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
110
+ drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
111
+ infoLayout.setBackground(drawableInfo)
112
+
113
+ val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
114
+ toolbarTitle.setText(title)
115
+ toolbarTitle.setTextColor(Color.parseColor(processingColor))
116
+
87
117
  startAssentifySdk()
88
118
 
89
119
 
@@ -96,24 +126,24 @@ class ScanIDActivity: AppCompatActivity(),
96
126
  backButton.setOnClickListener {
97
127
  runOnUiThread {
98
128
  triggerEvent("onBackClick", null)
99
- scanID.stopScanning();
129
+ if(isManual){
130
+ scanIDManual.stopScanning();
131
+ }else{
132
+ scanID.stopScanning();
133
+ }
134
+
100
135
  finish()
101
136
  }
102
137
  }
103
138
 
104
139
 
105
- infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
106
- val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
107
- drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
108
- infoLayout.setBackground(drawableInfo)
140
+
109
141
 
110
142
 
111
143
  flippingCard = findViewById<GifImageView>(R.id.flippingCard)
112
144
  flippingCard.visibility = View.GONE
113
145
 
114
- val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
115
- toolbarTitle.setText(title)
116
- toolbarTitle.setTextColor(Color.parseColor(processingColor))
146
+
117
147
 
118
148
 
119
149
  infoText = findViewById(R.id.infoText)
@@ -138,11 +168,17 @@ class ScanIDActivity: AppCompatActivity(),
138
168
  popUpContainer.visibility = View.GONE
139
169
  }
140
170
  }
171
+
172
+
141
173
  }
142
174
 
143
175
  override fun onBackPressed() {
144
176
  triggerEvent("onBackClick", null)
145
- scanID.stopScanning();
177
+ if(isManual){
178
+ scanIDManual.stopScanning();
179
+ }else{
180
+ scanID.stopScanning();
181
+ }
146
182
  finish()
147
183
  super.onBackPressed()
148
184
  }
@@ -199,14 +235,36 @@ class ScanIDActivity: AppCompatActivity(),
199
235
 
200
236
  fun startAssentifySdk() {
201
237
  assentifySdk = AssentifySdkObject.getAssentifySdkObject();
202
- scanID = assentifySdk!!.startScanIDCard(
238
+
239
+ when (val result = assentifySdk!!.startScanIDCard(
203
240
  this@ScanIDActivity,kycDocumentDetails,language,stepID!!
204
- );
205
- Thread.sleep(500);
206
- var fragmentManager = supportFragmentManager
207
- var transaction = fragmentManager.beginTransaction()
208
- transaction.replace(R.id.fragmentContainer, scanID)
209
- transaction.commit()
241
+ )) {
242
+ is ScanIDCardResult.Manual -> {
243
+ scanIDManual = result.data
244
+ isManual =true
245
+ runOnUiThread{
246
+ infoLayout.visibility = View.GONE
247
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
248
+ drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
249
+ takePhotoButton.setBackground(drawableInfo)
250
+ takePhotoButton.visibility = View.VISIBLE
251
+ }
252
+ Thread.sleep(500);
253
+ var fragmentManager = supportFragmentManager
254
+ var transaction = fragmentManager.beginTransaction()
255
+ transaction.replace(R.id.fragmentContainer, result.data)
256
+ transaction.commit()
257
+ }
258
+ is ScanIDCardResult.Auto -> {
259
+ scanID = result.data
260
+ Thread.sleep(500);
261
+ var fragmentManager = supportFragmentManager
262
+ var transaction = fragmentManager.beginTransaction()
263
+ transaction.replace(R.id.fragmentContainer, result.data)
264
+ transaction.commit()
265
+ }
266
+ }
267
+
210
268
 
211
269
  }
212
270
 
@@ -214,7 +272,7 @@ class ScanIDActivity: AppCompatActivity(),
214
272
  triggerEvent("onError", dataModel)
215
273
  runOnUiThread {
216
274
  start = false;
217
- showPopUpMessage(R.drawable.warning, "Unable to extract", "Let's try again", false)
275
+ showPopUpMessage(R.drawable.warning, "Your internet connection seems unstable. Please check your connection and try again.\n", "Let's try again", false)
218
276
  }
219
277
  }
220
278
 
@@ -232,7 +290,7 @@ class ScanIDActivity: AppCompatActivity(),
232
290
  triggerEvent("onRetry", dataModel)
233
291
  runOnUiThread {
234
292
  start = false;
235
- showPopUpMessage(R.drawable.warning, "Unable to extract", "Let's try again", false)
293
+ showPopUpMessage(R.drawable.warning, "We couldn’t read your card. Try again in better lighting and make sure the card is clear and visible.", "Let's try again", false)
236
294
  }
237
295
  }
238
296
 
@@ -243,7 +301,7 @@ class ScanIDActivity: AppCompatActivity(),
243
301
  start = false;
244
302
  showPopUpMessage(
245
303
  R.drawable.id_warning,
246
- "Failed ID Check",
304
+ "Please use your original physical ID card, not a photo or copy.",
247
305
  "Please real ID (Not copy)",
248
306
  false
249
307
  )
@@ -251,37 +309,46 @@ class ScanIDActivity: AppCompatActivity(),
251
309
  }
252
310
 
253
311
 
254
- override fun onComplete(dataModel: IDResponseModel, order: Int) {
312
+ override fun onComplete(dataModel: IDResponseModel, order: Int,doneFlag:DoneFlags) {
255
313
 
256
- triggerCompleteEvent("onComplete",dataModel.iDExtractedModel!!)
314
+ triggerCompleteEvent("onComplete",dataModel.iDExtractedModel!!,doneFlag)
257
315
 
258
316
  values.putAll(convertMap(dataModel.iDExtractedModel!!.transformedProperties))
259
317
 
260
318
 
261
319
  if(kycDocumentDetails.size > 1){
262
320
  if(order == kycDocumentDetails.size -1 ){
263
- scanID.stopScanning();
321
+ if(isManual){
322
+ scanIDManual.stopScanning();
323
+ }else{
324
+ scanID.stopScanning();
325
+ }
264
326
  /** Data To Submit **/
265
327
 
266
- val documentCaptureSharedPreferences =
267
- reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
328
+ val sharedPreferences = reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
329
+ val gson = Gson()
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)
268
334
 
269
- val stepKey = stepID.toString()
270
- val editor = documentCaptureSharedPreferences.edit()
335
+ // Make a mutable copy of the existing map
336
+ val updatedInfo = existingModel.extractedInformation.toMutableMap()
271
337
 
272
- if (documentCaptureSharedPreferences.contains(stepKey)) {
273
- editor.remove(stepKey)
274
- }
275
-
276
- val documentCaptureModel = SubmitRequestModel(
277
- stepID!!,
278
- StepsName.DocumentCapture,
279
- values
280
- )
338
+ // Merge new values (replace if exists, add if not)
339
+ for ((k, v) in values) {
340
+ updatedInfo[k] = v
341
+ }
281
342
 
282
- val documentCaptureStep = Gson().toJson(documentCaptureModel)
283
- editor.putString(stepKey, documentCaptureStep)
284
- editor.apply()
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()
285
352
 
286
353
 
287
354
 
@@ -296,39 +363,46 @@ class ScanIDActivity: AppCompatActivity(),
296
363
  }
297
364
  hidePopUpMessage()
298
365
  if(isFlippingCard){
299
- flippingCard.visibility = View.VISIBLE
300
- val backgroundThread = Thread {
301
- try {
302
- Thread.sleep(5000)
303
- runOnUiThread{
304
- flippingCard.visibility = View.GONE
305
- }
306
- } catch (e: InterruptedException) {
307
- e.printStackTrace()
308
- }
366
+ showBackIDPage();
367
+ }else{
368
+ if(isManual){
369
+ scanIDManual.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
370
+ }else{
371
+ scanID.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
309
372
  }
310
- backgroundThread.start()
311
373
  }
312
374
  }
313
375
  }else{
314
- scanID.stopScanning();
376
+ if(isManual){
377
+ scanIDManual.stopScanning();
378
+ }else{
379
+ scanID.stopScanning();
380
+ }
315
381
  /** Data To Submit **/
316
- val documentCaptureSharedPreferences = reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
317
- val documentCaptureModel = SubmitRequestModel(
318
- stepID!!,StepsName.DocumentCapture,
319
- values
320
- );
321
- val documentCaptureSharedPreferencesEditor =
322
- documentCaptureSharedPreferences.edit()
323
- val documentCaptureGson = Gson()
324
- val documentCaptureStep: String =
325
- documentCaptureGson.toJson(documentCaptureModel)
326
- documentCaptureSharedPreferencesEditor.putString(
327
- stepID.toString(),
328
- documentCaptureStep
329
- );
330
- documentCaptureSharedPreferencesEditor.apply()
331
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
+ }
396
+
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()
332
406
 
333
407
  /** **/
334
408
  runOnUiThread {
@@ -343,7 +417,7 @@ class ScanIDActivity: AppCompatActivity(),
343
417
  triggerEvent("onWrongTemplate", dataModel);
344
418
  runOnUiThread {
345
419
  start = false;
346
- showPopUpMessage(R.drawable.warning, "Wrong Template", "Let's try again", false)
420
+ showPopUpMessage(R.drawable.warning, "Please double-check that you selected the correct ID type and are presenting this ID type", "Let's try again", false)
347
421
  }
348
422
  }
349
423
 
@@ -400,12 +474,13 @@ class ScanIDActivity: AppCompatActivity(),
400
474
  }
401
475
 
402
476
 
403
- private fun triggerCompleteEvent(eventName:String, dataModel: IDExtractedModel?){
477
+ private fun triggerCompleteEvent(eventName:String, dataModel: IDExtractedModel?,doneFlag:DoneFlags){
404
478
  val eventResultMap = Arguments.createMap().apply {
405
479
  if(dataModel!=null){
406
480
  val gson = Gson()
407
481
  val jsonString = gson.toJson(dataModel!!)
408
482
  putString("IdDataModel", jsonString)
483
+ putString("DoneFlag", doneFlag.toString())
409
484
  }
410
485
  }
411
486
  reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
@@ -444,4 +519,56 @@ class ScanIDActivity: AppCompatActivity(),
444
519
  }
445
520
 
446
521
 
522
+ fun showBackIDPage(){
523
+ runOnUiThread{
524
+
525
+ takePhotoButton.visibility = View.GONE
526
+ val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
527
+ toolbarTitle.setText("Capture Back of ID")
528
+ toolbarTitle.setTextColor(Color.parseColor(processingColor))
529
+
530
+
531
+ val backIDPage = findViewById<LinearLayout>(R.id.backIDPage)
532
+ backIDPage.setBackgroundColor(Color.parseColor(holdHandColor))
533
+ backIDPage.visibility = View.VISIBLE
534
+
535
+
536
+ val nextTemplate = findViewById<Button>(R.id.nextTemplate)
537
+ nextTemplate.setOnClickListener {
538
+ if(isManual){
539
+ scanIDManual.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
540
+ }else{
541
+ scanID.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
542
+ }
543
+ hidrBackIDPage();
544
+ }
545
+
546
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
547
+ drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
548
+ nextTemplate.setBackground(drawableInfo)
549
+
550
+ val ivSample = findViewById<ImageView>(R.id.ivSample)
551
+ Picasso.get()
552
+ .load(kycDocumentDetails.last().templateSpecimen)
553
+ .into(ivSample)
554
+ }
555
+ }
556
+
557
+ fun hidrBackIDPage(){
558
+ runOnUiThread{
559
+ if(isManual){
560
+ takePhotoButton.visibility = View.VISIBLE
561
+ }
562
+ val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
563
+ toolbarTitle.setText(title)
564
+ toolbarTitle.setTextColor(Color.parseColor(processingColor))
565
+
566
+ val backIDPage = findViewById<LinearLayout>(R.id.backIDPage)
567
+ backIDPage.setBackgroundColor(Color.parseColor(holdHandColor))
568
+ backIDPage.visibility = View.GONE
569
+
570
+
571
+ }
572
+ }
573
+
447
574
  }
@@ -12,6 +12,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
12
12
  import com.assentify.sdk.Core.Constants.MotionType
13
13
  import com.assentify.sdk.Core.Constants.ZoomType
14
14
  import ImageToBase64Converter
15
+ import android.content.res.ColorStateList
15
16
  import android.widget.TextView
16
17
  import androidx.appcompat.widget.Toolbar
17
18
  import com.google.gson.Gson
@@ -33,6 +34,9 @@ import android.graphics.PorterDuff
33
34
  import android.widget.LinearLayout
34
35
  import android.widget.RelativeLayout
35
36
  import com.assentify.sdk.Core.Constants.BrightnessEvents
37
+ import com.assentify.sdk.Core.Constants.DoneFlags
38
+ import com.assentify.sdk.ScanOther.ScanOtherManual
39
+ import com.assentify.sdk.ScanOther.ScanOtherResult
36
40
  import java.text.SimpleDateFormat
37
41
 
38
42
 
@@ -42,6 +46,8 @@ class ScanOtherActivity: AppCompatActivity(),
42
46
  private lateinit var reactApplicationContext: ReactApplicationContext
43
47
  private lateinit var assentifySdk: AssentifySdk
44
48
  private lateinit var scanOther: ScanOther
49
+ private lateinit var scanOtherManual: ScanOtherManual
50
+ private var isManual: Boolean = false;
45
51
  private lateinit var infoText: TextView
46
52
  private lateinit var infoIcon: ImageView
47
53
  private lateinit var infoLayout: LinearLayout
@@ -59,6 +65,8 @@ class ScanOtherActivity: AppCompatActivity(),
59
65
  private var showCountDown: Boolean = true;
60
66
  private var apiKey: String = "";
61
67
  private var stepID: Int = -1;
68
+ private lateinit var takePhotoButton: Button;
69
+ private lateinit var manualClickColor: String;
62
70
  override fun onCreate(savedInstanceState: Bundle?) {
63
71
  super.onCreate(savedInstanceState)
64
72
  setContentView(R.layout.activity_scan)
@@ -67,8 +75,25 @@ class ScanOtherActivity: AppCompatActivity(),
67
75
  processingColor = intent.getStringExtra("processingColor")!!
68
76
  language = intent.getStringExtra("language")!!
69
77
  apiKey = intent.getStringExtra("apiKey")!!
78
+ manualClickColor = intent.getStringExtra("manualClickColor")!!
70
79
  showCountDown = intent.getBooleanExtra("showCountDown",true)
71
80
  stepID = intent.getIntExtra("stepID",-1)!!
81
+
82
+ takePhotoButton = findViewById<Button>(R.id.takePhoto)
83
+ takePhotoButton.visibility = View.GONE
84
+ takePhotoButton.setTextColor(Color.parseColor(processingColor))
85
+ takePhotoButton.backgroundTintList = ColorStateList.valueOf(
86
+ Color.parseColor(manualClickColor)
87
+ )
88
+ takePhotoButton.setOnClickListener {
89
+ scanOtherManual.takePicture()
90
+ }
91
+
92
+ infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
93
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
94
+ drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
95
+ infoLayout.setBackground(drawableInfo)
96
+
72
97
  startAssentifySdk()
73
98
 
74
99
 
@@ -81,16 +106,18 @@ class ScanOtherActivity: AppCompatActivity(),
81
106
  backButton.setOnClickListener {
82
107
  runOnUiThread {
83
108
  triggerEvent("onBackClick", null)
84
- scanOther.stopScanning();
109
+ if(isManual){
110
+ scanOtherManual.stopScanning();
111
+
112
+ }else{
113
+ scanOther.stopScanning();
114
+ }
85
115
  finish()
86
116
  }
87
117
  }
88
118
 
89
119
 
90
- infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
91
- val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
92
- drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
93
- infoLayout.setBackground(drawableInfo)
120
+
94
121
 
95
122
 
96
123
  val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
@@ -120,11 +147,18 @@ class ScanOtherActivity: AppCompatActivity(),
120
147
  popUpContainer.visibility = View.GONE
121
148
  }
122
149
  }
150
+
151
+
123
152
  }
124
153
 
125
154
  override fun onBackPressed() {
126
155
  triggerEvent("onBackClick", null)
127
- scanOther.stopScanning();
156
+ if(isManual){
157
+ scanOtherManual.stopScanning();
158
+
159
+ }else{
160
+ scanOther.stopScanning();
161
+ }
128
162
  finish()
129
163
  super.onBackPressed()
130
164
  }
@@ -179,15 +213,36 @@ class ScanOtherActivity: AppCompatActivity(),
179
213
 
180
214
  fun startAssentifySdk() {
181
215
  assentifySdk = AssentifySdkObject.getAssentifySdkObject();
182
- scanOther = assentifySdk!!.startScanOther(
216
+
217
+ when (val result = assentifySdk!!.startScanOther(
183
218
  this@ScanOtherActivity,
184
219
  language,stepID!!
185
- );
186
- Thread.sleep(500);
187
- var fragmentManager = supportFragmentManager
188
- var transaction = fragmentManager.beginTransaction()
189
- transaction.replace(R.id.fragmentContainer, scanOther)
190
- transaction.commit()
220
+ )) {
221
+ is ScanOtherResult.Manual -> {
222
+ isManual =true
223
+ runOnUiThread{
224
+ infoLayout.visibility = View.GONE
225
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
226
+ drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
227
+ takePhotoButton.setBackground(drawableInfo)
228
+ takePhotoButton.visibility = View.VISIBLE
229
+ }
230
+ scanOtherManual = result.data
231
+ Thread.sleep(500);
232
+ var fragmentManager = supportFragmentManager
233
+ var transaction = fragmentManager.beginTransaction()
234
+ transaction.replace(R.id.fragmentContainer, result.data)
235
+ transaction.commit()
236
+ }
237
+ is ScanOtherResult.Auto -> {
238
+ scanOther = result.data
239
+ Thread.sleep(500);
240
+ var fragmentManager = supportFragmentManager
241
+ var transaction = fragmentManager.beginTransaction()
242
+ transaction.replace(R.id.fragmentContainer, result.data)
243
+ transaction.commit()
244
+ }
245
+ }
191
246
 
192
247
  }
193
248
 
@@ -195,7 +250,7 @@ class ScanOtherActivity: AppCompatActivity(),
195
250
  triggerEvent("onError", dataModel)
196
251
  runOnUiThread {
197
252
  start = false;
198
- showPopUpMessage(R.drawable.warning, "Unable to extract", "Let's try again", false)
253
+ showPopUpMessage(R.drawable.warning, "Your internet connection seems unstable. Please check your connection and try again.\n", "Let's try again", false)
199
254
  }
200
255
  }
201
256
 
@@ -213,14 +268,14 @@ class ScanOtherActivity: AppCompatActivity(),
213
268
  triggerEvent("onRetry", dataModel)
214
269
  runOnUiThread {
215
270
  start = false;
216
- showPopUpMessage(R.drawable.warning, "Unable to extract", "Let's try again", false)
271
+ showPopUpMessage(R.drawable.warning, "We couldn’t read your card. Try again in better lighting and make sure the card is clear and visible.", "Let's try again", false)
217
272
  }
218
273
  }
219
274
 
220
275
 
221
276
 
222
- override fun onComplete(dataModel: OtherResponseModel) {
223
- triggerCompleteEvent("onComplete",dataModel)
277
+ override fun onComplete(dataModel: OtherResponseModel,doneFlag: DoneFlags) {
278
+ triggerCompleteEvent("onComplete",dataModel,doneFlag)
224
279
  /** Steps **/
225
280
 
226
281
  /** Data To Submit **/
@@ -248,7 +303,12 @@ class ScanOtherActivity: AppCompatActivity(),
248
303
 
249
304
  /** End **/
250
305
  runOnUiThread {
251
- scanOther.stopScanning();
306
+ if(isManual){
307
+ scanOtherManual.stopScanning();
308
+
309
+ }else{
310
+ scanOther.stopScanning();
311
+ }
252
312
  finish()
253
313
  }
254
314
 
@@ -319,12 +379,13 @@ class ScanOtherActivity: AppCompatActivity(),
319
379
  } ?: emptyMap()
320
380
  }
321
381
 
322
- private fun triggerCompleteEvent(eventName:String, dataModel: OtherResponseModel?){
382
+ private fun triggerCompleteEvent(eventName:String, dataModel: OtherResponseModel?,doneFlag: DoneFlags){
323
383
  val eventResultMap = Arguments.createMap().apply {
324
384
  if(dataModel!=null){
325
385
  val gson = Gson()
326
386
  val jsonString = gson.toJson(dataModel.otherExtractedModel!!)
327
387
  putString("OtherDataModel", jsonString)
388
+ putString("DoneFlag", doneFlag.toString())
328
389
  }
329
390
  }
330
391
  reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)