Removed automaticallyUpdateAccounts as automaticallyUpdateAccountsAfterMinutes can contain information if accounts should be updated automatically or not
This commit is contained in:
parent
ffeb412a84
commit
0706c91bac
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -70,12 +70,6 @@
|
|||
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
|
||||
android:id="@+id/selectUpdateAccountsAfter"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -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_settings_update_accounts_automatically">Konten automatisch aktualisieren</string>
|
||||
<string name="dialog_settings_update_accounts_automatically_after">Aktualisieren nach (kommt noch)</string>
|
||||
<string name="dialog_settings_update_accounts_automatically_after">Konten aktualisieren nach (kommt noch)</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_send_message_log_title">Message Log senden</string>
|
||||
|
|
|
@ -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_settings_update_accounts_automatically">Update accounts automatically</string>
|
||||
<string name="dialog_settings_update_accounts_automatically_after">Update after (to be implemented)</string>
|
||||
<string name="dialog_settings_update_accounts_automatically_after">Update accounts after (to be implemented)</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_send_message_log_title">Send message log</string>
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -122,7 +122,7 @@ open class BankingPresenter(
|
|||
readAppSettings()
|
||||
readPersistedBanks()
|
||||
|
||||
if (appSettings.automaticallyUpdateAccounts) {
|
||||
if (appSettings.automaticallyUpdateAccountsAfterMinutes != null) { // TODO: check if time has elapsed
|
||||
doAutomaticAccountsUpdate()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
<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="automaticallyUpdateAccounts" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
|
||||
<attribute name="automaticallyUpdateAccountsAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="360" usesScalarValueType="YES"/>
|
||||
<attribute name="automaticallyUpdateAccountsAfterMinutes" optional="YES" attributeType="Integer 32" defaultValueString="360" 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="photoTanSettings" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="PersistedTanMethodSettings"/>
|
||||
|
@ -109,7 +108,7 @@
|
|||
</entity>
|
||||
<elements>
|
||||
<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="PersistedBankData" positionX="-63" positionY="-18" width="128" height="298"/>
|
||||
<element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/>
|
||||
|
|
|
@ -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)";
|
||||
|
||||
|
|
|
@ -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)";
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue