Renamed updateAccountsAutomatically to automaticallyUpdateAccounts, refreshAccountsAfterMinutes to automaticallyUpdateAccountsAfterMinutes and added lockAppAfterMinutes

This commit is contained in:
dankito 2020-10-16 23:19:27 +02:00
parent 1ef89d27ec
commit 5a4f962293
7 changed files with 31 additions and 24 deletions

View File

@ -189,7 +189,8 @@ open class RoomBankingPersistence(protected open val applicationContext: Context
override fun saveOrUpdateAppSettings(appSettings: AppSettings) { 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) database.appSettingsDao().saveOrUpdate(mapped)
saveOrUpdateTanMethodSettings(appSettings.flickerCodeSettings, FlickerCodeTanMethodSettingsId) saveOrUpdateTanMethodSettings(appSettings.flickerCodeSettings, FlickerCodeTanMethodSettingsId)
@ -211,8 +212,9 @@ open class RoomBankingPersistence(protected open val applicationContext: Context
val settings = AppSettings() val settings = AppSettings()
database.appSettingsDao().getAll().firstOrNull { it.id == AppSettingsId }?.let { persistedSettings -> database.appSettingsDao().getAll().firstOrNull { it.id == AppSettingsId }?.let { persistedSettings ->
settings.updateAccountsAutomatically = persistedSettings.updateAccountsAutomatically settings.automaticallyUpdateAccounts = persistedSettings.automaticallyUpdateAccounts
settings.refreshAccountsAfterMinutes = persistedSettings.refreshAccountsAfterMinutes settings.automaticallyUpdateAccountsAfterMinutes = persistedSettings.automaticallyUpdateAccountsAfterMinutes
settings.lockAppAfterMinutes = persistedSettings.lockAppAfterMinutes
} }
settings.flickerCodeSettings = findTanMethodSettings(FlickerCodeTanMethodSettingsId, tanMethodSettings) settings.flickerCodeSettings = findTanMethodSettings(FlickerCodeTanMethodSettingsId, tanMethodSettings)

View File

@ -8,11 +8,12 @@ import net.dankito.banking.ui.model.settings.AppSettings
@Entity @Entity
open class AppSettings( open class AppSettings(
open var updateAccountsAutomatically: Boolean = true, open var automaticallyUpdateAccounts: Boolean = true,
open var refreshAccountsAfterMinutes: Int = AppSettings.DefaultRefreshAccountsAfterMinutes 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 @PrimaryKey
open var id: Int = RoomBankingPersistence.AppSettingsId open var id: Int = RoomBankingPersistence.AppSettingsId

View File

@ -4,19 +4,20 @@ import net.dankito.utils.multiplatform.UUID
open class AppSettings( open class AppSettings(
open var updateAccountsAutomatically: Boolean = true, open var automaticallyUpdateAccounts: Boolean = true,
open var refreshAccountsAfterMinutes: Int = DefaultRefreshAccountsAfterMinutes, open var automaticallyUpdateAccountsAfterMinutes: Int = DefaultAutomaticallyUpdateAccountsAfterMinutes,
open var lockAppAfterMinutes: Int? = null,
open var flickerCodeSettings: TanMethodSettings? = null, open var flickerCodeSettings: TanMethodSettings? = null,
open var qrCodeSettings: TanMethodSettings? = null, open var qrCodeSettings: TanMethodSettings? = null,
open var photoTanSettings: TanMethodSettings? = null open var photoTanSettings: TanMethodSettings? = null
) { ) {
companion object { 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() open var technicalId: String = UUID.random()

View File

@ -123,7 +123,7 @@ open class BankingPresenter(
readAppSettings() readAppSettings()
readPersistedBanks() readPersistedBanks()
if (appSettings.updateAccountsAutomatically) { if (appSettings.automaticallyUpdateAccounts) {
doAutomaticAccountsUpdate() doAutomaticAccountsUpdate()
} }
} }

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17192" systemVersion="19G2021" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> <model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17192" systemVersion="19H2" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="PersistedAccountTransaction" representedClassName="PersistedAccountTransaction" syncable="YES" codeGenerationType="class"> <entity name="PersistedAccountTransaction" representedClassName="PersistedAccountTransaction" syncable="YES" codeGenerationType="class">
<attribute name="amount" attributeType="Decimal" defaultValueString="0.0"/> <attribute name="amount" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="bookingDate" attributeType="Date" usesScalarValueType="NO"/> <attribute name="bookingDate" attributeType="Date" usesScalarValueType="NO"/>
@ -37,8 +37,9 @@
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistedBankAccount" inverseName="transactions" inverseEntity="PersistedBankAccount"/> <relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistedBankAccount" inverseName="transactions" inverseEntity="PersistedBankAccount"/>
</entity> </entity>
<entity name="PersistedAppSettings" representedClassName="PersistedAppSettings" syncable="YES" codeGenerationType="class"> <entity name="PersistedAppSettings" representedClassName="PersistedAppSettings" syncable="YES" codeGenerationType="class">
<attribute name="refreshAccountsAfterMinutes" attributeType="Integer 32" defaultValueString="480" usesScalarValueType="YES"/> <attribute name="automaticallyUpdateAccounts" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
<attribute name="updateAccountsAutomatically" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/> <attribute name="automaticallyUpdateAccountsAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="480" usesScalarValueType="YES"/>
<attribute name="lockAppAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="-1" usesScalarValueType="NO"/>
<relationship name="flickerCodeSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/> <relationship name="flickerCodeSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/>
<relationship name="photoTanSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/> <relationship name="photoTanSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/>
<relationship name="qrCodeSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/> <relationship name="qrCodeSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/>
@ -108,7 +109,7 @@
</entity> </entity>
<elements> <elements>
<element name="PersistedAccountTransaction" positionX="-36" positionY="45" width="128" height="553"/> <element name="PersistedAccountTransaction" positionX="-36" positionY="45" width="128" height="553"/>
<element name="PersistedAppSettings" positionX="-45" positionY="144" width="128" height="118"/> <element name="PersistedAppSettings" positionX="-45" positionY="144" width="128" height="133"/>
<element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="418"/> <element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="418"/>
<element name="PersistedBankData" positionX="-63" positionY="-18" width="128" height="298"/> <element name="PersistedBankData" positionX="-63" positionY="-18" width="128" height="298"/>
<element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/> <element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/>

View File

@ -319,8 +319,9 @@ class Mapper {
func map(_ settings: PersistedAppSettings) -> AppSettings { func map(_ settings: PersistedAppSettings) -> AppSettings {
let mapped = AppSettings( let mapped = AppSettings(
updateAccountsAutomatically: settings.updateAccountsAutomatically, automaticallyUpdateAccounts: settings.automaticallyUpdateAccounts,
refreshAccountsAfterMinutes: settings.refreshAccountsAfterMinutes, automaticallyUpdateAccountsAfterMinutes: settings.automaticallyUpdateAccountsAfterMinutes,
lockAppAfterMinutes: mapToInt(settings.lockAppAfterMinutes),
flickerCodeSettings: map(settings.flickerCodeSettings), flickerCodeSettings: map(settings.flickerCodeSettings),
qrCodeSettings: map(settings.qrCodeSettings), qrCodeSettings: map(settings.qrCodeSettings),
photoTanSettings: map(settings.photoTanSettings)) photoTanSettings: map(settings.photoTanSettings))
@ -333,8 +334,9 @@ class Mapper {
func map(_ settings: AppSettings, _ context: NSManagedObjectContext) -> PersistedAppSettings { func map(_ settings: AppSettings, _ context: NSManagedObjectContext) -> PersistedAppSettings {
let mapped = context.objectByID(settings.technicalId) ?? PersistedAppSettings(context: context) let mapped = context.objectByID(settings.technicalId) ?? PersistedAppSettings(context: context)
mapped.updateAccountsAutomatically = settings.updateAccountsAutomatically mapped.automaticallyUpdateAccounts = settings.automaticallyUpdateAccounts
mapped.refreshAccountsAfterMinutes = settings.refreshAccountsAfterMinutes mapped.automaticallyUpdateAccountsAfterMinutes = settings.automaticallyUpdateAccountsAfterMinutes
mapped.lockAppAfterMinutes = mapFromInt(settings.lockAppAfterMinutes)
mapped.flickerCodeSettings = map(settings.flickerCodeSettings, context) mapped.flickerCodeSettings = map(settings.flickerCodeSettings, context)
mapped.qrCodeSettings = map(settings.qrCodeSettings, context) mapped.qrCodeSettings = map(settings.qrCodeSettings, context)

View File

@ -13,7 +13,7 @@ struct SettingsDialog: View {
@Inject private var authenticationService: AuthenticationService @Inject private var authenticationService: AuthenticationService
@State private var updateAccountsAutomatically: Bool = true @State private var automaticallyUpdateAccounts: Bool = true
@State private var askToDeleteAccountMessage: Message? = nil @State private var askToDeleteAccountMessage: Message? = nil
@ -21,7 +21,7 @@ struct SettingsDialog: View {
init(_ data: AppData) { init(_ data: AppData) {
self.data = data 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 { Section {
Toggle("Update accounts automatically", isOn: $updateAccountsAutomatically) Toggle("Update accounts automatically", isOn: $automaticallyUpdateAccounts)
} }
Section { Section {
@ -110,8 +110,8 @@ struct SettingsDialog: View {
private func saveChanges() { private func saveChanges() {
if updateAccountsAutomatically != presenter.appSettings.updateAccountsAutomatically { if automaticallyUpdateAccounts != presenter.appSettings.automaticallyUpdateAccounts {
presenter.appSettings.updateAccountsAutomatically = updateAccountsAutomatically presenter.appSettings.automaticallyUpdateAccounts = automaticallyUpdateAccounts
presenter.appSettingsChanged() presenter.appSettingsChanged()
} }
} }