Merge "Use non-capitalized texts for "Me" header"
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index c69f89f..076f37f 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -83,7 +83,7 @@
             android:id="@+id/voicemail_container"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingBottom="@dimen/call_log_icon_margin"
+            android:paddingBottom="@dimen/call_detail_button_spacing"
             android:layout_below="@id/blue_separator"
             android:background="@android:color/black"
         >
@@ -135,7 +135,7 @@
         <FrameLayout android:id="@+id/call_and_sms_container"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_marginBottom="@dimen/call_log_icon_margin"
+            android:layout_marginBottom="@dimen/call_detail_button_spacing"
             android:layout_below="@id/voicemail_container"
             android:background="@android:color/black"
         >
diff --git a/res/layout/call_detail_history_header.xml b/res/layout/call_detail_history_header.xml
index 7fd7556..63c8673 100644
--- a/res/layout/call_detail_history_header.xml
+++ b/res/layout/call_detail_history_header.xml
@@ -48,8 +48,8 @@
     <View
         android:id="@+id/header_voicemail_container"
         android:layout_width="match_parent"
-        android:layout_height="142dip"
-        android:layout_marginBottom="@dimen/call_log_icon_margin"
+        android:layout_height="140dip"
+        android:layout_marginBottom="@dimen/call_detail_button_spacing"
     />
     <!-- Call and SMS -->
     <View
diff --git a/res/layout/call_detail_history_item.xml b/res/layout/call_detail_history_item.xml
index fa5bc28..28a7da0 100644
--- a/res/layout/call_detail_history_item.xml
+++ b/res/layout/call_detail_history_item.xml
@@ -19,7 +19,8 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:minHeight="@dimen/call_log_list_item_height"
-    android:paddingTop="@dimen/call_log_icon_margin"
+    android:paddingTop="@dimen/call_log_inner_margin"
+    android:paddingBottom="@dimen/call_log_inner_margin"
     android:paddingLeft="@dimen/call_log_indent_margin"
     android:paddingRight="@dimen/call_log_outer_margin"
     android:orientation="vertical"
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index 3458dd9..649dede 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -93,6 +93,7 @@
             android:layout_height="match_parent"
             android:layout_toRightOf="@id/quick_contact_photo"
             android:layout_toLeftOf="@id/divider"
+            android:layout_alignWithParentIfMissing="true"
             android:layout_centerVertical="true"
             android:padding="@dimen/call_log_inner_margin"
             android:orientation="vertical"
@@ -142,42 +143,29 @@
         </LinearLayout>
     </RelativeLayout>
 
-    <LinearLayout
+    <TextView
         android:id="@+id/call_log_header"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingLeft="@dimen/call_log_outer_margin"
-        android:paddingRight="@dimen/call_log_outer_margin"
+        style="?android:attr/listSeparatorTextViewStyle"
+        android:layout_marginLeft="@dimen/call_log_outer_margin"
+        android:layout_marginRight="@dimen/call_log_outer_margin"
         android:paddingTop="@dimen/call_log_inner_margin"
         android:paddingBottom="@dimen/call_log_inner_margin"
-        android:orientation="vertical">
-
-        <TextView
-            android:id="@+id/call_log_header_text"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingLeft="@dimen/call_log_inner_margin"
-            android:paddingRight="@dimen/call_log_inner_margin"
-            android:singleLine="true"
-            android:ellipsize="end"
-            android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textStyle="bold"
-            android:textColor="?attr/call_log_header_color"
-            android:textAllCaps="true"
-            android:focusable="true"
-        />
-        <View
-            android:layout_width="match_parent"
-            android:layout_height="2dip"
-            android:background="@color/call_log_voicemail_highlight_color"/>
-    </LinearLayout>
+        android:background="@drawable/list_section_divider_holo_custom"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textStyle="bold"
+        android:textColor="?attr/call_log_header_color"
+        android:textAllCaps="true"
+        android:singleLine="true"
+        android:ellipsize="end"
+        android:focusable="true"
+    />
 
     <View
         android:id="@+id/call_log_divider"
         android:layout_width="match_parent"
         android:layout_height="1px"
-        android:layout_marginLeft="16dip"
-        android:layout_marginRight="16dip"
-        android:background="#1a1a1a"
+        android:layout_marginLeft="@dimen/call_log_outer_margin"
+        android:layout_marginRight="@dimen/call_log_outer_margin"
+        android:background="#55ffffff"
     />
 </view>
diff --git a/res/layout/playback_layout.xml b/res/layout/playback_layout.xml
index 161c5bd..efd45b8 100644
--- a/res/layout/playback_layout.xml
+++ b/res/layout/playback_layout.xml
@@ -16,7 +16,7 @@
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="58dip"
-            android:layout_marginRight="2dip"
+            android:layout_marginRight="@dimen/call_detail_button_spacing"
             android:background="@drawable/dialpad_background"
             android:layout_weight="1"
         >
@@ -31,7 +31,6 @@
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="58dip"
-            android:layout_marginLeft="2dip"
             android:background="@drawable/dialpad_background"
             android:layout_weight="1"
         >
@@ -50,7 +49,7 @@
         android:layout_height="80dip"
         android:background="@drawable/dialpad_background"
         android:layout_below="@id/buttons_linear_layout"
-        android:layout_marginTop="4dip"
+        android:layout_marginTop="@dimen/call_detail_button_spacing"
     >
         <!-- SeekBar left-right margin decreased from redlines 72dip by 8dip to account for
              half thumb width (thumb is 16dip).
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 1c439d8..f0ba3d5 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -249,9 +249,8 @@
     <dimen name="call_log_indent_margin">24dip</dimen>
     <dimen name="call_log_list_item_height">56dip</dimen>
     <dimen name="call_log_list_contact_photo_size">64dip</dimen>
-    <dimen name="call_detail_contact_background_height">174dip</dimen>
     <dimen name="call_detail_contact_name_margin">24dip</dimen>
-    <dimen name="call_detail_action_bar_height">60dip</dimen>
+    <dimen name="call_detail_button_spacing">2dip</dimen>
 
     <!-- Empty message margins -->
     <dimen name="empty_message_top_margin">48dip</dimen>
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index 5479e86..e008516 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -502,6 +502,7 @@
                 }
 
                 mHasEditNumberBeforeCall = canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
+                invalidateOptionsMenu();
 
                 ListView historyList = (ListView) findViewById(R.id.history);
                 historyList.setAdapter(
diff --git a/src/com/android/contacts/ContactLoader.java b/src/com/android/contacts/ContactLoader.java
index 0addb07..57defcf 100644
--- a/src/com/android/contacts/ContactLoader.java
+++ b/src/com/android/contacts/ContactLoader.java
@@ -1079,30 +1079,51 @@
             }
 
             // Now retrieve any photo records associated with the stream items.
-            String[] streamItemIdArr = new String[streamItems.size()];
-            StringBuilder streamItemPhotoSelection = new StringBuilder();
             if (!streamItems.isEmpty()) {
-                streamItemPhotoSelection.append(StreamItemPhotos.STREAM_ITEM_ID + " IN (");
-                for (int i = 0; i < streamItems.size(); i++) {
-                    if (i > 0) {
-                        streamItemPhotoSelection.append(",");
+                if (result.isUserProfile()) {
+                    // If the stream items we're loading are for the profile, we can't bulk-load the
+                    // stream items with a custom selection.
+                    for (StreamItemEntry entry : streamItems) {
+                        Cursor siCursor = getContext().getContentResolver().query(
+                                Uri.withAppendedPath(
+                                        ContentUris.withAppendedId(
+                                                StreamItems.CONTENT_URI, entry.getId()),
+                                        StreamItems.StreamItemPhotos.CONTENT_DIRECTORY),
+                                null, null, null, null);
+                        try {
+                            while (siCursor.moveToNext()) {
+                                entry.addPhoto(new StreamItemPhotoEntry(siCursor));
+                            }
+                        } finally {
+                            siCursor.close();
+                        }
                     }
-                    streamItemPhotoSelection.append("?");
-                    streamItemIdArr[i] = String.valueOf(streamItems.get(i).getId());
-                }
-                streamItemPhotoSelection.append(")");
-                cursor = getContext().getContentResolver().query(StreamItems.CONTENT_PHOTO_URI,
-                        null, streamItemPhotoSelection.toString(), streamItemIdArr,
-                        StreamItemPhotos.STREAM_ITEM_ID);
-                try {
-                    while (cursor.moveToNext()) {
-                        long streamItemId = cursor.getLong(
-                                cursor.getColumnIndex(StreamItemPhotos.STREAM_ITEM_ID));
-                        StreamItemEntry streamItem = streamItemsById.get(streamItemId);
-                        streamItem.addPhoto(new StreamItemPhotoEntry(cursor));
+                } else {
+                    String[] streamItemIdArr = new String[streamItems.size()];
+                    StringBuilder streamItemPhotoSelection = new StringBuilder();
+                    streamItemPhotoSelection.append(StreamItemPhotos.STREAM_ITEM_ID + " IN (");
+                    for (int i = 0; i < streamItems.size(); i++) {
+                        if (i > 0) {
+                            streamItemPhotoSelection.append(",");
+                        }
+                        streamItemPhotoSelection.append("?");
+                        streamItemIdArr[i] = String.valueOf(streamItems.get(i).getId());
                     }
-                } finally {
-                    cursor.close();
+                    streamItemPhotoSelection.append(")");
+                    Cursor sipCursor = getContext().getContentResolver().query(
+                            StreamItems.CONTENT_PHOTO_URI,
+                            null, streamItemPhotoSelection.toString(), streamItemIdArr,
+                            StreamItemPhotos.STREAM_ITEM_ID);
+                    try {
+                        while (sipCursor.moveToNext()) {
+                            long streamItemId = sipCursor.getLong(
+                                    sipCursor.getColumnIndex(StreamItemPhotos.STREAM_ITEM_ID));
+                            StreamItemEntry streamItem = streamItemsById.get(streamItemId);
+                            streamItem.addPhoto(new StreamItemPhotoEntry(sipCursor));
+                        }
+                    } finally {
+                        sipCursor.close();
+                    }
                 }
             }
 
diff --git a/src/com/android/contacts/calllog/CallLogAdapter.java b/src/com/android/contacts/calllog/CallLogAdapter.java
index 604d528..bf1f857 100644
--- a/src/com/android/contacts/calllog/CallLogAdapter.java
+++ b/src/com/android/contacts/calllog/CallLogAdapter.java
@@ -542,7 +542,7 @@
                 || section == CallLogQuery.SECTION_OLD_HEADER) {
             views.listItemView.setVisibility(View.GONE);
             views.bottomDivider.setVisibility(View.GONE);
-            views.listHeaderView.setVisibility(View.VISIBLE);
+            views.listHeaderTextView.setVisibility(View.VISIBLE);
             views.listHeaderTextView.setText(
                     section == CallLogQuery.SECTION_NEW_HEADER
                             ? R.string.call_log_new_header
@@ -553,7 +553,7 @@
         // Default case: an item in the call log.
         views.listItemView.setVisibility(View.VISIBLE);
         views.bottomDivider.setVisibility(isLastOfSection(c) ? View.GONE : View.VISIBLE);
-        views.listHeaderView.setVisibility(View.GONE);
+        views.listHeaderTextView.setVisibility(View.GONE);
 
         final String number = c.getString(CallLogQuery.NUMBER);
         final long date = c.getLong(CallLogQuery.DATE);
diff --git a/src/com/android/contacts/calllog/CallLogListItemHelper.java b/src/com/android/contacts/calllog/CallLogListItemHelper.java
index 5951ea3..602c283 100644
--- a/src/com/android/contacts/calllog/CallLogListItemHelper.java
+++ b/src/com/android/contacts/calllog/CallLogListItemHelper.java
@@ -65,17 +65,14 @@
         if (canPlay) {
             // Playback action takes preference.
             configurePlaySecondaryAction(views);
-            views.unheardView.setVisibility(isHighlighted ? View.VISIBLE : View.GONE);
             views.dividerView.setVisibility(View.VISIBLE);
         } else if (canCall) {
             // Call is the secondary action.
             configureCallSecondaryAction(views);
-            views.unheardView.setVisibility(View.GONE);
             views.dividerView.setVisibility(View.VISIBLE);
         } else {
             // No action available.
             views.secondaryActionView.setVisibility(View.GONE);
-            views.unheardView.setVisibility(View.GONE);
             views.dividerView.setVisibility(View.GONE);
         }
     }
diff --git a/src/com/android/contacts/calllog/CallLogListItemViews.java b/src/com/android/contacts/calllog/CallLogListItemViews.java
index 938b2e3..a2679e9 100644
--- a/src/com/android/contacts/calllog/CallLogListItemViews.java
+++ b/src/com/android/contacts/calllog/CallLogListItemViews.java
@@ -35,33 +35,27 @@
     public final View primaryActionView;
     /** The secondary action button on the entry. */
     public final ImageView secondaryActionView;
-    /** The icon used for unheard voicemail. */
-    public final View unheardView;
     /** The divider between the primary and secondary actions. */
     public final View dividerView;
     /** The details of the phone call. */
     public final PhoneCallDetailsViews phoneCallDetailsViews;
     /** The item view for a stand-alone row, or null for other types of rows. */
     public final View listItemView;
-    /** The header of a section. */
-    public final View listHeaderView;
     /** The text of the header of a section. */
     public final TextView listHeaderTextView;
     /** The divider to be shown below items. */
     public final View bottomDivider;
 
     private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView,
-            ImageView secondaryActionView, View unheardView, View dividerView,
+            ImageView secondaryActionView, View dividerView,
             PhoneCallDetailsViews phoneCallDetailsViews, View listItemView,
-            View listHeaderView, TextView listHeaderTextView, View bottomDivider) {
+            TextView listHeaderTextView, View bottomDivider) {
         this.quickContactView = quickContactView;
         this.primaryActionView = primaryActionView;
         this.secondaryActionView = secondaryActionView;
-        this.unheardView = unheardView;
         this.dividerView = dividerView;
         this.phoneCallDetailsViews = phoneCallDetailsViews;
         this.listItemView = listItemView;
-        this.listHeaderView = listHeaderView;
         this.listHeaderTextView = listHeaderTextView;
         this.bottomDivider = bottomDivider;
     }
@@ -71,12 +65,10 @@
                 (QuickContactBadge) view.findViewById(R.id.quick_contact_photo),
                 view.findViewById(R.id.primary_action_view),
                 (ImageView) view.findViewById(R.id.secondary_action_icon),
-                view.findViewById(R.id.unheard_icon),
                 view.findViewById(R.id.divider),
                 PhoneCallDetailsViews.fromView(view),
                 view.findViewById(R.id.call_log_item),
-                view.findViewById(R.id.call_log_header),
-                (TextView) view.findViewById(R.id.call_log_header_text),
+                (TextView) view.findViewById(R.id.call_log_header),
                 view.findViewById(R.id.call_log_divider));
     }
 
@@ -86,10 +78,8 @@
                 new View(context),
                 new ImageView(context),
                 new View(context),
-                new View(context),
                 PhoneCallDetailsViews.createForTest(context),
                 new View(context),
-                new View(context),
                 new TextView(context),
                 new View(context));
     }
diff --git a/tests/src/com/android/contacts/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/contacts/calllog/CallLogListItemHelperTest.java
index 2c29608..ce3c14f 100644
--- a/tests/src/com/android/contacts/calllog/CallLogListItemHelperTest.java
+++ b/tests/src/com/android/contacts/calllog/CallLogListItemHelperTest.java
@@ -75,7 +75,6 @@
     public void testSetPhoneCallDetails() {
         setPhoneCallDetailsWithNumber("12125551234", "1-212-555-1234");
         assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility());
-        assertEquals(View.GONE, mViews.unheardView.getVisibility());
     }
 
     public void testSetPhoneCallDetails_Unknown() {
@@ -96,32 +95,27 @@
     public void testSetPhoneCallDetails_VoicemailNumber() {
         setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, TEST_VOICEMAIL_NUMBER);
         assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility());
-        assertEquals(View.GONE, mViews.unheardView.getVisibility());
     }
 
     public void testSetPhoneCallDetails_ReadVoicemail() {
         setPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE);
         assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility());
-        assertEquals(View.GONE, mViews.unheardView.getVisibility());
     }
 
     public void testSetPhoneCallDetails_UnreadVoicemail() {
         setUnreadPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE);
         assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility());
-        assertEquals(View.VISIBLE, mViews.unheardView.getVisibility());
     }
 
     public void testSetPhoneCallDetails_VoicemailFromUnknown() {
         setPhoneCallDetailsWithNumberAndType(CallerInfo.UNKNOWN_NUMBER, CallerInfo.UNKNOWN_NUMBER,
                 Calls.VOICEMAIL_TYPE);
         assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility());
-        assertEquals(View.GONE, mViews.unheardView.getVisibility());
     }
 
     /** Asserts that the whole call area is gone. */
     private void assertNoCallButton() {
         assertEquals(View.GONE, mViews.secondaryActionView.getVisibility());
-        assertEquals(View.GONE, mViews.unheardView.getVisibility());
         assertEquals(View.GONE, mViews.dividerView.getVisibility());
     }