Skip to content

Commit 3f00ffb

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "MediaRouter/Wifi Display improvements" into jb-mr1-dev
2 parents 2961d11 + 2ee6a2a commit 3f00ffb

24 files changed

+129
-24
lines changed

core/java/android/app/MediaRouteButton.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@ public class MediaRouteButton extends View {
5050
private boolean mRemoteActive;
5151
private boolean mToggleMode;
5252
private boolean mCheatSheetEnabled;
53+
private boolean mIsConnecting;
5354

5455
private int mMinWidth;
5556
private int mMinHeight;
5657

5758
private OnClickListener mExtendedSettingsClickListener;
5859
private MediaRouteChooserDialogFragment mDialogFragment;
5960

61+
private static final int[] CHECKED_STATE_SET = {
62+
R.attr.state_checked
63+
};
64+
6065
private static final int[] ACTIVATED_STATE_SET = {
6166
R.attr.state_activated
6267
};
@@ -210,10 +215,21 @@ public int getRouteTypes() {
210215
}
211216

212217
void updateRemoteIndicator() {
213-
final boolean isRemote =
214-
mRouter.getSelectedRoute(mRouteTypes) != mRouter.getSystemAudioRoute();
218+
final RouteInfo selected = mRouter.getSelectedRoute(mRouteTypes);
219+
final boolean isRemote = selected != mRouter.getSystemAudioRoute();
220+
final boolean isConnecting = selected.getStatusCode() == RouteInfo.STATUS_CONNECTING;
221+
222+
boolean needsRefresh = false;
215223
if (mRemoteActive != isRemote) {
216224
mRemoteActive = isRemote;
225+
needsRefresh = true;
226+
}
227+
if (mIsConnecting != isConnecting) {
228+
mIsConnecting = isConnecting;
229+
needsRefresh = true;
230+
}
231+
232+
if (needsRefresh) {
217233
refreshDrawableState();
218234
}
219235
}
@@ -248,7 +264,14 @@ void updateRouteCount() {
248264
@Override
249265
protected int[] onCreateDrawableState(int extraSpace) {
250266
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
251-
if (mRemoteActive) {
267+
268+
// Technically we should be handling this more completely, but these
269+
// are implementation details here. Checked is used to express the connecting
270+
// drawable state and it's mutually exclusive with activated for the purposes
271+
// of state selection here.
272+
if (mIsConnecting) {
273+
mergeDrawableStates(drawableState, CHECKED_STATE_SET);
274+
} else if (mRemoteActive) {
252275
mergeDrawableStates(drawableState, ACTIVATED_STATE_SET);
253276
}
254277
return drawableState;
@@ -425,6 +448,11 @@ public void onRouteUnselected(MediaRouter router, int type, RouteInfo info) {
425448
updateRemoteIndicator();
426449
}
427450

451+
@Override
452+
public void onRouteChanged(MediaRouter router, RouteInfo info) {
453+
updateRemoteIndicator();
454+
}
455+
428456
@Override
429457
public void onRouteAdded(MediaRouter router, RouteInfo info) {
430458
updateRouteCount();
1.29 KB
Loading
1.31 KB
Loading
1.31 KB
Loading
1.33 KB
Loading
1.33 KB
Loading
1.33 KB
Loading
967 Bytes
Loading
978 Bytes
Loading
976 Bytes
Loading

0 commit comments

Comments
 (0)