mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Update askUserForTwoFactorAuth for IME_ACTION_DONE to trigger performLogin
This commit is contained in:
parent
8938acda3f
commit
c850509fe5
1 changed files with 24 additions and 5 deletions
|
|
@ -348,12 +348,31 @@ class LoginActivity : AccountAuthenticatorActivity() {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
fun askUserForTwoFactorAuth() {
|
fun askUserForTwoFactorAuth() {
|
||||||
|
if (binding == null) {
|
||||||
|
Timber.w("Binding is null, reinitializing in askUserForTwoFactorAuth")
|
||||||
|
binding = ActivityLoginBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding!!.root)
|
||||||
|
}
|
||||||
progressDialog!!.dismiss()
|
progressDialog!!.dismiss()
|
||||||
with(binding!!) {
|
if (binding != null) {
|
||||||
twoFactorContainer.visibility = View.VISIBLE
|
with(binding!!) {
|
||||||
twoFactorContainer.hint = getString(if (lastLoginResult is LoginResult.EmailAuthResult) R.string.email_auth_code else R.string._2fa_code)
|
twoFactorContainer.visibility = View.VISIBLE
|
||||||
loginTwoFactor.visibility = View.VISIBLE
|
twoFactorContainer.hint = getString(if (lastLoginResult is LoginResult.EmailAuthResult) R.string.email_auth_code else R.string._2fa_code)
|
||||||
loginTwoFactor.requestFocus()
|
loginTwoFactor.visibility = View.VISIBLE
|
||||||
|
loginTwoFactor.requestFocus()
|
||||||
|
|
||||||
|
loginTwoFactor.setOnEditorActionListener { _, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_DONE ||
|
||||||
|
(event != null && event.keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_DOWN)) {
|
||||||
|
performLogin()
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Timber.e("Binding is null in askUserForTwoFactorAuth after reinitialization attempt")
|
||||||
}
|
}
|
||||||
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY)
|
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue