Merge "Change tab carousel tab size according to device size"
diff --git a/res/layout-sw580dp/contact_detail_updates_fragment.xml b/res/layout-sw580dp/contact_detail_updates_fragment.xml
index 8677737..ce3f661 100644
--- a/res/layout-sw580dp/contact_detail_updates_fragment.xml
+++ b/res/layout-sw580dp/contact_detail_updates_fragment.xml
@@ -36,7 +36,7 @@
                 class="com.android.contacts.widget.ProportionalLayout"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                ex:ratio="0.5"
+                ex:ratio="0.66"
                 ex:direction="widthToHeight">
 
                 <!-- Put a dummy view here because the ProportionalLayout requires one -->
diff --git a/res/layout-sw580dp/detail_header_contact_with_updates.xml b/res/layout-sw580dp/detail_header_contact_with_updates.xml
index fd45c3b..6b6f02b 100644
--- a/res/layout-sw580dp/detail_header_contact_with_updates.xml
+++ b/res/layout-sw580dp/detail_header_contact_with_updates.xml
@@ -26,14 +26,14 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
-    android:layout_marginTop="20dip">
+    android:layout_marginTop="30dip">
 
     <!-- Add a first item that gives us enough space to show the carousel -->
     <view
         class="com.android.contacts.widget.ProportionalLayout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        ex:ratio="0.5"
+        ex:ratio="0.66"
         ex:direction="widthToHeight">
 
         <!-- Put a dummy view here because the ProportionalLayout requires one -->
@@ -65,4 +65,4 @@
         android:contentDescription="@string/description_star"
         style="?android:attr/starStyle" />
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout-sw580dp/detail_header_contact_without_updates.xml b/res/layout-sw580dp/detail_header_contact_without_updates.xml
index 8379619..995e8f7 100644
--- a/res/layout-sw580dp/detail_header_contact_without_updates.xml
+++ b/res/layout-sw580dp/detail_header_contact_without_updates.xml
@@ -20,15 +20,42 @@
 -->
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">
 
-    <ImageView
-        android:id="@+id/photo"
-        android:scaleType="centerCrop"
-        android:layout_width="@dimen/detail_contact_photo_size"
-        android:layout_height="@dimen/detail_contact_photo_size" />
+    <!-- Ensure that the contact photo for a contact WITHOUT social updates is the same width and
+    height as a contact WITH social updates (where the photo is 2/3 of the screen width). -->
+    <view
+        class="com.android.contacts.widget.ProportionalLayout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        ex:ratio="0.66"
+        ex:direction="widthToHeight">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="horizontal">
+
+            <ImageView
+                android:id="@+id/photo"
+                android:scaleType="centerCrop"
+                android:layout_width="0dip"
+                android:layout_height="match_parent"
+                android:layout_weight="2" />
+
+            <!-- Empty view to fill the rest of the LinearLayout, so that a weight on its sibling
+            ImageView will work.-->
+            <View
+                android:layout_width="0dip"
+                android:layout_weight="1"
+                android:layout_height="match_parent" />
+
+        </LinearLayout>
+
+    </view>
 
     <TextView
         android:id="@+id/name"
@@ -52,4 +79,4 @@
         android:contentDescription="@string/description_star"
         style="?android:attr/starStyle" />
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout-w470dp/contact_detail_fragment.xml b/res/layout-w470dp/contact_detail_fragment.xml
index 5a48583..56c9f20 100644
--- a/res/layout-w470dp/contact_detail_fragment.xml
+++ b/res/layout-w470dp/contact_detail_fragment.xml
@@ -86,7 +86,7 @@
         android:layout_height="match_parent"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
-        android:background="@android:color/transparent"
+        android:background="?android:attr/selectableItemBackground"
         android:visibility="gone"/>
 </RelativeLayout>
 
diff --git a/res/layout-w470dp/contact_detail_updates_fragment.xml b/res/layout-w470dp/contact_detail_updates_fragment.xml
index 9b63ccf..0c8380c 100644
--- a/res/layout-w470dp/contact_detail_updates_fragment.xml
+++ b/res/layout-w470dp/contact_detail_updates_fragment.xml
@@ -58,7 +58,7 @@
         android:id="@+id/touch_intercept_overlay"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:background="@android:color/transparent"
+        android:background="?android:attr/selectableItemBackground"
         android:visibility="gone"/>
 
 </FrameLayout>
diff --git a/res/layout/carousel_about_tab.xml b/res/layout/carousel_about_tab.xml
index e902c8e..ad763be 100644
--- a/res/layout/carousel_about_tab.xml
+++ b/res/layout/carousel_about_tab.xml
@@ -36,8 +36,18 @@
         android:layout_height="@dimen/detail_tab_carousel_tab_label_height"
         android:layout_alignParentLeft="true"
         android:layout_alignParentBottom="true"
+        android:background="#7F000000" />
+
+    <View
+        android:id="@+id/alpha_overlay"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:layout_marginBottom="@dimen/detail_tab_carousel_tab_label_height"
         android:background="@android:color/black"
-        android:alpha=".25"/>
+        android:alpha="0"
+        android:visibility="gone"/>
 
     <TextView
         android:id="@+id/label"
@@ -53,16 +63,6 @@
         style="@android:style/Widget.Holo.ActionBar.TabView" />
 
     <View
-        android:id="@+id/alpha_overlay"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentTop="true"
-        android:background="@android:color/black"
-        android:alpha="0"
-        android:visibility="gone"/>
-
-    <View
         android:id="@+id/touch_intercept_overlay"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
diff --git a/res/layout/carousel_updates_tab.xml b/res/layout/carousel_updates_tab.xml
index 689e17b..b41829f 100644
--- a/res/layout/carousel_updates_tab.xml
+++ b/res/layout/carousel_updates_tab.xml
@@ -42,22 +42,7 @@
         android:layout_alignParentLeft="true"
         android:layout_alignParentBottom="true"
         android:layout_above="@id/status_photo"
-        android:background="@android:color/black"
-        android:alpha=".25"/>
-
-    <TextView
-        android:id="@+id/label"
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/detail_tab_carousel_tab_label_height"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentBottom="true"
-        android:layout_above="@id/status_photo"
-        android:paddingLeft="@dimen/detail_tab_carousel_tab_label_indent"
-        android:singleLine="true"
-        android:gravity="left|center_vertical"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:textColor="@color/detail_tab_carousel_tab_label_color"
-        style="@android:style/Widget.Holo.ActionBar.TabView" />
+        android:background="#7F000000" />
 
     <TextView android:id="@+id/status"
         android:layout_width="wrap_content"
@@ -79,10 +64,25 @@
         android:layout_height="match_parent"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
+        android:layout_marginBottom="@dimen/detail_tab_carousel_tab_label_height"
         android:background="@android:color/black"
         android:alpha="0"
         android:visibility="gone"/>
 
+    <TextView
+        android:id="@+id/label"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/detail_tab_carousel_tab_label_height"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentBottom="true"
+        android:layout_above="@id/status_photo"
+        android:paddingLeft="@dimen/detail_tab_carousel_tab_label_indent"
+        android:singleLine="true"
+        android:gravity="left|center_vertical"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:textColor="@color/detail_tab_carousel_tab_label_color"
+        style="@android:style/Widget.Holo.ActionBar.TabView" />
+
     <View
         android:id="@+id/touch_intercept_overlay"
         android:layout_width="match_parent"
diff --git a/res/values-sw580dp/donottranslate_config.xml b/res/values-sw580dp/donottranslate_config.xml
index 3d515eb..57db36b 100644
--- a/res/values-sw580dp/donottranslate_config.xml
+++ b/res/values-sw580dp/donottranslate_config.xml
@@ -21,4 +21,6 @@
     <bool name="config_use_two_panes">true</bool>
     <bool name="show_home_icon">true</bool>
     <bool name="config_show_group_action_in_action_bar">false</bool>
+    <item name="tab_width_screen_width_percentage" type="fraction">66%</item>
+    <item name="tab_height_screen_width_percentage" type="fraction">66%</item>
 </resources>
diff --git a/res/values/donottranslate_config.xml b/res/values/donottranslate_config.xml
index 6a4ea62..0da6485 100644
--- a/res/values/donottranslate_config.xml
+++ b/res/values/donottranslate_config.xml
@@ -112,4 +112,12 @@
       shown. Otherwise it will be part of the content on the group detail page.
     -->
     <bool name="config_show_group_action_in_action_bar">false</bool>
+
+    <!-- Width of a tab in the tab carousel as a percentage of the current screen width on the
+         contact detail page -->
+    <item name="tab_width_screen_width_percentage" type="fraction">75%</item>
+
+    <!-- Height of the tab carousel as a percentage of the current screen width on the
+         contact detail page -->
+    <item name="tab_height_screen_width_percentage" type="fraction">50%</item>
 </resources>
diff --git a/src/com/android/contacts/detail/ContactDetailTabCarousel.java b/src/com/android/contacts/detail/ContactDetailTabCarousel.java
index 4ef4b1c..cc4f0ff 100644
--- a/src/com/android/contacts/detail/ContactDetailTabCarousel.java
+++ b/src/com/android/contacts/detail/ContactDetailTabCarousel.java
@@ -42,7 +42,11 @@
     private static final int TAB_INDEX_UPDATES = 1;
     private static final int TAB_COUNT = 2;
 
-    private static final double TAB_WIDTH_SCREEN_PERCENTAGE = 0.75;
+    /** Tab width as defined as a fraction of the screen width */
+    private float mTabWidthScreenWidthFraction;
+
+    /** Tab height as defined as a fraction of the screen width */
+    private float mTabHeightScreenWidthFraction;
 
     private ImageView mPhotoView;
     private TextView mStatusView;
@@ -82,6 +86,10 @@
         Resources resources = mContext.getResources();
         mTabDisplayLabelHeight = resources.getDimensionPixelSize(
                 R.dimen.detail_tab_carousel_tab_label_height);
+        mTabWidthScreenWidthFraction = resources.getFraction(
+                R.fraction.tab_width_screen_width_percentage, 1, 1);
+        mTabHeightScreenWidthFraction = resources.getFraction(
+                R.fraction.tab_height_screen_width_percentage, 1, 1);
     }
 
     @Override
@@ -115,13 +123,13 @@
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         int screenWidth = MeasureSpec.getSize(widthMeasureSpec);
         // Compute the width of a tab as a fraction of the screen width
-        int tabWidth = (int) (TAB_WIDTH_SCREEN_PERCENTAGE * screenWidth);
+        int tabWidth = (int) (mTabWidthScreenWidthFraction * screenWidth);
 
         // Find the allowed scrolling length by subtracting the current visible screen width
         // from the total length of the tabs.
         mAllowedHorizontalScrollLength = tabWidth * TAB_COUNT - screenWidth;
 
-        int tabHeight = screenWidth / 2;
+        int tabHeight = (int) (screenWidth * mTabHeightScreenWidthFraction);
         // Set the child {@link LinearLayout} to be TAB_COUNT * the computed tab width so that the
         // {@link LinearLayout}'s children (which are the tabs) will evenly split that width.
         if (getChildCount() > 0) {