Allow use of theme attributes in color state lists
BUG: 17384842 Change-Id: Ibdc413acbd00e37b908432abd55f6521c22b8fc9
This commit is contained in:
@@ -402,7 +402,7 @@ public class ShapeDrawable extends Drawable {
|
||||
}
|
||||
|
||||
// Update local properties.
|
||||
initializeWithState(mShapeState, r);
|
||||
updateLocalState(r);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -410,16 +410,23 @@ public class ShapeDrawable extends Drawable {
|
||||
super.applyTheme(t);
|
||||
|
||||
final ShapeState state = mShapeState;
|
||||
if (state == null || state.mThemeAttrs == null) {
|
||||
if (state == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.ShapeDrawable);
|
||||
updateStateFromTypedArray(a);
|
||||
a.recycle();
|
||||
if (state.mThemeAttrs != null) {
|
||||
final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.ShapeDrawable);
|
||||
updateStateFromTypedArray(a);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
// Apply theme to contained color state list.
|
||||
if (state.mTint != null && state.mTint.canApplyTheme()) {
|
||||
state.mTint.applyTheme(t);
|
||||
}
|
||||
|
||||
// Update local properties.
|
||||
initializeWithState(state, t.getResources());
|
||||
updateLocalState(t.getResources());
|
||||
}
|
||||
|
||||
private void updateStateFromTypedArray(TypedArray a) {
|
||||
@@ -550,7 +557,8 @@ public class ShapeDrawable extends Drawable {
|
||||
|
||||
@Override
|
||||
public boolean canApplyTheme() {
|
||||
return mThemeAttrs != null;
|
||||
return mThemeAttrs != null
|
||||
|| (mTint != null && mTint.canApplyTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -576,7 +584,7 @@ public class ShapeDrawable extends Drawable {
|
||||
private ShapeDrawable(ShapeState state, Resources res) {
|
||||
mShapeState = state;
|
||||
|
||||
initializeWithState(state, res);
|
||||
updateLocalState(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -584,8 +592,8 @@ public class ShapeDrawable extends Drawable {
|
||||
* after significant state changes, e.g. from the One True Constructor and
|
||||
* after inflating or applying a theme.
|
||||
*/
|
||||
private void initializeWithState(ShapeState state, Resources res) {
|
||||
mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
|
||||
private void updateLocalState(Resources res) {
|
||||
mTintFilter = updateTintFilter(mTintFilter, mShapeState.mTint, mShapeState.mTintMode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user