diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt b/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt index 7db25e4f..444e8a37 100644 --- a/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -20,6 +20,7 @@ import net.dankito.fints.banks.BankFinder import net.dankito.fints.model.BankInfo import net.dankito.utils.IThreadPool import net.dankito.utils.ThreadPool +import net.dankito.utils.extensions.containsExactly import net.dankito.utils.extensions.ofMaxLength import org.slf4j.LoggerFactory import java.io.File @@ -50,6 +51,8 @@ open class BankingPresenter( protected var selectedBankAccountsField = mutableListOf() + protected var userSelectedSingleAccount = false + protected var saveAccountOnNextEnterTanInvocation = false @@ -138,6 +141,8 @@ open class BankingPresenter( if (response.isSuccessful) { addClientForAccount(account, newClient) + selectedAccount(account) + callAccountsChangedListeners() persistAccount(account) @@ -147,8 +152,6 @@ open class BankingPresenter( retrievedAccountTransactions(bankAccount, response) } } - - selectedAccount(account) } callback(response) @@ -315,15 +318,31 @@ open class BankingPresenter( open val balanceOfSelectedBankAccounts: BigDecimal get() = sumBalance(selectedBankAccounts.map { it.balance }) + open fun isSingleSelectedAccount(account: Account): Boolean { + return userSelectedSingleAccount + && selectedBankAccountsField.map { it.account }.toSet().containsExactly(account) + } + + open fun isSingleSelectedBankAccount(bankAccount: BankAccount): Boolean { + return userSelectedSingleAccount == false + && selectedBankAccountsField.containsExactly(bankAccount) + } + open fun selectedAllBankAccounts() { + userSelectedSingleAccount = false + setSelectedBankAccounts(bankAccounts) } open fun selectedAccount(account: Account) { + userSelectedSingleAccount = true + setSelectedBankAccounts(account.bankAccounts) } open fun selectedBankAccount(bankAccount: BankAccount) { + userSelectedSingleAccount = false + setSelectedBankAccounts(listOf(bankAccount)) } diff --git a/build.gradle b/build.gradle index 3000b040..804f0843 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ ext { kotlinVersion = '1.3.61' - javaUtilsVersion = '1.0.9' + javaUtilsVersion = '1.0.16-SNAPSHOT' hbci4jVersion = '3.1.37' diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/views/DrawerView.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/views/DrawerView.kt index cde449c3..491b82e2 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/views/DrawerView.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/views/DrawerView.kt @@ -117,6 +117,7 @@ open class DrawerView( .withName(account.displayName) .withLevel(AccountLevel) .withIcon(activity, FontAwesome.Icon.faw_piggy_bank, R.color.primaryTextColor_Dark) + .withSelected(presenter.isSingleSelectedAccount(account)) .withOnDrawerItemClickListener { _, _, _ -> itemClicked { presenter.selectedAccount(account) } } } @@ -125,6 +126,7 @@ open class DrawerView( SecondaryDrawerItem() .withName(bankAccount.displayName) .withLevel(BankAccountLevel) + .withSelected(presenter.isSingleSelectedBankAccount(bankAccount)) .withOnDrawerItemClickListener { _, _, _ -> itemClicked { presenter.selectedBankAccount(bankAccount) } } } }