diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bc8d86c4..86e3404ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added - Added missing `showInstructions` on some Composables +- Added missing parameters on Fragments ### Fixed - Fixed crash when duplicate images are attempted to be zipped @@ -25,7 +26,7 @@ ## 10.0.0-beta13 ### Added -- Added `extras` as optional params on all job types +- Added `partnerParams` as optional params on all job types - Added `allowAgentMode` option on Document Verification and Enhanced Document Verification ## 10.0.0-beta12 diff --git a/lib/src/main/java/com/smileidentity/fragment/BiometricKYCFragment.kt b/lib/src/main/java/com/smileidentity/fragment/BiometricKYCFragment.kt index ad77a7fc9..1acad91cb 100644 --- a/lib/src/main/java/com/smileidentity/fragment/BiometricKYCFragment.kt +++ b/lib/src/main/java/com/smileidentity/fragment/BiometricKYCFragment.kt @@ -22,6 +22,7 @@ import com.smileidentity.util.getParcelableCompat import com.smileidentity.util.getSerializableCompat import com.smileidentity.util.randomJobId import com.smileidentity.util.randomUserId +import kotlinx.collections.immutable.toImmutableMap import java.net.URL /** @@ -81,6 +82,8 @@ class BiometricKYCFragment : Fragment() { jobId: String = randomJobId(), allowAgentMode: Boolean = false, showAttribution: Boolean = true, + showInstructions: Boolean = true, + extraPartnerParams: HashMap? = null, ) = BiometricKYCFragment().apply { arguments = Bundle().apply { this.idInfo = idInfo @@ -92,6 +95,8 @@ class BiometricKYCFragment : Fragment() { this.jobId = jobId this.allowAgentMode = allowAgentMode this.showAttribution = showAttribution + this.showInstructions = showInstructions + this.extraPartnerParams = extraPartnerParams } } @@ -119,6 +124,8 @@ class BiometricKYCFragment : Fragment() { jobId = args.jobId, allowAgentMode = args.allowAgentMode, showAttribution = args.showAttribution, + showInstructions = args.showInstructions, + extraPartnerParams = (args.extraPartnerParams ?: mapOf()).toImmutableMap(), onResult = { setFragmentResult(KEY_REQUEST, Bundle().apply { smileIDResult = it }) }, @@ -172,6 +179,16 @@ private var Bundle.allowAgentMode: Boolean get() = getBoolean(KEY_ALLOW_AGENT_MODE) set(value) = putBoolean(KEY_ALLOW_AGENT_MODE, value) +private const val KEY_SHOW_INSTRUCTIONS = "showInstructions" +private var Bundle.showInstructions: Boolean + get() = getBoolean(KEY_SHOW_INSTRUCTIONS) + set(value) = putBoolean(KEY_SHOW_INSTRUCTIONS, value) + +private const val KEY_EXTRA_PARTNER_PARAMS = "extraPartnerParams" +private var Bundle.extraPartnerParams: HashMap? + get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS) + set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value) + private var Bundle.smileIDResult: SmileIDResult get() = getParcelableCompat(KEY_RESULT)!! set(value) = putParcelable(KEY_RESULT, value) diff --git a/lib/src/main/java/com/smileidentity/fragment/DocumentVerificationFragment.kt b/lib/src/main/java/com/smileidentity/fragment/DocumentVerificationFragment.kt index c24a50161..e19479ea7 100644 --- a/lib/src/main/java/com/smileidentity/fragment/DocumentVerificationFragment.kt +++ b/lib/src/main/java/com/smileidentity/fragment/DocumentVerificationFragment.kt @@ -19,6 +19,7 @@ import com.smileidentity.util.getParcelableCompat import com.smileidentity.util.getSerializableCompat import com.smileidentity.util.randomJobId import com.smileidentity.util.randomUserId +import kotlinx.collections.immutable.toImmutableMap import java.io.File /** @@ -71,21 +72,27 @@ class DocumentVerificationFragment : Fragment() { userId: String = randomUserId(), jobId: String = randomJobId(), showAttribution: Boolean = true, + allowAgentMode: Boolean = false, allowGalleryUpload: Boolean = false, + showInstructions: Boolean = true, idAspectRatio: Float? = null, captureBothSides: Boolean = false, bypassSelfieCaptureWithFile: File? = null, + extraPartnerParams: HashMap? = null, ) = DocumentVerificationFragment().apply { arguments = Bundle().apply { this.userId = userId this.jobId = jobId this.showAttribution = showAttribution + this.allowAgentMode = allowAgentMode this.allowGalleryUpload = allowGalleryUpload + this.showInstructions = showInstructions this.countryCode = countryCode this.documentType = documentType this.idAspectRatio = idAspectRatio ?: -1f this.captureBothSides = captureBothSides this.bypassSelfieCaptureWithFile = bypassSelfieCaptureWithFile + this.extraPartnerParams = extraPartnerParams } } @@ -110,9 +117,12 @@ class DocumentVerificationFragment : Fragment() { userId = args.userId, jobId = args.jobId, showAttribution = args.showAttribution, + allowAgentMode = args.allowAgentMode, allowGalleryUpload = args.allowGalleryUpload, + showInstructions = args.showInstructions, idAspectRatio = if (aspectRatio > 0) aspectRatio else null, bypassSelfieCaptureWithFile = args.bypassSelfieCaptureWithFile, + extraPartnerParams = (args.extraPartnerParams ?: mapOf()).toImmutableMap(), onResult = { setFragmentResult(KEY_REQUEST, Bundle().apply { smileIDResult = it }) }, @@ -136,11 +146,21 @@ private var Bundle.showAttribution: Boolean get() = getBoolean(KEY_SHOW_ATTRIBUTION) set(value) = putBoolean(KEY_SHOW_ATTRIBUTION, value) +private const val KEY_ALLOW_AGENT_MODE = "allowAgentMode" +private var Bundle.allowAgentMode: Boolean + get() = getBoolean(KEY_ALLOW_AGENT_MODE) + set(value) = putBoolean(KEY_ALLOW_AGENT_MODE, value) + private const val KEY_ALLOW_GALLERY_UPLOAD = "allowGalleryUpload" private var Bundle.allowGalleryUpload: Boolean get() = getBoolean(KEY_ALLOW_GALLERY_UPLOAD) set(value) = putBoolean(KEY_ALLOW_GALLERY_UPLOAD, value) +private const val KEY_SHOW_INSTRUCTIONS = "showInstructions" +private var Bundle.showInstructions: Boolean + get() = getBoolean(KEY_SHOW_INSTRUCTIONS) + set(value) = putBoolean(KEY_SHOW_INSTRUCTIONS, value) + private const val KEY_COUNTRY_CODE = "countryCode" private var Bundle.countryCode: String @@ -169,6 +189,11 @@ private var Bundle.bypassSelfieCaptureWithFile: File? get() = getSerializableCompat(KEY_BYPASS_SELFIE_CAPTURE_WITH_FILE) as File? set(value) = putSerializable(KEY_BYPASS_SELFIE_CAPTURE_WITH_FILE, value) +private const val KEY_EXTRA_PARTNER_PARAMS = "extraPartnerParams" +private var Bundle.extraPartnerParams: HashMap? + get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS) + set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value) + private var Bundle.smileIDResult: SmileIDResult get() = getParcelableCompat(KEY_RESULT)!! set(value) = putParcelable(KEY_RESULT, value) diff --git a/lib/src/main/java/com/smileidentity/fragment/EnhancedDocumentVerificationFragment.kt b/lib/src/main/java/com/smileidentity/fragment/EnhancedDocumentVerificationFragment.kt index 481417718..d3df155a3 100644 --- a/lib/src/main/java/com/smileidentity/fragment/EnhancedDocumentVerificationFragment.kt +++ b/lib/src/main/java/com/smileidentity/fragment/EnhancedDocumentVerificationFragment.kt @@ -16,17 +16,19 @@ import com.smileidentity.fragment.EnhancedDocumentVerificationFragment.Companion import com.smileidentity.results.EnhancedDocumentVerificationResult import com.smileidentity.results.SmileIDResult import com.smileidentity.util.getParcelableCompat +import com.smileidentity.util.getSerializableCompat import com.smileidentity.util.randomJobId import com.smileidentity.util.randomUserId +import kotlinx.collections.immutable.toImmutableMap /** * Perform Enhanced Document Verification * * [Docs](https://docs.usesmileid.com/products/for-individuals-kyc/enhanced-document-verification) * - * A [Fragment] wrapper for the [EnhancedDocumentVerification] to be used if not using Jetpack Compose. - * New instances *must* be created via [newInstance]. Results are communicated back to the caller - * via [setFragmentResult]. Therefore, the caller must use + * A [Fragment] wrapper for the [EnhancedDocumentVerificationScreen] to be used if not using Jetpack + * Compose. New instances *must* be created via [newInstance]. Results are communicated back to the + * caller via [setFragmentResult]. Therefore, the caller must use * [androidx.fragment.app.FragmentManager.setFragmentResultListener] to listen for the result. If * using parent/child fragments, the caller must use the appropriate child/parent FragmentManager. * The result key is [KEY_REQUEST] and the result is a [SmileIDResult] in the bundle under the @@ -69,19 +71,25 @@ class EnhancedDocumentVerificationFragment : Fragment() { userId: String = randomUserId(), jobId: String = randomJobId(), showAttribution: Boolean = true, + allowAgentMode: Boolean = false, allowGalleryUpload: Boolean = false, + showInstructions: Boolean = true, idAspectRatio: Float? = null, captureBothSides: Boolean = false, + extraPartnerParams: HashMap? = null, ) = EnhancedDocumentVerificationFragment().apply { arguments = Bundle().apply { this.userId = userId this.jobId = jobId this.showAttribution = showAttribution + this.allowAgentMode = allowAgentMode this.allowGalleryUpload = allowGalleryUpload + this.showInstructions = showInstructions this.countryCode = countryCode this.documentType = documentType this.idAspectRatio = idAspectRatio ?: -1f this.captureBothSides = captureBothSides + this.extraPartnerParams = extraPartnerParams } } @@ -106,8 +114,11 @@ class EnhancedDocumentVerificationFragment : Fragment() { userId = args.userId, jobId = args.jobId, showAttribution = args.showAttribution, + allowAgentMode = args.allowAgentMode, allowGalleryUpload = args.allowGalleryUpload, + showInstructions = args.showInstructions, idAspectRatio = if (aspectRatio > 0) aspectRatio else null, + extraPartnerParams = (args.extraPartnerParams ?: mapOf()).toImmutableMap(), onResult = { setFragmentResult(KEY_REQUEST, Bundle().apply { smileIDResult = it }) }, @@ -131,11 +142,21 @@ private var Bundle.showAttribution: Boolean get() = getBoolean(KEY_SHOW_ATTRIBUTION) set(value) = putBoolean(KEY_SHOW_ATTRIBUTION, value) +private const val KEY_ALLOW_AGENT_MODE = "allowAgentMode" +private var Bundle.allowAgentMode: Boolean + get() = getBoolean(KEY_ALLOW_AGENT_MODE) + set(value) = putBoolean(KEY_ALLOW_AGENT_MODE, value) + private const val KEY_ALLOW_GALLERY_UPLOAD = "allowGalleryUpload" private var Bundle.allowGalleryUpload: Boolean get() = getBoolean(KEY_ALLOW_GALLERY_UPLOAD) set(value) = putBoolean(KEY_ALLOW_GALLERY_UPLOAD, value) +private const val KEY_SHOW_INSTRUCTIONS = "showInstructions" +private var Bundle.showInstructions: Boolean + get() = getBoolean(KEY_SHOW_INSTRUCTIONS) + set(value) = putBoolean(KEY_SHOW_INSTRUCTIONS, value) + private const val KEY_COUNTRY_CODE = "countryCode" private var Bundle.countryCode: String @@ -159,6 +180,11 @@ private var Bundle.captureBothSides: Boolean get() = getBoolean(KEY_CAPTURE_BOTH_SIDES) set(value) = putBoolean(KEY_CAPTURE_BOTH_SIDES, value) +private const val KEY_EXTRA_PARTNER_PARAMS = "extraPartnerParams" +private var Bundle.extraPartnerParams: HashMap? + get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS) + set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value) + private var Bundle.smileIDResult: SmileIDResult get() = getParcelableCompat(DocumentVerificationFragment.KEY_RESULT)!! set(value) = putParcelable(DocumentVerificationFragment.KEY_RESULT, value) diff --git a/lib/src/main/java/com/smileidentity/fragment/SmartSelfieAuthenticationFragment.kt b/lib/src/main/java/com/smileidentity/fragment/SmartSelfieAuthenticationFragment.kt index 91ad561fa..42b92998f 100644 --- a/lib/src/main/java/com/smileidentity/fragment/SmartSelfieAuthenticationFragment.kt +++ b/lib/src/main/java/com/smileidentity/fragment/SmartSelfieAuthenticationFragment.kt @@ -16,8 +16,10 @@ import com.smileidentity.fragment.SmartSelfieAuthenticationFragment.Companion.re import com.smileidentity.results.SmartSelfieResult import com.smileidentity.results.SmileIDResult import com.smileidentity.util.getParcelableCompat +import com.smileidentity.util.getSerializableCompat import com.smileidentity.util.randomJobId import com.smileidentity.util.randomUserId +import kotlinx.collections.immutable.toImmutableMap /** * Perform a SmartSelfieā„¢ Authentication @@ -80,12 +82,16 @@ class SmartSelfieAuthenticationFragment : Fragment() { jobId: String = randomJobId(), allowAgentMode: Boolean = false, showAttribution: Boolean = true, + showInstructions: Boolean = true, + extraPartnerParams: HashMap? = null, ) = SmartSelfieAuthenticationFragment().apply { arguments = Bundle().apply { this.userId = userId this.jobId = jobId this.allowAgentMode = allowAgentMode this.showAttribution = showAttribution + this.showInstructions = showInstructions + this.extraPartnerParams = extraPartnerParams } } @@ -108,6 +114,8 @@ class SmartSelfieAuthenticationFragment : Fragment() { jobId = args.jobId, allowAgentMode = args.allowAgentMode, showAttribution = args.showAttribution, + showInstructions = args.showInstructions, + extraPartnerParams = (args.extraPartnerParams ?: mapOf()).toImmutableMap(), onResult = { setFragmentResult(KEY_REQUEST, Bundle().apply { smileIdResult = it }) }, @@ -136,6 +144,16 @@ private var Bundle.showAttribution: Boolean get() = getBoolean(KEY_SHOW_ATTRIBUTION) set(value) = putBoolean(KEY_SHOW_ATTRIBUTION, value) +private const val KEY_SHOW_INSTRUCTIONS = "showInstructions" +private var Bundle.showInstructions: Boolean + get() = getBoolean(KEY_SHOW_INSTRUCTIONS) + set(value) = putBoolean(KEY_SHOW_INSTRUCTIONS, value) + +private const val KEY_EXTRA_PARTNER_PARAMS = "extraPartnerParams" +private var Bundle.extraPartnerParams: HashMap? + get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS) + set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value) + private var Bundle.smileIdResult: SmileIDResult get() = getParcelableCompat(KEY_RESULT)!! set(value) = putParcelable(KEY_RESULT, value) diff --git a/lib/src/main/java/com/smileidentity/fragment/SmartSelfieEnrollmentFragment.kt b/lib/src/main/java/com/smileidentity/fragment/SmartSelfieEnrollmentFragment.kt index 93434dc68..b6e329d28 100644 --- a/lib/src/main/java/com/smileidentity/fragment/SmartSelfieEnrollmentFragment.kt +++ b/lib/src/main/java/com/smileidentity/fragment/SmartSelfieEnrollmentFragment.kt @@ -16,8 +16,10 @@ import com.smileidentity.fragment.SmartSelfieEnrollmentFragment.Companion.result import com.smileidentity.results.SmartSelfieResult import com.smileidentity.results.SmileIDResult import com.smileidentity.util.getParcelableCompat +import com.smileidentity.util.getSerializableCompat import com.smileidentity.util.randomJobId import com.smileidentity.util.randomUserId +import kotlinx.collections.immutable.toImmutableMap /** * Perform a SmartSelfieā„¢ Enrollment @@ -83,6 +85,7 @@ class SmartSelfieEnrollmentFragment : Fragment() { allowAgentMode: Boolean = false, showAttribution: Boolean = true, showInstructions: Boolean = true, + extraPartnerParams: HashMap? = null, ) = SmartSelfieEnrollmentFragment().apply { arguments = Bundle().apply { this.userId = userId @@ -90,6 +93,7 @@ class SmartSelfieEnrollmentFragment : Fragment() { this.allowAgentMode = allowAgentMode this.showAttribution = showAttribution this.showInstructions = showInstructions + this.extraPartnerParams = extraPartnerParams } } @@ -113,6 +117,7 @@ class SmartSelfieEnrollmentFragment : Fragment() { allowAgentMode = args.allowAgentMode, showAttribution = args.showAttribution, showInstructions = args.showInstructions, + extraPartnerParams = (args.extraPartnerParams ?: mapOf()).toImmutableMap(), onResult = { setFragmentResult(KEY_REQUEST, Bundle().apply { smileIdResult = it }) }, @@ -146,6 +151,11 @@ private var Bundle.showInstructions: Boolean get() = getBoolean(KEY_SHOW_INSTRUCTIONS) set(value) = putBoolean(KEY_SHOW_INSTRUCTIONS, value) +private const val KEY_EXTRA_PARTNER_PARAMS = "extraPartnerParams" +private var Bundle.extraPartnerParams: HashMap? + get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS) + set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value) + private var Bundle.smileIdResult: SmileIDResult get() = getParcelableCompat(KEY_RESULT)!! set(value) = putParcelable(KEY_RESULT, value)