Merge "Fix tests." into ics-mr1
diff --git a/res/layout-sw580dp-w1000dp/contact_detail_fragment.xml b/res/layout-sw580dp-w1000dp/contact_detail_fragment.xml
index 1623e84..ecf8130 100644
--- a/res/layout-sw580dp-w1000dp/contact_detail_fragment.xml
+++ b/res/layout-sw580dp-w1000dp/contact_detail_fragment.xml
@@ -22,7 +22,8 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@color/background_primary"
-    android:padding="16dip">
+    android:paddingLeft="16dip"
+    android:paddingRight="16dip">
 
     <!-- Placeholder for empty list -->
     <include
@@ -41,11 +42,14 @@
             android:scaleType="centerCrop"
             android:layout_width="@dimen/detail_contact_photo_size"
             android:layout_height="@dimen/detail_contact_photo_size"
+            android:layout_marginTop="@dimen/detail_contact_photo_margin"
             android:layout_marginRight="@dimen/detail_contact_photo_margin"/>
 
         <ListView android:id="@android:id/list"
             android:layout_width="0dip"
             android:layout_height="match_parent"
+            android:paddingTop="16dip"
+            android:clipToPadding="false"
             android:fadingEdge="none"
             android:layout_weight="1"
             android:divider="@null"/>
diff --git a/res/layout-sw580dp-w1000dp/contact_detail_list_item.xml b/res/layout-sw580dp-w1000dp/contact_detail_list_item.xml
index de6cd97..ffde8b0 100644
--- a/res/layout-sw580dp-w1000dp/contact_detail_list_item.xml
+++ b/res/layout-sw580dp-w1000dp/contact_detail_list_item.xml
@@ -90,8 +90,7 @@
             android:layout_height="16dip"
             android:visibility="gone"
             android:layout_gravity="center_vertical"
-            android:background="@drawable/ic_menu_mark" />
-
+            android:background="@drawable/ic_list_default_mime_holo_dark" />
 
         <View
             android:id="@+id/vertical_divider"
diff --git a/res/layout-sw580dp-w1000dp/people_activity.xml b/res/layout-sw580dp-w1000dp/people_activity.xml
index 29aa150..9d066df 100644
--- a/res/layout-sw580dp-w1000dp/people_activity.xml
+++ b/res/layout-sw580dp-w1000dp/people_activity.xml
@@ -129,7 +129,6 @@
                         class="com.android.contacts.list.ContactTileListFragment"
                         android:layout_height="match_parent"
                         android:layout_width="match_parent"
-                        android:layout_marginTop="32dip"
                         android:layout_marginRight="32dip"
                         android:layout_marginLeft="32dip"/>
 
diff --git a/res/layout-sw580dp/people_activity.xml b/res/layout-sw580dp/people_activity.xml
index fecb848..c32893e 100644
--- a/res/layout-sw580dp/people_activity.xml
+++ b/res/layout-sw580dp/people_activity.xml
@@ -117,7 +117,7 @@
                 <FrameLayout
                     android:layout_width="0dip"
                     android:layout_height="match_parent"
-                    android:layout_weight="1"
+                    android:layout_weight="10"
                     android:background="@drawable/panel_favorites_holo_light">
 
                     <fragment
@@ -125,9 +125,8 @@
                         class="com.android.contacts.list.ContactTileListFragment"
                         android:layout_height="match_parent"
                         android:layout_width="match_parent"
-                        android:layout_marginTop="32dip"
-                        android:layout_marginRight="32dip"
-                        android:layout_marginLeft="32dip"/>
+                        android:layout_marginRight="16dip"
+                        android:layout_marginLeft="16dip"/>
 
                 </FrameLayout>
 
@@ -137,8 +136,8 @@
                     class="com.android.contacts.list.ContactTileListFragment"
                     android:layout_width="0dip"
                     android:layout_height="match_parent"
-                    android:layout_weight="1"
-                    android:layout_marginTop="32dip"
+                    android:layout_weight="8"
+                    android:layout_marginTop="16dip"
                     android:layout_marginRight="16dip"/>
 
             </LinearLayout>
diff --git a/res/layout/contact_tile_list.xml b/res/layout/contact_tile_list.xml
index b1469f3..35c04c1 100644
--- a/res/layout/contact_tile_list.xml
+++ b/res/layout/contact_tile_list.xml
@@ -24,6 +24,8 @@
         android:id="@+id/contact_tile_list"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:paddingTop="@dimen/contact_tile_list_padding_top"
+        android:clipToPadding="false"
         android:fadingEdge="none"
         android:divider="@null" />
 
diff --git a/res/values-sw580dp-w1000dp/dimens.xml b/res/values-sw580dp-w1000dp/dimens.xml
index 334cc34..940e456 100644
--- a/res/values-sw580dp-w1000dp/dimens.xml
+++ b/res/values-sw580dp-w1000dp/dimens.xml
@@ -18,4 +18,5 @@
     <dimen name="group_detail_side_margin">32dip</dimen>
     <dimen name="detail_contact_photo_margin">16dip</dimen>
     <dimen name="contact_detail_list_top_padding">32dip</dimen>
+    <dimen name="contact_tile_list_padding_top">32dip</dimen>
 </resources>
diff --git a/res/values-sw580dp/dimens.xml b/res/values-sw580dp/dimens.xml
index 77315fc..8621afd 100644
--- a/res/values-sw580dp/dimens.xml
+++ b/res/values-sw580dp/dimens.xml
@@ -29,6 +29,7 @@
     <dimen name="detail_update_section_item_horizontal_padding">8dip</dimen>
     <dimen name="detail_update_section_item_vertical_padding">16dip</dimen>
     <dimen name="search_view_width">400dip</dimen>
+    <dimen name="contact_tile_list_padding_top">16dip</dimen>
     <!-- Center vertically -->
     <dimen name="quick_contact_top_position">-1px</dimen>
     <!-- Contact list (vertical scroll bar comes left) -->
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 12ae918..a5843c6 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -110,7 +110,6 @@
     <!-- Font size used for the social status in the widget -->
     <dimen name="widget_text_size_snippet">13sp</dimen>
 
-
     <!-- Size of the shortcut icon. 0dip means: use the system default -->
     <dimen name="shortcut_icon_size">0dip</dimen>
 
@@ -175,6 +174,9 @@
     -->
     <dimen name="contact_tile_shadowbox_height">48sp</dimen>
 
+    <!-- Top padding of the ListView in the contact tile list -->
+    <dimen name="contact_tile_list_padding_top">0dip</dimen>
+
     <!-- Call Log -->
     <dimen name="call_log_call_action_size">32dip</dimen>
     <dimen name="call_log_call_action_width">48dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ae2c680..0824358 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -136,7 +136,7 @@
     <!-- Menu item (in the action bar) that creates a new group [CHAR LIMIT=12] -->
     <string name="menu_new_group_action_bar">New</string>
 
-    <!-- Title of the confirmation dialog for separating contacts into multiple instances [CHAR LIMIT=20] -->
+    <!-- Title of the confirmation dialog for separating contacts into multiple instances [CHAR LIMIT=26] -->
     <string name="splitConfirmation_title">Separate contact?</string>
 
     <!-- Confirmation dialog for separating contacts into multiple instances [CHAR LIMIT=NONE] -->
@@ -163,7 +163,7 @@
     <!-- Toast shown after two contacts have been joined by a user action -->
     <string name="contactsJoinedMessage">Contacts joined</string>
 
-    <!-- Confirmation dialog title after users selects to delete a contact. [CHAR LIMIT=20]-->
+    <!-- Confirmation dialog title after users selects to delete a contact. [CHAR LIMIT=25]-->
     <string name="deleteConfirmation_title">Delete contact?</string>
 
     <!-- Menu item that opens the Options activity for a given contact [CHAR LIMIT=15] -->
@@ -414,7 +414,7 @@
     <!-- Text displayed when the call log is empty -->
     <string name="recentCalls_empty">Call log is empty.</string>
 
-    <!-- Title of the confirmation dialog for clearing the call log. [CHAR LIMIT=20]  -->
+    <!-- Title of the confirmation dialog for clearing the call log. [CHAR LIMIT=37]  -->
     <string name="clearCallLogConfirmation_title">Clear call log?</string>
 
     <!-- Confirmation dialog for clearing the call log. [CHAR LIMIT=NONE]  -->
@@ -823,7 +823,7 @@
     <!-- The failed reason which should not be shown but it may in some buggy condition. [CHAR LIMIT=40] -->
     <string name="fail_reason_unknown">Unknown error.</string>
 
-    <!-- Dialog title shown when a user is asked to select vCard file. [CHAR LIMIT=20] -->
+    <!-- Dialog title shown when a user is asked to select vCard file. [CHAR LIMIT=25] -->
     <string name="select_vcard_title">Choose vCard file</string>
 
     <!-- The title shown when vCard importer is caching files to be imported into local temporary
@@ -888,7 +888,7 @@
     <!-- The percentage, used for expressing the progress of vCard import/export. -->
     <string name="percentage">%s%%</string>
 
-    <!-- Dialog title shown when a user confirms whether he/she export Contact data. [CHAR LIMIT=20] -->
+    <!-- Dialog title shown when a user confirms whether he/she export Contact data. [CHAR LIMIT=32] -->
     <string name="confirm_export_title">Export contacts?</string>
 
     <!-- Dialog message shown when a user confirms whether he/she export Contact data [CHAR LIMIT=NONE] -->
@@ -1018,7 +1018,7 @@
     <!-- The menu item to bulk import or bulk export contacts from SIM card or SD card.  [CHAR LIMIT=30]-->
     <string name="menu_import_export">Import/export</string>
 
-    <!-- Dialog title when selecting the bulk operation to perform from a list. [CHAR LIMIT=25] -->
+    <!-- Dialog title when selecting the bulk operation to perform from a list. [CHAR LIMIT=36] -->
     <string name="dialog_import_export">Import/export contacts</string>
 
     <!-- The menu item to share the currently viewed contact [CHAR LIMIT=30] -->
diff --git a/src/com/android/contacts/detail/ContactDetailViewPagerAdapter.java b/src/com/android/contacts/detail/ContactDetailViewPagerAdapter.java
index e0ed5e9..edcfc39 100644
--- a/src/com/android/contacts/detail/ContactDetailViewPagerAdapter.java
+++ b/src/com/android/contacts/detail/ContactDetailViewPagerAdapter.java
@@ -19,10 +19,11 @@
 import android.support.v4.view.PagerAdapter;
 import android.support.v4.view.ViewPager;
 import android.view.View;
-import android.view.ViewGroup;
 
 /**
- * Adapter for the {@link ViewPager} for the contact detail page for a contact with social updates.
+ * Adapter for the {@link ViewPager} for the contact detail page for a contact in 2 cases:
+ * 1) without social updates, and 2) with social updates. The default initial case is for
+ * the contact with social updates which uses all possible pages.
  */
 public class ContactDetailViewPagerAdapter extends PagerAdapter {
 
@@ -34,6 +35,12 @@
 
     private static final int MAX_FRAGMENT_VIEW_COUNT = 2;
 
+    /**
+     * The initial value for the view count needs to be MAX_FRAGMENT_VIEW_COUNT,
+     * otherwise anything smaller would break screen rotation functionality for a user viewing
+     * a contact with social updates (i.e. the user was viewing the second page, rotates the
+     * device, the view pager requires the second page to exist immediately on launch).
+     */
     private int mFragmentViewCount = MAX_FRAGMENT_VIEW_COUNT;
 
     private View mAboutFragmentView;
@@ -67,12 +74,16 @@
     /** Gets called when the number of items changes. */
     @Override
     public int getItemPosition(Object object) {
+        // Always return a valid index for the about fragment view because it's always shown
+        // whether the contact has social updates or not.
         if (object == mAboutFragmentView) {
             return INDEX_ABOUT_FRAGMENT;
         }
-        if (object == mUpdatesFragmentView) {
+        // Only return a valid index for the updates fragment view if our view count > 1.
+        if (object == mUpdatesFragmentView && mFragmentViewCount > 1) {
             return INDEX_UPDATES_FRAGMENT;
         }
+        // Otherwise the view should have no position.
         return POSITION_NONE;
     }
 
@@ -84,8 +95,10 @@
     public Object instantiateItem(View container, int position) {
         switch (position) {
             case INDEX_ABOUT_FRAGMENT:
+                mAboutFragmentView.setVisibility(View.VISIBLE);
                 return mAboutFragmentView;
             case INDEX_UPDATES_FRAGMENT:
+                mUpdatesFragmentView.setVisibility(View.VISIBLE);
                 return mUpdatesFragmentView;
         }
         throw new IllegalArgumentException("Invalid position: " + position);
@@ -93,6 +106,7 @@
 
     @Override
     public void destroyItem(View container, int position, Object object) {
+        ((View) object).setVisibility(View.GONE);
     }
 
     @Override
diff --git a/src/com/android/contacts/list/ContactListPinnedHeaderView.java b/src/com/android/contacts/list/ContactListPinnedHeaderView.java
index 913bb75..aee77e1 100644
--- a/src/com/android/contacts/list/ContactListPinnedHeaderView.java
+++ b/src/com/android/contacts/list/ContactListPinnedHeaderView.java
@@ -113,8 +113,9 @@
 
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
-        int width = right - left - mPaddingRight;
+        int width = right - left;
 
+        // Take into account left and right padding when laying out the below views.
         mHeaderTextView.layout(mHeaderTextIndent + mPaddingLeft,
                 0,
                 mHeaderTextView.getMeasuredWidth() + mHeaderTextIndent + mPaddingLeft,
@@ -129,7 +130,7 @@
 
         mHeaderDivider.layout(mPaddingLeft,
                 mHeaderBackgroundHeight,
-                width,
+                width - mPaddingRight,
                 mHeaderBackgroundHeight + mHeaderUnderlineHeight);
     }