Merge "Fixed some small keyboard nav bugs (TabHost, directional focus)" into oc-mr1-dev

am: c8b91ecbae

Change-Id: Ife498c2a72c2053f9d6d7f2ffee6ed63153f2a7b
This commit is contained in:
Evan Rosky
2017-09-11 21:03:41 +00:00
committed by android-build-merger
2 changed files with 7 additions and 2 deletions

View File

@@ -574,10 +574,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}.");

View File

@@ -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;