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 7be731ec..7a340264 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,8 +189,8 @@ open class RoomBankingPersistence(protected open val applicationContext: Context
override fun saveOrUpdateAppSettings(appSettings: AppSettings) {
- val mapped = net.dankito.banking.persistence.model.AppSettings(appSettings.automaticallyUpdateAccounts,
- appSettings.automaticallyUpdateAccountsAfterMinutes, appSettings.lockAppAfterMinutes)
+ val mapped = net.dankito.banking.persistence.model.AppSettings(appSettings.automaticallyUpdateAccountsAfterMinutes,
+ appSettings.lockAppAfterMinutes)
database.appSettingsDao().saveOrUpdate(mapped)
saveOrUpdateTanMethodSettings(appSettings.flickerCodeSettings, FlickerCodeTanMethodSettingsId)
@@ -212,7 +212,6 @@ open class RoomBankingPersistence(protected open val applicationContext: Context
val settings = AppSettings()
database.appSettingsDao().getAll().firstOrNull { it.id == AppSettingsId }?.let { persistedSettings ->
- settings.automaticallyUpdateAccounts = persistedSettings.automaticallyUpdateAccounts
settings.automaticallyUpdateAccountsAfterMinutes = persistedSettings.automaticallyUpdateAccountsAfterMinutes
settings.lockAppAfterMinutes = persistedSettings.lockAppAfterMinutes
}
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 096deb88..49262216 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,12 +8,11 @@ import net.dankito.banking.ui.model.settings.AppSettings
@Entity
open class AppSettings(
- open var automaticallyUpdateAccounts: Boolean = true,
- open var automaticallyUpdateAccountsAfterMinutes: Int = AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes,
+ open var automaticallyUpdateAccountsAfterMinutes: Int? = AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes,
open var lockAppAfterMinutes: Int? = null
) {
- internal constructor() : this(true, AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes, null)
+ internal constructor() : this(AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes, null)
@PrimaryKey
open var id: Int = RoomBankingPersistence.AppSettingsId
diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialog.kt
index 38e7b7c6..647ede55 100644
--- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialog.kt
+++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialog.kt
@@ -52,7 +52,6 @@ open class SettingsDialog : SettingsDialogBase() {
banksAdapter.onClickListener = { navigationToBankSettingsDialog(it.bank) }
banksAdapter.itemDropped = { oldPosition, oldItem, newPosition, newItem -> reorderedBanks(oldPosition, oldItem.bank, newPosition, newItem.bank) }
- swtchAutomaticallyUpdateAccounts.isChecked = presenter.appSettings.automaticallyUpdateAccounts
selectUpdateAccountsAfter.periodInMinutes = presenter.appSettings.automaticallyUpdateAccountsAfterMinutes
btnSetAppProtection.setOnClickListener { navigateToProtectAppSettingsDialog() }
@@ -104,10 +103,12 @@ open class SettingsDialog : SettingsDialogBase() {
override val hasUnsavedChanges: Boolean
- get() = presenter.appSettings.automaticallyUpdateAccounts != swtchAutomaticallyUpdateAccounts.isChecked
+ get() = presenter.appSettings.automaticallyUpdateAccountsAfterMinutes != selectUpdateAccountsAfter.periodInMinutes
+ || presenter.appSettings.lockAppAfterMinutes != selectLockAppAfter.periodInMinutes
override fun saveChanges() {
- presenter.appSettings.automaticallyUpdateAccounts = swtchAutomaticallyUpdateAccounts.isChecked
+ presenter.appSettings.automaticallyUpdateAccountsAfterMinutes = selectUpdateAccountsAfter.periodInMinutes
+ presenter.appSettings.lockAppAfterMinutes = selectLockAppAfter.periodInMinutes
presenter.appSettingsChanged()
}
diff --git a/ui/BankingAndroidApp/src/main/res/layout/dialog_settings.xml b/ui/BankingAndroidApp/src/main/res/layout/dialog_settings.xml
index 64694a1e..3447c3f4 100644
--- a/ui/BankingAndroidApp/src/main/res/layout/dialog_settings.xml
+++ b/ui/BankingAndroidApp/src/main/res/layout/dialog_settings.xml
@@ -70,12 +70,6 @@
android:text="@string/settings"
/>
-
-
ATC muss eine Zahl sein.\n\nDer eingebene ATC Wert \'%s\' kann jedoch nicht in eine Zahl konvertiert werden.
- Konten automatisch aktualisieren
- Aktualisieren nach (kommt noch)
+ Konten aktualisieren nach (kommt noch)
Appdaten schützen
App sperren nach (kommt noch)
Message Log senden
diff --git a/ui/BankingAndroidApp/src/main/res/values/strings.xml b/ui/BankingAndroidApp/src/main/res/values/strings.xml
index 5b846dba..5f6825f9 100644
--- a/ui/BankingAndroidApp/src/main/res/values/strings.xml
+++ b/ui/BankingAndroidApp/src/main/res/values/strings.xml
@@ -134,8 +134,7 @@
ATC has to be a number.\n\nBut entered ATC value \'%s\' cannot be converted to a number.
- Update accounts automatically
- Update after (to be implemented)
+ Update accounts after (to be implemented)
Secure app data
Lock app after (to be implemented)
Send message log
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 c11ad2b3..238dba1e 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,8 +4,7 @@ import net.dankito.utils.multiplatform.UUID
open class AppSettings(
- open var automaticallyUpdateAccounts: Boolean = true,
- open var automaticallyUpdateAccountsAfterMinutes: Int = DefaultAutomaticallyUpdateAccountsAfterMinutes,
+ open var automaticallyUpdateAccountsAfterMinutes: Int? = DefaultAutomaticallyUpdateAccountsAfterMinutes,
open var lockAppAfterMinutes: Int? = null,
open var flickerCodeSettings: TanMethodSettings? = null,
open var qrCodeSettings: TanMethodSettings? = null,
@@ -17,7 +16,7 @@ open class AppSettings(
}
- internal constructor() : this(true, DefaultAutomaticallyUpdateAccountsAfterMinutes, null, null, null) // for object deserializers
+ internal constructor() : this(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 0f8bdd10..13810298 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
@@ -122,7 +122,7 @@ open class BankingPresenter(
readAppSettings()
readPersistedBanks()
- if (appSettings.automaticallyUpdateAccounts) {
+ if (appSettings.automaticallyUpdateAccountsAfterMinutes != null) { // TODO: check if time has elapsed
doAutomaticAccountsUpdate()
}
}
diff --git a/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents b/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents
index f4f713f6..561e16a0 100644
--- a/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents
+++ b/ui/BankingiOSApp/BankingiOSApp/BankingiOSApp.xcdatamodeld/BankingiOSApp.xcdatamodel/contents
@@ -37,8 +37,7 @@
-
-
+
@@ -109,7 +108,7 @@
-
+
diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings
index c5934333..d24a487e 100644
--- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings
+++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings
@@ -171,8 +171,7 @@ Unfortunately, Bankmeister cannot know whether a bank charges for real-time tran
/* SettingsDialog */
-"Automatically update accounts" = "Update accounts automatically";
-"Automatically update accounts after" = "Update after (to be implemented)";
+"Automatically update accounts after" = "Update accounts after (to be implemented)";
"Secure app data" = "Secure app data";
"Lock app after" = "Lock app after (to be implemented)";
diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings
index 2d7905f5..991eae41 100644
--- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings
+++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings
@@ -172,8 +172,7 @@ Ob eine Bank Gebühren für Echtzeitüberweisungen erhebt, kann Bankmeister leid
/* SettingsDialog */
-"Automatically update accounts" = "Konten automatisch aktualisieren";
-"Automatically update accounts after" = "Aktualisieren nach (kommt noch)";
+"Automatically update accounts after" = "Konten aktualisieren nach (kommt noch)";
"Secure app data" = "Appdaten schützen";
"Lock app after" = "App sperren nach (kommt noch)";
diff --git a/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift b/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift
index fc9d25ca..940b9aa2 100644
--- a/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift
+++ b/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift
@@ -319,23 +319,21 @@ class Mapper {
func map(_ settings: PersistedAppSettings) -> AppSettings {
let mapped = AppSettings(
- automaticallyUpdateAccounts: settings.automaticallyUpdateAccounts,
- automaticallyUpdateAccountsAfterMinutes: settings.automaticallyUpdateAccountsAfterMinutes,
+ automaticallyUpdateAccountsAfterMinutes: mapToInt(settings.automaticallyUpdateAccountsAfterMinutes),
lockAppAfterMinutes: mapToInt(settings.lockAppAfterMinutes),
flickerCodeSettings: map(settings.flickerCodeSettings),
qrCodeSettings: map(settings.qrCodeSettings),
photoTanSettings: map(settings.photoTanSettings))
mapped.technicalId = settings.objectIDAsString
-
+
return mapped
}
func map(_ settings: AppSettings, _ context: NSManagedObjectContext) -> PersistedAppSettings {
let mapped = context.objectByID(settings.technicalId) ?? PersistedAppSettings(context: context)
- mapped.automaticallyUpdateAccounts = settings.automaticallyUpdateAccounts
- mapped.automaticallyUpdateAccountsAfterMinutes = settings.automaticallyUpdateAccountsAfterMinutes
+ mapped.automaticallyUpdateAccountsAfterMinutes = mapFromInt(settings.automaticallyUpdateAccountsAfterMinutes)
mapped.lockAppAfterMinutes = mapFromInt(settings.lockAppAfterMinutes)
mapped.flickerCodeSettings = map(settings.flickerCodeSettings, context)
diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/SettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/SettingsDialog.swift
index ed8811c6..f70c79f3 100644
--- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/SettingsDialog.swift
+++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/SettingsDialog.swift
@@ -4,9 +4,11 @@ import BankingUiSwift
struct SettingsDialog: View {
- static private let AutomaticallyUpdateAccountsAfterOptions: [Int] = [ 60, 2 * 60, 4 * 60, 6 * 60, 8 * 60, 10 * 60, 12 * 60, 24 * 60 ]
+ static private let Never = -1
- static private let LockAppAfterOptions: [Int] = [ 0, 1, 2, 5, 10, 15, 30, 60, 2 * 60, 4 * 60, 8 * 60, 12 * 60, -1 ]
+ static private let AutomaticallyUpdateAccountsAfterOptions: [Int] = [ Never, 60, 2 * 60, 4 * 60, 6 * 60, 8 * 60, 10 * 60, 12 * 60, 24 * 60 ]
+
+ static private let LockAppAfterOptions: [Int] = [ 0, 1, 2, 5, 10, 15, 30, 60, 2 * 60, 4 * 60, 8 * 60, 12 * 60, Never ]
@Environment(\.editMode) var editMode
@@ -18,8 +20,6 @@ struct SettingsDialog: View {
@Inject private var authenticationService: AuthenticationService
- @State private var automaticallyUpdateAccounts: Bool = true
-
@State private var automaticallyUpdateAccountsAfterMinutesSelectedIndex: Int = 0
@State private var lockAppAfterMinutesSelectedIndex: Int = 0
@@ -32,10 +32,10 @@ struct SettingsDialog: View {
let settings = presenter.appSettings
- self._automaticallyUpdateAccounts = State(initialValue: settings.automaticallyUpdateAccounts)
- self._automaticallyUpdateAccountsAfterMinutesSelectedIndex = State(initialValue: Self.AutomaticallyUpdateAccountsAfterOptions.firstIndex(of: Int(settings.automaticallyUpdateAccountsAfterMinutes)) ?? 0)
+ let automaticallyUpdateAccountsAfterMinutes = settings.automaticallyUpdateAccountsAfterMinutes != nil ? Int(settings.automaticallyUpdateAccountsAfterMinutes!) : Self.Never
+ self._automaticallyUpdateAccountsAfterMinutesSelectedIndex = State(initialValue: Self.AutomaticallyUpdateAccountsAfterOptions.firstIndex(of: Int(automaticallyUpdateAccountsAfterMinutes)) ?? 0)
- let lockAppAfterMinutes = settings.lockAppAfterMinutes != nil ? Int(settings.lockAppAfterMinutes!) : -1
+ let lockAppAfterMinutes = settings.lockAppAfterMinutes != nil ? Int(settings.lockAppAfterMinutes!) : Self.Never
self._lockAppAfterMinutesSelectedIndex = State(initialValue: Self.LockAppAfterOptions.firstIndex(of: lockAppAfterMinutes) ?? 0)
}
@@ -54,8 +54,6 @@ struct SettingsDialog: View {
}
Section {
- Toggle("Automatically update accounts", isOn: $automaticallyUpdateAccounts)
-
Picker("Automatically update accounts after", selection: $automaticallyUpdateAccountsAfterMinutesSelectedIndex) {
ForEach(0 ..< Self.AutomaticallyUpdateAccountsAfterOptions.count) { optionIndex in
Text(getDisplayTextForPeriod(Self.AutomaticallyUpdateAccountsAfterOptions[optionIndex]))
@@ -156,12 +154,29 @@ struct SettingsDialog: View {
private func saveChanges() {
- if automaticallyUpdateAccounts != presenter.appSettings.automaticallyUpdateAccounts {
- presenter.appSettings.automaticallyUpdateAccounts = automaticallyUpdateAccounts
+ let settings = presenter.appSettings
+
+ let automaticallyUpdateAccountsAfterMinutes = getPeriod(Self.AutomaticallyUpdateAccountsAfterOptions, automaticallyUpdateAccountsAfterMinutesSelectedIndex)
+ let lockAppAfterMinutes = getPeriod(Self.LockAppAfterOptions, lockAppAfterMinutesSelectedIndex)
+
+ if automaticallyUpdateAccountsAfterMinutes != settings.automaticallyUpdateAccountsAfterMinutes
+ || lockAppAfterMinutes != settings.lockAppAfterMinutes {
+ settings.automaticallyUpdateAccountsAfterMinutes = automaticallyUpdateAccountsAfterMinutes
+ settings.lockAppAfterMinutes = lockAppAfterMinutes
presenter.appSettingsChanged()
}
}
+ private func getPeriod(_ allValues: [Int], _ selectedIndex: Int) -> KotlinInt? {
+ let value = allValues[selectedIndex]
+
+ if value == Self.Never {
+ return nil
+ }
+
+ return KotlinInt(int: Int32(value))
+ }
+
private func navigateToProtectAppSettingsDialog() {
if authenticationService.needsAuthenticationToUnlockApp == false {