Remove route icons from the API and the UI.
Bug: 8175766
Change-Id: Ic376cb99455fff1e48aa7d3243365aa7cb94659b
diff --git a/v7/mediarouter/res/layout-v17/media_route_list_item.xml b/v7/mediarouter/res/layout-v17/media_route_list_item.xml
index 1b7ddf0..1b798ee 100644
--- a/v7/mediarouter/res/layout-v17/media_route_list_item.xml
+++ b/v7/mediarouter/res/layout-v17/media_route_list_item.xml
@@ -19,12 +19,6 @@
android:layout_height="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical">
- <ImageView android:id="@android:id/icon"
- android:layout_width="56dp"
- android:layout_height="56dp"
- android:scaleType="center"
- android:duplicateParentState="true" />
-
<LinearLayout android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
diff --git a/v7/mediarouter/res/layout/media_route_list_item.xml b/v7/mediarouter/res/layout/media_route_list_item.xml
index 5d8942d..6c63a12 100644
--- a/v7/mediarouter/res/layout/media_route_list_item.xml
+++ b/v7/mediarouter/res/layout/media_route_list_item.xml
@@ -19,13 +19,6 @@
android:layout_height="64dp"
android:gravity="center_vertical">
- <ImageView android:id="@android:id/icon"
- android:layout_width="56dp"
- android:layout_height="56dp"
- android:scaleType="center"
- android:visibility="gone"
- android:duplicateParentState="true" />
-
<LinearLayout android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java b/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
index ee92b41..dd25aff 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouteChooserDialog.java
@@ -22,13 +22,13 @@
import android.support.v7.media.MediaRouter;
import android.support.v7.media.MediaRouteSelector;
import android.support.v7.mediarouter.R;
+import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
-import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -181,13 +181,17 @@
if (view == null) {
view = mInflater.inflate(R.layout.media_route_list_item, parent, false);
}
+ MediaRouter.RouteInfo route = getItem(position);
TextView text1 = (TextView)view.findViewById(android.R.id.text1);
TextView text2 = (TextView)view.findViewById(android.R.id.text2);
- ImageView icon = (ImageView)view.findViewById(android.R.id.icon);
- MediaRouter.RouteInfo route = getItem(position);
text1.setText(route.getName());
- text2.setText(route.getStatus());
- icon.setImageDrawable(route.getIconDrawable());
+ String status = route.getStatus();
+ if (TextUtils.isEmpty(status)) {
+ text2.setVisibility(View.GONE);
+ } else {
+ text2.setVisibility(View.VISIBLE);
+ text2.setText(status);
+ }
view.setEnabled(route.isEnabled());
return view;
}
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaRouteDescriptor.java b/v7/mediarouter/src/android/support/v7/media/MediaRouteDescriptor.java
index 79f18ac..774d6d4 100644
--- a/v7/mediarouter/src/android/support/v7/media/MediaRouteDescriptor.java
+++ b/v7/mediarouter/src/android/support/v7/media/MediaRouteDescriptor.java
@@ -16,7 +16,6 @@
package android.support.v7.media;
import android.content.IntentFilter;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
@@ -39,7 +38,6 @@
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_STATUS = "status";
- private static final String KEY_ICON_RESOURCE = "iconResource";
private static final String KEY_ENABLED = "enabled";
private static final String KEY_CONNECTING = "connecting";
private static final String KEY_CONTROL_FILTERS = "controlFilters";
@@ -52,13 +50,10 @@
private static final String KEY_EXTRAS = "extras";
private final Bundle mBundle;
- private final Drawable mIconDrawable;
private List<IntentFilter> mControlFilters;
- private MediaRouteDescriptor(Bundle bundle, Drawable iconDrawable,
- List<IntentFilter> controlFilters) {
+ private MediaRouteDescriptor(Bundle bundle, List<IntentFilter> controlFilters) {
mBundle = bundle;
- mIconDrawable = iconDrawable;
mControlFilters = controlFilters;
}
@@ -84,28 +79,6 @@
}
/**
- * Gets a drawable to display as the route's icon.
- * <p>
- * Because drawables cannot be transferred to other processes, the icon resource
- * is usually passed in {@link #getIconResource} instead.
- * </p>
- */
- public Drawable getIconDrawable() {
- return mIconDrawable;
- }
-
- /**
- * Gets the id of a drawable resource to display as the route's icon.
- * <p>
- * The specified drawable resource id will be loaded from the media route
- * provider's package.
- * </p>
- */
- public int getIconResource() {
- return mBundle.getInt(KEY_ICON_RESOURCE);
- }
-
- /**
* Gets whether the route is enabled.
*/
public boolean isEnabled() {
@@ -211,8 +184,6 @@
result.append(", isEnabled=").append(isEnabled());
result.append(", isConnecting=").append(isConnecting());
result.append(", controlFilters=").append(Arrays.toString(getControlFilters().toArray()));
- result.append(", iconDrawable=").append(getIconDrawable());
- result.append(", iconResource=").append(getIconResource());
result.append(", playbackType=").append(getPlaybackType());
result.append(", playbackStream=").append(getPlaybackStream());
result.append(", volume=").append(getVolume());
@@ -241,7 +212,7 @@
* @return The new instance, or null if the bundle was null.
*/
public static MediaRouteDescriptor fromBundle(Bundle bundle) {
- return bundle != null ? new MediaRouteDescriptor(bundle, null, null) : null;
+ return bundle != null ? new MediaRouteDescriptor(bundle, null) : null;
}
/**
@@ -249,7 +220,6 @@
*/
public static final class Builder {
private final Bundle mBundle;
- private Drawable mIconDrawable;
private ArrayList<IntentFilter> mControlFilters;
/**
@@ -274,7 +244,6 @@
}
mBundle = new Bundle(descriptor.mBundle);
- mIconDrawable = descriptor.mIconDrawable;
descriptor.ensureControlFilters();
if (!descriptor.mControlFilters.isEmpty()) {
@@ -307,32 +276,6 @@
}
/**
- * Sets a drawable to display as the route's icon.
- * <p>
- * Because drawables cannot be transferred to other processes, this method may
- * only be used by media route providers that reside in the same process
- * as the application. When implementing a media route provider service, use
- * {@link #setIconResource} instead.
- * </p>
- */
- public Builder setIconDrawable(Drawable drawable) {
- mIconDrawable = drawable;
- return this;
- }
-
- /**
- * Sets the id of a drawable resource to display as the route's icon.
- * <p>
- * The specified drawable resource id will be loaded from the media route
- * provider's package.
- * </p>
- */
- public Builder setIconResource(int id) {
- mBundle.putInt(KEY_ICON_RESOURCE, id);
- return this;
- }
-
- /**
* Sets whether the route is enabled.
* <p>
* Disabled routes represent routes that a route provider knows about, such as paired
@@ -451,7 +394,7 @@
if (mControlFilters != null) {
mBundle.putParcelableArrayList(KEY_CONTROL_FILTERS, mControlFilters);
}
- return new MediaRouteDescriptor(mBundle, mIconDrawable, mControlFilters);
+ return new MediaRouteDescriptor(mBundle, mControlFilters);
}
}
}
\ No newline at end of file
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaRouter.java b/v7/mediarouter/src/android/support/v7/media/MediaRouter.java
index 47c8a69..74be827 100644
--- a/v7/mediarouter/src/android/support/v7/media/MediaRouter.java
+++ b/v7/mediarouter/src/android/support/v7/media/MediaRouter.java
@@ -22,7 +22,6 @@
import android.content.IntentFilter;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -525,8 +524,6 @@
private final String mDescriptorId;
private String mName;
private String mStatus;
- private Drawable mIconDrawable;
- private int mIconResource;
private boolean mEnabled;
private boolean mConnecting;
private final ArrayList<IntentFilter> mControlFilters = new ArrayList<IntentFilter>();
@@ -612,30 +609,6 @@
}
/**
- * Get the icon representing this route.
- * This icon will be used in picker UIs if available.
- *
- * @return The icon representing this route or null if no icon is available.
- */
- public Drawable getIconDrawable() {
- checkCallingThread();
- if (mIconDrawable == null) {
- if (mIconResource != 0) {
- Resources resources = mProvider.getResources();
- if (resources != null) {
- try {
- mIconDrawable = resources.getDrawable(mIconResource);
- } catch (Resources.NotFoundException ex) {
- Log.w(TAG, "Unable to load media route icon drawable resource "
- + "from provider.", ex);
- }
- }
- }
- }
- return mIconDrawable;
- }
-
- /**
* Returns true if this route is enabled and may be selected.
*
* @return True if this route is enabled.
@@ -961,16 +934,6 @@
mStatus = descriptor.getStatus();
changes |= CHANGE_GENERAL;
}
- if (mIconResource != descriptor.getIconResource()) {
- mIconResource = descriptor.getIconResource();
- mIconDrawable = null;
- changes |= CHANGE_GENERAL;
- }
- if (mIconResource == 0
- && mIconDrawable != descriptor.getIconDrawable()) {
- mIconDrawable = descriptor.getIconDrawable();
- changes |= CHANGE_GENERAL;
- }
if (mEnabled != descriptor.isEnabled()) {
mEnabled = descriptor.isEnabled();
changes |= CHANGE_GENERAL;
diff --git a/v7/mediarouter/src/android/support/v7/media/SystemMediaRouteProvider.java b/v7/mediarouter/src/android/support/v7/media/SystemMediaRouteProvider.java
index 989519c..0a2a61f 100644
--- a/v7/mediarouter/src/android/support/v7/media/SystemMediaRouteProvider.java
+++ b/v7/mediarouter/src/android/support/v7/media/SystemMediaRouteProvider.java
@@ -569,8 +569,6 @@
if (status != null) {
builder.setStatus(status.toString());
}
- builder.setIconDrawable(
- MediaRouterJellybean.RouteInfo.getIconDrawable(record.mRouteObj));
builder.setPlaybackType(
MediaRouterJellybean.RouteInfo.getPlaybackType(record.mRouteObj));
builder.setPlaybackStream(
@@ -588,8 +586,6 @@
record.mRouteObj, record.mRoute.getName());
MediaRouterJellybean.UserRouteInfo.setStatus(
record.mRouteObj, normalizeStatus(record.mRoute.getStatus()));
- MediaRouterJellybean.UserRouteInfo.setIconDrawable(
- record.mRouteObj, record.mRoute.getIconDrawable());
MediaRouterJellybean.UserRouteInfo.setPlaybackType(
record.mRouteObj, record.mRoute.getPlaybackType());
MediaRouterJellybean.UserRouteInfo.setPlaybackStream(