gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-android] branch master updated: [wallet] Add test option in


From: gnunet
Subject: [taler-taler-android] branch master updated: [wallet] Add test option in dev mode and remove backup option
Date: Tue, 28 Mar 2023 20:06:37 +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.

The following commit(s) were added to refs/heads/master by this push:
     new 4d0fabf  [wallet] Add test option in dev mode and remove backup option
4d0fabf is described below

commit 4d0fabf804e1afffd91927d9805a026e8aaad777
Author: Torsten Grote <t@grobox.de>
AuthorDate: Tue Mar 28 14:08:37 2023 -0300

    [wallet] Add test option in dev mode and remove backup option
    
    to not give false impression that there's an actual backup/
---
 .../src/main/java/net/taler/wallet/MainActivity.kt |  1 -
 .../main/java/net/taler/wallet/MainViewModel.kt    | 24 +++++-----
 .../wallet/settings/BackupSettingsFragment.kt      | 29 ------------
 .../net/taler/wallet/settings/SettingsFragment.kt  | 25 +++++------
 wallet/src/main/res/navigation/nav_graph.xml       |  8 ----
 wallet/src/main/res/values/strings.xml             |  5 +--
 wallet/src/main/res/xml/settings_backup.xml        | 51 ----------------------
 wallet/src/main/res/xml/settings_main.xml          | 14 +++---
 8 files changed, 35 insertions(+), 122 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/MainActivity.kt 
b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
index e91b983..bf95475 100644
--- a/wallet/src/main/java/net/taler/wallet/MainActivity.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
@@ -344,7 +344,6 @@ class MainActivity : AppCompatActivity(), 
OnNavigationItemSelectedListener,
         pref: Preference,
     ): Boolean {
         when (pref.key) {
-            "pref_backup" -> 
nav.navigate(R.id.action_nav_settings_to_nav_settings_backup)
             "pref_exchanges" -> 
nav.navigate(R.id.action_nav_settings_to_nav_settings_exchanges)
         }
         return true
diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt 
b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
index bbd3ca3..2ad6f6b 100644
--- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
@@ -50,9 +50,6 @@ import net.taler.wallet.tip.TipManager
 import net.taler.wallet.transactions.TransactionManager
 import net.taler.wallet.withdraw.WithdrawManager
 import org.json.JSONObject
-import java.util.concurrent.TimeUnit.DAYS
-import java.util.concurrent.TimeUnit.MINUTES
-import kotlin.random.Random
 
 const val TAG = "taler-wallet"
 
@@ -97,13 +94,6 @@ class MainViewModel(
     private val mScanCodeEvent = MutableLiveData<Event<Boolean>>()
     val scanCodeEvent: LiveData<Event<Boolean>> = mScanCodeEvent
 
-    private val mLastBackup = MutableLiveData(
-        // fake backup time until we actually do backup
-        System.currentTimeMillis() -
-                Random.nextLong(MINUTES.toMillis(5), DAYS.toMillis(2))
-    )
-    val lastBackup: LiveData<Long> = mLastBackup
-
     override fun onVersionReceived(versionInfo: WalletCoreVersion) {
         exchangeVersion = versionInfo.exchange
         merchantVersion = versionInfo.merchant
@@ -207,6 +197,20 @@ class MainViewModel(
         mScanCodeEvent.value = true.toEvent()
     }
 
+    fun runIntegrationTest() {
+        viewModelScope.launch {
+            api.request<Unit>("runIntegrationTest") {
+                put("amountToWithdraw", "KUDOS:42")
+                put("amountToSpend", "KUDOS:23")
+                put("bankBaseUrl", "https://bank.demo.taler.net/";)
+                put("bankAccessApiBaseUrl", 
"https://bank.demo.taler.net/demobanks/default/access-api/";)
+                put("exchangeBaseUrl", "https://exchange.demo.taler.net/";)
+                put("merchantBaseUrl", "https://backend.demo.taler.net/";)
+                put("merchantAuthToken", "secret-token:sandbox")
+            }
+        }
+    }
+
 }
 
 sealed class AmountResult {
diff --git 
a/wallet/src/main/java/net/taler/wallet/settings/BackupSettingsFragment.kt 
b/wallet/src/main/java/net/taler/wallet/settings/BackupSettingsFragment.kt
deleted file mode 100644
index e9641a3..0000000
--- a/wallet/src/main/java/net/taler/wallet/settings/BackupSettingsFragment.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * This file is part of GNU Taler
- * (C) 2020 Taler Systems S.A.
- *
- * GNU Taler is free software; you can redistribute it and/or modify it under 
the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 3, or (at your option) any later version.
- *
- * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
- * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
- */
-
-package net.taler.wallet.settings
-
-import android.os.Bundle
-import androidx.preference.PreferenceFragmentCompat
-import net.taler.wallet.R
-
-class BackupSettingsFragment : PreferenceFragmentCompat() {
-
-    override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: 
String?) {
-        setPreferencesFromResource(R.xml.settings_backup, rootKey)
-    }
-
-}
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 11c252b..927d4a9 100644
--- a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt
@@ -27,7 +27,6 @@ import 
com.google.android.material.dialog.MaterialAlertDialogBuilder
 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.toRelativeTime
 import net.taler.qtart.BuildConfig.WALLET_CORE_VERSION
 import net.taler.wallet.BuildConfig.FLAVOR
 import net.taler.wallet.BuildConfig.VERSION_CODE
@@ -44,7 +43,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
     private val settingsManager get() = model.settingsManager
     private val withdrawManager by lazy { model.withdrawManager }
 
-    private lateinit var prefBackup: Preference
     private lateinit var prefDevMode: SwitchPreferenceCompat
     private lateinit var prefWithdrawTest: Preference
     private lateinit var prefLogcat: Preference
@@ -53,10 +51,10 @@ class SettingsFragment : PreferenceFragmentCompat() {
     private lateinit var prefVersionCore: Preference
     private lateinit var prefVersionExchange: Preference
     private lateinit var prefVersionMerchant: Preference
+    private lateinit var prefTest: Preference
     private lateinit var prefReset: Preference
     private val devPrefs by lazy {
         listOf(
-            prefBackup,
             prefWithdrawTest,
             prefLogcat,
             prefExportDb,
@@ -64,20 +62,21 @@ class SettingsFragment : PreferenceFragmentCompat() {
             prefVersionCore,
             prefVersionExchange,
             prefVersionMerchant,
-            prefReset
+            prefTest,
+            prefReset,
         )
     }
 
     private val logLauncher = 
registerForActivityResult(CreateDocument("text/plain")) { uri ->
         settingsManager.exportLogcat(uri)
     }
-    private val dbExportLauncher = 
registerForActivityResult(CreateDocument("application/json")) { uri ->
-        settingsManager.exportDb(uri)
-    }
+    private val dbExportLauncher =
+        registerForActivityResult(CreateDocument("application/json")) { uri ->
+            settingsManager.exportDb(uri)
+        }
 
     override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: 
String?) {
         setPreferencesFromResource(R.xml.settings_main, rootKey)
-        prefBackup = findPreference("pref_backup")!!
         prefDevMode = findPreference("pref_dev_mode")!!
         prefWithdrawTest = findPreference("pref_testkudos")!!
         prefLogcat = findPreference("pref_logcat")!!
@@ -86,17 +85,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
         prefVersionCore = findPreference("pref_version_core")!!
         prefVersionExchange = 
findPreference("pref_version_protocol_exchange")!!
         prefVersionMerchant = 
findPreference("pref_version_protocol_merchant")!!
+        prefTest = findPreference("pref_test")!!
         prefReset = findPreference("pref_reset")!!
     }
 
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
         super.onViewCreated(view, savedInstanceState)
 
-        model.lastBackup.observe(viewLifecycleOwner) {
-            val time = it.toRelativeTime(requireContext())
-            prefBackup.summary = getString(R.string.backup_last, time)
-        }
-
         model.devMode.observe(viewLifecycleOwner) { enabled ->
             prefDevMode.isChecked = enabled
             if (enabled) {
@@ -136,6 +131,10 @@ class SettingsFragment : PreferenceFragmentCompat() {
             true
         }
 
+        prefTest.setOnPreferenceClickListener {
+            model.runIntegrationTest()
+            true
+        }
         prefReset.setOnPreferenceClickListener {
             showResetDialog()
             true
diff --git a/wallet/src/main/res/navigation/nav_graph.xml 
b/wallet/src/main/res/navigation/nav_graph.xml
index 2b9463b..6508539 100644
--- a/wallet/src/main/res/navigation/nav_graph.xml
+++ b/wallet/src/main/res/navigation/nav_graph.xml
@@ -106,9 +106,6 @@
         <action
             android:id="@+id/action_nav_settings_to_nav_settings_exchanges"
             app:destination="@id/nav_settings_exchanges" />
-        <action
-            android:id="@+id/action_nav_settings_to_nav_settings_backup"
-            app:destination="@id/nav_settings_backup" />
     </fragment>
 
     <fragment
@@ -167,11 +164,6 @@
             app:popUpTo="@id/nav_main" />
     </fragment>
 
-    <fragment
-        android:id="@+id/nav_settings_backup"
-        android:name="net.taler.wallet.settings.BackupSettingsFragment"
-        android:label="@string/nav_settings_backup" />
-
     <fragment
         android:id="@+id/nav_peer_pull"
         android:name="net.taler.wallet.peer.OutgoingPullFragment"
diff --git a/wallet/src/main/res/values/strings.xml 
b/wallet/src/main/res/values/strings.xml
index c313248..67d2033 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -245,12 +245,11 @@ GNU Taler is immune against many types of fraud, such as 
phishing of credit card
     <string name="settings_version_protocol_exchange">Supported Exchange 
Versions</string>
     <string name="settings_version_protocol_merchant">Supported Merchant 
Versions</string>
     <string name="settings_version_unknown">Unknown</string>
+    <string name="settings_test">Run integration test</string>
+    <string name="settings_test_summary">Performs test transactions with demo 
setup</string>
     <string name="settings_reset">Reset Wallet (dangerous!)</string>
     <string name="settings_reset_summary">Throws away your money</string>
 
-    <string name="nav_settings_backup">Backup</string>
-    <string name="backup_last">Last Backup: %s</string>
-
     <string name="refund_title">Refund</string>
     <string name="refund_error">Error processing refund</string>
     <string name="refund_success">Refund received: %s</string>
diff --git a/wallet/src/main/res/xml/settings_backup.xml 
b/wallet/src/main/res/xml/settings_backup.xml
deleted file mode 100644
index aa9b129..0000000
--- a/wallet/src/main/res/xml/settings_backup.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
-  ~ This file is part of GNU Taler
-  ~ (C) 2020 Taler Systems S.A.
-  ~
-  ~ GNU Taler is free software; you can redistribute it and/or modify it under 
the
-  ~ terms of the GNU General Public License as published by the Free Software
-  ~ Foundation; either version 3, or (at your option) any later version.
-  ~
-  ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT 
ANY
-  ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
-  ~ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License along 
with
-  ~ GNU Taler; see the file COPYING.  If not, see 
<http://www.gnu.org/licenses/>
-  -->
-
-<PreferenceScreen
-    xmlns:app="http://schemas.android.com/apk/res-auto";>
-
-    <SwitchPreferenceCompat
-        app:defaultValue="@bool/settings_backup_default"
-        app:fragment="net.taler.wallet.settings.BackupSettingsFragment"
-        app:icon="@drawable/ic_baseline_backup"
-        app:key="pref_backup_switch"
-        app:summaryOff="Backup is disabled"
-        app:summaryOn="Backup is enabled"
-        app:title="Backup my wallet" />
-
-    <Preference
-        app:dependency="pref_backup_switch"
-        app:icon="@drawable/ic_baseline_account_tree"
-        app:key="pref_backup_services"
-        app:selectable="false"
-        app:summary="1 backup service set up"
-        app:title="Backup services" />
-
-    <PreferenceCategory
-        app:iconSpaceReserved="false"
-        app:summary="At least one of these is required to restore from backup"
-        app:title="Recovery Options">
-
-        <Preference
-            app:dependency="pref_backup_switch"
-            app:icon="@drawable/ic_baseline_vpn_key"
-            app:key="pref_backup_secret"
-            app:selectable="false"
-            app:title="Show backup secret" />
-
-    </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/wallet/src/main/res/xml/settings_main.xml 
b/wallet/src/main/res/xml/settings_main.xml
index 101aa37..3a6d991 100644
--- a/wallet/src/main/res/xml/settings_main.xml
+++ b/wallet/src/main/res/xml/settings_main.xml
@@ -24,13 +24,6 @@
         app:summary="@string/exchange_settings_summary"
         app:title="@string/exchange_settings_title" />
 
-    <Preference
-        app:fragment="net.taler.wallet.settings.BackupSettingsFragment"
-        app:icon="@drawable/ic_baseline_backup"
-        app:isPreferenceVisible="false"
-        app:key="pref_backup"
-        app:title="Backup"
-        tools:isPreferenceVisible="true" />
 
     <SwitchPreferenceCompat
         app:icon="@drawable/ic_developer_mode"
@@ -98,6 +91,13 @@
         app:title="@string/settings_version_protocol_merchant"
         tools:isPreferenceVisible="true" />
 
+    <Preference
+        app:isPreferenceVisible="false"
+        app:key="pref_test"
+        app:summary="@string/settings_test_summary"
+        app:title="@string/settings_test"
+        tools:isPreferenceVisible="true" />
+
     <Preference
         app:icon="@drawable/ic_nuke"
         app:isPreferenceVisible="false"

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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