Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
25500a79
Commit
25500a79
authored
Mar 17, 2020
by
ValentinTimisica
Browse files
For #6295: Clear focus for username/password when Done is pressed
parent
fb8dbbe4
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/feature/prompts/src/main/java/mozilla/components/feature/prompts/dialog/LoginDialogFragment.kt
View file @
25500a79
...
...
@@ -33,6 +33,7 @@ import mozilla.components.concept.storage.Login
import
mozilla.components.concept.storage.LoginValidationDelegate
import
mozilla.components.concept.storage.LoginValidationDelegate.Result
import
mozilla.components.feature.prompts.R
import
mozilla.components.feature.prompts.ext.onDone
import
mozilla.components.support.ktx.android.content.appName
import
mozilla.components.support.ktx.android.view.toScope
import
kotlin.reflect.KProperty
...
...
@@ -50,7 +51,7 @@ private const val KEY_LOGIN_HTTP_REALM = "KEY_LOGIN_HTTP_REALM"
* [android.support.v4.app.DialogFragment] implementation to display a
* dialog that allows users to save/update usernames and passwords for a given domain.
*/
@Suppress
(
"TooManyFunctions"
)
@Suppress
(
"TooManyFunctions"
,
"LargeClass"
)
internal
class
LoginDialogFragment
:
PromptDialogFragment
()
{
private
inner
class
SafeArgString
(
private
val
key
:
String
)
{
...
...
@@ -162,6 +163,12 @@ internal class LoginDialogFragment : PromptDialogFragment() {
override
fun
onTextChanged
(
s
:
CharSequence
?,
start
:
Int
,
before
:
Int
,
count
:
Int
)
=
Unit
})
with
(
usernameEditText
)
{
onDone
(
false
)
{
clearFocus
()
}
}
}
private
fun
bindPassword
(
view
:
View
)
{
...
...
@@ -192,6 +199,12 @@ internal class LoginDialogFragment : PromptDialogFragment() {
override
fun
onTextChanged
(
s
:
CharSequence
?,
start
:
Int
,
before
:
Int
,
count
:
Int
)
=
Unit
})
with
(
passwordEditText
)
{
onDone
(
false
)
{
clearFocus
()
}
}
}
/**
...
...
components/feature/prompts/src/main/java/mozilla/components/feature/prompts/ext/EditText.kt
0 → 100644
View file @
25500a79
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package
mozilla.components.feature.prompts.ext
import
android.view.inputmethod.EditorInfo
import
android.widget.EditText
/**
* Extension function to handle keyboard Done action
* @param actionConsumed true if you have consumed the action, else false.
* @param onDonePressed callback to execute when Done key is pressed
*/
internal
fun
EditText
.
onDone
(
actionConsumed
:
Boolean
,
onDonePressed
:
()
->
Unit
)
{
setOnEditorActionListener
{
_
,
actionId
,
_
->
when
(
actionId
)
{
EditorInfo
.
IME_ACTION_DONE
->
{
onDonePressed
()
actionConsumed
}
else
->
false
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment