Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdfa88de authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix tile color issues" into sc-dev am: c8472887

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14052806

Change-Id: Id77b1d56ff16df2f274197f28ca2c5e1daf7e83c
parents 10c080c1 c8472887
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -43,7 +43,7 @@ public class QSTileView extends QSTileBaseView {
    protected TextView mLabel;
    protected TextView mLabel;
    protected TextView mSecondLine;
    protected TextView mSecondLine;
    private ImageView mPadLock;
    private ImageView mPadLock;
    private int mState;
    protected int mState;
    protected ViewGroup mLabelContainer;
    protected ViewGroup mLabelContainer;
    private View mExpandIndicator;
    private View mExpandIndicator;
    private View mExpandSpace;
    private View mExpandSpace;
@@ -133,14 +133,7 @@ public class QSTileView extends QSTileBaseView {
    protected void handleStateChanged(QSTile.State state) {
    protected void handleStateChanged(QSTile.State state) {
        super.handleStateChanged(state);
        super.handleStateChanged(state);
        if (!Objects.equals(mLabel.getText(), state.label) || mState != state.state) {
        if (!Objects.equals(mLabel.getText(), state.label) || mState != state.state) {
            ColorStateList labelColor;
            ColorStateList labelColor = getLabelColor(state.state);
            if (state.state == Tile.STATE_ACTIVE) {
                labelColor = mColorLabelActive;
            } else if (state.state == Tile.STATE_INACTIVE) {
                labelColor = mColorLabelInactive;
            } else {
                labelColor = mColorLabelUnavailable;
            }
            changeLabelColor(labelColor);
            changeLabelColor(labelColor);
            mState = state.state;
            mState = state.state;
            mLabel.setText(state.label);
            mLabel.setText(state.label);
@@ -163,6 +156,15 @@ public class QSTileView extends QSTileBaseView {
        mPadLock.setVisibility(state.disabledByPolicy ? View.VISIBLE : View.GONE);
        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) {
    protected void changeLabelColor(ColorStateList color) {
        mLabel.setTextColor(color);
        mLabel.setTextColor(color);
    }
    }
+4 −5
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@ open class QSTileViewHorizontal(
        addView(mIcon, 0, LayoutParams(iconSize, iconSize))
        addView(mIcon, 0, LayoutParams(iconSize, iconSize))


        mColorLabelActive = ColorStateList.valueOf(getColorForState(getContext(), STATE_ACTIVE))
        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) {
    override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
@@ -121,7 +122,6 @@ open class QSTileViewHorizontal(
        if (allowAnimations) {
        if (allowAnimations) {
            animateBackground(newColor)
            animateBackground(newColor)
        } else {
        } else {
            if (newColor != paintColor) {
            clearBackgroundAnimator()
            clearBackgroundAnimator()
            colorBackgroundDrawable?.setTintList(ColorStateList.valueOf(newColor))?.also {
            colorBackgroundDrawable?.setTintList(ColorStateList.valueOf(newColor))?.also {
                paintColor = newColor
                paintColor = newColor
@@ -129,7 +129,6 @@ open class QSTileViewHorizontal(
            paintColor = newColor
            paintColor = newColor
        }
        }
    }
    }
    }


    private fun animateBackground(newBackgroundColor: Int) {
    private fun animateBackground(newBackgroundColor: Int) {
        if (newBackgroundColor != paintColor) {
        if (newBackgroundColor != paintColor) {