Removed automaticallyUpdateAccounts as automaticallyUpdateAccountsAfterMinutes can contain information if accounts should be updated automatically or not

This commit is contained in:
dankito 2020-10-17 01:39:52 +02:00
parent ffeb412a84
commit 0706c91bac
13 changed files with 46 additions and 46 deletions

View File

@ -189,8 +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.automaticallyUpdateAccounts, val mapped = net.dankito.banking.persistence.model.AppSettings(appSettings.automaticallyUpdateAccountsAfterMinutes,
appSettings.automaticallyUpdateAccountsAfterMinutes, appSettings.lockAppAfterMinutes) appSettings.lockAppAfterMinutes)
database.appSettingsDao().saveOrUpdate(mapped) database.appSettingsDao().saveOrUpdate(mapped)
saveOrUpdateTanMethodSettings(appSettings.flickerCodeSettings, FlickerCodeTanMethodSettingsId) saveOrUpdateTanMethodSettings(appSettings.flickerCodeSettings, FlickerCodeTanMethodSettingsId)
@ -212,7 +212,6 @@ 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.automaticallyUpdateAccounts = persistedSettings.automaticallyUpdateAccounts
settings.automaticallyUpdateAccountsAfterMinutes = persistedSettings.automaticallyUpdateAccountsAfterMinutes settings.automaticallyUpdateAccountsAfterMinutes = persistedSettings.automaticallyUpdateAccountsAfterMinutes
settings.lockAppAfterMinutes = persistedSettings.lockAppAfterMinutes settings.lockAppAfterMinutes = persistedSettings.lockAppAfterMinutes
} }

View File

@ -8,12 +8,11 @@ import net.dankito.banking.ui.model.settings.AppSettings
@Entity @Entity
open class AppSettings( 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 open var lockAppAfterMinutes: Int? = null
) { ) {
internal constructor() : this(true, AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes, null) internal constructor() : this(AppSettings.DefaultAutomaticallyUpdateAccountsAfterMinutes, null)
@PrimaryKey @PrimaryKey
open var id: Int = RoomBankingPersistence.AppSettingsId open var id: Int = RoomBankingPersistence.AppSettingsId

View File

@ -52,7 +52,6 @@ open class SettingsDialog : SettingsDialogBase() {
banksAdapter.onClickListener = { navigationToBankSettingsDialog(it.bank) } banksAdapter.onClickListener = { navigationToBankSettingsDialog(it.bank) }
banksAdapter.itemDropped = { oldPosition, oldItem, newPosition, newItem -> reorderedBanks(oldPosition, oldItem.bank, newPosition, newItem.bank) } banksAdapter.itemDropped = { oldPosition, oldItem, newPosition, newItem -> reorderedBanks(oldPosition, oldItem.bank, newPosition, newItem.bank) }
swtchAutomaticallyUpdateAccounts.isChecked = presenter.appSettings.automaticallyUpdateAccounts
selectUpdateAccountsAfter.periodInMinutes = presenter.appSettings.automaticallyUpdateAccountsAfterMinutes selectUpdateAccountsAfter.periodInMinutes = presenter.appSettings.automaticallyUpdateAccountsAfterMinutes
btnSetAppProtection.setOnClickListener { navigateToProtectAppSettingsDialog() } btnSetAppProtection.setOnClickListener { navigateToProtectAppSettingsDialog() }
@ -104,10 +103,12 @@ open class SettingsDialog : SettingsDialogBase() {
override val hasUnsavedChanges: Boolean override val hasUnsavedChanges: Boolean
get() = presenter.appSettings.automaticallyUpdateAccounts != swtchAutomaticallyUpdateAccounts.isChecked get() = presenter.appSettings.automaticallyUpdateAccountsAfterMinutes != selectUpdateAccountsAfter.periodInMinutes
|| presenter.appSettings.lockAppAfterMinutes != selectLockAppAfter.periodInMinutes
override fun saveChanges() { override fun saveChanges() {
presenter.appSettings.automaticallyUpdateAccounts = swtchAutomaticallyUpdateAccounts.isChecked presenter.appSettings.automaticallyUpdateAccountsAfterMinutes = selectUpdateAccountsAfter.periodInMinutes
presenter.appSettings.lockAppAfterMinutes = selectLockAppAfter.periodInMinutes
presenter.appSettingsChanged() presenter.appSettingsChanged()
} }

View File

@ -70,12 +70,6 @@
android:text="@string/settings" android:text="@string/settings"
/> />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swtchAutomaticallyUpdateAccounts"
style="@style/FormSwitchStyle"
android:text="@string/dialog_settings_update_accounts_automatically"
/>
<net.dankito.banking.ui.android.views.FormSelectPeriod <net.dankito.banking.ui.android.views.FormSelectPeriod
android:id="@+id/selectUpdateAccountsAfter" android:id="@+id/selectUpdateAccountsAfter"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -134,8 +134,7 @@
<string name="dialog_enter_atc_error_entered_atc_is_not_a_number">ATC muss eine Zahl sein.\n\nDer eingebene ATC Wert \'%s\' kann jedoch nicht in eine Zahl konvertiert werden.</string> <string name="dialog_enter_atc_error_entered_atc_is_not_a_number">ATC muss eine Zahl sein.\n\nDer eingebene ATC Wert \'%s\' kann jedoch nicht in eine Zahl konvertiert werden.</string>
<string name="dialog_settings_update_accounts_automatically">Konten automatisch aktualisieren</string> <string name="dialog_settings_update_accounts_automatically_after">Konten aktualisieren nach (kommt noch)</string>
<string name="dialog_settings_update_accounts_automatically_after">Aktualisieren nach (kommt noch)</string>
<string name="dialog_settings_secure_app_data">Appdaten schützen</string> <string name="dialog_settings_secure_app_data">Appdaten schützen</string>
<string name="dialog_settings_lock_app_after">App sperren nach (kommt noch)</string> <string name="dialog_settings_lock_app_after">App sperren nach (kommt noch)</string>
<string name="dialog_settings_send_message_log_title">Message Log senden</string> <string name="dialog_settings_send_message_log_title">Message Log senden</string>

View File

@ -134,8 +134,7 @@
<string name="dialog_enter_atc_error_entered_atc_is_not_a_number">ATC has to be a number.\n\nBut entered ATC value \'%s\' cannot be converted to a number.</string> <string name="dialog_enter_atc_error_entered_atc_is_not_a_number">ATC has to be a number.\n\nBut entered ATC value \'%s\' cannot be converted to a number.</string>
<string name="dialog_settings_update_accounts_automatically">Update accounts automatically</string> <string name="dialog_settings_update_accounts_automatically_after">Update accounts after (to be implemented)</string>
<string name="dialog_settings_update_accounts_automatically_after">Update after (to be implemented)</string>
<string name="dialog_settings_secure_app_data">Secure app data</string> <string name="dialog_settings_secure_app_data">Secure app data</string>
<string name="dialog_settings_lock_app_after">Lock app after (to be implemented)</string> <string name="dialog_settings_lock_app_after">Lock app after (to be implemented)</string>
<string name="dialog_settings_send_message_log_title">Send message log</string> <string name="dialog_settings_send_message_log_title">Send message log</string>

View File

@ -4,8 +4,7 @@ import net.dankito.utils.multiplatform.UUID
open class AppSettings( 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 lockAppAfterMinutes: Int? = null,
open var flickerCodeSettings: TanMethodSettings? = null, open var flickerCodeSettings: TanMethodSettings? = null,
open var qrCodeSettings: 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() open var technicalId: String = UUID.random()

View File

@ -122,7 +122,7 @@ open class BankingPresenter(
readAppSettings() readAppSettings()
readPersistedBanks() readPersistedBanks()
if (appSettings.automaticallyUpdateAccounts) { if (appSettings.automaticallyUpdateAccountsAfterMinutes != null) { // TODO: check if time has elapsed
doAutomaticAccountsUpdate() doAutomaticAccountsUpdate()
} }
} }

View File

@ -37,8 +37,7 @@
<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="automaticallyUpdateAccounts" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/> <attribute name="automaticallyUpdateAccountsAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="360" usesScalarValueType="NO"/>
<attribute name="automaticallyUpdateAccountsAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="360" usesScalarValueType="YES"/>
<attribute name="lockAppAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="-1" usesScalarValueType="NO"/> <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"/>
@ -109,7 +108,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="133"/> <element name="PersistedAppSettings" positionX="-45" positionY="144" width="128" height="118"/>
<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

@ -171,8 +171,7 @@ Unfortunately, Bankmeister cannot know whether a bank charges for real-time tran
/* SettingsDialog */ /* SettingsDialog */
"Automatically update accounts" = "Update accounts automatically"; "Automatically update accounts after" = "Update accounts after (to be implemented)";
"Automatically update accounts after" = "Update after (to be implemented)";
"Secure app data" = "Secure app data"; "Secure app data" = "Secure app data";
"Lock app after" = "Lock app after (to be implemented)"; "Lock app after" = "Lock app after (to be implemented)";

View File

@ -172,8 +172,7 @@ Ob eine Bank Gebühren für Echtzeitüberweisungen erhebt, kann Bankmeister leid
/* SettingsDialog */ /* SettingsDialog */
"Automatically update accounts" = "Konten automatisch aktualisieren"; "Automatically update accounts after" = "Konten aktualisieren nach (kommt noch)";
"Automatically update accounts after" = "Aktualisieren nach (kommt noch)";
"Secure app data" = "Appdaten schützen"; "Secure app data" = "Appdaten schützen";
"Lock app after" = "App sperren nach (kommt noch)"; "Lock app after" = "App sperren nach (kommt noch)";

View File

@ -319,8 +319,7 @@ class Mapper {
func map(_ settings: PersistedAppSettings) -> AppSettings { func map(_ settings: PersistedAppSettings) -> AppSettings {
let mapped = AppSettings( let mapped = AppSettings(
automaticallyUpdateAccounts: settings.automaticallyUpdateAccounts, automaticallyUpdateAccountsAfterMinutes: mapToInt(settings.automaticallyUpdateAccountsAfterMinutes),
automaticallyUpdateAccountsAfterMinutes: settings.automaticallyUpdateAccountsAfterMinutes,
lockAppAfterMinutes: mapToInt(settings.lockAppAfterMinutes), lockAppAfterMinutes: mapToInt(settings.lockAppAfterMinutes),
flickerCodeSettings: map(settings.flickerCodeSettings), flickerCodeSettings: map(settings.flickerCodeSettings),
qrCodeSettings: map(settings.qrCodeSettings), qrCodeSettings: map(settings.qrCodeSettings),
@ -334,8 +333,7 @@ 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.automaticallyUpdateAccounts = settings.automaticallyUpdateAccounts mapped.automaticallyUpdateAccountsAfterMinutes = mapFromInt(settings.automaticallyUpdateAccountsAfterMinutes)
mapped.automaticallyUpdateAccountsAfterMinutes = settings.automaticallyUpdateAccountsAfterMinutes
mapped.lockAppAfterMinutes = mapFromInt(settings.lockAppAfterMinutes) mapped.lockAppAfterMinutes = mapFromInt(settings.lockAppAfterMinutes)
mapped.flickerCodeSettings = map(settings.flickerCodeSettings, context) mapped.flickerCodeSettings = map(settings.flickerCodeSettings, context)

View File

@ -4,9 +4,11 @@ import BankingUiSwift
struct SettingsDialog: View { 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 @Environment(\.editMode) var editMode
@ -18,8 +20,6 @@ struct SettingsDialog: View {
@Inject private var authenticationService: AuthenticationService @Inject private var authenticationService: AuthenticationService
@State private var automaticallyUpdateAccounts: Bool = true
@State private var automaticallyUpdateAccountsAfterMinutesSelectedIndex: Int = 0 @State private var automaticallyUpdateAccountsAfterMinutesSelectedIndex: Int = 0
@State private var lockAppAfterMinutesSelectedIndex: Int = 0 @State private var lockAppAfterMinutesSelectedIndex: Int = 0
@ -32,10 +32,10 @@ struct SettingsDialog: View {
let settings = presenter.appSettings let settings = presenter.appSettings
self._automaticallyUpdateAccounts = State(initialValue: settings.automaticallyUpdateAccounts) let automaticallyUpdateAccountsAfterMinutes = settings.automaticallyUpdateAccountsAfterMinutes != nil ? Int(settings.automaticallyUpdateAccountsAfterMinutes!) : Self.Never
self._automaticallyUpdateAccountsAfterMinutesSelectedIndex = State(initialValue: Self.AutomaticallyUpdateAccountsAfterOptions.firstIndex(of: Int(settings.automaticallyUpdateAccountsAfterMinutes)) ?? 0) 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) self._lockAppAfterMinutesSelectedIndex = State(initialValue: Self.LockAppAfterOptions.firstIndex(of: lockAppAfterMinutes) ?? 0)
} }
@ -54,8 +54,6 @@ struct SettingsDialog: View {
} }
Section { Section {
Toggle("Automatically update accounts", isOn: $automaticallyUpdateAccounts)
Picker("Automatically update accounts after", selection: $automaticallyUpdateAccountsAfterMinutesSelectedIndex) { Picker("Automatically update accounts after", selection: $automaticallyUpdateAccountsAfterMinutesSelectedIndex) {
ForEach(0 ..< Self.AutomaticallyUpdateAccountsAfterOptions.count) { optionIndex in ForEach(0 ..< Self.AutomaticallyUpdateAccountsAfterOptions.count) { optionIndex in
Text(getDisplayTextForPeriod(Self.AutomaticallyUpdateAccountsAfterOptions[optionIndex])) Text(getDisplayTextForPeriod(Self.AutomaticallyUpdateAccountsAfterOptions[optionIndex]))
@ -156,12 +154,29 @@ struct SettingsDialog: View {
private func saveChanges() { private func saveChanges() {
if automaticallyUpdateAccounts != presenter.appSettings.automaticallyUpdateAccounts { let settings = presenter.appSettings
presenter.appSettings.automaticallyUpdateAccounts = automaticallyUpdateAccounts
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() 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() { private func navigateToProtectAppSettingsDialog() {
if authenticationService.needsAuthenticationToUnlockApp == false { if authenticationService.needsAuthenticationToUnlockApp == false {