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

Commit 40a43424 authored by Nader Jawad's avatar Nader Jawad Committed by Android (Google) Code Review
Browse files

Merge "Added framework APIs to leverage new BlendMode API"

parents 37c66e5e dadf251a
Loading
Loading
Loading
Loading
+42 −33
Original line number Original line Diff line number Diff line
@@ -14100,8 +14100,9 @@ package android.graphics {
  }
  }
  public class ComposeShader extends android.graphics.Shader {
  public class ComposeShader extends android.graphics.Shader {
    ctor public ComposeShader(@NonNull android.graphics.Shader, @NonNull android.graphics.Shader, @NonNull android.graphics.Xfermode);
    ctor @Deprecated public ComposeShader(@NonNull android.graphics.Shader, @NonNull android.graphics.Shader, @NonNull android.graphics.Xfermode);
    ctor public ComposeShader(@NonNull android.graphics.Shader, @NonNull android.graphics.Shader, @NonNull android.graphics.PorterDuff.Mode);
    ctor @Deprecated public ComposeShader(@NonNull android.graphics.Shader, @NonNull android.graphics.Shader, @NonNull android.graphics.PorterDuff.Mode);
    ctor public ComposeShader(@NonNull android.graphics.Shader, @NonNull android.graphics.Shader, @NonNull android.graphics.BlendMode);
  }
  }
  public class CornerPathEffect extends android.graphics.PathEffect {
  public class CornerPathEffect extends android.graphics.PathEffect {
@@ -14795,37 +14796,37 @@ package android.graphics {
    field public float y;
    field public float y;
  }
  }
  public class PorterDuff {
  @Deprecated public class PorterDuff {
    ctor public PorterDuff();
    ctor @Deprecated public PorterDuff();
  }
  }
  public enum PorterDuff.Mode {
  @Deprecated public enum PorterDuff.Mode {
    enum_constant public static final android.graphics.PorterDuff.Mode ADD;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode ADD;
    enum_constant public static final android.graphics.PorterDuff.Mode CLEAR;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode CLEAR;
    enum_constant public static final android.graphics.PorterDuff.Mode DARKEN;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode DARKEN;
    enum_constant public static final android.graphics.PorterDuff.Mode DST;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode DST;
    enum_constant public static final android.graphics.PorterDuff.Mode DST_ATOP;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode DST_ATOP;
    enum_constant public static final android.graphics.PorterDuff.Mode DST_IN;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode DST_IN;
    enum_constant public static final android.graphics.PorterDuff.Mode DST_OUT;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode DST_OUT;
    enum_constant public static final android.graphics.PorterDuff.Mode DST_OVER;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode DST_OVER;
    enum_constant public static final android.graphics.PorterDuff.Mode LIGHTEN;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode LIGHTEN;
    enum_constant public static final android.graphics.PorterDuff.Mode MULTIPLY;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode MULTIPLY;
    enum_constant public static final android.graphics.PorterDuff.Mode OVERLAY;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode OVERLAY;
    enum_constant public static final android.graphics.PorterDuff.Mode SCREEN;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode SCREEN;
    enum_constant public static final android.graphics.PorterDuff.Mode SRC;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode SRC;
    enum_constant public static final android.graphics.PorterDuff.Mode SRC_ATOP;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode SRC_ATOP;
    enum_constant public static final android.graphics.PorterDuff.Mode SRC_IN;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode SRC_IN;
    enum_constant public static final android.graphics.PorterDuff.Mode SRC_OUT;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode SRC_OUT;
    enum_constant public static final android.graphics.PorterDuff.Mode SRC_OVER;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode SRC_OVER;
    enum_constant public static final android.graphics.PorterDuff.Mode XOR;
    enum_constant @Deprecated public static final android.graphics.PorterDuff.Mode XOR;
  }
  }
  @Deprecated public class PorterDuffColorFilter extends android.graphics.ColorFilter {
  @Deprecated public class PorterDuffColorFilter extends android.graphics.ColorFilter {
    ctor @Deprecated public PorterDuffColorFilter(@ColorInt int, @NonNull android.graphics.PorterDuff.Mode);
    ctor @Deprecated public PorterDuffColorFilter(@ColorInt int, @NonNull android.graphics.PorterDuff.Mode);
  }
  }
  public class PorterDuffXfermode extends android.graphics.Xfermode {
  @Deprecated public class PorterDuffXfermode extends android.graphics.Xfermode {
    ctor public PorterDuffXfermode(android.graphics.PorterDuff.Mode);
    ctor @Deprecated public PorterDuffXfermode(android.graphics.PorterDuff.Mode);
  }
  }
  public interface PostProcessor {
  public interface PostProcessor {
@@ -15387,7 +15388,8 @@ package android.graphics.drawable {
    method public boolean setState(@NonNull int[]);
    method public boolean setState(@NonNull int[]);
    method public void setTint(@ColorInt int);
    method public void setTint(@ColorInt int);
    method public void setTintList(@Nullable android.content.res.ColorStateList);
    method public void setTintList(@Nullable android.content.res.ColorStateList);
    method public void setTintMode(@NonNull android.graphics.PorterDuff.Mode);
    method @Deprecated public void setTintMode(@NonNull android.graphics.PorterDuff.Mode);
    method public void setTintMode(@NonNull android.graphics.BlendMode);
    method public boolean setVisible(boolean, boolean);
    method public boolean setVisible(boolean, boolean);
    method public void unscheduleSelf(@NonNull Runnable);
    method public void unscheduleSelf(@NonNull Runnable);
  }
  }
@@ -15545,7 +15547,8 @@ package android.graphics.drawable {
    method public void loadDrawableAsync(android.content.Context, android.graphics.drawable.Icon.OnDrawableLoadedListener, android.os.Handler);
    method public void loadDrawableAsync(android.content.Context, android.graphics.drawable.Icon.OnDrawableLoadedListener, android.os.Handler);
    method public android.graphics.drawable.Icon setTint(@ColorInt int);
    method public android.graphics.drawable.Icon setTint(@ColorInt int);
    method public android.graphics.drawable.Icon setTintList(android.content.res.ColorStateList);
    method public android.graphics.drawable.Icon setTintList(android.content.res.ColorStateList);
    method public android.graphics.drawable.Icon setTintMode(android.graphics.PorterDuff.Mode);
    method @Deprecated @NonNull public android.graphics.drawable.Icon setTintMode(@NonNull android.graphics.PorterDuff.Mode);
    method @NonNull public android.graphics.drawable.Icon setTintMode(@NonNull android.graphics.BlendMode);
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.graphics.drawable.Icon> CREATOR;
    field @NonNull public static final android.os.Parcelable.Creator<android.graphics.drawable.Icon> CREATOR;
    field public static final int TYPE_ADAPTIVE_BITMAP = 5; // 0x5
    field public static final int TYPE_ADAPTIVE_BITMAP = 5; // 0x5
@@ -49718,8 +49721,9 @@ package android.view {
    method public default CharSequence getContentDescription();
    method public default CharSequence getContentDescription();
    method public int getGroupId();
    method public int getGroupId();
    method public android.graphics.drawable.Drawable getIcon();
    method public android.graphics.drawable.Drawable getIcon();
    method @Nullable public default android.graphics.BlendMode getIconTintBlendMode();
    method @Nullable public default android.content.res.ColorStateList getIconTintList();
    method @Nullable public default android.content.res.ColorStateList getIconTintList();
    method @Nullable public default android.graphics.PorterDuff.Mode getIconTintMode();
    method @Deprecated @Nullable public default android.graphics.PorterDuff.Mode getIconTintMode();
    method public android.content.Intent getIntent();
    method public android.content.Intent getIntent();
    method public int getItemId();
    method public int getItemId();
    method public android.view.ContextMenu.ContextMenuInfo getMenuInfo();
    method public android.view.ContextMenu.ContextMenuInfo getMenuInfo();
@@ -49748,7 +49752,8 @@ package android.view {
    method public android.view.MenuItem setIcon(android.graphics.drawable.Drawable);
    method public android.view.MenuItem setIcon(android.graphics.drawable.Drawable);
    method public android.view.MenuItem setIcon(@DrawableRes int);
    method public android.view.MenuItem setIcon(@DrawableRes int);
    method public default android.view.MenuItem setIconTintList(@Nullable android.content.res.ColorStateList);
    method public default android.view.MenuItem setIconTintList(@Nullable android.content.res.ColorStateList);
    method public default android.view.MenuItem setIconTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method @Deprecated @NonNull public default android.view.MenuItem setIconTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method @NonNull public default android.view.MenuItem setIconTintMode(@Nullable android.graphics.BlendMode);
    method public android.view.MenuItem setIntent(android.content.Intent);
    method public android.view.MenuItem setIntent(android.content.Intent);
    method public android.view.MenuItem setNumericShortcut(char);
    method public android.view.MenuItem setNumericShortcut(char);
    method public default android.view.MenuItem setNumericShortcut(char, int);
    method public default android.view.MenuItem setNumericShortcut(char, int);
@@ -50401,8 +50406,9 @@ package android.view {
    method public int getAutofillType();
    method public int getAutofillType();
    method @Nullable public android.view.autofill.AutofillValue getAutofillValue();
    method @Nullable public android.view.autofill.AutofillValue getAutofillValue();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.graphics.drawable.Drawable getBackground();
    method @Nullable public android.graphics.BlendMode getBackgroundBlendMode();
    method @Nullable public android.content.res.ColorStateList getBackgroundTintList();
    method @Nullable public android.content.res.ColorStateList getBackgroundTintList();
    method @Nullable public android.graphics.PorterDuff.Mode getBackgroundTintMode();
    method @Deprecated @Nullable public android.graphics.PorterDuff.Mode getBackgroundTintMode();
    method @android.view.ViewDebug.ExportedProperty(category="layout") public int getBaseline();
    method @android.view.ViewDebug.ExportedProperty(category="layout") public int getBaseline();
    method @android.view.ViewDebug.CapturedViewProperty public final int getBottom();
    method @android.view.ViewDebug.CapturedViewProperty public final int getBottom();
    method protected float getBottomFadingEdgeStrength();
    method protected float getBottomFadingEdgeStrength();
@@ -50433,9 +50439,10 @@ package android.view {
    method public java.util.ArrayList<android.view.View> getFocusables(int);
    method public java.util.ArrayList<android.view.View> getFocusables(int);
    method public void getFocusedRect(android.graphics.Rect);
    method public void getFocusedRect(android.graphics.Rect);
    method public android.graphics.drawable.Drawable getForeground();
    method public android.graphics.drawable.Drawable getForeground();
    method @Nullable public android.graphics.BlendMode getForegroundBlendMode();
    method public int getForegroundGravity();
    method public int getForegroundGravity();
    method @Nullable public android.content.res.ColorStateList getForegroundTintList();
    method @Nullable public android.content.res.ColorStateList getForegroundTintList();
    method @Nullable public android.graphics.PorterDuff.Mode getForegroundTintMode();
    method @Deprecated @Nullable public android.graphics.PorterDuff.Mode getForegroundTintMode();
    method public boolean getGlobalVisibleRect(android.graphics.Rect, android.graphics.Point);
    method public boolean getGlobalVisibleRect(android.graphics.Rect, android.graphics.Point);
    method public final boolean getGlobalVisibleRect(android.graphics.Rect);
    method public final boolean getGlobalVisibleRect(android.graphics.Rect);
    method public android.os.Handler getHandler();
    method public android.os.Handler getHandler();
@@ -50751,7 +50758,8 @@ package android.view {
    method @Deprecated public void setBackgroundDrawable(android.graphics.drawable.Drawable);
    method @Deprecated public void setBackgroundDrawable(android.graphics.drawable.Drawable);
    method public void setBackgroundResource(@DrawableRes int);
    method public void setBackgroundResource(@DrawableRes int);
    method public void setBackgroundTintList(@Nullable android.content.res.ColorStateList);
    method public void setBackgroundTintList(@Nullable android.content.res.ColorStateList);
    method public void setBackgroundTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method @Deprecated public void setBackgroundTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method public void setBackgroundTintMode(@Nullable android.graphics.BlendMode);
    method public final void setBottom(int);
    method public final void setBottom(int);
    method public void setCameraDistance(float);
    method public void setCameraDistance(float);
    method public void setClickable(boolean);
    method public void setClickable(boolean);
@@ -50778,7 +50786,8 @@ package android.view {
    method public void setForeground(android.graphics.drawable.Drawable);
    method public void setForeground(android.graphics.drawable.Drawable);
    method public void setForegroundGravity(int);
    method public void setForegroundGravity(int);
    method public void setForegroundTintList(@Nullable android.content.res.ColorStateList);
    method public void setForegroundTintList(@Nullable android.content.res.ColorStateList);
    method public void setForegroundTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method @Deprecated public void setForegroundTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method public void setForegroundTintMode(@Nullable android.graphics.BlendMode);
    method public void setHapticFeedbackEnabled(boolean);
    method public void setHapticFeedbackEnabled(boolean);
    method public void setHasTransientState(boolean);
    method public void setHasTransientState(boolean);
    method public void setHorizontalFadingEdgeEnabled(boolean);
    method public void setHorizontalFadingEdgeEnabled(boolean);
+7 −7
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@ import android.content.ContextWrapper;
import android.content.res.ColorStateList;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.content.res.XmlResourceParser;
import android.graphics.PorterDuff;
import android.graphics.BlendMode;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Log;
@@ -308,7 +308,7 @@ public class MenuInflater {
        private CharSequence itemTitleCondensed;
        private CharSequence itemTitleCondensed;
        private int itemIconResId;
        private int itemIconResId;
        private ColorStateList itemIconTintList = null;
        private ColorStateList itemIconTintList = null;
        private PorterDuff.Mode itemIconTintMode = null;
        private BlendMode mItemIconBlendMode = null;
        private char itemAlphabeticShortcut;
        private char itemAlphabeticShortcut;
        private int itemAlphabeticModifiers;
        private int itemAlphabeticModifiers;
        private char itemNumericShortcut;
        private char itemNumericShortcut;
@@ -401,12 +401,12 @@ public class MenuInflater {
            itemTitleCondensed = a.getText(com.android.internal.R.styleable.MenuItem_titleCondensed);
            itemTitleCondensed = a.getText(com.android.internal.R.styleable.MenuItem_titleCondensed);
            itemIconResId = a.getResourceId(com.android.internal.R.styleable.MenuItem_icon, 0);
            itemIconResId = a.getResourceId(com.android.internal.R.styleable.MenuItem_icon, 0);
            if (a.hasValue(com.android.internal.R.styleable.MenuItem_iconTintMode)) {
            if (a.hasValue(com.android.internal.R.styleable.MenuItem_iconTintMode)) {
                itemIconTintMode = Drawable.parseTintMode(a.getInt(
                mItemIconBlendMode = Drawable.parseBlendMode(a.getInt(
                        com.android.internal.R.styleable.MenuItem_iconTintMode, -1),
                        com.android.internal.R.styleable.MenuItem_iconTintMode, -1),
                        itemIconTintMode);
                        mItemIconBlendMode);
            } else {
            } else {
                // Reset to null so that it's not carried over to the next item
                // Reset to null so that it's not carried over to the next item
                itemIconTintMode = null;
                mItemIconBlendMode = null;
            }
            }
            if (a.hasValue(com.android.internal.R.styleable.MenuItem_iconTint)) {
            if (a.hasValue(com.android.internal.R.styleable.MenuItem_iconTint)) {
                itemIconTintList = a.getColorStateList(
                itemIconTintList = a.getColorStateList(
@@ -487,8 +487,8 @@ public class MenuInflater {
                item.setShowAsAction(itemShowAsAction);
                item.setShowAsAction(itemShowAsAction);
            }
            }


            if (itemIconTintMode != null) {
            if (mItemIconBlendMode != null) {
                item.setIconTintMode(itemIconTintMode);
                item.setIconTintMode(mItemIconBlendMode);
            }
            }


            if (itemIconTintList != null) {
            if (itemIconTintList != null) {
+50 −1
Original line number Original line Diff line number Diff line
@@ -18,11 +18,13 @@ package android.view;


import android.annotation.DrawableRes;
import android.annotation.DrawableRes;
import android.annotation.LayoutRes;
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.StringRes;
import android.annotation.StringRes;
import android.app.Activity;
import android.app.Activity;
import android.content.Intent;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.ColorStateList;
import android.graphics.BlendMode;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ContextMenu.ContextMenuInfo;
@@ -268,8 +270,33 @@ public interface MenuItem {
     * @attr ref android.R.styleable#MenuItem_iconTintMode
     * @attr ref android.R.styleable#MenuItem_iconTintMode
     * @see #setIconTintList(ColorStateList)
     * @see #setIconTintList(ColorStateList)
     * @see Drawable#setTintMode(PorterDuff.Mode)
     * @see Drawable#setTintMode(PorterDuff.Mode)
     * @see Drawable#setTintMode(BlendMode)
     *
     * @deprecated use {@link #setIconTintMode(BlendMode)} instead
     */
     */
    public default MenuItem setIconTintMode(@Nullable PorterDuff.Mode tintMode) { return this; }
    @Deprecated
    default @NonNull MenuItem setIconTintMode(@Nullable PorterDuff.Mode tintMode) {
        return this;
    }

    /**
     * Specifies the blending mode used to apply the tint specified by
     * {@link #setIconTintList(ColorStateList)} to this item's icon. The default mode is
     * {@link BlendMode#SRC_IN}.
     *
     * @param blendMode the blending mode used to apply the tint, may be
     *                 {@code null} to clear tint
     * @attr ref android.R.styleable#MenuItem_iconTintMode
     * @see #setIconTintList(ColorStateList)
     */
    default @NonNull MenuItem setIconTintMode(@Nullable BlendMode blendMode) {
        PorterDuff.Mode mode = BlendMode.blendModeToPorterDuffMode(blendMode);
        if (mode != null) {
            return setIconTintMode(mode);
        } else {
            return this;
        }
    }


    /**
    /**
     * Returns the blending mode used to apply the tint to this item's icon, if specified.
     * Returns the blending mode used to apply the tint to this item's icon, if specified.
@@ -277,10 +304,32 @@ public interface MenuItem {
     * @return the blending mode used to apply the tint to this item's icon
     * @return the blending mode used to apply the tint to this item's icon
     * @attr ref android.R.styleable#MenuItem_iconTintMode
     * @attr ref android.R.styleable#MenuItem_iconTintMode
     * @see #setIconTintMode(PorterDuff.Mode)
     * @see #setIconTintMode(PorterDuff.Mode)
     * @see #setIconTintMode(BlendMode)
     *
     * @deprecated Use {@link #getIconTintBlendMode()} instead
     */
     */
    @Deprecated
    @Nullable
    @Nullable
    public default PorterDuff.Mode getIconTintMode() { return null; }
    public default PorterDuff.Mode getIconTintMode() { return null; }


    /**
     * Returns the blending mode used to apply the tint to this item's icon, if specified.
     *
     * @return the blending mode used to apply the tint to this item's icon
     * @attr ref android.R.styleable#MenuItem_iconTintMode
     * @see #setIconTintMode(BlendMode)
     *
     */
    @Nullable
    default BlendMode getIconTintBlendMode() {
        PorterDuff.Mode mode = getIconTintMode();
        if (mode != null) {
            return BlendMode.fromValue(mode.nativeInt);
        } else {
            return null;
        }
    }
    
    /**
    /**
     * Change the Intent associated with this item.  By default there is no
     * Change the Intent associated with this item.  By default there is no
     * Intent associated with a menu item.  If you set one, and nothing
     * Intent associated with a menu item.  If you set one, and nothing
+103 −11
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
import android.graphics.BlendMode;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Insets;
@@ -4506,7 +4507,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    static class TintInfo {
    static class TintInfo {
        ColorStateList mTintList;
        ColorStateList mTintList;
        PorterDuff.Mode mTintMode;
        BlendMode mBlendMode;
        boolean mHasTintMode;
        boolean mHasTintMode;
        boolean mHasTintList;
        boolean mHasTintList;
    }
    }
@@ -5687,7 +5688,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    if (mBackgroundTint == null) {
                    if (mBackgroundTint == null) {
                        mBackgroundTint = new TintInfo();
                        mBackgroundTint = new TintInfo();
                    }
                    }
                    mBackgroundTint.mTintMode = Drawable.parseTintMode(a.getInt(
                    mBackgroundTint.mBlendMode = Drawable.parseBlendMode(a.getInt(
                            R.styleable.View_backgroundTintMode, -1), null);
                            R.styleable.View_backgroundTintMode, -1), null);
                    mBackgroundTint.mHasTintMode = true;
                    mBackgroundTint.mHasTintMode = true;
                    break;
                    break;
@@ -5707,7 +5708,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    break;
                    break;
                case R.styleable.View_foregroundTintMode:
                case R.styleable.View_foregroundTintMode:
                    if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) {
                    if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) {
                        setForegroundTintMode(Drawable.parseTintMode(a.getInt(attr, -1), null));
                        setForegroundTintMode(Drawable.parseBlendMode(a.getInt(attr, -1), null));
                    }
                    }
                    break;
                    break;
                case R.styleable.View_foregroundTint:
                case R.styleable.View_foregroundTint:
@@ -23266,7 +23267,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    /**
    /**
     * Applies a tint to the background drawable. Does not modify the current tint
     * Applies a tint to the background drawable. Does not modify the current tint
     * mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
     * mode, which is {@link BlendMode#SRC_IN} by default.
     * <p>
     * <p>
     * Subsequent calls to {@link #setBackground(Drawable)} will automatically
     * Subsequent calls to {@link #setBackground(Drawable)} will automatically
     * mutate the drawable and apply the specified tint and tint mode using
     * mutate the drawable and apply the specified tint and tint mode using
@@ -23311,12 +23312,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @attr ref android.R.styleable#View_backgroundTintMode
     * @attr ref android.R.styleable#View_backgroundTintMode
     * @see #getBackgroundTintMode()
     * @see #getBackgroundTintMode()
     * @see Drawable#setTintMode(PorterDuff.Mode)
     * @see Drawable#setTintMode(PorterDuff.Mode)
     *
     * @deprecated use @setBackgroundTintMode(BlendMode) instead
     */
     */
    @Deprecated
    public void setBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) {
    public void setBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) {
        BlendMode mode = null;
        if (tintMode != null) {
            mode = BlendMode.fromValue(tintMode.nativeInt);
        }
        setBackgroundTintMode(mode);
    }
    /**
     * Specifies the blending mode used to apply the tint specified by
     * {@link #setBackgroundTintList(ColorStateList)}} to the background
     * drawable. The default mode is {@link BlendMode#SRC_IN}.
     *
     * @param blendMode the blending mode used to apply the tint, may be
     *                 {@code null} to clear tint
     * @attr ref android.R.styleable#View_backgroundTintMode
     * @see #getBackgroundTintMode()
     * @see Drawable#setTintMode(BlendMode)
     */
    public void setBackgroundTintMode(@Nullable BlendMode blendMode) {
        if (mBackgroundTint == null) {
        if (mBackgroundTint == null) {
            mBackgroundTint = new TintInfo();
            mBackgroundTint = new TintInfo();
        }
        }
        mBackgroundTint.mTintMode = tintMode;
        mBackgroundTint.mBlendMode = blendMode;
        mBackgroundTint.mHasTintMode = true;
        mBackgroundTint.mHasTintMode = true;
        applyBackgroundTint();
        applyBackgroundTint();
@@ -23329,12 +23354,34 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @return the blending mode used to apply the tint to the background
     * @return the blending mode used to apply the tint to the background
     *         drawable
     *         drawable
     * @attr ref android.R.styleable#View_backgroundTintMode
     * @attr ref android.R.styleable#View_backgroundTintMode
     * @see #setBackgroundTintMode(PorterDuff.Mode)
     * @see #setBackgroundTintMode(BlendMode)
     *
     * @deprecated use #getBackgroundBlendMode() instead
     */
     */
    @Nullable
    @Nullable
    @InspectableProperty
    @InspectableProperty
    @Deprecated
    public PorterDuff.Mode getBackgroundTintMode() {
    public PorterDuff.Mode getBackgroundTintMode() {
        return mBackgroundTint != null ? mBackgroundTint.mTintMode : null;
        PorterDuff.Mode porterDuffMode;
        if (mBackgroundTint != null && mBackgroundTint.mBlendMode != null) {
            porterDuffMode = BlendMode.blendModeToPorterDuffMode(mBackgroundTint.mBlendMode);
        } else {
            porterDuffMode = null;
        }
        return porterDuffMode;
    }
    /**
     * Return the blending mode used to apply the tint to the background
     * drawable, if specified.
     *
     * @return the blending mode used to apply the tint to the background
     *         drawable, null if no blend has previously been configured
     * @attr ref android.R.styleable#View_backgroundTintMode
     * @see #setBackgroundTintMode(BlendMode)
     */
    public @Nullable BlendMode getBackgroundBlendMode() {
        return mBackgroundTint != null ? mBackgroundTint.mBlendMode : null;
    }
    }
    private void applyBackgroundTint() {
    private void applyBackgroundTint() {
@@ -23348,7 +23395,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                }
                }
                if (tintInfo.mHasTintMode) {
                if (tintInfo.mHasTintMode) {
                    mBackground.setTintMode(tintInfo.mTintMode);
                    mBackground.setTintMode(tintInfo.mBlendMode);
                }
                }
                // The drawable (or one of its children) may not have been
                // The drawable (or one of its children) may not have been
@@ -23532,15 +23579,37 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @attr ref android.R.styleable#View_foregroundTintMode
     * @attr ref android.R.styleable#View_foregroundTintMode
     * @see #getForegroundTintMode()
     * @see #getForegroundTintMode()
     * @see Drawable#setTintMode(PorterDuff.Mode)
     * @see Drawable#setTintMode(PorterDuff.Mode)
     *
     * @deprecated use #setForegroundTintMode(BlendMode)
     */
     */
    @Deprecated
    public void setForegroundTintMode(@Nullable PorterDuff.Mode tintMode) {
    public void setForegroundTintMode(@Nullable PorterDuff.Mode tintMode) {
        BlendMode mode = null;
        if (tintMode != null) {
            mode = BlendMode.fromValue(tintMode.nativeInt);
        }
        setForegroundTintMode(mode);
    }
    /**
     * Specifies the blending mode used to apply the tint specified by
     * {@link #setForegroundTintList(ColorStateList)}} to the background
     * drawable. The default mode is {@link BlendMode#SRC_IN}.
     *
     * @param blendMode the blending mode used to apply the tint, may be
     *                 {@code null} to clear tint
     * @attr ref android.R.styleable#View_foregroundTintMode
     * @see #getForegroundTintMode()
     * @see Drawable#setTintMode(BlendMode)
     */
    public void setForegroundTintMode(@Nullable BlendMode blendMode) {
        if (mForegroundInfo == null) {
        if (mForegroundInfo == null) {
            mForegroundInfo = new ForegroundInfo();
            mForegroundInfo = new ForegroundInfo();
        }
        }
        if (mForegroundInfo.mTintInfo == null) {
        if (mForegroundInfo.mTintInfo == null) {
            mForegroundInfo.mTintInfo = new TintInfo();
            mForegroundInfo.mTintInfo = new TintInfo();
        }
        }
        mForegroundInfo.mTintInfo.mTintMode = tintMode;
        mForegroundInfo.mTintInfo.mBlendMode = blendMode;
        mForegroundInfo.mTintInfo.mHasTintMode = true;
        mForegroundInfo.mTintInfo.mHasTintMode = true;
        applyForegroundTint();
        applyForegroundTint();
@@ -23554,12 +23623,35 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *         drawable
     *         drawable
     * @attr ref android.R.styleable#View_foregroundTintMode
     * @attr ref android.R.styleable#View_foregroundTintMode
     * @see #setForegroundTintMode(PorterDuff.Mode)
     * @see #setForegroundTintMode(PorterDuff.Mode)
     *
     * @deprecated use #getForegroundBlendMode() instead
     */
     */
    @InspectableProperty
    @InspectableProperty
    @Nullable
    @Nullable
    @Deprecated
    public PorterDuff.Mode getForegroundTintMode() {
    public PorterDuff.Mode getForegroundTintMode() {
        BlendMode blendMode = mForegroundInfo != null && mForegroundInfo.mTintInfo != null
                ? mForegroundInfo.mTintInfo.mBlendMode : null;
        if (blendMode != null) {
            return BlendMode.blendModeToPorterDuffMode(blendMode);
        } else {
            return null;
        }
    }
    /**
     * Return the blending mode used to apply the tint to the foreground
     * drawable, if specified.
     *
     * @return the blending mode used to apply the tint to the foreground
     *         drawable
     * @attr ref android.R.styleable#View_foregroundTintMode
     * @see #setForegroundTintMode(BlendMode)
     *
     */
    public @Nullable BlendMode getForegroundBlendMode() {
        return mForegroundInfo != null && mForegroundInfo.mTintInfo != null
        return mForegroundInfo != null && mForegroundInfo.mTintInfo != null
                ? mForegroundInfo.mTintInfo.mTintMode : null;
                ? mForegroundInfo.mTintInfo.mBlendMode : null;
    }
    }
    private void applyForegroundTint() {
    private void applyForegroundTint() {
@@ -23574,7 +23666,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                }
                }
                if (tintInfo.mHasTintMode) {
                if (tintInfo.mHasTintMode) {
                    mForegroundInfo.mDrawable.setTintMode(tintInfo.mTintMode);
                    mForegroundInfo.mDrawable.setTintMode(tintInfo.mBlendMode);
                }
                }
                // The drawable (or one of its children) may not have been
                // The drawable (or one of its children) may not have been
+1 −1
Original line number Original line Diff line number Diff line
@@ -240,7 +240,7 @@ public abstract class BaseCanvas {
    }
    }


    public void drawColor(@ColorInt int color) {
    public void drawColor(@ColorInt int color) {
        nDrawColor(mNativeCanvasWrapper, color, PorterDuff.Mode.SRC_OVER.nativeInt);
        nDrawColor(mNativeCanvasWrapper, color, BlendMode.SRC_OVER.getXfermode().porterDuffMode);
    }
    }


    /**
    /**
Loading