aboutsummaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net
diff options
context:
space:
mode:
Diffstat (limited to 'wallet/src/main/java/net')
-rw-r--r--wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt3
-rw-r--r--wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt1
-rw-r--r--wallet/src/main/java/net/taler/wallet/history/HistoryEventFragment.kt28
3 files changed, 28 insertions, 4 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt b/wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt
index 1c7f15e..ede55df 100644
--- a/wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt
@@ -71,13 +71,16 @@ internal class HistoryAdapter(
private val icon: ImageView = v.findViewById(R.id.icon)
protected val title: TextView = v.findViewById(R.id.title)
private val time: TextView = v.findViewById(R.id.time)
+ private val selectableBackground = v.background
@CallSuper
open fun bind(event: HistoryEvent) {
if (devMode || event.detailPageLayout != 0) {
+ v.background = selectableBackground
v.setOnClickListener { listener.onEventClicked(event) }
} else {
v.background = null
+ v.setOnClickListener(null)
}
icon.setImageResource(event.icon)
if (event.title == 0) title.text = event::class.java.simpleName
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 57bf6a3..50a973f 100644
--- a/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt
+++ b/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt
@@ -407,6 +407,7 @@ class HistoryRefundedEvent(
override val icon = R.drawable.history_refund
override val title = R.string.history_event_refund
override val layout = R.layout.history_receive
+ override val detailPageLayout = R.layout.fragment_event_paid
override val showToUser = true
}
diff --git a/wallet/src/main/java/net/taler/wallet/history/HistoryEventFragment.kt b/wallet/src/main/java/net/taler/wallet/history/HistoryEventFragment.kt
index 6a07625..0093bb5 100644
--- a/wallet/src/main/java/net/taler/wallet/history/HistoryEventFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/history/HistoryEventFragment.kt
@@ -25,12 +25,14 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
+import androidx.core.content.ContextCompat.getColor
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import kotlinx.android.synthetic.main.fragment_event_paid.*
import kotlinx.android.synthetic.main.fragment_event_withdraw.*
import kotlinx.android.synthetic.main.fragment_event_withdraw.feeView
import kotlinx.android.synthetic.main.fragment_event_withdraw.timeView
+import net.taler.common.Amount
import net.taler.common.toAbsoluteTime
import net.taler.wallet.R
import net.taler.wallet.WalletViewModel
@@ -65,7 +67,12 @@ class HistoryEventFragment : Fragment() {
when (val e = event) {
is HistoryWithdrawnEvent -> bind(e)
is HistoryPaymentSentEvent -> bind(e)
- else -> Toast.makeText(requireContext(), "event not implement", LENGTH_LONG).show()
+ is HistoryRefundedEvent -> bind(e)
+ else -> Toast.makeText(
+ requireContext(),
+ "event ${e.javaClass} not implement",
+ LENGTH_LONG
+ ).show()
}
}
@@ -96,12 +103,25 @@ class HistoryEventFragment : Fragment() {
private fun bind(event: HistoryPaymentSentEvent) {
amountPaidWithFeesView.text = event.amountPaidWithFees.toString()
- orderAmountView.text = event.orderShortInfo.amount.toString()
val fee = event.amountPaidWithFees - event.orderShortInfo.amount
+ bindOrderAndFee(event.orderShortInfo, fee)
+ }
+
+ private fun bind(event: HistoryRefundedEvent) {
+ amountPaidWithFeesLabel.text = getString(R.string.history_event_refund)
+ amountPaidWithFeesView.setTextColor(getColor(requireContext(), R.color.green))
+ amountPaidWithFeesView.text =
+ getString(R.string.amount_positive, event.amountRefundedEffective.toString())
+ val fee = event.orderShortInfo.amount - event.amountRefundedEffective
+ bindOrderAndFee(event.orderShortInfo, fee)
+ }
+
+ private fun bindOrderAndFee(orderShortInfo: OrderShortInfo, fee: Amount) {
+ orderAmountView.text = orderShortInfo.amount.toString()
feeView.text = getString(R.string.amount_negative, fee.toString())
- orderSummaryView.text = event.orderShortInfo.summary
+ orderSummaryView.text = orderShortInfo.summary
orderIdView.text =
- getString(R.string.history_event_payment_sent_order_id, event.orderShortInfo.orderId)
+ getString(R.string.history_event_payment_sent_order_id, orderShortInfo.orderId)
}
}