Make the minitabs stretch to fit the available space.

Change-Id: Ifd2b774b40e2831f4f2326c0fe9ebbb3e7d714d0
diff --git a/res/drawable-finger/tab_left_arrow.png b/res/drawable-finger/tab_left_arrow.png
index e35d58d..2008b80 100644
--- a/res/drawable-finger/tab_left_arrow.png
+++ b/res/drawable-finger/tab_left_arrow.png
Binary files differ
diff --git a/res/drawable-finger/tab_right_arrow.png b/res/drawable-finger/tab_right_arrow.png
index 8acbba0..50f172b 100644
--- a/res/drawable-finger/tab_right_arrow.png
+++ b/res/drawable-finger/tab_right_arrow.png
Binary files differ
diff --git a/res/layout-finger/all_tab_indicator.xml b/res/layout-finger/all_tab_indicator.xml
index fd5c35f..ca9ee34 100644
--- a/res/layout-finger/all_tab_indicator.xml
+++ b/res/layout-finger/all_tab_indicator.xml
@@ -15,8 +15,10 @@
 -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="80dip"
+    android:layout_width="wrap_content"
     android:layout_height="40dip"
+    android:layout_weight="1"
+    android:minWidth="72dip"
     android:background="@+drawable/tab_indicator_bg">
 
     <TextView
diff --git a/res/layout-finger/tab_indicator.xml b/res/layout-finger/tab_indicator.xml
index 119f86e..a9db229 100644
--- a/res/layout-finger/tab_indicator.xml
+++ b/res/layout-finger/tab_indicator.xml
@@ -15,8 +15,10 @@
 -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="80dip"
+    android:layout_width="wrap_content"
     android:layout_height="40dip"
+    android:layout_weight="1"
+    android:minWidth="72dip"
     android:background="@+drawable/tab_indicator_bg">
 
     <ImageView android:id="@+id/tab_icon"
diff --git a/res/layout-finger/tab_left_arrow.xml b/res/layout-finger/tab_left_arrow.xml
index 58c8b92..0ed2e57 100644
--- a/res/layout-finger/tab_left_arrow.xml
+++ b/res/layout-finger/tab_left_arrow.xml
@@ -16,7 +16,7 @@
 
 <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/arrow"
-    android:layout_width="40dip"
+    android:layout_width="32dip"
     android:layout_height="37dip"
     android:layout_alignParentLeft="true"
     android:layout_alignParentTop="true"
diff --git a/res/layout-finger/tab_right_arrow.xml b/res/layout-finger/tab_right_arrow.xml
index febc7f5..de69d8e 100644
--- a/res/layout-finger/tab_right_arrow.xml
+++ b/res/layout-finger/tab_right_arrow.xml
@@ -16,7 +16,7 @@
 
 <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/arrow"
-    android:layout_width="40dip"
+    android:layout_width="32dip"
     android:layout_height="37dip"
     android:layout_alignParentRight="true"
     android:layout_alignParentTop="true"
diff --git a/src/com/android/contacts/BaseContactCardActivity.java b/src/com/android/contacts/BaseContactCardActivity.java
index f123c89..2aac1a2 100644
--- a/src/com/android/contacts/BaseContactCardActivity.java
+++ b/src/com/android/contacts/BaseContactCardActivity.java
@@ -205,7 +205,7 @@
             // TODO: ensure inflation on background task so we don't block UI thread here
             final ContactsSource source = sources.getInflatedSource(accountType,
                     ContactsSource.LEVEL_SUMMARY);
-            addTab(rawContactId, createTabIndicatorView(mTabWidget, source));
+            addTab(rawContactId, createTabIndicatorView(mTabWidget.getTabParent(), source));
         }
 
         selectInitialTab();
@@ -213,18 +213,6 @@
         mTabWidget.postInvalidate();
     }
 
-
-    /**
-     * Add a tab to be displayed in the {@link ScrollingTabWidget}.
-     *
-     * @param contactId The contact id associated with the tab.
-     * @param label A label to display in the tab indicator.
-     * @param icon An icon to display in the tab indicator.
-     */
-    protected void addTab(long contactId, String label, Drawable icon) {
-        addTab(contactId, createTabIndicatorView(mTabWidget, label, icon));
-    }
-
     /**
      * Add a tab to be displayed in the {@link ScrollingTabWidget}.
      *
diff --git a/src/com/android/contacts/ScrollingTabWidget.java b/src/com/android/contacts/ScrollingTabWidget.java
index ddd101b..466071a 100644
--- a/src/com/android/contacts/ScrollingTabWidget.java
+++ b/src/com/android/contacts/ScrollingTabWidget.java
@@ -152,6 +152,14 @@
         return mTabsView.getChildCount();
     }
 
+    /**
+     * Returns the {@link ViewGroup} that actually contains the tabs. This is where the tab
+     * views should be attached to when being inflated.
+     */
+    public ViewGroup getTabParent() {
+        return mTabsView;
+    }
+
     public void removeAllTabs() {
         mTabsView.removeAllViews();
     }
diff --git a/src/com/android/contacts/TabStripView.java b/src/com/android/contacts/TabStripView.java
index 70878ea..ae80be0 100644
--- a/src/com/android/contacts/TabStripView.java
+++ b/src/com/android/contacts/TabStripView.java
@@ -25,6 +25,7 @@
 import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewParent;
 import android.widget.HorizontalScrollView;
 import android.widget.LinearLayout;
 
@@ -57,6 +58,16 @@
     }
 
     @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        ViewParent parent = getParent();
+        if (parent instanceof HorizontalScrollView) {
+            setMinimumWidth(((HorizontalScrollView) getParent()).getMeasuredWidth());
+        }
+
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+    }
+
+    @Override
     public void childDrawableStateChanged(View child) {
         if (child == getChildAt(mSelectedTabIndex)) {
             // To make sure that the bottom strip is redrawn
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index da49188..cd9802c 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -265,7 +265,8 @@
     }
 
     private void addAllTab() {
-        View allTabIndicator = mInflater.inflate(R.layout.all_tab_indicator, mTabWidget, false);
+        View allTabIndicator = mInflater.inflate(R.layout.all_tab_indicator,
+                mTabWidget.getTabParent(), false);
         allTabIndicator.getBackground().setDither(true);
         addTab(ALL_CONTACTS_ID, allTabIndicator);
     }
diff --git a/src/com/android/contacts/ui/EditContactActivity.java b/src/com/android/contacts/ui/EditContactActivity.java
index 03ef79a..0946e39 100644
--- a/src/com/android/contacts/ui/EditContactActivity.java
+++ b/src/com/android/contacts/ui/EditContactActivity.java
@@ -335,7 +335,8 @@
                 selectedTab = mTabWidget.getTabCount();
             }
 
-            final View tabView = BaseContactCardActivity.createTabIndicatorView(mTabWidget, source);
+            final View tabView = BaseContactCardActivity.createTabIndicatorView(
+                    mTabWidget.getTabParent(), source);
             mTabWidget.addTab(tabView);
         }
         if (mState.size() > 0) {