aboutsummaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler
diff options
context:
space:
mode:
Diffstat (limited to 'wallet/src/main/java/net/taler')
-rw-r--r--wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt10
-rw-r--r--wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt11
-rw-r--r--wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt15
3 files changed, 4 insertions, 32 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt b/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt
index 9e6984c..34a8023 100644
--- a/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt
@@ -64,13 +64,9 @@ class PaymentManager(
private val mPayStatus = MutableLiveData<PayStatus>(PayStatus.None)
internal val payStatus: LiveData<PayStatus> = mPayStatus
- private val mDetailsShown = MutableLiveData<Boolean>()
- internal val detailsShown: LiveData<Boolean> = mDetailsShown
-
@UiThread
fun preparePay(url: String) = scope.launch {
mPayStatus.value = PayStatus.Loading
- mDetailsShown.value = false
api.request("preparePay", PreparePayResponse.serializer()) {
put("talerPayUri", url)
}.onError {
@@ -119,12 +115,6 @@ class PaymentManager(
}
@UiThread
- fun toggleDetailsShown() {
- val oldValue = mDetailsShown.value ?: false
- mDetailsShown.value = !oldValue
- }
-
- @UiThread
fun resetPayStatus() {
mPayStatus.value = PayStatus.None
}
diff --git a/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt b/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt
index 24bbd27..87b6387 100644
--- a/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt
@@ -43,14 +43,9 @@ internal class ProductAdapter(private val listener: ProductImageClickListener) :
override fun getItemCount() = items.size
- override fun getItemViewType(position: Int): Int {
- return if (itemCount == 1) 1 else 0
- }
-
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductViewHolder {
- val res =
- if (viewType == 1) R.layout.list_item_product_single else R.layout.list_item_product
- val view = LayoutInflater.from(parent.context).inflate(res, parent, false)
+ val inflater = LayoutInflater.from(parent.context)
+ val view = inflater.inflate(R.layout.list_item_product, parent, false)
return ProductViewHolder(view)
}
@@ -81,7 +76,7 @@ internal class ProductAdapter(private val listener: ProductImageClickListener) :
val decodedString = Base64.decode(match.groups[2]!!.value, Base64.DEFAULT)
val bitmap = decodeByteArray(decodedString, 0, decodedString.size)
image.setImageBitmap(bitmap)
- if (itemCount > 1) image.setOnClickListener {
+ image.setOnClickListener {
listener.onImageClick(bitmap)
}
}
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt b/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt
index 8815408..664dcc9 100644
--- a/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt
@@ -21,15 +21,12 @@ import android.os.Bundle
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
-import androidx.lifecycle.Observer
import androidx.lifecycle.observe
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.transition.TransitionManager.beginDelayedTransition
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
import net.taler.common.ContractTerms
@@ -61,16 +58,7 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
paymentManager.payStatus.observe(viewLifecycleOwner, ::onPaymentStatusChanged)
- paymentManager.detailsShown.observe(viewLifecycleOwner, Observer { shown ->
- beginDelayedTransition(view as ViewGroup)
- val res = if (shown) R.string.payment_hide_details else R.string.payment_show_details
- ui.details.detailsButton.setText(res)
- ui.details.productsList.visibility = if (shown) VISIBLE else GONE
- })
- ui.details.detailsButton.setOnClickListener {
- paymentManager.toggleDetailsShown()
- }
ui.details.productsList.apply {
adapter = this@PromptPaymentFragment.adapter
layoutManager = LinearLayoutManager(requireContext())
@@ -147,7 +135,7 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
private fun showOrder(contractTerms: ContractTerms, amount:Amount, totalFees: Amount? = null) {
ui.details.orderView.text = contractTerms.summary
adapter.setItems(contractTerms.products)
- if (contractTerms.products.size == 1) paymentManager.toggleDetailsShown()
+ ui.details.productsList.fadeIn()
ui.bottom.totalView.text = amount.toString()
if (totalFees != null && !totalFees.isZero()) {
ui.bottom.feeView.text = getString(R.string.payment_fee, totalFees)
@@ -157,7 +145,6 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
}
ui.details.orderLabelView.fadeIn()
ui.details.orderView.fadeIn()
- if (contractTerms.products.size > 1) ui.details.detailsButton.fadeIn()
ui.bottom.totalLabelView.fadeIn()
ui.bottom.totalView.fadeIn()
}