gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-android] 02/03: [wallet] always show product details (remov


From: gnunet
Subject: [taler-taler-android] 02/03: [wallet] always show product details (remove details button)
Date: Mon, 07 Sep 2020 16:29:02 +0200

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository taler-android.

commit 01acacaecdde368c73414fce86cf320a7fbbddbc
Author: Torsten Grote <t@grobox.de>
AuthorDate: Mon Sep 7 11:09:22 2020 -0300

    [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(-)

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>(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 {
@@ -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 @@
-<?xml version="1.0" encoding="utf-8"?><!--
-  ~ This file is part of GNU Taler
-  ~ (C) 2020 Taler Systems S.A.
-  ~
-  ~ GNU Taler is free software; you can redistribute it and/or modify it under 
the
-  ~ terms of the GNU General Public License as published by the Free Software
-  ~ Foundation; either version 3, or (at your option) any later version.
-  ~
-  ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT 
ANY
-  ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
-  ~ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License along 
with
-  ~ GNU Taler; see the file COPYING.  If not, see 
<http://www.gnu.org/licenses/>
-  -->
-
-<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android";
-    xmlns:app="http://schemas.android.com/apk/res-auto";
-    xmlns:tools="http://schemas.android.com/tools";
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:padding="8dp">
-
-    <TextView
-        android:id="@+id/quantity"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:visibility="gone"
-        app:layout_constraintEnd_toStartOf="@+id/name"
-        app:layout_constraintHorizontal_bias="0.5"
-        app:layout_constraintHorizontal_chainStyle="packed"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintVertical_bias="0.0"
-        tools:text="31" />
-
-    <ImageView
-        android:id="@+id/image"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="8dp"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/name"
-        tools:ignore="ContentDescription"
-        tools:srcCompat="@tools:sample/avatars"
-        tools:visibility="visible" />
-
-    <TextView
-        android:id="@+id/name"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="8dp"
-        android:layout_marginEnd="8dp"
-        android:visibility="gone"
-        app:layout_constrainedWidth="true"
-        app:layout_constraintBottom_toTopOf="@+id/image"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintEnd_toStartOf="@+id/price"
-        app:layout_constraintHorizontal_bias="0.5"
-        app:layout_constraintStart_toEndOf="@+id/quantity"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_goneMarginEnd="0dp"
-        tools:text="A product item that can have a very long name that wraps 
over two lines" />
-
-    <TextView
-        android:id="@+id/price"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:visibility="gone"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintVertical_bias="0.0"
-        tools:text="23.42" />
-
-</androidx.constraintlayout.widget.ConstraintLayout>
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" />
 
-        <Button
-            android:id="@+id/detailsButton"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/payment_show_details"
-            android:visibility="gone"
-            app:layout_constraintBottom_toTopOf="@+id/productsList"
-            app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/orderView"
-            tools:visibility="visible" />
-
         <androidx.recyclerview.widget.RecyclerView
             android:id="@+id/productsList"
             android:layout_width="0dp"
@@ -97,7 +85,7 @@
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/detailsButton"
+            app:layout_constraintTop_toBottomOf="@+id/orderView"
             tools:listitem="@layout/list_item_product"
             tools:visibility="visible" />
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]