Merge "Scroll content to edges of screen on tablet" into ics-mr1
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/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/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index 5d549b8..eb31e2a 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -351,14 +351,14 @@
 
         if (isVisible(mNameTextView)) {
             mNameTextView.measure(
-                    MeasureSpec.makeMeasureSpec(effectiveWidth, MeasureSpec.AT_MOST),
+                    MeasureSpec.makeMeasureSpec(effectiveWidth, MeasureSpec.EXACTLY),
                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
             mNameTextViewHeight = mNameTextView.getMeasuredHeight();
         }
 
         if (isVisible(mPhoneticNameTextView)) {
             mPhoneticNameTextView.measure(
-                    MeasureSpec.makeMeasureSpec(effectiveWidth, MeasureSpec.AT_MOST),
+                    MeasureSpec.makeMeasureSpec(effectiveWidth, MeasureSpec.EXACTLY),
                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
             mPhoneticNameTextViewHeight = mPhoneticNameTextView.getMeasuredHeight();
         }
@@ -388,13 +388,13 @@
         }
 
         if (isVisible(mDataView)) {
-            mDataView.measure(MeasureSpec.makeMeasureSpec(dataWidth, MeasureSpec.AT_MOST),
+            mDataView.measure(MeasureSpec.makeMeasureSpec(dataWidth, MeasureSpec.EXACTLY),
                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
             mDataViewHeight = mDataView.getMeasuredHeight();
         }
 
         if (isVisible(mLabelView)) {
-            mLabelView.measure(MeasureSpec.makeMeasureSpec(labelWidth, MeasureSpec.AT_MOST),
+            mLabelView.measure(MeasureSpec.makeMeasureSpec(labelWidth, MeasureSpec.EXACTLY),
                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
             mLabelViewHeight = mLabelView.getMeasuredHeight();
         }
@@ -402,7 +402,7 @@
 
         if (isVisible(mSnippetView)) {
             mSnippetView.measure(
-                    MeasureSpec.makeMeasureSpec(effectiveWidth, MeasureSpec.AT_MOST),
+                    MeasureSpec.makeMeasureSpec(effectiveWidth, MeasureSpec.EXACTLY),
                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
             mSnippetTextViewHeight = mSnippetView.getMeasuredHeight();
         }
@@ -422,7 +422,7 @@
             } else {
                 statusWidth = effectiveWidth;
             }
-            mStatusView.measure(MeasureSpec.makeMeasureSpec(statusWidth, MeasureSpec.AT_MOST),
+            mStatusView.measure(MeasureSpec.makeMeasureSpec(statusWidth, MeasureSpec.EXACTLY),
                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
             mStatusTextViewHeight =
                     Math.max(mStatusTextViewHeight, mStatusView.getMeasuredHeight());
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);
     }