MediaRouter: Change the default route icon from TV to Cast

Bug: 24772220
Change-Id: If99fb505feafe24e4e1a7a0de4569ec57dbfdee7
diff --git a/v7/mediarouter/res/drawable-hdpi/ic_cast_grey.png b/v7/mediarouter/res/drawable-hdpi/ic_cast_grey.png
new file mode 100644
index 0000000..f0960f8
--- /dev/null
+++ b/v7/mediarouter/res/drawable-hdpi/ic_cast_grey.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-hdpi/ic_cast_white.png b/v7/mediarouter/res/drawable-hdpi/ic_cast_white.png
new file mode 100644
index 0000000..60d3915
--- /dev/null
+++ b/v7/mediarouter/res/drawable-hdpi/ic_cast_white.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-mdpi/ic_cast_grey.png b/v7/mediarouter/res/drawable-mdpi/ic_cast_grey.png
new file mode 100644
index 0000000..35ffd60
--- /dev/null
+++ b/v7/mediarouter/res/drawable-mdpi/ic_cast_grey.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-mdpi/ic_cast_white.png b/v7/mediarouter/res/drawable-mdpi/ic_cast_white.png
new file mode 100644
index 0000000..d62923f
--- /dev/null
+++ b/v7/mediarouter/res/drawable-mdpi/ic_cast_white.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-xhdpi/ic_cast_grey.png b/v7/mediarouter/res/drawable-xhdpi/ic_cast_grey.png
new file mode 100644
index 0000000..dba8992
--- /dev/null
+++ b/v7/mediarouter/res/drawable-xhdpi/ic_cast_grey.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-xhdpi/ic_cast_white.png b/v7/mediarouter/res/drawable-xhdpi/ic_cast_white.png
new file mode 100644
index 0000000..f5f7c14
--- /dev/null
+++ b/v7/mediarouter/res/drawable-xhdpi/ic_cast_white.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-xxhdpi/ic_cast_grey.png b/v7/mediarouter/res/drawable-xxhdpi/ic_cast_grey.png
new file mode 100644
index 0000000..7582751
--- /dev/null
+++ b/v7/mediarouter/res/drawable-xxhdpi/ic_cast_grey.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-xxhdpi/ic_cast_white.png b/v7/mediarouter/res/drawable-xxhdpi/ic_cast_white.png
new file mode 100644
index 0000000..7a7673f
--- /dev/null
+++ b/v7/mediarouter/res/drawable-xxhdpi/ic_cast_white.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-xxxhdpi/ic_cast_grey.png b/v7/mediarouter/res/drawable-xxxhdpi/ic_cast_grey.png
new file mode 100644
index 0000000..d124cb8
--- /dev/null
+++ b/v7/mediarouter/res/drawable-xxxhdpi/ic_cast_grey.png
Binary files differ
diff --git a/v7/mediarouter/res/drawable-xxxhdpi/ic_cast_white.png b/v7/mediarouter/res/drawable-xxxhdpi/ic_cast_white.png
new file mode 100644
index 0000000..bb3539c
--- /dev/null
+++ b/v7/mediarouter/res/drawable-xxxhdpi/ic_cast_white.png
Binary files differ
diff --git a/v7/mediarouter/res/values/attrs.xml b/v7/mediarouter/res/values/attrs.xml
index cd6e95b..bfc4c5e 100644
--- a/v7/mediarouter/res/values/attrs.xml
+++ b/v7/mediarouter/res/values/attrs.xml
@@ -36,9 +36,10 @@
     <attr name="mediaRouteCastDrawable" format="reference" />
     <attr name="mediaRouteAudioTrackDrawable" format="reference" />
     <attr name="mediaRouteDefaultIconDrawable" format="reference" />
+    <attr name="mediaRouteBluetoothIconDrawable" format="reference" />
+    <attr name="mediaRouteTvIconDrawable" format="reference" />
     <attr name="mediaRouteSpeakerIconDrawable" format="reference" />
     <attr name="mediaRouteSpeakerGroupIconDrawable" format="reference" />
-    <attr name="mediaRouteBluetoothIconDrawable" format="reference" />
     <attr name="mediaRouteChooserPrimaryTextStyle" format="reference" />
     <attr name="mediaRouteChooserSecondaryTextStyle" format="reference" />
     <attr name="mediaRouteControllerTitleTextStyle" format="reference" />
diff --git a/v7/mediarouter/res/values/themes.xml b/v7/mediarouter/res/values/themes.xml
index 3890199..d93bfd4 100644
--- a/v7/mediarouter/res/values/themes.xml
+++ b/v7/mediarouter/res/values/themes.xml
@@ -28,10 +28,11 @@
         <item name="mediaRoutePauseDrawable">@drawable/mr_ic_pause_dark</item>
         <item name="mediaRouteCastDrawable">@drawable/mr_ic_cast_dark</item>
         <item name="mediaRouteAudioTrackDrawable">@drawable/ic_audiotrack</item>
-        <item name="mediaRouteDefaultIconDrawable">@drawable/ic_tv_dark</item>
+        <item name="mediaRouteDefaultIconDrawable">@drawable/ic_cast_white</item>
+        <item name="mediaRouteBluetoothIconDrawable">@drawable/ic_bluetooth_white</item>
+        <item name="mediaRouteTvIconDrawable">@drawable/ic_tv_dark</item>
         <item name="mediaRouteSpeakerIconDrawable">@drawable/ic_speaker_dark</item>
         <item name="mediaRouteSpeakerGroupIconDrawable">@drawable/ic_speaker_group_dark</item>
-        <item name="mediaRouteBluetoothIconDrawable">@drawable/ic_bluetooth_white</item>
         <item name="mediaRouteChooserPrimaryTextStyle">@style/Widget.MediaRouter.ChooserText.Primary.Dark</item>
         <item name="mediaRouteChooserSecondaryTextStyle">@style/Widget.MediaRouter.ChooserText.Secondary.Dark</item>
         <item name="mediaRouteControllerTitleTextStyle">@style/Widget.MediaRouter.ControllerText.Title.Dark</item>
@@ -59,10 +60,11 @@
         <item name="mediaRoutePauseDrawable">@drawable/mr_ic_pause_light</item>
         <item name="mediaRouteCastDrawable">@drawable/mr_ic_cast_light</item>
         <item name="mediaRouteAudioTrackDrawable">@drawable/mr_ic_audiotrack_light</item>
-        <item name="mediaRouteDefaultIconDrawable">@drawable/ic_tv_light</item>
+        <item name="mediaRouteDefaultIconDrawable">@drawable/ic_cast_grey</item>
+        <item name="mediaRouteBluetoothIconDrawable">@drawable/ic_bluetooth_grey</item>
+        <item name="mediaRouteTvIconDrawable">@drawable/ic_tv_light</item>
         <item name="mediaRouteSpeakerIconDrawable">@drawable/ic_speaker_light</item>
         <item name="mediaRouteSpeakerGroupIconDrawable">@drawable/ic_speaker_group_light</item>
-        <item name="mediaRouteBluetoothIconDrawable">@drawable/ic_bluetooth_grey</item>
         <item name="mediaRouteChooserPrimaryTextStyle">@style/Widget.MediaRouter.ChooserText.Primary.Light</item>
         <item name="mediaRouteChooserSecondaryTextStyle">@style/Widget.MediaRouter.ChooserText.Secondary.Light</item>
         <item name="mediaRouteControllerTitleTextStyle">@style/Widget.MediaRouter.ControllerText.Title.Light</item>
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java b/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
index 1ffb19a..9beb8d9 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
@@ -214,22 +214,25 @@
             implements ListView.OnItemClickListener {
         private final LayoutInflater mInflater;
         private final Drawable mDefaultIcon;
+        private final Drawable mBluetoothIcon;
+        private final Drawable mTvIcon;
         private final Drawable mSpeakerIcon;
         private final Drawable mSpeakerGroupIcon;
-        private final Drawable mBluetoothIcon;
 
         public RouteAdapter(Context context, List<MediaRouter.RouteInfo> routes) {
             super(context, 0, routes);
             mInflater = LayoutInflater.from(context);
             TypedArray styledAttributes = getContext().obtainStyledAttributes(new int[] {
                     R.attr.mediaRouteDefaultIconDrawable,
+                    R.attr.mediaRouteBluetoothIconDrawable,
+                    R.attr.mediaRouteTvIconDrawable,
                     R.attr.mediaRouteSpeakerIconDrawable,
-                    R.attr.mediaRouteSpeakerGroupIconDrawable,
-                    R.attr.mediaRouteBluetoothIconDrawable });
+                    R.attr.mediaRouteSpeakerGroupIconDrawable});
             mDefaultIcon = styledAttributes.getDrawable(0);
-            mSpeakerIcon = styledAttributes.getDrawable(1);
-            mSpeakerGroupIcon = styledAttributes.getDrawable(2);
-            mBluetoothIcon = styledAttributes.getDrawable(3);
+            mBluetoothIcon = styledAttributes.getDrawable(1);
+            mTvIcon = styledAttributes.getDrawable(2);
+            mSpeakerIcon = styledAttributes.getDrawable(3);
+            mSpeakerGroupIcon = styledAttributes.getDrawable(4);
             styledAttributes.recycle();
         }
 
@@ -305,12 +308,15 @@
 
         private Drawable getDefaultIconDrawable(MediaRouter.RouteInfo route) {
             // If the type of the receiver device is specified, use it.
-            int deviceType = route.getDeviceType();
-            if (deviceType == MediaRouter.RouteInfo.DEVICE_TYPE_SPEAKER) {
-                return mSpeakerIcon;
-            } else if (deviceType == MediaRouter.RouteInfo.DEVICE_TYPE_BLUETOOTH) {
-                return mBluetoothIcon;
+            switch (route.getDeviceType()) {
+                case MediaRouter.RouteInfo.DEVICE_TYPE_BLUETOOTH:
+                    return mBluetoothIcon;
+                case  MediaRouter.RouteInfo.DEVICE_TYPE_TV:
+                    return mTvIcon;
+                case MediaRouter.RouteInfo.DEVICE_TYPE_SPEAKER:
+                    return mSpeakerIcon;
             }
+
             // Otherwise, make the best guess based on other route information.
             if (route instanceof MediaRouter.RouteGroup) {
                 // Only speakers can be grouped for now.
@@ -319,23 +325,6 @@
             if (isSystemLiveAudioOnlyRoute(route)) {
                 return mBluetoothIcon;
             }
-            if (route.supportsControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
-                    && !route.supportsControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)) {
-                return mSpeakerIcon;
-            }
-            // A workaround to get the speaker icon for known audio devices.
-            // TODO: Remove once the new setDeviceType(int) API is fully launched.
-            String packageName = route.getProvider().getPackageName();
-            if (packageName != null) {
-                if (packageName.startsWith("com.google.android.music")
-                        || packageName.startsWith("com.sonos")) {
-                    return mSpeakerIcon;
-                }
-            }
-            String description = route.getDescription();
-            if (!TextUtils.isEmpty(description) && description.toLowerCase().contains("audio")) {
-                return mSpeakerIcon;
-            }
             return mDefaultIcon;
         }
     }