Pixel perfect work on call log.

- Show a divider only between call log items, not when there is a
  section header.
- Format the phone label in the call details in white instead of gray.

Bug: 5225943
Change-Id: Ia7b959bae19f9e38021f173f23cd48ae67a84fe0
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index 157c761..df1ec62 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -163,12 +163,14 @@
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:textAppearance="?android:attr/textAppearanceMedium"
+                        android:textColor="?attr/call_log_primary_text_color"
                     />
 
                     <TextView android:id="@+id/call_and_sms_label"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:textAppearance="?android:attr/textAppearanceSmall"
+                        android:textColor="?attr/call_log_primary_text_color"
                         android:textAllCaps="true"
                     />
 
diff --git a/res/layout/call_log_fragment.xml b/res/layout/call_log_fragment.xml
index 7cfcef3..26689be 100644
--- a/res/layout/call_log_fragment.xml
+++ b/res/layout/call_log_fragment.xml
@@ -39,6 +39,7 @@
             android:layout_height="match_parent"
             android:fadingEdge="none"
             android:scrollbarStyle="outsideOverlay"
+            android:divider="@null"
         />
         <TextView android:id="@android:id/empty"
             android:layout_width="match_parent"
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index 734e1b8..3458dd9 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -19,6 +19,7 @@
     class="com.android.contacts.calllog.CallLogListItemView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:orientation="vertical"
 >
     <!--
         This layout may represent either a call log item or one of the
@@ -170,4 +171,13 @@
             android:layout_height="2dip"
             android:background="@color/call_log_voicemail_highlight_color"/>
     </LinearLayout>
+
+    <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"
+    />
 </view>
diff --git a/src/com/android/contacts/calllog/CallLogAdapter.java b/src/com/android/contacts/calllog/CallLogAdapter.java
index 94daf06..604d528 100644
--- a/src/com/android/contacts/calllog/CallLogAdapter.java
+++ b/src/com/android/contacts/calllog/CallLogAdapter.java
@@ -541,6 +541,7 @@
         if (section == CallLogQuery.SECTION_NEW_HEADER
                 || section == CallLogQuery.SECTION_OLD_HEADER) {
             views.listItemView.setVisibility(View.GONE);
+            views.bottomDivider.setVisibility(View.GONE);
             views.listHeaderView.setVisibility(View.VISIBLE);
             views.listHeaderTextView.setText(
                     section == CallLogQuery.SECTION_NEW_HEADER
@@ -551,6 +552,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);
 
         final String number = c.getString(CallLogQuery.NUMBER);
@@ -654,6 +656,16 @@
         }
     }
 
+    /** Returns true if this is the last item of a section. */
+    private boolean isLastOfSection(Cursor c) {
+        if (c.isLast()) return true;
+        final int section = c.getInt(CallLogQuery.SECTION);
+        if (!c.moveToNext()) return true;
+        final int nextSection = c.getInt(CallLogQuery.SECTION);
+        c.moveToPrevious();
+        return section != nextSection;
+    }
+
     /** Checks whether the contact info from the call log matches the one from the contacts db. */
     private boolean callLogInfoMatches(ContactInfo callLogInfo, ContactInfo info) {
         // The call log only contains a subset of the fields in the contacts db.
diff --git a/src/com/android/contacts/calllog/CallLogListItemViews.java b/src/com/android/contacts/calllog/CallLogListItemViews.java
index 847e354..938b2e3 100644
--- a/src/com/android/contacts/calllog/CallLogListItemViews.java
+++ b/src/com/android/contacts/calllog/CallLogListItemViews.java
@@ -47,11 +47,13 @@
     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,
             PhoneCallDetailsViews phoneCallDetailsViews, View listItemView,
-            View listHeaderView, TextView listHeaderTextView) {
+            View listHeaderView, TextView listHeaderTextView, View bottomDivider) {
         this.quickContactView = quickContactView;
         this.primaryActionView = primaryActionView;
         this.secondaryActionView = secondaryActionView;
@@ -61,6 +63,7 @@
         this.listItemView = listItemView;
         this.listHeaderView = listHeaderView;
         this.listHeaderTextView = listHeaderTextView;
+        this.bottomDivider = bottomDivider;
     }
 
     public static CallLogListItemViews fromView(View view) {
@@ -73,7 +76,8 @@
                 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_text),
+                view.findViewById(R.id.call_log_divider));
     }
 
     public static CallLogListItemViews createForTest(Context context) {
@@ -86,6 +90,7 @@
                 PhoneCallDetailsViews.createForTest(context),
                 new View(context),
                 new View(context),
-                new TextView(context));
+                new TextView(context),
+                new View(context));
     }
 }