From 87e506a9e7e16128bf59a1fa84679b8375c6c7ff Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 4 May 2023 12:59:56 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../userWalletList/UserWalletsListError.kt | 5 ++ .../BiometricUserWalletsKeysRepository.kt | 2 + .../ui/WalletSelectorBottomSheetFragment.kt | 2 + .../ui/WalletSelectorViewModel.kt | 4 ++ .../BiometricsDisabledWarningContent.kt | 55 +++++++++++++++++++ .../walletSelector/ui/model/DialogModel.kt | 5 ++ .../features/welcome/ui/WelcomeViewModel.kt | 4 ++ .../welcome/ui/components/WarningDialog.kt | 36 +++++++++++- .../features/welcome/ui/model/WarningModel.kt | 5 ++ core/res/src/main/res/values-ru/strings.xml | 1 + core/res/src/main/res/values/strings.xml | 1 + 11 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/BiometricsDisabledWarningContent.kt diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListError.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListError.kt index c73891df83..ec9ed95b1d 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListError.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListError.kt @@ -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" } diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/BiometricUserWalletsKeysRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/BiometricUserWalletsKeysRepository.kt index 5d39710ca7..affeeeef57 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/BiometricUserWalletsKeysRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/BiometricUserWalletsKeysRepository.kt @@ -48,6 +48,8 @@ internal class BiometricUserWalletsKeysRepository( UserWalletsListError.BiometricsAuthenticationLockout(isPermanent = true) is TangemSdkError.BiometricCryptographyKeyInvalidated -> UserWalletsListError.EncryptionKeyInvalidated + is TangemSdkError.BiometricsUnavailable -> + UserWalletsListError.BiometricsAuthenticationDisabled else -> error } } diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorBottomSheetFragment.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorBottomSheetFragment.kt index 9f82671d66..4f24d56193 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorBottomSheetFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorBottomSheetFragment.kt @@ -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 RenameWalletDialogContent(dialog) is WarningModel.BiometricsLockoutWarning -> BiometricsLockoutWarningContent(dialog) is WarningModel.KeyInvalidatedWarning -> KeyInvalidatedWarningContent(dialog) + is WarningModel.BiometricsDisabledWarning -> BiometricsDisabledWarningContent(dialog) } } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorViewModel.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorViewModel.kt index 2637e44e3b..99024dad35 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorViewModel.kt @@ -199,6 +199,10 @@ internal class WalletSelectorViewModel : ViewModel(), StoreSubscriber WarningModel.KeyInvalidatedWarning( onDismiss = this::dismissWarningDialog, ) + is UserWalletsListError.BiometricsAuthenticationDisabled -> WarningModel.BiometricsDisabledWarning( + onConfirm = { /* [REDACTED_TODO_COMMENT] */ }, + onDismiss = this::dismissWarningDialog, + ) else -> currentDialog } } diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/BiometricsDisabledWarningContent.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/BiometricsDisabledWarningContent.kt new file mode 100644 index 0000000000..429ab5471e --- /dev/null +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/BiometricsDisabledWarningContent.kt @@ -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 \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/model/DialogModel.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/model/DialogModel.kt index 8024e00021..b458313c35 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/model/DialogModel.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/model/DialogModel.kt @@ -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 } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/welcome/ui/WelcomeViewModel.kt b/app/src/main/java/com/tangem/tap/features/welcome/ui/WelcomeViewModel.kt index 3687df607c..e19891caa2 100644 --- a/app/src/main/java/com/tangem/tap/features/welcome/ui/WelcomeViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/welcome/ui/WelcomeViewModel.kt @@ -71,6 +71,10 @@ internal class WelcomeViewModel : ViewModel(), StoreSubscriber { is UserWalletsListError.EncryptionKeyInvalidated -> WarningModel.KeyInvalidatedWarning( onDismiss = this::dismissWarning, ) + is UserWalletsListError.BiometricsAuthenticationDisabled -> WarningModel.BiometricsDisabledWarning( + onConfirm = { /* [REDACTED_TODO_COMMENT] */ }, + onDismiss = this::dismissWarning, + ) else -> null } } diff --git a/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WarningDialog.kt b/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WarningDialog.kt index 40ae13b0cb..d8a78e246f 100644 --- a/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WarningDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WarningDialog.kt @@ -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 \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/welcome/ui/model/WarningModel.kt b/app/src/main/java/com/tangem/tap/features/welcome/ui/model/WarningModel.kt index 4940a4642a..55789fe91a 100644 --- a/app/src/main/java/com/tangem/tap/features/welcome/ui/model/WarningModel.kt +++ b/app/src/main/java/com/tangem/tap/features/welcome/ui/model/WarningModel.kt @@ -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 } \ No newline at end of file diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index f4d33131ce..e27b0df710 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -27,6 +27,7 @@ Пожалуйста, отсканируйте карту Пожалуйста, попробуйте снова через 30 секунд или отсканируйте карту Слишком много попыток + Вы отключили биометрическую аутентификацию на вашем телефоне и не сможете сохранять кошельки в приложении. Для сохранения кошельков, пожалуйста, включите функцию биометрической аутентификации в настройках телефона. Отключите эту опцию, если не хотите, чтобы эта карта использовалась для сброса кодов доступа на другие карты этого кошелька. Обратите внимание, сброс кода также не будет доступен на этой карте. Использовать эту карту для сброса кода доступа на других картах в этом кошельке Отключить возможность сброса кода доступа на этой карте или других картах этого кошелька diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index d2534d92f5..eda6534993 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -27,6 +27,7 @@ Please scan the card Please try again in 30 seconds or scan the card Too many attempts + 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. 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. 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. Allows you to use this card to reset access code on other cards in this wallet Disable the ability to reset access code on this card or other cards in this wallet