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

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

Improved the gradient drawing of the media notification

Previously we were drawing with a color on top of the
image instead of fading it out. This could lead to
visible artefacts in the background.
We're now fading out the alpha in a similar manner instead.

Test: runtest systemui
Change-Id: Ie6af7751a734b8fa44279eba970e7ca5ba67a4c0
Fixes: 37950482
parent 919076aa
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -70,8 +70,6 @@ public class ImageGradientColorizer {
                0, 0, 0, 1, 0,
        });

        drawable.setColorFilter(new ColorMatrixColorFilter(m));
        drawable.draw(canvas);
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        LinearGradient linearGradient =  new LinearGradient(0, 0, size, 0,
                new int[] {0, Color.argb(0.5f, 1, 1, 1), Color.BLACK},
@@ -83,14 +81,19 @@ public class ImageGradientColorizer {
        drawable.draw(fadeInCanvas);
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
        fadeInCanvas.drawPaint(paint);
        canvas.drawBitmap(fadeIn, 0, 0, null);

        Paint coloredPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        coloredPaint.setColorFilter(new ColorMatrixColorFilter(m));
        coloredPaint.setAlpha((int) (0.5f * 255));
        canvas.drawBitmap(fadeIn, 0, 0, coloredPaint);

        linearGradient =  new LinearGradient(0, 0, size, 0,
                new int[] {backgroundColor, Color.argb(0.5f, tr, tg, tb), 0},
                new int[] {0, Color.argb(0.5f, 1, 1, 1), Color.BLACK},
                new float[] {0.0f, 0.6f, 1.0f}, Shader.TileMode.CLAMP);
        paint.setShader(linearGradient);
        paint.setXfermode(null);
        canvas.drawPaint(paint);
        fadeInCanvas.drawPaint(paint);
        canvas.drawBitmap(fadeIn, 0, 0, null);

        return newBitmap;
    }
}