commit 06f9502134a10bc55d799ea1ddd63b3c52c2e0a1
parent 2f0b4a8ba263325f28701a001af2635b7fa96498
Author: Iván Ávalos <avalos@disroot.org>
Date: Wed, 30 Apr 2025 22:05:52 +0200
[wallet] confirmation dialog for cancelling payment
Diffstat:
4 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt b/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt
@@ -32,6 +32,7 @@ import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
+import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
import kotlinx.coroutines.launch
@@ -116,21 +117,27 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
}
ui.bottom.cancelButton.isEnabled = true
ui.bottom.cancelButton.setOnClickListener {
- transactionManager.abortTransaction(
- payStatus.transactionId,
- onSuccess = {
- Snackbar.make(requireView(), getString(R.string.payment_aborted), LENGTH_LONG).show()
- findNavController().popBackStack()
- },
- onError = { error ->
- Log.e(TAG, "Error abortTransaction $error")
- if (model.devMode.value == false) {
- showError(error.userFacingMsg)
- } else {
- showError(error)
- }
- }
- )
+ MaterialAlertDialogBuilder(requireContext())
+ .setTitle(R.string.payment_cancel_dialog_title)
+ .setMessage(R.string.payment_cancel_dialog_message)
+ .setNeutralButton(R.string.button_back) { dialog, _ -> dialog.dismiss() }
+ .setNegativeButton(R.string.payment_cancel_dialog_title) { _, _ ->
+ transactionManager.abortTransaction(
+ payStatus.transactionId,
+ onSuccess = {
+ Snackbar.make(requireView(), getString(R.string.payment_aborted), LENGTH_LONG).show()
+ findNavController().popBackStack()
+ },
+ onError = { error ->
+ Log.e(TAG, "Error abortTransaction $error")
+ if (model.devMode.value == false) {
+ showError(error.userFacingMsg)
+ } else {
+ showError(error)
+ }
+ }
+ )
+ }.show()
}
}
is PayStatus.InsufficientBalance -> {
diff --git a/wallet/src/main/res/layout-w550dp/payment_bottom_bar.xml b/wallet/src/main/res/layout-w550dp/payment_bottom_bar.xml
@@ -86,6 +86,7 @@
android:enabled="false"
style="@style/Widget.Material3.Button.OutlinedButton"
android:text="@string/payment_button_cancel"
+ android:textColor="?colorError"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/confirmButton"
app:layout_constraintHorizontal_bias="0.0"
diff --git a/wallet/src/main/res/layout/payment_bottom_bar.xml b/wallet/src/main/res/layout/payment_bottom_bar.xml
@@ -88,6 +88,7 @@
android:enabled="false"
style="@style/Widget.Material3.Button.OutlinedButton"
android:text="@string/payment_button_cancel"
+ android:textColor="?colorError"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/confirmButton"
app:layout_constraintHorizontal_bias="0.0"
diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml
@@ -47,7 +47,7 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card
<!-- General -->
<string name="actions">Actions</string>
- <string name="button_back">Go Back</string>
+ <string name="button_back">Go back</string>
<string name="button_scan_qr_code">Scan Taler QR code</string>
<string name="button_scan_qr_code_label">Scan QR code</string>
<string name="cancel">Cancel</string>
@@ -196,6 +196,8 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card
<string name="payment_balance_insufficient_max">Balance insufficient! Maximum is %1$s</string>
<string name="payment_button_cancel">Cancel</string>
<string name="payment_button_confirm">Confirm payment</string>
+ <string name="payment_cancel_dialog_message">Are you sure you want to cancel this payment? You won\'t be able to complete it later. Alternatively, you can simply exit this screen and come back later.</string>
+ <string name="payment_cancel_dialog_title">Cancel payment</string>
<string name="payment_confirmation_code">Confirmation code</string>
<string name="payment_create_order">Create order</string>
<string name="payment_error">Error: %s</string>