Updated on 2026-08-14

This commit is contained in:
Tangem 2023-06-27 20:25:28 +03:00
parent 448fcc09b7
commit 2ab957d18a
3 changed files with 27 additions and 23 deletions

View file

@ -1,20 +1,24 @@
package com.tangem.tap.features.wallet.ui
import android.view.View
import com.tangem.blockchain.blockchains.bitcoin.BitcoinAddressType
import com.tangem.blockchain.blockchains.cardano.CardanoAddressType
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.address.AddressType
import com.tangem.wallet.R
object MultipleAddressUiHelper {
fun typeToId(type: AddressType): Int {
return when (type) {
is BitcoinAddressType.Legacy -> R.id.chip_legacy
is BitcoinAddressType.Segwit -> R.id.chip_default
is CardanoAddressType.Byron -> R.id.chip_legacy
is CardanoAddressType.Shelley -> R.id.chip_default
else -> View.NO_ID
fun typeToId(type: AddressType, blockchain: Blockchain): Int {
return when (blockchain) {
in blockchainsSupportingSplit -> {
if (type == AddressType.Legacy) {
R.id.chip_legacy
} else {
R.id.chip_default
}
}
else -> {
View.NO_ID
}
}
}
@ -22,27 +26,27 @@ object MultipleAddressUiHelper {
return when (id) {
R.id.chip_default -> {
when (blockchain) {
Blockchain.Bitcoin,
Blockchain.BitcoinTestnet,
Blockchain.Litecoin,
Blockchain.BitcoinCash,
-> BitcoinAddressType.Segwit
Blockchain.CardanoShelley -> CardanoAddressType.Shelley
in blockchainsSupportingSplit -> AddressType.Default
else -> null
}
}
R.id.chip_legacy -> {
when (blockchain) {
Blockchain.Bitcoin,
Blockchain.BitcoinTestnet,
Blockchain.Litecoin,
Blockchain.BitcoinCash,
-> BitcoinAddressType.Legacy
Blockchain.CardanoShelley -> CardanoAddressType.Byron
in blockchainsSupportingSplit -> AddressType.Legacy
else -> null
}
}
else -> null
}
}
private val blockchainsSupportingSplit = listOf(
Blockchain.Bitcoin,
Blockchain.BitcoinTestnet,
Blockchain.Litecoin,
Blockchain.BitcoinCash,
Blockchain.CardanoShelley
)
}

View file

@ -390,7 +390,7 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details), SafeSt
chipGroupAddressType.show()
chipGroupAddressType.fitChipsByGroupWidth()
val checkedId = MultipleAddressUiHelper.typeToId(selectedAddress.type)
val checkedId = MultipleAddressUiHelper.typeToId(selectedAddress.type, currency.blockchain)
if (checkedId != View.NO_ID) chipGroupAddressType.check(checkedId)
chipGroupAddressType.setOnCheckedChangeListener { _, checkedId ->

View file

@ -190,7 +190,7 @@ class SingleWalletView : WalletView() {
(binding.lAddress.root as? ViewGroup)?.beginDelayedTransition()
chipGroupAddressType.show()
chipGroupAddressType.fitChipsByGroupWidth()
val checkedId = MultipleAddressUiHelper.typeToId(primaryWallet.walletAddresses.selectedAddress.type)
val checkedId = MultipleAddressUiHelper.typeToId(primaryWallet.walletAddresses.selectedAddress.type, primaryWallet.currency.blockchain)
if (checkedId != View.NO_ID) chipGroupAddressType.check(checkedId)
chipGroupAddressType.setOnCheckedChangeListener { group, checkedId ->