Merge "Add content description for output switcher chip" into sc-dev am: c970cc4ab7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15109833

Change-Id: I58d467bb75dcb27626aa2b6d65a32c380b360075
This commit is contained in:
Beth Thibodeau
2021-06-29 15:22:17 +00:00
committed by Automerger Merge Worker
2 changed files with 14 additions and 7 deletions

View File

@@ -347,10 +347,11 @@ public class MediaControlPanel {
artistText.setText(data.getArtist());
// Transfer chip
mPlayerViewHolder.getSeamless().setVisibility(View.VISIBLE);
ViewGroup seamlessView = mPlayerViewHolder.getSeamless();
seamlessView.setVisibility(View.VISIBLE);
setVisibleAndAlpha(collapsedSet, R.id.media_seamless, true /*visible */);
setVisibleAndAlpha(expandedSet, R.id.media_seamless, true /*visible */);
mPlayerViewHolder.getSeamless().setOnClickListener(v -> {
seamlessView.setOnClickListener(v -> {
mMediaOutputDialogFactory.create(data.getPackageName(), true);
});
@@ -374,9 +375,9 @@ public class MediaControlPanel {
collapsedSet.setAlpha(seamlessId, seamlessAlpha);
// Disable clicking on output switcher for resumption controls.
mPlayerViewHolder.getSeamless().setEnabled(!data.getResumption());
String deviceString = null;
if (showFallback) {
iconView.setImageDrawable(null);
deviceName.setText(null);
} else if (device != null) {
Drawable icon = device.getIcon();
iconView.setVisibility(View.VISIBLE);
@@ -387,13 +388,16 @@ public class MediaControlPanel {
} else {
iconView.setImageDrawable(icon);
}
deviceName.setText(device.getName());
deviceString = device.getName();
} else {
// Reset to default
Log.w(TAG, "device is null. Not binding output chip.");
iconView.setVisibility(View.GONE);
deviceName.setText(com.android.internal.R.string.ext_media_seamless_action);
deviceString = mContext.getString(
com.android.internal.R.string.ext_media_seamless_action);
}
deviceName.setText(deviceString);
seamlessView.setContentDescription(deviceString);
List<Integer> actionsWhenCollapsed = data.getActionsToShowInCompact();
// Media controls

View File

@@ -232,6 +232,7 @@ public class MediaControlPanelTest : SysuiTestCase() {
emptyList(), PACKAGE, session.getSessionToken(), null, device, true, null)
player.bindPlayer(state, PACKAGE)
assertThat(seamlessText.getText()).isEqualTo(DEVICE_NAME)
assertThat(seamless.contentDescription).isEqualTo(DEVICE_NAME)
assertThat(seamless.isEnabled()).isTrue()
}
@@ -251,13 +252,15 @@ public class MediaControlPanelTest : SysuiTestCase() {
@Test
fun bindNullDevice() {
val fallbackString = context.getResources().getString(
com.android.internal.R.string.ext_media_seamless_action)
player.attachPlayer(holder)
val state = MediaData(USER_ID, true, BG_COLOR, APP, null, ARTIST, TITLE, null, emptyList(),
emptyList(), PACKAGE, session.getSessionToken(), null, null, true, null)
player.bindPlayer(state, PACKAGE)
assertThat(seamless.isEnabled()).isTrue()
assertThat(seamlessText.getText()).isEqualTo(context.getResources().getString(
com.android.internal.R.string.ext_media_seamless_action))
assertThat(seamlessText.getText()).isEqualTo(fallbackString)
assertThat(seamless.contentDescription).isEqualTo(fallbackString)
}
@Test