Updated on 2026-08-14
This commit is contained in:
parent
a8fbabf35f
commit
f6e8d7fd73
6 changed files with 120 additions and 28 deletions
|
|
@ -75,13 +75,9 @@ dependencies {
|
||||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
||||||
|
|
||||||
// TODO: change to prod dependencies when they are available
|
implementation 'com.tangem:blockchain:develop-5'
|
||||||
// implementation 'com.tangem:blockchain:1.164.0'
|
implementation 'com.tangem:core:develop-10'
|
||||||
// implementation 'com.tangem:core:1.109.0'
|
implementation 'com.tangem:sdk:develop-10'
|
||||||
// implementation 'com.tangem:sdk:1.109.0'
|
|
||||||
implementation 'blockchain-sdk-kotlin:blockchain:tangem-20210416.151414-8'
|
|
||||||
implementation 'com.tangem:tangem-core:tangem-20210414.185224-2'
|
|
||||||
implementation 'com.tangem:tangem-sdk:tangem-20210414.185231-2'
|
|
||||||
|
|
||||||
// WebView
|
// WebView
|
||||||
implementation "androidx.browser:browser:1.3.0"
|
implementation "androidx.browser:browser:1.3.0"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.tangem.tap.common.extensions
|
||||||
|
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import com.squareup.picasso.Callback
|
||||||
|
import com.squareup.picasso.Picasso
|
||||||
|
import com.tangem.blockchain.common.Blockchain
|
||||||
|
import com.tangem.blockchain.common.IconsUtil
|
||||||
|
import com.tangem.blockchain.common.Token
|
||||||
|
import com.tangem.wallet.R
|
||||||
|
|
||||||
|
fun Picasso.loadCurrenciesIcon(
|
||||||
|
imageView: ImageView,
|
||||||
|
textView: TextView,
|
||||||
|
token: Token? = null,
|
||||||
|
blockchain: Blockchain?,
|
||||||
|
) {
|
||||||
|
val blockchain = blockchain ?: Blockchain.Ethereum
|
||||||
|
|
||||||
|
val url = if (token != null) {
|
||||||
|
IconsUtil.getTokenIconUri(blockchain, token)
|
||||||
|
} else {
|
||||||
|
IconsUtil.getBlockchainIconUri(blockchain)
|
||||||
|
}
|
||||||
|
|
||||||
|
imageView.setImageDrawable(null)
|
||||||
|
imageView.colorFilter = null
|
||||||
|
textView.text = null
|
||||||
|
|
||||||
|
if (url != null) {
|
||||||
|
this.load(url)
|
||||||
|
.placeholder(R.drawable.shape_circle)
|
||||||
|
?.into(imageView,
|
||||||
|
object : Callback {
|
||||||
|
override fun onError(e: Exception?) {
|
||||||
|
setOfflineCurrencyImage(imageView, textView, token, blockchain)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess() {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
setOfflineCurrencyImage(imageView, textView, token, blockchain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setOfflineCurrencyImage(
|
||||||
|
imageView: ImageView,
|
||||||
|
textView: TextView,
|
||||||
|
token: Token?,
|
||||||
|
blockchain: Blockchain,
|
||||||
|
) {
|
||||||
|
if (token != null) {
|
||||||
|
setTokenImage(imageView, textView, token)
|
||||||
|
} else {
|
||||||
|
setBlockchainImage(imageView, textView, blockchain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setBlockchainImage(
|
||||||
|
imageView: ImageView,
|
||||||
|
textView: TextView,
|
||||||
|
blockchain: Blockchain
|
||||||
|
) {
|
||||||
|
imageView.setImageResource(blockchain.getIconRes())
|
||||||
|
imageView.colorFilter = null
|
||||||
|
textView.text = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setTokenImage(
|
||||||
|
imageView: ImageView,
|
||||||
|
textView: TextView,
|
||||||
|
token: Token
|
||||||
|
) {
|
||||||
|
imageView.setImageResource(R.drawable.shape_circle)
|
||||||
|
imageView.setColorFilter(token.getColor())
|
||||||
|
textView.text = token.symbol.take(1)
|
||||||
|
}
|
||||||
|
|
@ -7,7 +7,10 @@ import androidx.annotation.StringRes
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.squareup.picasso.Callback
|
||||||
|
import com.squareup.picasso.Picasso
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
|
import com.tangem.blockchain.common.IconsUtil
|
||||||
import com.tangem.blockchain.common.Token
|
import com.tangem.blockchain.common.Token
|
||||||
import com.tangem.tap.common.extensions.*
|
import com.tangem.tap.common.extensions.*
|
||||||
import com.tangem.tap.common.redux.global.CryptoCurrencyName
|
import com.tangem.tap.common.redux.global.CryptoCurrencyName
|
||||||
|
|
@ -16,6 +19,7 @@ import com.tangem.tap.store
|
||||||
import com.tangem.wallet.R
|
import com.tangem.wallet.R
|
||||||
import kotlinx.android.synthetic.main.item_currency_subtitle.view.*
|
import kotlinx.android.synthetic.main.item_currency_subtitle.view.*
|
||||||
import kotlinx.android.synthetic.main.item_popular_token.view.*
|
import kotlinx.android.synthetic.main.item_popular_token.view.*
|
||||||
|
import java.lang.Exception
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>(DiffUtilCallback) {
|
class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>(DiffUtilCallback) {
|
||||||
|
|
@ -104,9 +108,11 @@ class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>
|
||||||
view.btn_add_token.show(!isAdded)
|
view.btn_add_token.show(!isAdded)
|
||||||
view.btn_token_added.show(isAdded)
|
view.btn_token_added.show(isAdded)
|
||||||
|
|
||||||
view.iv_currency.setImageResource(currency.blockchain.getIconRes())
|
Picasso.get().loadCurrenciesIcon(
|
||||||
view.iv_currency.colorFilter = null
|
imageView = view.iv_currency,
|
||||||
view.tv_token_letter.text = null
|
textView = view.tv_token_letter,
|
||||||
|
blockchain = blockchain, token = null
|
||||||
|
)
|
||||||
|
|
||||||
view.btn_add_token.setOnClickListener {
|
view.btn_add_token.setOnClickListener {
|
||||||
store.dispatch(WalletAction.MultiWallet.AddBlockchain(blockchain))
|
store.dispatch(WalletAction.MultiWallet.AddBlockchain(blockchain))
|
||||||
|
|
@ -123,10 +129,11 @@ class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>
|
||||||
view.btn_add_token.show(!isAdded)
|
view.btn_add_token.show(!isAdded)
|
||||||
view.btn_token_added.show(isAdded)
|
view.btn_token_added.show(isAdded)
|
||||||
|
|
||||||
view.iv_currency.setImageResource(R.drawable.shape_circle)
|
Picasso.get().loadCurrenciesIcon(
|
||||||
view.iv_currency.setColorFilter(token.getColor())
|
imageView = view.iv_currency,
|
||||||
view.tv_token_letter.text = token.symbol.take(1)
|
textView = view.tv_token_letter,
|
||||||
|
token = token, blockchain = Blockchain.Ethereum
|
||||||
|
)
|
||||||
view.btn_add_token.setOnClickListener {
|
view.btn_add_token.setOnClickListener {
|
||||||
store.dispatch(WalletAction.MultiWallet.AddToken(token))
|
store.dispatch(WalletAction.MultiWallet.AddToken(token))
|
||||||
view.btn_add_token.hide()
|
view.btn_add_token.hide()
|
||||||
|
|
@ -152,7 +159,10 @@ sealed class CurrencyListItem {
|
||||||
data class TitleListItem(@StringRes val titleResId: Int) : CurrencyListItem()
|
data class TitleListItem(@StringRes val titleResId: Int) : CurrencyListItem()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun createListOfCurrencies(blockchains: List<Blockchain>, tokens: List<Token>): List<CurrencyListItem> {
|
fun createListOfCurrencies(
|
||||||
|
blockchains: List<Blockchain>,
|
||||||
|
tokens: List<Token>
|
||||||
|
): List<CurrencyListItem> {
|
||||||
val blockchainsTitle = R.string.add_tokens_subtitle_blockchains
|
val blockchainsTitle = R.string.add_tokens_subtitle_blockchains
|
||||||
val tokensTitle = R.string.add_tokens_subtitle_tokens
|
val tokensTitle = R.string.add_tokens_subtitle_tokens
|
||||||
return listOf(TitleListItem(blockchainsTitle)) +
|
return listOf(TitleListItem(blockchainsTitle)) +
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,14 @@ import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.squareup.picasso.Callback
|
||||||
|
import com.squareup.picasso.Picasso
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
|
import com.tangem.blockchain.common.IconsUtil
|
||||||
import com.tangem.blockchain.common.Token
|
import com.tangem.blockchain.common.Token
|
||||||
import com.tangem.tap.common.extensions.getColor
|
import com.tangem.tap.common.extensions.getColor
|
||||||
import com.tangem.tap.common.extensions.getIconRes
|
import com.tangem.tap.common.extensions.getIconRes
|
||||||
|
import com.tangem.tap.common.extensions.loadCurrenciesIcon
|
||||||
import com.tangem.tap.common.extensions.show
|
import com.tangem.tap.common.extensions.show
|
||||||
import com.tangem.tap.features.wallet.redux.WalletAction
|
import com.tangem.tap.features.wallet.redux.WalletAction
|
||||||
import com.tangem.tap.features.wallet.redux.WalletData
|
import com.tangem.tap.features.wallet.redux.WalletData
|
||||||
|
|
@ -17,6 +21,11 @@ import com.tangem.tap.features.wallet.ui.BalanceStatus
|
||||||
import com.tangem.tap.store
|
import com.tangem.tap.store
|
||||||
import com.tangem.wallet.R
|
import com.tangem.wallet.R
|
||||||
import kotlinx.android.synthetic.main.item_currency_wallet.view.*
|
import kotlinx.android.synthetic.main.item_currency_wallet.view.*
|
||||||
|
import kotlinx.android.synthetic.main.item_currency_wallet.view.iv_currency
|
||||||
|
import kotlinx.android.synthetic.main.item_currency_wallet.view.tv_currency_symbol
|
||||||
|
import kotlinx.android.synthetic.main.item_currency_wallet.view.tv_token_letter
|
||||||
|
import kotlinx.android.synthetic.main.item_popular_token.view.*
|
||||||
|
import java.lang.Exception
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
|
|
||||||
class WalletAdapter
|
class WalletAdapter
|
||||||
|
|
@ -89,16 +98,15 @@ class WalletAdapter
|
||||||
view.card_wallet.setOnClickListener {
|
view.card_wallet.setOnClickListener {
|
||||||
store.dispatch(WalletAction.MultiWallet.SelectWallet(wallet))
|
store.dispatch(WalletAction.MultiWallet.SelectWallet(wallet))
|
||||||
}
|
}
|
||||||
val blockchain = wallet.currencyData.currencySymbol?.let { Blockchain.fromCurrency(it) }
|
val blockchain = wallet.blockchain
|
||||||
if (blockchain != null && blockchain != Blockchain.Unknown) {
|
val token = wallet.token
|
||||||
view.tv_token_letter.text = null
|
|
||||||
view.iv_currency.colorFilter = null
|
Picasso.get().loadCurrenciesIcon(
|
||||||
view.iv_currency.setImageResource(blockchain.getIconRes())
|
imageView = view.iv_currency,
|
||||||
} else {
|
textView = view.tv_token_letter,
|
||||||
view.tv_token_letter.text = wallet.currencyData.currencySymbol?.take(1)
|
token = token, blockchain = blockchain
|
||||||
wallet.token?.getColor()?.let { view.iv_currency.setColorFilter(it) }
|
)
|
||||||
view.iv_currency.setImageResource(R.drawable.shape_circle)
|
|
||||||
}
|
|
||||||
when (wallet.currencyData.status) {
|
when (wallet.currencyData.status) {
|
||||||
BalanceStatus.VerifiedOnline, BalanceStatus.SameCurrencyTransactionInProgress -> hideWarning()
|
BalanceStatus.VerifiedOnline, BalanceStatus.SameCurrencyTransactionInProgress -> hideWarning()
|
||||||
BalanceStatus.Loading -> {
|
BalanceStatus.Loading -> {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
ext.versions = [
|
ext.versions = [
|
||||||
kotlin : '1.4.31',
|
kotlin : '1.5.0',
|
||||||
build_gradle: '4.1.3',
|
build_gradle: '4.2.0',
|
||||||
]
|
]
|
||||||
|
|
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue