Bug 865228 - Only animate tabs counter once tabs button is on screen (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Wed, 01 May 2013 17:32:01 +0100
changeset 130493 885e0fb3afca0139d326b683f4c9d589bc006ec9
parent 130492 3f18ab3e32f27805cf10faffb80137d0cfeaaf2a
child 130494 913ae89e272b3629bb20538e1a8301738093bd80
push id1579
push userphilringnalda@gmail.com
push dateSat, 04 May 2013 04:38:04 +0000
treeherderfx-team@a56432a42a41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs865228
milestone23.0a1
Bug 865228 - Only animate tabs counter once tabs button is on screen (r=mfinkle)
mobile/android/base/BrowserApp.java
mobile/android/base/BrowserToolbar.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -659,32 +659,35 @@ abstract public class BrowserApp extends
     public void refreshChrome() {
         invalidateOptionsMenu();
         updateSideBarState();
         mTabsPanel.refresh();
     }
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-
         String url = null;
 
         // Don't update the url in the toolbar if the activity was cancelled.
         if (resultCode == Activity.RESULT_OK && data != null) {
             // Don't update the url if the activity was launched to pick a site.
             String targetKey = data.getStringExtra(AwesomeBar.TARGET_KEY);
             if (!AwesomeBar.Target.PICK_SITE.toString().equals(targetKey)) {
                 // Update the toolbar with the url that was just entered.
                 url = data.getStringExtra(AwesomeBar.URL_KEY);
             }
         }
 
         // We always need to call fromAwesomeBarSearch to perform the toolbar animation.
         mBrowserToolbar.fromAwesomeBarSearch(url);
+
+        // Trigger any tab-related events after we start restoring
+        // the toolbar state above to make ensure animations happen
+        // on the correct order.
+        super.onActivityResult(requestCode, resultCode, data);
     }
 
     public View getActionBarLayout() {
         RelativeLayout actionBar = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.browser_toolbar, null);
         actionBar.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
                                                                   (int) getResources().getDimension(R.dimen.browser_toolbar_height)));
         return actionBar;
     }
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -645,16 +645,20 @@ public class BrowserToolbar implements T
                                        1);
                 buttonsAnimator.attach(mStop,
                                        PropertyAnimator.Property.ALPHA,
                                        1);
 
                 buttonsAnimator.start();
 
                 mAnimatingEntry = false;
+
+                // Trigger animation to update the tabs counter once the
+                // tabs button is back on screen.
+                updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
             }
         });
 
         mAnimatingEntry = true;
 
         mHandler.postDelayed(new Runnable() {
             @Override
             public void run() {
@@ -770,24 +774,38 @@ public class BrowserToolbar implements T
 
     public void updateTabCountAndAnimate(int count) {
         // Don't animate if the toolbar is hidden.
         if (!isVisible()) {
             updateTabCount(count);
             return;
         }
 
-        mTabsCounter.setCount(count);
+        // If toolbar is selected, 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.
+        // See fromAwesomeBarSearch()
+        if (!mLayout.isSelected()) {
+            mTabsCounter.setCount(count);
 
-        mTabs.setContentDescription((count > 1) ?
-                                    mActivity.getString(R.string.num_tabs, count) :
-                                    mActivity.getString(R.string.one_tab));
+            mTabs.setContentDescription((count > 1) ?
+                                        mActivity.getString(R.string.num_tabs, count) :
+                                        mActivity.getString(R.string.one_tab));
+        }
     }
 
     public void updateTabCount(int count) {
+        // If toolbar is selected, 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.
+        // See fromAwesomeBarSearch()
+        if (mLayout.isSelected()) {
+            return;
+        }
+
         mTabsCounter.setCurrentText(String.valueOf(count));
         mTabs.setContentDescription((count > 1) ?
                                     mActivity.getString(R.string.num_tabs, count) :
                                     mActivity.getString(R.string.one_tab));
         updateTabs(mActivity.areTabsShown());
     }
 
     public void prepareTabsAnimation(PropertyAnimator animator, int width) {