From 01acacaecdde368c73414fce86cf320a7fbbddbc Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 7 Sep 2020 11:09:22 -0300 Subject: [wallet] always show product details (remove details button) --- wallet/build.gradle | 2 +- .../net/taler/wallet/payment/PaymentManager.kt | 10 --- .../net/taler/wallet/payment/ProductAdapter.kt | 11 +-- .../taler/wallet/payment/PromptPaymentFragment.kt | 15 +---- .../main/res/layout/list_item_product_single.xml | 78 ---------------------- wallet/src/main/res/layout/payment_details.xml | 16 +---- 6 files changed, 7 insertions(+), 125 deletions(-) delete mode 100644 wallet/src/main/res/layout/list_item_product_single.xml diff --git a/wallet/build.gradle b/wallet/build.gradle index b3a8210..0e04d17 100644 --- a/wallet/build.gradle +++ b/wallet/build.gradle @@ -47,7 +47,7 @@ android { minSdkVersion 24 targetSdkVersion 29 versionCode 6 - versionName "0.7.1.dev.25" + versionName "0.7.1.dev.28" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" buildConfigField "String", "WALLET_CORE_VERSION", "\"$walletCoreVersion\"" } 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.None) internal val payStatus: LiveData = mPayStatus - private val mDetailsShown = MutableLiveData() - internal val detailsShown: LiveData = mDetailsShown - @UiThread fun preparePay(url: String) = scope.launch { mPayStatus.value = PayStatus.Loading - mDetailsShown.value = false api.request("preparePay", PreparePayResponse.serializer()) { put("talerPayUri", url) }.onError { @@ -118,12 +114,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() } diff --git a/wallet/src/main/res/layout/list_item_product_single.xml b/wallet/src/main/res/layout/list_item_product_single.xml deleted file mode 100644 index 6f0f79f..0000000 --- a/wallet/src/main/res/layout/list_item_product_single.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - diff --git a/wallet/src/main/res/layout/payment_details.xml b/wallet/src/main/res/layout/payment_details.xml index 643974e..0610f52 100644 --- a/wallet/src/main/res/layout/payment_details.xml +++ b/wallet/src/main/res/layout/payment_details.xml @@ -69,25 +69,13 @@ android:textAppearance="@style/TextAppearance.AppCompat.Headline" android:textSize="25sp" android:visibility="invisible" - app:layout_constraintBottom_toTopOf="@+id/detailsButton" + app:layout_constraintBottom_toTopOf="@+id/productsList" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/orderLabelView" tools:text="2 x Cappuccino, 1 x Hot Meals, 1 x Dessert" tools:visibility="visible" /> -