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

Commit 14016e38 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Change the label color to textColorSecondary

This change is made for contrast purposes between the text and light
background.

Also, removed setting a Spannable in State.label just to override the
color.

Test: visual, light and dark mode
Fixes: 114481291
Change-Id: I8b85a2778fa166f820a41d5dd783b00c71fe6f83
parent bd39e731
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -44,8 +44,7 @@
            android:padding="0dp"
            android:gravity="center"
            android:ellipsize="marquee"
            android:textAppearance="@style/TextAppearance.QS.TileLabel"
            android:textColor="?android:attr/textColorPrimary"/>
            android:textAppearance="@style/TextAppearance.QS.TileLabel"/>

        <ImageView android:id="@+id/restricted_padlock"
            android:layout_width="@dimen/qs_tile_text_size"
+11 −8
Original line number Diff line number Diff line
@@ -15,11 +15,10 @@
package com.android.systemui.qs.tileimpl;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.service.quicksettings.Tile;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -27,6 +26,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.settingslib.Utils;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.plugins.qs.QSIconView;
@@ -46,6 +46,8 @@ public class QSTileView extends QSTileBaseView {
    private ViewGroup mLabelContainer;
    private View mExpandIndicator;
    private View mExpandSpace;
    private ColorStateList mColorLabelDefault;
    private ColorStateList mColorLabelUnavailable;

    public QSTileView(Context context, QSIconView icon) {
        this(context, icon, false);
@@ -62,6 +64,11 @@ public class QSTileView extends QSTileBaseView {
        createLabel();
        setOrientation(VERTICAL);
        setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
        mColorLabelDefault = Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary);
        // The text color for unavailable tiles is textColorSecondary, same as secondaryLabel for
        // contrast purposes
        mColorLabelUnavailable = Utils.getColorAttr(getContext(),
                android.R.attr.textColorSecondary);
    }

    TextView getLabel() {
@@ -111,12 +118,8 @@ public class QSTileView extends QSTileBaseView {
    protected void handleStateChanged(QSTile.State state) {
        super.handleStateChanged(state);
        if (!Objects.equals(mLabel.getText(), state.label) || mState != state.state) {
            if (state.state == Tile.STATE_UNAVAILABLE) {
                int color = QSTileImpl.getColorForState(getContext(), state.state);
                state.label = new SpannableStringBuilder().append(state.label,
                        new ForegroundColorSpan(color),
                        SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE);
            }
            mLabel.setTextColor(state.state == Tile.STATE_UNAVAILABLE ? mColorLabelUnavailable
                    : mColorLabelDefault);
            mState = state.state;
            mLabel.setText(state.label);
        }