Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66c68a4a authored by Andre Le's avatar Andre Le
Browse files

CastDetailsView: Remove route object in MediaRouteControllerDialog

Remove mRoute and mRouter in MediaRouteControllerDialog, since these
variables should be in the content manager only.

This CL follows the refactor mentioned in go/cast-details-view.

Bug: b/395947047
Flag: NONE refactor
Test: Cast to a device, click on the Cast tile, launched the dialog and
verified that the controller works.

Change-Id: I8f43c98fef504004cedda688c3d691788da948e0
parent 6fa5bdd1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -206,6 +206,13 @@ public class MediaRouteControllerContentManager {
        mDelegate.dismissView();
    }

    /**
     * Request the media route to update volume.
     */
    public void requestUpdateRouteVolume(int direction) {
        mRoute.requestUpdateVolume(direction);
    }

    private boolean isVolumeControlAvailable() {
        return mRoute.getVolumeHandling() == MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE;
    }
+2 −9
Original line number Diff line number Diff line
@@ -42,19 +42,11 @@ import com.android.internal.R;
 */
public class MediaRouteControllerDialog extends AlertDialog implements
        MediaRouteControllerContentManager.Delegate {
    // TODO(b/360050020): Eventually these 2 variables should be in the content manager instead of
    //  here. So these should be removed when the migration is completed.
    private final MediaRouter mRouter;
    private final MediaRouter.RouteInfo mRoute;

    private final MediaRouteControllerContentManager mContentManager;

    public MediaRouteControllerDialog(Context context, int theme) {
        super(context, theme);

        mContentManager = new MediaRouteControllerContentManager(context, this);
        mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
        mRoute = mRouter.getSelectedRoute();
    }

    @Override
@@ -91,7 +83,8 @@ public class MediaRouteControllerDialog extends AlertDialog implements
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
                || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            mRoute.requestUpdateVolume(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ? -1 : 1);
            mContentManager.requestUpdateRouteVolume(
                    keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ? -1 : 1);
            return true;
        }
        return super.onKeyDown(keyCode, event);