aboutsummaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-04-02 15:12:09 -0300
committerTorsten Grote <t@grobox.de>2020-04-02 15:12:09 -0300
commite52ee8f55326de402a7ad421c396eb6c81a79a68 (patch)
treeb33d5474a0bc7c73615c3e71010e678bb2f4883f /wallet/src/main/java/net/taler
parent78dcfb7c95fd17c8ee04f4c357b1c9b0a46cb0af (diff)
downloadtaler-android-e52ee8f55326de402a7ad421c396eb6c81a79a68.tar.gz
taler-android-e52ee8f55326de402a7ad421c396eb6c81a79a68.tar.bz2
taler-android-e52ee8f55326de402a7ad421c396eb6c81a79a68.zip
[wallet] Show withdraw fee
Diffstat (limited to 'wallet/src/main/java/net/taler')
-rw-r--r--wallet/src/main/java/net/taler/wallet/BalanceFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/withdraw/PromptWithdrawFragment.kt22
-rw-r--r--wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt16
3 files changed, 27 insertions, 13 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)
}
}