Renamed updateAccountsAutomatically to automaticallyUpdateAccounts, refreshAccountsAfterMinutes to automaticallyUpdateAccountsAfterMinutes and added lockAppAfterMinutes
This commit is contained in:
parent
1ef89d27ec
commit
5a4f962293
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -123,7 +123,7 @@ open class BankingPresenter(
|
|||
readAppSettings()
|
||||
readPersistedBanks()
|
||||
|
||||
if (appSettings.updateAccountsAutomatically) {
|
||||
if (appSettings.automaticallyUpdateAccounts) {
|
||||
doAutomaticAccountsUpdate()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?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">
|
||||
<attribute name="amount" attributeType="Decimal" defaultValueString="0.0"/>
|
||||
<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"/>
|
||||
</entity>
|
||||
<entity name="PersistedAppSettings" representedClassName="PersistedAppSettings" syncable="YES" codeGenerationType="class">
|
||||
<attribute name="refreshAccountsAfterMinutes" attributeType="Integer 32" defaultValueString="480" usesScalarValueType="YES"/>
|
||||
<attribute name="updateAccountsAutomatically" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
|
||||
<attribute name="automaticallyUpdateAccounts" 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="photoTanSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/>
|
||||
<relationship name="qrCodeSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/>
|
||||
|
@ -108,7 +109,7 @@
|
|||
</entity>
|
||||
<elements>
|
||||
<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="PersistedBankData" positionX="-63" positionY="-18" width="128" height="298"/>
|
||||
<element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue