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.
- package/LICENSE +3 -0
- package/README.md +65 -0
- package/android/build.gradle +111 -0
- package/android/gradle.properties +9 -0
- package/android/src/main/AndroidManifest.xml +55 -0
- package/android/src/main/java/com/assentifysdk/AndroidProgressBarModule.kt +33 -0
- package/android/src/main/java/com/assentifysdk/AssentifySdkBaseModule.kt +39 -0
- package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +432 -0
- package/android/src/main/java/com/assentifysdk/AssentifySdkPackage.kt +19 -0
- package/android/src/main/java/com/assentifysdk/FaceMatchActivity.kt +309 -0
- package/android/src/main/java/com/assentifysdk/ImageToBase64Converter.kt +40 -0
- package/android/src/main/java/com/assentifysdk/ReactApplicationContextObject.kt +14 -0
- package/android/src/main/java/com/assentifysdk/ScanIDActivity.kt +431 -0
- package/android/src/main/java/com/assentifysdk/ScanOtherActivity.kt +328 -0
- package/android/src/main/java/com/assentifysdk/ScanPassportActivity.kt +364 -0
- package/android/src/main/java/com/assentifysdk/StepsKeys.kt +91 -0
- package/android/src/main/res/drawable/back_icon.png +0 -0
- package/android/src/main/res/drawable/button_rounded_background.xml +6 -0
- package/android/src/main/res/drawable/card.gif +0 -0
- package/android/src/main/res/drawable/expire.png +0 -0
- package/android/src/main/res/drawable/id.gif +0 -0
- package/android/src/main/res/drawable/id_warning.png +0 -0
- package/android/src/main/res/drawable/info_icon.png +0 -0
- package/android/src/main/res/drawable/info_rounded_background.xml +6 -0
- package/android/src/main/res/drawable/passport.gif +0 -0
- package/android/src/main/res/drawable/rounded_background.xml +3 -0
- package/android/src/main/res/drawable/sending.png +0 -0
- package/android/src/main/res/drawable/warning.png +0 -0
- package/android/src/main/res/drawable/zoom_in.png +0 -0
- package/android/src/main/res/drawable/zoom_out.png +0 -0
- package/android/src/main/res/layout/activity_face_scan.xml +242 -0
- package/android/src/main/res/layout/activity_scan.xml +297 -0
- package/android/src/main/res/raw/sending_video.MP4 +0 -0
- package/android/src/main/res/values/colors.xml +8 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/values/styles.xml +4 -0
- package/assentify-sdk.podspec +43 -0
- package/ios/AssentifySdkBaseModule.swift +15 -0
- package/ios/Info.plist +27 -0
- package/ios/NativeAssentifySdk-Bridging-Header.h +3 -0
- package/ios/NativeAssentifySdk.mm +45 -0
- package/ios/NativeAssentifySdk.swift +460 -0
- package/ios/Resources/card.gif +0 -0
- package/ios/Resources/expire.png +0 -0
- package/ios/Resources/id.gif +0 -0
- package/ios/Resources/id_warning.png +0 -0
- package/ios/Resources/info_icon.png +0 -0
- package/ios/Resources/passport.gif +0 -0
- package/ios/Resources/sending.png +0 -0
- package/ios/Resources/warning.png +0 -0
- package/ios/Resources/zoom_in.png +0 -0
- package/ios/Resources/zoom_out.png +0 -0
- package/ios/UIComponents/RNIOSProgressBar.h +4 -0
- package/ios/UIComponents/RNIOSProgressBar.m +34 -0
- package/ios/UIComponents/RNPassportScanner.m +26 -0
- package/ios/UIComponents/RNPassportScanner.swift +245 -0
- package/ios/UIComponents/RNTMapManager.h +4 -0
- package/ios/UIComponents/RNTMapManager.m +19 -0
- package/ios/View/DataDecoder.swift +469 -0
- package/ios/View/FaceMatchController.swift +258 -0
- package/ios/View/IDCardController.swift +360 -0
- package/ios/View/OtherController.swift +283 -0
- package/ios/View/PassportController.swift +302 -0
- package/ios/View/UI.swift +298 -0
- package/lib/commonjs/AssentifyProvider.js +202 -0
- package/lib/commonjs/AssentifyProvider.js.map +1 -0
- package/lib/commonjs/AssentifyWrapper.js +76 -0
- package/lib/commonjs/AssentifyWrapper.js.map +1 -0
- package/lib/commonjs/Language.js +27 -0
- package/lib/commonjs/Language.js.map +1 -0
- package/lib/commonjs/helpers/index.js +2 -0
- package/lib/commonjs/helpers/index.js.map +1 -0
- package/lib/commonjs/helpers/parsers/FaceMatchParser.js +27 -0
- package/lib/commonjs/helpers/parsers/FaceMatchParser.js.map +1 -0
- package/lib/commonjs/helpers/parsers/IDCardParser.js +25 -0
- package/lib/commonjs/helpers/parsers/IDCardParser.js.map +1 -0
- package/lib/commonjs/helpers/parsers/OtherIDParser.js +29 -0
- package/lib/commonjs/helpers/parsers/OtherIDParser.js.map +1 -0
- package/lib/commonjs/helpers/parsers/PassportParser.js +25 -0
- package/lib/commonjs/helpers/parsers/PassportParser.js.map +1 -0
- package/lib/commonjs/index.js +49 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types.js +42 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/AssentifyProvider.js +193 -0
- package/lib/module/AssentifyProvider.js.map +1 -0
- package/lib/module/AssentifyWrapper.js +70 -0
- package/lib/module/AssentifyWrapper.js.map +1 -0
- package/lib/module/Language.js +21 -0
- package/lib/module/Language.js.map +1 -0
- package/lib/module/helpers/index.js +2 -0
- package/lib/module/helpers/index.js.map +1 -0
- package/lib/module/helpers/parsers/FaceMatchParser.js +21 -0
- package/lib/module/helpers/parsers/FaceMatchParser.js.map +1 -0
- package/lib/module/helpers/parsers/IDCardParser.js +19 -0
- package/lib/module/helpers/parsers/IDCardParser.js.map +1 -0
- package/lib/module/helpers/parsers/OtherIDParser.js +23 -0
- package/lib/module/helpers/parsers/OtherIDParser.js.map +1 -0
- package/lib/module/helpers/parsers/PassportParser.js +19 -0
- package/lib/module/helpers/parsers/PassportParser.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +36 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/babel.config.d.ts +3 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/commitlint.config.d.ts +7 -0
- package/lib/typescript/commitlint.config.d.ts.map +1 -0
- package/lib/typescript/example/babel.config.d.ts +8 -0
- package/lib/typescript/example/babel.config.d.ts.map +1 -0
- package/lib/typescript/example/index.d.ts +2 -0
- package/lib/typescript/example/index.d.ts.map +1 -0
- package/lib/typescript/example/jest.config.d.ts +2 -0
- package/lib/typescript/example/jest.config.d.ts.map +1 -0
- package/lib/typescript/example/metro.config.d.ts +3 -0
- package/lib/typescript/example/metro.config.d.ts.map +1 -0
- package/lib/typescript/example/react-native.config.d.ts +6 -0
- package/lib/typescript/example/react-native.config.d.ts.map +1 -0
- package/lib/typescript/example/src/App.d.ts +3 -0
- package/lib/typescript/example/src/App.d.ts.map +1 -0
- package/lib/typescript/example/src/Home.d.ts +4 -0
- package/lib/typescript/example/src/Home.d.ts.map +1 -0
- package/lib/typescript/example/src/navigator.d.ts +4 -0
- package/lib/typescript/example/src/navigator.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts +3 -0
- package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +11 -0
- package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Language.d.ts +22 -0
- package/lib/typescript/lib/commonjs/Language.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/helpers/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/FaceMatchParser.d.ts +12 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/IDCardParser.d.ts +11 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/IDCardParser.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/OtherIDParser.d.ts +13 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/OtherIDParser.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/PassportParser.d.ts +11 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/PassportParser.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/types.d.ts +18 -0
- package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/lib/module/AssentifyProvider.d.ts +3 -0
- package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -0
- package/lib/typescript/lib/module/AssentifyWrapper.d.ts +10 -0
- package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -0
- package/lib/typescript/lib/module/Language.d.ts +21 -0
- package/lib/typescript/lib/module/Language.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/index.d.ts +1 -0
- package/lib/typescript/lib/module/helpers/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/FaceMatchParser.d.ts +11 -0
- package/lib/typescript/lib/module/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/IDCardParser.d.ts +10 -0
- package/lib/typescript/lib/module/helpers/parsers/IDCardParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/OtherIDParser.d.ts +12 -0
- package/lib/typescript/lib/module/helpers/parsers/OtherIDParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/PassportParser.d.ts +10 -0
- package/lib/typescript/lib/module/helpers/parsers/PassportParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +12 -0
- package/lib/typescript/lib/module/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/types.d.ts +17 -0
- package/lib/typescript/lib/module/types.d.ts.map +1 -0
- package/lib/typescript/src/AssentifyProvider.d.ts +4 -0
- package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -0
- package/lib/typescript/src/AssentifyWrapper.d.ts +12 -0
- package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -0
- package/lib/typescript/src/Language.d.ts +22 -0
- package/lib/typescript/src/Language.d.ts.map +1 -0
- package/lib/typescript/src/helpers/index.d.ts +1 -0
- package/lib/typescript/src/helpers/index.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/PassportParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/PassportParser.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +12 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +308 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +201 -0
- package/src/AssentifyProvider.tsx +189 -0
- package/src/AssentifyWrapper.ts +142 -0
- package/src/Language.ts +22 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/parsers/FaceMatchParser.ts +28 -0
- package/src/helpers/parsers/IDCardParser.ts +27 -0
- package/src/helpers/parsers/OtherIDParser.ts +31 -0
- package/src/helpers/parsers/PassportParser.ts +27 -0
- package/src/index.ts +6 -0
- package/src/types.ts +373 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
package com.assentifysdk
|
|
2
|
+
|
|
3
|
+
|
|
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.FaceMatch.FaceMatchCallback
|
|
22
|
+
import com.assentify.sdk.RemoteClient.Models.StepDefinitions
|
|
23
|
+
import com.assentify.sdk.FaceMatch.FaceResponseModel
|
|
24
|
+
import com.assentify.sdk.FaceMatch.FaceMatch
|
|
25
|
+
import com.google.gson.Gson
|
|
26
|
+
import com.google.gson.reflect.TypeToken
|
|
27
|
+
import pl.droidsonroids.gif.GifImageView
|
|
28
|
+
import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
|
|
29
|
+
import android.content.Context
|
|
30
|
+
import android.content.Intent
|
|
31
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
32
|
+
import com.facebook.react.bridge.Arguments
|
|
33
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
34
|
+
import android.util.Log
|
|
35
|
+
|
|
36
|
+
class FaceMatchActivity: AppCompatActivity(),
|
|
37
|
+
FaceMatchCallback {
|
|
38
|
+
|
|
39
|
+
private lateinit var assentifySdk: AssentifySdk
|
|
40
|
+
private lateinit var reactApplicationContext: ReactApplicationContext
|
|
41
|
+
private lateinit var faceMatch: FaceMatch
|
|
42
|
+
private lateinit var infoText: TextView
|
|
43
|
+
private lateinit var infoIcon: ImageView
|
|
44
|
+
private lateinit var infoLayout: LinearLayout
|
|
45
|
+
private lateinit var popUpContainer: LinearLayout
|
|
46
|
+
private lateinit var popUpIcon: ImageView
|
|
47
|
+
private lateinit var popUpText: TextView
|
|
48
|
+
private lateinit var popUpSubText: TextView
|
|
49
|
+
private lateinit var popUpButton: Button
|
|
50
|
+
|
|
51
|
+
private lateinit var holdHandColor: String;
|
|
52
|
+
private lateinit var processingColor: String;
|
|
53
|
+
private var showCountDown: Boolean = true;
|
|
54
|
+
private var start: Boolean = false;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
59
|
+
super.onCreate(savedInstanceState)
|
|
60
|
+
setContentView(R.layout.activity_face_scan)
|
|
61
|
+
|
|
62
|
+
reactApplicationContext = ReactApplicationContextObject.getReactApplicationContextObject()
|
|
63
|
+
showCountDown = intent.getBooleanExtra("showCountDown",true)
|
|
64
|
+
holdHandColor = intent.getStringExtra("holdHandColor")!!
|
|
65
|
+
processingColor = intent.getStringExtra("processingColor")!!
|
|
66
|
+
|
|
67
|
+
startAssentifySdk()
|
|
68
|
+
|
|
69
|
+
val backButton = findViewById<RelativeLayout>(R.id.backButton)
|
|
70
|
+
val drawable = getResources().getDrawable(R.drawable.rounded_background)
|
|
71
|
+
drawable?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
|
|
72
|
+
backButton.setBackground(drawable)
|
|
73
|
+
|
|
74
|
+
backButton.setOnClickListener {
|
|
75
|
+
runOnUiThread {
|
|
76
|
+
triggerEvent("onBackClick", null)
|
|
77
|
+
faceMatch.stopScanning();
|
|
78
|
+
finish()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
|
|
84
|
+
val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
|
|
85
|
+
drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
|
|
86
|
+
infoLayout.setBackground(drawableInfo)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
|
|
90
|
+
toolbarTitle.setText("Face Capture")
|
|
91
|
+
toolbarTitle.setTextColor(Color.parseColor(processingColor))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
infoText = findViewById(R.id.infoText)
|
|
95
|
+
infoText.setText("Please face within circle")
|
|
96
|
+
infoText.setTextColor(Color.parseColor(processingColor))
|
|
97
|
+
|
|
98
|
+
infoIcon = findViewById<ImageView>(R.id.info_icon)
|
|
99
|
+
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
popUpContainer = findViewById<LinearLayout>(R.id.popUpContainer)
|
|
104
|
+
val drawablePopUpContainer = getResources().getDrawable(R.drawable.info_rounded_background)
|
|
105
|
+
drawablePopUpContainer?.setColorFilter(
|
|
106
|
+
Color.parseColor(holdHandColor),
|
|
107
|
+
PorterDuff.Mode.SRC_ATOP
|
|
108
|
+
)
|
|
109
|
+
popUpContainer.setBackground(drawablePopUpContainer)
|
|
110
|
+
popUpContainer.visibility = View.GONE
|
|
111
|
+
popUpContainer.setOnClickListener {
|
|
112
|
+
if (!start) {
|
|
113
|
+
popUpContainer.visibility = View.GONE
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
fun showPopUpMessage(icon: Int, title: String, subTitle: String, isSending: Boolean) {
|
|
121
|
+
popUpContainer.visibility = View.VISIBLE
|
|
122
|
+
|
|
123
|
+
popUpIcon = findViewById<ImageView>(R.id.popUpIcon)
|
|
124
|
+
popUpIcon.setImageDrawable(getResources().getDrawable(icon))
|
|
125
|
+
popUpIcon.visibility = View.VISIBLE
|
|
126
|
+
|
|
127
|
+
popUpText = findViewById(R.id.popUpText)
|
|
128
|
+
popUpText.setText(title)
|
|
129
|
+
popUpText.setTextColor(Color.parseColor(processingColor))
|
|
130
|
+
|
|
131
|
+
popUpSubText = findViewById(R.id.popUpSubText)
|
|
132
|
+
popUpSubText.visibility = View.GONE
|
|
133
|
+
|
|
134
|
+
val drawablePopUpButton = getResources().getDrawable(R.drawable.button_rounded_background)
|
|
135
|
+
drawablePopUpButton?.setColorFilter(Color.parseColor(processingColor), PorterDuff.Mode.SRC_ATOP)
|
|
136
|
+
popUpButton= findViewById(R.id.popUpButton)
|
|
137
|
+
popUpButton.setBackground(drawablePopUpButton)
|
|
138
|
+
popUpButton.setTextColor(Color.parseColor(holdHandColor))
|
|
139
|
+
|
|
140
|
+
popUpButton.setOnClickListener {
|
|
141
|
+
if(!start){
|
|
142
|
+
popUpContainer.visibility = View.GONE
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if(isSending){
|
|
147
|
+
popUpButton.visibility = View.GONE
|
|
148
|
+
}else{
|
|
149
|
+
popUpButton.visibility = View.VISIBLE
|
|
150
|
+
}
|
|
151
|
+
if (subTitle.isNotEmpty()) {
|
|
152
|
+
popUpSubText.setText(subTitle)
|
|
153
|
+
popUpSubText.setTextColor(Color.parseColor(processingColor))
|
|
154
|
+
popUpSubText.visibility = View.VISIBLE
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
fun hidePopUpMessage() {
|
|
161
|
+
popUpContainer.visibility = View.GONE
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
fun startAssentifySdk() {
|
|
165
|
+
val sharedPreferences = reactApplicationContext.getSharedPreferences("FaceMatch", Context.MODE_PRIVATE)
|
|
166
|
+
val base64SecondImage = sharedPreferences.getString("Base64SecondImage", "")
|
|
167
|
+
assentifySdk = AssentifySdkObject.getAssentifySdkObject();
|
|
168
|
+
faceMatch = assentifySdk!!.startFaceMatch(
|
|
169
|
+
this@FaceMatchActivity,
|
|
170
|
+
base64SecondImage!!,
|
|
171
|
+
showCountDown
|
|
172
|
+
);
|
|
173
|
+
Thread.sleep(500);
|
|
174
|
+
var fragmentManager = supportFragmentManager
|
|
175
|
+
var transaction = fragmentManager.beginTransaction()
|
|
176
|
+
transaction.replace(R.id.fragmentContainer, faceMatch)
|
|
177
|
+
transaction.commit()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
override fun onError(dataModel: BaseResponseDataModel) {
|
|
181
|
+
triggerEvent("onError", dataModel)
|
|
182
|
+
runOnUiThread {
|
|
183
|
+
start = false;
|
|
184
|
+
showPopUpMessage(R.drawable.warning, "Unable to Match", "Let's try again", false)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
override fun onSend() {
|
|
189
|
+
triggerEvent("onSend", null)
|
|
190
|
+
runOnUiThread {
|
|
191
|
+
start = true;
|
|
192
|
+
runOnUiThread {
|
|
193
|
+
showPopUpMessage(R.drawable.sending, "Transmitting", "", true)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
override fun onRetry(dataModel: BaseResponseDataModel) {
|
|
199
|
+
triggerEvent("onRetry", dataModel)
|
|
200
|
+
runOnUiThread {
|
|
201
|
+
start = false;
|
|
202
|
+
showPopUpMessage(R.drawable.warning, "Unable to Match", "Let's try again", false)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
override fun onLivenessUpdate(dataModel: BaseResponseDataModel) {
|
|
207
|
+
triggerEvent("onLivenessUpdate", dataModel)
|
|
208
|
+
runOnUiThread {
|
|
209
|
+
start = false;
|
|
210
|
+
showPopUpMessage(R.drawable.warning, "Liveness Failed", "", false)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
override fun onComplete(dataModel: FaceResponseModel) {
|
|
215
|
+
triggerCompleteEvent("onComplete",dataModel)
|
|
216
|
+
val sharedStepDefinitions =
|
|
217
|
+
reactApplicationContext.getSharedPreferences("StepDefinitions", Context.MODE_PRIVATE)
|
|
218
|
+
val gson = Gson()
|
|
219
|
+
val json: String = sharedStepDefinitions.getString("Steps", "")!!
|
|
220
|
+
val steps: List<StepDefinitions>? =
|
|
221
|
+
gson.fromJson(json, object : TypeToken<List<StepDefinitions>>() {}.type)
|
|
222
|
+
steps!!.forEach { item ->
|
|
223
|
+
if (item.stepDefinition == StepsName.FaceMatch) {
|
|
224
|
+
val documentCaptureModel = SubmitRequestModel(
|
|
225
|
+
item.stepId, StepsName.FaceMatch,
|
|
226
|
+
convertMap(dataModel.faceExtractedModel!!.outputProperties)
|
|
227
|
+
);
|
|
228
|
+
val documentCaptureSharedPreferences =
|
|
229
|
+
reactApplicationContext.getSharedPreferences("FaceMatchStepModel", Context.MODE_PRIVATE)
|
|
230
|
+
val documentCaptureSharedPreferencesEditor = documentCaptureSharedPreferences.edit()
|
|
231
|
+
val documentCaptureGson = Gson()
|
|
232
|
+
val documentCaptureStep: String = documentCaptureGson.toJson(documentCaptureModel)
|
|
233
|
+
documentCaptureSharedPreferencesEditor.putString(
|
|
234
|
+
"FaceMatchStep",
|
|
235
|
+
documentCaptureStep
|
|
236
|
+
);
|
|
237
|
+
documentCaptureSharedPreferencesEditor.apply()
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
runOnUiThread{
|
|
242
|
+
start = false
|
|
243
|
+
faceMatch.stopScanning();
|
|
244
|
+
finish()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
override fun onEnvironmentalConditionsChange(
|
|
249
|
+
brightness: Double,
|
|
250
|
+
motion: MotionType,
|
|
251
|
+
) {
|
|
252
|
+
runOnUiThread {
|
|
253
|
+
if (start == false) {
|
|
254
|
+
infoLayout.visibility = View.VISIBLE
|
|
255
|
+
if (motion == MotionType.HOLD_YOUR_HAND) {
|
|
256
|
+
infoText.setText("Please Hold Your Hand")
|
|
257
|
+
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
258
|
+
} else {
|
|
259
|
+
if (motion == MotionType.SENDING) {
|
|
260
|
+
infoText.setText("Hold Steady")
|
|
261
|
+
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
262
|
+
}
|
|
263
|
+
if (motion == MotionType.NO_DETECT) {
|
|
264
|
+
infoText.setText("Please face within circle")
|
|
265
|
+
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
infoLayout.visibility = View.GONE;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
private fun triggerCompleteEvent(eventName:String, dataModel: FaceResponseModel?){
|
|
277
|
+
val eventResultMap = Arguments.createMap().apply {
|
|
278
|
+
if(dataModel!=null){
|
|
279
|
+
val gson = Gson()
|
|
280
|
+
val jsonString = gson.toJson(dataModel.faceExtractedModel!!)
|
|
281
|
+
putString("FaceMatchDataModel", jsonString)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
285
|
+
.emit(eventName, eventResultMap)
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private fun triggerEvent(eventName:String, dataModel: BaseResponseDataModel?){
|
|
291
|
+
val eventResultMap = Arguments.createMap().apply {
|
|
292
|
+
if(dataModel!=null){
|
|
293
|
+
putString("FaceMatchDataModel", dataModel.response)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
297
|
+
.emit(eventName, eventResultMap)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
fun convertMap(map: Map<String, Any>?): Map<String, String> {
|
|
303
|
+
return map?.mapValues {
|
|
304
|
+
it.value.toString()
|
|
305
|
+
} ?: emptyMap()
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import android.graphics.Bitmap
|
|
2
|
+
import android.graphics.BitmapFactory
|
|
3
|
+
import android.os.AsyncTask
|
|
4
|
+
import android.util.Base64
|
|
5
|
+
import java.io.ByteArrayOutputStream
|
|
6
|
+
import java.io.InputStream
|
|
7
|
+
import java.net.HttpURLConnection
|
|
8
|
+
import java.net.URL
|
|
9
|
+
|
|
10
|
+
class ImageToBase64Converter(private val apiKey: String) : AsyncTask<String, Void, String?>() {
|
|
11
|
+
|
|
12
|
+
override fun doInBackground(vararg params: String): String? {
|
|
13
|
+
val imageUrl = params[0]
|
|
14
|
+
return try {
|
|
15
|
+
val url = URL(imageUrl)
|
|
16
|
+
val connection = url.openConnection() as HttpURLConnection
|
|
17
|
+
connection.doInput = true
|
|
18
|
+
|
|
19
|
+
// Add the X-Api-Key header using the apiKey passed as a parameter
|
|
20
|
+
connection.setRequestProperty("X-Api-Key", apiKey)
|
|
21
|
+
|
|
22
|
+
connection.connect()
|
|
23
|
+
val input: InputStream = connection.inputStream
|
|
24
|
+
val bitmap: Bitmap = BitmapFactory.decodeStream(input)
|
|
25
|
+
|
|
26
|
+
val byteArrayOutputStream = ByteArrayOutputStream()
|
|
27
|
+
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream)
|
|
28
|
+
val byteArray: ByteArray = byteArrayOutputStream.toByteArray()
|
|
29
|
+
Base64.encodeToString(byteArray, Base64.DEFAULT)
|
|
30
|
+
|
|
31
|
+
} catch (e: Exception) {
|
|
32
|
+
e.printStackTrace()
|
|
33
|
+
null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun onPostExecute(base64Image: String?) {
|
|
38
|
+
// Handle the base64 image result here if needed
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package com.assentifysdk
|
|
2
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
3
|
+
|
|
4
|
+
object ReactApplicationContextObject {
|
|
5
|
+
private lateinit var reactApplicationContext: ReactApplicationContext
|
|
6
|
+
fun setReactApplicationContextObject(reactApplicationContext: ReactApplicationContext) {
|
|
7
|
+
this.reactApplicationContext = reactApplicationContext;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
fun getReactApplicationContextObject(): ReactApplicationContext {
|
|
11
|
+
return this.reactApplicationContext
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|