Updated on 2026-08-14
This commit is contained in:
commit
e8428795e2
16 changed files with 401 additions and 46 deletions
|
|
@ -4,6 +4,7 @@ import android.graphics.PorterDuff
|
|||
import android.net.Uri
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.squareup.picasso.Callback
|
||||
import com.squareup.picasso.Picasso
|
||||
|
|
@ -14,7 +15,7 @@ import com.tangem.tap.domain.extensions.getCustomIconUrl
|
|||
import com.tangem.wallet.R
|
||||
|
||||
fun Picasso.loadCurrenciesIcon(
|
||||
imageView: ImageView,
|
||||
imageView: ImageFilterView,
|
||||
textView: TextView,
|
||||
token: Token? = null,
|
||||
blockchain: Blockchain,
|
||||
|
|
@ -54,7 +55,7 @@ fun Picasso.loadCurrenciesIcon(
|
|||
imageView.colorFilter = null
|
||||
textView.text = null
|
||||
}
|
||||
if (blockchain.isTestnet()) imageView.tint(R.color.tint)
|
||||
if (blockchain.isTestnet()) imageView.saturation = 0f
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -68,7 +69,7 @@ private const val QCX = "QCX"
|
|||
private const val VOYR = "VOYRME"
|
||||
|
||||
private fun setOfflineCurrencyImage(
|
||||
imageView: ImageView,
|
||||
imageView: ImageFilterView,
|
||||
textView: TextView,
|
||||
token: Token?,
|
||||
blockchain: Blockchain,
|
||||
|
|
@ -89,7 +90,7 @@ fun ImageView.tint(colorRes: Int) {
|
|||
}
|
||||
|
||||
private fun setBlockchainImage(
|
||||
imageView: ImageView,
|
||||
imageView: ImageFilterView,
|
||||
textView: TextView,
|
||||
blockchain: Blockchain,
|
||||
) {
|
||||
|
|
@ -99,11 +100,15 @@ private fun setBlockchainImage(
|
|||
}
|
||||
|
||||
private fun setTokenImage(
|
||||
imageView: ImageView,
|
||||
imageView: ImageFilterView,
|
||||
textView: TextView,
|
||||
token: Token,
|
||||
) {
|
||||
imageView.setImageResource(R.drawable.shape_circle)
|
||||
imageView.setColorFilter(token.getColor())
|
||||
if (token.blockchain.isTestnet()) {
|
||||
imageView.saturation = 0f
|
||||
} else {
|
||||
imageView.setColorFilter(token.getColor())
|
||||
}
|
||||
textView.text = token.symbol.take(1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ fun View.getString(@StringRes id: Int): String {
|
|||
return context.getString(id)
|
||||
}
|
||||
|
||||
fun View.getString(@StringRes id: Int, vararg formatArgs: String): String {
|
||||
return context.getString(id, *formatArgs)
|
||||
}
|
||||
|
||||
fun View.getResourceName(): String {
|
||||
return try {
|
||||
resources.getResourceEntryName(id)
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class WarningMessagesManager(
|
|||
"",
|
||||
type = WarningMessage.Type.TestCard,
|
||||
priority = WarningMessage.Priority.Critical,
|
||||
listOf(WarningMessage.Location.MainScreen),
|
||||
listOf(WarningMessage.Location.MainScreen, WarningMessage.Location.SendScreen),
|
||||
null,
|
||||
R.string.alert_title,
|
||||
R.string.warning_testnet_card_message,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.tangem.tap.domain.extensions.getCustomIconUrl
|
|||
import com.tangem.tap.domain.extensions.setCustomIconUrl
|
||||
import com.tangem.tap.features.demo.DemoHelper
|
||||
import com.tangem.tap.network.createMoshi
|
||||
import timber.log.Timber
|
||||
|
||||
class CurrenciesRepository(val context: Application) {
|
||||
|
||||
|
|
@ -122,16 +123,21 @@ class CurrenciesRepository(val context: Application) {
|
|||
getSupportedTokens()
|
||||
}
|
||||
|
||||
val blockchainTokens = supportedTokens.map {
|
||||
fromJsonToTokensDao(loadTokensJson(it), it)
|
||||
val blockchainTokens = supportedTokens.mapNotNull { blockchain ->
|
||||
loadTokensJson(blockchain)?.let { fromJsonToTokensDao(it, blockchain) }
|
||||
}
|
||||
val tokens = blockchainTokens.flatten().map { it.toToken() }
|
||||
return tokens
|
||||
}
|
||||
|
||||
private fun loadTokensJson(blockchain: Blockchain): String {
|
||||
private fun loadTokensJson(blockchain: Blockchain): String? {
|
||||
val fileName = getFileName(blockchain)
|
||||
return context.assets.readJsonFileToString(fileName)
|
||||
return try {
|
||||
context.assets.readJsonFileToString(fileName)
|
||||
} catch (ex: Exception) {
|
||||
Timber.e(ex, "Tokens with the file name %s not found", fileName)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFileName(blockchain: Blockchain): String {
|
||||
|
|
@ -148,12 +154,12 @@ class CurrenciesRepository(val context: Application) {
|
|||
|
||||
private fun getSupportedTokens(): List<Blockchain> {
|
||||
return listOf(
|
||||
Blockchain.Avalanche,
|
||||
Blockchain.Binance,
|
||||
Blockchain.BSC,
|
||||
Blockchain.Ethereum,
|
||||
Blockchain.BSC,
|
||||
Blockchain.Binance,
|
||||
Blockchain.Polygon,
|
||||
Blockchain.Solana,
|
||||
Blockchain.Avalanche,
|
||||
Blockchain.Fantom,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -169,10 +175,11 @@ class CurrenciesRepository(val context: Application) {
|
|||
return excludeUnsupportedBlockchains(blockchains)
|
||||
}
|
||||
|
||||
// Use this list to temporarily exclude a blockchain from the list of tokens.
|
||||
private fun excludeUnsupportedBlockchains(blockchains: List<Blockchain>): List<Blockchain> {
|
||||
return blockchains.toMutableList().apply {
|
||||
removeAll(listOf(
|
||||
// Blockchain.Fantom, Blockchain.FantomTestnet
|
||||
// Any blockchain
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
@ -187,6 +194,13 @@ class CurrenciesRepository(val context: Application) {
|
|||
}
|
||||
}
|
||||
|
||||
fun Blockchain.getTokensName(): String {
|
||||
return when (this) {
|
||||
Blockchain.Fantom -> "Fantom Opera"
|
||||
else -> this.fullName
|
||||
}
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class TokenDao(
|
||||
val name: String,
|
||||
|
|
|
|||
|
|
@ -102,7 +102,45 @@ class DemoConfig {
|
|||
?: Amount(BigDecimal.ZERO, blockchain).copy()
|
||||
|
||||
private val releaseDemoCardIds = mutableListOf<String>(
|
||||
|
||||
// Tangem Wallet:
|
||||
"AC01000000041100",
|
||||
"AC01000000042462",
|
||||
"AC01000000041647",
|
||||
"AC01000000041621",
|
||||
"AC01000000041217",
|
||||
"AC01000000041225",
|
||||
"AC01000000041209",
|
||||
"AC01000000041092",
|
||||
"AC01000000041472",
|
||||
"AC01000000041662",
|
||||
"AC01000000045754",
|
||||
"AC01000000045960",
|
||||
// Tangem Note BTC:
|
||||
"AB0100000046530",
|
||||
"AB0100000046720",
|
||||
"AB0100000046746",
|
||||
"AB0100000046498",
|
||||
"AB0100000046753",
|
||||
"AB0100000049608",
|
||||
"AB0100000046761",
|
||||
"AB0100000049574",
|
||||
"AB0100000046605",
|
||||
"AB0100000046571",
|
||||
"AB0100000046704",
|
||||
"AB0100000046647",
|
||||
// Tangem Note Ethereum:
|
||||
"AB02000000051000",
|
||||
"AB02000000050986",
|
||||
"AB02000000051026",
|
||||
"AB02000000051042",
|
||||
"AB02000000051091",
|
||||
"AB02000000051083",
|
||||
"AB02000000050960",
|
||||
"AB02000000051034",
|
||||
"AB02000000050911",
|
||||
"AB02000000051133",
|
||||
"AB02000000051158",
|
||||
"AB02000000051059",
|
||||
)
|
||||
|
||||
private val testDemoCardIds = listOf(
|
||||
|
|
|
|||
|
|
@ -23,12 +23,11 @@ sealed class CurrencyListItem {
|
|||
blockchains: List<Blockchain>,
|
||||
tokens: List<Token>,
|
||||
): List<CurrencyListItem> {
|
||||
return createBlockchainList(blockchains) +
|
||||
createTokensList(R.string.add_tokens_subtitle_ethereum_tokens, Blockchain.Ethereum, tokens) +
|
||||
createTokensList(R.string.add_tokens_subtitle_bsc_tokens, Blockchain.BSC, tokens) +
|
||||
createTokensList(R.string.add_tokens_subtitle_binance_tokens, Blockchain.Binance, tokens) +
|
||||
createTokensList(R.string.add_tokens_subtitle_polygon_tokens, Blockchain.Polygon, tokens) +
|
||||
createTokensList(R.string.add_tokens_subtitle_avalanche_tokens, Blockchain.Avalanche, tokens)
|
||||
val blockchainsItemList = createBlockchainList(blockchains)
|
||||
val tokenItemsLists = tokens.groupBy { it.blockchain }.map {
|
||||
createTokensList(R.string.add_tokens_subtitle_format, it.key, it.value)
|
||||
}
|
||||
return blockchainsItemList + tokenItemsLists.flatten()
|
||||
}
|
||||
|
||||
private fun createBlockchainList(blockchains: List<Blockchain>): List<CurrencyListItem> {
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ class TokensMiddleware {
|
|||
cardFirmware = scanResponse.card.firmwareVersion,
|
||||
isTestNet = isTestcard
|
||||
).sortedBy { it.fullName }
|
||||
val currencies =
|
||||
CurrencyListItem.createListOfCurrencies(blockchains, tokens).toMutableList()
|
||||
val currencies = CurrencyListItem.createListOfCurrencies(blockchains, tokens)
|
||||
store.dispatch(TokensAction.LoadCurrencies.Success(currencies))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.tangem.tap.common.extensions.hide
|
|||
import com.tangem.tap.common.extensions.loadCurrenciesIcon
|
||||
import com.tangem.tap.common.extensions.show
|
||||
import com.tangem.tap.domain.tokens.CardCurrencies
|
||||
import com.tangem.tap.domain.tokens.getTokensName
|
||||
import com.tangem.tap.features.tokens.redux.CurrencyListItem
|
||||
import com.tangem.tap.features.tokens.redux.TokensAction
|
||||
import com.tangem.tap.store
|
||||
|
|
@ -217,9 +218,9 @@ class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>
|
|||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(title: CurrencyListItem.TitleListItem) = with(binding) {
|
||||
tvSubtitle.text = tvSubtitle.getString(title.titleResId).uppercase()
|
||||
|
||||
if (title.blockchain != null) {
|
||||
val subtitle = root.getString(title.titleResId, title.blockchain.getTokensName())
|
||||
tvSubtitle.text = subtitle.uppercase()
|
||||
clSubtitleContainer.setOnClickListener {
|
||||
val rotation = if (title.isContentShown) -90f else 90f
|
||||
store.dispatch(
|
||||
|
|
@ -233,6 +234,7 @@ class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>
|
|||
}
|
||||
showArrow(title.isContentShown)
|
||||
} else {
|
||||
tvSubtitle.text = root.getString(title.titleResId).uppercase()
|
||||
ivToggleSublistVisibility.hide()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue