Implemented BankAccountSettingsDialog
This commit is contained in:
parent
85bf455c0c
commit
2c9c374ee1
|
@ -0,0 +1,59 @@
|
||||||
|
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_bank_account_settings.*
|
||||||
|
import kotlinx.android.synthetic.main.dialog_bank_account_settings.view.*
|
||||||
|
import kotlinx.android.synthetic.main.dialog_bank_settings.view.toolbar
|
||||||
|
import net.dankito.banking.ui.android.R
|
||||||
|
import net.dankito.banking.ui.model.TypedBankAccount
|
||||||
|
|
||||||
|
|
||||||
|
open class BankAccountSettingsDialog : SettingsDialogBase() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val DialogTag = "BankAccountSettingsDialog"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected lateinit var account: TypedBankAccount
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun show(account: TypedBankAccount, activity: AppCompatActivity) {
|
||||||
|
this.account = account
|
||||||
|
|
||||||
|
show(activity, DialogTag)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
val rootView = inflater.inflate(R.layout.dialog_bank_account_settings, container, false)
|
||||||
|
|
||||||
|
setupUI(rootView)
|
||||||
|
|
||||||
|
return rootView
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun setupUI(rootView: View) {
|
||||||
|
rootView.apply {
|
||||||
|
toolbar.apply {
|
||||||
|
setupToolbar(this, account.displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
edtxtBankAccountName.text = account.displayName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override val hasUnsavedChanges: Boolean
|
||||||
|
get() = didChange(edtxtBankAccountName, account.displayName)
|
||||||
|
|
||||||
|
override fun saveChanges() {
|
||||||
|
account.userSetDisplayName = edtxtBankAccountName.text
|
||||||
|
|
||||||
|
presenter.accountUpdated(account)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ open class BankSettingsDialog : SettingsDialogBase() {
|
||||||
protected open fun setupUI(rootView: View) {
|
protected open fun setupUI(rootView: View) {
|
||||||
rootView.apply {
|
rootView.apply {
|
||||||
toolbar.apply {
|
toolbar.apply {
|
||||||
setupToolbar(this, bank.bankName)
|
setupToolbar(this, bank.displayName)
|
||||||
}
|
}
|
||||||
|
|
||||||
edtxtBankName.text = bank.displayName
|
edtxtBankName.text = bank.displayName
|
||||||
|
@ -54,6 +54,7 @@ open class BankSettingsDialog : SettingsDialogBase() {
|
||||||
|
|
||||||
val items = bank.accountsSorted.map { DraggableBankAccountAdapterItem(it) }
|
val items = bank.accountsSorted.map { DraggableBankAccountAdapterItem(it) }
|
||||||
val adapter = FastAdapterRecyclerView(rootView.rcyBankAccounts, items, true)
|
val adapter = FastAdapterRecyclerView(rootView.rcyBankAccounts, items, true)
|
||||||
|
adapter.onClickListener = { navigationToBankAccountSettingsDialog(it.account) }
|
||||||
adapter.itemDropped = { oldPosition, oldItem, newPosition, newItem -> reorderedBankAccounts(oldPosition, oldItem.account, newPosition, newItem.account) }
|
adapter.itemDropped = { oldPosition, oldItem, newPosition, newItem -> reorderedBankAccounts(oldPosition, oldItem.account, newPosition, newItem.account) }
|
||||||
|
|
||||||
btnDeleteAccount.setOnClickListener { askUserToDeleteAccount() }
|
btnDeleteAccount.setOnClickListener { askUserToDeleteAccount() }
|
||||||
|
@ -61,6 +62,10 @@ open class BankSettingsDialog : SettingsDialogBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected open fun navigationToBankAccountSettingsDialog(account: TypedBankAccount) {
|
||||||
|
BankAccountSettingsDialog().show(account, requireActivity() as AppCompatActivity)
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun reorderedBankAccounts(oldPosition: Int, oldItem: TypedBankAccount, newPosition: Int, newItem: TypedBankAccount) {
|
protected open fun reorderedBankAccounts(oldPosition: Int, oldItem: TypedBankAccount, newPosition: Int, newItem: TypedBankAccount) {
|
||||||
oldItem.displayIndex = oldPosition
|
oldItem.displayIndex = oldPosition
|
||||||
newItem.displayIndex = newPosition
|
newItem.displayIndex = newPosition
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:navigationIcon="@drawable/ic_baseline_close_24"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- dummy layout to fetch focus on start so that dialog doesn't start with keyboard displayed -->
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="0px"
|
||||||
|
android:layout_height="0px"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="@dimen/form_padding"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
|
||||||
|
<net.dankito.banking.ui.android.views.FormEditText
|
||||||
|
android:id="@+id/edtxtBankAccountName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/dialog_bank_account_settings_account_name"
|
||||||
|
android:inputType="text"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -106,6 +106,8 @@
|
||||||
<string name="dialog_bank_settings_bank_name">Name</string>
|
<string name="dialog_bank_settings_bank_name">Name</string>
|
||||||
<string name="dialog_bank_settings_delete_account">Konto löschen</string>
|
<string name="dialog_bank_settings_delete_account">Konto löschen</string>
|
||||||
|
|
||||||
|
<string name="dialog_bank_account_settings_account_name">Name</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="alert_ask_discard_changes_title">Nicht gespeicherte Änderungen</string>
|
<string name="alert_ask_discard_changes_title">Nicht gespeicherte Änderungen</string>
|
||||||
<string name="alert_ask_discard_changes_message">Es wurden nicht alle Änderungen gespeichert. Sind Sie sich sicher, dass Sie sie verwerfen möchten?\n\n(TODO: Oder einfach: Änderungen verwerfen?)</string>
|
<string name="alert_ask_discard_changes_message">Es wurden nicht alle Änderungen gespeichert. Sind Sie sich sicher, dass Sie sie verwerfen möchten?\n\n(TODO: Oder einfach: Änderungen verwerfen?)</string>
|
||||||
|
|
|
@ -106,6 +106,8 @@
|
||||||
<string name="dialog_bank_settings_bank_name">Name</string>
|
<string name="dialog_bank_settings_bank_name">Name</string>
|
||||||
<string name="dialog_bank_settings_delete_account">Delete account</string>
|
<string name="dialog_bank_settings_delete_account">Delete account</string>
|
||||||
|
|
||||||
|
<string name="dialog_bank_account_settings_account_name">Name</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="alert_ask_discard_changes_title">Unsaved changed</string>
|
<string name="alert_ask_discard_changes_title">Unsaved changed</string>
|
||||||
<string name="alert_ask_discard_changes_message">Changed data hasn\'t been saved. Are you sure you want to discard them?\n\n(TODO: Oder einfach: Discard changes?)</string>
|
<string name="alert_ask_discard_changes_message">Changed data hasn\'t been saved. Are you sure you want to discard them?\n\n(TODO: Oder einfach: Discard changes?)</string>
|
||||||
|
|
Loading…
Reference in New Issue