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

Commit 45cb8614 authored by Selim Cinek's avatar Selim Cinek Committed by android-build-merger
Browse files

Merge changes Ie1686719,Ie6af7751 into oc-dev am: ba911a25

am: bbdf8924

Change-Id: I2305ec1268fbc4be9aed96da07e147f827e4e7bc
parents d58d7132 bbdf8924
Loading
Loading
Loading
Loading
+17 −8
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);
@@ -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},
@@ -81,16 +79,27 @@ 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);
        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;
    }
}
+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));
        }
    }