taler-android

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

commit a4bbe98e705b366644e788f4c72117a19b167d02
parent 2b81b999fbafe53bec54d21c5d035da8212c8c48
Author: Iván Ávalos <avalos@disroot.org>
Date:   Wed, 17 Apr 2024 17:34:29 -0600

[wallet] DD53: address transaction-list issues (+UI improvements)

bug 0008726

Diffstat:
Mwallet/src/main/java/net/taler/wallet/transactions/Transactions.kt | 8++++++--
Mwallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt | 12++++++++++++
Awallet/src/main/res/drawable/ic_funds_receive.xml | 5+++++
Awallet/src/main/res/drawable/ic_funds_send.xml | 5+++++
Mwallet/src/main/res/layout/fragment_transactions.xml | 113+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
Mwallet/src/main/res/values/strings.xml | 10++++++----
6 files changed, 104 insertions(+), 49 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt @@ -17,6 +17,7 @@ package net.taler.wallet.transactions import android.content.Context +import android.net.Uri import android.util.Log import androidx.annotation.DrawableRes import androidx.annotation.IdRes @@ -313,7 +314,7 @@ class TransactionPayment( @Transient override val amountType = AmountType.Negative - override fun getTitle(context: Context) = info.merchant.name + override fun getTitle(context: Context) = context.getString(R.string.transaction_payment_to, info.merchant.name) override val generalTitleRes = R.string.payment_title } @@ -404,7 +405,10 @@ class TransactionDeposit( @Transient override val amountType = AmountType.Negative override fun getTitle(context: Context): String { - return context.getString(R.string.transaction_deposit) + val uri = Uri.parse(targetPaytoUri) + return uri.getQueryParameter("receiver-name")?.let { receiverName -> + context.getString(R.string.transaction_deposit_to, receiverName) + } ?: context.getString(R.string.transaction_deposit) } override val generalTitleRes = R.string.transaction_deposit diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt @@ -26,6 +26,7 @@ import android.view.MenuItem import android.view.View import android.view.View.INVISIBLE import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView.OnQueryTextListener import androidx.fragment.app.Fragment @@ -44,6 +45,8 @@ import net.taler.wallet.MainViewModel import net.taler.wallet.R import net.taler.wallet.TAG import net.taler.wallet.balances.BalanceState.Success +import net.taler.wallet.balances.ScopeInfo +import net.taler.wallet.cleanExchange import net.taler.wallet.databinding.FragmentTransactionsBinding import net.taler.wallet.showError @@ -154,6 +157,10 @@ class TransactionsFragment : Fragment(), OnTransactionClickListener, ActionMode. override fun onStart() { 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)) + } } private fun setupSearch(item: MenuItem) { @@ -261,6 +268,11 @@ class TransactionsFragment : Fragment(), OnTransactionClickListener, ActionMode. return true } + override fun onStop() { + super.onStop() + (requireActivity() as AppCompatActivity).supportActionBar?.subtitle = null + } + override fun onDestroyActionMode(mode: ActionMode) { tracker?.clearSelection() actionMode = null diff --git a/wallet/src/main/res/drawable/ic_funds_receive.xml b/wallet/src/main/res/drawable/ic_funds_receive.xml @@ -0,0 +1,5 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> + + <path android:fillColor="@android:color/white" android:pathData="M20,12l-1.41,-1.41L13,16.17V4h-2v12.17l-5.58,-5.59L4,12l8,8 8,-8z"/> + +</vector> diff --git a/wallet/src/main/res/drawable/ic_funds_send.xml b/wallet/src/main/res/drawable/ic_funds_send.xml @@ -0,0 +1,5 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> + + <path android:fillColor="@android:color/white" android:pathData="M4,12l1.41,1.41L11,7.83V20h2V7.83l5.58,5.59L20,12l-8,-8 -8,8z"/> + +</vector> diff --git a/wallet/src/main/res/layout/fragment_transactions.xml b/wallet/src/main/res/layout/fragment_transactions.xml @@ -20,65 +20,92 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - <com.google.android.material.button.MaterialButton - android:id="@+id/sendButton" - android:layout_width="wrap_content" + <HorizontalScrollView + android:id="@+id/buttonScroll" + android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginStart="10dp" - android:text="@string/transactions_send_funds" - app:layout_constraintBottom_toTopOf="@+id/divider" + android:fadeScrollbars="false" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@id/amountBarrier" + app:layout_constraintBottom_toTopOf="@id/divider"> - <com.google.android.material.button.MaterialButton - android:id="@+id/receiveButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginHorizontal="10dp" - android:text="@string/transactions_receive_funds" - app:layout_constraintBottom_toTopOf="@+id/divider" - app:layout_constraintEnd_toStartOf="@+id/amount" - app:layout_constraintHorizontal_chainStyle="spread_inside" - app:layout_constraintStart_toEndOf="@+id/sendButton" - app:layout_constraintTop_toTopOf="parent" /> + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="horizontal"> - <TextView - android:id="@+id/balanceLabel" + <com.google.android.material.button.MaterialButton + android:id="@+id/sendButton" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginStart="10dp" + android:layout_marginVertical="10dp" + android:paddingHorizontal="18dp" + android:text="@string/transactions_send_funds" + app:icon="@drawable/ic_funds_send" /> + + <com.google.android.material.button.MaterialButton + android:id="@+id/receiveButton" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginHorizontal="10dp" + android:layout_marginVertical="10dp" + android:paddingHorizontal="18dp" + android:text="@string/transactions_receive_funds" + app:icon="@drawable/ic_funds_receive" /> + + </LinearLayout> + </HorizontalScrollView> + + <androidx.constraintlayout.widget.Barrier + android:id="@+id/amountBarrier" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:layout_marginEnd="16dp" - android:text="@string/transactions_balance" - android:textSize="14sp" - app:layout_constraintBottom_toTopOf="@+id/amount" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="1.0" - app:layout_constraintStart_toEndOf="@+id/receiveButton" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toTopOf="@id/divider" + app:barrierDirection="start"/> - <TextView - android:id="@+id/amount" + <LinearLayout + android:id="@+id/amountLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="16dp" - android:layout_marginBottom="8dp" - android:textSize="24sp" - android:textStyle="bold" - app:layout_constrainedWidth="true" - app:layout_constraintBottom_toTopOf="@+id/divider" + android:layout_marginStart="16dp" + android:orientation="vertical" + android:gravity="end" + app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" - app:layout_constraintStart_toEndOf="@+id/receiveButton" - app:layout_constraintTop_toBottomOf="@+id/balanceLabel" - tools:text="23.42" - tools:visibility="visible" /> + app:layout_constraintBottom_toTopOf="@id/divider" + app:layout_constraintStart_toEndOf="@id/amountBarrier"> + + <TextView + android:id="@+id/balanceLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginEnd="16dp" + android:text="@string/transactions_balance" + android:textSize="14sp" /> + + <TextView + android:id="@+id/amount" + style="@style/TextAppearance.Material3.TitleLarge" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:layout_marginBottom="8dp" + android:textStyle="bold" + tools:text="23.42" + tools:visibility="visible" /> + + </LinearLayout> <androidx.constraintlayout.widget.Barrier android:id="@+id/topBarrier" android:layout_width="match_parent" android:layout_height="wrap_content" app:barrierDirection="bottom" - app:constraint_referenced_ids="sendButton,receiveButton,amount" /> + app:constraint_referenced_ids="buttonScroll,amountLayout" /> <com.google.android.material.divider.MaterialDivider android:id="@+id/divider" diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml @@ -83,20 +83,20 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card <string name="amount_received">Amount received</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="balance_scope_exchange">Exchange: %1$s</string> + <string name="balance_scope_exchange">From&#160;%1$s</string> <string name="balance_scope_auditor">Auditor: %1$s</string> <string name="transactions_title">Transactions</string> <string name="transactions_balance">Balance</string> - <string name="transactions_send_funds">Send\nFunds</string> + <string name="transactions_send_funds">Send</string> <string name="transactions_send_funds_title">Send %1$s</string> - <string name="transactions_receive_funds">Receive\nFunds</string> + <string name="transactions_receive_funds">Receive</string> <string name="transactions_receive_funds_title">Receive %1$s</string> <string name="transactions_empty">You don\'t have any transactions</string> <string name="transactions_empty_search">No transactions found. Try a different search.</string> <string name="transactions_error">Could not load transactions\n\n%s</string> <string name="transactions_detail_title">Transaction</string> - <string name="transactions_detail_title_currency">%s Transactions</string> + <string name="transactions_detail_title_currency">%s transactions</string> <string name="transactions_delete">Delete</string> <string name="transactions_retry">Retry</string> <string name="transactions_abort">Abort</string> @@ -114,6 +114,7 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card <string name="transactions_cancel_dialog_message">Are you sure you want to cancel this withdrawal? Funds still in transit might get lost.</string> <!-- Transactions --> + <string name="transaction_payment_to">Payment to %1$s</string> <string name="transaction_paid">Paid</string> <string name="transaction_order_total">Total</string> <string name="transaction_order">Purchase</string> @@ -123,6 +124,7 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card <string name="transaction_pending">PENDING</string> <string name="transaction_refresh">Coin expiry change fee</string> <string name="transaction_deposit">Deposit</string> + <string name="transaction_deposit_to">Deposit to %1$s</string> <string name="transaction_peer_push_debit">Push payment</string> <string name="transaction_peer_pull_credit">Invoice</string> <string name="transaction_peer_pull_debit">Invoice paid</string>