@certiface/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +966 -0
- package/RnSdk.podspec +27 -0
- package/android/build.gradle +86 -0
- package/android/gradle.properties +6 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/RnSdkModule.kt +128 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/RnSdkPackage.kt +33 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/executor/LivenessExevutor.kt +66 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/factories/FacetecThemeFactory.kt +233 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/factories/IProovThemeFactory.kt +176 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/managers/AssetManager.kt +152 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/model/Featues.kt +6 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/processors/AssetProcessor.kt +179 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/strategy/FacetecStrategy.kt +25 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/strategy/IProovStrategy.kt +25 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/strategy/LivenessProviderStrategy.kt +16 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/theme/FacetecFonts.kt +85 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/theme/IProovFonts.kt +52 -0
- package/android/src/main/java/br/com/oititec/rn/sdk/utils/AssetProcessor.kt +181 -0
- package/android/src/main/res/drawable/backhand_left.xml +20 -0
- package/android/src/main/res/drawable/backhand_right.xml +20 -0
- package/android/src/main/res/drawable/camera_icon.xml +14 -0
- package/android/src/main/res/drawable/close_icon.xml +11 -0
- package/android/src/main/res/drawable/error_icon.xml +11 -0
- package/android/src/main/res/drawable/neutral_face.xml +11 -0
- package/android/src/main/res/drawable/success_icon.xml +11 -0
- package/android/src/main/res/font/sixty.ttf +0 -0
- package/ios/Extensions/RnSDK+Callbacks.swift +62 -0
- package/ios/Extensions/UIColor+Hex.swift +39 -0
- package/ios/Resources/Media.xcassets/Contents.json +6 -0
- package/ios/Resources/Media.xcassets/shell.imageset/Contents.json +12 -0
- package/ios/Resources/Media.xcassets/shell.imageset/shell.png +0 -0
- package/ios/Resources/Media.xcassets/test.imageset/Contents.json +12 -0
- package/ios/Resources/Media.xcassets/test.imageset/arrow_forward_ios.png +0 -0
- package/ios/RnSdk.h +5 -0
- package/ios/RnSdk.mm +71 -0
- package/ios/RnSdkImpl.swift +91 -0
- package/ios/Utils/RnSdkBundle.swift +27 -0
- package/ios/Utils/ThemeFactory.swift +424 -0
- package/lib/module/@types/result.js +2 -0
- package/lib/module/@types/result.js.map +1 -0
- package/lib/module/@types/theme.js +41 -0
- package/lib/module/@types/theme.js.map +1 -0
- package/lib/module/NativeRnSdk.js +5 -0
- package/lib/module/NativeRnSdk.js.map +1 -0
- package/lib/module/index.js +33 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/utils/AssetProcessor.js +78 -0
- package/lib/module/utils/AssetProcessor.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/@types/result.d.ts +17 -0
- package/lib/typescript/src/@types/result.d.ts.map +1 -0
- package/lib/typescript/src/@types/theme.d.ts +306 -0
- package/lib/typescript/src/@types/theme.d.ts.map +1 -0
- package/lib/typescript/src/NativeRnSdk.d.ts +9 -0
- package/lib/typescript/src/NativeRnSdk.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +14 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/AssetProcessor.d.ts +8 -0
- package/lib/typescript/src/utils/AssetProcessor.d.ts.map +1 -0
- package/package.json +165 -0
- package/src/@types/result.ts +19 -0
- package/src/@types/theme.ts +346 -0
- package/src/NativeRnSdk.ts +18 -0
- package/src/index.tsx +54 -0
- package/src/utils/AssetProcessor.ts +114 -0
package/RnSdk.podspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "RnSdk"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/oititec/certiface-sdk-rn.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
17
|
+
s.resource_bundles = {
|
|
18
|
+
'RnSdkBundle' => ['ios/Resources/**/*.xcassets']
|
|
19
|
+
}
|
|
20
|
+
s.private_header_files = "ios/**/*.h"
|
|
21
|
+
|
|
22
|
+
s.frameworks = "AVFoundation"
|
|
23
|
+
|
|
24
|
+
s.dependency 'CertifaceSDK', '1.2.0'
|
|
25
|
+
|
|
26
|
+
install_modules_dependencies(s)
|
|
27
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RnSdk_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.9.1"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
|
|
24
|
+
def getExtOrIntegerDefault(name) {
|
|
25
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RnSdk_" + name]).toInteger()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
android {
|
|
29
|
+
namespace "br.com.oititec.rn.sdk"
|
|
30
|
+
|
|
31
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
32
|
+
|
|
33
|
+
defaultConfig {
|
|
34
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
35
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
buildFeatures {
|
|
39
|
+
buildConfig true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
buildTypes {
|
|
43
|
+
release {
|
|
44
|
+
minifyEnabled false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
lintOptions {
|
|
49
|
+
disable "GradleCompatible"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
compileOptions {
|
|
53
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
54
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
sourceSets {
|
|
58
|
+
main {
|
|
59
|
+
java.srcDirs += [
|
|
60
|
+
"generated/java",
|
|
61
|
+
"generated/jni"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
repositories {
|
|
68
|
+
mavenLocal()
|
|
69
|
+
mavenCentral()
|
|
70
|
+
google()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
74
|
+
|
|
75
|
+
dependencies {
|
|
76
|
+
implementation "com.facebook.react:react-android"
|
|
77
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
78
|
+
|
|
79
|
+
implementation 'br.com.oiti:oitisdk:1.1.0'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
react {
|
|
83
|
+
jsRootDir = file("../src/")
|
|
84
|
+
libraryName = "RnSdk"
|
|
85
|
+
codegenJavaPackageName = "br.com.oititec.rn.sdk"
|
|
86
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
package br.com.oititec.rn.sdk
|
|
2
|
+
|
|
3
|
+
import android.Manifest
|
|
4
|
+
import android.content.pm.PackageManager
|
|
5
|
+
import androidx.core.app.ActivityCompat
|
|
6
|
+
import androidx.core.content.ContextCompat
|
|
7
|
+
import com.facebook.react.bridge.Callback
|
|
8
|
+
import com.facebook.react.bridge.Promise
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
|
+
import com.facebook.react.bridge.ReadableMap
|
|
11
|
+
import com.facebook.react.bridge.WritableMap
|
|
12
|
+
import com.facebook.react.bridge.Arguments
|
|
13
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
14
|
+
import br.com.oititec.rn.sdk.executor.LivenessExecutor
|
|
15
|
+
import br.com.oititec.rn.sdk.model.Features
|
|
16
|
+
import org.json.JSONObject
|
|
17
|
+
|
|
18
|
+
@ReactModule(name = RnSdkModule.NAME)
|
|
19
|
+
class RnSdkModule(reactContext: ReactApplicationContext) :
|
|
20
|
+
NativeRnSdkSpec(reactContext) {
|
|
21
|
+
|
|
22
|
+
override fun getName(): String {
|
|
23
|
+
return NAME
|
|
24
|
+
}
|
|
25
|
+
override fun checkCameraPermission(promise: Promise?) {
|
|
26
|
+
val permission = ContextCompat.checkSelfPermission(reactApplicationContext, Manifest.permission.CAMERA)
|
|
27
|
+
promise?.resolve(permission == PackageManager.PERMISSION_GRANTED)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun requestCameraPermission(promise: Promise) {
|
|
31
|
+
val currentActivity = currentActivity
|
|
32
|
+
if (currentActivity == null) {
|
|
33
|
+
promise.reject("ERROR", "Activity is null")
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
val permission = ContextCompat.checkSelfPermission(currentActivity, Manifest.permission.CAMERA)
|
|
38
|
+
if (permission == PackageManager.PERMISSION_GRANTED) {
|
|
39
|
+
promise.resolve(true)
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ActivityCompat.requestPermissions(currentActivity, arrayOf(Manifest.permission.CAMERA), CAMERA_PERMISSION_REQUEST_CODE)
|
|
44
|
+
promise.resolve(false)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override fun startJourney(
|
|
48
|
+
appKey: String?,
|
|
49
|
+
environment: String?,
|
|
50
|
+
provider: String?,
|
|
51
|
+
onSuccess: Callback?,
|
|
52
|
+
onError: Callback?,
|
|
53
|
+
isCustomEnabled: Boolean?,
|
|
54
|
+
theme: ReadableMap?
|
|
55
|
+
) {
|
|
56
|
+
val customEnabled = isCustomEnabled ?: false
|
|
57
|
+
|
|
58
|
+
if (appKey.isNullOrEmpty()) {
|
|
59
|
+
onError?.invoke("APP_KEY_NULO")
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (environment.isNullOrEmpty()) {
|
|
64
|
+
onError?.invoke("ENVIRONMENT_NULO")
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (provider.isNullOrEmpty()) {
|
|
69
|
+
onError?.invoke("PROVIDER_NULO")
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
val selectedFeature = when (provider) {
|
|
74
|
+
"FACETEC" -> Features.Facetec
|
|
75
|
+
"IPROOV" -> Features.IProov
|
|
76
|
+
else -> {
|
|
77
|
+
onError?.invoke("PROVIDER_INVALIDO: $provider")
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
val activity = reactApplicationContext ?: run {
|
|
83
|
+
onError?.invoke("NO_ACTIVITY")
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
LivenessExecutor(appKey, selectedFeature).executeLiveness(
|
|
88
|
+
context = activity,
|
|
89
|
+
environment = environment,
|
|
90
|
+
execOnSuccess = { livenessResult ->
|
|
91
|
+
val jsonResult = convertLivenessResultToJson(livenessResult)
|
|
92
|
+
onSuccess?.invoke(jsonResult)
|
|
93
|
+
},
|
|
94
|
+
execOnError = { error ->
|
|
95
|
+
onError?.invoke(error)
|
|
96
|
+
},
|
|
97
|
+
isCustomEnabled = customEnabled,
|
|
98
|
+
theme = theme
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private fun convertLivenessResultToJson(livenessResult: br.com.oiti.manager.exports.LivenessResult?): String {
|
|
103
|
+
return try {
|
|
104
|
+
val jsonObject = JSONObject()
|
|
105
|
+
jsonObject.put("status", "success")
|
|
106
|
+
|
|
107
|
+
val resultObject = JSONObject()
|
|
108
|
+
resultObject.put("valid", livenessResult?.valid ?: false)
|
|
109
|
+
resultObject.put("codID", livenessResult?.codID ?: "")
|
|
110
|
+
resultObject.put("cause", livenessResult?.cause ?: "")
|
|
111
|
+
resultObject.put("protocol", livenessResult?.protocol ?: "")
|
|
112
|
+
resultObject.put("scanResultBlob", livenessResult?.scanResultBlob ?: "")
|
|
113
|
+
|
|
114
|
+
jsonObject.put("result", resultObject)
|
|
115
|
+
jsonObject.toString()
|
|
116
|
+
} catch (e: Exception) {
|
|
117
|
+
val errorObject = JSONObject()
|
|
118
|
+
errorObject.put("status", "error")
|
|
119
|
+
errorObject.put("message", "Failed to serialize result: ${e.message}")
|
|
120
|
+
errorObject.toString()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
companion object {
|
|
125
|
+
const val NAME = "RnSdk"
|
|
126
|
+
const val CAMERA_PERMISSION_REQUEST_CODE = 100
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package br.com.oititec.rn.sdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class RnSdkPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == RnSdkModule.NAME) {
|
|
13
|
+
RnSdkModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[RnSdkModule.NAME] = ReactModuleInfo(
|
|
23
|
+
RnSdkModule.NAME,
|
|
24
|
+
RnSdkModule.NAME,
|
|
25
|
+
false,
|
|
26
|
+
false,
|
|
27
|
+
false,
|
|
28
|
+
true
|
|
29
|
+
)
|
|
30
|
+
moduleInfos
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package br.com.oititec.rn.sdk.executor
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import br.com.oiti.domain.liveness.LivenessResponse
|
|
5
|
+
import br.com.oiti.domain.model.ErrorResponse
|
|
6
|
+
import br.com.oiti.manager.exports.Environment
|
|
7
|
+
import br.com.oiti.manager.exports.LivenessResult
|
|
8
|
+
import br.com.oiti.manager.exports.ResultCallback
|
|
9
|
+
import br.com.oiti.manager.exports.SDKConfig
|
|
10
|
+
import br.com.oiti.manager.main.CertifaceSDK
|
|
11
|
+
import br.com.oititec.rn.sdk.model.Features
|
|
12
|
+
import br.com.oititec.rn.sdk.strategy.FacetecStrategy
|
|
13
|
+
import br.com.oititec.rn.sdk.strategy.IProovStrategy
|
|
14
|
+
import br.com.oititec.rn.sdk.strategy.LivenessProviderStrategy
|
|
15
|
+
import com.facebook.react.bridge.ReadableMap
|
|
16
|
+
|
|
17
|
+
class LivenessExecutor(val appkey: String, val feature: Features) {
|
|
18
|
+
|
|
19
|
+
private val strategies: Map<Features, LivenessProviderStrategy> = mapOf(
|
|
20
|
+
Features.Facetec to FacetecStrategy(),
|
|
21
|
+
Features.IProov to IProovStrategy()
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
fun executeLiveness(
|
|
25
|
+
context: Context,
|
|
26
|
+
environment: String,
|
|
27
|
+
execOnSuccess: (LivenessResult?) -> Unit,
|
|
28
|
+
execOnError: (String?) -> Unit,
|
|
29
|
+
isCustomEnabled: Boolean = false,
|
|
30
|
+
theme: ReadableMap? = null
|
|
31
|
+
) {
|
|
32
|
+
val sdkEnvironment = when (environment) {
|
|
33
|
+
"HML" -> Environment.HML
|
|
34
|
+
"PRD" -> Environment.PRD
|
|
35
|
+
else -> Environment.HML
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
CertifaceSDK.initialize(
|
|
39
|
+
context,
|
|
40
|
+
SDKConfig(
|
|
41
|
+
environment = sdkEnvironment,
|
|
42
|
+
appKey = appkey
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
val strategy = strategies[feature]
|
|
47
|
+
?: error("Nenhuma strategy pra feature $feature")
|
|
48
|
+
|
|
49
|
+
val callback = object : ResultCallback<LivenessResult> {
|
|
50
|
+
override fun onSuccess(result: LivenessResponse) {
|
|
51
|
+
execOnSuccess(result.livenessResult)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override fun onError(result: LivenessResponse) {
|
|
55
|
+
val errorResponse = result.errorResponse
|
|
56
|
+
val errorMessage = if (errorResponse != null) {
|
|
57
|
+
"[${errorResponse.errorType}]: ${errorResponse.errorMessage}"
|
|
58
|
+
} else {
|
|
59
|
+
"Unknown error occurred"
|
|
60
|
+
}
|
|
61
|
+
execOnError(errorMessage)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
strategy.start(context, appkey, isCustomEnabled, theme, callback)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
package br.com.oititec.rn.sdk.factories
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import br.com.oiti.designsystem.R
|
|
5
|
+
import br.com.oiti.domain.model.facetec.FacetecButtonLocation
|
|
6
|
+
import br.com.oiti.domain.model.facetec.FacetecExitAnimationStyle
|
|
7
|
+
import br.com.oiti.domain.model.facetec.FacetecTheme
|
|
8
|
+
import android.util.Log
|
|
9
|
+
import br.com.oiti.manager.exports.FacetecFontsKey
|
|
10
|
+
import br.com.oiti.manager.exports.FacetecTextKey
|
|
11
|
+
import br.com.oititec.rn.sdk.theme.FacetecFonts
|
|
12
|
+
import br.com.oititec.rn.sdk.processors.AssetProcessor
|
|
13
|
+
import com.facebook.react.bridge.ReadableMap
|
|
14
|
+
|
|
15
|
+
object FacetecThemeFactory {
|
|
16
|
+
private const val TAG = "FacetecThemeFactory"
|
|
17
|
+
|
|
18
|
+
fun buildDefault(): FacetecTheme = FacetecTheme.build {}
|
|
19
|
+
|
|
20
|
+
fun buildCustom(theme: ReadableMap? = null, context: Context? = null): FacetecTheme = FacetecTheme.build {
|
|
21
|
+
val instructionsTheme = theme?.getMap("instructions")
|
|
22
|
+
val instructionsColors = instructionsTheme?.getMap("colors")
|
|
23
|
+
val instructionsTexts = instructionsTheme?.getMap("texts")
|
|
24
|
+
val instructionsFonts = instructionsTheme?.getMap("fonts")
|
|
25
|
+
val instructionsConfiguration = instructionsTheme?.getMap("configuration")
|
|
26
|
+
val showInstructionScreen = instructionsConfiguration?.getBoolean("showInstructionScreen") ?: true
|
|
27
|
+
|
|
28
|
+
val permissionTheme = theme?.getMap("permission")
|
|
29
|
+
val permissionColors = permissionTheme?.getMap("colors")
|
|
30
|
+
val permissionTexts = permissionTheme?.getMap("texts")
|
|
31
|
+
val permissionFonts = permissionTheme?.getMap("fonts")
|
|
32
|
+
|
|
33
|
+
val facetecTheme = theme?.getMap("facetec")
|
|
34
|
+
val facetecColors = facetecTheme?.getMap("colors")
|
|
35
|
+
val facetecTexts = facetecTheme?.getMap("texts")
|
|
36
|
+
val facetecFontsMap = facetecTheme?.getMap("fonts")
|
|
37
|
+
|
|
38
|
+
val facetecFonts = if (facetecFontsMap != null) {
|
|
39
|
+
FacetecFonts(instructionsFonts, permissionFonts, facetecFontsMap).apply()
|
|
40
|
+
} else {
|
|
41
|
+
hashMapOf(
|
|
42
|
+
FacetecFontsKey.INSTRUCTIONS_TITLE_FONT to R.font.ubuntu_regular,
|
|
43
|
+
FacetecFontsKey.INSTRUCTIONS_CAPTION_FONT to R.font.ubuntu_regular,
|
|
44
|
+
FacetecFontsKey.INSTRUCTIONS_DOCUMENT_TYPES_INSTRUCTIONS_FONT to R.font.ubuntu_regular,
|
|
45
|
+
FacetecFontsKey.INSTRUCTIONS_DOCUMENT_TIPS_INSTRUCTIONS_FONT to R.font.ubuntu_regular,
|
|
46
|
+
FacetecFontsKey.INSTRUCTIONS_BUTTON_FONT to R.font.ubuntu_regular,
|
|
47
|
+
FacetecFontsKey.PERMISSION_TITLE_FONT to R.font.ubuntu_regular,
|
|
48
|
+
FacetecFontsKey.PERMISSION_CAPTION_FONT to R.font.ubuntu_regular,
|
|
49
|
+
FacetecFontsKey.PERMISSION_BUTTON_FONT to R.font.ubuntu_regular,
|
|
50
|
+
FacetecFontsKey.GUIDANCE_CUSTOMIZATION_HEADER_FONT to R.font.ubuntu_regular,
|
|
51
|
+
FacetecFontsKey.GUIDANCE_CUSTOMIZATION_SUBTEXT_FONT to R.font.ubuntu_regular,
|
|
52
|
+
FacetecFontsKey.GUIDANCE_CUSTOMIZATION_BUTTON_FONT to R.font.ubuntu_regular,
|
|
53
|
+
FacetecFontsKey.GUIDANCE_CUSTOMIZATION_READY_SCREEN_HEADER_FONT to R.font.ubuntu_regular,
|
|
54
|
+
FacetecFontsKey.GUIDANCE_CUSTOMIZATION_READY_SCREEN_SUBTEXT_FONT to R.font.ubuntu_regular,
|
|
55
|
+
FacetecFontsKey.GUIDANCE_CUSTOMIZATION_RETRY_SCREEN_HEADER_FONT to R.font.ubuntu_regular,
|
|
56
|
+
FacetecFontsKey.GUIDANCE_CUSTOMIZATION_RETRY_SCREEN_SUBTEXT_FONT to R.font.ubuntu_regular,
|
|
57
|
+
FacetecFontsKey.RESULT_SCREEN_CUSTOMIZATION_MESSAGE_FONT to R.font.ubuntu_regular,
|
|
58
|
+
FacetecFontsKey.FEEDBACK_CUSTOMIZATION_TEXT_FONT to R.font.ubuntu_regular
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Log.d(TAG, "🏭 Iniciando construção do tema Facetec customizado...")
|
|
63
|
+
val facetecDrawables = AssetProcessor.processFacetecAssets(theme)
|
|
64
|
+
Log.d(TAG, "📦 Assets processados: ${facetecDrawables.size} encontrados")
|
|
65
|
+
|
|
66
|
+
Log.d(TAG, "🎨 Assets encontrados para processamento: ${facetecDrawables.size}")
|
|
67
|
+
facetecDrawables.forEach { (key, value) ->
|
|
68
|
+
Log.d(TAG, " 📎 $key = '$value'")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (facetecDrawables.isNotEmpty()) {
|
|
72
|
+
Log.d(TAG, "🎨 Configurando drawables customizados: ${facetecDrawables.size} assets")
|
|
73
|
+
setFacetecDrawablesMap(facetecDrawables)
|
|
74
|
+
} else {
|
|
75
|
+
Log.d(TAG, "📋 Nenhum drawable customizado encontrado, usando padrões")
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
val customFacetecTexts = hashMapOf<FacetecTextKey, String>()
|
|
79
|
+
|
|
80
|
+
facetecTexts?.getString("readyHeader1")?.let { customFacetecTexts[FacetecTextKey.READY_HEADER_1] = it }
|
|
81
|
+
facetecTexts?.getString("readyHeader2")?.let { customFacetecTexts[FacetecTextKey.READY_HEADER_2] = it }
|
|
82
|
+
facetecTexts?.getString("readyMessage1")?.let { customFacetecTexts[FacetecTextKey.READY_MESSAGE_1] = it }
|
|
83
|
+
facetecTexts?.getString("readyMessage2")?.let { customFacetecTexts[FacetecTextKey.READY_MESSAGE_2] = it }
|
|
84
|
+
facetecTexts?.getString("readyButton")?.let { customFacetecTexts[FacetecTextKey.READY_BUTTON] = it }
|
|
85
|
+
|
|
86
|
+
facetecTexts?.getString("retryHeader")?.let { customFacetecTexts[FacetecTextKey.RETRY_HEADER] = it }
|
|
87
|
+
facetecTexts?.getString("retrySubheader")?.let { customFacetecTexts[FacetecTextKey.RETRY_SUBHEADER] = it }
|
|
88
|
+
facetecTexts?.getString("retryMessageSmile")?.let { customFacetecTexts[FacetecTextKey.RETRY_MESSAGE_SMILE] = it }
|
|
89
|
+
facetecTexts?.getString("retryMessageLighting")?.let { customFacetecTexts[FacetecTextKey.RETRY_MESSAGE_LIGHTING] = it }
|
|
90
|
+
facetecTexts?.getString("retryMessageContrast")?.let { customFacetecTexts[FacetecTextKey.RETRY_MESSAGE_CONTRAST] = it }
|
|
91
|
+
facetecTexts?.getString("retryYourPicture")?.let { customFacetecTexts[FacetecTextKey.RETRY_YOUR_PICTURE] = it }
|
|
92
|
+
facetecTexts?.getString("retryIdealPicture")?.let { customFacetecTexts[FacetecTextKey.RETRY_IDEAL_PICTURE] = it }
|
|
93
|
+
facetecTexts?.getString("retryButton")?.let { customFacetecTexts[FacetecTextKey.RETRY_BUTTON] = it }
|
|
94
|
+
|
|
95
|
+
facetecTexts?.getString("resultUploadMessage")?.let { customFacetecTexts[FacetecTextKey.RESULT_UPLOAD_MESSAGE] = it }
|
|
96
|
+
facetecTexts?.getString("resultSuccessMessage")?.let { customFacetecTexts[FacetecTextKey.RESULT_SUCCESS_MESSAGE] = it }
|
|
97
|
+
|
|
98
|
+
facetecTexts?.getString("feedbackLookStraightInOval")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_LOOK_STRAIGHT_IN_OVAL] = it }
|
|
99
|
+
facetecTexts?.getString("feedbackCenterFace")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_CENTER_FACE] = it }
|
|
100
|
+
facetecTexts?.getString("feedbackFaceNotFound")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_FACE_NOT_FOUND] = it }
|
|
101
|
+
facetecTexts?.getString("feedbackFaceNotLookingStraightAhead")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_FACE_NOT_LOOKING_STRAIGHT_AHEAD] = it }
|
|
102
|
+
facetecTexts?.getString("feedbackFaceNotUpright")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_FACE_NOT_UPRIGHT] = it }
|
|
103
|
+
facetecTexts?.getString("feedbackHoldSteady")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_HOLD_STEADY] = it }
|
|
104
|
+
facetecTexts?.getString("feedbackMovePhoneAway")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_MOVE_PHONE_AWAY] = it }
|
|
105
|
+
facetecTexts?.getString("feedbackMovePhoneCloser")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_MOVE_PHONE_CLOSER] = it }
|
|
106
|
+
facetecTexts?.getString("feedbackMovePhoneToEyeLevel")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_MOVE_PHONE_TO_EYE_LEVEL] = it }
|
|
107
|
+
facetecTexts?.getString("feedbackUseEvenLighting")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_USE_EVEN_LIGHTING] = it }
|
|
108
|
+
facetecTexts?.getString("feedbackFrameYourFace")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_FRAME_YOUR_FACE] = it }
|
|
109
|
+
facetecTexts?.getString("feedbackHoldSteady1")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_HOLD_STEADY_1] = it }
|
|
110
|
+
facetecTexts?.getString("feedbackHoldSteady2")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_HOLD_STEADY_2] = it }
|
|
111
|
+
facetecTexts?.getString("feedbackHoldSteady3")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_HOLD_STEADY_3] = it }
|
|
112
|
+
facetecTexts?.getString("feedbackRemoveDarkGlasses")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_REMOVE_DARK_GLASSES] = it }
|
|
113
|
+
facetecTexts?.getString("feedbackNeutralExpression")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_NEUTRAL_EXPRESSION] = it }
|
|
114
|
+
facetecTexts?.getString("feedbackConditionsTooBright")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_CONDITIONS_TOO_BRIGHT] = it }
|
|
115
|
+
facetecTexts?.getString("feedbackBrightenYourEnvironment")?.let { customFacetecTexts[FacetecTextKey.FEEDBACK_BRIGHTEN_YOUR_ENVIRONMENT] = it }
|
|
116
|
+
|
|
117
|
+
// Ready Screen
|
|
118
|
+
guidanceReadyScreenHeaderTextColor(facetecColors?.getString("readyScreenHeader") ?: "#FFFFFF")
|
|
119
|
+
guidanceReadyScreenSubtextTextColor(facetecColors?.getString("readyScreenSubtext") ?: "#BBBBBB")
|
|
120
|
+
guidanceReadyScreenTextBackgroundColor(facetecColors?.getString("readyScreenTextBackground") ?: "#BBBBBB")
|
|
121
|
+
guidanceReadyScreenOvalFillColor(facetecColors?.getString("readyScreenOvalFill") ?: "#00FF00")
|
|
122
|
+
guidanceReadyScreenTextBackgroundCornerRadius(12)
|
|
123
|
+
|
|
124
|
+
// Guidance
|
|
125
|
+
guidanceForegroundColor(facetecColors?.getString("guidanceForeground") ?: "#FFFFFF")
|
|
126
|
+
guidanceBackgroundColors(facetecColors?.getString("guidanceBackground") ?: "#1F1F1F")
|
|
127
|
+
guidanceButtonTextNormalColor(facetecColors?.getString("guidanceButtonTextNormal") ?: "#3d100c")
|
|
128
|
+
guidanceButtonTextHighlightColor(facetecColors?.getString("guidanceButtonTextHighlight") ?: "#000000")
|
|
129
|
+
guidanceButtonTextDisabledColor(facetecColors?.getString("guidanceButtonTextDisabled") ?: "#000000")
|
|
130
|
+
guidanceButtonBackgroundNormalColor(facetecColors?.getString("guidanceButtonBackgroundNormal") ?: "#00ff00")
|
|
131
|
+
guidanceButtonBackgroundHighlightColor(facetecColors?.getString("guidanceButtonBackgroundHighlight") ?: "#0F9D58")
|
|
132
|
+
guidanceButtonBackgroundDisabledColor(facetecColors?.getString("guidanceButtonBackgroundDisabled") ?: "#ff0000")
|
|
133
|
+
guidanceButtonBorderColor(facetecColors?.getString("guidanceButtonBorder") ?: "#0F9D58")
|
|
134
|
+
guidanceButtonBorderWidth(2)
|
|
135
|
+
guidanceButtonCornerRadius(12)
|
|
136
|
+
|
|
137
|
+
// Retry Screen
|
|
138
|
+
guidanceRetryScreenHeaderTextColor(facetecColors?.getString("retryScreenHeader") ?: "#FF5252")
|
|
139
|
+
guidanceRetryScreenSubtextTextColor(facetecColors?.getString("retryScreenSubtext") ?: "#DD3333")
|
|
140
|
+
guidanceRetryScreenOvalStrokeColor(facetecColors?.getString("retryScreenOvalStroke") ?: "#FFFFFF")
|
|
141
|
+
guidanceRetryScreenImageBorderColor(facetecColors?.getString("retryScreenImageBorder") ?: "#417FB2")
|
|
142
|
+
guidanceRetryScreenImageBorderWidth(3)
|
|
143
|
+
guidanceRetryScreenImageCornerRadius(12)
|
|
144
|
+
|
|
145
|
+
// Result Screen
|
|
146
|
+
resultScreenForegroundColor(facetecColors?.getString("resultScreenForeground") ?: "#0F9D58")
|
|
147
|
+
resultScreenBackgroundColors(facetecColors?.getString("resultScreenBackground") ?: "#DFFFD6")
|
|
148
|
+
resultScreenUploadProgressFillColor(facetecColors?.getString("resultScreenUploadProgressFill") ?: "#0F9D58")
|
|
149
|
+
resultScreenUploadProgressTrackColor(facetecColors?.getString("resultScreenUploadProgressTrack") ?: "#66000000")
|
|
150
|
+
resultScreenActivityIndicatorColor(facetecColors?.getString("resultScreenActivityIndicator") ?: "#0F9D58")
|
|
151
|
+
resultScreenResultAnimationBackgroundColor(facetecColors?.getString("resultScreenResultAnimationBackground") ?: "#417FB2")
|
|
152
|
+
resultScreenResultAnimationForegroundColor(facetecColors?.getString("resultScreenResultAnimationForeground") ?: "#FFFFFF")
|
|
153
|
+
resultScreenCustomActivityIndicatorAnimation(br.com.oiti.facetecsdk.R.drawable.animated_activity_indicator)
|
|
154
|
+
resultScreenCustomActivityIndicatorRotationInterval(1000)
|
|
155
|
+
resultScreenAnimationRelativeScale(1f)
|
|
156
|
+
resultScreenShowUploadProgressBar(true)
|
|
157
|
+
resultScreenCustomStaticResultAnimationUnSuccess(R.drawable.error_icon)
|
|
158
|
+
resultScreenCustomStaticResultAnimationSuccess(R.drawable.success_icon)
|
|
159
|
+
resultScreenCustomResultAnimationUnSuccess(R.drawable.error_icon)
|
|
160
|
+
resultScreenCustomResultAnimationSuccess(R.drawable.success_icon)
|
|
161
|
+
resultScreenResultAnimationUnSuccessBackgroundImage(R.drawable.error_icon)
|
|
162
|
+
resultScreenResultAnimationSuccessBackgroundImage(R.drawable.success_icon)
|
|
163
|
+
resultScreenOverrideSuccessMessage("Toque para reiniciar")
|
|
164
|
+
|
|
165
|
+
// Oval
|
|
166
|
+
ovalCustomizationStrokeWidth(4)
|
|
167
|
+
ovalCustomizationStrokeColor(facetecColors?.getString("ovalStroke") ?: "#00FF00")
|
|
168
|
+
ovalCustomizationProgressStrokeWidth(6)
|
|
169
|
+
ovalCustomizationProgressColor1(facetecColors?.getString("ovalProgressFirst") ?: "#00FF00")
|
|
170
|
+
ovalCustomizationProgressColor2(facetecColors?.getString("ovalProgressSecond") ?: "#FF0000")
|
|
171
|
+
ovalCustomizationProgressRadialOffset(8)
|
|
172
|
+
|
|
173
|
+
// Frame
|
|
174
|
+
frameBackgroundColor(facetecColors?.getString("frameBackground") ?: "#121212")
|
|
175
|
+
frameBorderColor(facetecColors?.getString("frameBorder") ?: "#FFFFFF")
|
|
176
|
+
frameBorderWidth(2)
|
|
177
|
+
frameCornerRadius(8)
|
|
178
|
+
frameElevation(5)
|
|
179
|
+
|
|
180
|
+
// Overlay
|
|
181
|
+
overlayBackgroundColor(facetecColors?.getString("overlayBackground") ?: "#80000000")
|
|
182
|
+
overlayShowBrandingImage(true)
|
|
183
|
+
|
|
184
|
+
// Feedback
|
|
185
|
+
feedbackBackgroundColors(facetecColors?.getString("feedbackBarBackground") ?: "#FFFDE7")
|
|
186
|
+
feedbackTextColor(facetecColors?.getString("feedbackMessage") ?: "#000000")
|
|
187
|
+
feedbackCornerRadius(12)
|
|
188
|
+
feedbackElevation(8)
|
|
189
|
+
feedbackEnablePulsatingText(true)
|
|
190
|
+
|
|
191
|
+
// Cancel Button
|
|
192
|
+
cancelButtonLocation(FacetecButtonLocation.TOP_RIGHT)
|
|
193
|
+
exitAnimationStyle(FacetecExitAnimationStyle.RIPPLE_IN)
|
|
194
|
+
|
|
195
|
+
setFacetecFontsMap(facetecFonts)
|
|
196
|
+
setFacetecTextMap(customFacetecTexts)
|
|
197
|
+
|
|
198
|
+
// Instructions Screen
|
|
199
|
+
setInstructionsTheme {
|
|
200
|
+
setShowInstructionScreen(showInstructionScreen)
|
|
201
|
+
setTitleText(instructionsTexts?.getString("title") ?: "Centralize seu rosto")
|
|
202
|
+
setCaptionText(instructionsTexts?.getString("caption") ?: "Mantenha-se dentro do círculo")
|
|
203
|
+
setStatusBarColor(instructionsColors?.getString("statusBar") ?: "#121212")
|
|
204
|
+
setStatusBarIsDarkIcons(false)
|
|
205
|
+
setBackgroundColor(instructionsColors?.getString("background") ?: "#121212")
|
|
206
|
+
setContinueButtonText(instructionsTexts?.getString("continueButtonText") ?: "Começar")
|
|
207
|
+
setContinueButtonColor(instructionsColors?.getString("continueButtonBackground") ?: "#0F9D58")
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Permission Screen
|
|
211
|
+
setPermissionTheme {
|
|
212
|
+
setTitle(permissionTexts?.getString("title") ?: "Permissão de Câmera")
|
|
213
|
+
setBackgroundColor(permissionColors?.getString("background") ?: "#1F1F1F")
|
|
214
|
+
setStatusBarColor(permissionColors?.getString("statusBar") ?: "#1F1F1F")
|
|
215
|
+
setStatusBarIsDarkIcons(false)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Processing Screen
|
|
219
|
+
val processingTheme = theme?.getMap("processing")
|
|
220
|
+
val processingColors = processingTheme?.getMap("colors")
|
|
221
|
+
|
|
222
|
+
setProcessingTheme {
|
|
223
|
+
setBackgroundColor(processingColors?.getString("background") ?: "#000000")
|
|
224
|
+
setLoadingDialogColor(processingColors?.getString("loading") ?: "#FFFFFF")
|
|
225
|
+
setStatusBarColor(processingColors?.getString("statusBar") ?: "#000000")
|
|
226
|
+
setStatusBarIsDarkIcons(false)
|
|
227
|
+
setLoadingIndicatorSize(80)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
fun create(isCustom: Boolean, theme: ReadableMap? = null, context: Context? = null): FacetecTheme =
|
|
232
|
+
if (isCustom) buildCustom(theme, context) else buildDefault()
|
|
233
|
+
}
|