commit 6017ba25a0727d91c4e74cf8c7ffbbd81877aa41
parent 3962afc92df544786a52556b076b634202437495
Author: Iván Ávalos <avalos@disroot.org>
Date: Tue, 27 Aug 2024 19:15:27 +0200
[wallet] Remove tax grouping from UI
Diffstat:
4 files changed, 6 insertions(+), 63 deletions(-)
diff --git a/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt b/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt
@@ -42,7 +42,6 @@ internal class ProductAdapter(private val listener: ProductImageClickListener) :
RecyclerView.Adapter<ProductViewHolder>() {
private var items = emptyList<ContractProduct>()
- private var taxesEqual = true
override fun getItemCount() = items.size
@@ -64,7 +63,6 @@ internal class ProductAdapter(private val listener: ProductImageClickListener) :
diffResult.dispatchUpdatesTo(this)
items = newItems
- taxesEqual = newItems.distinctBy { it.taxes }.size == 1
}
internal inner class ProductViewHolder(v: View) : ViewHolder(v) {
@@ -101,7 +99,7 @@ internal class ProductAdapter(private val listener: ProductImageClickListener) :
price.visibility = GONE
}
- if (!taxesEqual && product.taxes != null && product.taxes!!.isNotEmpty()) {
+ if (product.taxes != null && product.taxes!!.isNotEmpty()) {
taxes.visibility = VISIBLE
taxes.text = product.taxes!!.filter {
!it.tax.isZero()
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt b/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt
@@ -22,7 +22,6 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
-import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
@@ -34,7 +33,6 @@ import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
import kotlinx.coroutines.launch
import net.taler.common.Amount
import net.taler.common.ContractTerms
-import net.taler.common.Tax
import net.taler.common.fadeIn
import net.taler.common.fadeOut
import net.taler.common.showError
@@ -104,8 +102,7 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
is PayStatus.Prepared -> {
showLoading(false)
val fees = payStatus.amountEffective - payStatus.amountRaw
- val taxes = compileTaxes(payStatus.contractTerms)
- showOrder(payStatus.contractTerms, payStatus.amountRaw, fees, taxes)
+ showOrder(payStatus.contractTerms, payStatus.amountRaw, fees)
ui.bottom.confirmButton.isEnabled = true
ui.bottom.confirmButton.setOnClickListener {
model.showProgressBar.value = true
@@ -156,20 +153,10 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
}
}
- private fun compileTaxes(contractTerms: ContractTerms): Set<Tax>? {
- val distinct = contractTerms.products.distinctBy { it.taxes }
- return if (distinct.size == 1) {
- distinct.first().taxes
- } else {
- null
- }
- }
-
private fun showOrder(
contractTerms: ContractTerms,
amount: Amount,
totalFees: Amount? = null,
- taxes: Set<Tax>? = null,
) {
ui.details.orderView.text = contractTerms.summary
adapter.update(contractTerms.products)
@@ -183,17 +170,6 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
ui.bottom.feeView.visibility = GONE
}
- if (taxes != null) {
- ui.bottom.feeView.visibility = VISIBLE
- ui.bottom.feeView.text = taxes.filter {
- !it.tax.isZero()
- }.joinToString(separator = "\n") {
- requireContext().getString(R.string.payment_tax, it.name, it.tax)
- }
- } else {
- ui.bottom.feeView.visibility = GONE
- }
-
ui.details.orderLabelView.fadeIn()
ui.details.orderView.fadeIn()
ui.bottom.totalLabelView.fadeIn()
diff --git a/wallet/src/main/res/layout-w550dp/payment_bottom_bar.xml b/wallet/src/main/res/layout-w550dp/payment_bottom_bar.xml
@@ -67,30 +67,14 @@
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
- android:visibility="gone"
- app:layout_constraintEnd_toStartOf="@+id/confirmButton"
- app:layout_constraintHorizontal_bias="1.0"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintBottom_toTopOf="@id/taxView"
- app:layout_constraintTop_toBottomOf="@+id/totalView"
- tools:text="@string/payment_fee"
- tools:visibility="visible" />
-
- <TextView
- android:id="@+id/taxView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:visibility="gone"
app:layout_constraintEnd_toStartOf="@+id/confirmButton"
- app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/feeView"
app:layout_constraintBottom_toBottomOf="parent"
- tools:text="@string/payment_tax"
+ app:layout_constraintTop_toBottomOf="@+id/totalView"
+ tools:text="@string/payment_fee"
tools:visibility="visible" />
<Button
diff --git a/wallet/src/main/res/layout/payment_bottom_bar.xml b/wallet/src/main/res/layout/payment_bottom_bar.xml
@@ -71,7 +71,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:visibility="gone"
- app:layout_constraintBottom_toTopOf="@+id/taxView"
+ app:layout_constraintBottom_toTopOf="@+id/confirmButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
@@ -79,21 +79,6 @@
tools:text="@string/payment_fee"
tools:visibility="visible" />
- <TextView
- android:id="@+id/taxView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_marginEnd="8dp"
- android:visibility="gone"
- app:layout_constraintBottom_toTopOf="@+id/confirmButton"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHorizontal_bias="1.0"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/feeView"
- tools:text="@string/payment_tax"
- tools:visibility="visible" />
-
<Button
android:id="@+id/confirmButton"
android:layout_width="wrap_content"
@@ -106,7 +91,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/taxView"
+ app:layout_constraintTop_toBottomOf="@+id/feeView"
tools:enabled="true" />
<ProgressBar