Skip to content

Commit ce16411

Browse files
committed
244: allow traversal outside of textviews on Google TV pre A14
1 parent b79ad5a commit ce16411

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

app/src/main/java/net/christianbeier/droidvnc_ng/InputService.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,29 @@ public static void onKeyEvent(int down, long keysym, long client) {
675675
supportsTextTraversal = className.equals("android.widget.EditText") || className.contains("TextField");
676676
}
677677

678+
boolean shouldDoFocusTraversal = false;
678679
if (supportsTextTraversal) {
680+
// Check if we're at text boundaries and should traverse focus instead
681+
CharSequence text = currentFocusNode.getText();
682+
int cursorPos = getCursorPos(currentFocusNode);
683+
int textLength = (text != null) ? text.length() : 0;
684+
685+
// Left: traverse focus if cursor is at beginning
686+
if (keysym == 0xff51 && cursorPos == 0) {
687+
shouldDoFocusTraversal = true;
688+
}
689+
// Right: traverse focus if cursor is at end
690+
else if (keysym == 0xff53 && cursorPos == textLength) {
691+
shouldDoFocusTraversal = true;
692+
}
693+
// Up/Down: for multi-line text, we'd need line info which is harder to get
694+
// For now, always allow Up/Down to traverse out of text fields
695+
else if (keysym == 0xff52 || keysym == 0xff54) {
696+
shouldDoFocusTraversal = true;
697+
}
698+
}
699+
700+
if (supportsTextTraversal && !shouldDoFocusTraversal) {
679701
// Text Traversal
680702
Bundle action = new Bundle();
681703
int granularity = (keysym == 0xff51 || keysym == 0xff53) ?

0 commit comments

Comments
 (0)