summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorKi-Hwan Lee <kihwanl@google.com>2013-01-08 13:19:32 +0900
committerKi-Hwan Lee <kihwanl@google.com>2013-02-07 13:26:14 +0900
commit4ef158baa3382909c436cbc31e123ef981387e4e (patch)
treef9f4376ecc68b8f785c0fcb0f391e0b74e208f37 /core/java/android
parentaf595a0f37643f12f32860fdea43fb67b74654b4 (diff)
downloadframeworks_base-4ef158baa3382909c436cbc31e123ef981387e4e.zip
frameworks_base-4ef158baa3382909c436cbc31e123ef981387e4e.tar.gz
frameworks_base-4ef158baa3382909c436cbc31e123ef981387e4e.tar.bz2
Fix ViewRootImpl to find missing focus using D-pad.
By using D-pad, no-focus in non touch mode is rare but legal in a case like below. 1. The first request to get focus for a new activity is handled in the first performTraversals() call when activity is not ready for a complete view hierarchy. So there might be no focusable yet. 2. If the activity has some menus, ActionMenuView can be attached to the view hierarchy in the PhoneWindow.preparePanel() soon. So there can be focusables but still not focused. Fixed ViewRootImpl.deliverKeyEventPostIme() to handle this case to resurrect a focus if there are focusables. How to reproduce: (1) Open "API Demos" application -> Views -> Search View (2) Select "Action Bar" item using the D-pad (3) Try to focus the Search View, using the D-pad. Change-Id: Ic379774f0307f168f0ed775d0f6a9078ac5c9713
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/ViewRootImpl.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 27d770b..6d63c6f 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -3793,6 +3793,13 @@ public final class ViewRootImpl implements ViewParent,
finishInputEvent(q, true);
return;
}
+ } else {
+ // find the best view to give focus to in this non-touch-mode with no-focus
+ View v = focusSearch(null, direction);
+ if (v != null && v.requestFocus(direction)) {
+ finishInputEvent(q, true);
+ return;
+ }
}
}
}