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

Commit 7ab5459a authored by Rahul Ravikumar's avatar Rahul Ravikumar
Browse files

Add a EdgeEffect#setBlendMode API.

* Fixes hidden api usage b/123769450
* Move from setXferMode() to setBlendMode in Paint.

Fixes: b/123769450

Test: Added CTS Tests.
Change-Id: I1f950e4c14d30dd223cce05835b230c086755089
parent adafb1b4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -55548,6 +55548,7 @@ package android.widget {
    ctor public EdgeEffect(android.content.Context);
    method public boolean draw(android.graphics.Canvas);
    method public void finish();
    method @Nullable public android.graphics.BlendMode getBlendMode();
    method @ColorInt public int getColor();
    method public int getMaxHeight();
    method public boolean isFinished();
@@ -55555,8 +55556,10 @@ package android.widget {
    method public void onPull(float);
    method public void onPull(float, float);
    method public void onRelease();
    method public void setBlendMode(@Nullable android.graphics.BlendMode);
    method public void setColor(@ColorInt int);
    method public void setSize(int, int);
    field public static final android.graphics.BlendMode DEFAULT_BLEND_MODE;
  }
  public class EditText extends android.widget.TextView {
+41 −4
Original line number Diff line number Diff line
@@ -17,14 +17,15 @@
package android.widget;

import android.annotation.ColorInt;
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.BlendMode;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.os.Build;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
@@ -48,6 +49,12 @@ import android.view.animation.Interpolator;
 * {@link #draw(Canvas)} method.</p>
 */
public class EdgeEffect {

    /**
     * The default blend mode used by {@link EdgeEffect}.
     */
    public static final BlendMode DEFAULT_BLEND_MODE = BlendMode.SRC_ATOP;

    @SuppressWarnings("UnusedDeclaration")
    private static final String TAG = "EdgeEffect";

@@ -108,7 +115,7 @@ public class EdgeEffect {
    private float mPullDistance;

    private final Rect mBounds = new Rect();
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769450)
    private final Paint mPaint = new Paint();
    private float mRadius;
    private float mBaseGlowScale;
@@ -128,7 +135,7 @@ public class EdgeEffect {
        a.recycle();
        mPaint.setColor((themeColor & 0xffffff) | 0x33000000);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
        mPaint.setBlendMode(DEFAULT_BLEND_MODE);
        mInterpolator = new DecelerateInterpolator();
    }

@@ -301,6 +308,22 @@ public class EdgeEffect {
        mPaint.setColor(color);
    }

    /**
     * Set or clear the blend mode. A blend mode defines how source pixels
     * (generated by a drawing command) are composited with the destination pixels
     * (content of the render target).
     * <p />
     * Pass null to clear any previous blend mode.
     * <p />
     *
     * @see BlendMode
     *
     * @param blendmode May be null. The blend mode to be installed in the paint
     */
    public void setBlendMode(@Nullable BlendMode blendmode) {
        mPaint.setBlendMode(blendmode);
    }

    /**
     * Return the color of this edge effect in argb.
     * @return The color of this edge effect in argb
@@ -310,6 +333,20 @@ public class EdgeEffect {
        return mPaint.getColor();
    }


    /**
     * Returns the blend mode. A blend mode defines how source pixels
     * (generated by a drawing command) are composited with the destination pixels
     * (content of the render target).
     * <p />
     *
     * @return BlendMode
     */
    @Nullable
    public BlendMode getBlendMode() {
        return mPaint.getBlendMode();
    }

    /**
     * Draw into the provided canvas. Assumes that the canvas has been rotated
     * accordingly and the size has been set. The effect will be drawn the full
+0 −1
Original line number Diff line number Diff line
@@ -1279,7 +1279,6 @@ public class Paint {
     * (content of the render target).
     * <p />
     * Pass null to clear any previous blend mode.
     * As a convenience, the parameter passed is also returned.
     * <p />
     *
     * @see BlendMode