Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17d67458 authored by shaoweishen's avatar shaoweishen
Browse files

DO NOT MERGE: Downbranch merge conflict [Output Switcher] Fix situation when...

DO NOT MERGE: Downbranch merge conflict [Output Switcher] Fix situation when icon is not available for getBitmap

if icon we get from app metadata is not available for getBitmap, use
default colorscheme as color filter.

Bug: 232702573
Test: Verified on device
Change-Id: Ibd4f2644500c87b4ebb731f6f8fee64188bb7e8f
parent ac94a2da
Loading
Loading
Loading
Loading
+22 −13
Original line number Diff line number Diff line
@@ -314,6 +314,10 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
            mHeaderIcon.setImageResource(iconRes);
        } else if (iconCompat != null) {
            Icon icon = iconCompat.toIcon(mContext);
            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;
@@ -321,12 +325,8 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
                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());
                    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;