[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-android] 01/04: [wallet] Expand JSON error in XML transacti
From: |
gnunet |
Subject: |
[taler-taler-android] 01/04: [wallet] Expand JSON error in XML transaction detail fragments |
Date: |
Tue, 21 Mar 2023 17:28:58 +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 b1a114987cec6634645f7ee2b5962a9e3131a64c
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Thu Mar 9 23:51:08 2023 -0600
[wallet] Expand JSON error in XML transaction detail fragments
bug 0007606
---
.../transactions/TransactionDetailFragment.kt | 26 ++++++++++++++++++++++
.../transactions/TransactionPaymentFragment.kt | 7 ++++++
.../transactions/TransactionRefreshFragment.kt | 7 ++++++
.../transactions/TransactionRefundFragment.kt | 7 ++++++
.../transactions/TransactionWithdrawalFragment.kt | 6 +++++
.../res/layout/fragment_transaction_payment.xml | 19 +++++++++++++++-
.../res/layout/fragment_transaction_withdrawal.xml | 19 +++++++++++++++-
7 files changed, 89 insertions(+), 2 deletions(-)
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 1905a05..46d605c 100644
---
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
+++
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
@@ -28,9 +28,12 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.google.android.material.dialog.MaterialAlertDialogBuilder
+import kotlinx.serialization.json.Json
import net.taler.common.Amount
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
+import net.taler.wallet.backend.TalerErrorInfo
+import net.taler.wallet.compose.copyToClipBoard
import net.taler.wallet.getAttrColor
import net.taler.wallet.launchInAppBrowser
@@ -38,6 +41,7 @@ abstract class TransactionDetailFragment : Fragment() {
private val model: MainViewModel by activityViewModels()
val transactionManager by lazy { model.transactionManager }
+ val devMode by lazy { model.devMode }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -122,4 +126,26 @@ abstract class TransactionDetailFragment : Fragment() {
findNavController().popBackStack()
}
+ private val json = Json { prettyPrint = true }
+
+ protected fun onShowErrorButtonClicked(t: Transaction) {
+ t.error?.let { err ->
+ val message = json.encodeToString(TalerErrorInfo.serializer(), err)
+ MaterialAlertDialogBuilder(requireContext(),
R.style.MaterialAlertDialog_Material3)
+ .setTitle(getString(R.string.nav_error))
+ .setMessage(message)
+ .setNeutralButton(R.string.close) { dialog, _ ->
+ dialog.cancel()
+ }
+ .setPositiveButton(R.string.copy) { _, _ ->
+ copyToClipBoard(
+ requireContext(),
+ getString(R.string.nav_error),
+ message,
+ )
+ }
+ .show()
+ }
+ }
+
}
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 ec18c98..068a41e 100644
---
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionPaymentFragment.kt
+++
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionPaymentFragment.kt
@@ -19,6 +19,7 @@ package net.taler.wallet.transactions
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
+import android.view.View.VISIBLE
import android.view.ViewGroup
import net.taler.common.toAbsoluteTime
import net.taler.wallet.databinding.FragmentTransactionPaymentBinding
@@ -55,6 +56,12 @@ class TransactionPaymentFragment :
TransactionDetailFragment() {
ui.deleteButton.setOnClickListener {
onDeleteButtonClicked(t)
}
+ if (devMode.value == true && t.error != null) {
+ ui.showErrorButton.visibility = VISIBLE
+ ui.showErrorButton.setOnClickListener {
+ onShowErrorButtonClicked(t)
+ }
+ }
}
}
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 4c26449..36d3bc7 100644
---
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt
+++
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt
@@ -20,6 +20,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
+import android.view.View.VISIBLE
import android.view.ViewGroup
import net.taler.common.toAbsoluteTime
import net.taler.wallet.R
@@ -55,6 +56,12 @@ class TransactionRefreshFragment :
TransactionDetailFragment() {
ui.deleteButton.setOnClickListener {
onDeleteButtonClicked(t)
}
+ if (devMode.value == true && t.error != null) {
+ ui.showErrorButton.visibility = VISIBLE
+ ui.showErrorButton.setOnClickListener {
+ onShowErrorButtonClicked(t)
+ }
+ }
}
}
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 125ae0c..9c30609 100644
---
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt
+++
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt
@@ -19,6 +19,7 @@ package net.taler.wallet.transactions
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
+import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.core.content.ContextCompat.getColor
import net.taler.common.toAbsoluteTime
@@ -60,6 +61,12 @@ class TransactionRefundFragment :
TransactionDetailFragment() {
ui.deleteButton.setOnClickListener {
onDeleteButtonClicked(t)
}
+ if (devMode.value == true && t.error != null) {
+ ui.showErrorButton.visibility = VISIBLE
+ ui.showErrorButton.setOnClickListener {
+ onShowErrorButtonClicked(t)
+ }
+ }
}
}
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 9a43efa..ad70d2f 100644
---
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
+++
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
@@ -73,6 +73,12 @@ class TransactionWithdrawalFragment :
TransactionDetailFragment() {
ui.deleteButton.setOnClickListener {
onDeleteButtonClicked(t)
}
+ if (devMode.value == true && t.error != null) {
+ ui.showErrorButton.visibility = VISIBLE
+ ui.showErrorButton.setOnClickListener {
+ onShowErrorButtonClicked(t)
+ }
+ }
}
}
diff --git a/wallet/src/main/res/layout/fragment_transaction_payment.xml
b/wallet/src/main/res/layout/fragment_transaction_payment.xml
index b57315f..5b674bd 100644
--- a/wallet/src/main/res/layout/fragment_transaction_payment.xml
+++ b/wallet/src/main/res/layout/fragment_transaction_payment.xml
@@ -122,11 +122,28 @@
app:backgroundTint="?colorError"
app:icon="@drawable/ic_delete"
app:iconTint="?colorOnError"
- app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/showErrorButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/orderIdView" />
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/showErrorButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginVertical="10dp"
+ android:visibility="gone"
+ android:text="@string/nav_error"
+ app:backgroundTint="?colorError"
+ app:icon="@drawable/ic_error"
+ android:textColor="?colorOnError"
+ app:iconTint="?colorOnError"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/deleteButton"
+ tools:visibility="visible" />
+
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
diff --git a/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml
b/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml
index 100ddbc..87530a4 100644
--- a/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml
+++ b/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml
@@ -149,11 +149,28 @@
app:icon="@drawable/ic_delete"
android:textColor="?colorOnError"
app:iconTint="?colorOnError"
- app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/showErrorButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/exchangeView" />
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/showErrorButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginVertical="10dp"
+ android:visibility="gone"
+ android:text="@string/nav_error"
+ app:backgroundTint="?colorError"
+ app:icon="@drawable/ic_error"
+ android:textColor="?colorOnError"
+ app:iconTint="?colorOnError"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/deleteButton"
+ tools:visibility="visible" />
+
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.