summaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler/wallet/history
diff options
context:
space:
mode:
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/history')
-rw-r--r--wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt41
-rw-r--r--wallet/src/main/java/net/taler/wallet/history/ReserveTransaction.kt1
-rw-r--r--wallet/src/main/java/net/taler/wallet/history/WalletHistoryAdapter.kt28
3 files changed, 28 insertions, 42 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt b/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt
index 9e5c99d..b78c062 100644
--- a/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt
+++ b/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt
@@ -29,7 +29,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME
import com.fasterxml.jackson.annotation.JsonTypeName
-import net.taler.wallet.ParsedAmount.Companion.parseAmount
+import net.taler.common.Amount
+import net.taler.common.Timestamp
import net.taler.wallet.R
import org.json.JSONObject
@@ -70,13 +71,6 @@ enum class RefreshReason {
BACKUP_RESTORED
}
-
-@JsonInclude(NON_EMPTY)
-class Timestamp(
- @JsonProperty("t_ms")
- val ms: Long
-)
-
@JsonInclude(NON_EMPTY)
class ReserveShortInfo(
/**
@@ -181,12 +175,12 @@ class ReserveBalanceUpdatedEvent(
/**
* Amount currently left in the reserve.
*/
- val amountReserveBalance: String,
+ val amountReserveBalance: Amount,
/**
* Amount we expected to be in the reserve at that time,
* considering ongoing withdrawals from that reserve.
*/
- val amountExpected: String
+ val amountExpected: Amount
) : HistoryEvent(timestamp) {
override val title = R.string.history_event_reserve_balance_updated
}
@@ -208,11 +202,11 @@ class HistoryWithdrawnEvent(
* Amount that has been subtracted from the reserve's balance
* for this withdrawal.
*/
- val amountWithdrawnRaw: String,
+ val amountWithdrawnRaw: Amount,
/**
* Amount that actually was added to the wallet's balance.
*/
- val amountWithdrawnEffective: String
+ val amountWithdrawnEffective: Amount
) : HistoryEvent(timestamp) {
override val layout = R.layout.history_receive
override val title = R.string.history_event_withdrawn
@@ -263,7 +257,7 @@ class HistoryPaymentSentEvent(
/**
* Amount that was paid, including deposit and wire fees.
*/
- val amountPaidWithFees: String,
+ val amountPaidWithFees: Amount,
/**
* Session ID that the payment was (re-)submitted under.
*/
@@ -285,7 +279,7 @@ class HistoryPaymentAbortedEvent(
/**
* Amount that was lost due to refund and refreshing fees.
*/
- val amountLost: String
+ val amountLost: Amount
) : HistoryEvent(timestamp) {
override val layout = R.layout.history_payment
override val title = R.string.history_event_payment_aborted
@@ -300,11 +294,11 @@ class HistoryRefreshedEvent(
* Amount that is now available again because it has
* been refreshed.
*/
- val amountRefreshedEffective: String,
+ val amountRefreshedEffective: Amount,
/**
* Amount that we spent for refreshing.
*/
- val amountRefreshedRaw: String,
+ val amountRefreshedRaw: Amount,
/**
* Why was the refreshing done?
*/
@@ -321,8 +315,7 @@ class HistoryRefreshedEvent(
override val layout = R.layout.history_payment
override val icon = R.drawable.history_refresh
override val title = R.string.history_event_refreshed
- override val showToUser =
- !(parseAmount(amountRefreshedRaw) - parseAmount(amountRefreshedEffective)).isZero()
+ override val showToUser = !(amountRefreshedRaw - amountRefreshedEffective).isZero()
}
@JsonTypeName("order-redirected")
@@ -352,7 +345,7 @@ class HistoryTipAcceptedEvent(
/**
* Raw amount of the tip, without extra fees that apply.
*/
- val tipRaw: String
+ val tipRaw: Amount
) : HistoryEvent(timestamp) {
override val icon = R.drawable.history_tip_accepted
override val title = R.string.history_event_tip_accepted
@@ -370,7 +363,7 @@ class HistoryTipDeclinedEvent(
/**
* Raw amount of the tip, without extra fees that apply.
*/
- val tipAmount: String
+ val tipAmount: Amount
) : HistoryEvent(timestamp) {
override val icon = R.drawable.history_tip_declined
override val title = R.string.history_event_tip_declined
@@ -391,15 +384,15 @@ class HistoryRefundedEvent(
* Part of the refund that couldn't be applied because
* the refund permissions were expired.
*/
- val amountRefundedInvalid: String,
+ val amountRefundedInvalid: Amount,
/**
* Amount that has been refunded by the merchant.
*/
- val amountRefundedRaw: String,
+ val amountRefundedRaw: Amount,
/**
* Amount will be added to the wallet's balance after fees and refreshing.
*/
- val amountRefundedEffective: String
+ val amountRefundedEffective: Amount
) : HistoryEvent(timestamp) {
override val icon = R.drawable.history_refund
override val title = R.string.history_event_refund
@@ -444,7 +437,7 @@ data class OrderShortInfo(
/**
* Amount that must be paid for the contract.
*/
- val amount: String,
+ val amount: Amount,
/**
* Summary of the proposal, given by the merchant.
*/
diff --git a/wallet/src/main/java/net/taler/wallet/history/ReserveTransaction.kt b/wallet/src/main/java/net/taler/wallet/history/ReserveTransaction.kt
index 45c539c..6c8fdaa 100644
--- a/wallet/src/main/java/net/taler/wallet/history/ReserveTransaction.kt
+++ b/wallet/src/main/java/net/taler/wallet/history/ReserveTransaction.kt
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME
import com.fasterxml.jackson.annotation.JsonTypeName
+import net.taler.common.Timestamp
@JsonTypeInfo(
diff --git a/wallet/src/main/java/net/taler/wallet/history/WalletHistoryAdapter.kt b/wallet/src/main/java/net/taler/wallet/history/WalletHistoryAdapter.kt
index 71bdebc..5424b62 100644
--- a/wallet/src/main/java/net/taler/wallet/history/WalletHistoryAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/history/WalletHistoryAdapter.kt
@@ -38,9 +38,8 @@ import androidx.annotation.CallSuper
import androidx.core.net.toUri
import androidx.recyclerview.widget.RecyclerView.Adapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder
+import net.taler.common.Amount
import net.taler.wallet.BuildConfig
-import net.taler.wallet.ParsedAmount
-import net.taler.wallet.ParsedAmount.Companion.parseAmount
import net.taler.wallet.R
@@ -119,7 +118,7 @@ internal class WalletHistoryAdapter(
info.text = when (event) {
is ExchangeAddedEvent -> event.exchangeBaseUrl
is ExchangeUpdatedEvent -> event.exchangeBaseUrl
- is ReserveBalanceUpdatedEvent -> parseAmount(event.amountReserveBalance).toString()
+ is ReserveBalanceUpdatedEvent -> event.amountReserveBalance.toString()
is HistoryPaymentSentEvent -> event.orderShortInfo.summary
is HistoryOrderAcceptedEvent -> event.orderShortInfo.summary
is HistoryOrderRefusedEvent -> event.orderShortInfo.summary
@@ -151,36 +150,30 @@ internal class WalletHistoryAdapter(
title.text = getHostname(event.exchangeBaseUrl)
summary.setText(event.title)
- val parsedEffective = parseAmount(event.amountWithdrawnEffective)
- val parsedRaw = parseAmount(event.amountWithdrawnRaw)
- showAmounts(parsedEffective, parsedRaw)
+ showAmounts(event.amountWithdrawnEffective, event.amountWithdrawnRaw)
}
private fun bind(event: HistoryRefundedEvent) {
title.text = event.orderShortInfo.summary
summary.setText(event.title)
- val parsedEffective = parseAmount(event.amountRefundedEffective)
- val parsedRaw = parseAmount(event.amountRefundedRaw)
- showAmounts(parsedEffective, parsedRaw)
+ showAmounts(event.amountRefundedEffective, event.amountRefundedRaw)
}
private fun bind(event: HistoryTipAcceptedEvent) {
title.setText(event.title)
summary.text = null
- val amount = parseAmount(event.tipRaw)
- showAmounts(amount, amount)
+ showAmounts(event.tipRaw, event.tipRaw)
}
private fun bind(event: HistoryTipDeclinedEvent) {
title.setText(event.title)
summary.text = null
- val amount = parseAmount(event.tipAmount)
- showAmounts(amount, amount)
+ showAmounts(event.tipAmount, event.tipAmount)
amountWithdrawn.paintFlags = amountWithdrawn.paintFlags or STRIKE_THRU_TEXT_FLAG
}
- private fun showAmounts(effective: ParsedAmount, raw: ParsedAmount) {
+ private fun showAmounts(effective: Amount, raw: Amount) {
@SuppressLint("SetTextI18n")
amountWithdrawn.text = "+$raw"
val calculatedFee = raw - effective
@@ -220,19 +213,18 @@ internal class WalletHistoryAdapter(
private fun bind(event: HistoryPaymentSentEvent) {
title.text = event.orderShortInfo.summary
@SuppressLint("SetTextI18n")
- amountPaidWithFees.text = "-${parseAmount(event.amountPaidWithFees)}"
+ amountPaidWithFees.text = "-${event.amountPaidWithFees}"
}
private fun bind(event: HistoryPaymentAbortedEvent) {
title.text = event.orderShortInfo.summary
@SuppressLint("SetTextI18n")
- amountPaidWithFees.text = "-${parseAmount(event.amountLost)}"
+ amountPaidWithFees.text = "-${event.amountLost}"
}
private fun bind(event: HistoryRefreshedEvent) {
title.text = ""
- val fee =
- parseAmount(event.amountRefreshedRaw) - parseAmount(event.amountRefreshedEffective)
+ val fee = event.amountRefreshedRaw - event.amountRefreshedEffective
@SuppressLint("SetTextI18n")
if (fee.isZero()) amountPaidWithFees.text = null
else amountPaidWithFees.text = "-$fee"