Bug 702287: Caret should be shown throughtout the animation [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Mon, 14 Nov 2011 15:30:34 -0800
changeset 81825 6b776bed41d7f1fea5fe28c46f2473637147de83
parent 81824 704f79a17282301d61a41ba0453f4d678a869e46
child 81826 bbde0864db917990ce28b70988109d311a7b66e6
push idunknown
push userunknown
push dateunknown
reviewersmfinkle
bugs702287
milestone11.0a1
Bug 702287: Caret should be shown throughtout the animation [r=mfinkle]
embedding/android/BrowserToolbar.java
--- a/embedding/android/BrowserToolbar.java
+++ b/embedding/android/BrowserToolbar.java
@@ -65,17 +65,19 @@ public class BrowserToolbar extends Line
     final private ImageButton mTabs;
     final public ImageButton mFavicon;
     final private AnimationDrawable mProgressSpinner;
     final private TextSwitcher mTabsCount;
 
     final private Context mContext;
     final private Handler mHandler;
     final private int mColor;
+    final private int mCounterColor;
 
+    final private int mDuration;
     final private TranslateAnimation mSlideUpIn;
     final private TranslateAnimation mSlideUpOut;
     final private TranslateAnimation mSlideDownIn;
     final private TranslateAnimation mSlideDownOut;
 
     private int mCount;
 
     public BrowserToolbar(Context context, AttributeSet attrs) {
@@ -107,43 +109,46 @@ public class BrowserToolbar extends Line
                 if (Tabs.getInstance().getCount() > 1)
                     showTabs();
                 else
                     addTab();
             }
         });
         mTabs.setImageLevel(1);
 
+        mCounterColor = 0x99ffffff;
+
         mTabsCount = (TextSwitcher) findViewById(R.id.tabs_count);
         mTabsCount.setFactory(new ViewFactory() {
             public View makeView() {
                 TextView text = new TextView(mContext);
                 text.setGravity(Gravity.CENTER);
                 text.setTextSize(16);
-                text.setTextColor(0x99ffffff);
+                text.setTextColor(mCounterColor);
                 text.setTypeface(text.getTypeface(), Typeface.BOLD);
                 return text;
             } 
         });
         mCount = 0;
         mTabsCount.setText("0");
 
         mFavicon = (ImageButton) findViewById(R.id.favicon);
         mProgressSpinner = (AnimationDrawable) context.getResources().getDrawable(R.drawable.progress_spinner);
 
         mHandler = new Handler();
         mSlideUpIn = new TranslateAnimation(0, 0, 30, 0);
         mSlideUpOut = new TranslateAnimation(0, 0, 0, -30);
         mSlideDownIn = new TranslateAnimation(0, 0, -30, 0);
         mSlideDownOut = new TranslateAnimation(0, 0, 0, 30);
 
-        mSlideUpIn.setDuration(750);
-        mSlideUpOut.setDuration(750);
-        mSlideDownIn.setDuration(750);
-        mSlideDownOut.setDuration(750);
+        mDuration = 750;
+        mSlideUpIn.setDuration(mDuration);
+        mSlideUpOut.setDuration(mDuration);
+        mSlideDownIn.setDuration(mDuration);
+        mSlideDownOut.setDuration(mDuration);
     }
 
     private void onAwesomeBarSearch() {
         GeckoApp.mAppContext.onEditRequested();
     }
 
     private void addTab() {
         GeckoApp.mAppContext.addTab();
@@ -161,30 +166,42 @@ public class BrowserToolbar extends Line
         if (mCount > count) {
             mTabsCount.setInAnimation(mSlideDownIn);
             mTabsCount.setOutAnimation(mSlideDownOut);
         } else if (mCount < count) {
             mTabsCount.setInAnimation(mSlideUpIn);
             mTabsCount.setOutAnimation(mSlideUpOut);
         }
 
-        mTabs.setImageLevel(0);
+        if (count > 1)
+            mTabs.setImageLevel(count);
+        else
+            mTabs.setImageLevel(0);
+
         mTabsCount.setVisibility(View.VISIBLE);
         mTabsCount.setText(String.valueOf(count));
         mCount = count;
 
         mHandler.postDelayed(new Runnable() {
             public void run() {
-                int count = Tabs.getInstance().getCount();
-                mTabs.setImageLevel(count);
+                ((TextView) mTabsCount.getCurrentView()).setTextColor(mColor);
+            }
+        }, mDuration);
 
-                if (count == 1)
+        mHandler.postDelayed(new Runnable() {
+            public void run() {
+                if (Tabs.getInstance().getCount() == 1) {
+                    mTabs.setImageLevel(1);
                     mTabsCount.setVisibility(View.GONE);
+                    ((TextView) mTabsCount.getCurrentView()).setTextColor(mCounterColor);
+                } else {
+                    ((TextView) mTabsCount.getCurrentView()).setTextColor(mCounterColor);
+                }
             }
-        }, 1500);
+        }, 2 * mDuration);
     }
 
     public void setProgressVisibility(boolean visible) {
         if (visible) {
             mFavicon.setImageDrawable(mProgressSpinner);
             mProgressSpinner.start();
         } else {
             mProgressSpinner.stop();