Implemented logging in / setting authentication method when pressing enter

This commit is contained in:
dankito 2020-10-07 20:51:44 +02:00
parent 0a6fa8e01a
commit 26baf222d6
2 changed files with 22 additions and 1 deletions

View File

@ -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 {

View File

@ -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
}
}