taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

commit 13c4700300ff83a88d0f2eabbdb306e94c78c4cc
parent d8c2ec321c1f7e2f10e0599244b8af7d20d6d8fb
Author: Iván Ávalos <avalos@disroot.org>
Date:   Tue,  4 Jul 2023 11:03:41 -0600

[wallet] Fully remove deprecated status fields

Diffstat:
Mwallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt | 2--
Mwallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt | 32+++++++++++++++++++++++++++-----
Mwallet/src/main/java/net/taler/wallet/transactions/Transactions.kt | 40----------------------------------------
3 files changed, 27 insertions(+), 47 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt b/wallet/src/main/java/net/taler/wallet/payment/TransactionPaymentComposable.kt @@ -40,7 +40,6 @@ import net.taler.wallet.backend.TalerErrorInfo import net.taler.wallet.compose.TalerSurface import net.taler.wallet.transactions.AmountType import net.taler.wallet.transactions.ErrorTransactionButton -import net.taler.wallet.transactions.PaymentStatus import net.taler.wallet.transactions.TransactionAction import net.taler.wallet.transactions.TransactionAction.Abort import net.taler.wallet.transactions.TransactionAction.Retry @@ -148,7 +147,6 @@ fun TransactionPaymentComposablePreview() { fulfillmentUrl = "https://bank.demo.taler.net/", products = listOf(), ), - status = PaymentStatus.Paid, amountRaw = Amount.fromString("TESTKUDOS", "42.1337"), amountEffective = Amount.fromString("TESTKUDOS", "42.23"), error = TalerErrorInfo(code = TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED), diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt @@ -36,7 +36,17 @@ import net.taler.common.exhaustive import net.taler.common.toRelativeTime import net.taler.wallet.R import net.taler.wallet.transactions.TransactionAdapter.TransactionViewHolder +import net.taler.wallet.transactions.TransactionMajorState.Aborted +import net.taler.wallet.transactions.TransactionMajorState.Aborting +import net.taler.wallet.transactions.TransactionMajorState.Deleted +import net.taler.wallet.transactions.TransactionMajorState.Dialog +import net.taler.wallet.transactions.TransactionMajorState.Done +import net.taler.wallet.transactions.TransactionMajorState.Failed +import net.taler.wallet.transactions.TransactionMajorState.None import net.taler.wallet.transactions.TransactionMajorState.Pending +import net.taler.wallet.transactions.TransactionMajorState.Suspended +import net.taler.wallet.transactions.TransactionMajorState.SuspendedAborting +import net.taler.wallet.transactions.TransactionMajorState.Unknown internal class TransactionAdapter( private val listener: OnTransactionClickListener @@ -115,12 +125,24 @@ internal class TransactionAdapter( extraInfoView.setText(R.string.withdraw_waiting_confirm) extraInfoView.setTextColor(amountColor) extraInfoView.visibility = VISIBLE - } else if (transaction is TransactionPayment && transaction.status != PaymentStatus.Paid && transaction.status != PaymentStatus.Accepted) { - extraInfoView.setText(if (transaction.status == PaymentStatus.Aborted) R.string.payment_aborted else R.string.payment_failed) - extraInfoView.setTextColor(amountColor) - extraInfoView.visibility = VISIBLE } else { - extraInfoView.visibility = GONE + when (transaction.txState.major) { + Aborted -> R.string.payment_aborted + Failed -> R.string.payment_failed + None -> null + Pending -> null + Done -> null + Aborting -> null + Suspended -> null + Dialog -> null + SuspendedAborting -> null + Deleted -> null + Unknown -> null + }?.let { + extraInfoView.setText(it) + } ?: { + extraInfoView.visibility = GONE + } } } diff --git a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt @@ -120,30 +120,6 @@ sealed class Transaction { } @Serializable -enum class ExtendedStatus { - @SerialName("pending") - Pending, - - @SerialName("done") - Done, - - @SerialName("aborting") - Aborting, - - @SerialName("aborted") - Aborted, - - @SerialName("suspended") - Suspended, - - @SerialName("failed") - Failed, - - @SerialName("deleted") - Deleted; -} - -@Serializable enum class TransactionAction { // Common States @SerialName("delete") @@ -238,7 +214,6 @@ class TransactionPayment( override val txState: TransactionState, override val txActions: List<TransactionAction>, val info: TransactionInfo, - val status: PaymentStatus, override val error: TalerErrorInfo? = null, override val amountRaw: Amount, override val amountEffective: Amount, @@ -272,21 +247,6 @@ class TransactionInfo( ) @Serializable -enum class PaymentStatus { - @SerialName("aborted") - Aborted, - - @SerialName("failed") - Failed, - - @SerialName("paid") - Paid, - - @SerialName("accepted") - Accepted -} - -@Serializable @SerialName("refund") class TransactionRefund( override val transactionId: String,