Sync the style of MediaRouteChooserDialog among different SDK versions

- Use the same layout for media route list items.
- Sync the text style.

Bug: 23478125
Change-Id: Ie4249caef0700b755f837a686159724528740044
diff --git a/v7/mediarouter/res/layout-v17/mr_media_route_list_item.xml b/v7/mediarouter/res/layout-v17/mr_media_route_list_item.xml
deleted file mode 100644
index e0bb840..0000000
--- a/v7/mediarouter/res/layout-v17/mr_media_route_list_item.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:layout_width="match_parent"
-              android:layout_height="wrap_content"
-              android:orientation="horizontal"
-              android:gravity="center_vertical">
-
-    <ImageView android:id="@+id/routeIcon"
-               android:layout_width="24dp"
-               android:layout_height="24dp"
-               android:layout_marginLeft="24dp"
-               android:layout_marginRight="24dp" />
-
-    <LinearLayout android:layout_width="0dp"
-                  android:layout_height="wrap_content"
-                  android:layout_weight="1"
-                  android:layout_marginRight="24dp"
-                  android:orientation="vertical"
-                  android:gravity="start|center_vertical"
-                  android:duplicateParentState="true">
-
-        <TextView android:id="@android:id/text1"
-                  android:layout_width="match_parent"
-                  android:layout_height="32dp"
-                  android:singleLine="true"
-                  android:gravity="bottom"
-                  android:ellipsize="marquee"
-                  android:textAppearance="?attr/mediaRouteTextStyle"
-                  android:duplicateParentState="true" />
-
-        <TextView android:id="@android:id/text2"
-                  android:layout_width="match_parent"
-                  android:layout_height="24dp"
-                  android:singleLine="true"
-                  android:ellipsize="marquee"
-                  android:textAppearance="?attr/mediaRouteSecondaryTextStyle"
-                  android:duplicateParentState="true" />
-    </LinearLayout>
-
-</LinearLayout>
diff --git a/v7/mediarouter/res/layout/mr_media_route_list_item.xml b/v7/mediarouter/res/layout/mr_media_route_list_item.xml
index 6c63a12..d07dd6e 100644
--- a/v7/mediarouter/res/layout/mr_media_route_list_item.xml
+++ b/v7/mediarouter/res/layout/mr_media_route_list_item.xml
@@ -16,32 +16,38 @@
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="fill_parent"
-              android:layout_height="64dp"
+              android:layout_height="wrap_content"
+              android:orientation="horizontal"
               android:gravity="center_vertical">
 
+    <ImageView android:id="@+id/routeIcon"
+               android:layout_width="24dp"
+               android:layout_height="24dp"
+               android:layout_marginLeft="24dp"
+               android:layout_marginRight="24dp" />
+
     <LinearLayout android:layout_width="0dp"
-                  android:layout_height="fill_parent"
+                  android:layout_height="wrap_content"
                   android:layout_weight="1"
+                  android:layout_marginRight="24dp"
                   android:orientation="vertical"
                   android:gravity="left|center_vertical"
-                  android:paddingLeft="16dp"
-                  android:paddingRight="16dp"
                   android:duplicateParentState="true">
 
         <TextView android:id="@android:id/text1"
                   android:layout_width="fill_parent"
-                  android:layout_height="wrap_content"
+                  android:layout_height="32dp"
                   android:singleLine="true"
                   android:ellipsize="marquee"
-                  android:textAppearance="?android:attr/textAppearanceMedium"
+                  android:textAppearance="?attr/mediaRouteTextStyle"
                   android:duplicateParentState="true" />
 
         <TextView android:id="@android:id/text2"
                   android:layout_width="fill_parent"
-                  android:layout_height="wrap_content"
+                  android:layout_height="24dp"
                   android:singleLine="true"
                   android:ellipsize="marquee"
-                  android:textAppearance="?android:attr/textAppearanceSmall"
+                  android:textAppearance="?attr/mediaRouteSecondaryTextStyle"
                   android:duplicateParentState="true" />
     </LinearLayout>
 
diff --git a/v7/mediarouter/res/values-v17/dimens.xml b/v7/mediarouter/res/values-v17/dimens.xml
deleted file mode 100644
index 41b5479..0000000
--- a/v7/mediarouter/res/values-v17/dimens.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-
-<resources>
-    <dimen name="mr_list_item_margin">24dp</dimen>
-</resources>
\ No newline at end of file
diff --git a/v7/mediarouter/res/values/dimens.xml b/v7/mediarouter/res/values/dimens.xml
index b6c3058..d253f4c 100644
--- a/v7/mediarouter/res/values/dimens.xml
+++ b/v7/mediarouter/res/values/dimens.xml
@@ -16,5 +16,5 @@
 
 <resources>
     <dimen name="mr_media_route_controller_art_max_height">320dp</dimen>
-    <dimen name="mr_list_item_margin">0dp</dimen>
-</resources>
\ No newline at end of file
+    <dimen name="mr_list_item_margin">24dp</dimen>
+</resources>
diff --git a/v7/mediarouter/res/values/styles.xml b/v7/mediarouter/res/values/styles.xml
index 1023f80..8bb9d66 100644
--- a/v7/mediarouter/res/values/styles.xml
+++ b/v7/mediarouter/res/values/styles.xml
@@ -29,6 +29,7 @@
 
     <style name="Widget.MediaRouter.MediaRouteText" parent="">
         <item name="android:fontFamily">sans-serif</item>
+        <item name="android:textStyle">normal</item>
     </style>
 
     <style name="Widget.MediaRouter.MediaRouteText.Primary">
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java b/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
index c4ccdc4..569c736 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
@@ -34,6 +34,7 @@
 import android.support.v7.mediarouter.R;
 import android.text.TextUtils;
 import android.util.Log;
+import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -242,9 +243,11 @@
                     route.getConnectionState() == CONNECTION_STATE_CONNECTED
                             || route.getConnectionState() == CONNECTION_STATE_CONNECTING;
             if (isConnectedOrConnecting && !TextUtils.isEmpty(description)) {
+                text1.setGravity(Gravity.BOTTOM);
                 text2.setVisibility(View.VISIBLE);
                 text2.setText(description);
             } else {
+                text1.setGravity(Gravity.CENTER_VERTICAL);
                 text2.setVisibility(View.GONE);
                 text2.setText("");
             }