Fixed some small keyboard nav bugs (TabHost, directional focus)
- TabHost was forwarding Tab/shift+tab/space to its content instead of navigating through the tabs. - FocusFinder's directional focus considered 2 touching Views to be overlapping which would yield confusing directional movement at times. Bug: 62943663 Bug: 62911028 Test: Added CTS tests Change-Id: I253f66b7513daf5c2c9fdeed8a2fb930b4fd8db4
This commit is contained in:
@@ -564,10 +564,10 @@ public class FocusFinder {
|
||||
switch (direction) {
|
||||
case View.FOCUS_LEFT:
|
||||
case View.FOCUS_RIGHT:
|
||||
return (rect2.bottom >= rect1.top) && (rect2.top <= rect1.bottom);
|
||||
return (rect2.bottom > rect1.top) && (rect2.top < rect1.bottom);
|
||||
case View.FOCUS_UP:
|
||||
case View.FOCUS_DOWN:
|
||||
return (rect2.right >= rect1.left) && (rect2.left <= rect1.right);
|
||||
return (rect2.right > rect1.left) && (rect2.left < rect1.right);
|
||||
}
|
||||
throw new IllegalArgumentException("direction must be one of "
|
||||
+ "{FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}.");
|
||||
|
||||
@@ -146,12 +146,17 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
|
||||
// and relays them to the tab content.
|
||||
mTabKeyListener = new OnKeyListener() {
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (KeyEvent.isModifierKey(keyCode)) {
|
||||
return false;
|
||||
}
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_DPAD_CENTER:
|
||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||
case KeyEvent.KEYCODE_DPAD_UP:
|
||||
case KeyEvent.KEYCODE_DPAD_DOWN:
|
||||
case KeyEvent.KEYCODE_TAB:
|
||||
case KeyEvent.KEYCODE_SPACE:
|
||||
case KeyEvent.KEYCODE_ENTER:
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user