gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-android] branch master updated (a94022d -> 17fe2f7)


From: gnunet
Subject: [taler-taler-android] branch master updated (a94022d -> 17fe2f7)
Date: Tue, 19 May 2020 20:17:48 +0200

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

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

    from a94022d  [wallet] upgrade to latest core and fix sorting bug
     new e3edd5f  [wallet] show transaction errors to user
     new 17fe2f7  [wallet] Implement detail page for refresh transaction

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../wallet/transactions/TransactionAdapter.kt      | 22 +++++++++++++++----
 .../transactions/TransactionDetailFragment.kt      | 14 +++++++++++-
 .../net/taler/wallet/transactions/Transactions.kt  | 25 ++++++++++++++++------
 wallet/src/main/res/values/strings.xml             |  2 ++
 4 files changed, 52 insertions(+), 11 deletions(-)

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 e6dad6f..d670b74 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
@@ -92,15 +92,29 @@ internal class TransactionAdapter(
 
             icon.setImageResource(transaction.icon)
             title.text = transaction.getTitle(context)
-            if (transaction is TransactionWithdrawal && 
!transaction.confirmed) {
+            bindExtraInfo(transaction)
+            time.text = transaction.timestamp.ms.toRelativeTime(context)
+            bindAmount(transaction)
+            pendingView.visibility = if (transaction.pending) VISIBLE else GONE
+        }
+
+        private fun bindExtraInfo(transaction: Transaction) {
+            if (transaction.error != null) {
+                extraInfoView.text =
+                    context.getString(R.string.payment_error, 
transaction.error.text)
+                extraInfoView.setTextColor(red)
+                extraInfoView.visibility = VISIBLE
+            } else if (transaction is TransactionWithdrawal && 
!transaction.confirmed) {
                 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
             }
-            time.text = transaction.timestamp.ms.toRelativeTime(context)
-            bindAmount(transaction)
-            pendingView.visibility = if (transaction.pending) VISIBLE else GONE
         }
 
         private fun bindAmount(transaction: Transaction) {
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 6b58824..f78d98f 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
@@ -73,9 +73,10 @@ class TransactionDetailFragment : Fragment() {
             is TransactionWithdrawal -> bind(e)
             is TransactionPayment -> bind(e)
             is TransactionRefund -> bind(e)
+            is TransactionRefresh -> bind(e)
             else -> Toast.makeText(
                 requireContext(),
-                "event ${e.javaClass} not implement",
+                "Transaction ${e.javaClass.simpleName} not implemented.",
                 LENGTH_LONG
             ).show()
         }
@@ -125,6 +126,17 @@ class TransactionDetailFragment : Fragment() {
         bindOrderAndFee(t.info, t.amountRaw, fee)
     }
 
+    private fun bind(t: TransactionRefresh) {
+        effectiveAmountLabel.visibility = GONE
+        effectiveAmountView.visibility = GONE
+        confirmWithdrawalButton.visibility = GONE
+        chosenAmountLabel.visibility = GONE
+        chosenAmountView.visibility = GONE
+        val fee = t.amountEffective
+        feeView.text = getString(R.string.amount_negative, fee.toString())
+        exchangeView.text = cleanExchange(t.exchangeBaseUrl)
+    }
+
     private fun bindOrderAndFee(info: TransactionInfo, raw: Amount, fee: 
Amount) {
         orderAmountView.text = raw.toString()
         feeView.text = getString(R.string.amount_negative, fee.toString())
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt 
b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
index 55579cc..27384d8 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
@@ -46,6 +46,7 @@ abstract class Transaction(
     val transactionId: String,
     val timestamp: Timestamp,
     val pending: Boolean,
+    val error: TransactionError? = null,
     val amountRaw: Amount,
     val amountEffective: Amount
 ) {
@@ -69,6 +70,10 @@ sealed class AmountType {
     object Neutral : AmountType()
 }
 
+class TransactionError(private val ec: Int, private val hint: String?) {
+    val text get() = if (hint == null) "$ec" else "$ec - $hint"
+}
+
 @JsonTypeName("withdrawal")
 class TransactionWithdrawal(
     transactionId: String,
@@ -77,9 +82,10 @@ class TransactionWithdrawal(
     val exchangeBaseUrl: String,
     val confirmed: Boolean,
     val bankConfirmationUrl: String?,
+    error: TransactionError? = null,
     amountRaw: Amount,
     amountEffective: Amount
-) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) 
{
+) : Transaction(transactionId, timestamp, pending, error, amountRaw, 
amountEffective) {
     override val icon = R.drawable.transaction_withdrawal
     override val detailPageLayout = R.layout.fragment_transaction_withdrawal
     override val amountType = AmountType.Positive
@@ -94,9 +100,10 @@ class TransactionPayment(
     pending: Boolean,
     val info: TransactionInfo,
     val status: PaymentStatus,
+    error: TransactionError? = null,
     amountRaw: Amount,
     amountEffective: Amount
-) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) 
{
+) : Transaction(transactionId, timestamp, pending, error, amountRaw, 
amountEffective) {
     override val icon = R.drawable.ic_cash_usd_outline
     override val detailPageLayout = R.layout.fragment_transaction_payment
     override val amountType = AmountType.Negative
@@ -136,15 +143,17 @@ class TransactionRefund(
     val refundedTransactionId: String,
     val info: TransactionInfo,
     val amountInvalid: Amount,
+    error: TransactionError? = null,
     amountRaw: Amount,
     amountEffective: Amount
-) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) 
{
+) : Transaction(transactionId, timestamp, pending, error, amountRaw, 
amountEffective) {
     override val icon = R.drawable.transaction_refund
     override val detailPageLayout = R.layout.fragment_transaction_payment
     override val amountType = AmountType.Positive
     override fun getTitle(context: Context): String {
         return context.getString(R.string.transaction_refund_from, 
info.merchant.name)
     }
+
     override val generalTitleRes = R.string.refund_title
 }
 
@@ -156,15 +165,17 @@ class TransactionTip(
     // TODO status: TipStatus,
     val exchangeBaseUrl: String,
     val merchant: ContractMerchant,
+    error: TransactionError? = null,
     amountRaw: Amount,
     amountEffective: Amount
-) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) 
{
+) : Transaction(transactionId, timestamp, pending, error, amountRaw, 
amountEffective) {
     override val icon = R.drawable.transaction_tip_accepted // TODO different 
when declined
     override val detailPageLayout = R.layout.fragment_transaction_payment
     override val amountType = AmountType.Positive
     override fun getTitle(context: Context): String {
         return context.getString(R.string.transaction_tip_from, merchant.name)
     }
+
     override val generalTitleRes = R.string.tip_title
 }
 
@@ -174,14 +185,16 @@ class TransactionRefresh(
     timestamp: Timestamp,
     pending: Boolean,
     val exchangeBaseUrl: String,
+    error: TransactionError? = null,
     amountRaw: Amount,
     amountEffective: Amount
-) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) 
{
+) : Transaction(transactionId, timestamp, pending, error, amountRaw, 
amountEffective) {
     override val icon = R.drawable.transaction_refresh
-    override val detailPageLayout = R.layout.fragment_transaction_payment
+    override val detailPageLayout = R.layout.fragment_transaction_withdrawal
     override val amountType = AmountType.Negative
     override fun getTitle(context: Context): String {
         return context.getString(R.string.transaction_refresh)
     }
+
     override val generalTitleRes = R.string.transaction_refresh
 }
diff --git a/wallet/src/main/res/values/strings.xml 
b/wallet/src/main/res/values/strings.xml
index e815e9b..7d76806 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -87,6 +87,8 @@ GNU Taler is immune against many types of fraud, such as 
phishing of credit card
     <string name="payment_balance_insufficient">Balance insufficient!</string>
     <string name="payment_show_details">Show Details</string>
     <string name="payment_hide_details">Hide Details</string>
+    <string name="payment_aborted">Aborted</string>
+    <string name="payment_failed">Failed</string>
     <string name="payment_initiated">Payment initiated</string>
     <string name="payment_already_paid_title">Already paid</string>
     <string name="payment_already_paid">You\'ve already paid for this 
purchase.</string>

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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