gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-android] 02/15: [wallet] DD51: enrich some tx amounts with


From: gnunet
Subject: [taler-taler-android] 02/15: [wallet] DD51: enrich some tx amounts with currencySpecification
Date: Wed, 27 Mar 2024 18:27:05 +0100

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository taler-android.

commit c86ae12e55c227e285252271c90b56f35f38858e
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Mon Feb 12 18:47:53 2024 -0600

    [wallet] DD51: enrich some tx amounts with currencySpecification
    
    bug 0008329
    
    (cherry picked from commit 021e4443bae33abbdc9de21f2708e633e99ca055)
---
 .../main/java/net/taler/wallet/balances/BalanceManager.kt | 15 +++++++++++++++
 .../src/main/java/net/taler/wallet/balances/Balances.kt   |  1 -
 .../taler/wallet/deposit/TransactionDepositComposable.kt  | 10 ++++++----
 .../taler/wallet/payment/TransactionPaymentComposable.kt  | 10 ++++++----
 .../net/taler/wallet/peer/TransactionPeerPullCredit.kt    | 11 ++++++-----
 .../net/taler/wallet/peer/TransactionPeerPullDebit.kt     | 13 +++++++------
 .../net/taler/wallet/peer/TransactionPeerPushCredit.kt    | 11 ++++++-----
 .../net/taler/wallet/peer/TransactionPeerPushDebit.kt     | 11 ++++++-----
 .../taler/wallet/refund/TransactionRefundComposable.kt    | 10 ++++++----
 .../net/taler/wallet/transactions/TransactionAdapter.kt   | 10 +++++++++-
 .../wallet/transactions/TransactionDepositFragment.kt     |  1 +
 .../wallet/transactions/TransactionDetailFragment.kt      |  1 +
 .../wallet/transactions/TransactionPaymentFragment.kt     |  1 +
 .../taler/wallet/transactions/TransactionPeerFragment.kt  | 14 +++++++++-----
 .../wallet/transactions/TransactionRefreshFragment.kt     | 10 +++++++---
 .../wallet/transactions/TransactionRefundFragment.kt      |  4 +++-
 .../wallet/transactions/TransactionWithdrawalFragment.kt  |  1 +
 .../net/taler/wallet/transactions/TransactionsFragment.kt |  5 ++++-
 .../wallet/withdraw/TransactionWithdrawalComposable.kt    |  9 +++++----
 19 files changed, 99 insertions(+), 49 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/balances/BalanceManager.kt 
b/wallet/src/main/java/net/taler/wallet/balances/BalanceManager.kt
index 9b5beaf..b2e6be3 100644
--- a/wallet/src/main/java/net/taler/wallet/balances/BalanceManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/balances/BalanceManager.kt
@@ -108,6 +108,21 @@ class BalanceManager(
         return spec
     }
 
+    @Deprecated("Please find spec via scopeInfo instead", 
ReplaceWith("getSpecForScopeInfo"))
+    fun getSpecForCurrency(currency: String): CurrencySpecification? {
+        val state = mState.value
+        if (state !is BalanceState.Success) return null
+
+        return state.balances.find { it.currency == currency }?.available?.spec
+    }
+
+    fun getSpecForScopeInfo(scopeInfo: ScopeInfo): CurrencySpecification? {
+        val state = mState.value
+        if (state !is BalanceState.Success) return null
+
+        return state.balances.find { it.scopeInfo == scopeInfo 
}?.available?.spec
+    }
+
     fun resetBalances() {
         mState.value = BalanceState.None
     }
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 3e0acc9..dff2ffb 100644
--- a/wallet/src/main/java/net/taler/wallet/balances/Balances.kt
+++ b/wallet/src/main/java/net/taler/wallet/balances/Balances.kt
@@ -19,7 +19,6 @@ package net.taler.wallet.balances
 import kotlinx.serialization.SerialName
 import kotlinx.serialization.Serializable
 import net.taler.common.Amount
-import net.taler.common.CurrencySpecification
 
 @Serializable
 data class BalanceItem(
diff --git 
a/wallet/src/main/java/net/taler/wallet/deposit/TransactionDepositComposable.kt 
b/wallet/src/main/java/net/taler/wallet/deposit/TransactionDepositComposable.kt
index 807d631..817dfac 100644
--- 
a/wallet/src/main/java/net/taler/wallet/deposit/TransactionDepositComposable.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/deposit/TransactionDepositComposable.kt
@@ -32,6 +32,7 @@ import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import net.taler.common.Amount
+import net.taler.common.CurrencySpecification
 import net.taler.common.Timestamp
 import net.taler.common.toAbsoluteTime
 import net.taler.wallet.R
@@ -53,6 +54,7 @@ import net.taler.wallet.transactions.TransitionsComposable
 fun TransactionDepositComposable(
     t: TransactionDeposit,
     devMode: Boolean,
+    spec: CurrencySpecification?,
     onTransition: (t: TransactionAction) -> Unit,
 ) {
     val scrollState = rememberScrollState()
@@ -71,7 +73,7 @@ fun TransactionDepositComposable(
 
         TransactionAmountComposable(
             label = stringResource(id = R.string.amount_chosen),
-            amount = t.amountRaw,
+            amount = t.amountRaw.withSpec(spec),
             amountType = AmountType.Neutral,
         )
 
@@ -79,14 +81,14 @@ fun TransactionDepositComposable(
         if (!fee.isZero()) {
             TransactionAmountComposable(
                 label = stringResource(id = R.string.withdraw_fees),
-                amount = fee,
+                amount = fee.withSpec(spec),
                 amountType = AmountType.Negative,
             )
         }
 
         TransactionAmountComposable(
             label = stringResource(id = R.string.amount_sent),
-            amount = t.amountEffective,
+            amount = t.amountEffective.withSpec(spec),
             amountType = AmountType.Negative,
         )
 
@@ -112,6 +114,6 @@ fun TransactionDepositComposablePreview() {
         error = TalerErrorInfo(code = EXCHANGE_GENERIC_KYC_REQUIRED),
     )
     Surface {
-        TransactionDepositComposable(t, true) {}
+        TransactionDepositComposable(t, true, null) {}
     }
 }
diff --git 
a/wallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt 
b/wallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt
index 5bbbd97..0f6d661 100644
--- 
a/wallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt
@@ -32,6 +32,7 @@ import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import net.taler.common.Amount
 import net.taler.common.ContractMerchant
+import net.taler.common.CurrencySpecification
 import net.taler.common.Timestamp
 import net.taler.common.toAbsoluteTime
 import net.taler.wallet.R
@@ -57,6 +58,7 @@ import net.taler.wallet.transactions.TransitionsComposable
 fun TransactionPaymentComposable(
     t: TransactionPayment,
     devMode: Boolean,
+    spec: CurrencySpecification?,
     onFulfill: (url: String) -> Unit,
     onTransition: (t: TransactionAction) -> Unit,
 ) {
@@ -76,7 +78,7 @@ fun TransactionPaymentComposable(
 
         TransactionAmountComposable(
             label = stringResource(id = R.string.transaction_order_total),
-            amount = t.amountRaw,
+            amount = t.amountRaw.withSpec(spec),
             amountType = AmountType.Neutral,
         )
 
@@ -84,14 +86,14 @@ fun TransactionPaymentComposable(
         if (!fee.isZero()) {
             TransactionAmountComposable(
                 label = stringResource(id = R.string.withdraw_fees),
-                amount = fee,
+                amount = fee.withSpec(spec),
                 amountType = AmountType.Negative,
             )
         }
 
         TransactionAmountComposable(
             label = stringResource(id = R.string.transaction_paid),
-            amount = t.amountEffective,
+            amount = t.amountEffective.withSpec(spec),
             amountType = AmountType.Negative,
         )
 
@@ -167,6 +169,6 @@ fun TransactionPaymentComposablePreview() {
         error = TalerErrorInfo(code = 
TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED),
     )
     TalerSurface {
-        TransactionPaymentComposable(t = t, devMode = true, onFulfill = {}) {}
+        TransactionPaymentComposable(t = t, devMode = true, spec = null, 
onFulfill = {}) {}
     }
 }
diff --git 
a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt 
b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt
index 898ff69..3b15b6f 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt
@@ -22,6 +22,7 @@ import androidx.compose.runtime.Composable
 import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.tooling.preview.Preview
 import net.taler.common.Amount
+import net.taler.common.CurrencySpecification
 import net.taler.common.Timestamp
 import net.taler.wallet.R
 import net.taler.wallet.backend.TalerErrorCode.EXCHANGE_GENERIC_KYC_REQUIRED
@@ -41,7 +42,7 @@ import net.taler.wallet.transactions.TransactionPeerPullCredit
 import net.taler.wallet.transactions.TransactionState
 
 @Composable
-fun ColumnScope.TransactionPeerPullCreditComposable(t: 
TransactionPeerPullCredit) {
+fun ColumnScope.TransactionPeerPullCreditComposable(t: 
TransactionPeerPullCredit, spec: CurrencySpecification?) {
     if (t.error == null) PeerQrCode(
         state = t.txState,
         talerUri = t.talerUri,
@@ -49,7 +50,7 @@ fun ColumnScope.TransactionPeerPullCreditComposable(t: 
TransactionPeerPullCredit
     
     TransactionAmountComposable(
         label = stringResource(id = R.string.receive_peer_amount_invoiced),
-        amount = t.amountRaw,
+        amount = t.amountRaw.withSpec(spec),
         amountType = AmountType.Neutral,
     )
 
@@ -57,14 +58,14 @@ fun ColumnScope.TransactionPeerPullCreditComposable(t: 
TransactionPeerPullCredit
     if (!fee.isZero()) {
         TransactionAmountComposable(
             label = stringResource(id = R.string.withdraw_fees),
-            amount = fee,
+            amount = fee.withSpec(spec),
             amountType = AmountType.Negative,
         )
     }
 
     TransactionAmountComposable(
         label = stringResource(id = R.string.amount_received),
-        amount = t.amountEffective,
+        amount = t.amountEffective.withSpec(spec),
         amountType = AmountType.Positive,
     )
 
@@ -93,7 +94,7 @@ fun TransactionPeerPullCreditPreview(loading: Boolean = 
false) {
         error = TalerErrorInfo(code = EXCHANGE_GENERIC_KYC_REQUIRED),
     )
     Surface {
-        TransactionPeerComposable(t, true) {}
+        TransactionPeerComposable(t, true, null) {}
     }
 }
 
diff --git 
a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullDebit.kt 
b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullDebit.kt
index 783907e..dadff4a 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullDebit.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullDebit.kt
@@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable
 import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.tooling.preview.Preview
 import net.taler.common.Amount
+import net.taler.common.CurrencySpecification
 import net.taler.common.Timestamp
 import net.taler.wallet.R
 import net.taler.wallet.backend.TalerErrorCode.EXCHANGE_GENERIC_KYC_REQUIRED
@@ -38,25 +39,25 @@ import 
net.taler.wallet.transactions.TransactionPeerPullDebit
 import net.taler.wallet.transactions.TransactionState
 
 @Composable
-fun TransactionPeerPullDebitComposable(t: TransactionPeerPullDebit) {
+fun TransactionPeerPullDebitComposable(t: TransactionPeerPullDebit, spec: 
CurrencySpecification?) {
     TransactionAmountComposable(
         label = stringResource(id = R.string.transaction_order_total),
-        amount = t.amountRaw,
+        amount = t.amountRaw.withSpec(spec),
         amountType = AmountType.Neutral,
     )
-    
+
     val fee = t.amountEffective - t.amountRaw
     if (!fee.isZero()) {
         TransactionAmountComposable(
             label = stringResource(id = R.string.withdraw_fees),
-            amount = fee,
+            amount = fee.withSpec(spec),
             amountType = AmountType.Negative,
         )
     }
 
     TransactionAmountComposable(
         label = stringResource(id = R.string.transaction_paid),
-        amount = t.amountEffective,
+        amount = t.amountEffective.withSpec(spec),
         amountType = AmountType.Negative,
     )
 
@@ -84,6 +85,6 @@ fun TransactionPeerPullDebitPreview() {
         error = TalerErrorInfo(code = EXCHANGE_GENERIC_KYC_REQUIRED),
     )
     Surface {
-        TransactionPeerComposable(t, true) {}
+        TransactionPeerComposable(t, true, null) {}
     }
 }
diff --git 
a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushCredit.kt 
b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushCredit.kt
index 75d299b..dbf0fb9 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushCredit.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushCredit.kt
@@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable
 import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.tooling.preview.Preview
 import net.taler.common.Amount
+import net.taler.common.CurrencySpecification
 import net.taler.common.Timestamp
 import net.taler.wallet.R
 import net.taler.wallet.backend.TalerErrorCode.EXCHANGE_GENERIC_KYC_REQUIRED
@@ -38,10 +39,10 @@ import 
net.taler.wallet.transactions.TransactionPeerPushCredit
 import net.taler.wallet.transactions.TransactionState
 
 @Composable
-fun TransactionPeerPushCreditComposable(t: TransactionPeerPushCredit) {
+fun TransactionPeerPushCreditComposable(t: TransactionPeerPushCredit, spec: 
CurrencySpecification?) {
     TransactionAmountComposable(
         label = stringResource(id = R.string.amount_sent),
-        amount = t.amountRaw,
+        amount = t.amountRaw.withSpec(spec),
         amountType = AmountType.Neutral,
     )
 
@@ -49,14 +50,14 @@ fun TransactionPeerPushCreditComposable(t: 
TransactionPeerPushCredit) {
     if (!fee.isZero()) {
         TransactionAmountComposable(
             label = stringResource(id = R.string.withdraw_fees),
-            amount = fee,
+            amount = fee.withSpec(spec),
             amountType = AmountType.Negative,
         )
     }
 
     TransactionAmountComposable(
         label = stringResource(id = R.string.amount_received),
-        amount = t.amountEffective,
+        amount = t.amountEffective.withSpec(spec),
         amountType = AmountType.Positive,
     )
 
@@ -84,6 +85,6 @@ fun TransactionPeerPushCreditPreview() {
         error = TalerErrorInfo(code = EXCHANGE_GENERIC_KYC_REQUIRED),
     )
     Surface {
-        TransactionPeerComposable(t, true) {}
+        TransactionPeerComposable(t, true, null) {}
     }
 }
diff --git 
a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt 
b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt
index 909fd47..e592c3e 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt
@@ -30,6 +30,7 @@ import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import net.taler.common.Amount
+import net.taler.common.CurrencySpecification
 import net.taler.common.Timestamp
 import net.taler.wallet.R
 import net.taler.wallet.backend.TalerErrorCode.EXCHANGE_GENERIC_KYC_REQUIRED
@@ -52,7 +53,7 @@ import net.taler.wallet.transactions.TransactionPeerPushDebit
 import net.taler.wallet.transactions.TransactionState
 
 @Composable
-fun ColumnScope.TransactionPeerPushDebitComposable(t: 
TransactionPeerPushDebit) {
+fun ColumnScope.TransactionPeerPushDebitComposable(t: 
TransactionPeerPushDebit, spec: CurrencySpecification?) {
     if (t.error == null) PeerQrCode(
         state = t.txState,
         talerUri = t.talerUri,
@@ -60,7 +61,7 @@ fun ColumnScope.TransactionPeerPushDebitComposable(t: 
TransactionPeerPushDebit)
 
     TransactionAmountComposable(
         label = stringResource(id = R.string.transaction_order_total),
-        amount = t.amountRaw,
+        amount = t.amountRaw.withSpec(spec),
         amountType = AmountType.Neutral,
     )
 
@@ -68,14 +69,14 @@ fun ColumnScope.TransactionPeerPushDebitComposable(t: 
TransactionPeerPushDebit)
     if (!fee.isZero()) {
         TransactionAmountComposable(
             label = stringResource(id = R.string.withdraw_fees),
-            amount = fee,
+            amount = fee.withSpec(spec),
             amountType = AmountType.Negative,
         )
     }
 
     TransactionAmountComposable(
         label = stringResource(id = R.string.transaction_paid),
-        amount = t.amountEffective,
+        amount = t.amountEffective.withSpec(spec),
         amountType = AmountType.Negative,
     )
 
@@ -140,7 +141,7 @@ fun TransactionPeerPushDebitPreview(loading: Boolean = 
false) {
     )
 
     TalerSurface {
-        TransactionPeerComposable(t, true) {}
+        TransactionPeerComposable(t, true, null) {}
     }
 }
 
diff --git 
a/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt 
b/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt
index 82dceb5..637b41a 100644
--- 
a/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt
@@ -31,6 +31,7 @@ import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import net.taler.common.Amount
+import net.taler.common.CurrencySpecification
 import net.taler.common.Timestamp
 import net.taler.common.toAbsoluteTime
 import net.taler.wallet.R
@@ -54,6 +55,7 @@ import net.taler.wallet.transactions.TransitionsComposable
 fun TransactionRefundComposable(
     t: TransactionRefund,
     devMode: Boolean,
+    spec: CurrencySpecification?,
     onTransition: (t: TransactionAction) -> Unit,
 ) {
     val scrollState = rememberScrollState()
@@ -71,19 +73,19 @@ fun TransactionRefundComposable(
         )
         TransactionAmountComposable(
             label = stringResource(id = R.string.transaction_refund),
-            amount = t.amountEffective,
+            amount = t.amountEffective.withSpec(spec),
             amountType = AmountType.Positive,
         )
         TransactionAmountComposable(
             label = stringResource(id = R.string.transaction_order_total),
-            amount = t.amountRaw,
+            amount = t.amountRaw.withSpec(spec),
             amountType = AmountType.Neutral,
         )
         val fee = t.amountRaw - t.amountEffective
         if (!fee.isZero()) {
             TransactionAmountComposable(
                 label = stringResource(id = R.string.withdraw_fees),
-                amount = fee,
+                amount = fee.withSpec(spec),
                 amountType = AmountType.Negative,
             )
         }
@@ -116,6 +118,6 @@ fun TransactionRefundComposablePreview() {
         error = TalerErrorInfo(code = 
TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED),
     )
     TalerSurface {
-        TransactionRefundComposable(t = t, devMode = true) {}
+        TransactionRefundComposable(t = t, devMode = true, spec = null) {}
     }
 }
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
index 6fade86..22dcc3f 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
@@ -32,6 +32,7 @@ import androidx.recyclerview.selection.SelectionTracker
 import androidx.recyclerview.widget.RecyclerView
 import androidx.recyclerview.widget.RecyclerView.Adapter
 import androidx.recyclerview.widget.RecyclerView.ViewHolder
+import net.taler.common.CurrencySpecification
 import net.taler.common.exhaustive
 import net.taler.common.toRelativeTime
 import net.taler.wallet.R
@@ -47,6 +48,8 @@ internal class TransactionAdapter(
 ) : Adapter<TransactionViewHolder>() {
 
     private var transactions: List<Transaction> = ArrayList()
+    private var currencySpec: CurrencySpecification? = null
+
     lateinit var tracker: SelectionTracker<String>
     val keyProvider = TransactionKeyProvider()
 
@@ -67,6 +70,11 @@ internal class TransactionAdapter(
         holder.bind(transaction, tracker.isSelected(transaction.transactionId))
     }
 
+    fun setCurrencySpec(spec: CurrencySpecification?) {
+        this.currencySpec = spec
+        this.notifyDataSetChanged()
+    }
+
     fun update(updatedTransactions: List<Transaction>) {
         this.transactions = updatedTransactions
         this.notifyDataSetChanged()
@@ -183,7 +191,7 @@ internal class TransactionAdapter(
         }
 
         private fun bindAmount(transaction: Transaction) {
-            val amountStr = transaction.amountEffective.toString(showSymbol = 
false)
+            val amountStr = 
transaction.amountEffective.withSpec(currencySpec).toString(showSymbol = false)
             when (transaction.amountType) {
                 AmountType.Positive -> {
                     amount.text = context.getString(R.string.amount_positive, 
amountStr)
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
index f23b8d7..d2be3cf 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
@@ -38,6 +38,7 @@ class TransactionDepositFragment : 
TransactionDetailFragment() {
                 if (t is TransactionDeposit) TransactionDepositComposable(
                     t = t,
                     devMode = devMode,
+                    spec = 
balanceManager.getSpecForCurrency(t.amountRaw.currency),
                 ) {
                     onTransitionButtonClicked(t, it)
                 }
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
index 78b728a..09ca05b 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
@@ -39,6 +39,7 @@ abstract class TransactionDetailFragment : Fragment() {
 
     private val model: MainViewModel by activityViewModels()
     protected val transactionManager by lazy { model.transactionManager }
+    protected val balanceManager by lazy { model.balanceManager }
     protected val devMode get() = model.devMode.value == true
 
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionPaymentFragment.kt
 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionPaymentFragment.kt
index 27598ab..596a4a9 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionPaymentFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionPaymentFragment.kt
@@ -37,6 +37,7 @@ class TransactionPaymentFragment : 
TransactionDetailFragment() {
             TalerSurface {
                 val t = 
transactionManager.selectedTransaction.observeAsState().value
                 if (t is TransactionPayment) TransactionPaymentComposable(t, 
devMode,
+                    balanceManager.getSpecForCurrency(t.amountRaw.currency),
                     onFulfill = { url ->
                         launchInAppBrowser(requireContext(), url)
                     },
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt
index 7feedd1..27809a7 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt
@@ -38,6 +38,7 @@ import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import net.taler.common.Amount
+import net.taler.common.CurrencySpecification
 import net.taler.common.toAbsoluteTime
 import net.taler.wallet.R
 import net.taler.wallet.compose.TalerSurface
@@ -56,7 +57,9 @@ class TransactionPeerFragment : TransactionDetailFragment() {
         setContent {
             TalerSurface {
                 val t = 
transactionManager.selectedTransaction.observeAsState(null).value
-                if (t != null) TransactionPeerComposable(t, devMode) {
+                if (t != null) TransactionPeerComposable(t, devMode,
+                    balanceManager.getSpecForCurrency(t.amountRaw.currency),
+                ) {
                     onTransitionButtonClicked(t, it)
                 }
             }
@@ -68,6 +71,7 @@ class TransactionPeerFragment : TransactionDetailFragment() {
 fun TransactionPeerComposable(
     t: Transaction,
     devMode: Boolean,
+    spec: CurrencySpecification?,
     onTransition: (t: TransactionAction) -> Unit,
 ) {
     val scrollState = rememberScrollState()
@@ -84,10 +88,10 @@ fun TransactionPeerComposable(
             style = MaterialTheme.typography.bodyLarge,
         )
         when (t) {
-            is TransactionPeerPullCredit -> 
TransactionPeerPullCreditComposable(t)
-            is TransactionPeerPushCredit -> 
TransactionPeerPushCreditComposable(t)
-            is TransactionPeerPullDebit -> 
TransactionPeerPullDebitComposable(t)
-            is TransactionPeerPushDebit -> 
TransactionPeerPushDebitComposable(t)
+            is TransactionPeerPullCredit -> 
TransactionPeerPullCreditComposable(t, spec)
+            is TransactionPeerPushCredit -> 
TransactionPeerPushCreditComposable(t, spec)
+            is TransactionPeerPullDebit -> 
TransactionPeerPullDebitComposable(t, spec)
+            is TransactionPeerPushDebit -> 
TransactionPeerPushDebitComposable(t, spec)
             else -> error("unexpected transaction: ${t::class.simpleName}")
         }
         TransitionsComposable(t, devMode, onTransition)
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt
 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt
index da4b14d..8f474f9 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt
@@ -38,6 +38,7 @@ import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import net.taler.common.Amount
+import net.taler.common.CurrencySpecification
 import net.taler.common.Timestamp
 import net.taler.common.toAbsoluteTime
 import net.taler.wallet.R
@@ -59,7 +60,9 @@ class TransactionRefreshFragment : 
TransactionDetailFragment() {
         setContent {
             TalerSurface {
                 val t = 
transactionManager.selectedTransaction.observeAsState().value
-                if (t is TransactionRefresh) TransactionRefreshComposable(t, 
devMode) {
+                if (t is TransactionRefresh) TransactionRefreshComposable(t, 
devMode,
+                    balanceManager.getSpecForCurrency(t.amountRaw.currency),
+                ) {
                     onTransitionButtonClicked(t, it)
                 }
             }
@@ -71,6 +74,7 @@ class TransactionRefreshFragment : 
TransactionDetailFragment() {
 private fun TransactionRefreshComposable(
     t: TransactionRefresh,
     devMode: Boolean,
+    spec: CurrencySpecification?,
     onTransition: (t: TransactionAction) -> Unit,
 ) {
     val scrollState = rememberScrollState()
@@ -88,7 +92,7 @@ private fun TransactionRefreshComposable(
         )
         TransactionAmountComposable(
             label = stringResource(id = R.string.withdraw_fees),
-            amount = t.amountEffective,
+            amount = t.amountEffective.withSpec(spec),
             amountType = AmountType.Negative,
         )
         TransitionsComposable(t, devMode, onTransition)
@@ -111,6 +115,6 @@ private fun TransactionRefreshComposablePreview() {
         error = TalerErrorInfo(code = 
TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED),
     )
     Surface {
-        TransactionRefreshComposable(t, true) {}
+        TransactionRefreshComposable(t, true, null) {}
     }
 }
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt
 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt
index cd50be7..7992565 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt
@@ -35,7 +35,9 @@ class TransactionRefundFragment : TransactionDetailFragment() 
{
         setContent {
             TalerSurface {
                 val t = 
transactionManager.selectedTransaction.observeAsState().value
-                if (t is TransactionRefund) TransactionRefundComposable(t, 
devMode) {
+                if (t is TransactionRefund) TransactionRefundComposable(t, 
devMode,
+                    balanceManager.getSpecForCurrency(t.amountRaw.currency)
+                ) {
                     onTransitionButtonClicked(t, it)
                 }
             }
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
index 969db13..27e59bb 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
@@ -49,6 +49,7 @@ class TransactionWithdrawalFragment : 
TransactionDetailFragment(), ActionListene
                 if (t is TransactionWithdrawal) 
TransactionWithdrawalComposable(
                     t = t,
                     devMode = devMode,
+                    spec = 
balanceManager.getSpecForCurrency(t.amountRaw.currency),
                     actionListener = this@TransactionWithdrawalFragment,
                 ) {
                     onTransitionButtonClicked(t, it)
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
index d89fbb5..2e97484 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
@@ -55,6 +55,7 @@ class TransactionsFragment : Fragment(), 
OnTransactionClickListener, ActionMode.
 
     private val model: MainViewModel by activityViewModels()
     private val transactionManager by lazy { model.transactionManager }
+    private val balanceManager by lazy { model.balanceManager }
 
     private lateinit var ui: FragmentTransactionsBinding
     private val transactionAdapter by lazy { TransactionAdapter(this) }
@@ -107,14 +108,16 @@ class TransactionsFragment : Fragment(), 
OnTransactionClickListener, ActionMode.
             }
         })
 
-        model.balanceManager.state.observe(viewLifecycleOwner) { state ->
+        balanceManager.state.observe(viewLifecycleOwner) { state ->
             if (state !is Success) return@observe
             val balances = state.balances
             // hide extra fab when in single currency mode (uses 
MainFragment's FAB)
             if (balances.size == 1) ui.mainFab.visibility = INVISIBLE
+
             // TODO: find via scopeInfo instead of currency
             balances.find { it.currency == currency }?.let { balance ->
                 ui.amount.text = balance.available.toString(showSymbol = false)
+                transactionAdapter.setCurrencySpec(balance.available.spec)
             }
         }
         transactionManager.progress.observe(viewLifecycleOwner) { show ->
diff --git 
a/wallet/src/main/java/net/taler/wallet/withdraw/TransactionWithdrawalComposable.kt
 
b/wallet/src/main/java/net/taler/wallet/withdraw/TransactionWithdrawalComposable.kt
index 7e8f94f..5155b5b 100644
--- 
a/wallet/src/main/java/net/taler/wallet/withdraw/TransactionWithdrawalComposable.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/withdraw/TransactionWithdrawalComposable.kt
@@ -61,6 +61,7 @@ import 
net.taler.wallet.transactions.WithdrawalExchangeAccountDetails
 fun TransactionWithdrawalComposable(
     t: TransactionWithdrawal,
     devMode: Boolean,
+    spec: CurrencySpecification?,
     actionListener: ActionListener,
     onTransition: (t: TransactionAction) -> Unit,
 ) {
@@ -82,7 +83,7 @@ fun TransactionWithdrawalComposable(
 
         TransactionAmountComposable(
             label = stringResource(R.string.amount_chosen),
-            amount = t.amountRaw,
+            amount = t.amountRaw.withSpec(spec),
             amountType = AmountType.Neutral,
         )
 
@@ -90,14 +91,14 @@ fun TransactionWithdrawalComposable(
         if (!fee.isZero()) {
             TransactionAmountComposable(
                 label = stringResource(id = R.string.withdraw_fees),
-                amount = fee,
+                amount = fee.withSpec(spec),
                 amountType = AmountType.Negative,
             )
         }
 
         TransactionAmountComposable(
             label = stringResource(id = R.string.withdraw_total),
-            amount = t.amountEffective,
+            amount = t.amountEffective.withSpec(spec),
             amountType = AmountType.Positive,
         )
 
@@ -148,6 +149,6 @@ fun TransactionWithdrawalComposablePreview() {
     }
 
     Surface {
-        TransactionWithdrawalComposable(t, true, listener) {}
+        TransactionWithdrawalComposable(t, true, null, listener) {}
     }
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]