Extend the call log highlight to include the call icon.

This commit moves the call icon (the secondary action) within the
primary action, which means the highlight for the primary action will
extend to it.

In order to preserve accessibility, it add a nextFocusRight and
nextFocusLeft to the primary and secondary actions, so that it is
possible to navigate between them.

Bug: 5290460
Change-Id: I75f1ca5530d9e656d54f32b58bc1cb04bfc6bed6
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index 2482e46..bf01103 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -32,57 +32,18 @@
         @id/call_log_item gone
     -->
 
-    <RelativeLayout
-        android:id="@+id/call_log_item"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginLeft="@dimen/call_log_outer_margin"
-        android:layout_marginRight="@dimen/call_log_outer_margin"
-        android:gravity="center_vertical"
-    >
-        <LinearLayout
-            android:id="@+id/divider"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:layout_alignParentRight="true"
-            android:layout_centerVertical="true"
-            android:layout_alignTop="@+id/primary_action_view"
-            android:layout_alignBottom="@+id/primary_action_view"
-            android:orientation="horizontal"
-        >
-            <View
-                android:layout_width="1px"
-                android:layout_height="@dimen/call_log_call_action_size"
-                android:background="@drawable/ic_divider_dashed_holo_dark"
-                android:layout_gravity="center_vertical"
-            />
-            <ImageButton
-                android:id="@+id/secondary_action_icon"
-                android:layout_width="@dimen/call_log_call_action_width"
-                android:layout_height="match_parent"
-                android:paddingLeft="@dimen/call_log_inner_margin"
-                android:paddingTop="@dimen/call_log_inner_margin"
-                android:paddingBottom="@dimen/call_log_inner_margin"
-                android:paddingRight="@dimen/call_log_inner_margin"
-                android:scaleType="center"
-                android:background="?android:attr/selectableItemBackground"
-            />
-        </LinearLayout>
         <LinearLayout
             android:id="@+id/primary_action_view"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_toLeftOf="@id/divider"
-            android:layout_alignParentLeft="true"
-            android:layout_alignWithParentIfMissing="true"
             android:layout_centerVertical="true"
-            android:paddingRight="@dimen/call_log_inner_margin"
-            android:paddingTop="@dimen/call_log_inner_margin"
-            android:paddingBottom="@dimen/call_log_inner_margin"
+            android:layout_marginLeft="@dimen/call_log_outer_margin"
+            android:layout_marginRight="@dimen/call_log_outer_margin"
             android:orientation="horizontal"
             android:gravity="center_vertical"
             android:background="?android:attr/selectableItemBackground"
             android:focusable="true"
+            android:nextFocusRight="@+id/secondary_action_icon"
         >
             <QuickContactBadge
                 android:id="@+id/quick_contact_photo"
@@ -94,6 +55,9 @@
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:paddingTop="@dimen/call_log_inner_margin"
+                android:paddingBottom="@dimen/call_log_inner_margin"
                 android:orientation="vertical"
                 android:gravity="center_vertical"
                 android:layout_marginLeft="@dimen/call_log_inner_margin"
@@ -139,8 +103,26 @@
                     />
                 </LinearLayout>
             </LinearLayout>
+            <View
+                android:id="@+id/divider"
+                android:layout_width="1px"
+                android:layout_height="@dimen/call_log_call_action_size"
+                android:background="@drawable/ic_divider_dashed_holo_dark"
+                android:layout_gravity="center_vertical"
+            />
+            <ImageButton
+                android:id="@+id/secondary_action_icon"
+                android:layout_width="@dimen/call_log_call_action_width"
+                android:layout_height="match_parent"
+                android:paddingLeft="@dimen/call_log_inner_margin"
+                android:paddingTop="@dimen/call_log_inner_margin"
+                android:paddingBottom="@dimen/call_log_inner_margin"
+                android:paddingRight="@dimen/call_log_inner_margin"
+                android:scaleType="center"
+                android:background="?android:attr/selectableItemBackground"
+                android:nextFocusLeft="@id/primary_action_view"
+            />
         </LinearLayout>
-    </RelativeLayout>
 
     <TextView
         android:id="@+id/call_log_header"
diff --git a/src/com/android/contacts/calllog/CallLogAdapter.java b/src/com/android/contacts/calllog/CallLogAdapter.java
index 0dc5e35..7666a7a 100644
--- a/src/com/android/contacts/calllog/CallLogAdapter.java
+++ b/src/com/android/contacts/calllog/CallLogAdapter.java
@@ -538,7 +538,7 @@
         // This might be a header: check the value of the section column in the cursor.
         if (section == CallLogQuery.SECTION_NEW_HEADER
                 || section == CallLogQuery.SECTION_OLD_HEADER) {
-            views.listItemView.setVisibility(View.GONE);
+            views.primaryActionView.setVisibility(View.GONE);
             views.bottomDivider.setVisibility(View.GONE);
             views.listHeaderTextView.setVisibility(View.VISIBLE);
             views.listHeaderTextView.setText(
@@ -549,7 +549,7 @@
             return;
         }
         // Default case: an item in the call log.
-        views.listItemView.setVisibility(View.VISIBLE);
+        views.primaryActionView.setVisibility(View.VISIBLE);
         views.bottomDivider.setVisibility(isLastOfSection(c) ? View.GONE : View.VISIBLE);
         views.listHeaderTextView.setVisibility(View.GONE);
 
diff --git a/src/com/android/contacts/calllog/CallLogListItemViews.java b/src/com/android/contacts/calllog/CallLogListItemViews.java
index a2679e9..741d218 100644
--- a/src/com/android/contacts/calllog/CallLogListItemViews.java
+++ b/src/com/android/contacts/calllog/CallLogListItemViews.java
@@ -39,8 +39,6 @@
     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 text of the header of a section. */
     public final TextView listHeaderTextView;
     /** The divider to be shown below items. */
@@ -48,14 +46,13 @@
 
     private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView,
             ImageView secondaryActionView, View dividerView,
-            PhoneCallDetailsViews phoneCallDetailsViews, View listItemView,
+            PhoneCallDetailsViews phoneCallDetailsViews,
             TextView listHeaderTextView, View bottomDivider) {
         this.quickContactView = quickContactView;
         this.primaryActionView = primaryActionView;
         this.secondaryActionView = secondaryActionView;
         this.dividerView = dividerView;
         this.phoneCallDetailsViews = phoneCallDetailsViews;
-        this.listItemView = listItemView;
         this.listHeaderTextView = listHeaderTextView;
         this.bottomDivider = bottomDivider;
     }
@@ -67,7 +64,6 @@
                 (ImageView) view.findViewById(R.id.secondary_action_icon),
                 view.findViewById(R.id.divider),
                 PhoneCallDetailsViews.fromView(view),
-                view.findViewById(R.id.call_log_item),
                 (TextView) view.findViewById(R.id.call_log_header),
                 view.findViewById(R.id.call_log_divider));
     }
@@ -79,7 +75,6 @@
                 new ImageView(context),
                 new View(context),
                 PhoneCallDetailsViews.createForTest(context),
-                new View(context),
                 new TextView(context),
                 new View(context));
     }