Updated on 2026-08-14
This commit is contained in:
commit
a33d6dd4ab
16 changed files with 193 additions and 66 deletions
|
|
@ -71,7 +71,7 @@ dependencies {
|
|||
implementation 'com.google.android.material:material:1.2.1'
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'
|
||||
|
||||
implementation 'com.tangem:blockchain:1.108.0'
|
||||
implementation 'com.tangem:blockchain:1.114.0'
|
||||
implementation 'com.tangem:core:1.80.0'
|
||||
implementation 'com.tangem:sdk:1.80.0'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.tap.domain
|
||||
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.blockchain.common.WalletManager
|
||||
import com.tangem.commands.CardStatus
|
||||
|
|
@ -66,17 +67,13 @@ class TapWalletManager {
|
|||
}
|
||||
|
||||
suspend fun loadFiatRate(fiatCurrency: FiatCurrencyName) {
|
||||
val wallet = store.state.globalState.scanNoteResponse?.walletManager?.wallet
|
||||
val blockchainCurrency = wallet?.blockchain?.currency
|
||||
val tokenCurrency = wallet?.token?.symbol
|
||||
val wallet = store.state.globalState.scanNoteResponse?.walletManager?.wallet ?: return
|
||||
|
||||
val blockchainRate = blockchainCurrency?.let { coinMarketCapService.getRate(it, fiatCurrency) }
|
||||
val tokenRate = tokenCurrency?.let { coinMarketCapService.getRate(it, fiatCurrency) }
|
||||
val currencyList = wallet.getTokens().map { it.symbol }.toMutableList()
|
||||
currencyList.add(wallet.blockchain.currency)
|
||||
|
||||
val results = mutableListOf<Pair<CryptoCurrencyName, Result<BigDecimal>?>>()
|
||||
if (blockchainCurrency != null) results.add(blockchainCurrency to blockchainRate)
|
||||
if (tokenCurrency != null) results.add(tokenCurrency to tokenRate)
|
||||
|
||||
currencyList.forEach { results.add(it to coinMarketCapService.getRate(it, fiatCurrency)) }
|
||||
handleFiatRatesResult(results)
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +142,8 @@ class TapWalletManager {
|
|||
val error = result.error
|
||||
val blockchain = walletManager.wallet.blockchain
|
||||
if (error != null && blockchain.isNoAccountError(error)) {
|
||||
val amountToCreateAccount = blockchain.amountToCreateAccount(walletManager.wallet.token)
|
||||
val token = walletManager.wallet.getFirstToken()
|
||||
val amountToCreateAccount = blockchain.amountToCreateAccount(token)
|
||||
if (amountToCreateAccount != null) {
|
||||
store.dispatch(WalletAction.LoadWallet.NoAccount(amountToCreateAccount.toString()))
|
||||
return@withContext
|
||||
|
|
@ -209,4 +207,8 @@ class TapWalletManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Wallet.getFirstToken(): Token? {
|
||||
return getTokens().toList().getOrNull(0)
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.tangem.blockchain.common.AmountType
|
|||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.tap.common.extensions.scaleToFiat
|
||||
import com.tangem.tap.common.extensions.stripZeroPlainString
|
||||
import com.tangem.tap.domain.getFirstToken
|
||||
import com.tangem.tap.features.send.redux.ReceiptAction.RefreshReceipt
|
||||
import com.tangem.tap.features.send.redux.SendScreenAction
|
||||
import com.tangem.tap.features.send.redux.states.*
|
||||
|
|
@ -179,7 +180,7 @@ class ReceiptReducer : SendInternalReducer {
|
|||
return ReceiptSymbols(
|
||||
fiat = store.state.globalState.appCurrency,
|
||||
crypto = wallet.blockchain.currency,
|
||||
token = wallet.amounts[AmountType.Token]?.currencySymbol
|
||||
token = wallet.getFirstToken()?.symbol
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -187,12 +188,12 @@ class ReceiptReducer : SendInternalReducer {
|
|||
return when (mainCurrencyType) {
|
||||
MainCurrencyType.FIAT -> when (amountType) {
|
||||
AmountType.Coin -> ReceiptLayoutType.FIAT
|
||||
AmountType.Token -> ReceiptLayoutType.TOKEN_FIAT
|
||||
is AmountType.Token -> ReceiptLayoutType.TOKEN_FIAT
|
||||
AmountType.Reserve -> ReceiptLayoutType.UNKNOWN
|
||||
}
|
||||
MainCurrencyType.CRYPTO -> when (amountType) {
|
||||
AmountType.Coin -> ReceiptLayoutType.CRYPTO
|
||||
AmountType.Token -> ReceiptLayoutType.TOKEN_CRYPTO
|
||||
is AmountType.Token -> ReceiptLayoutType.TOKEN_CRYPTO
|
||||
AmountType.Reserve -> ReceiptLayoutType.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,14 +78,14 @@ data class SendState(
|
|||
|
||||
fun convertFiatToExtractCrypto(fiatValue: BigDecimal): BigDecimal = when (amountState.typeOfAmount) {
|
||||
AmountType.Coin -> convertFiatToCoin(fiatValue)
|
||||
AmountType.Token -> convertFiatToToken(fiatValue)
|
||||
is AmountType.Token -> convertFiatToToken(fiatValue)
|
||||
AmountType.Reserve -> fiatValue
|
||||
}
|
||||
|
||||
fun convertExtractCryptoToFiat(cryptoValue: BigDecimal, scaleWithPrecision: Boolean = false): BigDecimal {
|
||||
return when (amountState.typeOfAmount) {
|
||||
AmountType.Coin -> convertCoinToFiat(cryptoValue, scaleWithPrecision)
|
||||
AmountType.Token -> convertTokenToFiat(cryptoValue, scaleWithPrecision)
|
||||
is AmountType.Token -> convertTokenToFiat(cryptoValue, scaleWithPrecision)
|
||||
AmountType.Reserve -> cryptoValue
|
||||
}
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ data class SendState(
|
|||
fun mainCurrencyCanBeSwitched(): Boolean {
|
||||
return when (amountState.typeOfAmount) {
|
||||
AmountType.Coin -> coinIsConvertible()
|
||||
AmountType.Token -> tokenIsConvertible()
|
||||
is AmountType.Token -> tokenIsConvertible()
|
||||
AmountType.Reserve -> false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ class FeeUiHelper {
|
|||
companion object {
|
||||
fun feeToId(fee: FeeType): Int {
|
||||
return when (fee) {
|
||||
FeeType.SINGLE -> 0
|
||||
FeeType.SINGLE -> View.NO_ID
|
||||
FeeType.LOW -> R.id.chipLow
|
||||
FeeType.NORMAL -> R.id.chipNormal
|
||||
FeeType.PRIORITY -> R.id.chipPriority
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.tap.features.send.ui.stateSubscribers
|
|||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.text.bold
|
||||
import com.tangem.tap.common.extensions.*
|
||||
|
|
@ -200,7 +201,7 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
|
|||
}
|
||||
|
||||
val chipId = FeeUiHelper.feeToId(state.selectedFeeType)
|
||||
if (fg.chipGroup.checkedChipId != chipId && chipId != 0) fg.chipGroup.check(chipId)
|
||||
if (fg.chipGroup.checkedChipId != chipId && chipId != View.NO_ID) fg.chipGroup.check(chipId)
|
||||
}
|
||||
|
||||
private fun handleReceiptState(fg: BaseStoreFragment, state: ReceiptState) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.tap.features.wallet.redux
|
|||
import android.content.Context
|
||||
import com.tangem.blockchain.common.Amount
|
||||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.blockchain.common.address.AddressType
|
||||
import com.tangem.commands.Card
|
||||
import com.tangem.tap.common.redux.ErrorAction
|
||||
import com.tangem.tap.common.redux.NotificationAction
|
||||
|
|
@ -91,4 +92,6 @@ sealed class WalletAction : Action {
|
|||
sealed class TopUpAction : WalletAction() {
|
||||
data class TopUp(val context: Context, val toolbarColor: Int) : TopUpAction()
|
||||
}
|
||||
|
||||
data class ChangeSelectedAddress(val type: AddressType): WalletAction()
|
||||
}
|
||||
|
|
@ -133,13 +133,13 @@ class WalletMiddleware {
|
|||
}
|
||||
}
|
||||
is WalletAction.CopyAddress -> {
|
||||
store.state.walletState.addressData?.address?.let {
|
||||
store.state.walletState.walletAddresses?.selectedAddress?.address?.let {
|
||||
action.context.copyToClipboard(it)
|
||||
store.dispatch(WalletAction.CopyAddress.Success)
|
||||
}
|
||||
}
|
||||
is WalletAction.ExploreAddress -> {
|
||||
val uri = Uri.parse(store.state.walletState.addressData?.exploreUrl)
|
||||
val uri = Uri.parse(store.state.walletState.walletAddresses?.selectedAddress?.exploreUrl)
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
ContextCompat.startActivity(action.context, intent, null)
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ class WalletMiddleware {
|
|||
|
||||
private fun prepareSendAction(amount: Amount?): Action {
|
||||
return if (amount != null) {
|
||||
if (amount.type == AmountType.Token) {
|
||||
if (amount.type is AmountType.Token) {
|
||||
PrepareSendScreen(store.state.walletState.wallet?.amounts?.get(AmountType.Coin), amount)
|
||||
} else {
|
||||
PrepareSendScreen(amount)
|
||||
|
|
@ -258,7 +258,7 @@ private class TopUpMiddleware {
|
|||
val config = store.state.globalState.configManager?.config ?: return
|
||||
val url = TopUpHelper.getUrl(
|
||||
store.state.walletState.currencyData.currencySymbol!!,
|
||||
store.state.walletState.addressData!!.address,
|
||||
store.state.walletState.walletAddresses!!.selectedAddress.address,
|
||||
config.moonPayApiKey,
|
||||
config.moonPayApiSecretKey
|
||||
)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.tangem.tap.common.extensions.toFormattedString
|
|||
import com.tangem.tap.common.extensions.toQrCode
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.domain.TapError
|
||||
import com.tangem.tap.domain.getFirstToken
|
||||
import com.tangem.tap.features.wallet.models.removeUnknownTransactions
|
||||
import com.tangem.tap.features.wallet.models.toPendingTransactions
|
||||
import com.tangem.tap.features.wallet.ui.BalanceStatus
|
||||
|
|
@ -43,19 +44,14 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
when (action.error) {
|
||||
is TapError.NoInternetConnection -> {
|
||||
val wallet = state.globalState.scanNoteResponse?.walletManager?.wallet
|
||||
val addressData = if (wallet == null) {
|
||||
null
|
||||
} else {
|
||||
AddressData(wallet.address, wallet.shareUrl, wallet.exploreUrl)
|
||||
}
|
||||
newState = newState.copy(
|
||||
state = ProgressState.Error,
|
||||
error = ErrorType.NoInternetConnection,
|
||||
addressData = addressData,
|
||||
walletAddresses = createAddressList(wallet, newState.walletAddresses),
|
||||
currencyData = BalanceWidgetData(
|
||||
status = BalanceStatus.Unreachable,
|
||||
currency = wallet?.blockchain?.fullName,
|
||||
token = wallet?.token?.symbol?.let {
|
||||
token = wallet?.getFirstToken()?.symbol?.let {
|
||||
TokenData("", tokenSymbol = it)
|
||||
}),
|
||||
mainButton = WalletMainButton.SendButton(false),
|
||||
|
|
@ -86,11 +82,11 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
BalanceStatus.Loading,
|
||||
wallet.blockchain.fullName,
|
||||
currencySymbol = wallet.blockchain.currency,
|
||||
token = wallet.token?.symbol?.let {
|
||||
token = wallet.getFirstToken()?.symbol?.let {
|
||||
TokenData("", tokenSymbol = it)
|
||||
}
|
||||
),
|
||||
addressData = AddressData(wallet.address, wallet.shareUrl, wallet.exploreUrl),
|
||||
walletAddresses = createAddressList(wallet, newState.walletAddresses),
|
||||
mainButton = WalletMainButton.SendButton(false),
|
||||
topUpState = TopUpState(allowed = action.allowTopUp)
|
||||
)
|
||||
|
|
@ -143,9 +139,9 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
} else {
|
||||
newState.currencyData.fiatAmount
|
||||
}
|
||||
val tokenFiatAmount = if (currency == newState.wallet?.token?.symbol) {
|
||||
newState.wallet?.amounts?.get(AmountType.Token)?.value
|
||||
?.toFiatString(rate, state.globalState.appCurrency)
|
||||
val token = newState.wallet?.getFirstToken()
|
||||
val tokenFiatAmount = if (currency == token?.symbol) {
|
||||
newState.wallet?.getTokenAmount(token)?.value?.toFiatString(rate, state.globalState.appCurrency)
|
||||
} else {
|
||||
newState.currencyData.token?.fiatAmount
|
||||
}
|
||||
|
|
@ -171,8 +167,8 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
is WalletAction.ShowQrCode -> {
|
||||
newState = newState.copy(
|
||||
walletDialog = WalletDialog.QrDialog(
|
||||
newState.addressData?.shareUrl?.toQrCode(),
|
||||
newState.addressData?.shareUrl,
|
||||
newState.walletAddresses?.selectedAddress?.shareUrl?.toQrCode(),
|
||||
newState.walletAddresses?.selectedAddress?.shareUrl,
|
||||
newState.currencyData.currency
|
||||
)
|
||||
)
|
||||
|
|
@ -216,10 +212,39 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
is WalletAction.TopUpAction -> {
|
||||
newState = newState.copy(topUpState = handleTopUpActions(action, newState.topUpState))
|
||||
}
|
||||
is WalletAction.ChangeSelectedAddress -> {
|
||||
val walletAddresses = newState.walletAddresses ?: return newState
|
||||
val address = walletAddresses.list.firstOrNull { it.type == action.type } ?: return newState
|
||||
|
||||
newState = newState.copy(walletAddresses = WalletAddresses(address, walletAddresses.list))
|
||||
}
|
||||
}
|
||||
return newState
|
||||
}
|
||||
|
||||
fun createAddressList(wallet: Wallet?, walletAddresses: WalletAddresses? = null): WalletAddresses? {
|
||||
if (wallet == null) return null
|
||||
|
||||
val listOfAddressData = mutableListOf<AddressData>()
|
||||
// put a defaultAddress at the first place
|
||||
wallet.addresses.forEach {
|
||||
val addressData = AddressData(it.value, it.type, wallet.getShareUri(it.value), wallet.getExploreUrl(it.value))
|
||||
if (it.type == wallet.blockchain.defaultAddressType()) {
|
||||
listOfAddressData.add(0, addressData)
|
||||
} else {
|
||||
listOfAddressData.add(addressData)
|
||||
}
|
||||
}
|
||||
|
||||
// restore a selected wallet address
|
||||
var indexOfSelectedWallet = 0
|
||||
walletAddresses?.let {
|
||||
val index = listOfAddressData.indexOfFirst { it.address == walletAddresses.selectedAddress.address }
|
||||
if (index != -1) indexOfSelectedWallet = index
|
||||
}
|
||||
return WalletAddresses(listOfAddressData[indexOfSelectedWallet], listOfAddressData)
|
||||
}
|
||||
|
||||
private fun handleTopUpActions(action: WalletAction.TopUpAction, state: TopUpState): TopUpState {
|
||||
return when (action) {
|
||||
is WalletAction.TopUpAction.TopUp -> state
|
||||
|
|
@ -230,13 +255,17 @@ private fun onWalletLoaded(
|
|||
wallet: Wallet, walletState: WalletState, topUpAllowed: Boolean? = null
|
||||
): WalletState {
|
||||
val fiatCurrencySymbol = store.state.globalState.appCurrency
|
||||
val token = wallet.amounts[AmountType.Token]
|
||||
val token = wallet.getFirstToken()
|
||||
val tokenData = if (token != null) {
|
||||
val tokenFiatRate = store.state.globalState.conversionRates.getRate(token.currencySymbol)
|
||||
val tokenFiatAmount = tokenFiatRate?.let { token.value?.toFiatString(it, fiatCurrencySymbol) }
|
||||
TokenData(
|
||||
token.value?.toFormattedString(token.decimals) ?: "",
|
||||
token.currencySymbol, tokenFiatAmount)
|
||||
val tokenAmount = wallet.getTokenAmount(token)
|
||||
if (tokenAmount != null) {
|
||||
val tokenFiatRate = store.state.globalState.conversionRates.getRate(tokenAmount.currencySymbol)
|
||||
val tokenFiatAmount = tokenFiatRate?.let { tokenAmount.value?.toFiatString(it, fiatCurrencySymbol) }
|
||||
TokenData(tokenAmount.value?.toFormattedString(tokenAmount.decimals) ?: "",
|
||||
tokenAmount.currencySymbol, tokenFiatAmount)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package com.tangem.tap.features.wallet.redux
|
|||
|
||||
import android.graphics.Bitmap
|
||||
import com.tangem.blockchain.common.Amount
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.blockchain.common.address.AddressType
|
||||
import com.tangem.tap.common.entities.Button
|
||||
import com.tangem.tap.common.redux.global.CryptoCurrencyName
|
||||
import com.tangem.tap.features.wallet.models.PendingTransaction
|
||||
|
|
@ -16,7 +18,7 @@ data class WalletState(
|
|||
val wallet: Wallet? = null,
|
||||
val pendingTransactions: List<PendingTransaction> = emptyList(),
|
||||
val hashesCountVerified: Boolean? = null,
|
||||
val addressData: AddressData? = null,
|
||||
val walletAddresses: WalletAddresses? = null,
|
||||
val currencyData: BalanceWidgetData = BalanceWidgetData(),
|
||||
val payIdData: PayIdData = PayIdData(),
|
||||
val walletDialog: WalletDialog? = null,
|
||||
|
|
@ -27,6 +29,12 @@ data class WalletState(
|
|||
val showDetails: Boolean =
|
||||
currencyData.status != com.tangem.tap.features.wallet.ui.BalanceStatus.EmptyCard &&
|
||||
currencyData.status != com.tangem.tap.features.wallet.ui.BalanceStatus.UnknownBlockchain
|
||||
|
||||
val showSegwitAddress: Boolean
|
||||
get() {
|
||||
val listOfAddresses = walletAddresses?.list ?: return false
|
||||
return wallet?.blockchain == Blockchain.Bitcoin && listOfAddresses.size > 1
|
||||
}
|
||||
}
|
||||
|
||||
sealed class WalletDialog {
|
||||
|
|
@ -60,8 +68,14 @@ sealed class WalletMainButton(enabled: Boolean) : Button(enabled) {
|
|||
class CreateWalletButton(enabled: Boolean) : WalletMainButton(enabled)
|
||||
}
|
||||
|
||||
data class WalletAddresses(
|
||||
val selectedAddress: AddressData,
|
||||
val list: List<AddressData>
|
||||
)
|
||||
|
||||
data class AddressData(
|
||||
val address: String,
|
||||
val type: AddressType,
|
||||
val shareUrl: String,
|
||||
val exploreUrl: String
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ package com.tangem.tap.features.wallet.ui
|
|||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.*
|
||||
import android.view.Menu.NONE
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
|
|
@ -14,6 +11,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import androidx.transition.TransitionInflater
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.squareup.picasso.Picasso
|
||||
import com.tangem.blockchain.blockchains.bitcoin.BitcoinAddressType
|
||||
import com.tangem.blockchain.common.address.AddressType
|
||||
import com.tangem.tap.common.extensions.beginDelayedTransition
|
||||
import com.tangem.tap.common.extensions.hide
|
||||
import com.tangem.tap.common.extensions.show
|
||||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
|
|
@ -29,6 +29,7 @@ import com.tangem.wallet.R
|
|||
import kotlinx.android.synthetic.main.card_balance.*
|
||||
import kotlinx.android.synthetic.main.fragment_wallet.*
|
||||
import kotlinx.android.synthetic.main.layout_address.*
|
||||
import kotlinx.android.synthetic.main.layout_send_fee.*
|
||||
import kotlinx.android.synthetic.main.layout_wallet_long_buttons.*
|
||||
import kotlinx.android.synthetic.main.layout_wallet_short_buttons.*
|
||||
import org.rekotlin.StoreSubscriber
|
||||
|
|
@ -206,9 +207,30 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
}
|
||||
|
||||
private fun setupAddressCard(state: WalletState) {
|
||||
if (state.addressData != null) {
|
||||
if (state.walletAddresses != null) {
|
||||
l_address?.show()
|
||||
tv_address.text = state.addressData.address
|
||||
val tvAddressPaddingTop = tv_address.resources.getDimension(R.dimen.dimen16).toInt()
|
||||
if (state.showSegwitAddress) {
|
||||
(l_address as? ViewGroup)?.beginDelayedTransition()
|
||||
tv_address.setPadding(tv_address.paddingStart, tvAddressPaddingTop / 2,
|
||||
tv_address.paddingEnd, tv_address.paddingBottom)
|
||||
chip_group_segwit.show()
|
||||
val checkedId = SegwitUiHelper.typeToId(state.walletAddresses.selectedAddress.type)
|
||||
if (checkedId != View.NO_ID) chip_group_segwit.check(checkedId)
|
||||
|
||||
chip_group_segwit.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId == -1) return@setOnCheckedChangeListener
|
||||
|
||||
SegwitUiHelper.idToType(checkedId)?.let {
|
||||
store.dispatch(WalletAction.ChangeSelectedAddress(it))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tv_address.setPadding(tv_address.paddingStart, tvAddressPaddingTop,
|
||||
tv_address.paddingEnd, tv_address.paddingBottom)
|
||||
chip_group_segwit.hide()
|
||||
}
|
||||
tv_address.text = state.walletAddresses.selectedAddress.address
|
||||
tv_explore?.setOnClickListener {
|
||||
store.dispatch(WalletAction.ExploreAddress(requireContext()))
|
||||
}
|
||||
|
|
@ -285,4 +307,24 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
if (store.state.walletState.showDetails) inflater.inflate(R.menu.wallet, menu)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SegwitUiHelper {
|
||||
companion object {
|
||||
fun typeToId(type: AddressType): Int {
|
||||
return when (type) {
|
||||
is BitcoinAddressType.Legacy -> R.id.chip_legacy
|
||||
is BitcoinAddressType.Segwit -> R.id.chip_default
|
||||
else -> View.NO_ID
|
||||
}
|
||||
}
|
||||
|
||||
fun idToType(id: Int): AddressType? {
|
||||
return when (id) {
|
||||
R.id.chip_default -> BitcoinAddressType.Segwit
|
||||
R.id.chip_legacy -> BitcoinAddressType.Legacy
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,21 +23,52 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/chip_group_segwit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:selectionRequired="true"
|
||||
app:singleLine="true"
|
||||
app:singleSelection="true"
|
||||
tools:visibility="visible">
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/chip_default"
|
||||
style="@style/TapChip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/wallet_address_chip_default" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/chip_legacy"
|
||||
style="@style/TapChip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/wallet_address_chip_legacy" />
|
||||
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_address"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="middle"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="@dimen/dimen16"
|
||||
android:paddingTop="@dimen/dimen16"
|
||||
android:paddingEnd="@dimen/dimen16"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/darkGray1"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintEnd_toStartOf="@id/btn_copy"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_segwit"
|
||||
tools:text="139mrsJgyWnJ**** **** y9BV" />
|
||||
|
||||
<TextView
|
||||
|
|
@ -66,10 +97,10 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/shape_ellipse"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:elevation="3dp"
|
||||
android:focusable="true"
|
||||
app:layout_constraintEnd_toStartOf="@id/btn_show_qr"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_segwit">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_copy"
|
||||
|
|
@ -90,10 +121,10 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/shape_ellipse"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:elevation="3dp"
|
||||
android:focusable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
app:layout_constraintTop_toBottomOf="@id/chip_group_segwit">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_qr"
|
||||
|
|
@ -145,15 +176,15 @@
|
|||
android:ellipsize="middle"
|
||||
android:padding="16dp"
|
||||
android:singleLine="true"
|
||||
android:textAlignment="textEnd"
|
||||
android:textColor="@color/darkGray1"
|
||||
android:textSize="13sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_payid_icon"
|
||||
android:textAlignment="textEnd"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/v_payid_divider"
|
||||
tools:text="roman$payid.tangem.com"
|
||||
android:visibility="gone"/>
|
||||
tools:text="roman$payid.tangem.com" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/group_payid"
|
||||
|
|
|
|||
|
|
@ -48,21 +48,21 @@
|
|||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/chipLow"
|
||||
style="@style/ChipNetworkFee"
|
||||
style="@style/TapChip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/send_fee_picker_low" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/chipNormal"
|
||||
style="@style/ChipNetworkFee"
|
||||
style="@style/TapChip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/send_fee_picker_normal" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/chipPriority"
|
||||
style="@style/ChipNetworkFee"
|
||||
style="@style/TapChip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/send_fee_picker_priority" />
|
||||
|
|
|
|||
|
|
@ -33,5 +33,6 @@
|
|||
<dimen name="btn_rounded_size">44dp</dimen>
|
||||
|
||||
<dimen name="text_size_amount_to_send">32sp</dimen>
|
||||
<dimen name="dimen16">16dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
<resources>
|
||||
<string name="wallet_button_topup" translatable="false">Top Up</string>
|
||||
<string name="wallet_address_chip_default" translatable="false">Default</string>
|
||||
<string name="wallet_address_chip_compatibility" translatable="false">Compatibility</string>
|
||||
<string name="wallet_address_chip_legacy" translatable="false">Legacy</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
<item name="android:backgroundTint">@color/selector_btn_black</item>
|
||||
</style>
|
||||
|
||||
<style name="ChipNetworkFee" parent="@style/Widget.MaterialComponents.Chip.Choice">
|
||||
<style name="TapChip" parent="@style/Widget.MaterialComponents.Chip.Choice">
|
||||
<item name="chipBackgroundColor">@color/selector_chip_background</item>
|
||||
<item name="chipStrokeColor">@color/selector_chip_stroke</item>
|
||||
<item name="chipStrokeWidth">1dp</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue