From 17b50539208a3ce93cdae92a15ff02eed3e5937c Mon Sep 17 00:00:00 2001 From: shaoweishen Date: Wed, 7 Sep 2022 09:24:04 +0000 Subject: [PATCH] [Output switcher] Fix color issue Test: atest MediaOutputControllerTest MediaOutputBaseDialogTest MediaOutputDialogTest Bug: 237827969 Bug: 243701968 Change-Id: I0b59d6750c64e8ad636d2db11930d97bac886d99 --- .../media_output_dialog_background.xml | 22 +++++++++++++++++++ .../res/layout/media_output_dialog.xml | 1 + packages/SystemUI/res/values/colors.xml | 2 +- .../media/dialog/MediaOutputBaseDialog.java | 13 +++++++++-- .../media/dialog/MediaOutputController.java | 9 ++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 packages/SystemUI/res/drawable/media_output_dialog_background.xml diff --git a/packages/SystemUI/res/drawable/media_output_dialog_background.xml b/packages/SystemUI/res/drawable/media_output_dialog_background.xml new file mode 100644 index 0000000000000..40bfd83038af7 --- /dev/null +++ b/packages/SystemUI/res/drawable/media_output_dialog_background.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/media_output_dialog.xml b/packages/SystemUI/res/layout/media_output_dialog.xml index 93c16e4e119db..b76de5afdb730 100644 --- a/packages/SystemUI/res/layout/media_output_dialog.xml +++ b/packages/SystemUI/res/layout/media_output_dialog.xml @@ -20,6 +20,7 @@ android:id="@+id/media_output_dialog" android:layout_width="@dimen/large_dialog_width" android:layout_height="wrap_content" + android:background="@drawable/media_output_dialog_background" android:orientation="vertical"> @color/material_dynamic_primary20 @color/material_dynamic_secondary95 @color/material_dynamic_primary90 - @color/material_dynamic_secondary40 + @android:color/system_accent1_200 @color/material_dynamic_primary40 @color/material_dynamic_neutral95 diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java index e08e33802ce08..85d8f3fdd20a7 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java @@ -310,6 +310,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements if (icon.getType() != Icon.TYPE_BITMAP && icon.getType() != Icon.TYPE_ADAPTIVE_BITMAP) { // icon doesn't support getBitmap, use default value for color scheme updateButtonBackgroundColorFilter(); + updateDialogBackgroundColor(); } else { Configuration config = mContext.getResources().getConfiguration(); int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK; @@ -319,11 +320,14 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements if (colorSetUpdated) { mAdapter.updateColorScheme(wallpaperColors, isDarkThemeOn); updateButtonBackgroundColorFilter(); + updateDialogBackgroundColor(); } } mHeaderIcon.setVisibility(View.VISIBLE); mHeaderIcon.setImageIcon(icon); } else { + updateButtonBackgroundColorFilter(); + updateDialogBackgroundColor(); mHeaderIcon.setVisibility(View.GONE); } if (appSourceIcon != null) { @@ -381,11 +385,16 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements private void updateButtonBackgroundColorFilter() { ColorFilter buttonColorFilter = new PorterDuffColorFilter( - mAdapter.getController().getColorButtonBackground(), + mMediaOutputController.getColorButtonBackground(), PorterDuff.Mode.SRC_IN); mDoneButton.getBackground().setColorFilter(buttonColorFilter); mStopButton.getBackground().setColorFilter(buttonColorFilter); - mDoneButton.setTextColor(mAdapter.getController().getColorPositiveButtonText()); + mDoneButton.setTextColor(mMediaOutputController.getColorPositiveButtonText()); + } + + private void updateDialogBackgroundColor() { + getDialogView().getBackground().setTint(mMediaOutputController.getColorDialogBackground()); + mDeviceListLayout.setBackgroundColor(mMediaOutputController.getColorDialogBackground()); } private Drawable resizeDrawable(Drawable drawable, int size) { diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java index 8dd843a6f9218..e59b0bb6d1077 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java @@ -140,6 +140,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, private int mColorItemBackground; private int mColorConnectedItemBackground; private int mColorPositiveButtonText; + private int mColorDialogBackground; private float mInactiveRadius; private float mActiveRadius; @@ -188,6 +189,8 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, R.dimen.media_output_dialog_background_radius); mActiveRadius = mContext.getResources().getDimension( R.dimen.media_output_dialog_active_background_radius); + mColorDialogBackground = Utils.getColorStateListDefaultColor(mContext, + R.color.media_dialog_background); } void start(@NonNull Callback cb) { @@ -471,6 +474,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, mColorItemBackground = mCurrentColorScheme.getNeutral2().get(9); // N2-800 mColorConnectedItemBackground = mCurrentColorScheme.getAccent2().get(9); // A2-800 mColorPositiveButtonText = mCurrentColorScheme.getAccent2().get(9); // A2-800 + mColorDialogBackground = mCurrentColorScheme.getNeutral1().get(10); // N1-900 } else { mColorItemContent = mCurrentColorScheme.getAccent1().get(9); // A1-800 mColorSeekbarProgress = mCurrentColorScheme.getAccent1().get(4); // A1-300 @@ -478,6 +482,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, mColorItemBackground = mCurrentColorScheme.getAccent2().get(1); // A2-50 mColorConnectedItemBackground = mCurrentColorScheme.getAccent1().get(2); // A1-100 mColorPositiveButtonText = mCurrentColorScheme.getNeutral1().get(1); // N1-50 + mColorDialogBackground = mCurrentColorScheme.getBackgroundColor(); } } @@ -497,6 +502,10 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, return mColorPositiveButtonText; } + public int getColorDialogBackground() { + return mColorDialogBackground; + } + public int getColorItemContent() { return mColorItemContent; }