Merge "[Output Switcher] Fix SASS device update in U" into udc-dev

This commit is contained in:
Shaowei Shen
2023-05-12 10:13:15 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 16 deletions

View File

@@ -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()) {

View File

@@ -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()));
});

View File

@@ -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);