diff options
author | Iván Ávalos <avalos@disroot.org> | 2024-01-15 18:32:11 -0600 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2024-02-09 14:41:31 -0300 |
commit | 8b5a283a471bafbf19f36a0051e8a40c9dcf844e (patch) | |
tree | 1d81e28a3eed0ef531cfcf14e3f994e736ac1a76 /wallet/src/main/java | |
parent | 512e79eaf07eadd24914eb4a41b52c824866c528 (diff) | |
download | taler-android-8b5a283a471bafbf19f36a0051e8a40c9dcf844e.tar.gz taler-android-8b5a283a471bafbf19f36a0051e8a40c9dcf844e.tar.bz2 taler-android-8b5a283a471bafbf19f36a0051e8a40c9dcf844e.zip |
[wallet] DD35: show scope info in balance list
Diffstat (limited to 'wallet/src/main/java')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt | 19 | ||||
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/balances/Balances.kt | 27 |
2 files changed, 46 insertions, 0 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt b/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt index 6f3d79b..efb3d48 100644 --- a/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt @@ -26,6 +26,10 @@ import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.Adapter import net.taler.wallet.R import net.taler.wallet.balances.BalanceAdapter.BalanceViewHolder +import net.taler.wallet.balances.ScopeInfo.Auditor +import net.taler.wallet.balances.ScopeInfo.Exchange +import net.taler.wallet.balances.ScopeInfo.Global +import net.taler.wallet.cleanExchange class BalanceAdapter(private val listener: BalanceClickListener) : Adapter<BalanceViewHolder>() { @@ -56,6 +60,7 @@ class BalanceAdapter(private val listener: BalanceClickListener) : Adapter<Balan inner class BalanceViewHolder(private val v: View) : RecyclerView.ViewHolder(v) { private val currencyView: TextView = v.findViewById(R.id.balanceCurrencyView) private val amountView: TextView = v.findViewById(R.id.balanceAmountView) + private val scopeView: TextView = v.findViewById(R.id.scopeView) private val balanceInboundAmount: TextView = v.findViewById(R.id.balanceInboundAmount) private val balanceInboundLabel: TextView = v.findViewById(R.id.balanceInboundLabel) private val pendingView: TextView = v.findViewById(R.id.pendingView) @@ -75,6 +80,20 @@ class BalanceAdapter(private val listener: BalanceClickListener) : Adapter<Balan balanceInboundAmount.text = v.context.getString(R.string.amount_positive, amountIncoming) } + + val scopeInfo = item.scopeInfo + scopeView.visibility = when (scopeInfo) { + is Global -> GONE + is Exchange -> { + scopeView.text = v.context.getString(R.string.balance_scope_exchange, cleanExchange(scopeInfo.url)) + VISIBLE + } + is Auditor -> { + scopeView.text = v.context.getString(R.string.balance_scope_auditor, cleanExchange(scopeInfo.url)) + VISIBLE + } + } + pendingView.visibility = if (item.hasPending) VISIBLE else GONE } } diff --git a/wallet/src/main/java/net/taler/wallet/balances/Balances.kt b/wallet/src/main/java/net/taler/wallet/balances/Balances.kt index 2954f5b..dff2ffb 100644 --- a/wallet/src/main/java/net/taler/wallet/balances/Balances.kt +++ b/wallet/src/main/java/net/taler/wallet/balances/Balances.kt @@ -16,15 +16,42 @@ package net.taler.wallet.balances +import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import net.taler.common.Amount @Serializable data class BalanceItem( + val scopeInfo: ScopeInfo, val available: Amount, val pendingIncoming: Amount, val pendingOutgoing: Amount, ) { val currency: String get() = available.currency val hasPending: Boolean get() = !pendingIncoming.isZero() || !pendingOutgoing.isZero() +} + +@Serializable +sealed class ScopeInfo { + abstract val currency: String + + @Serializable + @SerialName("global") + data class Global( + override val currency: String + ): ScopeInfo() + + @Serializable + @SerialName("exchange") + data class Exchange( + override val currency: String, + val url: String, + ): ScopeInfo() + + @Serializable + @SerialName("auditor") + data class Auditor( + override val currency: String, + val url: String, + ): ScopeInfo() }
\ No newline at end of file |