From ebaffcdfabd2d33e1754321f0c08d7ca5bd1570a Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 15 May 2020 13:28:45 -0300 Subject: [wallet] show a pending badge next to balances with pending transactions --- .../src/main/java/net/taler/wallet/MainFragment.kt | 1 + .../main/java/net/taler/wallet/MainViewModel.kt | 6 ++--- .../net/taler/wallet/balances/BalanceAdapter.kt | 10 +++++--- .../net/taler/wallet/balances/BalancesFragment.kt | 1 - .../wallet/transactions/TransactionManager.kt | 8 ++++++ wallet/src/main/res/drawable/badge.xml | 26 +++++++++++++++++++ wallet/src/main/res/layout/list_item_balance.xml | 30 +++++++++++++++------- 7 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 wallet/src/main/res/drawable/badge.xml (limited to 'wallet') diff --git a/wallet/src/main/java/net/taler/wallet/MainFragment.kt b/wallet/src/main/java/net/taler/wallet/MainFragment.kt index 328d7a2..26c5a90 100644 --- a/wallet/src/main/java/net/taler/wallet/MainFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/MainFragment.kt @@ -28,6 +28,7 @@ import kotlinx.android.synthetic.main.fragment_main.* import net.taler.common.EventObserver import net.taler.wallet.CurrencyMode.MULTI import net.taler.wallet.CurrencyMode.SINGLE +import net.taler.wallet.balances.BalanceItem import net.taler.wallet.balances.BalancesFragment import net.taler.wallet.transactions.TransactionsFragment diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt index 6a1d6aa..75cab67 100644 --- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt +++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt @@ -32,6 +32,7 @@ import net.taler.common.Event import net.taler.common.assertUiThread import net.taler.common.toEvent import net.taler.wallet.backend.WalletBackendApi +import net.taler.wallet.balances.BalanceItem import net.taler.wallet.history.DevHistoryManager import net.taler.wallet.payment.PaymentManager import net.taler.wallet.pending.PendingOperationsManager @@ -48,8 +49,6 @@ private val transactionNotifications = listOf( "withdraw-group-finished" ) -data class BalanceItem(val available: Amount, val pendingIncoming: Amount) - class MainViewModel(val app: Application) : AndroidViewModel(app) { private val mBalances = MutableLiveData>() @@ -127,7 +126,8 @@ class MainViewModel(val app: Application) : AndroidViewModel(app) { val jsonAmountIncoming = byCurrency.getJSONObject(currency) .getJSONObject("pendingIncoming") val amountIncoming = Amount.fromJsonObject(jsonAmountIncoming) - balanceMap[currency] = BalanceItem(amount, amountIncoming) + val hasPending = transactionManager.hasPending(currency) + balanceMap[currency] = BalanceItem(amount, amountIncoming, hasPending) } mBalances.postValue(balanceMap) showProgressBar.postValue(false) diff --git a/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt b/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt index 0ccfeb2..be50364 100644 --- a/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/balances/BalanceAdapter.kt @@ -24,10 +24,12 @@ import android.view.ViewGroup import android.widget.TextView import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.Adapter -import net.taler.wallet.BalanceItem +import net.taler.common.Amount import net.taler.wallet.R import net.taler.wallet.balances.BalanceAdapter.BalanceViewHolder +data class BalanceItem(val available: Amount, val pendingIncoming: Amount, val hasPending: Boolean) + class BalanceAdapter(private val listener: BalanceClickListener) : Adapter() { private var items = emptyList() @@ -55,10 +57,11 @@ class BalanceAdapter(private val listener: BalanceClickListener) : Adapter + --> + + + + + + \ No newline at end of file diff --git a/wallet/src/main/res/layout/list_item_balance.xml b/wallet/src/main/res/layout/list_item_balance.xml index a9e15df..475e7d6 100644 --- a/wallet/src/main/res/layout/list_item_balance.xml +++ b/wallet/src/main/res/layout/list_item_balance.xml @@ -23,12 +23,12 @@ android:padding="16dp"> @@ -75,4 +76,15 @@ app:layout_constraintTop_toTopOf="@+id/balanceInboundAmount" tools:visibility="visible" /> + + -- cgit v1.2.3