[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-android] branch master updated: prompt for reset, hide spu
From: |
gnunet |
Subject: |
[taler-wallet-android] branch master updated: prompt for reset, hide spurious error message |
Date: |
Thu, 19 Dec 2019 22:57:52 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-android.
The following commit(s) were added to refs/heads/master by this push:
new 1fc9eab prompt for reset, hide spurious error message
1fc9eab is described below
commit 1fc9eab2d625cd836108893818afe1c7233fea5c
Author: Florian Dold <address@hidden>
AuthorDate: Thu Dec 19 22:57:49 2019 +0100
prompt for reset, hide spurious error message
---
app/src/main/java/net/taler/wallet/MainActivity.kt | 13 ++++-
.../main/java/net/taler/wallet/PromptPayment.kt | 3 ++
app/src/main/java/net/taler/wallet/Settings.kt | 61 +++++++++++++++++-----
.../main/java/net/taler/wallet/WalletViewModel.kt | 2 +-
.../main/res/layout/fragment_prompt_payment.xml | 2 +-
app/src/main/res/layout/fragment_settings.xml | 4 +-
6 files changed, 67 insertions(+), 18 deletions(-)
diff --git a/app/src/main/java/net/taler/wallet/MainActivity.kt
b/app/src/main/java/net/taler/wallet/MainActivity.kt
index 5ea96a0..3f38a44 100644
--- a/app/src/main/java/net/taler/wallet/MainActivity.kt
+++ b/app/src/main/java/net/taler/wallet/MainActivity.kt
@@ -45,7 +45,7 @@ import
me.zhanghai.android.materialprogressbar.MaterialProgressBar
import java.util.*
-class MainActivity : AppCompatActivity(),
NavigationView.OnNavigationItemSelectedListener {
+class MainActivity : AppCompatActivity(),
NavigationView.OnNavigationItemSelectedListener, ResetDialogEventListener {
lateinit var model: WalletViewModel
@@ -223,4 +223,15 @@ class MainActivity : AppCompatActivity(),
NavigationView.OnNavigationItemSelecte
}
}
}
+
+ override fun onResetConfirmed() {
+ model.dangerouslyReset()
+ val snackbar = Snackbar.make(findViewById(R.id.nav_host_fragment),
"Wallet has been reset", Snackbar.LENGTH_SHORT)
+ snackbar.show()
+ }
+
+ override fun onResetCancelled() {
+ val snackbar = Snackbar.make(findViewById(R.id.nav_host_fragment),
"Reset cancelled", Snackbar.LENGTH_SHORT)
+ snackbar.show()
+ }
}
diff --git a/app/src/main/java/net/taler/wallet/PromptPayment.kt
b/app/src/main/java/net/taler/wallet/PromptPayment.kt
index f5d4bce..2714a7f 100644
--- a/app/src/main/java/net/taler/wallet/PromptPayment.kt
+++ b/app/src/main/java/net/taler/wallet/PromptPayment.kt
@@ -150,6 +150,9 @@ class PromptPayment : Fragment() {
val abortPaymentButton =
view.findViewById<Button>(R.id.button_abort_payment)
+ val errorTextView = view.findViewById<TextView>(R.id.pay_error_text)
+ errorTextView.visibility = View.GONE
+
abortPaymentButton.setOnClickListener {
model.payStatus.value = PayStatus.None()
requireActivity().findNavController(R.id.nav_host_fragment).navigateUp()
diff --git a/app/src/main/java/net/taler/wallet/Settings.kt
b/app/src/main/java/net/taler/wallet/Settings.kt
index 46bf2e3..ab3fec4 100644
--- a/app/src/main/java/net/taler/wallet/Settings.kt
+++ b/app/src/main/java/net/taler/wallet/Settings.kt
@@ -16,30 +16,66 @@
package net.taler.wallet
+import android.app.Dialog
+import android.content.Context
+import android.content.DialogInterface
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
+import androidx.appcompat.app.AlertDialog
+import androidx.fragment.app.DialogFragment
import androidx.lifecycle.ViewModelProviders
+
+interface ResetDialogEventListener {
+ fun onResetConfirmed()
+ fun onResetCancelled()
+}
+
+
+class ResetDialogFragment : DialogFragment() {
+ private lateinit var model: WalletViewModel
+ private lateinit var listener: ResetDialogEventListener
+
+ override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
+ return activity?.let {
+ // Use the Builder class for convenient dialog construction
+ val builder = AlertDialog.Builder(it)
+ builder.setMessage("Do you really want to reset the wallet and
lose all coins and purchases? Consider making a backup first.")
+ .setPositiveButton("Reset") { _, _ ->
+ listener.onResetConfirmed()
+ }
+ .setNegativeButton("Cancel") { _, _ ->
+ listener.onResetCancelled()
+ }
+ // Create the AlertDialog object and return it
+ builder.create()
+ } ?: throw IllegalStateException("Activity cannot be null")
+ }
+
+ override fun onAttach(context: Context) {
+ super.onAttach(context)
+ // Verify that the host activity implements the callback interface
+ try {
+ // Instantiate the NoticeDialogListener so we can send events to
the host
+ listener = context as ResetDialogEventListener
+ } catch (e: ClassCastException) {
+ // The activity doesn't implement the interface, throw exception
+ throw ClassCastException((context.toString() +
+ " must implement ResetDialogEventListener"))
+ }
+ }
+}
+
/**
* A simple [Fragment] subclass.
*
*/
class Settings : Fragment() {
- private lateinit var model: WalletViewModel
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
-
- model = activity?.run {
- ViewModelProviders.of(this)[WalletViewModel::class.java]
- } ?: throw Exception("Invalid Activity")
-
- }
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
@@ -48,10 +84,9 @@ class Settings : Fragment() {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_settings, container,
false)
view.findViewById<Button>(R.id.button_reset_wallet_dangerously).setOnClickListener
{
- model.dangerouslyReset()
+ val d = ResetDialogFragment()
+ d.show(requireActivity().supportFragmentManager,
"walletResetDialog")
}
return view
}
-
-
}
diff --git a/app/src/main/java/net/taler/wallet/WalletViewModel.kt
b/app/src/main/java/net/taler/wallet/WalletViewModel.kt
index 13fa28e..e5e888d 100644
--- a/app/src/main/java/net/taler/wallet/WalletViewModel.kt
+++ b/app/src/main/java/net/taler/wallet/WalletViewModel.kt
@@ -388,7 +388,7 @@ class WalletViewModel(val app: Application) :
AndroidViewModel(app) {
if (!termsOfServiceAccepted) {
val exchange = ei.getJSONObject("exchangeInfo")
val tosText = exchange.getString("termsOfServiceText")
- val tosEtag = exchange.getString("termsOfServiceLastEtag")
+ val tosEtag = exchange.optString("termsOfServiceLastEtag",
"undefined")
withdrawStatus.postValue(
WithdrawStatus.TermsOfServiceReviewRequired(
status.talerWithdrawUri,
diff --git a/app/src/main/res/layout/fragment_prompt_payment.xml
b/app/src/main/res/layout/fragment_prompt_payment.xml
index ac2b88e..1febf9f 100644
--- a/app/src/main/res/layout/fragment_prompt_payment.xml
+++ b/app/src/main/res/layout/fragment_prompt_payment.xml
@@ -7,7 +7,7 @@
tools:context=".PromptPayment">
<TextView
- android:text="Error:"
+ android:text="Error: (placeholder)"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
diff --git a/app/src/main/res/layout/fragment_settings.xml
b/app/src/main/res/layout/fragment_settings.xml
index 6ac8b8d..5b85876 100644
--- a/app/src/main/res/layout/fragment_settings.xml
+++ b/app/src/main/res/layout/fragment_settings.xml
@@ -69,10 +69,10 @@
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
- android:text="Test Settings" />
+ android:text="Developer Settings (be careful!)" />
<Button
- android:text="Reset Wallet (Dangerous!)"
+ android:text="Reset Wallet (dangerous!)"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button_reset_wallet_dangerously"/>
</LinearLayout>
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-android] branch master updated: prompt for reset, hide spurious error message,
gnunet <=