gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-android] 03/04: Clean up balances UI


From: gnunet
Subject: [taler-wallet-android] 03/04: Clean up balances UI
Date: Thu, 05 Mar 2020 19:53:07 +0100

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

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

commit 44693dd2742c14136fada73c777f14d62f326f8d
Author: Torsten Grote <address@hidden>
AuthorDate: Thu Mar 5 15:40:31 2020 -0300

    Clean up balances UI
---
 .../wallet/{ShowBalance.kt => BalanceFragment.kt}  | 25 +++---
 app/src/main/res/layout/balance_row.xml            | 90 ----------------------
 app/src/main/res/layout/fragment_show_balance.xml  |  5 +-
 app/src/main/res/layout/list_item_balance.xml      | 77 ++++++++++++++++++
 app/src/main/res/navigation/nav_graph.xml          |  2 +-
 app/src/main/res/values/strings.xml                |  3 +-
 6 files changed, 97 insertions(+), 105 deletions(-)

diff --git a/app/src/main/java/net/taler/wallet/ShowBalance.kt 
b/app/src/main/java/net/taler/wallet/BalanceFragment.kt
similarity index 87%
rename from app/src/main/java/net/taler/wallet/ShowBalance.kt
rename to app/src/main/java/net/taler/wallet/BalanceFragment.kt
index 71ef87f..b9f5818 100644
--- a/app/src/main/java/net/taler/wallet/ShowBalance.kt
+++ b/app/src/main/java/net/taler/wallet/BalanceFragment.kt
@@ -16,7 +16,6 @@
 
 package net.taler.wallet
 
-import android.annotation.SuppressLint
 import android.os.Bundle
 import android.transition.TransitionManager.beginDelayedTransition
 import android.util.Log
@@ -42,7 +41,7 @@ import 
com.google.zxing.integration.android.IntentIntegrator.QR_CODE_TYPES
 import kotlinx.android.synthetic.main.fragment_show_balance.*
 import net.taler.wallet.BalanceAdapter.BalanceViewHolder
 
-class ShowBalance : Fragment() {
+class BalanceFragment : Fragment() {
 
     private val model: WalletViewModel by activityViewModels()
     private val withdrawManager by lazy { model.withdrawManager }
@@ -148,7 +147,8 @@ class BalanceAdapter : Adapter<BalanceViewHolder>() {
     }
 
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): 
BalanceViewHolder {
-        val v = 
LayoutInflater.from(parent.context).inflate(R.layout.balance_row, parent, false)
+        val v =
+            
LayoutInflater.from(parent.context).inflate(R.layout.list_item_balance, parent, 
false)
         return BalanceViewHolder(v)
     }
 
@@ -164,11 +164,11 @@ class BalanceAdapter : Adapter<BalanceViewHolder>() {
         this.notifyDataSetChanged()
     }
 
-    class BalanceViewHolder(v: View) : ViewHolder(v) {
+    class BalanceViewHolder(private val v: View) : ViewHolder(v) {
         private val currencyView: TextView = 
v.findViewById(R.id.balance_currency)
         private val amountView: TextView = v.findViewById(R.id.balance_amount)
-        private val amountIncomingRow: View = 
v.findViewById(R.id.balance_row_pending)
-        private val amountIncomingView: TextView = 
v.findViewById(R.id.balance_pending)
+        private val balanceInboundAmount: TextView = 
v.findViewById(R.id.balanceInboundAmount)
+        private val balanceInboundLabel: TextView = 
v.findViewById(R.id.balanceInboundLabel)
 
         fun bind(item: BalanceItem) {
             currencyView.text = item.available.currency
@@ -176,11 +176,16 @@ class BalanceAdapter : Adapter<BalanceViewHolder>() {
 
             val amountIncoming = item.pendingIncoming
             if (amountIncoming.isZero()) {
-                amountIncomingRow.visibility = GONE
+                balanceInboundAmount.visibility = GONE
+                balanceInboundLabel.visibility = GONE
             } else {
-                amountIncomingRow.visibility = VISIBLE
-                @SuppressLint("SetTextI18n")
-                amountIncomingView.text = "${amountIncoming.amount} 
${amountIncoming.currency}"
+                balanceInboundAmount.visibility = VISIBLE
+                balanceInboundLabel.visibility = VISIBLE
+                balanceInboundAmount.text = v.context.getString(
+                    R.string.balances_inbound_amount,
+                    amountIncoming.amount,
+                    amountIncoming.currency
+                )
             }
         }
     }
diff --git a/app/src/main/res/layout/balance_row.xml 
b/app/src/main/res/layout/balance_row.xml
deleted file mode 100644
index 662068b..0000000
--- a/app/src/main/res/layout/balance_row.xml
+++ /dev/null
@@ -1,90 +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/>
-  -->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
-        xmlns:tools="http://schemas.android.com/tools";
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical">
-
-    <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal">
-
-        <TextView
-                android:id="@+id/balance_amount"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="40sp"
-                tools:text="100.50" />
-
-        <Space
-                android:layout_width="10sp"
-                android:layout_height="match_parent" />
-
-        <TextView
-                android:id="@+id/balance_currency"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="20sp"
-                tools:text="TESTKUDOS" />
-
-    </LinearLayout>
-
-    <LinearLayout
-            android:id="@+id/balance_row_pending"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal">
-
-        <Space
-                android:layout_width="5sp"
-                android:layout_height="match_parent" />
-
-        <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="+"
-                android:textColor="#006600"
-                tools:ignore="HardcodedText" />
-
-        <Space
-                android:layout_width="5sp"
-                android:layout_height="match_parent" />
-
-        <TextView
-                android:id="@+id/balance_pending"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textColor="#006600"
-                android:textSize="20sp"
-                tools:text="10 TESTKUDOS" />
-
-        <Space
-                android:layout_width="5sp"
-                android:layout_height="match_parent" />
-
-        <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/balances_inbound"
-                android:textColor="#006600" />
-
-    </LinearLayout>
-
-
-</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_show_balance.xml 
b/app/src/main/res/layout/fragment_show_balance.xml
index 5b38fb6..5bc6ee8 100644
--- a/app/src/main/res/layout/fragment_show_balance.xml
+++ b/app/src/main/res/layout/fragment_show_balance.xml
@@ -23,7 +23,6 @@
             android:id="@+id/balancesList"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:layout_margin="16dp"
             android:visibility="gone"
             app:layout_constraintBottom_toTopOf="@+id/scanButton"
             app:layout_constraintEnd_toEndOf="parent"
@@ -32,7 +31,7 @@
             app:layout_constraintVertical_bias="0.0"
             app:layout_constraintVertical_chainStyle="packed"
             tools:layout_height="200dp"
-            tools:listitem="@layout/balance_row"
+            tools:listitem="@layout/list_item_balance"
             tools:visibility="visible" />
 
     <TextView
@@ -49,7 +48,7 @@
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toTopOf="parent"
-            tools:visibility="visible" />
+            tools:visibility="gone" />
 
     <androidx.constraintlayout.widget.Barrier
             android:id="@+id/barrier"
diff --git a/app/src/main/res/layout/list_item_balance.xml 
b/app/src/main/res/layout/list_item_balance.xml
new file mode 100644
index 0000000..f9c37b7
--- /dev/null
+++ b/app/src/main/res/layout/list_item_balance.xml
@@ -0,0 +1,77 @@
+<?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="16dp">
+
+    <TextView
+            android:id="@+id/balance_amount"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="8dp"
+            android:textSize="40sp"
+            app:layout_constraintEnd_toStartOf="@+id/balance_currency"
+            app:layout_constraintHorizontal_bias="0.0"
+            app:layout_constraintHorizontal_chainStyle="packed"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            tools:text="100.50" />
+
+    <TextView
+            android:id="@+id/balance_currency"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textSize="20sp"
+            app:layout_constraintBottom_toBottomOf="@+id/balance_amount"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintHorizontal_bias="0.5"
+            app:layout_constraintStart_toEndOf="@+id/balance_amount"
+            app:layout_constraintTop_toTopOf="@+id/balance_amount"
+            tools:text="TESTKUDOS" />
+
+    <TextView
+            android:id="@+id/balanceInboundAmount"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@color/green"
+            android:textSize="20sp"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toStartOf="@+id/balanceInboundLabel"
+            app:layout_constraintHorizontal_bias="0.0"
+            app:layout_constraintHorizontal_chainStyle="packed"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/balance_amount"
+            tools:text="+10 TESTKUDOS"
+            tools:visibility="visible" />
+
+    <TextView
+            android:id="@+id/balanceInboundLabel"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="8dp"
+            android:text="@string/balances_inbound_label"
+            android:textColor="@color/green"
+            app:layout_constraintBottom_toBottomOf="@+id/balanceInboundAmount"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toEndOf="@+id/balanceInboundAmount"
+            app:layout_constraintTop_toTopOf="@+id/balanceInboundAmount"
+            tools:visibility="visible" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/navigation/nav_graph.xml 
b/app/src/main/res/navigation/nav_graph.xml
index 3a14e8b..e540c12 100644
--- a/app/src/main/res/navigation/nav_graph.xml
+++ b/app/src/main/res/navigation/nav_graph.xml
@@ -23,7 +23,7 @@
 
     <fragment
             android:id="@+id/showBalance"
-            android:name="net.taler.wallet.ShowBalance"
+            android:name="net.taler.wallet.BalanceFragment"
             android:label="@string/balances_title"
             tools:layout="@layout/fragment_show_balance">
         <action
diff --git a/app/src/main/res/values/strings.xml 
b/app/src/main/res/values/strings.xml
index 3be1745..a5ff395 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -39,7 +39,8 @@
     <string name="aiddescription">my aid</string>
 
     <string name="balances_title">Balances</string>
-    <string name="balances_inbound">inbound</string>
+    <string name="balances_inbound_amount">+%1s %2s</string>
+    <string name="balances_inbound_label">inbound</string>
     <string name="balances_empty_state">There is no digital cash in your 
wallet.\n\nYou can get test money from the demo 
bank:\n\nhttps://bank.demo.taler.net</string>
 
     <string name="history_title">History</string>

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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