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 ddd61e8e..38e7b7c6 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,9 +52,11 @@ 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
+ swtchAutomaticallyUpdateAccounts.isChecked = presenter.appSettings.automaticallyUpdateAccounts
+ selectUpdateAccountsAfter.periodInMinutes = presenter.appSettings.automaticallyUpdateAccountsAfterMinutes
btnSetAppProtection.setOnClickListener { navigateToProtectAppSettingsDialog() }
+ selectLockAppAfter.periodInMinutes = presenter.appSettings.lockAppAfterMinutes
// on Pre Lollipop devices setting vector drawables in xml is not supported -> set left drawable here
val sendIcon = AppCompatResources.getDrawable(context, R.drawable.ic_baseline_send_24)
@@ -102,10 +104,10 @@ open class SettingsDialog : SettingsDialogBase() {
override val hasUnsavedChanges: Boolean
- get() = presenter.appSettings.updateAccountsAutomatically != swtchUpdateAccountsAutomatically.isChecked
+ get() = presenter.appSettings.automaticallyUpdateAccounts != swtchAutomaticallyUpdateAccounts.isChecked
override fun saveChanges() {
- presenter.appSettings.updateAccountsAutomatically = swtchUpdateAccountsAutomatically.isChecked
+ presenter.appSettings.automaticallyUpdateAccounts = swtchAutomaticallyUpdateAccounts.isChecked
presenter.appSettingsChanged()
}
diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt
index 602ed227..5efbca51 100644
--- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt
+++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt
@@ -5,6 +5,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
+import android.widget.TextView
import kotlinx.android.synthetic.main.view_form_labelled_value.view.*
import net.dankito.banking.ui.android.R
@@ -13,6 +14,10 @@ open class FormLabelledValue @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
+ protected lateinit var txtLabel: TextView
+
+ protected lateinit var txtValue: TextView
+
init {
setupUi(context, attrs)
@@ -23,6 +28,8 @@ open class FormLabelledValue @JvmOverloads constructor(
val rootView = inflater.inflate(R.layout.view_form_labelled_value, this, true)
rootView.apply {
+ txtLabel = findViewById(R.id.txtLabel)
+ txtValue = findViewById(R.id.txtValue)
context.theme.obtainStyledAttributes(
attrs,
diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormSelectPeriod.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormSelectPeriod.kt
new file mode 100644
index 00000000..1dfc37bf
--- /dev/null
+++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormSelectPeriod.kt
@@ -0,0 +1,102 @@
+package net.dankito.banking.ui.android.views
+
+import android.content.Context
+import android.os.Build
+import android.util.AttributeSet
+import android.view.Gravity
+import android.view.LayoutInflater
+import android.view.View
+import android.widget.RelativeLayout
+import android.widget.TextView
+import net.dankito.banking.ui.android.R
+
+
+open class FormSelectPeriod @JvmOverloads constructor(
+ context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
+) : RelativeLayout(context, attrs, defStyleAttr) {
+
+ protected lateinit var txtLabel: TextView
+
+ protected lateinit var txtValue: TextView
+
+
+ init {
+ setupUi(context, attrs)
+ }
+
+ private fun setupUi(context: Context, attrs: AttributeSet?) {
+ val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+ val rootView = inflater.inflate(R.layout.view_form_select_period, this, true)
+
+ rootView.apply {
+ txtLabel = findViewById(R.id.txtLabel)
+ txtValue = findViewById(R.id.txtValue)
+
+ txtLabel.gravity = Gravity.CENTER_VERTICAL
+ txtValue.gravity = Gravity.CENTER_VERTICAL
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ txtLabel.textAlignment = View.TEXT_ALIGNMENT_GRAVITY
+ txtValue.textAlignment = View.TEXT_ALIGNMENT_GRAVITY
+ }
+
+ this.isEnabled = false // TODO: undo as soon as selecting periods is implemented
+
+ context.theme.obtainStyledAttributes(
+ attrs,
+ R.styleable.FormLabelledValue,
+ 0, 0).apply {
+
+ try {
+ txtLabel.text = getString(R.styleable.FormSelectPeriod_android_label)
+
+ val defaultValue = Int.MIN_VALUE
+ val configuredPeriod = getInteger(R.styleable.FormSelectPeriod_periodInMinutes, defaultValue)
+ periodInMinutes = if (configuredPeriod == defaultValue) null else configuredPeriod
+ displaySelectedPeriod()
+ } finally {
+ recycle()
+ }
+ }
+ }
+ }
+
+
+ protected open fun displaySelectedPeriod() {
+ txtValue.text = getDisplayTextForSelectedPeriod()
+ }
+
+ protected open fun getDisplayTextForSelectedPeriod(): String {
+ periodInMinutes?.let { periodInMinutes ->
+ if (periodInMinutes > 0) {
+ if (periodInMinutes < 60) {
+ return context.getString(R.string.minutes, periodInMinutes)
+ }
+
+ return context.getString(R.string.hours, (periodInMinutes / 60))
+ }
+ }
+
+ return context.getString(R.string.never)
+ }
+
+
+ open var label: CharSequence
+ get() = txtLabel.text
+ set(value) {
+ txtLabel.text = value
+ }
+
+ open var periodInMinutes: Int? = null
+ set(value) {
+ field = value
+ displaySelectedPeriod()
+ }
+
+ override fun setEnabled(enabled: Boolean) {
+ super.setEnabled(enabled)
+
+ alpha = if (enabled) 1f else 0.5f
+ }
+
+}
\ No newline at end of file
diff --git a/ui/BankingAndroidApp/src/main/res/layout/dialog_settings.xml b/ui/BankingAndroidApp/src/main/res/layout/dialog_settings.xml
index 0bf10896..64694a1e 100644
--- a/ui/BankingAndroidApp/src/main/res/layout/dialog_settings.xml
+++ b/ui/BankingAndroidApp/src/main/res/layout/dialog_settings.xml
@@ -71,11 +71,18 @@
/>
+
+
@@ -93,6 +100,13 @@
android:text="@string/dialog_settings_secure_app_data"
/>
+
+