taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

commit bd3013dfb8004157c92ba8b72a24b9f0ed526329
parent a4bbe98e705b366644e788f4c72117a19b167d02
Author: Iván Ávalos <avalos@disroot.org>
Date:   Mon, 22 Apr 2024 08:43:57 -0600

[wallet] DD53: address balance-list issues

bug 0008726

Diffstat:
Mwallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt | 17++++++++++-------
Mwallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt | 4+---
Mwallet/src/main/res/layout/list_item_balance.xml | 51+++++++++------------------------------------------
Mwallet/src/main/res/values/strings.xml | 3++-
4 files changed, 22 insertions(+), 53 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt b/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt @@ -61,8 +61,7 @@ class BalanceAdapter(private val listener: BalanceClickListener) : Adapter<Balan private val amountView: TextView = v.findViewById(R.id.balanceAmountView) private val scopeView: TextView = v.findViewById(R.id.scopeView) private val balanceInboundAmount: TextView = v.findViewById(R.id.balanceInboundAmount) - private val balanceInboundLabel: TextView = v.findViewById(R.id.balanceInboundLabel) - private val pendingView: TextView = v.findViewById(R.id.pendingView) + private val balanceOutboundAmount: TextView = v.findViewById(R.id.balanceOutboundAmount) fun bind(item: BalanceItem) { v.setOnClickListener { listener.onBalanceClick(item.scopeInfo) } @@ -71,11 +70,17 @@ class BalanceAdapter(private val listener: BalanceClickListener) : Adapter<Balan val amountIncoming = item.pendingIncoming if (amountIncoming.isZero()) { balanceInboundAmount.visibility = GONE - balanceInboundLabel.visibility = GONE } else { balanceInboundAmount.visibility = VISIBLE - balanceInboundLabel.visibility = VISIBLE - balanceInboundAmount.text = v.context.getString(R.string.amount_positive, amountIncoming.toString(showSymbol = false)) + balanceInboundAmount.text = v.context.getString(R.string.balances_inbound_amount, amountIncoming.toString(showSymbol = false)) + } + + val amountOutgoing = item.pendingOutgoing + if (amountOutgoing.isZero()) { + balanceOutboundAmount.visibility = GONE + } else { + balanceOutboundAmount.visibility = VISIBLE + balanceOutboundAmount.text = v.context.getString(R.string.balances_outbound_amount, amountOutgoing.toString(showSymbol = false)) } val scopeInfo = item.scopeInfo @@ -90,8 +95,6 @@ class BalanceAdapter(private val listener: BalanceClickListener) : Adapter<Balan VISIBLE } } - - pendingView.visibility = if (item.hasPending) VISIBLE else GONE } } diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt @@ -158,9 +158,7 @@ class TransactionsFragment : Fragment(), OnTransactionClickListener, ActionMode. super.onStart() requireActivity().title = getString(R.string.transactions_detail_title_currency, scopeInfo.currency) (requireActivity() as AppCompatActivity).supportActionBar?.subtitle = - (scopeInfo as? ScopeInfo.Exchange)?.url?.let { - getString(R.string.balance_scope_exchange, cleanExchange(it)) - } + (scopeInfo as? ScopeInfo.Exchange)?.url?.let { cleanExchange(it) } } private fun setupSearch(item: MenuItem) { diff --git a/wallet/src/main/res/layout/list_item_balance.xml b/wallet/src/main/res/layout/list_item_balance.xml @@ -14,9 +14,9 @@ ~ 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" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" + android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" @@ -26,26 +26,16 @@ android:id="@+id/balanceAmountView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="8dp" style="?textAppearanceDisplaySmall" - app:layout_constraintEnd_toStartOf="@+id/pendingView" - 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/scopeView" - android:layout_width="0dp" + android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" style="?textAppearanceBodyMedium" android:visibility="gone" - app:layout_constraintTop_toBottomOf="@id/balanceAmountView" - app:layout_constraintBottom_toTopOf="@id/balanceInboundAmount" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toStartOf="@id/pendingView" tools:text="@string/balance_scope_exchange" tools:visibility="visible"/> @@ -54,40 +44,17 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/green" - android:textSize="20sp" style="?textAppearanceBodyLarge" - 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/scopeView" - tools:text="+10 TESTKUDOS" + tools:text="+10 TESTKUDOS inbound" tools:visibility="visible" /> <TextView - android:id="@+id/balanceInboundLabel" + android:id="@+id/balanceOutboundAmount" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:text="@string/balances_inbound_label" - android:textColor="@color/green" - style="?textAppearanceBodyMedium" - app:layout_constraintBottom_toBottomOf="@+id/balanceInboundAmount" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toEndOf="@+id/balanceInboundAmount" - app:layout_constraintTop_toTopOf="@+id/balanceInboundAmount" + android:textColor="?colorError" + style="?textAppearanceBodyLarge" + tools:text="-10 TESTKUDOS outbound" tools:visibility="visible" /> - <TextView - android:id="@+id/pendingView" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:background="@drawable/badge" - android:text="@string/transaction_pending" - android:textColor="?android:textColorPrimaryInverse" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - -</androidx.constraintlayout.widget.ConstraintLayout> +</LinearLayout> diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml @@ -81,7 +81,8 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card <string name="amount_chosen">Chosen Amount</string> <string name="amount_sent">Amount sent</string> <string name="amount_received">Amount received</string> - <string name="balances_inbound_label">inbound</string> + <string name="balances_inbound_amount">+%1$s inbound</string> + <string name="balances_outbound_amount">-%1$s outbound</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="balance_scope_exchange">From&#160;%1$s</string> <string name="balance_scope_auditor">Auditor: %1$s</string>