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

Commit 7b5a57c4 authored by Adam Powell's avatar Adam Powell Committed by Android Git Automerger
Browse files

am 3f00ffbe: Merge "MediaRouter/Wifi Display improvements" into jb-mr1-dev

* commit '3f00ffbe':
  MediaRouter/Wifi Display improvements
parents 80faaa35 3f00ffbe
Loading
Loading
Loading
Loading
+31 −3
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class MediaRouteButton extends View {
    private boolean mRemoteActive;
    private boolean mToggleMode;
    private boolean mCheatSheetEnabled;
    private boolean mIsConnecting;

    private int mMinWidth;
    private int mMinHeight;
@@ -57,6 +58,10 @@ public class MediaRouteButton extends View {
    private OnClickListener mExtendedSettingsClickListener;
    private MediaRouteChooserDialogFragment mDialogFragment;

    private static final int[] CHECKED_STATE_SET = {
        R.attr.state_checked
    };

    private static final int[] ACTIVATED_STATE_SET = {
        R.attr.state_activated
    };
@@ -210,10 +215,21 @@ public class MediaRouteButton extends View {
    }

    void updateRemoteIndicator() {
        final boolean isRemote =
                mRouter.getSelectedRoute(mRouteTypes) != mRouter.getSystemAudioRoute();
        final RouteInfo selected = mRouter.getSelectedRoute(mRouteTypes);
        final boolean isRemote = selected != mRouter.getSystemAudioRoute();
        final boolean isConnecting = selected.getStatusCode() == RouteInfo.STATUS_CONNECTING;

        boolean needsRefresh = false;
        if (mRemoteActive != isRemote) {
            mRemoteActive = isRemote;
            needsRefresh = true;
        }
        if (mIsConnecting != isConnecting) {
            mIsConnecting = isConnecting;
            needsRefresh = true;
        }

        if (needsRefresh) {
            refreshDrawableState();
        }
    }
@@ -248,7 +264,14 @@ public class MediaRouteButton extends View {
    @Override
    protected int[] onCreateDrawableState(int extraSpace) {
        final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
        if (mRemoteActive) {

        // Technically we should be handling this more completely, but these
        // are implementation details here. Checked is used to express the connecting
        // drawable state and it's mutually exclusive with activated for the purposes
        // of state selection here.
        if (mIsConnecting) {
            mergeDrawableStates(drawableState, CHECKED_STATE_SET);
        } else if (mRemoteActive) {
            mergeDrawableStates(drawableState, ACTIVATED_STATE_SET);
        }
        return drawableState;
@@ -425,6 +448,11 @@ public class MediaRouteButton extends View {
            updateRemoteIndicator();
        }

        @Override
        public void onRouteChanged(MediaRouter router, RouteInfo info) {
            updateRemoteIndicator();
        }

        @Override
        public void onRouteAdded(MediaRouter router, RouteInfo info) {
            updateRouteCount();
+1.29 KiB
Loading image diff...
+1.31 KiB
Loading image diff...
+1.31 KiB
Loading image diff...
+1.33 KiB
Loading image diff...
Loading