[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-android] branch master updated: [wallet] Show withdraw fee
From: |
gnunet |
Subject: |
[taler-taler-android] branch master updated: [wallet] Show withdraw fee |
Date: |
Thu, 02 Apr 2020 20:12:40 +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 e52ee8f [wallet] Show withdraw fee
e52ee8f is described below
commit e52ee8f55326de402a7ad421c396eb6c81a79a68
Author: Torsten Grote <address@hidden>
AuthorDate: Thu Apr 2 15:12:09 2020 -0300
[wallet] Show withdraw fee
---
.../main/java/net/taler/wallet/BalanceFragment.kt | 2 +-
.../wallet/withdraw/PromptWithdrawFragment.kt | 22 +++++--
.../net/taler/wallet/withdraw/WithdrawManager.kt | 16 +++--
.../main/res/layout/fragment_prompt_withdraw.xml | 70 +++++++++++++++++++---
wallet/src/main/res/values/strings.xml | 5 +-
5 files changed, 91 insertions(+), 24 deletions(-)
diff --git a/wallet/src/main/java/net/taler/wallet/BalanceFragment.kt
b/wallet/src/main/java/net/taler/wallet/BalanceFragment.kt
index 93ed235..d871cfb 100644
--- a/wallet/src/main/java/net/taler/wallet/BalanceFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/BalanceFragment.kt
@@ -187,7 +187,7 @@ class BalanceAdapter : Adapter<BalanceViewHolder>() {
balanceInboundAmount.visibility = VISIBLE
balanceInboundLabel.visibility = VISIBLE
balanceInboundAmount.text =
- v.context.getString(R.string.balances_inbound_amount,
amountIncoming)
+ v.context.getString(R.string.amount_positive,
amountIncoming)
}
}
}
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 875a9c4..ea04e24 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/PromptWithdrawFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/PromptWithdrawFragment.kt
@@ -56,13 +56,16 @@ class PromptWithdrawFragment : Fragment() {
private fun showWithdrawStatus(status: WithdrawStatus?): Any = when
(status) {
is WithdrawStatus.ReceivedDetails -> {
- showContent(status.amount, status.suggestedExchange)
+ showContent(status.amount, status.fee, status.suggestedExchange)
confirmWithdrawButton.apply {
text = getString(R.string.withdraw_button_confirm)
setOnClickListener {
it.fadeOut()
confirmProgressBar.fadeIn()
- withdrawManager.acceptWithdrawal(status.talerWithdrawUri,
status.suggestedExchange)
+ withdrawManager.acceptWithdrawal(
+ status.talerWithdrawUri,
+ status.suggestedExchange
+ )
}
isEnabled = true
}
@@ -79,7 +82,7 @@ class PromptWithdrawFragment : Fragment() {
model.showProgressBar.value = true
}
is TermsOfServiceReviewRequired -> {
- showContent(status.amount, status.suggestedExchange)
+ showContent(status.amount, status.fee, status.suggestedExchange)
confirmWithdrawButton.apply {
text = getString(R.string.withdraw_button_tos)
setOnClickListener {
@@ -95,13 +98,20 @@ class PromptWithdrawFragment : Fragment() {
null -> model.showProgressBar.value = false
}
- private fun showContent(amount: Amount, exchange: String) {
+ private fun showContent(amount: Amount, fee: Amount, exchange: String) {
model.showProgressBar.value = false
progressBar.fadeOut()
introView.fadeIn()
- withdrawAmountView.text = amount.toString()
- withdrawAmountView.fadeIn()
+ effectiveAmountView.text = (amount - fee).toString()
+ effectiveAmountView.fadeIn()
+
+ chosenAmountLabel.fadeIn()
+ chosenAmountView.text = amount.toString()
+ chosenAmountView.fadeIn()
+
+ feeLabel.fadeIn()
+ feeView.text = getString(R.string.amount_negative, fee.toString())
feeView.fadeIn()
exchangeIntroView.fadeIn()
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 e252627..26515a5 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
@@ -32,12 +32,14 @@ sealed class WithdrawStatus {
val tosText: String,
val tosEtag: String,
val amount: Amount,
+ val fee: Amount,
val suggestedExchange: String
) : WithdrawStatus()
data class ReceivedDetails(
val talerWithdrawUri: String,
val amount: Amount,
+ val fee: Amount,
val suggestedExchange: String
) : WithdrawStatus()
@@ -131,6 +133,10 @@ class WithdrawManager(private val walletBackendApi:
WalletBackendApi) {
val ei = result.getJSONObject("exchangeWithdrawDetails")
val termsOfServiceAccepted =
ei.getBoolean("termsOfServiceAccepted")
+ val withdrawFee =
Amount.fromJsonObject(ei.getJSONObject("withdrawFee"))
+ val overhead = Amount.fromJsonObject(ei.getJSONObject("overhead"))
+ val fee = withdrawFee + overhead
+
if (!termsOfServiceAccepted) {
val exchange = ei.getJSONObject("exchangeInfo")
val tosText = exchange.getString("termsOfServiceText")
@@ -138,10 +144,8 @@ class WithdrawManager(private val walletBackendApi:
WalletBackendApi) {
withdrawStatus.postValue(
WithdrawStatus.TermsOfServiceReviewRequired(
status.talerWithdrawUri,
- selectedExchange,
- tosText,
- tosEtag,
- amount,
+ selectedExchange, tosText, tosEtag,
+ amount, fee,
suggestedExchange
)
)
@@ -149,7 +153,7 @@ class WithdrawManager(private val walletBackendApi:
WalletBackendApi) {
withdrawStatus.postValue(
ReceivedDetails(
status.talerWithdrawUri,
- amount,
+ amount, fee,
suggestedExchange
)
)
@@ -195,7 +199,7 @@ class WithdrawManager(private val walletBackendApi:
WalletBackendApi) {
Log.e(TAG, "Error acceptExchangeTermsOfService
${result.toString(4)}")
return@sendRequest
}
- val status = ReceivedDetails(s.talerWithdrawUri, s.amount,
s.suggestedExchange)
+ val status = ReceivedDetails(s.talerWithdrawUri, s.amount, s.fee,
s.suggestedExchange)
withdrawStatus.postValue(status)
}
}
diff --git a/wallet/src/main/res/layout/fragment_prompt_withdraw.xml
b/wallet/src/main/res/layout/fragment_prompt_withdraw.xml
index b03ee03..4372cba 100644
--- a/wallet/src/main/res/layout/fragment_prompt_withdraw.xml
+++ b/wallet/src/main/res/layout/fragment_prompt_withdraw.xml
@@ -31,7 +31,7 @@
android:gravity="center"
android:text="@string/withdraw_total"
android:visibility="invisible"
- app:layout_constraintBottom_toTopOf="@+id/withdrawAmountView"
+ app:layout_constraintBottom_toTopOf="@+id/effectiveAmountView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
@@ -40,36 +40,88 @@
tools:visibility="visible" />
<TextView
- android:id="@+id/withdrawAmountView"
+ android:id="@+id/effectiveAmountView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
- android:textAppearance="@style/TextAppearance.AppCompat.Headline"
+ android:textColor="@color/green"
+ android:textSize="24sp"
android:visibility="invisible"
- app:layout_constraintBottom_toTopOf="@+id/feeView"
+ app:layout_constraintBottom_toTopOf="@+id/chosenAmountLabel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/introView"
- tools:text="10.00 TESTKUDOS"
+ tools:text="9.8 TESTKUDOS"
tools:visibility="visible" />
<TextView
- android:id="@+id/feeView"
+ android:id="@+id/chosenAmountLabel"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="32dp"
+ android:layout_marginEnd="16dp"
+ android:gravity="center"
+ android:text="Chosen Amount"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toTopOf="@+id/chosenAmountView"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/effectiveAmountView"
+ tools:visibility="visible" />
+
+ <TextView
+ android:id="@+id/chosenAmountView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:gravity="center"
+ android:textSize="20sp"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toTopOf="@+id/feeLabel"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/chosenAmountLabel"
+ tools:text="10 TESTKUDOS"
+ tools:visibility="visible" />
+
+ <TextView
+ android:id="@+id/feeLabel"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="32dp"
+ android:layout_marginEnd="16dp"
+ android:gravity="center"
android:text="@string/withdraw_fees"
android:visibility="invisible"
- app:layout_constraintBottom_toTopOf="@+id/exchangeIntroView"
+ app:layout_constraintBottom_toTopOf="@+id/feeView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/withdrawAmountView"
+ app:layout_constraintTop_toBottomOf="@+id/chosenAmountView"
+ tools:visibility="visible" />
+
+ <TextView
+ android:id="@+id/feeView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="16dp"
+ android:gravity="center"
+ android:textColor="@color/red"
+ android:textSize="20sp"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toTopOf="@+id/exchangeIntroView"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/feeLabel"
+ tools:text="-0.2 TESTKUDOS"
tools:visibility="visible" />
<TextView
@@ -111,7 +163,7 @@
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- app:layout_constraintBottom_toTopOf="@+id/withdrawCard"
+ app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
diff --git a/wallet/src/main/res/values/strings.xml
b/wallet/src/main/res/values/strings.xml
index 8cd2dd8..bcd173f 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -39,7 +39,8 @@
<string name="aiddescription">my aid</string>
<string name="balances_title">Balances</string>
- <string name="balances_inbound_amount">+%s</string>
+ <string name="amount_positive">+%s</string>
+ <string name="amount_negative">-%s</string>
<string name="balances_inbound_label">inbound</string>
<string name="balances_empty_state">There is no digital cash in your
wallet.\n\nYou can get test money from the demo
bank:\n\nhttps://bank.demo.taler.net</string>
@@ -80,7 +81,7 @@
<string name="withdraw_accepted">Withdrawal accepted</string>
<string name="withdraw_success_info">The wire transfer now needs to be
confirmed with the bank. Once the wire transfer is complete, the digital cash
will automatically show in this wallet.</string>
<string name="withdraw_total">Withdraw</string>
- <string name="withdraw_fees">(minus exchange fees)</string>
+ <string name="withdraw_fees">Fee</string>
<string name="withdraw_exchange">Exchange</string>
<string name="withdraw_button_testkudos">Withdraw TESTKUDOS</string>
<string name="withdraw_button_confirm">Confirm Withdraw</string>
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-taler-android] branch master updated: [wallet] Show withdraw fee,
gnunet <=