Bug 1106779 - Wait for keyboard to disappear before showing tabs. r=mcomella
authorJeff Lu <jll544@yahoo.com>
Wed, 25 Mar 2015 11:15:29 -0700
changeset 266028 d5fe53d4a359c5105b63d80554c79bb3233bf6b5
parent 266027 39c20be5a4bf2dba97e0d50243caf218e011423e
child 266029 bf13341538f76f5ebc254b51f20133efad96a908
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1106779
milestone39.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 1106779 - Wait for keyboard to disappear before showing tabs. r=mcomella
mobile/android/base/toolbar/BrowserToolbar.java
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -44,16 +44,17 @@ import android.graphics.drawable.StateLi
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.ContextMenu;
 import android.view.LayoutInflater;
 import android.view.MenuInflater;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.PopupWindow;
 
 /**
 * {@code BrowserToolbar} is single entry point for users of the toolbar
 * subsystem i.e. this should be the only import outside the 'toolbar'
@@ -538,35 +539,47 @@ public abstract class BrowserToolbar ext
     @Override
     public void setNextFocusDownId(int nextId) {
         super.setNextFocusDownId(nextId);
         tabsButton.setNextFocusDownId(nextId);
         urlDisplayLayout.setNextFocusDownId(nextId);
         menuButton.setNextFocusDownId(nextId);
     }
 
-    public void hideVirtualKeyboard() {
+    public boolean hideVirtualKeyboard() {
         InputMethodManager imm =
                 (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
-        imm.hideSoftInputFromWindow(tabsButton.getWindowToken(), 0);
+        return imm.hideSoftInputFromWindow(tabsButton.getWindowToken(), 0);
+    }
+
+    private void showSelectedTabs() {
+        Tab tab = Tabs.getInstance().getSelectedTab();
+        if (tab != null) {
+            if (!tab.isPrivate())
+                activity.showNormalTabs();
+            else
+                activity.showPrivateTabs();
+        }
     }
 
     private void toggleTabs() {
         if (activity.areTabsShown()) {
             if (activity.hasTabsSideBar())
                 activity.hideTabs();
         } else {
-
-            hideVirtualKeyboard();
-            Tab tab = Tabs.getInstance().getSelectedTab();
-            if (tab != null) {
-                if (!tab.isPrivate())
-                    activity.showNormalTabs();
-                else
-                    activity.showPrivateTabs();
+            if (hideVirtualKeyboard()) {
+                getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
+                    @Override
+                    public void onGlobalLayout() {
+                        getViewTreeObserver().removeGlobalOnLayoutListener(this);
+                        showSelectedTabs();
+                    }
+                });
+            } else {
+                showSelectedTabs();
             }
         }
     }
 
     protected void updateTabCount(final int count) {
         // If toolbar is in edit mode on a phone, this means the entry is expanded
         // and the tabs button is translated offscreen. Don't trigger tabs counter
         // updates until the tabs button is back on screen.