summaryrefslogtreecommitdiff
path: root/wallet
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-01-15 18:32:11 -0600
committerTorsten Grote <t@grobox.de>2024-02-09 14:41:31 -0300
commit8b5a283a471bafbf19f36a0051e8a40c9dcf844e (patch)
tree1d81e28a3eed0ef531cfcf14e3f994e736ac1a76 /wallet
parent512e79eaf07eadd24914eb4a41b52c824866c528 (diff)
downloadtaler-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')
-rw-r--r--wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt19
-rw-r--r--wallet/src/main/java/net/taler/wallet/balances/Balances.kt27
-rw-r--r--wallet/src/main/res/layout/list_item_balance.xml15
-rw-r--r--wallet/src/main/res/values/strings.xml2
4 files changed, 62 insertions, 1 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
diff --git a/wallet/src/main/res/layout/list_item_balance.xml b/wallet/src/main/res/layout/list_item_balance.xml
index 475e7d6..82e663f 100644
--- a/wallet/src/main/res/layout/list_item_balance.xml
+++ b/wallet/src/main/res/layout/list_item_balance.xml
@@ -49,6 +49,19 @@
tools:text="TESTKUDOS" />
<TextView
+ android:id="@+id/scopeView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:visibility="gone"
+ app:layout_constraintTop_toBottomOf="@id/balanceAmountView"
+ app:layout_constraintBottom_toTopOf="@id/balanceInboundAmount"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/pendingView"
+ tools:text="@string/balance_scope_exchange"
+ tools:visibility="visible"/>
+
+ <TextView
android:id="@+id/balanceInboundAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -59,7 +72,7 @@
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/balanceAmountView"
+ app:layout_constraintTop_toBottomOf="@+id/scopeView"
tools:text="+10 TESTKUDOS"
tools:visibility="visible" />
diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml
index 6dac8a8..bca71ef 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -78,6 +78,8 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card
<string name="amount_chosen">Chosen Amount</string>
<string name="balances_inbound_label">inbound</string>
<string name="balances_empty_state">There is no digital cash in your wallet.\n\nYou can get test money from the demo bank:\n\nhttps://bank.demo.taler.net</string>
+ <string name="balance_scope_exchange">Exchange: %1$s</string>
+ <string name="balance_scope_auditor">Auditor: %1$s</string>
<string name="transactions_title">Transactions</string>
<string name="transactions_balance">Balance</string>