Bug 961749 - Disable tab count animation in editing mode. r=lucasr, a=lsblakk
authorBrian Nicholson <bnicholson@mozilla.com>
Tue, 28 Jan 2014 15:19:42 -0800
changeset 175193 f2569a4bbaf0843b2cc8cd4b1daa31d9efb10127
parent 175192 14d893faf45b523638b426f9bae76e4d16931a14
child 175194 466a0f1b98cdca02a8f2fe00383ec32f29c33961
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr, lsblakk
bugs961749
milestone28.0a2
Bug 961749 - Disable tab count animation in editing mode. r=lucasr, a=lsblakk
mobile/android/base/toolbar/BrowserToolbar.java
mobile/android/base/toolbar/TabCounter.java
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -734,17 +734,17 @@ public class BrowserToolbar extends Geck
         // and the tabs button is translated offscreen. Don't trigger tabs counter
         // updates until the tabs button is back on screen.
         // See stopEditing()
         if (isEditing() && !HardwareUtils.isTablet()) {
             return;
         }
 
         // Set TabCounter based on visibility
-        if (isVisible() && ViewHelper.getAlpha(mTabsCounter) != 0) {
+        if (isVisible() && ViewHelper.getAlpha(mTabsCounter) != 0 && !isEditing()) {
             mTabsCounter.setCountWithAnimation(count);
         } else {
             mTabsCounter.setCount(count);
         }
 
         // Update A11y information
         mTabs.setContentDescription((count > 1) ?
                                     mActivity.getString(R.string.num_tabs, count) :
@@ -1110,16 +1110,20 @@ public class BrowserToolbar extends Geck
 
         // 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);
 
+        if (!enabled) {
+            mTabsCounter.onEnterEditingMode();
+        }
+
         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);
--- a/mobile/android/base/toolbar/TabCounter.java
+++ b/mobile/android/base/toolbar/TabCounter.java
@@ -97,16 +97,26 @@ public class TabCounter extends GeckoTex
         mCount = count;
     }
 
     public void setCount(int count) {
         setCurrentText(String.valueOf(count));
         mCount = count;
     }
 
+    // Alpha animations in editing mode cause action bar corruption on the
+    // Nexus 7 (bug 961749). As a workaround, skip these animations in editing
+    // mode.
+    void onEnterEditingMode() {
+        final int childCount = getChildCount();
+        for (int i = 0; i < childCount; i++) {
+            getChildAt(i).clearAnimation();
+        }
+    }
+
     private AnimationSet createAnimation(float startAngle, float endAngle,
                                          FadeMode fadeMode,
                                          float zEnd, boolean reverse) {
         final Context context = getContext();
         AnimationSet set = new AnimationSet(context, null);
         set.addAnimation(new Rotate3DAnimation(startAngle, endAngle, CENTER_X, CENTER_Y, zEnd, reverse));
         set.addAnimation(fadeMode == FadeMode.FADE_IN ? new AlphaAnimation(0.0f, 1.0f) :
                                                         new AlphaAnimation(1.0f, 0.0f));