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

Commit 377d1337 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Support tinting blur drawable

In order to achieve the look and feel of colored surfaces, the blur
drawable should be able to receive a color and draw it on top of the
blur region.

Test: manual
Fixes: 172372852
Change-Id: I4cab21e337ca18f617780531368ba70154027b72
parent 19188bcc
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
@@ -75,7 +76,8 @@ public final class BackgroundBlurDrawable extends Drawable {

    private BackgroundBlurDrawable(Aggregator aggregator) {
        mAggregator = aggregator;
        mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
        mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
        mPaint.setColor(Color.TRANSPARENT);
        mRenderNode = new RenderNode("BackgroundBlurDrawable");
        mRenderNode.addPositionUpdateListener(mPositionUpdateListener);
    }
@@ -85,10 +87,16 @@ public final class BackgroundBlurDrawable extends Drawable {
        if (mRectPath.isEmpty() || !isVisible() || getAlpha() == 0) {
            return;
        }

        canvas.drawPath(mRectPath, mPaint);
        canvas.drawRenderNode(mRenderNode);
    }

    @Override
    public void setTint(int tintColor) {
        mPaint.setColor(tintColor);
    }

    @Override
    public boolean setVisible(boolean visible, boolean restart) {
        boolean changed = super.setVisible(visible, restart);