diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java | 35 |
1 files changed, 22 insertions, 13 deletions
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 e9c00ef01e2a..e5913061ef3f 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java @@ -314,19 +314,19 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements mHeaderIcon.setImageResource(iconRes); } else if (iconCompat != null) { Icon icon = iconCompat.toIcon(mContext); - Configuration config = mContext.getResources().getConfiguration(); - int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK; - boolean isDarkThemeOn = currentNightMode == Configuration.UI_MODE_NIGHT_YES; - WallpaperColors wallpaperColors = WallpaperColors.fromBitmap(icon.getBitmap()); - colorSetUpdated = !wallpaperColors.equals(mWallpaperColors); - if (colorSetUpdated) { - mAdapter.updateColorScheme(wallpaperColors, isDarkThemeOn); - ColorFilter buttonColorFilter = new PorterDuffColorFilter( - mAdapter.getController().getColorButtonBackground(), - PorterDuff.Mode.SRC_IN); - mDoneButton.getBackground().setColorFilter(buttonColorFilter); - mStopButton.getBackground().setColorFilter(buttonColorFilter); - mDoneButton.setTextColor(mAdapter.getController().getColorPositiveButtonText()); + if (icon.getType() != Icon.TYPE_BITMAP && icon.getType() != Icon.TYPE_ADAPTIVE_BITMAP) { + // icon doesn't support getBitmap, use default value for color scheme + updateButtonBackgroundColorFilter(); + } else { + Configuration config = mContext.getResources().getConfiguration(); + int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK; + boolean isDarkThemeOn = currentNightMode == Configuration.UI_MODE_NIGHT_YES; + WallpaperColors wallpaperColors = WallpaperColors.fromBitmap(icon.getBitmap()); + colorSetUpdated = !wallpaperColors.equals(mWallpaperColors); + if (colorSetUpdated) { + mAdapter.updateColorScheme(wallpaperColors, isDarkThemeOn); + updateButtonBackgroundColorFilter(); + } } mHeaderIcon.setVisibility(View.VISIBLE); mHeaderIcon.setImageIcon(icon); @@ -368,6 +368,15 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements 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) { if (drawable == null) { return null; |