-
-
Notifications
You must be signed in to change notification settings - Fork 280
bug_244: fix pre-Android 14 Google TV DPAD input handling of text v.s… #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
app/src/main/java/net/christianbeier/droidvnc_ng/InputService.java
Outdated
Show resolved
Hide resolved
| Objects.requireNonNull(currentFocusNode).performAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_NEXT_AT_MOVEMENT_GRANULARITY.getId(), action); | ||
| if ((keysym == 0xff51 || keysym == 0xff52 || keysym == 0xff53 || keysym == 0xff54) && down != 0) { | ||
|
|
||
| if (currentFocusNode == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the indentation seems off here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved
| supportsTextTraversal = className.equals("android.widget.EditText") || className.contains("TextField"); | ||
| } | ||
|
|
||
| if (supportsTextTraversal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would we be able to focus-traverse out of a text field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this current implementation, it won't traverse out.
I need to add something to check if the cursor is at the edge of the text (beginning, end, top, or bottom), and allow traversal in that case.
|
Sorry -- I have not forgotten about this -- I will find some time this weekend and update! |
No problem; I know exactly how this is... |
|
@dustinmcafee you don't have to invest time on this, I've taken your PR and reworked it a bit in the light of shortcomings in my code that I need to fix. I will commit your change, preserving your authorship, when done. |
…. non-text focusable views
…AT_MOVEMENT_GRANULARITY is actually commonly used on Android Google TV homescreen. Also, if currentFocusNode is null, then try to attain focus on some node to prevent forcing user to use mouse
…uneccesary logic to other keypresses
|
@bk138 Sorry -- I actually was taking another look, today. I fixed indentation issues, and re-added the comment. I am going to try to test this commit out sometime today for the traversing out of text fields: Also, I needed to do some force-pushes -- because I didn't realize I was using the wrong SSH keys to push some commits, and I needed to make sure it specified my current email address. |
|
How can I test this bug fix? The DPAD issue would be a fantastic fix! |
Thanks! I'll give it a go tonight! |
|
@andresberge this is still a bit rough (focus sometimes lost on app change) but the basics do work. |
RCA:
For Android devices older than version 14, the application was attempting to handle DPAD (remote control directional pad) inputs by moving a text cursor, which is incorrect for navigating a TV user interface.
To fix this, I made the following changes to app/src/main/java/net/christianbeier/droidvnc_ng/InputService.java:
Added context-aware navigation: When the user has a text field (including standard EditText and TextView) in focus, the D-pad now functions as a text cursor.
View Navigation: If the focused element is not a text field, the D-pad retains its original behavior, shifting the focus between different UI components.
Also attempts to attain focus when user presses on DPAD, and there is no focus available. This allows user to have better control in the edge-case where device doesn't consider any particular view in focus.
On a TV Device (running Android < 14):
Effect: This is a critical fix. DPAD navigation with a remote control will now work correctly, allowing users to navigate between buttons, menus, and other UI elements. The application is now usable on these devices.
Risk: None. This change corrects the behavior to match user expectations for a TV app.
On a non-TV Device (Phone/Tablet, running Android < 14):
Effect: This change is also an improvement. If a user has an external keyboard connected, the arrow keys will now properly navigate between focusable elements in the app (like buttons or input fields), which is standard behavior. The previous text-cursor logic was less useful and only worked inside text boxes.
Risk: Very low. The new behavior is more consistent with standard Android keyboard navigation and is unlikely to cause any issues.
On Any Device (TV or non-TV, running Android 14+):
Effect: None. These devices use a more modern input handling method that was already working correctly. The code I modified is part of a fallback for older Android versions and is not executed on newer ones.
Risk: None.
Video of test run on Sony TV running Android 9:
https://drive.google.com/file/d/1gjjfkjSKLxkCvSKM51FbqrCtp24S7ygE/view?usp=sharing