Merge "Use label instead of cast icon in output switcher" into sc-qpr1-dev

This commit is contained in:
TreeHugger Robot
2021-09-03 23:53:48 +00:00
committed by Android (Google) Code Review
9 changed files with 32 additions and 81 deletions

View File

@@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,4H4c-1.1,0 -2,0.9 -2,2v11c0,1.1 0.9,2 2,2h4v2h3v-4H4V6h16v1h2V6c0,-1.1 -0.9,-2 -2,-2z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M17.5,16.5m-2.33,0a2.33,2.33 0,1 1,4.66 0a2.33,2.33 0,1 1,-4.66 0"/>
<path
android:fillColor="@android:color/white"
android:pathData="M21,8h-7c-0.55,0 -1,0.45 -1,1v11c0,0.55 0.45,1 1,1h7c0.55,0 1,-0.45 1,-1L22,9c0,-0.55 -0.45,-1 -1,-1zM17.5,9c0.83,0 1.5,0.67 1.5,1.5s-0.67,1.5 -1.5,1.5 -1.5,-0.67 -1.5,-1.5 0.67,-1.5 1.5,-1.5zM17.5,20c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
</vector>

View File

@@ -163,18 +163,6 @@
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/media_seamless_fallback"
android:layout_width="@dimen/qs_seamless_fallback_icon_size"
android:layout_height="@dimen/qs_seamless_fallback_icon_size"
android:layout_marginTop="@dimen/qs_media_padding"
android:layout_marginBottom="@dimen/qs_media_padding"
android:layout_marginStart="@dimen/qs_center_guideline_padding"
android:layout_marginEnd="@dimen/qs_seamless_fallback_margin"
android:tint="?android:attr/textColor"
android:src="@drawable/ic_cast_connected"
android:forceHasOverlappingRendering="false" />
<!-- Seek Bar -->
<!-- As per Material Design on Biderectionality, this is forced to LTR in code -->
<SeekBar

View File

@@ -1298,8 +1298,6 @@
<dimen name="qs_media_action_margin">12dp</dimen>
<dimen name="qs_seamless_height">24dp</dimen>
<dimen name="qs_seamless_icon_size">12dp</dimen>
<dimen name="qs_seamless_fallback_icon_size">@dimen/qs_seamless_icon_size</dimen>
<dimen name="qs_seamless_fallback_margin">20dp</dimen>
<dimen name="qs_footer_horizontal_margin">22dp</dimen>
<dimen name="qs_media_disabled_seekbar_height">1dp</dimen>
<dimen name="qs_media_enabled_seekbar_height">2dp</dimen>

View File

@@ -1008,7 +1008,7 @@
<string name="sensor_privacy_start_use_mic_camera_dialog_content">This unblocks access for all apps and services allowed to use your camera or microphone.</string>
<!-- Default name for the media device shown in the output switcher when the name is not available [CHAR LIMIT=30] -->
<string name="media_seamless_remote_device">Device</string>
<string name="media_seamless_other_device">Other device</string>
<!-- QuickStep: Accessibility to toggle overview [CHAR LIMIT=40] -->
<string name="quick_step_accessibility_toggle_overview">Toggle Overview</string>

View File

@@ -43,23 +43,6 @@
android:layout_marginStart="@dimen/qs_center_guideline_padding"
/>
<Constraint
android:id="@+id/media_seamless_fallback"
android:layout_width="@dimen/qs_seamless_fallback_icon_size"
android:layout_height="@dimen/qs_seamless_fallback_icon_size"
android:layout_marginTop="@dimen/qs_media_padding"
android:layout_marginBottom="@dimen/qs_media_padding"
android:layout_marginStart="@dimen/qs_center_guideline_padding"
android:layout_marginEnd="@dimen/qs_seamless_fallback_margin"
android:alpha="0.5"
android:visibility="gone"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/center_horizontal_guideline"
app:layout_constraintStart_toEndOf="@id/center_vertical_guideline"
app:layout_constraintEnd_toEndOf="parent"
/>
<Constraint
android:id="@+id/album_art"
android:layout_width="@dimen/qs_media_album_size_small"

View File

@@ -44,22 +44,6 @@
android:layout_marginStart="@dimen/qs_center_guideline_padding"
android:layout_marginBottom="4dp" />
<Constraint
android:id="@+id/media_seamless_fallback"
android:layout_width="@dimen/qs_seamless_fallback_icon_size"
android:layout_height="@dimen/qs_seamless_fallback_icon_size"
android:layout_marginTop="@dimen/qs_media_padding"
android:layout_marginBottom="16dp"
android:layout_marginStart="@dimen/qs_center_guideline_padding"
android:layout_marginEnd="@dimen/qs_seamless_fallback_margin"
android:alpha="0.5"
android:visibility="gone"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/center_vertical_guideline"
app:layout_constraintEnd_toEndOf="parent"
/>
<Constraint
android:id="@+id/album_art"
android:layout_width="@dimen/qs_media_album_size"

View File

@@ -370,27 +370,16 @@ public class MediaControlPanel {
final MediaDeviceData device = data.getDevice();
final int seamlessId = mPlayerViewHolder.getSeamless().getId();
final int seamlessFallbackId = mPlayerViewHolder.getSeamlessFallback().getId();
final boolean showFallback = device != null && !device.getEnabled();
final int seamlessFallbackVisibility = showFallback ? View.VISIBLE : View.GONE;
mPlayerViewHolder.getSeamlessFallback().setVisibility(seamlessFallbackVisibility);
expandedSet.setVisibility(seamlessFallbackId, seamlessFallbackVisibility);
collapsedSet.setVisibility(seamlessFallbackId, seamlessFallbackVisibility);
final int seamlessVisibility = showFallback ? View.GONE : View.VISIBLE;
mPlayerViewHolder.getSeamless().setVisibility(seamlessVisibility);
expandedSet.setVisibility(seamlessId, seamlessVisibility);
collapsedSet.setVisibility(seamlessId, seamlessVisibility);
final float seamlessAlpha = data.getResumption() ? DISABLED_ALPHA : 1.0f;
// Disable clicking on output switcher for invalid devices and resumption controls
final boolean seamlessDisabled = (device != null && !device.getEnabled())
|| data.getResumption();
final float seamlessAlpha = seamlessDisabled ? DISABLED_ALPHA : 1.0f;
expandedSet.setAlpha(seamlessId, seamlessAlpha);
collapsedSet.setAlpha(seamlessId, seamlessAlpha);
// Disable clicking on output switcher for resumption controls.
mPlayerViewHolder.getSeamless().setEnabled(!data.getResumption());
mPlayerViewHolder.getSeamless().setEnabled(!seamlessDisabled);
String deviceString = null;
if (showFallback) {
iconView.setImageDrawable(null);
} else if (device != null) {
if (device != null && device.getEnabled()) {
Drawable icon = device.getIcon();
iconView.setVisibility(View.VISIBLE);
if (icon instanceof AdaptiveIcon) {
AdaptiveIcon aIcon = (AdaptiveIcon) icon;
aIcon.setBackgroundColor(mBackgroundColor);
@@ -401,10 +390,9 @@ public class MediaControlPanel {
deviceString = device.getName();
} else {
// Reset to default
Log.w(TAG, "device is null. Not binding output chip.");
iconView.setVisibility(View.GONE);
deviceString = mContext.getString(
com.android.internal.R.string.ext_media_seamless_action);
Log.w(TAG, "Device is null or not enabled: " + device + ", not binding output chip.");
iconView.setImageResource(R.drawable.ic_media_home_devices);
deviceString = mContext.getString(R.string.media_seamless_other_device);
}
deviceName.setText(deviceString);
seamlessView.setContentDescription(deviceString);

View File

@@ -43,7 +43,6 @@ class PlayerViewHolder private constructor(itemView: View) {
val seamless = itemView.requireViewById<ViewGroup>(R.id.media_seamless)
val seamlessIcon = itemView.requireViewById<ImageView>(R.id.media_seamless_image)
val seamlessText = itemView.requireViewById<TextView>(R.id.media_seamless_text)
val seamlessFallback = itemView.requireViewById<ImageView>(R.id.media_seamless_fallback)
// Seek bar
val seekBar = itemView.requireViewById<SeekBar>(R.id.media_progress_bar)
@@ -124,7 +123,6 @@ class PlayerViewHolder private constructor(itemView: View) {
R.id.header_title,
R.id.header_artist,
R.id.media_seamless,
R.id.media_seamless_fallback,
R.id.notification_media_progress_time,
R.id.media_progress_bar,
R.id.action0,

View File

@@ -37,6 +37,7 @@ import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.LiveData
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.media.dialog.MediaOutputDialogFactory
import com.android.systemui.plugins.ActivityStarter
@@ -101,7 +102,6 @@ public class MediaControlPanelTest : SysuiTestCase() {
private lateinit var seamless: ViewGroup
private lateinit var seamlessIcon: ImageView
private lateinit var seamlessText: TextView
private lateinit var seamlessFallback: ImageView
private lateinit var seekBar: SeekBar
private lateinit var elapsedTimeView: TextView
private lateinit var totalTimeView: TextView
@@ -154,8 +154,6 @@ public class MediaControlPanelTest : SysuiTestCase() {
whenever(holder.seamlessIcon).thenReturn(seamlessIcon)
seamlessText = TextView(context)
whenever(holder.seamlessText).thenReturn(seamlessText)
seamlessFallback = ImageView(context)
whenever(holder.seamlessFallback).thenReturn(seamlessFallback)
seekBar = SeekBar(context)
whenever(holder.seekBar).thenReturn(seekBar)
elapsedTimeView = TextView(context)
@@ -239,21 +237,19 @@ public class MediaControlPanelTest : SysuiTestCase() {
@Test
fun bindDisabledDevice() {
seamless.id = 1
seamlessFallback.id = 2
val fallbackString = context.getString(R.string.media_seamless_other_device)
player.attachPlayer(holder)
val state = MediaData(USER_ID, true, BG_COLOR, APP, null, ARTIST, TITLE, null, emptyList(),
emptyList(), PACKAGE, session.getSessionToken(), null, disabledDevice, true, null)
player.bindPlayer(state, PACKAGE)
verify(expandedSet).setVisibility(seamless.id, View.GONE)
verify(expandedSet).setVisibility(seamlessFallback.id, View.VISIBLE)
verify(collapsedSet).setVisibility(seamless.id, View.GONE)
verify(collapsedSet).setVisibility(seamlessFallback.id, View.VISIBLE)
assertThat(seamless.isEnabled()).isFalse()
assertThat(seamlessText.getText()).isEqualTo(fallbackString)
assertThat(seamless.contentDescription).isEqualTo(fallbackString)
}
@Test
fun bindNullDevice() {
val fallbackString = context.getResources().getString(
com.android.internal.R.string.ext_media_seamless_action)
val fallbackString = context.getResources().getString(R.string.media_seamless_other_device)
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)