diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0b2d7e6df6..cf4d86ade8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -162,6 +162,7 @@ dependencies { implementation(projects.domain.walletManager.models) implementation(projects.domain.yieldSupply) implementation(projects.domain.blockaid) + implementation(projects.domain.hotWallet) implementation(projects.common) implementation(projects.common.routing) @@ -212,6 +213,7 @@ dependencies { implementation(projects.data.swap) implementation(projects.data.walletManager) implementation(projects.data.yieldSupply) + implementation(projects.data.hotWallet) /** Features */ implementation(projects.features.referral.impl) diff --git a/app/src/main/java/com/tangem/tap/di/domain/HotWalletDomainModule.kt b/app/src/main/java/com/tangem/tap/di/domain/HotWalletDomainModule.kt new file mode 100644 index 0000000000..57fd8da9ae --- /dev/null +++ b/app/src/main/java/com/tangem/tap/di/domain/HotWalletDomainModule.kt @@ -0,0 +1,27 @@ +package com.tangem.tap.di.domain + +import com.tangem.domain.hotwallet.GetAccessCodeSkippedUseCase +import com.tangem.domain.hotwallet.SetAccessCodeSkippedUseCase +import com.tangem.domain.hotwallet.repository.HotWalletRepository +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal object HotWalletDomainModule { + + @Provides + @Singleton + fun provideGetAccessCodeSkippedUseCase(hotWalletRepository: HotWalletRepository): GetAccessCodeSkippedUseCase { + return GetAccessCodeSkippedUseCase(hotWalletRepository) + } + + @Provides + @Singleton + fun provideSetAccessCodeSkippedUseCase(hotWalletRepository: HotWalletRepository): SetAccessCodeSkippedUseCase { + return SetAccessCodeSkippedUseCase(hotWalletRepository) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt b/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt index 38034af856..a4c618527d 100644 --- a/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt +++ b/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt @@ -551,6 +551,7 @@ internal class ChildFactory @Inject constructor( context = context, params = WalletActivationComponent.Params( userWalletId = route.userWalletId, + isBackupExists = route.isBackupExists, ), componentFactory = walletActivationComponentFactory, ) diff --git a/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt b/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt index 3d827e8a0a..009e76a239 100644 --- a/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt +++ b/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt @@ -358,6 +358,7 @@ sealed class AppRoute(val path: String) : Route { @Serializable data class WalletActivation( val userWalletId: UserWalletId, + val isBackupExists: Boolean, ) : AppRoute(path = "/wallet_activation/${userWalletId.stringValue}") @Serializable diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt index 6e163fbb4c..e392f5c5dc 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt @@ -121,6 +121,8 @@ object PreferencesKeys { val YIELD_SUPPLY_WARNINGS_STATES_KEY by lazy { stringPreferencesKey(name = "yieldSupplyWarningsStates") } + val ACCESS_CODE_SKIPPED_STATES_KEY by lazy { stringPreferencesKey(name = "accessCodeSkippedStates") } + // region Notifications val NOTIFICATIONS_APPLICATION_ID_KEY by lazy { stringPreferencesKey(name = "notificationsApplicationId") } diff --git a/data/hot-wallet/.gitignore b/data/hot-wallet/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/data/hot-wallet/.gitignore @@ -0,0 +1 @@ +/build diff --git a/data/hot-wallet/build.gradle.kts b/data/hot-wallet/build.gradle.kts new file mode 100644 index 0000000000..285d04e10c --- /dev/null +++ b/data/hot-wallet/build.gradle.kts @@ -0,0 +1,27 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) + alias(deps.plugins.hilt.android) + id("configuration") +} + +android { + namespace = "com.tangem.data.hotwallet" +} + +dependencies { + implementation(projects.core.datasource) + implementation(projects.core.utils) + + implementation(projects.domain.hotWallet) + implementation(projects.domain.models) + + implementation(deps.hilt.android) + kapt(deps.hilt.kapt) + + implementation(deps.androidx.datastore) + implementation(deps.kotlin.coroutines) + implementation(deps.moshi) + implementation(deps.moshi.kotlin) +} \ No newline at end of file diff --git a/data/hot-wallet/src/main/java/com/tangem/data/hotwallet/DefaultHotWalletRepository.kt b/data/hot-wallet/src/main/java/com/tangem/data/hotwallet/DefaultHotWalletRepository.kt new file mode 100644 index 0000000000..d4064d0089 --- /dev/null +++ b/data/hot-wallet/src/main/java/com/tangem/data/hotwallet/DefaultHotWalletRepository.kt @@ -0,0 +1,28 @@ +package com.tangem.data.hotwallet + +import com.tangem.datasource.local.preferences.AppPreferencesStore +import com.tangem.datasource.local.preferences.PreferencesKeys +import com.tangem.datasource.local.preferences.utils.getObjectMap +import com.tangem.domain.hotwallet.repository.HotWalletRepository +import com.tangem.domain.models.wallet.UserWalletId +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map + +internal class DefaultHotWalletRepository( + private val appPreferencesStore: AppPreferencesStore, +) : HotWalletRepository { + + override fun accessCodeSkipped(userWalletId: UserWalletId): Flow = appPreferencesStore + .getObjectMap(PreferencesKeys.ACCESS_CODE_SKIPPED_STATES_KEY) + .map { it[userWalletId.stringValue] == true } + + override suspend fun setAccessCodeSkipped(userWalletId: UserWalletId, skipped: Boolean) { + appPreferencesStore.editData { + it.setObjectMap( + key = PreferencesKeys.ACCESS_CODE_SKIPPED_STATES_KEY, + value = it.getObjectMap(PreferencesKeys.ACCESS_CODE_SKIPPED_STATES_KEY) + .plus(userWalletId.stringValue to skipped), + ) + } + } +} \ No newline at end of file diff --git a/data/hot-wallet/src/main/java/com/tangem/data/hotwallet/di/HotWalletDataModule.kt b/data/hot-wallet/src/main/java/com/tangem/data/hotwallet/di/HotWalletDataModule.kt new file mode 100644 index 0000000000..f8c678c0e2 --- /dev/null +++ b/data/hot-wallet/src/main/java/com/tangem/data/hotwallet/di/HotWalletDataModule.kt @@ -0,0 +1,23 @@ +package com.tangem.data.hotwallet.di + +import com.tangem.data.hotwallet.DefaultHotWalletRepository +import com.tangem.datasource.local.preferences.AppPreferencesStore +import com.tangem.domain.hotwallet.repository.HotWalletRepository +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal object HotWalletDataModule { + + @Provides + @Singleton + fun provideHotWalletRepository(appPreferencesStore: AppPreferencesStore): HotWalletRepository { + return DefaultHotWalletRepository( + appPreferencesStore = appPreferencesStore, + ) + } +} \ No newline at end of file diff --git a/domain/hot-wallet/.gitignore b/domain/hot-wallet/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/domain/hot-wallet/.gitignore @@ -0,0 +1 @@ +/build diff --git a/domain/hot-wallet/build.gradle.kts b/domain/hot-wallet/build.gradle.kts new file mode 100644 index 0000000000..471afb3452 --- /dev/null +++ b/domain/hot-wallet/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + id("configuration") +} + +android { + namespace = "com.tangem.domain.hotwallet" +} + +dependencies { + implementation(projects.domain.core) + implementation(projects.domain.models) + implementation(projects.domain.wallets.models) + + implementation(deps.kotlin.coroutines) +} \ No newline at end of file diff --git a/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/GetAccessCodeSkippedUseCase.kt b/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/GetAccessCodeSkippedUseCase.kt new file mode 100644 index 0000000000..9924aa5439 --- /dev/null +++ b/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/GetAccessCodeSkippedUseCase.kt @@ -0,0 +1,14 @@ +package com.tangem.domain.hotwallet + +import com.tangem.domain.hotwallet.repository.HotWalletRepository +import com.tangem.domain.models.wallet.UserWalletId +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.distinctUntilChanged + +class GetAccessCodeSkippedUseCase( + private val hotWalletRepository: HotWalletRepository, +) { + operator fun invoke(userWalletId: UserWalletId): Flow = hotWalletRepository + .accessCodeSkipped(userWalletId) + .distinctUntilChanged() +} \ No newline at end of file diff --git a/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/SetAccessCodeSkippedUseCase.kt b/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/SetAccessCodeSkippedUseCase.kt new file mode 100644 index 0000000000..79b6d991e0 --- /dev/null +++ b/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/SetAccessCodeSkippedUseCase.kt @@ -0,0 +1,13 @@ +package com.tangem.domain.hotwallet + +import arrow.core.Either +import com.tangem.domain.hotwallet.repository.HotWalletRepository +import com.tangem.domain.models.wallet.UserWalletId + +class SetAccessCodeSkippedUseCase( + private val hotWalletRepository: HotWalletRepository, +) { + suspend operator fun invoke(userWalletId: UserWalletId, skipped: Boolean): Either = Either.catch { + hotWalletRepository.setAccessCodeSkipped(userWalletId, skipped) + } +} \ No newline at end of file diff --git a/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/repository/HotWalletRepository.kt b/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/repository/HotWalletRepository.kt new file mode 100644 index 0000000000..5bc636f2dd --- /dev/null +++ b/domain/hot-wallet/src/main/kotlin/com/tangem/domain/hotwallet/repository/HotWalletRepository.kt @@ -0,0 +1,11 @@ +package com.tangem.domain.hotwallet.repository + +import com.tangem.domain.models.wallet.UserWalletId +import kotlinx.coroutines.flow.Flow + +interface HotWalletRepository { + + fun accessCodeSkipped(userWalletId: UserWalletId): Flow + + suspend fun setAccessCodeSkipped(userWalletId: UserWalletId, skipped: Boolean) +} \ No newline at end of file diff --git a/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/WalletActivationComponent.kt b/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/WalletActivationComponent.kt index 8b99c19f36..b92f94c6e0 100644 --- a/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/WalletActivationComponent.kt +++ b/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/WalletActivationComponent.kt @@ -8,6 +8,7 @@ interface WalletActivationComponent : ComposableContentComponent { data class Params( val userWalletId: UserWalletId, + val isBackupExists: Boolean, ) interface Factory : ComponentFactory diff --git a/features/hot-wallet/impl/build.gradle.kts b/features/hot-wallet/impl/build.gradle.kts index 0a0ed7aef6..380b51678e 100644 --- a/features/hot-wallet/impl/build.gradle.kts +++ b/features/hot-wallet/impl/build.gradle.kts @@ -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) diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt index 1d3c4a2762..99114079d4 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt @@ -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, ), diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt index dcbec9f6f5..ae8297cc1b 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt @@ -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() @@ -54,8 +57,13 @@ internal class WalletActivationModel @Inject constructor( val pushNotificationsCallbacks = PushNotificationsCallbacks() val mobileWalletSetupFinishedModelCallbacks = MobileWalletSetupFinishedModelCallbacks() + val isStartingWithAccessCode = params.isBackupExists val stackNavigation = StackNavigation() - val startRoute = WalletActivationRoute.ManualBackupStart + val startRoute = if (isStartingWithAccessCode) { + WalletActivationRoute.SetAccessCode + } else { + WalletActivationRoute.ManualBackupStart + } val currentRoute: MutableStateFlow = 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, ), diff --git a/features/wallet/impl/build.gradle.kts b/features/wallet/impl/build.gradle.kts index 4b2119adcb..ca7ea45cc6 100644 --- a/features/wallet/impl/build.gradle.kts +++ b/features/wallet/impl/build.gradle.kts @@ -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) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletWarningsClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletWarningsClickIntents.kt index ff0397e424..340c7c3d6d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletWarningsClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletWarningsClickIntents.kt @@ -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) } } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt index e21b971fe1..6d3994fe52 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt @@ -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, 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) }, ) }, ), diff --git a/settings.gradle.kts b/settings.gradle.kts index 7703f86c1f..9517b22ba2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -348,6 +348,7 @@ include(":domain:promo") include(":domain:promo:models") include(":domain:nft") include(":domain:nft:models") +include(":domain:hot-wallet") include(":domain:networks") include(":domain:quotes") include(":domain:blockaid") @@ -389,6 +390,7 @@ include(":data:markets") include(":data:manage-tokens") include(":data:networks") include(":data:nft") +include(":data:hot-wallet") include(":data:onramp") include(":data:quotes") include(":data:notifications")