From c981dc94eff8d675c77edf9c344ce50c5035dfef Mon Sep 17 00:00:00 2001 From: Robert Snoeberger Date: Mon, 27 Apr 2020 15:00:50 -0400 Subject: [PATCH] Show "Device" for remote playback device. Since we currently don't have access to the name of a remote device, show a default string "Device" for the device name. In addition, disable tap on the output switcher. Fixes: 151486245 Test: manual - cast GPM to home mini and check output switcher in player for correct icon and string. Additionally, check that tap is disabled. Change-Id: I31d81f00f0b506b1e2ddc3158043e93cc6db35a8 --- .../res/drawable/ic_hardware_speaker.xml | 24 +++++++++++++++++++ .../SystemUI/res/layout/qs_media_panel.xml | 1 + packages/SystemUI/res/values/strings.xml | 3 +++ .../systemui/media/MediaControlPanel.java | 22 ++++++++++++++++- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 packages/SystemUI/res/drawable/ic_hardware_speaker.xml diff --git a/packages/SystemUI/res/drawable/ic_hardware_speaker.xml b/packages/SystemUI/res/drawable/ic_hardware_speaker.xml new file mode 100644 index 0000000000000..0081e56a45f21 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_hardware_speaker.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/layout/qs_media_panel.xml b/packages/SystemUI/res/layout/qs_media_panel.xml index e5ac5f89cd25a..a194569dcca4f 100644 --- a/packages/SystemUI/res/layout/qs_media_panel.xml +++ b/packages/SystemUI/res/layout/qs_media_panel.xml @@ -119,6 +119,7 @@ android:id="@+id/media_seamless" android:background="@*android:drawable/media_seamless_background" android:layout_weight="1" + android:forceHasOverlappingRendering="false" > Stop + + Device + Swipe up to switch apps diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java index ddc9c9d7c3148..b12d02d26b9be 100644 --- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java +++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java @@ -36,6 +36,7 @@ import android.media.MediaDescription; import android.media.MediaMetadata; import android.media.ThumbnailUtils; import android.media.session.MediaController; +import android.media.session.MediaController.PlaybackInfo; import android.media.session.MediaSession; import android.media.session.PlaybackState; import android.net.Uri; @@ -96,6 +97,7 @@ public class MediaControlPanel { public static final String MEDIA_PREFERENCE_KEY = "browser_components"; private SharedPreferences mSharedPrefs; private boolean mCheckedForResumption = false; + private boolean mIsRemotePlayback; // Button IDs used in notifications protected static final int[] NOTIF_ACTION_IDS = { @@ -300,6 +302,13 @@ public class MediaControlPanel { Log.d(TAG, "LocalMediaManager is null. Not binding output chip for pkg=" + pkgName); } } + PlaybackInfo playbackInfo = mController.getPlaybackInfo(); + if (playbackInfo != null) { + mIsRemotePlayback = playbackInfo.getPlaybackType() == PlaybackInfo.PLAYBACK_TYPE_REMOTE; + } else { + Log.d(TAG, "PlaybackInfo was null. Defaulting to local playback."); + mIsRemotePlayback = false; + } makeActive(); @@ -545,7 +554,16 @@ public class MediaControlPanel { TextView deviceName = mSeamless.findViewById(R.id.media_seamless_text); deviceName.setTextColor(fgTintList); - if (device != null) { + if (mIsRemotePlayback) { + mSeamless.setEnabled(false); + mSeamless.setAlpha(0.38f); + iconView.setImageResource(R.drawable.ic_hardware_speaker); + iconView.setVisibility(View.VISIBLE); + iconView.setImageTintList(fgTintList); + deviceName.setText(R.string.media_seamless_remote_device); + } else if (device != null) { + mSeamless.setEnabled(true); + mSeamless.setAlpha(1f); Drawable icon = device.getIcon(); iconView.setVisibility(View.VISIBLE); iconView.setImageTintList(fgTintList); @@ -561,6 +579,8 @@ public class MediaControlPanel { } else { // Reset to default Log.d(TAG, "device is null. Not binding output chip."); + mSeamless.setEnabled(true); + mSeamless.setAlpha(1f); iconView.setVisibility(View.GONE); deviceName.setText(com.android.internal.R.string.ext_media_seamless_action); }