Bug 743158 - Take focus away from awesome bar when accessing awesome screen lists. r=wesj
authorJim Chen <nchen@mozilla.com>
Mon, 29 Apr 2013 14:36:23 -0400
changeset 130260 cc11cd6a518a0baaf071c5c02207c231c6c4161c
parent 130259 6a0948b0cd69ddd4e532c167039bcddac0f469e4
child 130261 0c37b537e562be3761ca17a8c70df5abec4f5825
push id24609
push useremorley@mozilla.com
push dateTue, 30 Apr 2013 12:53:53 +0000
treeherdermozilla-central@3fb2370f4871 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs743158
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 743158 - Take focus away from awesome bar when accessing awesome screen lists. r=wesj
mobile/android/base/AwesomeBarTabs.java
mobile/android/base/resources/layout/awesomebar_tabs.xml
--- a/mobile/android/base/AwesomeBarTabs.java
+++ b/mobile/android/base/AwesomeBarTabs.java
@@ -127,18 +127,20 @@ public class AwesomeBarTabs extends TabH
 
         // This should be called before adding any tabs
         // to the TabHost.
         setup();
 
         mListTouchListener = new View.OnTouchListener() {
             @Override
             public boolean onTouch(View view, MotionEvent event) {
-                if (event.getActionMasked() == MotionEvent.ACTION_DOWN)
-                    hideSoftInput(view);
+                if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+                    // take focus away from awesome bar to hide the keyboard
+                    requestFocus();
+                }
                 return false;
             }
         };
 
         mTabs = new AwesomeBarTab[] {
             new AllPagesTab(mContext),
             new BookmarksTab(mContext),
             new HistoryTab(mContext)
@@ -156,17 +158,18 @@ public class AwesomeBarTabs extends TabH
             @Override
             public void onPageScrollStateChanged(int state) { }
             @Override
             public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }
             @Override
             public void onPageSelected(int position) {
                 tabWidget.setCurrentTab(position);
                 styleSelectedTab();
-                hideSoftInput(mViewPager);
+                // take focus away from awesome bar to hide the keyboard
+                requestFocus();
              }
          });
 
         for (int i = 0; i < mTabs.length; i++) {
             mTabs[i].setListTouchListener(mListTouchListener);
             addAwesomeTab(mTabs[i].getTag(),
                           mTabs[i].getTitleStringId(),
                           i);
@@ -271,23 +274,16 @@ public class AwesomeBarTabs extends TabH
             public void onClick(View v) {
                 mViewPager.setCurrentItem(contentId, true);
             }
         });
 
         return indicatorView;
     }
 
-    private boolean hideSoftInput(View view) {
-        InputMethodManager imm =
-                (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
-
-        return imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
-    }
-
     public void setOnUrlOpenListener(OnUrlOpenListener listener) {
         mUrlOpenListener = listener;
         for (AwesomeBarTab tab : mTabs) {
             tab.setUrlListener(listener);
         }
     }
 
     public void destroy() {
--- a/mobile/android/base/resources/layout/awesomebar_tabs.xml
+++ b/mobile/android/base/resources/layout/awesomebar_tabs.xml
@@ -1,17 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <org.mozilla.gecko.AwesomeBarTabs xmlns:android="http://schemas.android.com/apk/res/android"
                                   android:id="@+id/awesomebar_tabs"
                                   android:layout_width="fill_parent"
-                                  android:layout_height="fill_parent">
+                                  android:layout_height="fill_parent"
+                                  android:focusable="true"
+                                  android:focusableInTouchMode="true">
 
     <LinearLayout android:orientation="vertical"
                   android:layout_width="fill_parent"
                   android:layout_height="fill_parent">
 
         <view class="org.mozilla.gecko.AwesomeBarTabs$BackgroundLayout"
               android:id="@+id/tab_widget_container"
               android:layout_width="fill_parent"