Implemented showing selected bank's / account's title in toolbar
This commit is contained in:
parent
427db22ef1
commit
0beeaa485d
|
@ -7,6 +7,7 @@ import android.view.*
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
@ -22,6 +23,7 @@ import net.dankito.banking.ui.android.di.BankingComponent
|
||||||
import net.dankito.banking.ui.android.extensions.addHorizontalItemDivider
|
import net.dankito.banking.ui.android.extensions.addHorizontalItemDivider
|
||||||
import net.dankito.banking.ui.android.extensions.showAmount
|
import net.dankito.banking.ui.android.extensions.showAmount
|
||||||
import net.dankito.banking.ui.android.views.InfoPopupWindow
|
import net.dankito.banking.ui.android.views.InfoPopupWindow
|
||||||
|
import net.dankito.banking.ui.model.SelectedAccountType
|
||||||
import net.dankito.banking.ui.model.TransactionsRetrievalState
|
import net.dankito.banking.ui.model.TransactionsRetrievalState
|
||||||
import net.dankito.banking.ui.model.TypedBankAccount
|
import net.dankito.banking.ui.model.TypedBankAccount
|
||||||
import net.dankito.banking.ui.model.parameters.TransferMoneyData
|
import net.dankito.banking.ui.model.parameters.TransferMoneyData
|
||||||
|
@ -253,6 +255,8 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
private fun updateTransactionsToDisplayOnUiThread() {
|
private fun updateTransactionsToDisplayOnUiThread() {
|
||||||
|
setToolbarTitle()
|
||||||
|
|
||||||
transactionAdapter.items = presenter.searchSelectedAccountTransactions(appliedTransactionsFilter)
|
transactionAdapter.items = presenter.searchSelectedAccountTransactions(appliedTransactionsFilter)
|
||||||
|
|
||||||
mnitmBalance.title = presenter.formatAmount(presenter.balanceOfSelectedAccounts)
|
mnitmBalance.title = presenter.formatAmount(presenter.balanceOfSelectedAccounts)
|
||||||
|
@ -271,6 +275,20 @@ class HomeFragment : Fragment() {
|
||||||
setFetchAllTransactionsView()
|
setFetchAllTransactionsView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setToolbarTitle() {
|
||||||
|
// TODO: also set selected account's icon
|
||||||
|
|
||||||
|
if (presenter.allBanks.isNotEmpty()) {
|
||||||
|
activity?.findViewById<Toolbar>(R.id.toolbar)?.let { toolbar ->
|
||||||
|
toolbar.title = when (presenter.selectedAccountType) {
|
||||||
|
SelectedAccountType.AllAccounts -> context?.getString(R.string.drawer_menu_all_bank_accounts_title)
|
||||||
|
SelectedAccountType.SingleBank -> presenter.getSingleSelectedBank()?.displayName
|
||||||
|
SelectedAccountType.SingleAccount -> presenter.getSingleSelectedAccount()?.displayName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setRecyclerViewAndNoTransactionsFetchedView() {
|
private fun setRecyclerViewAndNoTransactionsFetchedView() {
|
||||||
val transactionsRetrievalState = presenter.selectedAccountsTransactionRetrievalState
|
val transactionsRetrievalState = presenter.selectedAccountsTransactionRetrievalState
|
||||||
val haveTransactionsBeenRetrieved = transactionsRetrievalState == TransactionsRetrievalState.RetrievedTransactions
|
val haveTransactionsBeenRetrieved = transactionsRetrievalState == TransactionsRetrievalState.RetrievedTransactions
|
||||||
|
|
|
@ -91,7 +91,8 @@ open class BankingPresenter(
|
||||||
|
|
||||||
protected var _selectedAccounts = mutableListOf<TypedBankAccount>()
|
protected var _selectedAccounts = mutableListOf<TypedBankAccount>()
|
||||||
|
|
||||||
protected var selectedAccountType = SelectedAccountType.AllAccounts
|
open var selectedAccountType = SelectedAccountType.AllAccounts
|
||||||
|
protected set
|
||||||
|
|
||||||
protected var saveAccountOnNextEnterTanInvocation = false
|
protected var saveAccountOnNextEnterTanInvocation = false
|
||||||
|
|
||||||
|
@ -858,11 +859,32 @@ open class BankingPresenter(
|
||||||
&& _selectedAccounts.map { it.bank }.toSet().containsExactly(bank)
|
&& _selectedAccounts.map { it.bank }.toSet().containsExactly(bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun getSingleSelectedBank(): TypedBankData? {
|
||||||
|
val selectedBanks = _selectedAccounts.map { it.bank }.toSet()
|
||||||
|
|
||||||
|
if (selectedBanks.size == 1) {
|
||||||
|
return selectedBanks.first() as? TypedBankData
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
open fun isSingleSelectedAccount(account: TypedBankAccount): Boolean {
|
open fun isSingleSelectedAccount(account: TypedBankAccount): Boolean {
|
||||||
return selectedAccountType == SelectedAccountType.SingleAccount
|
return selectedAccountType == SelectedAccountType.SingleAccount
|
||||||
&& _selectedAccounts.containsExactly(account)
|
&& _selectedAccounts.containsExactly(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun getSingleSelectedAccount(): TypedBankAccount? {
|
||||||
|
val selectedAccounts = _selectedAccounts.toSet()
|
||||||
|
|
||||||
|
if (selectedAccounts.size == 1) {
|
||||||
|
return selectedAccounts.first()
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
open fun selectedAllAccounts() {
|
open fun selectedAllAccounts() {
|
||||||
selectedAccountType = SelectedAccountType.AllAccounts
|
selectedAccountType = SelectedAccountType.AllAccounts
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue