Added UI to set if accounts should be updated automatically
This commit is contained in:
parent
746591597e
commit
e64e8925c4
|
@ -3,6 +3,7 @@ package net.dankito.banking.ui.android.dialogs.settings
|
|||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import kotlinx.android.synthetic.main.dialog_settings.*
|
||||
import kotlinx.android.synthetic.main.dialog_settings.view.*
|
||||
import net.dankito.banking.ui.android.R
|
||||
import net.dankito.banking.ui.android.adapter.BankDataAdapterItem
|
||||
|
@ -42,7 +43,7 @@ open class SettingsDialog : SettingsDialogBase() {
|
|||
protected open fun setupUI(rootView: View) {
|
||||
rootView.apply {
|
||||
toolbar.apply {
|
||||
setupToolbar(this, rootView.context.getString(R.string.settings), false)
|
||||
setupToolbar(this, rootView.context.getString(R.string.settings))
|
||||
}
|
||||
|
||||
val items = createBanksAdapterItems()
|
||||
|
@ -50,6 +51,8 @@ open class SettingsDialog : SettingsDialogBase() {
|
|||
banksAdapter.onClickListener = { navigationToBankSettingsDialog(it.bank) }
|
||||
banksAdapter.itemDropped = { oldPosition, oldItem, newPosition, newItem -> reorderedBanks(oldPosition, oldItem.bank, newPosition, newItem.bank) }
|
||||
|
||||
swtchUpdateAccountsAutomatically.isChecked = presenter.appSettings.updateAccountsAutomatically
|
||||
|
||||
btnSetAppProtection.setOnClickListener { ProtectAppSettingsDialog().show(requireActivity() as AppCompatActivity) }
|
||||
|
||||
btnShowSendMessageLogDialog.setOnClickListener { presenter.showSendMessageLogDialog() }
|
||||
|
@ -87,10 +90,11 @@ open class SettingsDialog : SettingsDialogBase() {
|
|||
|
||||
|
||||
override val hasUnsavedChanges: Boolean
|
||||
get() = false
|
||||
get() = presenter.appSettings.updateAccountsAutomatically != swtchUpdateAccountsAutomatically.isChecked
|
||||
|
||||
override fun saveChanges() {
|
||||
|
||||
presenter.appSettings.updateAccountsAutomatically = swtchUpdateAccountsAutomatically.isChecked
|
||||
presenter.appSettingsChanged()
|
||||
}
|
||||
|
||||
}
|
|
@ -57,6 +57,28 @@
|
|||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/form_section_extra_margin_top"
|
||||
>
|
||||
|
||||
<net.dankito.banking.ui.android.views.FormSectionTitle
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swtchUpdateAccountsAutomatically"
|
||||
style="@style/FormSwitchStyle"
|
||||
android:text="@string/dialog_settings_update_accounts_automatically"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSetAppProtection"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -118,8 +118,9 @@
|
|||
<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_send_message_log_title">Message Log senden</string>
|
||||
<string name="dialog_settings_update_accounts_automatically">Konten automatisch aktualisieren</string>
|
||||
<string name="dialog_settings_secure_app_data">Appdaten schützen</string>
|
||||
<string name="dialog_settings_send_message_log_title">Message Log senden</string>
|
||||
|
||||
<string name="dialog_protect_app_settings_title">Appzugangsschutz</string>
|
||||
<string name="dialog_protect_app_settings_biometric_authentication_method_title">Biometrie</string>
|
||||
|
|
|
@ -118,8 +118,9 @@
|
|||
<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_send_message_log_title">Send message log</string>
|
||||
<string name="dialog_settings_update_accounts_automatically">Update accounts automatically</string>
|
||||
<string name="dialog_settings_secure_app_data">Secure app data</string>
|
||||
<string name="dialog_settings_send_message_log_title">Send message log</string>
|
||||
|
||||
<string name="dialog_protect_app_settings_title">App protection</string>
|
||||
<string name="dialog_protect_app_settings_biometric_authentication_method_title">Biometric</string>
|
||||
|
|
|
@ -160,6 +160,7 @@ Unfortunately, Bankmeister cannot know whether a bank charges for real-time tran
|
|||
|
||||
/* SettingsDialog */
|
||||
|
||||
"Update accounts automatically" = "Update accounts automatically";
|
||||
"Secure app data" = "Secure app data";
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class TabBarController : UITabBarController, UITabBarControllerDelegate {
|
|||
newOptionsTab.tabBarItem = buildTabBarItem("New", "new")
|
||||
|
||||
|
||||
let settingsTab = buildControllerAndTabBarItem("Settings", "Settings", SettingsDialog(data: data))
|
||||
let settingsTab = buildControllerAndTabBarItem("Settings", "Settings", SettingsDialog(data))
|
||||
|
||||
|
||||
self.viewControllers = [accountsTab, newOptionsTab, settingsTab]
|
||||
|
|
|
@ -161,6 +161,7 @@ Ob eine Bank Gebühren für Echtzeitüberweisungen erhebt, kann Bankmeister leid
|
|||
|
||||
/* SettingsDialog */
|
||||
|
||||
"Update accounts automatically" = "Konten automatisch aktualisieren";
|
||||
"Secure app data" = "Appdaten schützen";
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,17 @@ struct SettingsDialog: View {
|
|||
|
||||
@Inject var presenter: BankingPresenterSwift
|
||||
|
||||
|
||||
@State private var updateAccountsAutomatically: Bool = true
|
||||
|
||||
@State private var askToDeleteAccountMessage: Message? = nil
|
||||
|
||||
|
||||
init(_ data: AppData) {
|
||||
self.data = data
|
||||
|
||||
self._updateAccountsAutomatically = State(initialValue: presenter.appSettings.updateAccountsAutomatically)
|
||||
}
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
@ -27,6 +36,10 @@ struct SettingsDialog: View {
|
|||
.onDelete(perform: deleteBanks)
|
||||
}
|
||||
|
||||
Section {
|
||||
Toggle("Update accounts automatically", isOn: $updateAccountsAutomatically)
|
||||
}
|
||||
|
||||
Section {
|
||||
NavigationLink(destination: EmptyView(), isActive: .constant(false)) { // we need custom navigation handling, so disable that NavigationLink takes care of navigating
|
||||
Text("Secure app data")
|
||||
|
@ -38,6 +51,7 @@ struct SettingsDialog: View {
|
|||
self.navigateToProtectAppSettingsDialog()
|
||||
}
|
||||
}
|
||||
.onDisappear { self.saveChanges() }
|
||||
.alert(message: $askToDeleteAccountMessage)
|
||||
.showNavigationBarTitle("Settings")
|
||||
}
|
||||
|
@ -93,6 +107,14 @@ struct SettingsDialog: View {
|
|||
}
|
||||
|
||||
|
||||
private func saveChanges() {
|
||||
if updateAccountsAutomatically != presenter.appSettings.updateAccountsAutomatically {
|
||||
presenter.appSettings.updateAccountsAutomatically = updateAccountsAutomatically
|
||||
presenter.appSettingsChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func navigateToProtectAppSettingsDialog() {
|
||||
let authenticationService = AuthenticationService()
|
||||
|
||||
|
@ -116,7 +138,7 @@ struct SettingsDialog: View {
|
|||
struct SettingsDialog_Previews: PreviewProvider {
|
||||
|
||||
static var previews: some View {
|
||||
SettingsDialog(data: AppData())
|
||||
SettingsDialog(AppData())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue