From 1c43ae08a8dae32bebc13623f6a42d3754903618 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 24 Oct 2022 15:21:08 -0300 Subject: [wallet] allow peer pull payment even when no balance --- .../java/net/taler/wallet/exchanges/ExchangeAdapter.kt | 5 +++++ .../net/taler/wallet/exchanges/ExchangeListFragment.kt | 14 ++++++++++---- wallet/src/main/res/menu/exchange.xml | 3 +++ 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'wallet/src') diff --git a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt index e315632..5b0d947 100644 --- a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt @@ -43,6 +43,7 @@ data class ExchangeItem( interface ExchangeClickListener { fun onExchangeSelected(item: ExchangeItem) fun onManualWithdraw(item: ExchangeItem) + fun onPeerReceive(item: ExchangeItem) } internal class ExchangeAdapter( @@ -98,6 +99,10 @@ internal class ExchangeAdapter( listener.onManualWithdraw(item) true } + R.id.action_receive_peer -> { + listener.onPeerReceive(item) + true + } else -> false } } 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 9a96b59..44c98c1 100644 --- a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeListFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeListFragment.kt @@ -38,6 +38,7 @@ open class ExchangeListFragment : Fragment(), ExchangeClickListener { protected val model: MainViewModel by activityViewModels() private val exchangeManager by lazy { model.exchangeManager } + private val transactionManager get() = model.transactionManager protected lateinit var ui: FragmentExchangeListBinding protected open val isSelectOnly = false @@ -61,12 +62,12 @@ open class ExchangeListFragment : Fragment(), ExchangeClickListener { AddExchangeDialogFragment().show(parentFragmentManager, "ADD_EXCHANGE") } - exchangeManager.progress.observe(viewLifecycleOwner, { show -> + exchangeManager.progress.observe(viewLifecycleOwner) { show -> if (show) ui.progressBar.fadeIn() else ui.progressBar.fadeOut() - }) - exchangeManager.exchanges.observe(viewLifecycleOwner, { exchanges -> + } + exchangeManager.exchanges.observe(viewLifecycleOwner) { exchanges -> onExchangeUpdate(exchanges) - }) + } exchangeManager.addError.observe(viewLifecycleOwner, EventObserver { error -> if (error) onAddExchangeFailed() }) @@ -96,4 +97,9 @@ open class ExchangeListFragment : Fragment(), ExchangeClickListener { findNavController().navigate(R.id.action_nav_settings_exchanges_to_nav_exchange_manual_withdrawal) } + override fun onPeerReceive(item: ExchangeItem) { + transactionManager.selectedCurrency = item.currency + findNavController().navigate(R.id.receiveFunds) + } + } diff --git a/wallet/src/main/res/menu/exchange.xml b/wallet/src/main/res/menu/exchange.xml index 85ec08f..d6a18e7 100644 --- a/wallet/src/main/res/menu/exchange.xml +++ b/wallet/src/main/res/menu/exchange.xml @@ -18,4 +18,7 @@ + -- cgit v1.2.3