From 1d09789d38719a612fac7ef180772f82380c27dc Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 28 Sep 2020 15:44:45 +0200 Subject: [PATCH] Implemented persisting for which account prominent (top) fetch all transactions view shouldn't be displayed anymore --- .../banking/persistence/model/BankAccount.kt | 3 +++ .../persistence/model/BankAccountEntity.kt | 3 ++- .../banking/ui/android/home/HomeFragment.kt | 8 +++----- .../net/dankito/banking/ui/model/BankAccount.kt | 4 ++++ .../dankito/banking/ui/model/IBankAccount.kt | 1 + .../banking/ui/presenter/BankingPresenter.kt | 17 +++++++++++++++++ .../BankingiOSApp.xcdatamodel/contents | 3 ++- .../BankingiOSApp/persistence/Mapper.swift | 4 ++++ .../ui/dialogs/AccountTransactionsDialog.swift | 11 ++++------- 9 files changed, 40 insertions(+), 14 deletions(-) diff --git a/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/model/BankAccount.kt b/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/model/BankAccount.kt index 0a4e8943..7d9ce5d7 100644 --- a/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/model/BankAccount.kt +++ b/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/model/BankAccount.kt @@ -66,6 +66,9 @@ open class BankAccount( override var displayIndex: Int = 0 + override var doNotShowStrikingFetchAllTransactionsView = false + + override fun toString(): String { return stringRepresentation } diff --git a/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/model/BankAccountEntity.kt b/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/model/BankAccountEntity.kt index 062e5c63..5993faab 100644 --- a/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/model/BankAccountEntity.kt +++ b/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/model/BankAccountEntity.kt @@ -33,7 +33,8 @@ open class BankAccountEntity( override var userSetDisplayName: String? = null, override var haveAllTransactionsBeenRetrieved: Boolean = false, override var isAccountTypeSupportedByApplication: Boolean = true, - override var displayIndex: Int = 0 + override var displayIndex: Int = 0, + override var doNotShowStrikingFetchAllTransactionsView: Boolean = false ) : IBankAccount { diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt index 1458d1ef..0679f72f 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt @@ -293,8 +293,8 @@ class HomeFragment : Fragment() { private fun setFetchAllTransactionsView() { accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched - val showFetchAllTransactionsView = accountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty() - || presenter.selectedAccountsTransactionRetrievalState == TransactionsRetrievalState.RetrievedTransactions + showTopFetchAllTransactionsView = presenter.showStrikingFetchAllTransactionsViewForSelectedAccounts + val showFetchAllTransactionsView = presenter.showFetchAllTransactionsViewForSelectedAccounts if (showFetchAllTransactionsView && showTopFetchAllTransactionsView) { lytTopFetchAllTransactions.visibility = View.VISIBLE @@ -313,9 +313,7 @@ class HomeFragment : Fragment() { } private fun hideTopFetchAllTransactionsView() { - // TODO: persist - - showTopFetchAllTransactionsView = false + presenter.doNotShowStrikingFetchAllTransactionsViewAnymore(accountsForWhichNotAllTransactionsHaveBeenFetched) setFetchAllTransactionsView() } diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt index d4810ae0..ced2909a 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt @@ -50,6 +50,10 @@ open class BankAccount @JvmOverloads constructor( override var displayIndex: Int = 0 + override var doNotShowStrikingFetchAllTransactionsView = false + + + override fun toString(): String { return stringRepresentation } diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/IBankAccount.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/IBankAccount.kt index 91835245..f345ad66 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/IBankAccount.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/IBankAccount.kt @@ -30,6 +30,7 @@ interface IBankAccount : OrderedDisplayable { var haveAllTransactionsBeenRetrieved: Boolean var isAccountTypeSupportedByApplication: Boolean var userSetDisplayName: String? + var doNotShowStrikingFetchAllTransactionsView: Boolean override val displayName: String diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt index 39c6f78a..40396be5 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -471,6 +471,16 @@ open class BankingPresenter( callBanksChangedListeners() } + open fun doNotShowStrikingFetchAllTransactionsViewAnymore(accounts: List) { + accounts.forEach { account -> + account.doNotShowStrikingFetchAllTransactionsView = true + + persistBankAsync(account.bank) + } + + callBanksChangedListeners() + } + protected open fun persistBankAsync(bank: IBankData<*, *>) { asyncRunner.runAsync { persistBankOffUiThread(bank) @@ -680,6 +690,13 @@ open class BankingPresenter( open val selectedAccountsForWhichNotAllTransactionsHaveBeenFetched: List get() = selectedAccounts.filter { it.haveAllTransactionsBeenRetrieved == false && it.isAccountTypeSupportedByApplication } + open val showFetchAllTransactionsViewForSelectedAccounts: Boolean + get() = selectedAccountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty() + && selectedAccountsTransactionRetrievalState == TransactionsRetrievalState.RetrievedTransactions + + open val showStrikingFetchAllTransactionsViewForSelectedAccounts: Boolean + get() = selectedAccountsForWhichNotAllTransactionsHaveBeenFetched.any { it.doNotShowStrikingFetchAllTransactionsView == false } + open val selectedAccountsTransactionRetrievalState: TransactionsRetrievalState get() = getAccountsTransactionRetrievalState(selectedAccounts) diff --git a/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents b/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents index 74991583..5e0b3b2f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents +++ b/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents @@ -42,6 +42,7 @@ + @@ -90,7 +91,7 @@ - + diff --git a/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift b/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift index 11540080..d6f0d183 100644 --- a/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift +++ b/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift @@ -66,6 +66,8 @@ class Mapper { mapped.userSetDisplayName = account.userSetDisplayName mapped.displayIndex = account.displayIndex + mapped.doNotShowStrikingFetchAllTransactionsView = account.doNotShowStrikingFetchAllTransactionsView + mapped.bookedTransactions = map(mapped, account.transactions as? Set) mapped.technicalId = account.objectIDAsString @@ -103,6 +105,8 @@ class Mapper { mapped.userSetDisplayName = account.userSetDisplayName mapped.displayIndex = account.displayIndex + mapped.doNotShowStrikingFetchAllTransactionsView = account.doNotShowStrikingFetchAllTransactionsView + mapped.transactions = NSSet(array: map(mapped, account.bookedTransactions, context)) return mapped diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift index 48e3b408..aa05280f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift @@ -165,8 +165,8 @@ struct AccountTransactionsDialog: View { let haveTransactionsForSelectedAccountsBeenRetrieved = transactionsRetrievalState == .retrievedtransactions self.accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched - self.showFetchAllTransactionsView = accountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty && haveTransactionsForSelectedAccountsBeenRetrieved - //self.showFetchAllTransactionsViewAtTop = true // TODO: read from database + self.showFetchAllTransactionsView = presenter.showFetchAllTransactionsViewForSelectedAccounts + self.showFetchAllTransactionsViewAtTop = presenter.showStrikingFetchAllTransactionsViewForSelectedAccounts self.showTransactionsList = haveTransactionsForSelectedAccountsBeenRetrieved @@ -176,12 +176,9 @@ struct AccountTransactionsDialog: View { } private func hideTopFetchAllTransactionsView() { - // TODO: save that we shouldn't show showFetchAllTransactionsView at top anymore in database - for account in accountsForWhichNotAllTransactionsHaveBeenFetched { - //UserDefaults.standard.set(true, forKey: Self.DoNotShowFetchAllTransactionsOverlayForUserDefaultsKeyPrefix + account.technicalId) - } + presenter.doNotShowStrikingFetchAllTransactionsViewAnymore(accounts: accountsForWhichNotAllTransactionsHaveBeenFetched) - self.showFetchAllTransactionsViewAtTop = false + setTransactionsView() }