fix tab title

    http://b/issue?id=3384383
    changed favicon background
    cleaned up spacing
    added fade to tab out animation
    increase size of tab for chevron

Change-Id: I749c108691b73738839028b9cac89add86aa8b00
diff --git a/res/layout/tab_title.xml b/res/layout/tab_title.xml
index 62ef2f3..e2c6d0a 100644
--- a/res/layout/tab_title.xml
+++ b/res/layout/tab_title.xml
@@ -18,17 +18,15 @@
     android:orientation="horizontal">
     <ImageView
         android:id="@+id/chevron"
-        android:layout_width="16dip"
-        android:layout_height="16dip"
-        android:layout_marginRight="4dip"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
         android:gravity="center_vertical"
         android:src="@drawable/ic_chevron"
         android:visibility="gone" />
     <ImageView
         android:id="@+id/incognito"
-        android:layout_width="32dip"
-        android:layout_height="32dip"
-        android:layout_marginRight="8dip"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
         android:gravity="center_vertical"
         android:src="@drawable/ic_incognito_holo_dark"
         android:visibility="gone" />
@@ -36,19 +34,20 @@
         android:id="@+id/favicon"
         android:layout_width="20dip"
         android:layout_height="20dip"
-        android:layout_marginRight="16dip" />
+        android:layout_marginLeft="8dip"
+        android:layout_marginRight="8dip" />
     <ImageView
         android:id="@+id/lock"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginRight="16dip"
         android:visibility="gone" />
     <TextView
         android:id="@+id/title"
         android:layout_height="match_parent"
         android:layout_width="0dip"
         android:layout_weight="1.0"
-        android:layout_marginRight="16dip"
+        android:paddingLeft="8dip"
+        android:paddingRight="8dip"
         android:textAppearance="?android:attr/textAppearanceSmall"
         android:textColor="@color/white"
         android:gravity="center_vertical"
@@ -60,6 +59,5 @@
         android:background="?android:attr/selectableItemBackground"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginRight="16dip"
         android:src="@drawable/ic_tab_close" />
 </merge>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 84e5348..68b58f7 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -34,4 +34,5 @@
     <color name="bookmarkWidgetFaviconBackground">#23ffffff</color>
     <color name="bookmarkListFaviconBackground">#23ffffff</color>
     <color name="urlTextColor">#0E774A</color>
+    <color name="tabFaviconBackground">#FF555555</color>
 </resources>
diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml
index d738288..b1e1d92 100644
--- a/res/values/dimensions.xml
+++ b/res/values/dimensions.xml
@@ -43,4 +43,5 @@
     <dimen name="tab_first_padding_left">12dp</dimen>
     <dimen name="list_favicon_padding">5dip</dimen>
     <dimen name="list_favicon_corner_radius">3dip</dimen>
+    <dimen name="tab_favicon_corner_radius">2dip</dimen>
 </resources>
diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java
index 301165a..790d162 100644
--- a/src/com/android/browser/TabBar.java
+++ b/src/com/android/browser/TabBar.java
@@ -28,7 +28,6 @@
 import android.graphics.Bitmap;
 import android.graphics.BitmapShader;
 import android.graphics.Canvas;
-import android.graphics.Color;
 import android.graphics.Matrix;
 import android.graphics.Paint;
 import android.graphics.Path;
@@ -331,7 +330,7 @@
             mTab = tab;
             setGravity(Gravity.CENTER_VERTICAL);
             setOrientation(LinearLayout.HORIZONTAL);
-            setPadding(mTabPadding, 0, 0, 0);
+            setPadding(mTabOverlap, 0, mTabSliceWidth, 0);
             LayoutInflater inflater = LayoutInflater.from(getContext());
             mTabContent = inflater.inflate(R.layout.tab_title, this, true);
             mTitle = (TextView) mTabContent.findViewById(R.id.title);
@@ -350,6 +349,14 @@
         void showIndicator(boolean show) {
             if (mSelected) {
                 mIndicator.setVisibility(show ? View.VISIBLE : View.GONE);
+                LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams();
+                if (show) {
+                    lp.width = mTabWidthSelected + mIndicator.getWidth();
+                } else {
+                    lp.width = mTabWidthSelected;
+                }
+                lp.height =  LayoutParams.MATCH_PARENT;
+                setLayoutParams(lp);
             } else {
                 mIndicator.setVisibility(View.GONE);
             }
@@ -489,26 +496,35 @@
 
     }
 
+    static Drawable createFaviconBackground(Context context) {
+        PaintDrawable faviconBackground = new PaintDrawable();
+        Resources res = context.getResources();
+        faviconBackground.getPaint().setColor(context.getResources()
+                .getColor(R.color.tabFaviconBackground));
+        faviconBackground.setCornerRadius(
+                res.getDimension(R.dimen.tab_favicon_corner_radius));
+        return faviconBackground;
+    }
+
     private Drawable renderFavicon(Bitmap icon) {
-        Drawable[] array = new Drawable[3];
-        array[0] = new PaintDrawable(Color.BLACK);
-        array[1] = new PaintDrawable(Color.WHITE);
+        Drawable[] array = new Drawable[2];
+        array[0] = createFaviconBackground(getContext());
         if (icon == null) {
-            array[2] = mGenericFavicon;
+            array[1] = mGenericFavicon;
         } else {
-            array[2] = new BitmapDrawable(icon);
+            array[1] = new BitmapDrawable(icon);
         }
         LayerDrawable d = new LayerDrawable(array);
-        d.setLayerInset(1, 1, 1, 1, 1);
-        d.setLayerInset(2, 2, 2, 2, 2);
+        d.setLayerInset(1, 2, 2, 2, 2);
         return d;
     }
 
     private void animateTabOut(final Tab tab, final TabView tv) {
         ObjectAnimator scalex = ObjectAnimator.ofFloat(tv, "scaleX", 1.0f, 0.0f);
         ObjectAnimator scaley = ObjectAnimator.ofFloat(tv, "scaleY", 1.0f, 0.0f);
+        ObjectAnimator alpha = ObjectAnimator.ofFloat(tv, "alpha", 1.0f, 0.0f);
         AnimatorSet animator = new AnimatorSet();
-        animator.playTogether(scalex, scaley);
+        animator.playTogether(scalex, scaley, alpha);
         animator.setDuration(150);
         animator.addListener(new AnimatorListener() {
 
@@ -535,7 +551,7 @@
     }
 
     private void animateTabIn(final Tab tab, final TabView tv) {
-        ObjectAnimator scalex = ObjectAnimator.ofFloat(tv, "scaleX", 0f, 1.0f);
+        ObjectAnimator scalex = ObjectAnimator.ofFloat(tv, "scaleX", 0.0f, 1.0f);
         scalex.setDuration(150);
         scalex.addListener(new AnimatorListener() {