Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-17 12:51:54 +05:00
parent 2746ee308a
commit a139dbca40
22 changed files with 252 additions and 39 deletions

View file

@ -8,6 +8,7 @@ interface WalletActivationComponent : ComposableContentComponent {
data class Params(
val userWalletId: UserWalletId,
val isBackupExists: Boolean,
)
interface Factory : ComponentFactory<Params, WalletActivationComponent>

View file

@ -37,6 +37,7 @@ dependencies {
implementation(projects.domain.settings)
implementation(projects.domain.feedback)
implementation(projects.domain.feedback.models)
implementation(projects.domain.hotWallet)
/** Common */
implementation(projects.common.ui)

View file

@ -14,6 +14,7 @@ import com.tangem.core.ui.message.DialogMessage
import com.tangem.core.ui.message.EventMessageAction
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.settings.ShouldAskPermissionUseCase
import com.tangem.domain.hotwallet.SetAccessCodeSkippedUseCase
import com.tangem.features.hotwallet.addexistingwallet.entry.routing.AddExistingWalletRoute
import com.tangem.features.hotwallet.addexistingwallet.im.port.AddExistingWalletImportComponent
import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedComponent
@ -34,6 +35,7 @@ internal class AddExistingWalletModel @Inject constructor(
private val shouldAskPermissionUseCase: ShouldAskPermissionUseCase,
@GlobalUiMessageSender private val uiMessageSender: UiMessageSender,
private val trackingContextProxy: TrackingContextProxy,
private val setAccessCodeSkippedUseCase: SetAccessCodeSkippedUseCase,
) : Model() {
val hotWalletStepperComponentModelCallback = HotWalletStepperComponentModelCallback()
@ -83,6 +85,12 @@ internal class AddExistingWalletModel @Inject constructor(
}
private fun showSkipAccessCodeWarningDialog() {
val userWalletId = when (val route = currentRoute.value) {
is AddExistingWalletRoute.SetAccessCode -> route.userWalletId
is AddExistingWalletRoute.ConfirmAccessCode -> route.userWalletId
else -> null
}
uiMessageSender.send(
DialogMessage(
message = resourceReference(R.string.access_code_alert_skip_description),
@ -93,7 +101,14 @@ internal class AddExistingWalletModel @Inject constructor(
),
secondAction = EventMessageAction(
title = resourceReference(R.string.access_code_alert_skip_ok),
onClick = { navigateToPushNotificationsOrNext() },
onClick = {
if (userWalletId != null) {
modelScope.launch {
setAccessCodeSkippedUseCase(userWalletId, true)
}
}
navigateToPushNotificationsOrNext()
},
),
shouldDismissOnFirstAction = true,
),

View file

@ -17,6 +17,7 @@ import com.tangem.core.ui.message.DialogMessage
import com.tangem.core.ui.message.EventMessageAction
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.settings.ShouldAskPermissionUseCase
import com.tangem.domain.hotwallet.SetAccessCodeSkippedUseCase
import com.tangem.features.hotwallet.manualbackup.check.ManualBackupCheckComponent
import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedComponent
import com.tangem.features.hotwallet.manualbackup.phrase.ManualBackupPhraseComponent
@ -33,6 +34,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
@Suppress("LongParameterList")
@ModelScoped
internal class WalletActivationModel @Inject constructor(
paramsContainer: ParamsContainer,
@ -41,6 +43,7 @@ internal class WalletActivationModel @Inject constructor(
private val shouldAskPermissionUseCase: ShouldAskPermissionUseCase,
@GlobalUiMessageSender private val uiMessageSender: UiMessageSender,
private val trackingContextProxy: TrackingContextProxy,
private val setAccessCodeSkippedUseCase: SetAccessCodeSkippedUseCase,
) : Model() {
val params = paramsContainer.require<WalletActivationComponent.Params>()
@ -54,8 +57,13 @@ internal class WalletActivationModel @Inject constructor(
val pushNotificationsCallbacks = PushNotificationsCallbacks()
val mobileWalletSetupFinishedModelCallbacks = MobileWalletSetupFinishedModelCallbacks()
val isStartingWithAccessCode = params.isBackupExists
val stackNavigation = StackNavigation<WalletActivationRoute>()
val startRoute = WalletActivationRoute.ManualBackupStart
val startRoute = if (isStartingWithAccessCode) {
WalletActivationRoute.SetAccessCode
} else {
WalletActivationRoute.ManualBackupStart
}
val currentRoute: MutableStateFlow<WalletActivationRoute> = MutableStateFlow(startRoute)
init {
@ -73,7 +81,9 @@ internal class WalletActivationModel @Inject constructor(
is WalletActivationRoute.ManualBackupPhrase -> stackNavigation.pop()
is WalletActivationRoute.ManualBackupCheck -> stackNavigation.pop()
is WalletActivationRoute.ManualBackupCompleted -> Unit
is WalletActivationRoute.SetAccessCode -> Unit
is WalletActivationRoute.SetAccessCode -> if (isStartingWithAccessCode) {
router.pop()
}
is WalletActivationRoute.ConfirmAccessCode -> stackNavigation.pop()
is WalletActivationRoute.PushNotifications -> Unit
is WalletActivationRoute.SetupFinished -> Unit
@ -96,6 +106,8 @@ internal class WalletActivationModel @Inject constructor(
}
private fun showSkipAccessCodeWarningDialog() {
val userWalletId = params.userWalletId
uiMessageSender.send(
DialogMessage(
message = resourceReference(R.string.access_code_alert_skip_description),
@ -106,7 +118,12 @@ internal class WalletActivationModel @Inject constructor(
),
secondAction = EventMessageAction(
title = resourceReference(R.string.access_code_alert_skip_ok),
onClick = { navigateToPushNotificationsOrNext() },
onClick = {
modelScope.launch {
setAccessCodeSkippedUseCase(userWalletId, true)
}
navigateToPushNotificationsOrNext()
},
),
shouldDismissOnFirstAction = true,
),

View file

@ -36,6 +36,7 @@ dependencies {
implementation(deps.jodatime)
implementation(deps.kotlin.immutable.collections)
implementation(deps.reKotlin)
implementation(tangemDeps.hot.core)
implementation(tangemDeps.card.core)
implementation(tangemDeps.blockchain)
implementation(deps.timber)
@ -82,6 +83,7 @@ dependencies {
implementation(projects.domain.networks)
implementation(projects.domain.nft)
implementation(projects.domain.nft.models)
implementation(projects.domain.hotWallet)
implementation(projects.domain.onramp)
implementation(projects.domain.onramp.models)
implementation(projects.domain.promo)

View file

@ -110,7 +110,7 @@ internal interface WalletWarningsClickIntents {
fun onDenyPermissions()
fun onFinishWalletActivationClick(type: WalletActivationBannerType)
fun onFinishWalletActivationClick(bannerType: WalletActivationBannerType, isBackupExists: Boolean)
}
@Suppress("LargeClass", "LongParameterList", "TooManyFunctions")
@ -147,32 +147,6 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
private val uiMessageSender: UiMessageSender,
) : BaseWalletClickIntents(), WalletWarningsClickIntents {
private val finalizeWalletSetupAlertBS
get() = bottomSheetMessage {
infoBlock {
icon(R.drawable.img_knight_shield_32) {
type = MessageBottomSheetUMV2.Icon.Type.Warning
backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.SameAsTint
}
title = resourceReference(R.string.hw_activation_need_title)
body = resourceReference(R.string.hw_activation_need_description)
}
secondaryButton {
text = resourceReference(R.string.common_later)
onClick {
closeBs()
}
}
primaryButton {
text = resourceReference(R.string.hw_activation_need_backup)
onClick {
val userWallet = getSelectedUserWallet() ?: return@onClick
appRouter.push(WalletActivation(userWallet.walletId))
closeBs()
}
}
}
override fun onAddBackupCardClick() {
analyticsEventHandler.send(MainScreen.NoticeBackupYourWalletTapped)
@ -501,14 +475,38 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
}
}
override fun onFinishWalletActivationClick(type: WalletActivationBannerType) {
when (type) {
override fun onFinishWalletActivationClick(bannerType: WalletActivationBannerType, isBackupExists: Boolean) {
when (bannerType) {
WalletActivationBannerType.Attention -> {
val userWallet = getSelectedUserWallet() ?: return
appRouter.push(WalletActivation(userWallet.walletId))
appRouter.push(WalletActivation(userWallet.walletId, isBackupExists))
}
WalletActivationBannerType.Warning -> {
messageSender.send(finalizeWalletSetupAlertBS)
val message = bottomSheetMessage {
infoBlock {
icon(R.drawable.img_knight_shield_32) {
type = MessageBottomSheetUMV2.Icon.Type.Warning
backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.SameAsTint
}
title = resourceReference(R.string.hw_activation_need_title)
body = resourceReference(R.string.hw_activation_need_description)
}
secondaryButton {
text = resourceReference(R.string.common_later)
onClick {
closeBs()
}
}
primaryButton {
text = resourceReference(R.string.hw_activation_need_backup)
onClick {
val userWallet = getSelectedUserWallet() ?: return@onClick
appRouter.push(WalletActivation(userWallet.walletId, isBackupExists))
closeBs()
}
}
}
messageSender.send(message)
}
}
}

View file

@ -31,11 +31,13 @@ import com.tangem.domain.tokens.error.TokenListError
import com.tangem.domain.wallets.models.SeedPhraseNotificationsStatus
import com.tangem.domain.wallets.usecase.IsNeedToBackupUseCase
import com.tangem.domain.wallets.usecase.SeedPhraseNotificationUseCase
import com.tangem.domain.hotwallet.GetAccessCodeSkippedUseCase
import com.tangem.feature.wallet.child.wallet.model.WalletActivationBannerType
import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents
import com.tangem.feature.wallet.impl.R
import com.tangem.feature.wallet.presentation.account.AccountDependencies
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification
import com.tangem.hot.sdk.model.HotWalletId
import com.tangem.lib.crypto.BlockchainUtils.isBitcoin
import com.tangem.utils.extensions.addIf
import com.tangem.utils.extensions.isPositive
@ -62,6 +64,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
private val getOnrampCountryUseCase: GetOnrampCountryUseCase,
private val notificationsRepository: NotificationsRepository,
private val accountDependencies: AccountDependencies,
private val getAccessCodeSkippedUseCase: GetAccessCodeSkippedUseCase,
) {
@Suppress("UNCHECKED_CAST", "MagicNumber")
@ -98,6 +101,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
shouldShowPromoWalletUseCase(userWalletId = userWallet.walletId, promoId = PromoId.VisaPresale),
shouldShowPromoWalletUseCase(userWalletId = userWallet.walletId, promoId = PromoId.Sepa),
notificationsRepository.getShouldShowNotification(NotificationId.EnablePushesReminderNotification.key),
getAccessCodeSkippedUseCase(userWallet.walletId),
) { array -> array }
.combine(tokenListFlow()) { array, any: Any -> arrayOf(any).plus(elements = array) }
.map { array ->
@ -110,13 +114,14 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
val shouldShowVisaPromo = array[4] as Boolean
val shouldShowSepaBanner = array[5] as Boolean
val shouldShowEnablePushesReminderNotification = array[6] as Boolean
val accessCodeSkipped = array[7] as Boolean
buildList {
addUsedOutdatedDataNotification(totalFiatBalance)
addCriticalNotifications(userWallet, seedPhraseIssueStatus, clickIntents)
addFinishWalletActivationNotification(userWallet, totalFiatBalance, clickIntents)
addFinishWalletActivationNotification(userWallet, totalFiatBalance, clickIntents, accessCodeSkipped)
addVisaPresalePromoNotification(clickIntents, shouldShowVisaPromo)
@ -405,10 +410,14 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
userWallet: UserWallet,
totalFiatBalance: Lce<TokenListError, TotalFiatBalance>,
clickIntents: WalletClickIntents,
accessCodeSkipped: Boolean,
) {
if (userWallet !is UserWallet.Hot) return
val shouldShowFinishActivation = !userWallet.backedUp
val isBackupExists = userWallet.backedUp
val isAccessCodeRequired = userWallet.hotWalletId.authType == HotWalletId.AuthType.NoPassword &&
!accessCodeSkipped
val shouldShowFinishActivation = !isBackupExists || isAccessCodeRequired
val type = totalFiatBalance.fold(
ifLoading = { it.getFinishWalletActivationType() },
@ -427,11 +436,11 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
buttonsState = when (type) {
WalletActivationBannerType.Warning -> ButtonsState.PrimaryButtonConfig(
text = resourceReference(R.string.hw_activation_need_finish),
onClick = { clickIntents.onFinishWalletActivationClick(type) },
onClick = { clickIntents.onFinishWalletActivationClick(type, isBackupExists) },
)
else -> ButtonsState.SecondaryButtonConfig(
text = resourceReference(R.string.hw_activation_need_finish),
onClick = { clickIntents.onFinishWalletActivationClick(type) },
onClick = { clickIntents.onFinishWalletActivationClick(type, isBackupExists) },
)
},
),