[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-android] 01/02: [wallet] expose error message when withdraw
From: |
gnunet |
Subject: |
[taler-taler-android] 01/02: [wallet] expose error message when withdrawing TESTKUDOS fails |
Date: |
Tue, 13 Oct 2020 15:14:49 +0200 |
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 e9aae97e558c0f57479d5f827a0fc6b802bfee81
Author: Torsten Grote <t@grobox.de>
AuthorDate: Tue Oct 13 09:42:22 2020 -0300
[wallet] expose error message when withdrawing TESTKUDOS fails
---
wallet/src/main/java/net/taler/wallet/MainViewModel.kt | 2 +-
.../java/net/taler/wallet/settings/SettingsFragment.kt | 10 +++++++++-
.../main/java/net/taler/wallet/withdraw/WithdrawManager.kt | 14 ++++++++++----
wallet/src/main/res/values/strings.xml | 1 +
4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
index 9e49f54..7bb6ad9 100644
--- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
@@ -132,7 +132,7 @@ class MainViewModel(val app: Application) :
AndroidViewModel(app) {
@UiThread
fun dangerouslyReset() {
api.sendRequest("reset")
- withdrawManager.testWithdrawalInProgress.value = false
+ withdrawManager.testWithdrawalStatus.value = null
mBalances.value = emptyList()
}
diff --git a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt
b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt
index d2f30aa..bd6ce1a 100644
--- a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt
@@ -25,6 +25,7 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_SHORT
import com.google.android.material.snackbar.Snackbar
+import net.taler.common.showError
import net.taler.common.showLogViewer
import net.taler.common.toRelativeTime
import net.taler.wallet.BuildConfig.FLAVOR
@@ -33,6 +34,7 @@ import net.taler.wallet.BuildConfig.VERSION_NAME
import net.taler.wallet.BuildConfig.WALLET_CORE_VERSION
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
+import net.taler.wallet.withdraw.WithdrawTestStatus
class SettingsFragment : PreferenceFragmentCompat() {
@@ -98,9 +100,15 @@ class SettingsFragment : PreferenceFragmentCompat() {
true
}
- withdrawManager.testWithdrawalInProgress.observe(viewLifecycleOwner, {
loading ->
+ withdrawManager.testWithdrawalStatus.observe(viewLifecycleOwner, {
status ->
+ if (status == null) return@observe
+ val loading = status is WithdrawTestStatus.Withdrawing
prefWithdrawTest.isEnabled = !loading
model.showProgressBar.value = loading
+ if (status is WithdrawTestStatus.Error) {
+ requireActivity().showError(R.string.withdraw_error_test,
status.message)
+ }
+ withdrawManager.testWithdrawalStatus.value = null
})
prefWithdrawTest.setOnPreferenceClickListener {
withdrawManager.withdrawTestkudos()
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
index 5e11c04..5afb125 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
@@ -59,6 +59,12 @@ sealed class WithdrawStatus {
data class Error(val message: String?) : WithdrawStatus()
}
+sealed class WithdrawTestStatus {
+ object Withdrawing : WithdrawTestStatus()
+ object Success : WithdrawTestStatus()
+ data class Error(val message: String) : WithdrawTestStatus()
+}
+
@Serializable
data class WithdrawalDetailsForUri(
val amount: Amount,
@@ -84,7 +90,7 @@ class WithdrawManager(
) {
val withdrawStatus = MutableLiveData<WithdrawStatus>()
- val testWithdrawalInProgress = MutableLiveData(false)
+ val testWithdrawalStatus = MutableLiveData<WithdrawTestStatus>()
private val _exchangeSelection =
MutableLiveData<Event<ExchangeSelection>>()
val exchangeSelection: LiveData<Event<ExchangeSelection>> =
_exchangeSelection
@@ -92,11 +98,11 @@ class WithdrawManager(
private set
fun withdrawTestkudos() = scope.launch {
- testWithdrawalInProgress.value = true
+ testWithdrawalStatus.value = WithdrawTestStatus.Withdrawing
api.request<Unit>("withdrawTestkudos").onError {
- testWithdrawalInProgress.postValue(false)
+ testWithdrawalStatus.value =
WithdrawTestStatus.Error(it.userFacingMsg)
}.onSuccess {
- testWithdrawalInProgress.postValue(false)
+ testWithdrawalStatus.value = WithdrawTestStatus.Success
}
}
diff --git a/wallet/src/main/res/values/strings.xml
b/wallet/src/main/res/values/strings.xml
index 2e32c88..2fad06a 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -120,6 +120,7 @@ GNU Taler is immune against many types of fraud, such as
phishing of credit card
<string name="withdraw_manual_check_fees">Check fees</string>
<string name="withdraw_error_title">Withdrawal Error</string>
<string name="withdraw_error_message">Withdrawing is currently not
possible. Please try again later!</string>
+ <string name="withdraw_error_test">Error withdrawing TESTKUDOS</string>
<string name="exchange_settings_title">Exchanges</string>
<string name="exchange_settings_summary">Manage list of exchanges known to
this wallet</string>
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.