servoview: Focus the view when a touch input occurs.#40049
Conversation
Signed-off-by: Josh Matthews <[email protected]>
|
|
||
| @Override | ||
| public boolean onTouchEvent(final MotionEvent e) { | ||
| requestFocus(); |
There was a problem hiding this comment.
Do we have to request focus on each touch event? Also, I noticed that the focus change listener we add in the activity here never gets called. Could this be related to the current issue?
There was a problem hiding this comment.
I'm having trouble imagining what alternatives there are to requesting focus on input. Also, the focus listener is definitely called in my testing—how are you determining that?
There was a problem hiding this comment.
I'm having trouble imagining what alternatives there are to requesting focus on input.
My concern was that requestFocus might be too costly to be called on every touch event, so maybe there could be an alternative where we requestFocus only when we know the view doesn't have it already. I don't know about the actual cost of requestFocus though.
Also, the focus listener is definitely called in my testing—how are you determining that?
Yep, it does get called. I was using assert false as the body, but I didn't realize assertions are disabled in release builds. The debug build confirms that it is called.
mukilan
left a comment
There was a problem hiding this comment.
I couldn't come up with a better approach, so lets go with this.
Focusing the location bar in the Android app shows the onscreen keyboard, but clicking on a link in the current document does not make it disappear. This change ensures the input focus is reset appropriately and ensures the keyboard disappear when the location bar is not being edited.
Testing: Manually tested. No automated tests for Android app at this time.
Fixes: #40008