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

This commit is contained in:
Beth Thibodeau
2021-06-29 15:14:42 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 7 deletions

View File

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

View File

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