aboutsummaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-05-15 10:10:43 -0300
committerTorsten Grote <t@grobox.de>2020-05-15 14:26:43 -0300
commit3565fc05bca6e55896ff7b5115e6b8021f2a9d4e (patch)
treead31de3bf00b9e0d73a8041ace54414924575198 /wallet/src/main/java/net
parentdfc0db1432b181723e20efc01d46335ffd53115d (diff)
downloadtaler-android-3565fc05bca6e55896ff7b5115e6b8021f2a9d4e.tar.gz
taler-android-3565fc05bca6e55896ff7b5115e6b8021f2a9d4e.tar.bz2
taler-android-3565fc05bca6e55896ff7b5115e6b8021f2a9d4e.zip
[wallet] remove workarounds for fixed core bugs
Diffstat (limited to 'wallet/src/main/java/net')
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainViewModel.kt8
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt38
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt11
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt19
4 files changed, 26 insertions, 50 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
index 485df73..8276823 100644
--- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
@@ -122,14 +122,6 @@ class MainViewModel(val app: Application) : AndroidViewModel(app) {
val amountIncoming = Amount.fromJsonObject(jsonAmountIncoming)
balanceMap[currency] = BalanceItem(amount, amountIncoming)
}
- // TODO remove when wallet-core supports 0 balance for pending transactions
- if (balanceMap.isEmpty()) {
- val transactionsResult = transactionManager.transactions.value
- if (transactionsResult is TransactionsResult.Success && transactionsResult.transactions.isNotEmpty()) {
- val currency = transactionsResult.transactions[0].amountRaw.currency
- balanceMap[currency] = BalanceItem(Amount.zero(currency), Amount.zero(currency))
- }
- }
mBalances.postValue(balanceMap)
showProgressBar.postValue(false)
}
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
index f93dd66..e6dad6f 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
@@ -104,30 +104,22 @@ internal class TransactionAdapter(
}
private fun bindAmount(transaction: Transaction) {
- val amountEffective = transaction.amountEffective
- if (amountEffective == null) {
- amount.visibility = GONE
- } else {
- amount.visibility = VISIBLE
- when (transaction.amountType) {
- AmountType.Positive -> {
- amount.text =
- context.getString(R.string.amount_positive, amountEffective.amountStr)
- amount.setTextColor(if (transaction.pending) amountColor else green)
- }
- AmountType.Negative -> {
- amount.text =
- context.getString(R.string.amount_negative, amountEffective.amountStr)
- amount.setTextColor(if (transaction.pending) amountColor else red)
- }
- AmountType.Neutral -> {
- amount.text = amountEffective.amountStr
- amount.setTextColor(amountColor)
- }
- }.exhaustive
- }
+ val amountStr = transaction.amountEffective.amountStr
+ when (transaction.amountType) {
+ AmountType.Positive -> {
+ amount.text = context.getString(R.string.amount_positive, amountStr)
+ amount.setTextColor(if (transaction.pending) amountColor else green)
+ }
+ AmountType.Negative -> {
+ amount.text = context.getString(R.string.amount_negative, amountStr)
+ amount.setTextColor(if (transaction.pending) amountColor else red)
+ }
+ AmountType.Neutral -> {
+ amount.text = amountStr
+ amount.setTextColor(amountColor)
+ }
+ }.exhaustive
}
-
}
internal inner class TransactionKeyProvider : ItemKeyProvider<String>(SCOPE_MAPPED) {
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
index 9893852..fdb074d 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
@@ -36,7 +36,6 @@ import kotlinx.android.synthetic.main.fragment_transaction_withdrawal.*
import kotlinx.android.synthetic.main.fragment_transaction_withdrawal.feeView
import kotlinx.android.synthetic.main.fragment_transaction_withdrawal.timeView
import net.taler.common.Amount
-import net.taler.common.AmountOverflowException
import net.taler.common.isSafe
import net.taler.common.toAbsoluteTime
import net.taler.wallet.MainViewModel
@@ -106,18 +105,14 @@ class TransactionDetailFragment : Fragment() {
chosenAmountLabel.text = getString(R.string.amount_chosen)
chosenAmountView.text =
getString(R.string.amount_positive, t.amountRaw.toString())
- val fee = try { // TODO remove when fixed in wallet-core
- t.amountRaw - (t.amountEffective ?: t.amountRaw)
- } catch (e: AmountOverflowException) {
- (t.amountEffective ?: t.amountRaw) - t.amountRaw
- }
+ val fee = t.amountRaw - t.amountEffective
feeView.text = getString(R.string.amount_negative, fee.toString())
exchangeView.text = cleanExchange(t.exchangeBaseUrl)
}
private fun bind(t: TransactionPayment) {
amountPaidWithFeesView.text = t.amountEffective.toString()
- val fee = (t.amountEffective ?: t.amountRaw) - t.amountRaw
+ val fee = t.amountEffective - t.amountRaw
bindOrderAndFee(t.info, t.amountRaw, fee)
}
@@ -126,7 +121,7 @@ class TransactionDetailFragment : Fragment() {
amountPaidWithFeesView.setTextColor(getColor(requireContext(), R.color.green))
amountPaidWithFeesView.text =
getString(R.string.amount_positive, t.amountEffective.toString())
- val fee = t.amountRaw - (t.amountEffective ?: t.amountRaw)
+ val fee = t.amountRaw - t.amountEffective
bindOrderAndFee(t.info, t.amountRaw, fee)
}
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
index cff742f..c3a0c08 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
@@ -46,7 +46,7 @@ abstract class Transaction(
val timestamp: Timestamp,
val pending: Boolean,
val amountRaw: Amount,
- val amountEffective: Amount?
+ val amountEffective: Amount
) {
@get:DrawableRes
abstract val icon: Int
@@ -70,11 +70,11 @@ class TransactionWithdrawal(
transactionId: String,
timestamp: Timestamp,
pending: Boolean,
- val exchangeBaseUrl: String = "unknown", // TODO fix in wallet-core
+ val exchangeBaseUrl: String,
val confirmed: Boolean,
val bankConfirmationUrl: String?,
amountRaw: Amount,
- amountEffective: Amount?
+ amountEffective: Amount
) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) {
override val icon = R.drawable.transaction_withdrawal
override val detailPageLayout = R.layout.fragment_transaction_withdrawal
@@ -90,7 +90,7 @@ class TransactionPayment(
val info: TransactionInfo,
val status: PaymentStatus,
amountRaw: Amount,
- amountEffective: Amount?
+ amountEffective: Amount
) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) {
override val icon = R.drawable.ic_cash_usd_outline
override val detailPageLayout = R.layout.fragment_transaction_payment
@@ -102,7 +102,7 @@ class TransactionInfo(
val orderId: String,
val merchant: ContractMerchant,
val summary: String,
- @get:JsonProperty("description_i18n")
+ @get:JsonProperty("summary_i18n")
val summaryI18n: Map<String, String>?,
val products: List<ContractProduct>,
val fulfillmentUrl: String
@@ -118,9 +118,6 @@ enum class PaymentStatus {
@JsonProperty("paid")
Paid,
- @JsonProperty("offered")
- Offered,
-
@JsonProperty("accepted")
Accepted
}
@@ -134,7 +131,7 @@ class TransactionRefund(
val info: TransactionInfo,
val amountInvalid: Amount,
amountRaw: Amount,
- amountEffective: Amount?
+ amountEffective: Amount
) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) {
override val icon = R.drawable.transaction_refund
override val detailPageLayout = R.layout.fragment_transaction_payment
@@ -157,7 +154,7 @@ class TransactionTip(
val exchangeBaseUrl: String,
val merchant: ContractMerchant,
amountRaw: Amount,
- amountEffective: Amount?
+ amountEffective: Amount
) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) {
override val icon = R.drawable.transaction_tip_accepted // TODO different when declined
override val detailPageLayout = R.layout.fragment_transaction_payment
@@ -174,7 +171,7 @@ class TransactionRefresh(
pending: Boolean,
val exchangeBaseUrl: String,
amountRaw: Amount,
- amountEffective: Amount?
+ amountEffective: Amount
) : Transaction(transactionId, timestamp, pending, amountRaw, amountEffective) {
override val icon = R.drawable.transaction_refresh
override val detailPageLayout = R.layout.fragment_transaction_payment