Updated on 2026-08-14
This commit is contained in:
parent
ad65a62b3f
commit
97a13da0d7
19 changed files with 176 additions and 56 deletions
|
|
@ -9,5 +9,5 @@ interface ForceUpdateComponent : ComposableContentComponent {
|
|||
|
||||
data class Params(val mode: Mode)
|
||||
|
||||
enum class Mode { Force, Brick, OsTooOld, Optional }
|
||||
enum class Mode { Force, Brick, OsTooOld }
|
||||
}
|
||||
|
|
@ -33,6 +33,8 @@ dependencies {
|
|||
|
||||
/** Domain modules */
|
||||
implementation(projects.domain.appUpdate)
|
||||
implementation(projects.domain.feedback)
|
||||
implementation(projects.domain.feedback.models)
|
||||
|
||||
/** DI */
|
||||
implementation(deps.hilt.android)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import com.tangem.core.navigation.url.AppStoreOpener
|
|||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.domain.appupdate.model.AppUpdateState
|
||||
import com.tangem.domain.appupdate.usecase.GetAppUpdateStateUseCase
|
||||
import com.tangem.domain.feedback.SendFeedbackEmailUseCase
|
||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
||||
import com.tangem.features.forceupdate.ForceUpdateComponent
|
||||
import com.tangem.features.forceupdate.ForceUpdateContinuation
|
||||
import com.tangem.features.forceupdate.impl.R
|
||||
|
|
@ -25,6 +27,7 @@ internal class ForceUpdateModel @Inject constructor(
|
|||
private val appStoreOpener: AppStoreOpener,
|
||||
private val forceUpdateContinuation: ForceUpdateContinuation,
|
||||
private val getAppUpdateStateUseCase: GetAppUpdateStateUseCase,
|
||||
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
|
||||
paramsContainer: ParamsContainer,
|
||||
) : Model() {
|
||||
|
||||
|
|
@ -43,36 +46,24 @@ internal class ForceUpdateModel @Inject constructor(
|
|||
accent = Accent.Red,
|
||||
title = resourceReference(R.string.force_update_warning_title),
|
||||
description = resourceReference(R.string.force_update_warning_message),
|
||||
isBlocking = true,
|
||||
onUpdateClick = ::onUpdateClick,
|
||||
onLaterClick = null,
|
||||
)
|
||||
ForceUpdateComponent.Mode.Optional -> ForceUpdateUM(
|
||||
mode = mode,
|
||||
accent = Accent.Yellow,
|
||||
title = resourceReference(R.string.force_update_warning_title),
|
||||
description = resourceReference(R.string.force_update_warning_message),
|
||||
isBlocking = false,
|
||||
onUpdateClick = ::onUpdateClick,
|
||||
onLaterClick = ::onLaterClick,
|
||||
onSupportClick = ::onSupportClick,
|
||||
)
|
||||
ForceUpdateComponent.Mode.Brick -> ForceUpdateUM(
|
||||
mode = mode,
|
||||
accent = Accent.Red,
|
||||
title = resourceReference(R.string.force_update_brick_title),
|
||||
description = resourceReference(R.string.force_update_brick_description),
|
||||
isBlocking = true,
|
||||
onUpdateClick = null,
|
||||
onLaterClick = null,
|
||||
onSupportClick = ::onSupportClick,
|
||||
)
|
||||
ForceUpdateComponent.Mode.OsTooOld -> ForceUpdateUM(
|
||||
mode = mode,
|
||||
accent = Accent.Red,
|
||||
title = resourceReference(R.string.force_update_os_title),
|
||||
description = resourceReference(R.string.force_update_os_description),
|
||||
isBlocking = true,
|
||||
onUpdateClick = null,
|
||||
onLaterClick = null,
|
||||
onSupportClick = null,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -80,8 +71,10 @@ internal class ForceUpdateModel @Inject constructor(
|
|||
appStoreOpener.openStorePage()
|
||||
}
|
||||
|
||||
private fun onLaterClick() {
|
||||
forceUpdateContinuation.dismiss()
|
||||
private fun onSupportClick() {
|
||||
modelScope.launch {
|
||||
sendFeedbackEmailUseCase(type = FeedbackEmailType.AppUpdateProblem)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,7 +98,8 @@ internal class ForceUpdateModel @Inject constructor(
|
|||
AppUpdateState.ForceUpdate -> ForceUpdateComponent.Mode.Force
|
||||
AppUpdateState.Brick -> ForceUpdateComponent.Mode.Brick
|
||||
AppUpdateState.OsTooOld -> ForceUpdateComponent.Mode.OsTooOld
|
||||
AppUpdateState.OptionalUpdate -> ForceUpdateComponent.Mode.Optional
|
||||
AppUpdateState.NoUpdate -> null
|
||||
AppUpdateState.OptionalUpdate,
|
||||
AppUpdateState.NoUpdate,
|
||||
-> null
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.features.forceupdate.impl.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
|
|
@ -39,10 +38,6 @@ import com.tangem.features.forceupdate.impl.ui.state.ForceUpdateUM.Accent
|
|||
|
||||
@Composable
|
||||
internal fun ForceUpdateContent(state: ForceUpdateUM, modifier: Modifier = Modifier) {
|
||||
BackHandler(enabled = !state.isBlocking) {
|
||||
state.onLaterClick?.invoke()
|
||||
}
|
||||
|
||||
val accentColor = when (state.accent) {
|
||||
Accent.Red -> TangemTheme.colors3.icon.accent.red
|
||||
Accent.Yellow -> TangemTheme.colors3.icon.accent.yellow
|
||||
|
|
@ -111,6 +106,14 @@ private fun Buttons(state: ForceUpdateUM, modifier: Modifier = Modifier) {
|
|||
modifier = modifier,
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
state.onSupportClick?.let { onClick ->
|
||||
TangemButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
variant = TangemButton.Variant.Secondary,
|
||||
text = resourceReference(R.string.common_contact_support),
|
||||
onClick = onClick,
|
||||
)
|
||||
}
|
||||
state.onUpdateClick?.let { onClick ->
|
||||
TangemButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
|
@ -119,14 +122,6 @@ private fun Buttons(state: ForceUpdateUM, modifier: Modifier = Modifier) {
|
|||
onClick = onClick,
|
||||
)
|
||||
}
|
||||
state.onLaterClick?.let { onClick ->
|
||||
TangemButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
variant = TangemButton.Variant.Secondary,
|
||||
text = resourceReference(R.string.common_later),
|
||||
onClick = onClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -154,9 +149,8 @@ private fun PreviewForce() {
|
|||
accent = Accent.Red,
|
||||
title = TextReference.Str("Update Required"),
|
||||
description = TextReference.Str("Please update the application to the latest version."),
|
||||
isBlocking = true,
|
||||
onUpdateClick = {},
|
||||
onLaterClick = null,
|
||||
onSupportClick = {},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -165,17 +159,16 @@ private fun PreviewForce() {
|
|||
@Preview(showBackground = true, widthDp = 360, heightDp = 780)
|
||||
@Preview(showBackground = true, widthDp = 360, heightDp = 780, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun PreviewOptional() {
|
||||
private fun PreviewBrick() {
|
||||
TangemThemePreviewRedesign {
|
||||
ForceUpdateContent(
|
||||
state = ForceUpdateUM(
|
||||
mode = ForceUpdateComponent.Mode.Optional,
|
||||
accent = Accent.Yellow,
|
||||
title = TextReference.Str("Update Required"),
|
||||
description = TextReference.Str("Please update the application to the latest version."),
|
||||
isBlocking = false,
|
||||
onUpdateClick = {},
|
||||
onLaterClick = {},
|
||||
mode = ForceUpdateComponent.Mode.Brick,
|
||||
accent = Accent.Red,
|
||||
title = TextReference.Str("Device not supported"),
|
||||
description = TextReference.Str("This device can't run the OS version Tangem needs."),
|
||||
onUpdateClick = null,
|
||||
onSupportClick = {},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@ internal data class ForceUpdateUM(
|
|||
val accent: Accent,
|
||||
val title: TextReference,
|
||||
val description: TextReference,
|
||||
val isBlocking: Boolean,
|
||||
val onUpdateClick: (() -> Unit)?,
|
||||
val onLaterClick: (() -> Unit)?,
|
||||
val onSupportClick: (() -> Unit)?,
|
||||
) {
|
||||
|
||||
enum class Accent { Red, Yellow }
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ dependencies {
|
|||
api(projects.domain.analytics)
|
||||
api(projects.domain.appCurrency)
|
||||
api(projects.domain.appTheme)
|
||||
api(projects.domain.appUpdate)
|
||||
api(projects.domain.assetsdiscovery)
|
||||
api(projects.domain.balanceHiding)
|
||||
api(projects.domain.card)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.tangem.core.analytics.models.event.AssetsDiscoveryAnalyticsEvent
|
|||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.ui.UiMessageSender
|
||||
import com.tangem.core.navigation.review.ReviewManager
|
||||
import com.tangem.core.navigation.url.AppStoreOpener
|
||||
import com.tangem.domain.assetsdiscovery.usecase.AcknowledgeAssetsDiscoveryCompletionUseCase
|
||||
import com.tangem.domain.card.SetCardWasScannedUseCase
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
|
|
@ -73,6 +74,8 @@ internal interface WalletWarningsClickIntents {
|
|||
|
||||
fun onSupportClick()
|
||||
|
||||
fun onSoftUpdateClick()
|
||||
|
||||
fun onBackupErrorClick()
|
||||
|
||||
fun onNoteMigrationButtonClick(url: String)
|
||||
|
|
@ -111,6 +114,7 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
|
|||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
private val getWalletMetaInfoUseCase: GetWalletMetaInfoUseCase,
|
||||
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
|
||||
private val appStoreOpener: AppStoreOpener,
|
||||
private val multiNetworkStatusFetcher: MultiNetworkStatusFetcher,
|
||||
private val multiQuoteStatusFetcher: MultiQuoteStatusFetcher,
|
||||
private val multiStakingBalanceFetcher: MultiStakingBalanceFetcher,
|
||||
|
|
@ -248,6 +252,10 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onSoftUpdateClick() {
|
||||
appStoreOpener.openStorePage()
|
||||
}
|
||||
|
||||
override fun onBackupErrorClick() {
|
||||
val userWallet = getSelectedUserWallet() ?: return
|
||||
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ internal class WalletWarningsAnalyticsSender @Inject constructor(
|
|||
WalletNotificationUM.TangemPayUnreachable,
|
||||
is WalletNotificationUM.YieldBoostPromo,
|
||||
is WalletNotificationUM.AssetsDiscoveryCompleted,
|
||||
is WalletNotificationUM.SoftUpdateAvailable,
|
||||
-> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import com.tangem.core.decompose.di.ModelScoped
|
|||
import com.tangem.core.ui.ds.message.TangemMessageEffect
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.domain.account.status.producer.SingleAccountStatusListProducer
|
||||
import com.tangem.domain.appupdate.model.AppUpdateState
|
||||
import com.tangem.domain.appupdate.usecase.GetAppUpdateStateUseCase
|
||||
import com.tangem.domain.assetsdiscovery.model.AssetsDiscoveryProgress
|
||||
import com.tangem.domain.assetsdiscovery.usecase.ObserveAssetsDiscoveryUseCase
|
||||
import com.tangem.domain.card.CardTypesResolver
|
||||
|
|
@ -49,6 +51,7 @@ internal class GetWalletNotificationsFactory @Inject constructor(
|
|||
private val getAccessCodeSkippedUseCase: GetAccessCodeSkippedUseCase,
|
||||
private val hasSingleWalletSignedHashesUseCase: HasSingleWalletSignedHashesUseCase,
|
||||
private val observeAssetsDiscoveryUseCase: ObserveAssetsDiscoveryUseCase,
|
||||
private val getAppUpdateStateUseCase: GetAppUpdateStateUseCase,
|
||||
) {
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntents): Flow<ImmutableList<WalletNotificationUM>> {
|
||||
val cardTypesResolver = (userWallet as? UserWallet.Cold)?.scanResponse?.cardTypesResolver
|
||||
|
|
@ -68,7 +71,8 @@ internal class GetWalletNotificationsFactory @Inject constructor(
|
|||
flow2 = isNeedToBackupUseCase(userWallet.walletId).distinctUntilChanged(),
|
||||
flow3 = getAccessCodeSkippedUseCase(userWallet.walletId).distinctUntilChanged(),
|
||||
flow4 = assetsDiscoveryProgressFlow,
|
||||
) { accountList, isNeedToBackup, shouldAccessCodeSkipped, assetsDiscoveryProgress ->
|
||||
flow5 = getAppUpdateStateUseCase.getBannerStateFlow(),
|
||||
) { accountList, isNeedToBackup, shouldAccessCodeSkipped, assetsDiscoveryProgress, appUpdateState ->
|
||||
val totalFiatBalance = accountList.totalFiatBalance
|
||||
val flattenCurrencies = accountList.flattenCurrencies()
|
||||
|
||||
|
|
@ -126,10 +130,22 @@ internal class GetWalletNotificationsFactory @Inject constructor(
|
|||
walletClickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
addSoftUpdateBanner(appUpdateState, clickIntents)
|
||||
}.sortedBy { it.type.ordinal }.toImmutableList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotificationUM>.addSoftUpdateBanner(
|
||||
appUpdateState: AppUpdateState,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
addIf(
|
||||
element = WalletNotificationUM.SoftUpdateAvailable(onUpdateClick = clickIntents::onSoftUpdateClick),
|
||||
condition = appUpdateState == AppUpdateState.OptionalUpdate,
|
||||
)
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotificationUM>.addUsedOutdatedDataNotification(totalFiatBalance: TotalFiatBalance) {
|
||||
addIf(
|
||||
element = WalletNotificationUM.UsedOutdatedData,
|
||||
|
|
|
|||
|
|
@ -352,6 +352,27 @@ internal sealed class WalletNotificationUM(val messageUM: TangemMessageUM, val t
|
|||
),
|
||||
type = WalletNotificationType.Warning,
|
||||
)
|
||||
|
||||
data class SoftUpdateAvailable(val onUpdateClick: () -> Unit) : WalletNotificationUM(
|
||||
messageUM = TangemMessageUM(
|
||||
id = "SoftUpdateAvailableNotification",
|
||||
title = resourceReference(id = CoreResR.string.force_update_banner_title),
|
||||
subtitle = resourceReference(id = CoreResR.string.force_update_banner_message),
|
||||
iconUM = TangemIconUM.Icon(
|
||||
iconRes = R.drawable.ic_attention_default_24,
|
||||
tintReference = { TangemTheme.colors2.graphic.status.attention },
|
||||
),
|
||||
messageEffect = TangemMessageEffect.Warning,
|
||||
buttonsUM = persistentListOf(
|
||||
TangemMessageButtonUM(
|
||||
text = resourceReference(id = CoreResR.string.force_update_action),
|
||||
type = TangemButtonType.Primary,
|
||||
onClick = onUpdateClick,
|
||||
),
|
||||
),
|
||||
),
|
||||
type = WalletNotificationType.Warning,
|
||||
)
|
||||
// endregion
|
||||
|
||||
// region Promo
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import com.tangem.common.test.domain.token.MockCryptoCurrencyFactory
|
|||
import com.tangem.domain.account.models.AccountStatusList
|
||||
import com.tangem.domain.account.status.producer.SingleAccountStatusListProducer
|
||||
import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier
|
||||
import com.tangem.domain.appupdate.model.AppUpdateState
|
||||
import com.tangem.domain.appupdate.usecase.GetAppUpdateStateUseCase
|
||||
import com.tangem.domain.assetsdiscovery.model.AssetsDiscoveryProgress
|
||||
import com.tangem.domain.assetsdiscovery.usecase.ObserveAssetsDiscoveryUseCase
|
||||
import com.tangem.domain.card.CardTypesResolver
|
||||
|
|
@ -56,6 +58,7 @@ internal class GetWalletNotificationsFactoryTest {
|
|||
private val getAccessCodeSkippedUseCase: GetAccessCodeSkippedUseCase = mockk()
|
||||
private val hasSingleWalletSignedHashesUseCase: HasSingleWalletSignedHashesUseCase = mockk()
|
||||
private val observeAssetsDiscoveryUseCase: ObserveAssetsDiscoveryUseCase = mockk()
|
||||
private val getAppUpdateStateUseCase: GetAppUpdateStateUseCase = mockk()
|
||||
private val singleAccountStatusListSupplier: SingleAccountStatusListSupplier = mockk()
|
||||
private val clickIntents: WalletClickIntents = mockk(relaxed = true)
|
||||
|
||||
|
|
@ -73,6 +76,7 @@ internal class GetWalletNotificationsFactoryTest {
|
|||
getAccessCodeSkippedUseCase = getAccessCodeSkippedUseCase,
|
||||
hasSingleWalletSignedHashesUseCase = hasSingleWalletSignedHashesUseCase,
|
||||
observeAssetsDiscoveryUseCase = observeAssetsDiscoveryUseCase,
|
||||
getAppUpdateStateUseCase = getAppUpdateStateUseCase,
|
||||
)
|
||||
|
||||
@BeforeEach
|
||||
|
|
@ -85,6 +89,7 @@ internal class GetWalletNotificationsFactoryTest {
|
|||
getAccessCodeSkippedUseCase,
|
||||
hasSingleWalletSignedHashesUseCase,
|
||||
observeAssetsDiscoveryUseCase,
|
||||
getAppUpdateStateUseCase,
|
||||
singleAccountStatusListSupplier,
|
||||
clickIntents,
|
||||
coldResolver,
|
||||
|
|
@ -100,6 +105,7 @@ internal class GetWalletNotificationsFactoryTest {
|
|||
every { isNeedToBackupUseCase(any()) } returns flowOf(false)
|
||||
every { getAccessCodeSkippedUseCase(any()) } returns flowOf(true)
|
||||
every { observeAssetsDiscoveryUseCase(any()) } returns flowOf(AssetsDiscoveryProgress.Idle)
|
||||
every { getAppUpdateStateUseCase.getBannerStateFlow() } returns flowOf(AppUpdateState.NoUpdate)
|
||||
every { hasSingleWalletSignedHashesUseCase(any(), any()) } returns flowOf(false)
|
||||
// Balance is loaded and non-zero, so both the outdated-data and add-funds banners stay hidden.
|
||||
stubAccountStatusList(balance = LOADED_NON_ZERO)
|
||||
|
|
@ -648,6 +654,42 @@ internal class GetWalletNotificationsFactoryTest {
|
|||
}
|
||||
// endregion
|
||||
|
||||
// region SoftUpdate
|
||||
@Test
|
||||
fun `GIVEN optional update WHEN create THEN soft-update banner is shown`() = runTest {
|
||||
// Arrange
|
||||
every { getAppUpdateStateUseCase.getBannerStateFlow() } returns flowOf(AppUpdateState.OptionalUpdate)
|
||||
|
||||
// Act
|
||||
val result = factory.create(coldWallet, clickIntents).first()
|
||||
|
||||
// Assert
|
||||
assertThat(result.any { it is WalletNotificationUM.SoftUpdateAvailable }).isTrue()
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideNonOptionalUpdateStates")
|
||||
fun `GIVEN non-optional update state WHEN create THEN soft-update banner is hidden`(
|
||||
state: AppUpdateState,
|
||||
) = runTest {
|
||||
// Arrange
|
||||
every { getAppUpdateStateUseCase.getBannerStateFlow() } returns flowOf(state)
|
||||
|
||||
// Act
|
||||
val result = factory.create(coldWallet, clickIntents).first()
|
||||
|
||||
// Assert
|
||||
assertThat(result.none { it is WalletNotificationUM.SoftUpdateAvailable }).isTrue()
|
||||
}
|
||||
|
||||
private fun provideNonOptionalUpdateStates() = listOf(
|
||||
AppUpdateState.NoUpdate,
|
||||
AppUpdateState.ForceUpdate,
|
||||
AppUpdateState.Brick,
|
||||
AppUpdateState.OsTooOld,
|
||||
)
|
||||
// endregion
|
||||
|
||||
// region TangemPay warnings
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTangemPayModels")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue