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

Commit b49a070d authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed a bug where the media notification image was wrong

In RTL the gradient was being applied the wrong way.

Test: switch to RTL, play music
Change-Id: Ie1686719d56436712fd0e6c99ba2723ba53d0025
Fixes: 37996998
parent ca585d29
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import android.graphics.drawable.Drawable;
 * A utility class to colorize bitmaps with a color gradient and a special blending mode
 */
public class ImageGradientColorizer {
    public Bitmap colorize(Drawable drawable, int backgroundColor) {
    public Bitmap colorize(Drawable drawable, int backgroundColor, boolean isRtl) {
        int width = drawable.getIntrinsicWidth();
        int height = drawable.getIntrinsicHeight();
        int size = Math.min(width, height);
@@ -79,6 +79,12 @@ public class ImageGradientColorizer {
        Canvas fadeInCanvas = new Canvas(fadeIn);
        drawable.clearColorFilter();
        drawable.draw(fadeInCanvas);

        if (isRtl) {
            // Let's flip the gradient
            fadeInCanvas.translate(size, 0);
            fadeInCanvas.scale(-1, 1);
        }
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
        fadeInCanvas.drawPaint(paint);

+4 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.support.v4.graphics.ColorUtils;
import android.support.v7.graphics.Palette;
import android.util.LayoutDirection;

import com.android.systemui.R;

@@ -187,7 +188,9 @@ public class MediaNotificationProcessor {
                        : R.color.notification_material_background_color;
                backgroundColor = mContext.getColor(id);
            }
            Bitmap colorized = mColorizer.colorize(drawable, backgroundColor);
            Bitmap colorized = mColorizer.colorize(drawable, backgroundColor,
                    mContext.getResources().getConfiguration().getLayoutDirection() ==
                            LayoutDirection.RTL);
            builder.setLargeIcon(Icon.createWithBitmap(colorized));
        }
    }