Skip to content

Commit

Permalink
[Identity] Remove all parameters for Scan and Upload destinations (#7555
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ccen-stripe committed Nov 16, 2023
1 parent 32e3ff7 commit 2ccb804
Show file tree
Hide file tree
Showing 27 changed files with 813 additions and 1,371 deletions.
12 changes: 6 additions & 6 deletions identity/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>CyclomaticComplexMethod:CameraScreenLaunchedEffect.kt$@Composable internal fun CameraScreenLaunchedEffect( identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel, verificationPage: VerificationPage, navController: NavController, cameraManager: IdentityCameraManager, onCameraReady: () -> Unit )</ID>
<ID>CyclomaticComplexMethod:DocumenetScanScreen.kt$@Composable internal fun DocumentScanScreen( navController: NavController, identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel, frontScanType: IdentityScanState.ScanType, backScanType: IdentityScanState.ScanType?, shouldStartFromBack: Boolean, messageRes: DocumentScanMessageRes, collectedDataParamType: CollectedDataParam.Type, route: String )</ID>
<ID>CyclomaticComplexMethod:IdentityTopLevelDestination.kt$internal fun String.routeToScreenName(): String</ID>
<ID>CyclomaticComplexMethod:IdentityViewModel.kt$IdentityViewModel$fun updateNewScanType(scanType: IdentityScanState.ScanType)</ID>
<ID>CyclomaticComplexMethod:OTPScreen.kt$@Composable internal fun OTPScreen( navController: NavController, identityViewModel: IdentityViewModel, otpViewModelFactory: ViewModelProvider.Factory = OTPViewModel.Factory( identityRepository = identityViewModel.identityRepository, verificationArgs = identityViewModel.verificationArgs ) )</ID>
<ID>CyclomaticComplexMethod:UploadScreen.kt$@Composable internal fun UploadScreen( navController: NavController, identityViewModel: IdentityViewModel, collectedDataParamType: CollectedDataParam.Type, route: String, @StringRes titleRes: Int, @StringRes contextRes: Int, frontInfo: DocumentUploadSideInfo, backInfo: DocumentUploadSideInfo? )</ID>
<ID>CyclomaticComplexMethod:UploadScreen.kt$@Composable internal fun UploadScreen( navController: NavController, identityViewModel: IdentityViewModel, )</ID>
<ID>LargeClass:IdentityViewModel.kt$IdentityViewModel : AndroidViewModel</ID>
<ID>LargeClass:IdentityViewModelTest.kt$IdentityViewModelTest</ID>
<ID>LongMethod:AddressSection.kt$@Composable internal fun AddressSection( enabled: Boolean, identityViewModel: IdentityViewModel, addressCountries: List&lt;Country>, addressNotListedText: String, navController: NavController, onAddressCollected: (Resource&lt;RequiredInternationalAddress>) -> Unit )</ID>
<ID>LongMethod:CameraScreenLaunchedEffect.kt$@Composable internal fun CameraScreenLaunchedEffect( identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel, verificationPage: VerificationPage, navController: NavController, cameraManager: IdentityCameraManager, onCameraReady: () -> Unit )</ID>
<ID>LongMethod:CameraScreenLaunchedEffectLight.kt$@Composable internal fun CameraScreenLaunchedEffectLight( identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel, verificationPage: VerificationPage, navController: NavController )</ID>
<ID>LongMethod:ConfirmationScreen.kt$@Composable internal fun ConfirmationScreen( navController: NavController, identityViewModel: IdentityViewModel, verificationFlowFinishable: VerificationFlowFinishable )</ID>
<ID>LongMethod:ConsentScreen.kt$@Composable private fun SuccessUI( merchantLogoUri: Uri, consentPage: VerificationPageStaticContentConsentPage, bottomSheets: Map&lt;String, VerificationPageStaticContentBottomSheetContent>?, visitedIndividualWelcomePage: Boolean, onConsentAgreed: () -> Unit, onConsentDeclined: () -> Unit )</ID>
<ID>LongMethod:ConsentWelcomeHeader.kt$@Composable internal fun ConsentWelcomeHeader( modifier: Modifier = Modifier, merchantLogoUri: Uri, title: String?, showLogos: Boolean = true )</ID>
<ID>LongMethod:DebugScreen.kt$@Composable internal fun CompleteWithTestDataSection( onClickSubmit: (CompleteOption) -> Unit )</ID>
<ID>LongMethod:DebugScreen.kt$@Composable internal fun DebugScreen( navController: NavController, identityViewModel: IdentityViewModel, verificationFlowFinishable: VerificationFlowFinishable )</ID>
<ID>LongMethod:DocSelectionScreen.kt$@Composable internal fun DocSelectionScreen( navController: NavController, identityViewModel: IdentityViewModel, cameraPermissionEnsureable: CameraPermissionEnsureable )</ID>
<ID>LongMethod:DocumenetScanScreen.kt$@Composable internal fun DocumentScanScreen( navController: NavController, identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel, frontScanType: IdentityScanState.ScanType, backScanType: IdentityScanState.ScanType?, shouldStartFromBack: Boolean, messageRes: DocumentScanMessageRes, collectedDataParamType: CollectedDataParam.Type, route: String )</ID>
<ID>LongMethod:DocumentScanScreen.kt$@Composable internal fun DocumentScanScreen( navController: NavController, identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel )</ID>
<ID>LongMethod:DocumentScanScreen.kt$@Composable private fun ScanScreen( newDisplayState: IdentityScanState?, documentScannerState: IdentityScanViewModel.State, targetScanType: IdentityScanState.ScanType?, identityScanViewModel: IdentityScanViewModel, identityViewModel: IdentityViewModel, lifecycleOwner: LifecycleOwner, cameraManager: IdentityCameraManager, onContinueClick: () -> Unit )</ID>
<ID>LongMethod:ErrorScreen.kt$@Composable internal fun ErrorScreen( identityViewModel: IdentityViewModel, title: String, modifier: Modifier = Modifier, message1: String? = null, message2: String? = null, topButton: ErrorScreenButton? = null, bottomButton: ErrorScreenButton? = null, )</ID>
<ID>LongMethod:IDDetectorAnalyzer.kt$IDDetectorAnalyzer$override suspend fun analyze( data: AnalyzerInput, state: IdentityScanState ): AnalyzerOutput</ID>
<ID>LongMethod:IDNumberSection.kt$@Composable internal fun IDNumberSection( enabled: Boolean, idNumberCountries: List&lt;Country>, countryNotListedText: String, navController: NavController, onIdNumberCollected: (Resource&lt;IdNumberParam>) -> Unit )</ID>
<ID>LongMethod:IdentityActivity.kt$IdentityActivity$@ExperimentalMaterialApi override fun onCreate(savedInstanceState: Bundle?)</ID>
<ID>LongMethod:IdentityNavGraph.kt$@Composable @ExperimentalMaterialApi internal fun IdentityNavGraph( navController: NavHostController = rememberNavController(), identityViewModel: IdentityViewModel, fallbackUrlLauncher: FallbackUrlLauncher, appSettingsOpenable: AppSettingsOpenable, cameraPermissionEnsureable: CameraPermissionEnsureable, verificationFlowFinishable: VerificationFlowFinishable, identityScanViewModelFactory: IdentityScanViewModel.IdentityScanViewModelFactory, onTopBarNavigationClick: () -> Unit, topBarState: IdentityTopBarState, onNavControllerCreated: (NavController) -> Unit )</ID>
<ID>LongMethod:IdentityViewModel.kt$IdentityViewModel$internal fun uploadScanResult( result: IdentityAggregator.FinalResult, verificationPage: VerificationPage, targetScanType: IdentityScanState.ScanType? )</ID>
<ID>LongMethod:IdentityViewModel.kt$IdentityViewModel$internal fun uploadScanResult( result: IdentityAggregator.FinalResult, verificationPage: VerificationPage )</ID>
<ID>LongMethod:IdentityViewModel.kt$IdentityViewModel$private fun uploadDocumentImagesAndNotify( imageFile: File, filePurpose: StripeFilePurpose, uploadMethod: UploadMethod, scores: List&lt;Float>? = null, isHighRes: Boolean, isFront: Boolean, scanType: IdentityScanState.ScanType, compressionQuality: Float )</ID>
<ID>LongMethod:IdentityViewModel.kt$IdentityViewModel$suspend fun postVerificationPageDataForDocSelection( type: CollectedDataParam.Type, navController: NavController, viewLifecycleOwner: LifecycleOwner, cameraPermissionEnsureable: CameraPermissionEnsureable )</ID>
<ID>LongMethod:IdentityViewModelTest.kt$IdentityViewModelTest$private fun testUploadDocumentScanSuccessResult(isFront: Boolean)</ID>
Expand All @@ -35,7 +35,7 @@
<ID>LongMethod:OTPScreen.kt$@Composable private fun OTPViewStateEffect( viewState: OTPViewState?, navController: NavController, identityViewModel: IdentityViewModel, viewModel: OTPViewModel, focusRequester: FocusRequester )</ID>
<ID>LongMethod:SelfieScreen.kt$@Composable internal fun SelfieScanScreen( navController: NavController, identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel, )</ID>
<ID>LongMethod:SelfieScreen.kt$@Composable private fun ResultView( displayState: IdentityScanState, allowImageCollectionHtml: String, isSubmittingSelfie: Boolean, allowImageCollection: Boolean, navController: NavController, onAllowImageCollectionChanged: (Boolean) -> Unit )</ID>
<ID>LongMethod:UploadScreen.kt$@Composable internal fun UploadScreen( navController: NavController, identityViewModel: IdentityViewModel, collectedDataParamType: CollectedDataParam.Type, route: String, @StringRes titleRes: Int, @StringRes contextRes: Int, frontInfo: DocumentUploadSideInfo, backInfo: DocumentUploadSideInfo? )</ID>
<ID>LongMethod:UploadScreen.kt$@Composable internal fun UploadScreen( navController: NavController, identityViewModel: IdentityViewModel, )</ID>
<ID>MagicNumber:DefaultIdentityIO.kt$DefaultIdentityIO$100</ID>
<ID>MagicNumber:DefaultIdentityIO.kt$DefaultIdentityIO$5</ID>
<ID>MagicNumber:DobParam.kt$DobParam.Companion$4</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,8 @@ internal class IdentityAnalyticsRequestFactory @Inject constructor(
)
)

fun cameraPermissionGranted(
scanType: IdentityScanState.ScanType
) = requestFactory.createRequest(
eventName = EVENT_CAMERA_PERMISSION_GRANTED,
additionalParams = additionalParamWithEventMetadata(
PARAM_SCAN_TYPE to scanType.toParam()
)
fun cameraPermissionGranted() = requestFactory.createRequest(
eventName = EVENT_CAMERA_PERMISSION_GRANTED
)

fun documentTimeout(
Expand Down Expand Up @@ -247,21 +242,15 @@ internal class IdentityAnalyticsRequestFactory @Inject constructor(

private fun IdentityScanState.ScanType.toParam(): String =
when (this) {
IdentityScanState.ScanType.ID_FRONT -> ID
IdentityScanState.ScanType.ID_BACK -> ID
IdentityScanState.ScanType.PASSPORT -> PASSPORT
IdentityScanState.ScanType.DL_FRONT -> DRIVER_LICENSE
IdentityScanState.ScanType.DL_BACK -> DRIVER_LICENSE
IdentityScanState.ScanType.DOC_FRONT -> DOC_FRONT
IdentityScanState.ScanType.DOC_BACK -> DOC_BACK
IdentityScanState.ScanType.SELFIE -> SELFIE
}

private fun IdentityScanState.ScanType.toSide(): String =
when (this) {
IdentityScanState.ScanType.ID_FRONT -> FRONT
IdentityScanState.ScanType.ID_BACK -> BACK
IdentityScanState.ScanType.PASSPORT -> FRONT
IdentityScanState.ScanType.DL_FRONT -> FRONT
IdentityScanState.ScanType.DL_BACK -> BACK
IdentityScanState.ScanType.DOC_FRONT -> FRONT
IdentityScanState.ScanType.DOC_BACK -> BACK
else -> {
throw IllegalArgumentException("Unknown type: $this")
}
Expand All @@ -271,8 +260,8 @@ internal class IdentityAnalyticsRequestFactory @Inject constructor(
const val CLIENT_ID = "mobile-identity-sdk"
const val ORIGIN = "stripe-identity-android"
const val ID = "id"
const val PASSPORT = "passport"
const val DRIVER_LICENSE = "driver_license"
const val DOC_FRONT = "doc_front"
const val DOC_BACK = "doc_front"
const val SELFIE = "selfie"
const val FRONT = "front"
const val BACK = "back"
Expand Down Expand Up @@ -334,14 +323,10 @@ internal class IdentityAnalyticsRequestFactory @Inject constructor(

const val SCREEN_NAME_CONSENT = "consent"
const val SCREEN_NAME_DOC_SELECT = "document_select"
const val SCREEN_NAME_LIVE_CAPTURE_PASSPORT = "live_capture_passport"
const val SCREEN_NAME_LIVE_CAPTURE_ID = "live_capture_id"
const val SCREEN_NAME_LIVE_CAPTURE_DRIVER_LICENSE = "live_capture_driver_license"
const val SCREEN_NAME_FILE_UPLOAD_PASSPORT = "file_upload_passport"
const val SCREEN_NAME_FILE_UPLOAD_ID = "file_upload_id"
const val SCREEN_NAME_FILE_UPLOAD_DRIVER_LICENSE = "file_upload_driver_license"
const val SCREEN_NAME_SELFIE_WARMUP = "selfie_warmup"
const val SCREEN_NAME_SELFIE = "selfie"
const val SCREEN_NAME_LIVE_CAPTURE = "live_capture"
const val SCREEN_NAME_FILE_UPLOAD = "file_upload"
const val SCREEN_NAME_CONFIRMATION = "confirmation"
const val SCREEN_NAME_ERROR = "error"
const val SCREEN_NAME_INDIVIDUAL = "individual"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,30 @@ package com.stripe.android.identity.navigation
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavType
import androidx.navigation.navArgument
import com.stripe.android.identity.states.IdentityScanState

internal class CouldNotCaptureDestination(
scanType: IdentityScanState.ScanType,
requireLiveCapture: Boolean
fromSelfie: Boolean
) : IdentityTopLevelDestination() {
override val destinationRoute = ROUTE
override val routeWithArgs = destinationRoute.withParams(
ARG_COULD_NOT_CAPTURE_SCAN_TYPE to scanType,
ARG_REQUIRE_LIVE_CAPTURE to requireLiveCapture
ARG_FROM_SELFIE to fromSelfie
)

companion object {
const val COULD_NOT_CAPTURE = "CouldNotCapture"
const val ARG_COULD_NOT_CAPTURE_SCAN_TYPE = "scanType"
const val ARG_REQUIRE_LIVE_CAPTURE = "requireLiveCapture"
const val ARG_FROM_SELFIE = "fromSelfie"

val ROUTE = object : DestinationRoute() {
override val routeBase = COULD_NOT_CAPTURE

override val arguments = listOf(
navArgument(ARG_COULD_NOT_CAPTURE_SCAN_TYPE) {
type = NavType.EnumType(IdentityScanState.ScanType::class.java)
},
navArgument(ARG_REQUIRE_LIVE_CAPTURE) {
navArgument(ARG_FROM_SELFIE) {
type = NavType.BoolType
}
)
}

fun couldNotCaptureScanType(backStackEntry: NavBackStackEntry) =
backStackEntry.arguments?.getSerializable(
ARG_COULD_NOT_CAPTURE_SCAN_TYPE
) as IdentityScanState.ScanType

fun requireLiveCapture(backStackEntry: NavBackStackEntry) =
backStackEntry.getBooleanArgument(ARG_REQUIRE_LIVE_CAPTURE)
fun fromSelfie(backStackEntry: NavBackStackEntry) =
backStackEntry.getBooleanArgument(ARG_FROM_SELFIE)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.stripe.android.identity.navigation

internal object DocumentUploadDestination : IdentityTopLevelDestination(
popUpToParam = PopUpToParam(
route = DocSelectionDestination.ROUTE.route,
inclusive = false
)
) {
val ROUTE = object : DestinationRoute() {
override val routeBase = UPLOAD
}

override val destinationRoute = ROUTE
}
Loading

0 comments on commit 2ccb804

Please sign in to comment.