diff options
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/withdraw')
3 files changed, 16 insertions, 52 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/PromptWithdrawFragment.kt b/wallet/src/main/java/net/taler/wallet/withdraw/PromptWithdrawFragment.kt index 747551b..e700f67 100644 --- a/wallet/src/main/java/net/taler/wallet/withdraw/PromptWithdrawFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/withdraw/PromptWithdrawFragment.kt @@ -24,12 +24,14 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.lifecycle.Observer import androidx.navigation.fragment.findNavController +import com.google.android.material.snackbar.Snackbar +import com.google.android.material.snackbar.Snackbar.LENGTH_LONG import kotlinx.android.synthetic.main.fragment_prompt_withdraw.* import net.taler.common.Amount import net.taler.common.fadeIn import net.taler.common.fadeOut -import net.taler.wallet.R import net.taler.wallet.MainViewModel +import net.taler.wallet.R import net.taler.wallet.cleanExchange import net.taler.wallet.withdraw.WithdrawStatus.Loading import net.taler.wallet.withdraw.WithdrawStatus.TermsOfServiceReviewRequired @@ -63,7 +65,11 @@ class PromptWithdrawFragment : Fragment() { setOnClickListener { it.fadeOut() confirmProgressBar.fadeIn() - withdrawManager.acceptWithdrawal(status.talerWithdrawUri, status.exchange) + withdrawManager.acceptWithdrawal( + status.talerWithdrawUri, + status.exchange, + status.amount.currency + ) } isEnabled = true } @@ -71,7 +77,10 @@ class PromptWithdrawFragment : Fragment() { is WithdrawStatus.Success -> { model.showProgressBar.value = false withdrawManager.withdrawStatus.value = null - findNavController().navigate(R.id.action_promptWithdraw_to_withdrawSuccessful) + // TODO bring the user to the currency's transaction page, if there's more than one currency + model.transactionManager.selectedCurrency = status.currency + findNavController().navigate(R.id.action_promptWithdraw_to_nav_main) + Snackbar.make(requireView(), R.string.withdraw_initiated, LENGTH_LONG).show() } is Loading -> { model.showProgressBar.value = true 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 6bcd013..75e4daa 100644 --- a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt +++ b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt @@ -43,8 +43,7 @@ sealed class WithdrawStatus { ) : WithdrawStatus() data class Withdrawing(val talerWithdrawUri: String) : WithdrawStatus() - - object Success : WithdrawStatus() + data class Success(val currency: String) : WithdrawStatus() data class Error(val message: String?) : WithdrawStatus() } @@ -145,7 +144,7 @@ class WithdrawManager(private val walletBackendApi: WalletBackendApi) { } } - fun acceptWithdrawal(talerWithdrawUri: String, selectedExchange: String) { + fun acceptWithdrawal(talerWithdrawUri: String, selectedExchange: String, currency: String) { val args = JSONObject() args.put("talerWithdrawUri", talerWithdrawUri) args.put("selectedExchange", selectedExchange) @@ -154,7 +153,7 @@ class WithdrawManager(private val walletBackendApi: WalletBackendApi) { walletBackendApi.sendRequest("acceptWithdrawal", args) { isError, result -> if (isError) { - Log.v(TAG, "got acceptWithdrawal error result: ${result.toString(4)}") + Log.v(TAG, "got acceptWithdrawal error result: ${result.toString(2)}") return@sendRequest } Log.v(TAG, "got acceptWithdrawal result") @@ -163,7 +162,7 @@ class WithdrawManager(private val walletBackendApi: WalletBackendApi) { Log.w(TAG, "ignoring acceptWithdrawal result, invalid state: $status") return@sendRequest } - withdrawStatus.postValue(WithdrawStatus.Success) + withdrawStatus.postValue(WithdrawStatus.Success(currency)) } } diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawSuccessfulFragment.kt b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawSuccessfulFragment.kt deleted file mode 100644 index 5daeff1..0000000 --- a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawSuccessfulFragment.kt +++ /dev/null @@ -1,44 +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.withdraw - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.Fragment -import androidx.navigation.fragment.findNavController -import kotlinx.android.synthetic.main.fragment_withdraw_successful.* -import net.taler.wallet.R - -class WithdrawSuccessfulFragment : Fragment() { - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return inflater.inflate(R.layout.fragment_withdraw_successful, container, false) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - backButton.setOnClickListener { - findNavController().navigateUp() - } - } - -} |