public class MediaRouteActionProvider extends android.view.ActionProvider {
ctor public MediaRouteActionProvider(android.content.Context);
method public android.view.View onCreateActionView();
+ method public void setExtendedSettingsClickListener(android.view.View.OnClickListener);
method public void setRouteTypes(int);
}
ctor public MediaRouteButton(android.content.Context, android.util.AttributeSet);
ctor public MediaRouteButton(android.content.Context, android.util.AttributeSet, int);
method public int getRouteTypes();
+ method public void setExtendedSettingsClickListener(android.view.View.OnClickListener);
method public void setRouteTypes(int);
}
private MediaRouteButton mView;
private int mRouteTypes;
private final RouterCallback mRouterCallback = new RouterCallback();
+ private View.OnClickListener mExtendedSettingsListener;
public MediaRouteActionProvider(Context context) {
super(context);
mContext = context;
- mRouter = (MediaRouter)context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
+ mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
// Start with live audio by default.
// TODO Update this when new route types are added; segment by API level
mView = new MediaRouteButton(mContext);
mMenuItem.setVisible(mRouter.getRouteCount() > 1);
mView.setRouteTypes(mRouteTypes);
+ mView.setExtendedSettingsClickListener(mExtendedSettingsListener);
return mView;
}
return true;
}
+ public void setExtendedSettingsClickListener(View.OnClickListener listener) {
+ mExtendedSettingsListener = listener;
+ if (mView != null) {
+ mView.setExtendedSettingsClickListener(listener);
+ }
+ }
+
private class RouterCallback extends MediaRouter.SimpleCallback {
@Override
public void onRouteAdded(MediaRouter router, RouteInfo info) {
private int mMinWidth;
private int mMinHeight;
+ private OnClickListener mExtendedSettingsClickListener;
+
private static final int[] ACTIVATED_STATE_SET = {
R.attr.state_activated
};
mRemoteIndicator.draw(canvas);
}
+ public void setExtendedSettingsClickListener(OnClickListener listener) {
+ // TODO: if dialog is already open, propagate so that it updates live.
+ mExtendedSettingsClickListener = listener;
+ }
+
private class MediaRouteCallback extends MediaRouter.SimpleCallback {
@Override
public void onRouteSelected(MediaRouter router, int type, RouteInfo info) {
private static final String TAG = "MediaRouter";
static class Static {
- private final Resources mResources;
- private final AudioManager mAudioManager;
- private final Handler mHandler;
- private final ArrayList<CallbackInfo> mCallbacks = new ArrayList<CallbackInfo>();
+ final Resources mResources;
+ final AudioManager mAudioManager;
+ final Handler mHandler;
+ final ArrayList<CallbackInfo> mCallbacks = new ArrayList<CallbackInfo>();
- private final ArrayList<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
- private final ArrayList<RouteCategory> mCategories = new ArrayList<RouteCategory>();
+ final ArrayList<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
+ final ArrayList<RouteCategory> mCategories = new ArrayList<RouteCategory>();
- private final RouteCategory mSystemCategory;
- private final HeadphoneChangedBroadcastReceiver mHeadphoneChangedReceiver;
+ final RouteCategory mSystemCategory;
+ final HeadphoneChangedBroadcastReceiver mHeadphoneChangedReceiver;
- private RouteInfo mDefaultAudio;
- private RouteInfo mBluetoothA2dpRoute;
+ RouteInfo mDefaultAudio;
+ RouteInfo mBluetoothA2dpRoute;
- private RouteInfo mSelectedRoute;
+ RouteInfo mSelectedRoute;
Static(Context appContext) {
mResources = Resources.getSystem();
speakerFilter.addAction(Intent.ACTION_HDMI_AUDIO_PLUG);
mHeadphoneChangedReceiver = new HeadphoneChangedBroadcastReceiver();
appContext.registerReceiver(mHeadphoneChangedReceiver, speakerFilter);
+ }
+ // Called after sStatic is initialized
+ void initDefaultRoutes() {
mDefaultAudio = new RouteInfo(mSystemCategory);
mDefaultAudio.mName = mResources.getText(
com.android.internal.R.string.default_audio_route_name);
synchronized (Static.class) {
if (sStatic == null) {
sStatic = new Static(context.getApplicationContext());
+ sStatic.initDefaultRoutes();
}
}
}