Add missing screenshot and improve UX when user enter wrong pin then correct pin.

This commit is contained in:
Benoit Marty 2026-05-06 14:48:55 +02:00 committed by Benoit Marty
parent ab48f761e1
commit f529f49e3c
2 changed files with 42 additions and 23 deletions

View file

@ -20,7 +20,7 @@ open class PinUnlockStateProvider : PreviewParameterProvider<PinUnlockState> {
override val values: Sequence<PinUnlockState>
get() = sequenceOf(
aPinUnlockState(),
aPinUnlockState(pinEntry = PinEntry.createEmpty(4).fillWith("12")),
aPinUnlockState(pinEntry = AsyncData.Success(PinEntry.createEmpty(4).fillWith("12"))),
aPinUnlockState(showWrongPinTitle = true),
aPinUnlockState(showSignOutPrompt = true),
aPinUnlockState(showBiometricUnlock = false),
@ -31,11 +31,18 @@ open class PinUnlockStateProvider : PreviewParameterProvider<PinUnlockState> {
BiometricUnlockError(BiometricPrompt.ERROR_LOCKOUT, "Biometric auth disabled")
)
),
aPinUnlockState(showSignOutPrompt = true, pinEntry = AsyncData.Failure(Exception("An error occurred"))),
// User enter wrong pin once, and then correct PIN. In this case, the error (with counter reset to 3) should not be displayed.
aPinUnlockState(
remainingAttempts = AsyncData.Success(2),
showWrongPinTitle = true,
isUnlocked = true,
),
)
}
fun aPinUnlockState(
pinEntry: PinEntry = PinEntry.createEmpty(4),
pinEntry: AsyncData<PinEntry> = AsyncData.Success(PinEntry.createEmpty(4)),
remainingAttempts: AsyncData<Int> = AsyncData.Success(3),
showWrongPinTitle: Boolean = false,
showSignOutPrompt: Boolean = false,
@ -44,7 +51,7 @@ fun aPinUnlockState(
isUnlocked: Boolean = false,
signOutAction: AsyncAction<Unit> = AsyncAction.Uninitialized,
) = PinUnlockState(
pinEntry = AsyncData.Success(pinEntry),
pinEntry = pinEntry,
showWrongPinTitle = showWrongPinTitle,
remainingAttempts = remainingAttempts,
showSignOutPrompt = showSignOutPrompt,

View file

@ -311,15 +311,27 @@ private fun PinUnlockHeader(
)
Spacer(Modifier.height(8.dp))
val remainingAttempts = state.remainingAttempts.dataOrNull()
val subtitle = if (remainingAttempts != null) {
if (state.showWrongPinTitle) {
pluralStringResource(id = R.plurals.screen_app_lock_subtitle_wrong_pin, count = remainingAttempts, remainingAttempts)
} else {
pluralStringResource(id = R.plurals.screen_app_lock_subtitle, count = remainingAttempts, remainingAttempts)
}
} else {
val subtitle = when {
state.isUnlocked -> {
// Hide any previous error
""
}
remainingAttempts != null ->
if (state.showWrongPinTitle) {
pluralStringResource(
id = R.plurals.screen_app_lock_subtitle_wrong_pin,
count = remainingAttempts,
remainingAttempts,
)
} else {
pluralStringResource(
id = R.plurals.screen_app_lock_subtitle,
count = remainingAttempts,
remainingAttempts,
)
}
else -> ""
}
val subtitleColor = if (state.showWrongPinTitle) {
ElementTheme.colors.textCriticalPrimary
} else {