From 53ed17fffcc06fccb18f958113d1bbdeb5b9e403 Mon Sep 17 00:00:00 2001 From: shaoweishen Date: Mon, 8 May 2023 15:46:06 +0000 Subject: [Output Switcher] Fix SASS device update in U SASS device should also work in U, this change fixs color update for SASS device layout, consistently use setBackgroundTintList. Bug: 281521758 Test: atest MediaOutputAdapterTest Change-Id: Ie9fe55b829d6326ac22322b6c4a1b38b15726119 --- .../systemui/media/dialog/MediaOutputAdapter.java | 2 +- .../media/dialog/MediaOutputBaseAdapter.java | 25 ++++++++++------------ .../media/dialog/MediaOutputAdapterTest.java | 5 ++++- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java index d949cf56ff0e..162766289ba4 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java @@ -207,10 +207,10 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { updateTitleIcon(R.drawable.media_output_icon_volume, mController.getColorItemContent()); } - initMutingExpectedDevice(); mCurrentActivePosition = position; updateFullItemClickListener(v -> onItemClick(v, device)); setSingleLineLayout(getItemTitle(device)); + initMutingExpectedDevice(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && mController.isSubStatusSupported() && mController.isAdvancedLayoutSupported() && device.hasSubtext()) { diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java index 151dbb2746aa..6ebda40a8001 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java @@ -47,7 +47,6 @@ import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import androidx.recyclerview.widget.RecyclerView; -import com.android.settingslib.Utils; import com.android.settingslib.media.MediaDevice; import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.R; @@ -277,9 +276,10 @@ public abstract class MediaOutputBaseAdapter extends backgroundDrawable = mContext.getDrawable( showSeekBar || isFakeActive ? R.drawable.media_output_item_background_active : R.drawable.media_output_item_background).mutate(); - backgroundDrawable.setTint( + mItemLayout.setBackgroundTintList(ColorStateList.valueOf( showSeekBar || isFakeActive ? mController.getColorConnectedItemBackground() - : mController.getColorItemBackground()); + : mController.getColorItemBackground() + )); mIconAreaLayout.setBackgroundTintList( ColorStateList.valueOf(showProgressBar || isFakeActive ? mController.getColorConnectedItemBackground() @@ -299,7 +299,8 @@ public abstract class MediaOutputBaseAdapter extends backgroundDrawable = mContext.getDrawable( R.drawable.media_output_item_background) .mutate(); - backgroundDrawable.setTint(mController.getColorItemBackground()); + mItemLayout.setBackgroundTintList( + ColorStateList.valueOf(mController.getColorItemBackground())); } mItemLayout.setBackground(backgroundDrawable); mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE); @@ -455,11 +456,16 @@ public abstract class MediaOutputBaseAdapter extends void initMutingExpectedDevice() { disableSeekBar(); + updateTitleIcon(R.drawable.media_output_icon_volume, + mController.getColorItemContent()); final Drawable backgroundDrawable = mContext.getDrawable( R.drawable.media_output_item_background_active) .mutate(); - backgroundDrawable.setTint(mController.getColorConnectedItemBackground()); mItemLayout.setBackground(backgroundDrawable); + mItemLayout.setBackgroundTintList( + ColorStateList.valueOf(mController.getColorConnectedItemBackground())); + mIconAreaLayout.setBackgroundTintList( + ColorStateList.valueOf(mController.getColorConnectedItemBackground())); } private void animateCornerAndVolume(int fromProgress, int toProgress) { @@ -530,14 +536,6 @@ public abstract class MediaOutputBaseAdapter extends }); } - Drawable getSpeakerDrawable() { - final Drawable drawable = mContext.getDrawable(R.drawable.ic_speaker_group_black_24dp) - .mutate(); - drawable.setTint(Utils.getColorStateListDefaultColor(mContext, - R.color.media_dialog_item_main_content)); - return drawable; - } - protected void disableSeekBar() { mSeekBar.setEnabled(false); mSeekBar.setOnTouchListener((v, event) -> true); @@ -574,7 +572,6 @@ public abstract class MediaOutputBaseAdapter extends return; } mTitleIcon.setImageIcon(icon); - icon.setTint(mController.getColorItemContent()); mTitleIcon.setImageTintList( ColorStateList.valueOf(mController.getColorItemContent())); }); diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.java b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.java index faca8a91d6b3..9b26d9c1a249 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.java @@ -347,10 +347,13 @@ public class MediaOutputAdapterTest extends SysuiTestCase { } @Test - public void onBindViewHolder_isMutingExpectedDevice_verifyView() { + public void advanced_onBindViewHolder_isMutingExpectedDevice_verifyView() { + when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true); when(mMediaDevice1.isMutingExpectedDevice()).thenReturn(true); when(mMediaOutputController.isCurrentConnectedDeviceRemote()).thenReturn(false); when(mMediaOutputController.isActiveRemoteDevice(mMediaDevice1)).thenReturn(false); + mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter + .onCreateViewHolder(new LinearLayout(mContext), 0); mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0); assertThat(mViewHolder.mTwoLineLayout.getVisibility()).isEqualTo(View.GONE); -- cgit v1.2.3-59-g8ed1b