Bug 918007 - Disable toolbar elements while in editing mode on tablets (r=sriram)
☠☠ backed out by 5bafaa6987eb ☠ ☠
authorLucas Rocha <lucasr@mozilla.com>
Wed, 23 Oct 2013 14:16:44 +0100
changeset 166567 0117133ba8efeec277059f2f214b1fff55b5dd77
parent 166566 2d8cdd7baa58bfab0b5cd805e555f4bdb26a4c9b
child 166568 69a2b8bb41beb1bf32ca9bcf5c46edcd0c803bfa
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs918007
milestone27.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 918007 - Disable toolbar elements while in editing mode on tablets (r=sriram)
mobile/android/base/BrowserToolbar.java
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -1271,31 +1271,68 @@ public class BrowserToolbar extends Geck
                     ViewHelper.setAlpha(mGo, 1.0f);
                     showSoftInput();
                 }
             }
         });
     }
 
     /**
+     * Disables and dims all toolbar elements which are not
+     * related to editing mode.
+     */
+    private void updateChildrenForEditing() {
+        // This is for the tablet UI only
+        if (!HardwareUtils.isTablet()) {
+            return;
+        }
+
+        // Disable toolbar elemens while in editing mode
+        final boolean enabled = !mIsEditing;
+
+        // This alpha value has to be in sync with the one used
+        // in setButtonEnabled().
+        final float alpha = (enabled ? 1.0f : 0.24f);
+
+        mTabs.setEnabled(enabled);
+        ViewHelper.setAlpha(mTabsCounter, alpha);
+        mMenu.setEnabled(enabled);
+        ViewHelper.setAlpha(mMenuIcon, alpha);
+
+        final int actionItemsCount = mActionItemBar.getChildCount();
+        for (int i = 0; i < actionItemsCount; i++) {
+            mActionItemBar.getChildAt(i).setEnabled(enabled);
+        }
+        ViewHelper.setAlpha(mActionItemBar, alpha);
+
+        final Tab tab = Tabs.getInstance().getSelectedTab();
+        if (tab != null) {
+            setButtonEnabled(mBack, enabled && tab.canDoBack());
+            setButtonEnabled(mForward, enabled && tab.canDoForward());
+        }
+    }
+
+    /**
      * Returns whether or not the URL bar is in editing mode (url bar is expanded, hiding the new
      * tab button). Note that selection state is independent of editing mode.
      */
     public boolean isEditing() {
         return mIsEditing;
     }
 
     public void startEditing(String url, PropertyAnimator animator) {
         if (isEditing()) {
             return;
         }
 
         mUrlEditText.setText(url != null ? url : "");
         mIsEditing = true;
 
+        updateChildrenForEditing();
+
         if (mStartEditingListener != null) {
             mStartEditingListener.onStartEditing();
         }
 
         final int entryTranslation = getUrlBarEntryTranslation();
         final int curveTranslation = getUrlBarCurveTranslation();
 
         // This animation doesn't make much sense in a sidebar UI
@@ -1398,16 +1435,18 @@ public class BrowserToolbar extends Geck
 
     private String stopEditing() {
         final String url = mUrlEditText.getText().toString();
         if (!isEditing()) {
             return url;
         }
         mIsEditing = false;
 
+        updateChildrenForEditing();
+
         if (mStopEditingListener != null) {
             mStopEditingListener.onStopEditing();
         }
 
         if (HardwareUtils.isTablet() || Build.VERSION.SDK_INT < 11) {
             hideUrlEditContainer();
 
             if (!HardwareUtils.isTablet()) {
@@ -1562,33 +1601,35 @@ public class BrowserToolbar extends Geck
         if (newInputType != currentInputType) {
             mUrlEditText.setRawInputType(newInputType);
         }
     }
 
     public void setButtonEnabled(ImageButton button, boolean enabled) {
         final Drawable drawable = button.getDrawable();
         if (drawable != null) {
+            // This alpha value has to be in sync with the one used
+            // in updateChildrenForEditing().
             drawable.setAlpha(enabled ? 255 : 61);
         }
 
         button.setEnabled(enabled);
     }
 
     public void updateBackButton(boolean enabled) {
         setButtonEnabled(mBack, enabled);
     }
 
     public void updateForwardButton(final boolean enabled) {
         if (mForward.isEnabled() == enabled)
             return;
 
         // Save the state on the forward button so that we can skip animations
         // when there's nothing to change
-        mForward.setEnabled(enabled);
+        setButtonEnabled(mForward, enabled);
 
         if (mForward.getVisibility() != View.VISIBLE)
             return;
 
         // We want the forward button to show immediately when switching tabs
         mForwardAnim = new PropertyAnimator(mSwitchingTabs ? 10 : FORWARD_ANIMATION_DURATION);
         final int width = mForward.getWidth() / 2;