Loading api/current.txt +1 −2 Original line number Diff line number Diff line Loading @@ -9448,11 +9448,10 @@ package android.content.res { public class ColorStateList implements android.os.Parcelable { ctor public ColorStateList(int[][], int[]); method public void applyTheme(android.content.res.Resources.Theme); method public boolean canApplyTheme(); 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(); api/system-current.txt +1 −2 Original line number Diff line number Diff line Loading @@ -9737,11 +9737,10 @@ package android.content.res { public class ColorStateList implements android.os.Parcelable { ctor public ColorStateList(int[][], int[]); method public void applyTheme(android.content.res.Resources.Theme); method public boolean canApplyTheme(); 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(); core/java/android/content/res/ColorStateList.java +61 −19 Original line number Diff line number Diff line Loading @@ -71,10 +71,15 @@ import java.util.Arrays; */ public class ColorStateList implements Parcelable { private static final String TAG = "ColorStateList"; private static final int DEFAULT_COLOR = Color.RED; private static final int[][] EMPTY = new int[][] { new int[0] }; private static final SparseArray<WeakReference<ColorStateList>> sCache = new SparseArray<WeakReference<ColorStateList>>(); /** Thread-safe cache of single-color ColorStateLists. */ private static final SparseArray<WeakReference<ColorStateList>> sCache = new SparseArray<>(); /** Lazily-created factory for this color state list. */ private ColorStateListFactory mFactory; private int[][] mThemeAttrs; private int mChangingConfigurations; Loading Loading @@ -125,7 +130,7 @@ public class ColorStateList implements Parcelable { } final ColorStateList csl = new ColorStateList(EMPTY, new int[] { color }); sCache.put(color, new WeakReference<ColorStateList>(csl)); sCache.put(color, new WeakReference<>(csl)); return csl; } } Loading @@ -141,11 +146,13 @@ public class ColorStateList implements Parcelable { */ private ColorStateList(ColorStateList orig) { if (orig != null) { mChangingConfigurations = orig.mChangingConfigurations; mStateSpecs = orig.mStateSpecs; mDefaultColor = orig.mDefaultColor; mIsOpaque = orig.mIsOpaque; // Deep copy, this may change due to theming. // Deep copy, these may change due to applyTheme(). mThemeAttrs = orig.mThemeAttrs.clone(); mColors = orig.mColors.clone(); } } Loading Loading @@ -329,6 +336,7 @@ public class ColorStateList implements Parcelable { * attributes. * * @return whether a theme can be applied to this color state list * @hide only for resource preloading */ public boolean canApplyTheme() { return mThemeAttrs != null; Loading @@ -336,10 +344,15 @@ public class ColorStateList implements Parcelable { /** * Applies a theme to this color state list. * <p> * <strong>Note:</strong> Applying a theme may affect the changing * configuration parameters of this color state list. After calling this * method, any dependent configurations must be updated by obtaining the * new configuration mask from {@link #getChangingConfigurations()}. * * @param t the theme to apply */ public void applyTheme(Theme t) { private void applyTheme(Theme t) { if (mThemeAttrs == null) { return; } Loading Loading @@ -376,6 +389,38 @@ public class ColorStateList implements Parcelable { onColorsChanged(); } /** * Returns an appropriately themed color state list. * * @param t the theme to apply * @return a copy of the color state list with the theme applied, or the * color state list itself if there were no unresolved theme * attributes * @hide only for resource preloading */ public ColorStateList obtainForTheme(Theme t) { if (t == null || !canApplyTheme()) { return this; } final ColorStateList clone = new ColorStateList(this); clone.applyTheme(t); return clone; } /** * Returns a mask of the configuration parameters for which this color * state list 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; } private int modulateColorAlpha(int baseColor, float alphaMod) { if (alphaMod == 1.0f) { return baseColor; Loading @@ -383,8 +428,7 @@ public class ColorStateList implements Parcelable { final int baseAlpha = Color.alpha(baseColor); final int alpha = MathUtils.constrain((int) (baseAlpha * alphaMod + 0.5f), 0, 255); final int color = (baseColor & 0xFFFFFF) | (alpha << 24); return color; return (baseColor & 0xFFFFFF) | (alpha << 24); } /** Loading Loading @@ -534,14 +578,18 @@ public class ColorStateList implements Parcelable { } /** * @return A factory that can create new instances of this ColorStateList. * @return a factory that can create new instances of this ColorStateList * @hide only for resource preloading */ ColorStateListFactory getFactory() { return new ColorStateListFactory(this); public ConstantState<ColorStateList> getConstantState() { if (mFactory != null) { mFactory = new ColorStateListFactory(this); } return mFactory; } static class ColorStateListFactory extends ConstantState<ColorStateList> { final ColorStateList mSrc; private static class ColorStateListFactory extends ConstantState<ColorStateList> { private final ColorStateList mSrc; public ColorStateListFactory(ColorStateList src) { mSrc = src; Loading @@ -559,13 +607,7 @@ public class ColorStateList implements Parcelable { @Override public ColorStateList newInstance(Resources res, Theme theme) { if (theme == null || !mSrc.canApplyTheme()) { return mSrc; } final ColorStateList clone = new ColorStateList(mSrc); clone.applyTheme(theme); return clone; return mSrc.obtainForTheme(theme); } } Loading core/java/android/content/res/Resources.java +9 −8 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ import android.annotation.RawRes; import android.annotation.StringRes; import android.annotation.XmlRes; import android.content.pm.ActivityInfo; import android.content.res.ColorStateList.ColorStateListFactory; import android.graphics.Movie; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; Loading Loading @@ -112,8 +111,8 @@ public class Resources { private static final LongSparseArray<ConstantState>[] sPreloadedDrawables; private static final LongSparseArray<ConstantState> sPreloadedColorDrawables = new LongSparseArray<>(); private static final LongSparseArray<ColorStateListFactory> sPreloadedColorStateLists = new LongSparseArray<>(); private static final LongSparseArray<android.content.res.ConstantState<ColorStateList>> sPreloadedColorStateLists = new LongSparseArray<>(); // Pool of TypedArrays targeted to this Resources object. final SynchronizedPool<TypedArray> mTypedArrayPool = new SynchronizedPool<>(5); Loading Loading @@ -2667,7 +2666,8 @@ public class Resources { // Handle inline color definitions. if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) { final ColorStateListFactory factory = sPreloadedColorStateLists.get(key); final android.content.res.ConstantState<ColorStateList> factory = sPreloadedColorStateLists.get(key); if (factory != null) { return factory.newInstance(); } Loading @@ -2677,7 +2677,7 @@ public class Resources { if (mPreloading) { if (verifyPreloadConfig(value.changingConfigurations, 0, value.resourceId, "color")) { sPreloadedColorStateLists.put(key, csl.getFactory()); sPreloadedColorStateLists.put(key, csl.getConstantState()); } } Loading @@ -2691,7 +2691,8 @@ public class Resources { return csl; } final ColorStateListFactory factory = sPreloadedColorStateLists.get(key); final android.content.res.ConstantState<ColorStateList> factory = sPreloadedColorStateLists.get(key); if (factory != null) { csl = factory.newInstance(this, theme); } Loading @@ -2704,10 +2705,10 @@ public class Resources { if (mPreloading) { if (verifyPreloadConfig(value.changingConfigurations, 0, value.resourceId, "color")) { sPreloadedColorStateLists.put(key, csl.getFactory()); sPreloadedColorStateLists.put(key, csl.getConstantState()); } } else { cache.put(key, theme, csl.getFactory()); cache.put(key, theme, csl.getConstantState()); } } Loading graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +1 −1 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable { @Override public int getChangingConfigurations() { return super.getChangingConfigurations() | mAnimatedVectorState.mChangingConfigurations; return super.getChangingConfigurations() | mAnimatedVectorState.getChangingConfigurations(); } @Override Loading Loading
api/current.txt +1 −2 Original line number Diff line number Diff line Loading @@ -9448,11 +9448,10 @@ package android.content.res { public class ColorStateList implements android.os.Parcelable { ctor public ColorStateList(int[][], int[]); method public void applyTheme(android.content.res.Resources.Theme); method public boolean canApplyTheme(); 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();
api/system-current.txt +1 −2 Original line number Diff line number Diff line Loading @@ -9737,11 +9737,10 @@ package android.content.res { public class ColorStateList implements android.os.Parcelable { ctor public ColorStateList(int[][], int[]); method public void applyTheme(android.content.res.Resources.Theme); method public boolean canApplyTheme(); 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();
core/java/android/content/res/ColorStateList.java +61 −19 Original line number Diff line number Diff line Loading @@ -71,10 +71,15 @@ import java.util.Arrays; */ public class ColorStateList implements Parcelable { private static final String TAG = "ColorStateList"; private static final int DEFAULT_COLOR = Color.RED; private static final int[][] EMPTY = new int[][] { new int[0] }; private static final SparseArray<WeakReference<ColorStateList>> sCache = new SparseArray<WeakReference<ColorStateList>>(); /** Thread-safe cache of single-color ColorStateLists. */ private static final SparseArray<WeakReference<ColorStateList>> sCache = new SparseArray<>(); /** Lazily-created factory for this color state list. */ private ColorStateListFactory mFactory; private int[][] mThemeAttrs; private int mChangingConfigurations; Loading Loading @@ -125,7 +130,7 @@ public class ColorStateList implements Parcelable { } final ColorStateList csl = new ColorStateList(EMPTY, new int[] { color }); sCache.put(color, new WeakReference<ColorStateList>(csl)); sCache.put(color, new WeakReference<>(csl)); return csl; } } Loading @@ -141,11 +146,13 @@ public class ColorStateList implements Parcelable { */ private ColorStateList(ColorStateList orig) { if (orig != null) { mChangingConfigurations = orig.mChangingConfigurations; mStateSpecs = orig.mStateSpecs; mDefaultColor = orig.mDefaultColor; mIsOpaque = orig.mIsOpaque; // Deep copy, this may change due to theming. // Deep copy, these may change due to applyTheme(). mThemeAttrs = orig.mThemeAttrs.clone(); mColors = orig.mColors.clone(); } } Loading Loading @@ -329,6 +336,7 @@ public class ColorStateList implements Parcelable { * attributes. * * @return whether a theme can be applied to this color state list * @hide only for resource preloading */ public boolean canApplyTheme() { return mThemeAttrs != null; Loading @@ -336,10 +344,15 @@ public class ColorStateList implements Parcelable { /** * Applies a theme to this color state list. * <p> * <strong>Note:</strong> Applying a theme may affect the changing * configuration parameters of this color state list. After calling this * method, any dependent configurations must be updated by obtaining the * new configuration mask from {@link #getChangingConfigurations()}. * * @param t the theme to apply */ public void applyTheme(Theme t) { private void applyTheme(Theme t) { if (mThemeAttrs == null) { return; } Loading Loading @@ -376,6 +389,38 @@ public class ColorStateList implements Parcelable { onColorsChanged(); } /** * Returns an appropriately themed color state list. * * @param t the theme to apply * @return a copy of the color state list with the theme applied, or the * color state list itself if there were no unresolved theme * attributes * @hide only for resource preloading */ public ColorStateList obtainForTheme(Theme t) { if (t == null || !canApplyTheme()) { return this; } final ColorStateList clone = new ColorStateList(this); clone.applyTheme(t); return clone; } /** * Returns a mask of the configuration parameters for which this color * state list 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; } private int modulateColorAlpha(int baseColor, float alphaMod) { if (alphaMod == 1.0f) { return baseColor; Loading @@ -383,8 +428,7 @@ public class ColorStateList implements Parcelable { final int baseAlpha = Color.alpha(baseColor); final int alpha = MathUtils.constrain((int) (baseAlpha * alphaMod + 0.5f), 0, 255); final int color = (baseColor & 0xFFFFFF) | (alpha << 24); return color; return (baseColor & 0xFFFFFF) | (alpha << 24); } /** Loading Loading @@ -534,14 +578,18 @@ public class ColorStateList implements Parcelable { } /** * @return A factory that can create new instances of this ColorStateList. * @return a factory that can create new instances of this ColorStateList * @hide only for resource preloading */ ColorStateListFactory getFactory() { return new ColorStateListFactory(this); public ConstantState<ColorStateList> getConstantState() { if (mFactory != null) { mFactory = new ColorStateListFactory(this); } return mFactory; } static class ColorStateListFactory extends ConstantState<ColorStateList> { final ColorStateList mSrc; private static class ColorStateListFactory extends ConstantState<ColorStateList> { private final ColorStateList mSrc; public ColorStateListFactory(ColorStateList src) { mSrc = src; Loading @@ -559,13 +607,7 @@ public class ColorStateList implements Parcelable { @Override public ColorStateList newInstance(Resources res, Theme theme) { if (theme == null || !mSrc.canApplyTheme()) { return mSrc; } final ColorStateList clone = new ColorStateList(mSrc); clone.applyTheme(theme); return clone; return mSrc.obtainForTheme(theme); } } Loading
core/java/android/content/res/Resources.java +9 −8 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ import android.annotation.RawRes; import android.annotation.StringRes; import android.annotation.XmlRes; import android.content.pm.ActivityInfo; import android.content.res.ColorStateList.ColorStateListFactory; import android.graphics.Movie; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; Loading Loading @@ -112,8 +111,8 @@ public class Resources { private static final LongSparseArray<ConstantState>[] sPreloadedDrawables; private static final LongSparseArray<ConstantState> sPreloadedColorDrawables = new LongSparseArray<>(); private static final LongSparseArray<ColorStateListFactory> sPreloadedColorStateLists = new LongSparseArray<>(); private static final LongSparseArray<android.content.res.ConstantState<ColorStateList>> sPreloadedColorStateLists = new LongSparseArray<>(); // Pool of TypedArrays targeted to this Resources object. final SynchronizedPool<TypedArray> mTypedArrayPool = new SynchronizedPool<>(5); Loading Loading @@ -2667,7 +2666,8 @@ public class Resources { // Handle inline color definitions. if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) { final ColorStateListFactory factory = sPreloadedColorStateLists.get(key); final android.content.res.ConstantState<ColorStateList> factory = sPreloadedColorStateLists.get(key); if (factory != null) { return factory.newInstance(); } Loading @@ -2677,7 +2677,7 @@ public class Resources { if (mPreloading) { if (verifyPreloadConfig(value.changingConfigurations, 0, value.resourceId, "color")) { sPreloadedColorStateLists.put(key, csl.getFactory()); sPreloadedColorStateLists.put(key, csl.getConstantState()); } } Loading @@ -2691,7 +2691,8 @@ public class Resources { return csl; } final ColorStateListFactory factory = sPreloadedColorStateLists.get(key); final android.content.res.ConstantState<ColorStateList> factory = sPreloadedColorStateLists.get(key); if (factory != null) { csl = factory.newInstance(this, theme); } Loading @@ -2704,10 +2705,10 @@ public class Resources { if (mPreloading) { if (verifyPreloadConfig(value.changingConfigurations, 0, value.resourceId, "color")) { sPreloadedColorStateLists.put(key, csl.getFactory()); sPreloadedColorStateLists.put(key, csl.getConstantState()); } } else { cache.put(key, theme, csl.getFactory()); cache.put(key, theme, csl.getConstantState()); } } Loading
graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +1 −1 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable { @Override public int getChangingConfigurations() { return super.getChangingConfigurations() | mAnimatedVectorState.mChangingConfigurations; return super.getChangingConfigurations() | mAnimatedVectorState.getChangingConfigurations(); } @Override Loading