Bug 924480 - Part 1.5: Make HomePager focusable. r=lucasr

This commit is contained in:
Michael Comella 2013-10-23 12:15:34 -07:00
Родитель 0acfb1147a
Коммит 262a916f39
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -96,6 +96,13 @@ public class HomePager extends ViewPager {
// This is to keep all 4 pages in memory after they are
// selected in the pager.
setOffscreenPageLimit(3);
// We can call HomePager.requestFocus to steal focus from the URL bar and drop the soft
// keyboard. However, if there are no focusable views (e.g. an empty reading list), the
// URL bar will be refocused. Therefore, we make the HomePager container focusable to
// ensure there is always a focusable view. This would ordinarily be done via an XML
// attribute, but it is not working properly.
setFocusableInTouchMode(true);
}
@Override
@ -324,10 +331,7 @@ public class HomePager extends ViewPager {
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
// XXX: Drop the soft keyboard by stealing focus. Note that the HomePager (via XML
// attr) is focusable after its descendants allowing requestFocus to succeed and drop
// the soft keyboard even if there are no other focusable views on the screen (e.g.
// the Reading List is empty).
// Drop the soft keyboard by stealing focus from the URL bar.
requestFocus();
}