Updated on 2026-08-14

This commit is contained in:
Tangem 2023-05-04 12:59:56 +03:00
parent 48ef51b445
commit 87e506a9e7
11 changed files with 118 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import com.tangem.common.core.TangemError
import com.tangem.wallet.R
sealed class UserWalletsListError(code: Int) : TangemError(code) {
override val silent: Boolean
get() = (cause as? TangemError)?.silent == true
@ -18,6 +19,10 @@ sealed class UserWalletsListError(code: Int) : TangemError(code) {
override var customMessage: String = "Encryption key invalidated"
}
object BiometricsAuthenticationDisabled : UserWalletsListError(code = 60005) {
override var customMessage: String = "Biometrics authentication disabled"
}
data class BiometricsAuthenticationLockout(val isPermanent: Boolean) : UserWalletsListError(code = 60003) {
override var customMessage: String = "Biometric authentication lockout, permanent: $isPermanent"
}

View file

@ -48,6 +48,8 @@ internal class BiometricUserWalletsKeysRepository(
UserWalletsListError.BiometricsAuthenticationLockout(isPermanent = true)
is TangemSdkError.BiometricCryptographyKeyInvalidated ->
UserWalletsListError.EncryptionKeyInvalidated
is TangemSdkError.BiometricsUnavailable ->
UserWalletsListError.BiometricsAuthenticationDisabled
else -> error
}
}

View file

@ -25,6 +25,7 @@ import com.tangem.core.ui.fragments.ComposeBottomSheetFragment
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.common.analytics.events.MyWallets
import com.tangem.tap.features.details.ui.cardsettings.resolveReference
import com.tangem.tap.features.walletSelector.ui.components.BiometricsDisabledWarningContent
import com.tangem.tap.features.walletSelector.ui.components.BiometricsLockoutWarningContent
import com.tangem.tap.features.walletSelector.ui.components.KeyInvalidatedWarningContent
import com.tangem.tap.features.walletSelector.ui.components.RemoveWalletDialogContent
@ -96,6 +97,7 @@ internal class WalletSelectorBottomSheetFragment : ComposeBottomSheetFragment<Wa
is DialogModel.RenameWalletDialog -> RenameWalletDialogContent(dialog)
is WarningModel.BiometricsLockoutWarning -> BiometricsLockoutWarningContent(dialog)
is WarningModel.KeyInvalidatedWarning -> KeyInvalidatedWarningContent(dialog)
is WarningModel.BiometricsDisabledWarning -> BiometricsDisabledWarningContent(dialog)
}
}
}

View file

@ -199,6 +199,10 @@ internal class WalletSelectorViewModel : ViewModel(), StoreSubscriber<WalletSele
is UserWalletsListError.EncryptionKeyInvalidated -> WarningModel.KeyInvalidatedWarning(
onDismiss = this::dismissWarningDialog,
)
is UserWalletsListError.BiometricsAuthenticationDisabled -> WarningModel.BiometricsDisabledWarning(
onConfirm = { /* [REDACTED_TODO_COMMENT] */ },
onDismiss = this::dismissWarningDialog,
)
else -> currentDialog
}
}

View file

@ -0,0 +1,55 @@
package com.tangem.tap.features.walletSelector.ui.components
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.tangem.core.ui.components.BasicDialog
import com.tangem.core.ui.components.DialogButton
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.features.walletSelector.ui.model.WarningModel
import com.tangem.wallet.R
@Composable
internal fun BiometricsDisabledWarningContent(warning: WarningModel.BiometricsDisabledWarning) {
BasicDialog(
title = stringResource(id = R.string.common_warning),
message = stringResource(id = R.string.biometric_unavailable_warning),
onDismissDialog = warning.onDismiss,
confirmButton = DialogButton(
title = stringResource(id = R.string.common_ok),
onClick = warning.onDismiss,
),
)
}
// region Preview
@Composable
private fun BiometricsDisabledWarningContentSample(modifier: Modifier = Modifier) {
Column(modifier = modifier) {
BiometricsDisabledWarningContent(
warning = WarningModel.BiometricsDisabledWarning(
onConfirm = {},
onDismiss = {},
),
)
}
}
@Preview(showBackground = true, widthDp = 360)
@Composable
private fun BiometricsDisabledWarningContentPreview_Light() {
TangemTheme {
BiometricsDisabledWarningContentSample()
}
}
@Preview(showBackground = true, widthDp = 360)
@Composable
private fun BiometricsDisabledWarningContentPreview_Dark() {
TangemTheme(isDark = true) {
BiometricsDisabledWarningContentSample()
}
}
// endregion Preview

View file

@ -22,4 +22,9 @@ internal sealed interface WarningModel : DialogModel {
data class KeyInvalidatedWarning(
val onDismiss: () -> Unit,
) : WarningModel
data class BiometricsDisabledWarning(
val onConfirm: () -> Unit,
val onDismiss: () -> Unit,
) : WarningModel
}

View file

@ -71,6 +71,10 @@ internal class WelcomeViewModel : ViewModel(), StoreSubscriber<WelcomeState> {
is UserWalletsListError.EncryptionKeyInvalidated -> WarningModel.KeyInvalidatedWarning(
onDismiss = this::dismissWarning,
)
is UserWalletsListError.BiometricsAuthenticationDisabled -> WarningModel.BiometricsDisabledWarning(
onConfirm = { /* [REDACTED_TODO_COMMENT] */ },
onDismiss = this::dismissWarning,
)
else -> null
}
}

View file

@ -43,6 +43,17 @@ internal fun WarningDialog(warning: WarningModel?) {
),
)
}
is WarningModel.BiometricsDisabledWarning -> {
BasicDialog(
title = stringResource(id = R.string.common_warning),
message = stringResource(id = R.string.biometric_unavailable_warning),
onDismissDialog = warning.onDismiss,
confirmButton = DialogButton(
title = stringResource(id = R.string.common_ok),
onClick = warning.onConfirm,
),
)
}
}
}
@ -103,7 +114,6 @@ private fun BiometricsLockoutDialog_Permanent_Preview_Dark() {
}
}
// region Preview
@Composable
private fun KeyInvalidatedWarningSample(modifier: Modifier = Modifier) {
Column(modifier = modifier) {
@ -126,5 +136,27 @@ private fun KeyInvalidatedWarningPreview_Dark() {
KeyInvalidatedWarningSample()
}
}
// endregion Preview
@Composable
private fun BiometricDisabledWarningSample(modifier: Modifier = Modifier) {
Column(modifier = modifier) {
WarningDialog(warning = WarningModel.BiometricsDisabledWarning(onConfirm = {}, onDismiss = {}))
}
}
@Preview(showBackground = true, widthDp = 360)
@Composable
private fun BiometricDisabledWarningPreview_Light() {
TangemTheme {
BiometricDisabledWarningSample()
}
}
@Preview(showBackground = true, widthDp = 360)
@Composable
private fun BiometricDisabledWarningPreview_Dark() {
TangemTheme(isDark = true) {
BiometricDisabledWarningSample()
}
}
// endregion Preview

View file

@ -9,4 +9,9 @@ internal sealed interface WarningModel {
data class KeyInvalidatedWarning(
val onDismiss: () -> Unit,
) : WarningModel
data class BiometricsDisabledWarning(
val onConfirm: () -> Unit,
val onDismiss: () -> Unit,
) : WarningModel
}

View file

@ -27,6 +27,7 @@
<string name="biometric_lockout_permanent_warning_description">Пожалуйста, отсканируйте карту</string>
<string name="biometric_lockout_warning_description">Пожалуйста, попробуйте снова через 30 секунд или отсканируйте карту</string>
<string name="biometric_lockout_warning_title">Слишком много попыток</string>
<string name="biometric_unavailable_warning">Вы отключили биометрическую аутентификацию на вашем телефоне и не сможете сохранять кошельки в приложении. Для сохранения кошельков, пожалуйста, включите функцию биометрической аутентификации в настройках телефона.</string>
<string name="card_settings_access_code_recovery_disabled_description">Отключите эту опцию, если не хотите, чтобы эта карта использовалась для сброса кодов доступа на другие карты этого кошелька. Обратите внимание, сброс кода также не будет доступен на этой карте.</string>
<string name="card_settings_access_code_recovery_enabled_description">Использовать эту карту для сброса кода доступа на других картах в этом кошельке</string>
<string name="card_settings_access_code_recovery_footer">Отключить возможность сброса кода доступа на этой карте или других картах этого кошелька</string>

View file

@ -27,6 +27,7 @@
<string name="biometric_lockout_permanent_warning_description">Please scan the card</string>
<string name="biometric_lockout_warning_description">Please try again in 30 seconds or scan the card</string>
<string name="biometric_lockout_warning_title">Too many attempts</string>
<string name="biometric_unavailable_warning">You have disabled biometric authentication on your phone and will not be able to save wallets in the app. To save wallets, please enable the biometric authentication function in your phone settings.</string> <string name="biometric_unavailable_warning">You have disabled biometric authentication on your phone and will not be able to save wallets in the app. To save wallets, please enable the biometric authentication function in your phone settings.</string>
<string name="card_settings_access_code_recovery_disabled_description">Disable this option if you don\'t want this card to be used to reset access codes on other cards of this wallet. Note that you will not be able to reset access code on this card as well.</string>
<string name="card_settings_access_code_recovery_enabled_description">Allows you to use this card to reset access code on other cards in this wallet</string>
<string name="card_settings_access_code_recovery_footer">Disable the ability to reset access code on this card or other cards in this wallet</string>