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
diff --git a/api/current.txt b/api/current.txt
index 9e0af76..f533772 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -10116,7 +10116,6 @@
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 int describeContents();
- method public int getChangingConfigurations();
method public int getColorForState(int[], int);
method public int getDefaultColor();
method public boolean isOpaque();
@@ -10128,6 +10127,7 @@
public abstract class ComplexColor {
ctor public ComplexColor();
+ method public int getChangingConfigurations();
method public abstract int getDefaultColor();
method public boolean isStateful();
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 00cf357..5c8d6df 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -10511,7 +10511,6 @@
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 int describeContents();
- method public int getChangingConfigurations();
method public int getColorForState(int[], int);
method public int getDefaultColor();
method public boolean isOpaque();
@@ -10523,6 +10522,7 @@
public abstract class ComplexColor {
ctor public ComplexColor();
+ method public int getChangingConfigurations();
method public abstract int getDefaultColor();
method public boolean isStateful();
}
diff --git a/api/test-current.txt b/api/test-current.txt
index 9aed5e9..b71cf23 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -10126,7 +10126,6 @@
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 int describeContents();
- method public int getChangingConfigurations();
method public int getColorForState(int[], int);
method public int getDefaultColor();
method public boolean isOpaque();
@@ -10138,6 +10137,7 @@
public abstract class ComplexColor {
ctor public ComplexColor();
+ method public int getChangingConfigurations();
method public abstract int getDefaultColor();
method public boolean isStateful();
}
diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java
index 5bf2e3e..fb5bfd3 100644
--- a/core/java/android/content/res/ColorStateList.java
+++ b/core/java/android/content/res/ColorStateList.java
@@ -442,7 +442,7 @@
* @see android.content.pm.ActivityInfo
*/
public @Config int getChangingConfigurations() {
- return mChangingConfigurations;
+ return super.getChangingConfigurations() | mChangingConfigurations;
}
private int modulateColorAlpha(int baseColor, float alphaMod) {
diff --git a/core/java/android/content/res/ComplexColor.java b/core/java/android/content/res/ComplexColor.java
index d96ec62..b297764 100644
--- a/core/java/android/content/res/ComplexColor.java
+++ b/core/java/android/content/res/ComplexColor.java
@@ -25,6 +25,8 @@
* {@link android.content.res.ColorStateList} or {@link android.content.res.GradientColor}
*/
public abstract class ComplexColor {
+ private int mChangingConfigurations;
+
/**
* @return {@code true} if this ComplexColor changes color based on state, {@code false}
* otherwise.
@@ -52,4 +54,24 @@
* @hide only for resource preloading
*/
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;
+ }
}
diff --git a/core/java/android/content/res/GradientColor.java b/core/java/android/content/res/GradientColor.java
index 3291340..f29656a 100644
--- a/core/java/android/content/res/GradientColor.java
+++ b/core/java/android/content/res/GradientColor.java
@@ -542,6 +542,19 @@
return clone;
}
+ /**
+ * Returns a mask of the configuration parameters for which this gradient
+ * 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 super.getChangingConfigurations() | mChangingConfigurations;
+ }
+
private void applyTheme(Theme t) {
if (mThemeAttrs != null) {
applyRootAttrsTheme(t);
diff --git a/core/java/android/content/res/ResourcesImpl.java b/core/java/android/content/res/ResourcesImpl.java
index 90037f7..a364010 100644
--- a/core/java/android/content/res/ResourcesImpl.java
+++ b/core/java/android/content/res/ResourcesImpl.java
@@ -713,9 +713,11 @@
}
if (complexColor != null) {
+ complexColor.setBaseChangingConfigurations(value.changingConfigurations);
+
if (mPreloading) {
- if (verifyPreloadConfig(value.changingConfigurations, 0, value.resourceId,
- "color")) {
+ if (verifyPreloadConfig(complexColor.getChangingConfigurations(),
+ 0, value.resourceId, "color")) {
sPreloadedComplexColors.put(key, complexColor.getConstantState());
}
} else {