Skip to content

Commit

Permalink
Update Fragments with missing parameters (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanshg authored Nov 16, 2023
1 parent 5f695e5 commit 4c18d41
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -81,6 +82,8 @@ class BiometricKYCFragment : Fragment() {
jobId: String = randomJobId(),
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
extraPartnerParams: HashMap<String, String>? = null,
) = BiometricKYCFragment().apply {
arguments = Bundle().apply {
this.idInfo = idInfo
Expand All @@ -92,6 +95,8 @@ class BiometricKYCFragment : Fragment() {
this.jobId = jobId
this.allowAgentMode = allowAgentMode
this.showAttribution = showAttribution
this.showInstructions = showInstructions
this.extraPartnerParams = extraPartnerParams
}
}

Expand Down Expand Up @@ -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 })
},
Expand Down Expand Up @@ -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<String, String>?
get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS)
set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value)

private var Bundle.smileIDResult: SmileIDResult<BiometricKycResult>
get() = getParcelableCompat(KEY_RESULT)!!
set(value) = putParcelable(KEY_RESULT, value)
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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<String, String>? = 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
}
}

Expand All @@ -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 })
},
Expand All @@ -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
Expand Down Expand Up @@ -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<String, String>?
get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS)
set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value)

private var Bundle.smileIDResult: SmileIDResult<DocumentVerificationResult>
get() = getParcelableCompat(KEY_RESULT)!!
set(value) = putParcelable(KEY_RESULT, value)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String, String>? = 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
}
}

Expand All @@ -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 })
},
Expand All @@ -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
Expand All @@ -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<String, String>?
get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS)
set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value)

private var Bundle.smileIDResult: SmileIDResult<EnhancedDocumentVerificationResult>
get() = getParcelableCompat(DocumentVerificationFragment.KEY_RESULT)!!
set(value) = putParcelable(DocumentVerificationFragment.KEY_RESULT, value)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,12 +82,16 @@ class SmartSelfieAuthenticationFragment : Fragment() {
jobId: String = randomJobId(),
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
extraPartnerParams: HashMap<String, String>? = null,
) = SmartSelfieAuthenticationFragment().apply {
arguments = Bundle().apply {
this.userId = userId
this.jobId = jobId
this.allowAgentMode = allowAgentMode
this.showAttribution = showAttribution
this.showInstructions = showInstructions
this.extraPartnerParams = extraPartnerParams
}
}

Expand All @@ -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 })
},
Expand Down Expand Up @@ -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<String, String>?
get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS)
set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value)

private var Bundle.smileIdResult: SmileIDResult<SmartSelfieResult>
get() = getParcelableCompat(KEY_RESULT)!!
set(value) = putParcelable(KEY_RESULT, value)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -83,13 +85,15 @@ class SmartSelfieEnrollmentFragment : Fragment() {
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
extraPartnerParams: HashMap<String, String>? = null,
) = SmartSelfieEnrollmentFragment().apply {
arguments = Bundle().apply {
this.userId = userId
this.jobId = jobId
this.allowAgentMode = allowAgentMode
this.showAttribution = showAttribution
this.showInstructions = showInstructions
this.extraPartnerParams = extraPartnerParams
}
}

Expand All @@ -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 })
},
Expand Down Expand Up @@ -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<String, String>?
get() = getSerializableCompat(KEY_EXTRA_PARTNER_PARAMS)
set(value) = putSerializable(KEY_EXTRA_PARTNER_PARAMS, value)

private var Bundle.smileIdResult: SmileIDResult<SmartSelfieResult>
get() = getParcelableCompat(KEY_RESULT)!!
set(value) = putParcelable(KEY_RESULT, value)

0 comments on commit 4c18d41

Please sign in to comment.