From ec4ad767f28f71a8e067f47d38046fd74bbd90d4 Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Mon, 28 Oct 2013 12:06:25 -0700 Subject: [PATCH] Bug 924480 - Part 1.5: Make HomePager focusable. r=lucasr --- mobile/android/base/home/HomePager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/home/HomePager.java b/mobile/android/base/home/HomePager.java index d07debd36d5..52512320de4 100644 --- a/mobile/android/base/home/HomePager.java +++ b/mobile/android/base/home/HomePager.java @@ -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(); }