diff --git a/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/RoomBankingPersistence.kt b/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/RoomBankingPersistence.kt index 8a6bf1e0..7be731ec 100644 --- a/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/RoomBankingPersistence.kt +++ b/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/RoomBankingPersistence.kt @@ -189,7 +189,8 @@ open class RoomBankingPersistence(protected open val applicationContext: Context override fun saveOrUpdateAppSettings(appSettings: AppSettings) { - val mapped = net.dankito.banking.persistence.model.AppSettings(appSettings.updateAccountsAutomatically, appSettings.refreshAccountsAfterMinutes) + val mapped = net.dankito.banking.persistence.model.AppSettings(appSettings.automaticallyUpdateAccounts, + appSettings.automaticallyUpdateAccountsAfterMinutes, appSettings.lockAppAfterMinutes) database.appSettingsDao().saveOrUpdate(mapped) saveOrUpdateTanMethodSettings(appSettings.flickerCodeSettings, FlickerCodeTanMethodSettingsId) @@ -211,8 +212,9 @@ open class RoomBankingPersistence(protected open val applicationContext: Context val settings = AppSettings() database.appSettingsDao().getAll().firstOrNull { it.id == AppSettingsId }?.let { persistedSettings -> - settings.updateAccountsAutomatically = persistedSettings.updateAccountsAutomatically - settings.refreshAccountsAfterMinutes = persistedSettings.refreshAccountsAfterMinutes + settings.automaticallyUpdateAccounts = persistedSettings.automaticallyUpdateAccounts + settings.automaticallyUpdateAccountsAfterMinutes = persistedSettings.automaticallyUpdateAccountsAfterMinutes + settings.lockAppAfterMinutes = persistedSettings.lockAppAfterMinutes } settings.flickerCodeSettings = findTanMethodSettings(FlickerCodeTanMethodSettingsId, tanMethodSettings) diff --git a/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/model/AppSettings.kt b/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/model/AppSettings.kt index 859aee9c..096deb88 100644 --- a/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/model/AppSettings.kt +++ b/persistence/database/RoomBankingPersistence/src/main/java/net/dankito/banking/persistence/model/AppSettings.kt @@ -8,11 +8,12 @@ import net.dankito.banking.ui.model.settings.AppSettings @Entity open class AppSettings( - open var updateAccountsAutomatically: Boolean = true, - open var refreshAccountsAfterMinutes: Int = AppSettings.DefaultRefreshAccountsAfterMinutes + open var automaticallyUpdateAccounts: Boolean = true, + open var automaticallyUpdateAccountsAfterMinutes: Int = AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes, + open var lockAppAfterMinutes: Int? = null ) { - internal constructor() : this(true, AppSettings.DefaultRefreshAccountsAfterMinutes) + internal constructor() : this(true, AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes, null) @PrimaryKey open var id: Int = RoomBankingPersistence.AppSettingsId diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/AppSettings.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/AppSettings.kt index e0d49696..7b857e20 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/AppSettings.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/settings/AppSettings.kt @@ -4,19 +4,20 @@ import net.dankito.utils.multiplatform.UUID open class AppSettings( - open var updateAccountsAutomatically: Boolean = true, - open var refreshAccountsAfterMinutes: Int = DefaultRefreshAccountsAfterMinutes, + open var automaticallyUpdateAccounts: Boolean = true, + open var automaticallyUpdateAccountsAfterMinutes: Int = DefaultAutomaticallyUpdateAccountsAfterMinutes, + open var lockAppAfterMinutes: Int? = null, open var flickerCodeSettings: TanMethodSettings? = null, open var qrCodeSettings: TanMethodSettings? = null, open var photoTanSettings: TanMethodSettings? = null ) { companion object { - const val DefaultRefreshAccountsAfterMinutes = 8 * 60 // 8 hours + const val DefaultAutomaticallyUpdateAccountsAfterMinutes = 8 * 60 // 8 hours } - internal constructor() : this(true, DefaultRefreshAccountsAfterMinutes, null, null) // for object deserializers + internal constructor() : this(true, DefaultAutomaticallyUpdateAccountsAfterMinutes, null, null, null) // for object deserializers open var technicalId: String = UUID.random() 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 932414c1..526a5a15 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 @@ -123,7 +123,7 @@ open class BankingPresenter( readAppSettings() readPersistedBanks() - if (appSettings.updateAccountsAutomatically) { + if (appSettings.automaticallyUpdateAccounts) { doAutomaticAccountsUpdate() } } diff --git a/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents b/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents index ddf7d94c..f45d0513 100644 --- a/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents +++ b/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -37,8 +37,9 @@ - - + + + @@ -108,7 +109,7 @@ - + diff --git a/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift b/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift index 8c8a7abf..fc9d25ca 100644 --- a/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift +++ b/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift @@ -319,8 +319,9 @@ class Mapper { func map(_ settings: PersistedAppSettings) -> AppSettings { let mapped = AppSettings( - updateAccountsAutomatically: settings.updateAccountsAutomatically, - refreshAccountsAfterMinutes: settings.refreshAccountsAfterMinutes, + automaticallyUpdateAccounts: settings.automaticallyUpdateAccounts, + automaticallyUpdateAccountsAfterMinutes: settings.automaticallyUpdateAccountsAfterMinutes, + lockAppAfterMinutes: mapToInt(settings.lockAppAfterMinutes), flickerCodeSettings: map(settings.flickerCodeSettings), qrCodeSettings: map(settings.qrCodeSettings), photoTanSettings: map(settings.photoTanSettings)) @@ -333,8 +334,9 @@ class Mapper { func map(_ settings: AppSettings, _ context: NSManagedObjectContext) -> PersistedAppSettings { let mapped = context.objectByID(settings.technicalId) ?? PersistedAppSettings(context: context) - mapped.updateAccountsAutomatically = settings.updateAccountsAutomatically - mapped.refreshAccountsAfterMinutes = settings.refreshAccountsAfterMinutes + mapped.automaticallyUpdateAccounts = settings.automaticallyUpdateAccounts + mapped.automaticallyUpdateAccountsAfterMinutes = settings.automaticallyUpdateAccountsAfterMinutes + mapped.lockAppAfterMinutes = mapFromInt(settings.lockAppAfterMinutes) mapped.flickerCodeSettings = map(settings.flickerCodeSettings, context) mapped.qrCodeSettings = map(settings.qrCodeSettings, context) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/SettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/SettingsDialog.swift index f82b3fa7..93439f19 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/SettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/SettingsDialog.swift @@ -13,7 +13,7 @@ struct SettingsDialog: View { @Inject private var authenticationService: AuthenticationService - @State private var updateAccountsAutomatically: Bool = true + @State private var automaticallyUpdateAccounts: Bool = true @State private var askToDeleteAccountMessage: Message? = nil @@ -21,7 +21,7 @@ struct SettingsDialog: View { init(_ data: AppData) { self.data = data - self._updateAccountsAutomatically = State(initialValue: presenter.appSettings.updateAccountsAutomatically) + self._automaticallyUpdateAccounts = State(initialValue: presenter.appSettings.automaticallyUpdateAccounts) } @@ -39,7 +39,7 @@ struct SettingsDialog: View { } Section { - Toggle("Update accounts automatically", isOn: $updateAccountsAutomatically) + Toggle("Update accounts automatically", isOn: $automaticallyUpdateAccounts) } Section { @@ -110,8 +110,8 @@ struct SettingsDialog: View { private func saveChanges() { - if updateAccountsAutomatically != presenter.appSettings.updateAccountsAutomatically { - presenter.appSettings.updateAccountsAutomatically = updateAccountsAutomatically + if automaticallyUpdateAccounts != presenter.appSettings.automaticallyUpdateAccounts { + presenter.appSettings.automaticallyUpdateAccounts = automaticallyUpdateAccounts presenter.appSettingsChanged() } }