Show tab count in snapshot view

Browser was showing 0 tab count when view was switched
to snapshot (saved pages). The snapshot bar code was missing
the logic to show the tab count.

Change-Id: Ifc293c2612e14adb6d79e9cd74906127921f22fd
diff --git a/src/com/android/browser/SnapshotBar.java b/src/com/android/browser/SnapshotBar.java
index 42f9fba..9446b29 100644
--- a/src/com/android/browser/SnapshotBar.java
+++ b/src/com/android/browser/SnapshotBar.java
@@ -21,6 +21,7 @@
 import android.os.Message;
 import android.text.TextUtils;
 import android.util.AttributeSet;
+import android.util.TypedValue;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -34,6 +35,9 @@
 import com.android.browser.R;
 import com.android.browser.UI.ComboViews;
 
+import org.codeaurora.swe.util.Activator;
+import org.codeaurora.swe.util.Observable;
+
 import java.text.DateFormat;
 import java.util.Date;
 
@@ -48,11 +52,14 @@
     private View mBookmarks;
     private TitleBar mTitleBar;
     private View mTabSwitcher;
+    private TextView mTabText;
     private View mOverflowMenu;
     private View mToggleContainer;
     private boolean mIsAnimating;
     private ViewPropertyAnimator mTitleAnimator, mDateAnimator;
     private float mAnimRadius = 20f;
+    private float mTabSwitcherInitialTextSize = 0;
+    private float mTabSwitcherCompressedTextSize = 0;
 
     public SnapshotBar(Context context) {
         super(context);
@@ -69,6 +76,20 @@
     public void setTitleBar(TitleBar titleBar) {
         mTitleBar = titleBar;
         setFavicon(null);
+        Activator.activate(
+                new Observable.Observer() {
+                    @Override
+                    public void onChange(Object... params) {
+                        if ((Integer) params[0] > 9) {
+                            mTabText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabSwitcherCompressedTextSize);
+                        } else {
+                            mTabText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabSwitcherInitialTextSize);
+                        }
+
+                        mTabText.setText(Integer.toString((Integer) params[0]));
+                    }
+                },
+                mTitleBar.getUiController().getTabControl().getTabCountObservable());
     }
 
     private Handler mHandler = new Handler() {
@@ -90,6 +111,7 @@
         mTitle = (TextView) findViewById(R.id.title);
         mBookmarks = findViewById(R.id.all_btn);
         mTabSwitcher = findViewById(R.id.tab_switcher);
+        mTabText = (TextView) findViewById(R.id.tab_switcher_text);
         mOverflowMenu = findViewById(R.id.more);
         mToggleContainer = findViewById(R.id.toggle_container);
 
@@ -109,6 +131,11 @@
             mToggleContainer.setOnClickListener(this);
             resetAnimation();
         }
+
+        if (mTabSwitcherInitialTextSize == 0) {
+            mTabSwitcherInitialTextSize = mTabText.getTextSize();
+            mTabSwitcherCompressedTextSize = (float) (mTabSwitcherInitialTextSize / 1.2);
+        }
     }
 
     @Override