Merge "DO NOT MERGE Remove the car-stream-lib dependency from Dialer. Replace with the one in car support lib." into pi-dev
am: f364a0f31b

Change-Id: I0c1af3c114ab94d2697ebd14002a526a3810cf08
diff --git a/Android.mk b/Android.mk
index 9b5987e..c727011 100644
--- a/Android.mk
+++ b/Android.mk
@@ -38,7 +38,6 @@
     android-support-v4 \
     android-support-v7-cardview \
     car-apps-common \
-    car-stream-ui-lib \
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     android-support-constraint-layout-solver \
diff --git a/res/drawable/car_card_rounded_bottom_background.xml b/res/drawable/car_card_rounded_bottom_background.xml
deleted file mode 100644
index d0249f9..0000000
--- a/res/drawable/car_card_rounded_bottom_background.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2018 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="?attr/listItemBackgroundColor"/>
-    <corners
-        android:bottomRightRadius="@dimen/car_radius_3"
-        android:bottomLeftRadius="@dimen/car_radius_3"/>
-</shape>
\ No newline at end of file
diff --git a/res/drawable/car_card_rounded_top_background.xml b/res/drawable/car_card_rounded_top_background.xml
deleted file mode 100644
index ed52a59..0000000
--- a/res/drawable/car_card_rounded_top_background.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2018 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="?attr/listItemBackgroundColor"/>
-    <corners
-        android:topRightRadius="@dimen/car_radius_3"
-        android:topLeftRadius="@dimen/car_radius_3"/>
-</shape>
\ No newline at end of file
diff --git a/res/drawable/car_card_rounded_top_bottom_background.xml b/res/drawable/car_card_rounded_top_bottom_background.xml
deleted file mode 100644
index 7891fd1..0000000
--- a/res/drawable/car_card_rounded_top_bottom_background.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2018 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="@color/car_card" />
-    <corners
-            android:radius="@dimen/car_radius_3"/>
-</shape>
diff --git a/src/com/android/car/dialer/ContactDetailsFragment.java b/src/com/android/car/dialer/ContactDetailsFragment.java
index 9328415..bb3b1b5 100644
--- a/src/com/android/car/dialer/ContactDetailsFragment.java
+++ b/src/com/android/car/dialer/ContactDetailsFragment.java
@@ -40,6 +40,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import androidx.car.utils.ListItemBackgroundResolver;
 import androidx.car.widget.DayNightStyle;
 import androidx.car.widget.PagedListView;
 
@@ -330,36 +331,8 @@
             } else {
                 viewHolder.divier.setVisibility(View.VISIBLE);
             }
-            setBackground(viewHolder.card,
+            ListItemBackgroundResolver.setBackground(viewHolder.card,
                     viewHolder.getAdapterPosition(), getItemCount());
         }
     }
-
-    private void setBackground(View view, int currentPosition, int totalItems) {
-        if (currentPosition < 0) {
-            throw new IllegalArgumentException("currentPosition cannot be less than zero.");
-        }
-
-        if (currentPosition >= totalItems) {
-            throw new IndexOutOfBoundsException("currentPosition: " + currentPosition + "; "
-                    + "totalItems: " + totalItems);
-        }
-
-        // Correctly set the background for each card. Only the top and last card should
-        // have rounded corners.
-        if (totalItems == 1) {
-            // One card - all corners are rounded
-            view.setBackgroundResource(
-                    R.drawable.car_card_rounded_top_bottom_background);
-        } else if (currentPosition == 0) {
-            // First card gets rounded top
-            view.setBackgroundResource(R.drawable.car_card_rounded_top_background);
-        } else if (currentPosition == totalItems - 1) {
-            // Last one has a rounded bottom
-            view.setBackgroundResource(R.drawable.car_card_rounded_bottom_background);
-        } else {
-            // Middle has no rounded corners
-            view.setBackgroundResource(R.color.phone_theme);
-        }
-    }
 }
diff --git a/src/com/android/car/dialer/ContactResultViewHolder.java b/src/com/android/car/dialer/ContactResultViewHolder.java
index 2a73944..00766e1 100644
--- a/src/com/android/car/dialer/ContactResultViewHolder.java
+++ b/src/com/android/car/dialer/ContactResultViewHolder.java
@@ -27,9 +27,10 @@
 import android.widget.ImageView;
 import android.widget.TextView;
 
+import androidx.car.utils.ListItemBackgroundResolver;
+
 import com.android.car.apps.common.LetterTileDrawable;
 import com.android.car.dialer.ui.CircleBitmapDrawable;
-import com.android.car.view.CardListBackgroundResolver;
 
 import java.io.FileNotFoundException;
 import java.io.InputStream;
@@ -57,7 +58,7 @@
      * provided {@link ContactDetails}.
      */
     public void bind(ContactDetails details, int itemCount) {
-        CardListBackgroundResolver.setBackground(mContactCard, getAdapterPosition(), itemCount);
+        ListItemBackgroundResolver.setBackground(mContactCard, getAdapterPosition(), itemCount);
 
         mContactCard.setOnClickListener(v -> {
             Intent intent = new Intent();