Merge changes from topic "am-d860aeb1f4184ec4b358c442e876df1c" into tm-dev-plus-aosp

* changes:
  Merge "DO NOT MERGE: Downbranch merge conflict [Output Switcher] Fix situation when icon is not available for getBitmap" into tm-dev am: d0225df023
  DO NOT MERGE: Downbranch merge conflict [Output Switcher] Fix situation when icon is not available for getBitmap am: 17d674584b
This commit is contained in:
Automerger Merge Worker
2022-05-24 00:54:41 +00:00
committed by Android (Google) Code Review

View File

@@ -314,19 +314,19 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
mHeaderIcon.setImageResource(iconRes); mHeaderIcon.setImageResource(iconRes);
} else if (iconCompat != null) { } else if (iconCompat != null) {
Icon icon = iconCompat.toIcon(mContext); Icon icon = iconCompat.toIcon(mContext);
Configuration config = mContext.getResources().getConfiguration(); if (icon.getType() != Icon.TYPE_BITMAP && icon.getType() != Icon.TYPE_ADAPTIVE_BITMAP) {
int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK; // icon doesn't support getBitmap, use default value for color scheme
boolean isDarkThemeOn = currentNightMode == Configuration.UI_MODE_NIGHT_YES; updateButtonBackgroundColorFilter();
WallpaperColors wallpaperColors = WallpaperColors.fromBitmap(icon.getBitmap()); } else {
colorSetUpdated = !wallpaperColors.equals(mWallpaperColors); Configuration config = mContext.getResources().getConfiguration();
if (colorSetUpdated) { int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK;
mAdapter.updateColorScheme(wallpaperColors, isDarkThemeOn); boolean isDarkThemeOn = currentNightMode == Configuration.UI_MODE_NIGHT_YES;
ColorFilter buttonColorFilter = new PorterDuffColorFilter( WallpaperColors wallpaperColors = WallpaperColors.fromBitmap(icon.getBitmap());
mAdapter.getController().getColorButtonBackground(), colorSetUpdated = !wallpaperColors.equals(mWallpaperColors);
PorterDuff.Mode.SRC_IN); if (colorSetUpdated) {
mDoneButton.getBackground().setColorFilter(buttonColorFilter); mAdapter.updateColorScheme(wallpaperColors, isDarkThemeOn);
mStopButton.getBackground().setColorFilter(buttonColorFilter); updateButtonBackgroundColorFilter();
mDoneButton.setTextColor(mAdapter.getController().getColorPositiveButtonText()); }
} }
mHeaderIcon.setVisibility(View.VISIBLE); mHeaderIcon.setVisibility(View.VISIBLE);
mHeaderIcon.setImageIcon(icon); mHeaderIcon.setImageIcon(icon);
@@ -368,6 +368,15 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
mStopButton.setOnClickListener(v -> onStopButtonClick()); mStopButton.setOnClickListener(v -> onStopButtonClick());
} }
private void updateButtonBackgroundColorFilter() {
ColorFilter buttonColorFilter = new PorterDuffColorFilter(
mAdapter.getController().getColorButtonBackground(),
PorterDuff.Mode.SRC_IN);
mDoneButton.getBackground().setColorFilter(buttonColorFilter);
mStopButton.getBackground().setColorFilter(buttonColorFilter);
mDoneButton.setTextColor(mAdapter.getController().getColorPositiveButtonText());
}
private Drawable resizeDrawable(Drawable drawable, int size) { private Drawable resizeDrawable(Drawable drawable, int size) {
if (drawable == null) { if (drawable == null) {
return null; return null;