diff options
author | Adam Powell <adamp@google.com> | 2012-10-01 15:01:25 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-01 15:01:25 -0700 |
commit | 3f00ffbe2b97f8acd9edcd683ed48cc65710e6f1 (patch) | |
tree | e9b243e5fb59c3428b9cdfa9651730db54eae848 /core/java | |
parent | 2961d111570d310b3ba504784e7cff651bc93207 (diff) | |
parent | 2ee6a2a83262d05a566bd713d238e89edfd33a29 (diff) | |
download | frameworks_base-3f00ffbe2b97f8acd9edcd683ed48cc65710e6f1.zip frameworks_base-3f00ffbe2b97f8acd9edcd683ed48cc65710e6f1.tar.gz frameworks_base-3f00ffbe2b97f8acd9edcd683ed48cc65710e6f1.tar.bz2 |
Merge "MediaRouter/Wifi Display improvements" into jb-mr1-dev
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/MediaRouteButton.java | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/core/java/android/app/MediaRouteButton.java b/core/java/android/app/MediaRouteButton.java index a9ccef0..3ecafc3 100644 --- a/core/java/android/app/MediaRouteButton.java +++ b/core/java/android/app/MediaRouteButton.java @@ -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; @@ -426,6 +449,11 @@ public class MediaRouteButton extends View { } @Override + public void onRouteChanged(MediaRouter router, RouteInfo info) { + updateRemoteIndicator(); + } + + @Override public void onRouteAdded(MediaRouter router, RouteInfo info) { updateRouteCount(); } |