From 26baf222d6353ca433b57aee7d26493f156ba8ea Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 7 Oct 2020 20:51:44 +0200 Subject: [PATCH] Implemented logging in / setting authentication method when pressing enter --- .../ui/android/activities/LoginActivity.kt | 6 ++++++ .../settings/ProtectAppSettingsDialog.kt | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/activities/LoginActivity.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/activities/LoginActivity.kt index 27d84312..350185c6 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/activities/LoginActivity.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/activities/LoginActivity.kt @@ -9,6 +9,7 @@ import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.authentication.AuthenticationService import net.dankito.banking.ui.android.authentication.AuthenticationType import net.dankito.banking.ui.android.di.BankingComponent +import net.dankito.banking.ui.android.extensions.addEnterPressedListener import javax.inject.Inject @@ -36,6 +37,11 @@ open class LoginActivity : BaseActivity() { if (authenticationService.authenticationType == AuthenticationType.Password) { lytBiometricAuthentication.visibility = View.GONE + edtxtLoginPassword.actualEditText.addEnterPressedListener { + checkEnteredPasswordAndLogIn() + true + } + btnLogin.setOnClickListener { checkEnteredPasswordAndLogIn() } } else { diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt index 421efe0c..9ec43fac 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt @@ -12,6 +12,7 @@ import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.authentication.AuthenticationService import net.dankito.banking.ui.android.authentication.AuthenticationType import net.dankito.banking.ui.android.di.BankingComponent +import net.dankito.banking.ui.android.extensions.addEnterPressedListener import net.dankito.banking.ui.android.util.StandardTextWatcher import net.dankito.utils.android.extensions.hideKeyboardDelayed import org.slf4j.LoggerFactory @@ -89,7 +90,9 @@ open class ProtectAppSettingsDialog : SettingsDialogBase() { btnBiometricAuthentication.authenticationSuccessful = { btnSetAuthenticationMethod.isEnabled = true } edtxtPassword.actualEditText.addTextChangedListener(StandardTextWatcher { checkIfEnteredPasswordsMatch() } ) + edtxtPassword.actualEditText.addEnterPressedListener { checkIfEnteredPasswordsMatchAndSetAuthenticationMethod() } edtxtPasswordConfirmation.actualEditText.addTextChangedListener(StandardTextWatcher { checkIfEnteredPasswordsMatch() } ) + edtxtPasswordConfirmation.actualEditText.addEnterPressedListener { checkIfEnteredPasswordsMatchAndSetAuthenticationMethod() } btnSetAuthenticationMethod.setOnClickListener { setAuthenticationMethod() } @@ -125,14 +128,26 @@ open class ProtectAppSettingsDialog : SettingsDialogBase() { } - protected open fun checkIfEnteredPasswordsMatch() { + protected open fun checkIfEnteredPasswordsMatchAndSetAuthenticationMethod(): Boolean { + if (checkIfEnteredPasswordsMatch()) { + setAuthenticationMethod() + + return true + } + + return false + } + + protected open fun checkIfEnteredPasswordsMatch(): Boolean { val enteredPassword = edtxtPassword.text if (enteredPassword.isNotBlank() && enteredPassword == edtxtPasswordConfirmation.text) { btnSetAuthenticationMethod.isEnabled = true + return true } else { btnSetAuthenticationMethod.isEnabled = false + return false } }