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

Commit 0b9295d0 authored by Alan Viverette's avatar Alan Viverette
Browse files

Push flags from top-level TypedValue into ComplexColor changing configs

Previously a ComplexColor that was defined within varying configs would
not push the flags into its changing configs, so it wouldn't get reloaded.

This implementation follows the Drawable implementation, where the base
changing configs are stored in the superclass.

Bug: 27573177
Change-Id: I1da5ee6ab998d8296f8860c1a99d3e1399438543
parent 513f77c8
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -10116,7 +10116,6 @@ package android.content.res {
    method public static deprecated android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static deprecated android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public int describeContents();
    method public int describeContents();
    method public int getChangingConfigurations();
    method public int getColorForState(int[], int);
    method public int getColorForState(int[], int);
    method public int getDefaultColor();
    method public int getDefaultColor();
    method public boolean isOpaque();
    method public boolean isOpaque();
@@ -10128,6 +10127,7 @@ package android.content.res {
  public abstract class ComplexColor {
  public abstract class ComplexColor {
    ctor public ComplexColor();
    ctor public ComplexColor();
    method public int getChangingConfigurations();
    method public abstract int getDefaultColor();
    method public abstract int getDefaultColor();
    method public boolean isStateful();
    method public boolean isStateful();
  }
  }
+1 −1
Original line number Original line Diff line number Diff line
@@ -10511,7 +10511,6 @@ package android.content.res {
    method public static deprecated android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static deprecated android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public int describeContents();
    method public int describeContents();
    method public int getChangingConfigurations();
    method public int getColorForState(int[], int);
    method public int getColorForState(int[], int);
    method public int getDefaultColor();
    method public int getDefaultColor();
    method public boolean isOpaque();
    method public boolean isOpaque();
@@ -10523,6 +10522,7 @@ package android.content.res {
  public abstract class ComplexColor {
  public abstract class ComplexColor {
    ctor public ComplexColor();
    ctor public ComplexColor();
    method public int getChangingConfigurations();
    method public abstract int getDefaultColor();
    method public abstract int getDefaultColor();
    method public boolean isStateful();
    method public boolean isStateful();
  }
  }
+1 −1
Original line number Original line Diff line number Diff line
@@ -10126,7 +10126,6 @@ package android.content.res {
    method public static deprecated android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static deprecated android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.content.res.ColorStateList createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public int describeContents();
    method public int describeContents();
    method public int getChangingConfigurations();
    method public int getColorForState(int[], int);
    method public int getColorForState(int[], int);
    method public int getDefaultColor();
    method public int getDefaultColor();
    method public boolean isOpaque();
    method public boolean isOpaque();
@@ -10138,6 +10137,7 @@ package android.content.res {
  public abstract class ComplexColor {
  public abstract class ComplexColor {
    ctor public ComplexColor();
    ctor public ComplexColor();
    method public int getChangingConfigurations();
    method public abstract int getDefaultColor();
    method public abstract int getDefaultColor();
    method public boolean isStateful();
    method public boolean isStateful();
  }
  }
+1 −1
Original line number Original line Diff line number Diff line
@@ -442,7 +442,7 @@ public class ColorStateList extends ComplexColor implements Parcelable {
     * @see android.content.pm.ActivityInfo
     * @see android.content.pm.ActivityInfo
     */
     */
    public @Config int getChangingConfigurations() {
    public @Config int getChangingConfigurations() {
        return mChangingConfigurations;
        return super.getChangingConfigurations() | mChangingConfigurations;
    }
    }


    private int modulateColorAlpha(int baseColor, float alphaMod) {
    private int modulateColorAlpha(int baseColor, float alphaMod) {
+22 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,8 @@ import android.graphics.Color;
 * {@link android.content.res.ColorStateList} or {@link android.content.res.GradientColor}
 * {@link android.content.res.ColorStateList} or {@link android.content.res.GradientColor}
 */
 */
public abstract class ComplexColor {
public abstract class ComplexColor {
    private int mChangingConfigurations;

    /**
    /**
     * @return {@code true}  if this ComplexColor changes color based on state, {@code false}
     * @return {@code true}  if this ComplexColor changes color based on state, {@code false}
     * otherwise.
     * otherwise.
@@ -52,4 +54,24 @@ public abstract class ComplexColor {
     * @hide only for resource preloading
     * @hide only for resource preloading
     */
     */
    public abstract ComplexColor obtainForTheme(Theme t);
    public abstract ComplexColor obtainForTheme(Theme t);

    /**
     * @hide only for resource preloading
     */
    final void setBaseChangingConfigurations(int changingConfigurations) {
        mChangingConfigurations = changingConfigurations;
    }

    /**
     * Returns a mask of the configuration parameters for which this color
     * may change, requiring that it be re-created.
     *
     * @return a mask of the changing configuration parameters, as defined by
     *         {@link android.content.pm.ActivityInfo}
     *
     * @see android.content.pm.ActivityInfo
     */
    public int getChangingConfigurations() {
        return mChangingConfigurations;
    }
}
}
Loading