From cccede436d20887233501777651612e0306d79b0 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 19 Nov 2020 16:22:34 +0100 Subject: [PATCH] Fixed that after changing or even deleting a selected bank's name 'Add account' button still has been activated --- .../ui/android/dialogs/AddAccountDialog.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt index fee8e1aa..d30d28ad 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt @@ -24,6 +24,7 @@ import net.dankito.banking.ui.android.util.StandardAutocompleteCallback import net.dankito.banking.ui.model.responses.AddAccountResponse import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.bankfinder.BankInfo +import net.dankito.banking.ui.android.util.StandardTextWatcher import net.dankito.utils.android.extensions.asActivity import net.dankito.utils.android.extensions.hide import net.dankito.utils.android.extensions.show @@ -40,6 +41,8 @@ open class AddAccountDialog : DialogFragment() { protected var selectedBank: BankInfo? = null + protected var justDidSelectBank: Boolean = false + @Inject protected lateinit var presenter: BankingPresenter @@ -87,6 +90,10 @@ open class AddAccountDialog : DialogFragment() { } private fun initBankListAutocompletion(edtxtBank: EditText) { + edtxtBank.addTextChangedListener(StandardTextWatcher { + mayClearSelectedBank() + }) + val autocompleteCallback = StandardAutocompleteCallback { _, item -> bankSelected(item) true @@ -163,8 +170,12 @@ open class AddAccountDialog : DialogFragment() { protected open fun bankSelected(bank: BankInfo) { selectedBank = bank + justDidSelectBank = true + edtxtBank.text = bank.name + justDidSelectBank = false + edtxtUserName.requestFocus() checkIfRequiredDataEnteredOnUiThread() @@ -174,6 +185,14 @@ open class AddAccountDialog : DialogFragment() { } } + protected open fun mayClearSelectedBank() { + if (justDidSelectBank == false) { + selectedBank = null + } + + checkIfRequiredDataEnteredOnUiThread() + } + private fun showBankDoesNotSupportFinTs30ErrorMessage(bank: BankInfo) { activity?.let { context -> val errorMessage = context.getString(R.string.dialog_add_account_bank_does_not_support_fints_3_error_message, bank.name)