Merge "Fix tile color issues" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c8472887fc
@@ -43,7 +43,7 @@ public class QSTileView extends QSTileBaseView {
|
||||
protected TextView mLabel;
|
||||
protected TextView mSecondLine;
|
||||
private ImageView mPadLock;
|
||||
private int mState;
|
||||
protected int mState;
|
||||
protected ViewGroup mLabelContainer;
|
||||
private View mExpandIndicator;
|
||||
private View mExpandSpace;
|
||||
@@ -133,14 +133,7 @@ public class QSTileView extends QSTileBaseView {
|
||||
protected void handleStateChanged(QSTile.State state) {
|
||||
super.handleStateChanged(state);
|
||||
if (!Objects.equals(mLabel.getText(), state.label) || mState != state.state) {
|
||||
ColorStateList labelColor;
|
||||
if (state.state == Tile.STATE_ACTIVE) {
|
||||
labelColor = mColorLabelActive;
|
||||
} else if (state.state == Tile.STATE_INACTIVE) {
|
||||
labelColor = mColorLabelInactive;
|
||||
} else {
|
||||
labelColor = mColorLabelUnavailable;
|
||||
}
|
||||
ColorStateList labelColor = getLabelColor(state.state);
|
||||
changeLabelColor(labelColor);
|
||||
mState = state.state;
|
||||
mLabel.setText(state.label);
|
||||
@@ -163,6 +156,15 @@ public class QSTileView extends QSTileBaseView {
|
||||
mPadLock.setVisibility(state.disabledByPolicy ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
protected final ColorStateList getLabelColor(int state) {
|
||||
if (state == Tile.STATE_ACTIVE) {
|
||||
return mColorLabelActive;
|
||||
} else if (state == Tile.STATE_INACTIVE) {
|
||||
return mColorLabelInactive;
|
||||
}
|
||||
return mColorLabelUnavailable;
|
||||
}
|
||||
|
||||
protected void changeLabelColor(ColorStateList color) {
|
||||
mLabel.setTextColor(color);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ open class QSTileViewHorizontal(
|
||||
addView(mIcon, 0, LayoutParams(iconSize, iconSize))
|
||||
|
||||
mColorLabelActive = ColorStateList.valueOf(getColorForState(getContext(), STATE_ACTIVE))
|
||||
changeLabelColor(getLabelColor(mState)) // Matches the default state of the tile
|
||||
}
|
||||
|
||||
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
||||
@@ -121,13 +122,11 @@ open class QSTileViewHorizontal(
|
||||
if (allowAnimations) {
|
||||
animateBackground(newColor)
|
||||
} else {
|
||||
if (newColor != paintColor) {
|
||||
clearBackgroundAnimator()
|
||||
colorBackgroundDrawable?.setTintList(ColorStateList.valueOf(newColor))?.also {
|
||||
paintColor = newColor
|
||||
}
|
||||
clearBackgroundAnimator()
|
||||
colorBackgroundDrawable?.setTintList(ColorStateList.valueOf(newColor))?.also {
|
||||
paintColor = newColor
|
||||
}
|
||||
paintColor = newColor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user