summaryrefslogtreecommitdiff
path: root/wallet
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2024-01-03 17:10:37 -0300
committerTorsten Grote <t@grobox.de>2024-01-03 17:10:37 -0300
commit1598fae3c6d0fab955f1ca23dfe79aef85ebb20b (patch)
tree7dd0d5a8dd88b393d3e2c58160965bbe674d9ac3 /wallet
parent034d787f12367c7a62b6ae78db08ae723beda034 (diff)
downloadtaler-android-1598fae3c6d0fab955f1ca23dfe79aef85ebb20b.tar.gz
taler-android-1598fae3c6d0fab955f1ca23dfe79aef85ebb20b.tar.bz2
taler-android-1598fae3c6d0fab955f1ca23dfe79aef85ebb20b.zip
[wallet] Add option to add all known dev exchanges
to ease testing and finding at least one that works
Diffstat (limited to 'wallet')
-rw-r--r--wallet/src/main/java/net/taler/wallet/exchanges/ExchangeListFragment.kt20
-rw-r--r--wallet/src/main/java/net/taler/wallet/exchanges/ExchangeManager.kt17
-rw-r--r--wallet/src/main/res/menu/exchange_list.xml25
-rw-r--r--wallet/src/main/res/values/strings.xml1
4 files changed, 63 insertions, 0 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeListFragment.kt b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeListFragment.kt
index 439ec2f..c622d65 100644
--- a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeListFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeListFragment.kt
@@ -18,12 +18,17 @@ package net.taler.wallet.exchanges
import android.os.Bundle
import android.view.LayoutInflater
+import android.view.Menu
+import android.view.MenuInflater
+import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
+import androidx.core.view.MenuProvider
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
+import androidx.lifecycle.Lifecycle.State.RESUMED
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager.VERTICAL
@@ -55,6 +60,21 @@ open class ExchangeListFragment : Fragment(), ExchangeClickListener {
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ requireActivity().addMenuProvider(object : MenuProvider {
+ override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
+ if (model.devMode.value == true) {
+ menuInflater.inflate(R.menu.exchange_list, menu)
+ }
+ }
+
+ override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
+ if (menuItem.itemId == R.id.action_add_dev_exchanges) {
+ exchangeManager.addDevExchanges()
+ }
+ return true
+ }
+ }, viewLifecycleOwner, RESUMED)
+
ui.list.apply {
adapter = exchangeAdapter
addItemDecoration(DividerItemDecoration(context, VERTICAL))
diff --git a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeManager.kt b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeManager.kt
index 65f5c5c..2048b7c 100644
--- a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeManager.kt
@@ -21,6 +21,7 @@ import androidx.annotation.WorkerThread
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch
@@ -103,4 +104,20 @@ class ExchangeManager(
return exchange
}
+ fun addDevExchanges() {
+ scope.launch {
+ listOf(
+ "https://exchange.demo.taler.net/",
+ "https://exchange.test.taler.net/",
+ "https://exchange.head.taler.net/",
+ "https://exchange.taler.ar/",
+ "https://exchange.taler.fdold.eu/",
+ "https://exchange.taler.grothoff.org/",
+ ).forEach { exchangeUrl ->
+ add(exchangeUrl)
+ delay(100)
+ }
+ }
+ }
+
}
diff --git a/wallet/src/main/res/menu/exchange_list.xml b/wallet/src/main/res/menu/exchange_list.xml
new file mode 100644
index 0000000..21c028d
--- /dev/null
+++ b/wallet/src/main/res/menu/exchange_list.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2024 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/>
+ -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <item
+ android:id="@+id/action_add_dev_exchanges"
+ android:title="@string/exchange_list_add_dev"
+ app:showAsAction="never" />
+
+</menu>
diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml
index 058c30b..731b03a 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -227,6 +227,7 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card
<string name="exchange_add_url">Enter address of exchange</string>
<string name="exchange_add_error">Could not add exchange</string>
<string name="exchange_list_error">Could not list exchanges</string>
+ <string name="exchange_list_add_dev">Add development exchanges</string>
<string name="exchange_menu_manual_withdraw">Withdraw</string>
<string name="exchange_fee_withdrawal_fee_label">Withdrawal Fee:</string>