-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow wrappers sdks to capture face images separately v10 [React vs F…
…lutter] (#66) * feat: selfie capture standalone * feat: selfie and doc capture complete * feat: ios update * fix: custom result with absolute file paths * feat: bump android sdk * feat: remove config.json * feat: make ios and android params work the same * feat: bump ios to 10.2.12 * feat: document capture ios same file paths with selfie
- Loading branch information
Showing
29 changed files
with
1,044 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
android/src/main/java/com/smileidentity/react/utils/DocumentCaptureResultAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.smileidentity.react.utils | ||
|
||
import com.smileidentity.react.views.DocumentCaptureResult | ||
import com.squareup.moshi.FromJson | ||
import com.squareup.moshi.JsonAdapter | ||
import com.squareup.moshi.JsonReader | ||
import com.squareup.moshi.JsonWriter | ||
import com.squareup.moshi.Moshi | ||
import com.squareup.moshi.ToJson | ||
import java.io.File | ||
import java.lang.reflect.Type | ||
|
||
class DocumentCaptureResultAdapter : JsonAdapter<DocumentCaptureResult>() { | ||
|
||
@FromJson | ||
override fun fromJson(reader: JsonReader): DocumentCaptureResult { | ||
reader.beginObject() | ||
var frontFile: File? = null | ||
var backFile: File? = null | ||
while (reader.hasNext()) { | ||
when (reader.nextName()) { | ||
"documentFrontFile" -> frontFile = reader.nextString()?.let { File(it) } | ||
"documentBackFile" -> backFile = reader.nextString()?.let { File(it) } | ||
else -> reader.skipValue() | ||
} | ||
} | ||
reader.endObject() | ||
return DocumentCaptureResult(frontFile, backFile) | ||
} | ||
|
||
@ToJson | ||
override fun toJson(writer: JsonWriter, value: DocumentCaptureResult?) { | ||
if (value == null) { | ||
writer.nullValue() | ||
return | ||
} | ||
writer.beginObject() | ||
writer.name("documentFrontFile").value(value.documentFrontFile?.absolutePath) | ||
writer.name("documentBackFile").value(value.documentBackFile?.absolutePath) | ||
writer.endObject() | ||
} | ||
|
||
companion object { | ||
val FACTORY = object : Factory { | ||
override fun create( | ||
type: Type, | ||
annotations: Set<Annotation>, | ||
moshi: Moshi | ||
): JsonAdapter<*>? { | ||
return if (type == DocumentCaptureResult::class.java) DocumentCaptureResultAdapter() else null | ||
} | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
android/src/main/java/com/smileidentity/react/utils/SelfieCaptureResultAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.smileidentity.react.utils | ||
|
||
import com.smileidentity.react.views.SmartSelfieCaptureResult | ||
import com.squareup.moshi.FromJson | ||
import com.squareup.moshi.JsonAdapter | ||
import com.squareup.moshi.JsonReader | ||
import com.squareup.moshi.JsonWriter | ||
import com.squareup.moshi.Moshi | ||
import com.squareup.moshi.ToJson | ||
import java.io.File | ||
import java.lang.reflect.Type | ||
|
||
class SelfieCaptureResultAdapter : JsonAdapter<SmartSelfieCaptureResult>() { | ||
|
||
@FromJson | ||
override fun fromJson(reader: JsonReader): SmartSelfieCaptureResult { | ||
reader.beginObject() | ||
var selfieFile: File? = null | ||
var livenessFiles: List<File>? = null | ||
while (reader.hasNext()) { | ||
when (reader.nextName()) { | ||
"selfieFile" -> selfieFile = reader.nextString()?.let { File(it) } | ||
"livenessFiles" -> { | ||
reader.beginArray() | ||
val files = mutableListOf<File>() | ||
while (reader.hasNext()) { | ||
reader.nextString()?.let { files.add(File(it)) } | ||
} | ||
reader.endArray() | ||
livenessFiles = files | ||
} | ||
else -> reader.skipValue() | ||
} | ||
} | ||
reader.endObject() | ||
return SmartSelfieCaptureResult(selfieFile, livenessFiles) | ||
} | ||
|
||
@ToJson | ||
override fun toJson(writer: JsonWriter, value: SmartSelfieCaptureResult?) { | ||
if (value == null) { | ||
writer.nullValue() | ||
return | ||
} | ||
writer.beginObject() | ||
writer.name("selfieFile").value(value.selfieFile?.absolutePath) | ||
writer.name("livenessFiles") | ||
writer.beginArray() | ||
value.livenessFiles?.forEach { file -> | ||
writer.value(file.absolutePath) | ||
} | ||
writer.endArray() | ||
writer.endObject() | ||
} | ||
|
||
companion object { | ||
val FACTORY = object : Factory { | ||
override fun create( | ||
type: Type, | ||
annotations: Set<Annotation>, | ||
moshi: Moshi | ||
): JsonAdapter<*>? { | ||
return if (type == SmartSelfieCaptureResult::class.java) SelfieCaptureResultAdapter() else null | ||
} | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...d/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentCaptureViewManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.smileidentity.react.viewmanagers | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReadableArray | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.smileidentity.react.utils.getBoolOrDefault | ||
import com.smileidentity.react.utils.getStringOrDefault | ||
import com.smileidentity.react.views.SmileIDDocumentCaptureView | ||
|
||
@ReactModule(name = SmileIDDocumentCaptureViewManager.NAME) | ||
class SmileIDDocumentCaptureViewManager( | ||
private val reactApplicationContext: ReactApplicationContext | ||
) : SimpleViewManager<SmileIDDocumentCaptureView>() { | ||
override fun getName(): String = NAME | ||
|
||
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> { | ||
return mapOf( | ||
"onSmileResult" to mapOf( | ||
"phasedRegistrationNames" to mapOf( | ||
"bubbled" to "onResult" | ||
) | ||
) | ||
) | ||
} | ||
|
||
override fun getCommandsMap(): Map<String, Int> { | ||
return mapOf("setParams" to COMMAND_SET_PARAMS) | ||
} | ||
|
||
override fun receiveCommand( | ||
view: SmileIDDocumentCaptureView, | ||
commandId: String?, | ||
args: ReadableArray? | ||
) { | ||
super.receiveCommand(view, commandId, args) | ||
when (commandId?.toInt()) { | ||
COMMAND_SET_PARAMS -> { | ||
// Extract params from args and apply to view | ||
val params = args?.getMap(0) | ||
params?.let { | ||
view.userId = params.getStringOrDefault("userId") | ||
view.jobId = params.getStringOrDefault("jobId") | ||
view.allowAgentMode = params.getBoolOrDefault("allowAgentMode", true) | ||
view.showAttribution = params.getBoolOrDefault("showAttribution", true) | ||
view.showInstructions = params.getBoolOrDefault("showInstructions", true) | ||
view.showConfirmation = params.getBoolOrDefault("showConfirmation", true) | ||
view.allowGalleryUpload = params.getBoolOrDefault("allowGalleryUpload", false) | ||
view.front = params.getBoolOrDefault("isDocumentFrontSide", true) | ||
view.renderContent() | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun createViewInstance(p0: ThemedReactContext): SmileIDDocumentCaptureView { | ||
return SmileIDDocumentCaptureView(reactApplicationContext) | ||
} | ||
|
||
companion object { | ||
const val NAME = "SmileIDDocumentCaptureView" | ||
const val COMMAND_SET_PARAMS = 1 | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...rc/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieCaptureViewManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.smileidentity.react.viewmanagers | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReadableArray | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.smileidentity.react.utils.getBoolOrDefault | ||
import com.smileidentity.react.utils.getStringOrDefault | ||
import com.smileidentity.react.views.SmileIDSmartSelfieCaptureView | ||
|
||
@ReactModule(name = SmileIDSmartSelfieCaptureViewManager.NAME) | ||
class SmileIDSmartSelfieCaptureViewManager( | ||
private val reactApplicationContext: ReactApplicationContext | ||
) : SimpleViewManager<SmileIDSmartSelfieCaptureView>() { | ||
override fun getName(): String = NAME | ||
|
||
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> { | ||
return mapOf( | ||
"onSmileResult" to mapOf( | ||
"phasedRegistrationNames" to mapOf( | ||
"bubbled" to "onResult" | ||
) | ||
) | ||
) | ||
} | ||
|
||
override fun getCommandsMap(): Map<String, Int> { | ||
return mapOf("setParams" to COMMAND_SET_PARAMS) | ||
} | ||
|
||
override fun receiveCommand( | ||
view: SmileIDSmartSelfieCaptureView, | ||
commandId: String?, | ||
args: ReadableArray? | ||
) { | ||
super.receiveCommand(view, commandId, args) | ||
when (commandId?.toInt()) { | ||
COMMAND_SET_PARAMS -> { | ||
// Extract params from args and apply to view | ||
val params = args?.getMap(0) | ||
params?.let { | ||
view.userId = params.getStringOrDefault("userId") | ||
view.jobId = params.getStringOrDefault("jobId") | ||
view.allowAgentMode = params.getBoolOrDefault("allowAgentMode", false) | ||
view.showAttribution = params.getBoolOrDefault("showAttribution", true) | ||
view.showInstructions = params.getBoolOrDefault("showInstructions", true) | ||
view.showConfirmation = params.getBoolOrDefault("showConfirmation", true) | ||
view.renderContent() | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun createViewInstance(p0: ThemedReactContext): SmileIDSmartSelfieCaptureView { | ||
return SmileIDSmartSelfieCaptureView(reactApplicationContext) | ||
} | ||
|
||
companion object { | ||
const val NAME = "SmileIDSmartSelfieCaptureView" | ||
const val COMMAND_SET_PARAMS = 1 | ||
} | ||
} |
Oops, something went wrong.