Fix tile color issues

Test: manual
Fixes: 183888161

Change-Id: I818d41246c892a2cb211170afadc110930f40ab1
This commit is contained in:
Fabian Kozynski
2021-03-31 10:46:44 -04:00
parent 81b1281672
commit b714201e33
2 changed files with 15 additions and 14 deletions

View File

@@ -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);
}

View File

@@ -56,6 +56,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 createLabel() {
@@ -113,13 +114,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
}
}