Bug 1137483 - Move search engine bar under keyboard when shown. r=liuche
☠☠ backed out by 638037d979da ☠ ☠
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 23 Apr 2015 12:21:55 -0700
changeset 274017 3a1669b7df0f9e78b216e807962847023cd92dd5
parent 274016 501e46e3e348fdf8e503f330d40d538456d10544
child 274018 3dae1f0d8b0bbcdb17b56650752b80b2f41e9aaf
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs1137483
milestone40.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 1137483 - Move search engine bar under keyboard when shown. r=liuche This requires the window to resize when the keyboard is shown, which required a revision in when we draw the window background.
mobile/android/base/BrowserApp.java
mobile/android/base/home/BrowserSearch.java
mobile/android/base/resources/layout/browser_search.xml
mobile/android/base/resources/layout/gecko_app.xml
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -2627,32 +2627,44 @@ public class BrowserApp extends GeckoApp
         // (see bug 925012). Because of an Android bug (http://code.google.com/p/android/issues/detail?id=61179),
         // calling FragmentTransaction#add immediately after FragmentTransaction#remove won't add the fragment's
         // view to the layout. Calling FragmentManager#executePendingTransactions before re-adding the fragment
         // prevents this issue.
         fm.executePendingTransactions();
 
         fm.beginTransaction().add(R.id.search_container, mBrowserSearch, BROWSER_SEARCH_TAG).commitAllowingStateLoss();
         mBrowserSearch.setUserVisibleHint(true);
+
+        // We want to adjust the window size when the keyboard appears to bring the
+        // SearchEngineBar above the keyboard. However, adjusting the window size
+        // when hiding the keyboard results in graphical glitches where the keyboard was
+        // because nothing was being drawn underneath (bug 933422). This can be
+        // prevented drawing content under the keyboard (i.e. in the Window).
+        //
+        // We do this here because there are glitches when unlocking a device with
+        // BrowserSearch in the foreground if we use BrowserSearch.onStart/Stop.
+        getActivity().getWindow().setBackgroundDrawableResource(android.R.color.white);
     }
 
     private void hideBrowserSearch() {
         if (!mBrowserSearch.getUserVisibleHint()) {
             return;
         }
 
         // To prevent overdraw, the HomePager is hidden when BrowserSearch is displayed:
         // reverse that.
         mHomePagerContainer.setVisibility(View.VISIBLE);
 
         mBrowserSearchContainer.setVisibility(View.INVISIBLE);
 
         getSupportFragmentManager().beginTransaction()
                 .remove(mBrowserSearch).commitAllowingStateLoss();
         mBrowserSearch.setUserVisibleHint(false);
+
+        getWindow().setBackgroundDrawable(null);
     }
 
     /**
      * Hides certain UI elements (e.g. button toast, tabs panel) when the
      * user touches the main layout.
      */
     private class HideOnTouchListener implements TouchEventInterceptor {
         private boolean mIsHidingTabs;
--- a/mobile/android/base/home/BrowserSearch.java
+++ b/mobile/android/base/home/BrowserSearch.java
@@ -226,33 +226,16 @@ public class BrowserSearch extends HomeF
     @Override
     public void onDestroy() {
         super.onDestroy();
 
         mSearchEngines = null;
     }
 
     @Override
-    public void onStart() {
-        super.onStart();
-
-        // Adjusting the window size when showing the keyboard results in the underlying
-        // activity being painted when the keyboard is hidden (bug 933422). This can be
-        // prevented by not resizing the window.
-        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
-    }
-
-    @Override
-    public void onStop() {
-        super.onStop();
-
-        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
-    }
-
-    @Override
     public void onResume() {
         super.onResume();
 
         // Fetch engines if we need to.
         if (mSearchEngines.isEmpty() || !Locale.getDefault().equals(mLastLocale)) {
             GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:GetVisible", null));
         }
 
--- a/mobile/android/base/resources/layout/browser_search.xml
+++ b/mobile/android/base/resources/layout/browser_search.xml
@@ -14,20 +14,25 @@
               android:layout="@layout/home_suggestion_prompt" />
 
     <view class="org.mozilla.gecko.home.BrowserSearch$HomeSearchListView"
             android:id="@+id/home_list_view"
             android:layout_width="match_parent"
             android:layout_height="0dp"
             android:layout_weight="1" />
 
+    <!-- The window background is set to our desired color, #fff, so
+         reduce overdraw by not drawing the background.
+
+         Note: this needs to be transparent and not null because we
+         draw a divider in onDraw. -->
     <view class="org.mozilla.gecko.home.SearchEngineBar$SearchEngineBarContainer"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
-          android:background="#fff">
+          android:background="@android:color/transparent">
 
         <!-- We add a marginTop so the outer container can draw a divider.
 
              listSelector is too slow for showing pressed state
              so we set the pressed colors on the child. -->
         <org.mozilla.gecko.home.SearchEngineBar
               android:id="@+id/search_engine_bar"
               android:layout_width="wrap_content"
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -72,17 +72,16 @@
                                            android:layout_alignParentBottom="true"
                                            style="@style/FindBar"
                                            android:visibility="gone"/>
 
         <FrameLayout android:id="@+id/search_container"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:layout_below="@+id/browser_chrome"
-                     android:background="@android:color/white"
                      android:visibility="invisible"/>
 
         <!-- When focus is cleared from from BrowserToolbar's EditText to
              lower the virtual keyboard, focus will be returned to the root
              view. To make sure the EditText is not the first focusable view in
              the root view, BrowserToolbar should be specified as low in the
              view hierarchy as possible. -->