[DO NOT MERGE] Define list item specific background drawables

Bug: 147512913
Test: Manual

Change-Id: I27a62f14cc5422fbe7f629124e0994660ca0627f
diff --git a/car-ui-lib/res/drawable/car_ui_list_header_background.xml b/car-ui-lib/res/drawable/car_ui_list_header_background.xml
new file mode 100644
index 0000000..656b191
--- /dev/null
+++ b/car-ui-lib/res/drawable/car_ui_list_header_background.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2020 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="@android:color/transparent"/>
+</shape>
diff --git a/car-ui-lib/res/drawable/car_ui_list_item_background.xml b/car-ui-lib/res/drawable/car_ui_list_item_background.xml
new file mode 100644
index 0000000..df8df2f
--- /dev/null
+++ b/car-ui-lib/res/drawable/car_ui_list_item_background.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="?android:colorControlHighlight">
+    <item android:id="@android:id/mask">
+        <shape android:shape="rectangle">
+            <solid android:color="?android:colorAccent" />
+        </shape>
+    </item>
+</ripple>
\ No newline at end of file
diff --git a/car-ui-lib/res/layout/car_ui_header_list_item.xml b/car-ui-lib/res/layout/car_ui_header_list_item.xml
index 2bb1fce..8f07636 100644
--- a/car-ui-lib/res/layout/car_ui_header_list_item.xml
+++ b/car-ui-lib/res/layout/car_ui_header_list_item.xml
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?><!--
+<?xml version="1.0" encoding="utf-8"?>
+<!--
   ~ Copyright 2019 The Android Open Source Project
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,8 +15,10 @@
   ~ limitations under the License.
   -->
 
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:background="@drawable/car_ui_list_header_background"
     android:layout_width="match_parent"
     android:layout_height="@dimen/car_ui_list_item_header_height">
 
diff --git a/car-ui-lib/res/layout/car_ui_list_item.xml b/car-ui-lib/res/layout/car_ui_list_item.xml
index d7aa12f..b7efd33 100644
--- a/car-ui-lib/res/layout/car_ui_list_item.xml
+++ b/car-ui-lib/res/layout/car_ui_list_item.xml
@@ -25,7 +25,7 @@
         android:id="@+id/touch_interceptor"
         android:layout_width="0dp"
         android:layout_height="0dp"
-        android:background="?android:attr/selectableItemBackground"
+        android:background="@drawable/car_ui_list_item_background"
         android:clickable="true"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
@@ -37,7 +37,7 @@
         android:id="@+id/reduced_touch_interceptor"
         android:layout_width="0dp"
         android:layout_height="0dp"
-        android:background="?android:attr/selectableItemBackground"
+        android:background="@drawable/car_ui_list_item_background"
         android:clickable="true"
         android:visibility="gone"
         app:layout_constraintBottom_toBottomOf="parent"
@@ -94,12 +94,24 @@
         app:layout_constraintTop_toBottomOf="@+id/title"
         app:layout_goneMarginStart="@dimen/car_ui_list_item_text_no_icon_start_margin" />
 
+    <!-- This touch interceptor is sized and positioned to encompass the action container   -->
+    <View
+        android:id="@+id/action_container_touch_interceptor"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:background="@drawable/car_ui_list_item_background"
+        android:clickable="true"
+        android:visibility="gone"
+        app:layout_constraintBottom_toBottomOf="@id/action_container"
+        app:layout_constraintEnd_toEndOf="@id/action_container"
+        app:layout_constraintStart_toStartOf="@id/action_container"
+        app:layout_constraintTop_toTopOf="@id/action_container" />
+
     <FrameLayout
         android:id="@+id/action_container"
         android:layout_width="wrap_content"
         android:minWidth="@dimen/car_ui_list_item_icon_container_width"
         android:layout_height="0dp"
-        android:background="?android:attr/selectableItemBackground"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="@+id/car_ui_list_item_end_guideline"
         app:layout_constraintTop_toTopOf="parent">
diff --git a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiListItemAdapter.java b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
index ddc5aec..91a4d71 100644
--- a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
+++ b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
@@ -161,6 +161,7 @@
         private final ImageView mSupplementalIcon;
         private final View mTouchInterceptor;
         private final View mReducedTouchInterceptor;
+        private final View mActionContainerTouchInterceptor;
 
 
         ListItemViewHolder(@NonNull View itemView) {
@@ -177,6 +178,8 @@
             mSupplementalIcon = itemView.requireViewById(R.id.supplemental_icon);
             mReducedTouchInterceptor = itemView.requireViewById(R.id.reduced_touch_interceptor);
             mTouchInterceptor = itemView.requireViewById(R.id.touch_interceptor);
+            mActionContainerTouchInterceptor = itemView.requireViewById(
+                    R.id.action_container_touch_interceptor);
         }
 
         private void bind(@NonNull CarUiContentListItem item) {
@@ -193,6 +196,7 @@
 
             if (!TextUtils.isEmpty(body)) {
                 mBody.setText(body);
+                mBody.setVisibility(View.VISIBLE);
             } else {
                 mBody.setVisibility(View.GONE);
             }
@@ -220,6 +224,7 @@
                     // touch interceptor.
                     mTouchInterceptor.setVisibility(View.VISIBLE);
                     mReducedTouchInterceptor.setVisibility(View.GONE);
+                    mActionContainerTouchInterceptor.setVisibility(View.GONE);
                     break;
                 case SWITCH:
                     mSwitch.setVisibility(View.VISIBLE);
@@ -240,6 +245,7 @@
                     mTouchInterceptor.setVisibility(View.VISIBLE);
                     mTouchInterceptor.setOnClickListener(v -> mSwitch.toggle());
                     mReducedTouchInterceptor.setVisibility(View.GONE);
+                    mActionContainerTouchInterceptor.setVisibility(View.GONE);
 
                     mActionContainer.setVisibility(View.VISIBLE);
                     mActionContainer.setClickable(false);
@@ -263,6 +269,7 @@
                     mTouchInterceptor.setVisibility(View.VISIBLE);
                     mTouchInterceptor.setOnClickListener(v -> mCheckBox.toggle());
                     mReducedTouchInterceptor.setVisibility(View.GONE);
+                    mActionContainerTouchInterceptor.setVisibility(View.GONE);
 
                     mActionContainer.setVisibility(View.VISIBLE);
                     mActionContainer.setClickable(false);
@@ -286,6 +293,7 @@
                     mTouchInterceptor.setVisibility(View.VISIBLE);
                     mTouchInterceptor.setOnClickListener(v -> mRadioButton.toggle());
                     mReducedTouchInterceptor.setVisibility(View.GONE);
+                    mActionContainerTouchInterceptor.setVisibility(View.GONE);
 
                     mActionContainer.setVisibility(View.VISIBLE);
                     mActionContainer.setClickable(false);
@@ -294,7 +302,7 @@
                     mSupplementalIcon.setVisibility(View.VISIBLE);
                     mSupplementalIcon.setImageDrawable(item.getSupplementalIcon());
                     mActionContainer.setVisibility(View.VISIBLE);
-                    mActionContainer.setOnClickListener(
+                    mActionContainerTouchInterceptor.setOnClickListener(
                             (container) -> {
                                 if (item.getSupplementalIconOnClickListener() != null) {
                                     item.getSupplementalIconOnClickListener().onClick(mIcon);
@@ -309,10 +317,10 @@
                         mTouchInterceptor.setVisibility(View.VISIBLE);
                         mTouchInterceptor.setOnClickListener(null);
                         mReducedTouchInterceptor.setVisibility(View.GONE);
-                        mActionContainer.setClickable(false);
+                        mActionContainerTouchInterceptor.setVisibility(View.GONE);
                     } else {
                         mReducedTouchInterceptor.setVisibility(View.VISIBLE);
-                        mReducedTouchInterceptor.setOnClickListener(null);
+                        mActionContainerTouchInterceptor.setVisibility(View.VISIBLE);
                         mTouchInterceptor.setVisibility(View.GONE);
                     }
                     break;
diff --git a/car-ui-lib/tests/apitest/current.xml b/car-ui-lib/tests/apitest/current.xml
index 694a9d9..4ee3e7d 100644
--- a/car-ui-lib/tests/apitest/current.xml
+++ b/car-ui-lib/tests/apitest/current.xml
@@ -167,6 +167,8 @@
   <public type="drawable" name="car_ui_icon_search"/>
   <public type="drawable" name="car_ui_icon_search_nav_icon"/>
   <public type="drawable" name="car_ui_icon_settings"/>
+  <public type="drawable" name="car_ui_list_header_background"/>
+  <public type="drawable" name="car_ui_list_item_background"/>
   <public type="drawable" name="car_ui_list_item_divider"/>
   <public type="drawable" name="car_ui_preference_icon_chevron"/>
   <public type="drawable" name="car_ui_recyclerview_button_ripple_background"/>