From 94ee3a2f114e0345ea7408aacc30e3da9545474c Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Tue, 14 Nov 2023 12:35:37 -0600 Subject: [wallet] Show KYC notice in transaction list, and don't render fees when zero --- .../wallet/payment/TransactionPaymentComposable.kt | 13 +++++++---- .../wallet/refund/TransactionRefundComposable.kt | 13 +++++++---- .../wallet/transactions/TransactionAdapter.kt | 27 ++++++++++++++++++---- .../withdraw/TransactionWithdrawalComposable.kt | 13 +++++++---- 4 files changed, 46 insertions(+), 20 deletions(-) (limited to 'wallet/src/main/java/net/taler') 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 c08bc76..7de16b6 100644 --- a/wallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt @@ -83,11 +83,14 @@ fun TransactionPaymentComposable( amount = t.amountRaw, amountType = AmountType.Neutral, ) - TransactionAmountComposable( - label = stringResource(id = R.string.withdraw_fees), - amount = t.amountEffective - t.amountRaw, - amountType = AmountType.Negative, - ) + val fee = t.amountEffective - t.amountRaw + if (!fee.isZero()) { + TransactionAmountComposable( + label = stringResource(id = R.string.withdraw_fees), + amount = fee, + amountType = AmountType.Negative, + ) + } if (t.posConfirmation != null) { TransactionInfoComposable( label = stringResource(id = R.string.payment_confirmation_code), 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 ac5e2da..82dceb5 100644 --- a/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt @@ -79,11 +79,14 @@ fun TransactionRefundComposable( amount = t.amountRaw, amountType = AmountType.Neutral, ) - TransactionAmountComposable( - label = stringResource(id = R.string.withdraw_fees), - amount = t.amountRaw - t.amountEffective, - amountType = AmountType.Negative, - ) + val fee = t.amountRaw - t.amountEffective + if (!fee.isZero()) { + TransactionAmountComposable( + label = stringResource(id = R.string.withdraw_fees), + amount = fee, + amountType = AmountType.Negative, + ) + } TransactionInfoComposable( label = stringResource(id = R.string.transaction_order), info = t.paymentInfo?.summary ?: "", 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 18480e1..c9ae889 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt @@ -39,6 +39,8 @@ import net.taler.wallet.transactions.TransactionAdapter.TransactionViewHolder import net.taler.wallet.transactions.TransactionMajorState.Aborted import net.taler.wallet.transactions.TransactionMajorState.Failed import net.taler.wallet.transactions.TransactionMajorState.Pending +import net.taler.wallet.transactions.TransactionMinorState.BankConfirmTransfer +import net.taler.wallet.transactions.TransactionMinorState.KycRequired internal class TransactionAdapter( private val listener: OnTransactionClickListener, @@ -112,6 +114,14 @@ internal class TransactionAdapter( private fun bindExtraInfo(transaction: Transaction) { when { + // Goes first so it always shows errors when present + transaction.error != null -> { + extraInfoView.text = + context.getString(R.string.payment_error, transaction.error!!.userFacingMsg) + extraInfoView.setTextColor(red) + extraInfoView.visibility = VISIBLE + } + transaction.txState.major == Aborted -> { extraInfoView.setText(R.string.payment_aborted) extraInfoView.setTextColor(red) @@ -124,11 +134,18 @@ internal class TransactionAdapter( extraInfoView.visibility = VISIBLE } - transaction.error != null -> { - extraInfoView.text = - context.getString(R.string.payment_error, transaction.error!!.userFacingMsg) - extraInfoView.setTextColor(red) - extraInfoView.visibility = VISIBLE + transaction.txState.major == Pending -> when (transaction.txState.minor) { + BankConfirmTransfer -> { + extraInfoView.setText(R.string.withdraw_waiting_confirm) + extraInfoView.setTextColor(amountColor) + extraInfoView.visibility = VISIBLE + } + KycRequired -> { + extraInfoView.setText(R.string.transaction_action_kyc) + extraInfoView.setTextColor(amountColor) + extraInfoView.visibility = VISIBLE + } + else -> extraInfoView.visibility = GONE } transaction is TransactionWithdrawal && !transaction.confirmed -> { 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 79cfc5e..378e283 100644 --- a/wallet/src/main/java/net/taler/wallet/withdraw/TransactionWithdrawalComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/withdraw/TransactionWithdrawalComposable.kt @@ -86,11 +86,14 @@ fun TransactionWithdrawalComposable( amount = t.amountRaw, amountType = AmountType.Neutral, ) - TransactionAmountComposable( - label = stringResource(id = R.string.withdraw_fees), - amount = t.amountRaw - t.amountEffective, - amountType = AmountType.Negative, - ) + val fee = t.amountRaw - t.amountEffective + if (!fee.isZero()) { + TransactionAmountComposable( + label = stringResource(id = R.string.withdraw_fees), + amount = fee, + amountType = AmountType.Negative, + ) + } TransactionInfoComposable( label = stringResource(id = R.string.withdraw_exchange), info = cleanExchange(t.exchangeBaseUrl), -- cgit v1.2.3