From 30980bc83be99ea85205f44c815b78164b11f7b9 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 3 Mar 2020 14:03:45 -0300 Subject: Clean up and improve withdraw UI (first pass) --- app/src/main/java/net/taler/wallet/MainActivity.kt | 6 +- .../main/java/net/taler/wallet/PromptWithdraw.kt | 127 ------------- .../java/net/taler/wallet/ReviewExchangeTOS.kt | 91 ---------- app/src/main/java/net/taler/wallet/ShowBalance.kt | 154 +++++++--------- app/src/main/java/net/taler/wallet/Utils.kt | 11 +- .../main/java/net/taler/wallet/WalletViewModel.kt | 176 +----------------- .../java/net/taler/wallet/WithdrawSuccessful.kt | 42 ----- .../wallet/withdraw/PromptWithdrawFragment.kt | 107 +++++++++++ .../wallet/withdraw/ReviewExchangeTosFragment.kt | 80 ++++++++ .../net/taler/wallet/withdraw/WithdrawManager.kt | 193 ++++++++++++++++++++ .../wallet/withdraw/WithdrawSuccessfulFragment.kt | 44 +++++ .../main/res/layout-w550dp/payment_bottom_bar.xml | 3 +- app/src/main/res/layout/app_bar_main.xml | 19 +- .../main/res/layout/fragment_prompt_withdraw.xml | 201 ++++++++++++++------- .../res/layout/fragment_review_exchange_tos.xml | 101 +++++++---- .../res/layout/fragment_withdraw_successful.xml | 66 ++++--- app/src/main/res/layout/payment_bottom_bar.xml | 3 +- app/src/main/res/navigation/nav_graph.xml | 12 +- app/src/main/res/values/strings.xml | 3 + app/src/main/res/values/styles.xml | 5 + 20 files changed, 774 insertions(+), 670 deletions(-) delete mode 100644 app/src/main/java/net/taler/wallet/PromptWithdraw.kt delete mode 100644 app/src/main/java/net/taler/wallet/ReviewExchangeTOS.kt delete mode 100644 app/src/main/java/net/taler/wallet/WithdrawSuccessful.kt create mode 100644 app/src/main/java/net/taler/wallet/withdraw/PromptWithdrawFragment.kt create mode 100644 app/src/main/java/net/taler/wallet/withdraw/ReviewExchangeTosFragment.kt create mode 100644 app/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt create mode 100644 app/src/main/java/net/taler/wallet/withdraw/WithdrawSuccessfulFragment.kt diff --git a/app/src/main/java/net/taler/wallet/MainActivity.kt b/app/src/main/java/net/taler/wallet/MainActivity.kt index 79c3373..ebc7136 100644 --- a/app/src/main/java/net/taler/wallet/MainActivity.kt +++ b/app/src/main/java/net/taler/wallet/MainActivity.kt @@ -24,7 +24,7 @@ import android.content.IntentFilter import android.os.Bundle import android.util.Log import android.view.MenuItem -import android.view.View.INVISIBLE +import android.view.View.GONE import android.view.View.VISIBLE import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity @@ -74,7 +74,7 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener, toolbar.setupWithNavController(nav, appBarConfiguration) model.showProgressBar.observe(this, Observer { show -> - progress_bar.visibility = if (show) VISIBLE else INVISIBLE + progress_bar.visibility = if (show) VISIBLE else GONE }) if (intent.action == ACTION_VIEW) intent.dataString?.let { uri -> @@ -131,7 +131,7 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener, url.toLowerCase(ROOT).startsWith("taler://withdraw/") -> { Log.v(TAG, "navigating!") nav.navigate(R.id.action_showBalance_to_promptWithdraw) - model.getWithdrawalInfo(url) + model.withdrawManager.getWithdrawalInfo(url) } url.toLowerCase(ROOT).startsWith("taler://refund/") -> { // TODO implement refunds diff --git a/app/src/main/java/net/taler/wallet/PromptWithdraw.kt b/app/src/main/java/net/taler/wallet/PromptWithdraw.kt deleted file mode 100644 index ec65b0e..0000000 --- a/app/src/main/java/net/taler/wallet/PromptWithdraw.kt +++ /dev/null @@ -1,127 +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 - */ - -package net.taler.wallet - -import android.annotation.SuppressLint -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 android.widget.TextView -import androidx.lifecycle.Observer -import androidx.lifecycle.ViewModelProviders -import androidx.navigation.findNavController -import com.google.android.material.snackbar.Snackbar -import me.zhanghai.android.materialprogressbar.MaterialProgressBar - - -class PromptWithdraw : Fragment() { - - private lateinit var model: WalletViewModel - - private fun triggerLoading() { - val loading = - model.withdrawStatus.value is WithdrawStatus.Loading || model.withdrawStatus.value is WithdrawStatus.Withdrawing - val myActivity = activity!! - val progressBar = myActivity.findViewById(R.id.progress_bar) - if (loading) { - progressBar.visibility = View.VISIBLE - } else { - progressBar.visibility = View.INVISIBLE - } - } - - private fun showWithdrawStatus(view: View, status: WithdrawStatus) { - val confirmButton = view.findViewById