diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml
index 078e9b7128..670cd963ee 100644
--- a/core/res/src/main/res/values/strings.xml
+++ b/core/res/src/main/res/values/strings.xml
@@ -530,6 +530,9 @@
Create Mobile Wallet
This recovery phrase has already been imported
Mobile Wallet
+ This device can’t be used for upgrade, it already contains another wallet.
+ Choose another device, this one can’t be used for upgrade.
+ An error occurred during the operation.
Your funds stay safe and fully accessible during the process
Funds access
All private wallet data will be removed from the mobile app and stored securely on your Tangem device only
@@ -981,6 +984,7 @@
Memo
Check your network connection
Network fee info unreachable
+ You send
From
From %s
Gas limit
diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt
index b3c517ceed..b69ef65add 100644
--- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt
+++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt
@@ -28,6 +28,7 @@ import com.tangem.domain.models.wallet.isMultiCurrency
import com.tangem.domain.tokens.GetMinimumTransactionAmountSyncUseCase
import com.tangem.domain.tokens.model.ScenarioUnavailabilityReason
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
+import com.tangem.domain.wallets.usecase.GetWalletsUseCase
import com.tangem.features.send.v2.api.SendFeatureToggles
import com.tangem.features.send.v2.api.entity.PredefinedValues
import com.tangem.features.send.v2.api.subcomponents.amount.analytics.CommonSendAmountAnalyticEvents
@@ -66,6 +67,7 @@ internal class SendAmountModel @Inject constructor(
private val getUserWalletUseCase: GetUserWalletUseCase,
private val rampStateManager: RampStateManager,
private val sendAmountAlertFactory: SendAmountAlertFactory,
+ private val getWalletsUseCase: GetWalletsUseCase,
) : Model(), SendAmountClickIntents {
private val params: SendAmountComponentParams = paramsContainer.require()
@@ -176,6 +178,7 @@ internal class SendAmountModel @Inject constructor(
private fun initialState() {
if (uiState.value is AmountState.Empty && userWallet != null) {
+ val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
_uiState.update {
AmountStateConverterV2(
clickIntents = this,
@@ -187,10 +190,14 @@ internal class SendAmountModel @Inject constructor(
isBalanceHidden = params.isBalanceHidingFlow.value,
).convert(
AmountParameters(
- title = resourceReference(
- R.string.send_from_wallet_name,
- WrappedList(listOf(userWallet?.name.orEmpty())), // TODO [REDACTED_TASK_KEY]
- ),
+ title = if (isSingleWallet) {
+ resourceReference(R.string.send_from_title)
+ } else {
+ resourceReference(
+ R.string.send_from_wallet_name,
+ WrappedList(listOf(userWallet?.name.orEmpty())), // TODO [REDACTED_TASK_KEY]
+ )
+ },
value = "",
),
)
diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt
index aa2ef6ed3d..b2e38a4172 100644
--- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt
+++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt
@@ -35,6 +35,7 @@ import com.tangem.domain.swap.usecase.GetSwapQuoteUseCase
import com.tangem.domain.swap.usecase.SelectInitialPairUseCase
import com.tangem.domain.tokens.GetMinimumTransactionAmountSyncUseCase
import com.tangem.domain.transaction.usecase.GetAllowanceUseCase
+import com.tangem.domain.wallets.usecase.GetWalletsUseCase
import com.tangem.features.send.v2.api.subcomponents.amount.analytics.CommonSendAmountAnalyticEvents
import com.tangem.features.send.v2.api.subcomponents.feeSelector.FeeSelectorReloadTrigger
import com.tangem.features.swap.v2.api.choosetoken.SwapChooseTokenNetworkListener
@@ -91,6 +92,7 @@ internal class SwapAmountModel @Inject constructor(
private val feeSelectorReloadTrigger: FeeSelectorReloadTrigger,
private val shouldShowNotificationUseCase: ShouldShowNotificationUseCase,
private val analyticsEventHandler: AnalyticsEventHandler,
+ private val getWalletsUseCase: GetWalletsUseCase,
) : Model(), SwapAmountClickIntents, SwapChooseProviderComponent.ModelCallback {
private val params: SwapAmountComponentParams = paramsContainer.require()
@@ -328,21 +330,18 @@ internal class SwapAmountModel @Inject constructor(
}
private fun subscribeOnBalanceHiddenUpdates() {
- params.isBalanceHidingFlow.onEach {
- val primaryCryptoCurrencyStatus = (uiState.value as? SwapAmountUM.Content)?.primaryCryptoCurrencyStatus
- if (primaryCryptoCurrencyStatus != null) {
- uiState.transformerUpdate(
- SwapAmountPrimaryReadyStateTransformer(
- userWallet = userWallet,
- primaryCryptoCurrencyStatus = primaryCryptoCurrencyStatus,
- appCurrency = appCurrency,
- swapDirection = swapDirection,
- clickIntents = this,
- isBalanceHidden = params.isBalanceHidingFlow.value,
- showBestRateAnimation = showBestRateAnimation,
- ),
- )
- }
+ params.isBalanceHidingFlow.onEach { isHidden ->
+ val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
+ uiState.transformerUpdate(
+ SwapAmountBalanceHiddenTransformer(
+ isBalanceHidden = isHidden,
+ isSingleWallet = isSingleWallet,
+ userWallet = userWallet,
+ appCurrency = appCurrency,
+ swapDirection = swapDirection,
+ clickIntents = this,
+ ),
+ )
}.launchIn(modelScope)
}
@@ -352,6 +351,7 @@ internal class SwapAmountModel @Inject constructor(
val primaryCryptoCurrencyStatus = (uiState.value as? SwapAmountUM.Content)?.primaryCryptoCurrencyStatus
if (primaryCryptoCurrencyStatus != null) {
+ val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
uiState.transformerUpdate(
SwapAmountPrimaryReadyStateTransformer(
userWallet = userWallet,
@@ -361,6 +361,7 @@ internal class SwapAmountModel @Inject constructor(
clickIntents = this,
isBalanceHidden = params.isBalanceHidingFlow.value,
showBestRateAnimation = showBestRateAnimation,
+ isSingleWallet = isSingleWallet,
),
)
}
@@ -386,6 +387,7 @@ internal class SwapAmountModel @Inject constructor(
),
)
} else {
+ val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
uiState.transformerUpdate(
SwapAmountPrimaryReadyStateTransformer(
userWallet = userWallet,
@@ -395,6 +397,7 @@ internal class SwapAmountModel @Inject constructor(
clickIntents = this,
isBalanceHidden = params.isBalanceHidingFlow.value,
showBestRateAnimation = showBestRateAnimation,
+ isSingleWallet = isSingleWallet,
),
)
}
@@ -492,6 +495,7 @@ internal class SwapAmountModel @Inject constructor(
val primaryStatus = (uiState.value as? SwapAmountUM.Content)?.primaryCryptoCurrencyStatus
if (secondaryStatus != null && primaryStatus != null) {
initCurrencies(primaryStatus, secondaryStatus)
+ val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
uiState.transformerUpdate(
SwapAmountSecondaryReadyStateTransformer(
userWallet = userWallet,
@@ -503,6 +507,7 @@ internal class SwapAmountModel @Inject constructor(
clickIntents = this@SwapAmountModel,
isBalanceHidden = params.isBalanceHidingFlow.value,
showBestRateAnimation = showBestRateAnimation,
+ isSingleWallet = isSingleWallet,
),
)
startLoadingQuotesTask(isSilentReload = false)
diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt
index f1d7e06cb3..1962a4d356 100644
--- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt
+++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt
@@ -25,6 +25,7 @@ internal class SwapAmountFieldConverter(
private val userWallet: UserWallet,
private val appCurrency: AppCurrency,
private val clickIntents: AmountScreenClickIntents,
+ private val isSingleWallet: Boolean,
) {
private val iconStateConverter = CryptoCurrencyToIconStateConverter()
@@ -51,11 +52,15 @@ internal class SwapAmountFieldConverter(
isBalanceHidden = isBalanceHidden,
).convert(
AmountParameters(
- title = combinedReference(
- resourceReference(R.string.send_from_wallet_android),
- stringReference(" "),
- stringReference(userWallet.name),
- ),
+ title = if (isSingleWallet) {
+ resourceReference(R.string.send_from_title)
+ } else {
+ combinedReference(
+ resourceReference(R.string.send_from_wallet_android),
+ stringReference(" "),
+ stringReference(userWallet.name),
+ )
+ },
value = "",
),
),
diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountBalanceHiddenTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountBalanceHiddenTransformer.kt
new file mode 100644
index 0000000000..52fc0217cd
--- /dev/null
+++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountBalanceHiddenTransformer.kt
@@ -0,0 +1,66 @@
+package com.tangem.features.swap.v2.impl.amount.model.transformers
+
+import com.tangem.common.ui.amountScreen.AmountScreenClickIntents
+import com.tangem.common.ui.amountScreen.models.AmountState
+import com.tangem.domain.appcurrency.model.AppCurrency
+import com.tangem.domain.models.wallet.UserWallet
+import com.tangem.domain.swap.models.SwapDirection
+import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
+import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
+import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
+import com.tangem.features.swap.v2.impl.amount.model.converter.SwapAmountFieldConverter
+import com.tangem.utils.transformer.Transformer
+
+internal class SwapAmountBalanceHiddenTransformer(
+ private val isBalanceHidden: Boolean,
+ private val isSingleWallet: Boolean,
+ private val userWallet: UserWallet,
+ private val appCurrency: AppCurrency,
+ private val swapDirection: SwapDirection,
+ private val clickIntents: AmountScreenClickIntents,
+) : Transformer {
+
+ override fun transform(prevState: SwapAmountUM): SwapAmountUM {
+ val content = prevState as? SwapAmountUM.Content ?: return prevState
+
+ val amountFieldConverter = SwapAmountFieldConverter(
+ swapDirection = swapDirection,
+ isBalanceHidden = isBalanceHidden,
+ userWallet = userWallet,
+ appCurrency = appCurrency,
+ clickIntents = clickIntents,
+ isSingleWallet = isSingleWallet,
+ )
+
+ val recalculatedPrimary = amountFieldConverter.convert(
+ selectedType = SwapAmountType.From,
+ cryptoCurrencyStatus = content.primaryCryptoCurrencyStatus,
+ ) as SwapAmountFieldUM.Content
+
+ val oldPrimary = content.primaryAmount as? SwapAmountFieldUM.Content
+
+ val mergedAmountField = if (
+ oldPrimary?.amountField is AmountState.Data && recalculatedPrimary.amountField is AmountState.Data
+ ) {
+ val oldData = oldPrimary.amountField
+ val newData = recalculatedPrimary.amountField
+ newData.copy(
+ amountTextField = oldData.amountTextField,
+ selectedButton = oldData.selectedButton,
+ isPrimaryButtonEnabled = oldData.isPrimaryButtonEnabled,
+ isSegmentedButtonsEnabled = oldData.isSegmentedButtonsEnabled,
+ isEditingDisabled = oldData.isEditingDisabled,
+ reduceAmountBy = oldData.reduceAmountBy,
+ isIgnoreReduce = oldData.isIgnoreReduce,
+ )
+ } else {
+ recalculatedPrimary.amountField
+ }
+
+ val updatedPrimaryAmount = recalculatedPrimary.copy(
+ amountField = mergedAmountField,
+ )
+
+ return content.copy(primaryAmount = updatedPrimaryAmount)
+ }
+}
\ No newline at end of file
diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt
index 3279e896ab..b6ff17ca44 100644
--- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt
+++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt
@@ -24,6 +24,7 @@ internal class SwapAmountPrimaryReadyStateTransformer(
private val swapDirection: SwapDirection,
private val isBalanceHidden: Boolean,
private val showBestRateAnimation: Boolean,
+ private val isSingleWallet: Boolean,
) : Transformer {
private val amountFieldConverter = SwapAmountFieldConverter(
@@ -32,6 +33,7 @@ internal class SwapAmountPrimaryReadyStateTransformer(
userWallet = userWallet,
appCurrency = appCurrency,
clickIntents = clickIntents,
+ isSingleWallet = isSingleWallet,
)
override fun transform(prevState: SwapAmountUM): SwapAmountUM {
diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt
index 7a0a94e535..da85780483 100644
--- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt
+++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt
@@ -25,6 +25,7 @@ internal class SwapAmountSecondaryReadyStateTransformer(
private val swapDirection: SwapDirection,
private val isBalanceHidden: Boolean,
private val showBestRateAnimation: Boolean,
+ private val isSingleWallet: Boolean,
) : Transformer {
private val amountFieldConverter = SwapAmountFieldConverter(
@@ -33,6 +34,7 @@ internal class SwapAmountSecondaryReadyStateTransformer(
userWallet = userWallet,
appCurrency = appCurrency,
clickIntents = clickIntents,
+ isSingleWallet = isSingleWallet,
)
override fun transform(prevState: SwapAmountUM): SwapAmountUM {