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

Commit 450b3311 authored by Raff Tsai's avatar Raff Tsai Committed by Android (Google) Code Review
Browse files

Merge "Fix Disabled text color in dark theme"

parents 40a41861 c9e26ba7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -663,7 +663,8 @@ public class RestrictedLockUtilsInternal extends RestrictedLockUtils {
        final SpannableStringBuilder sb = new SpannableStringBuilder(textView.getText());
        removeExistingRestrictedSpans(sb);
        if (disabled) {
            final int disabledColor = context.getColor(R.color.disabled_text_color);
            final int disabledColor = Utils.getDisabled(context,
                    textView.getCurrentTextColor());
            sb.setSpan(new ForegroundColorSpan(disabledColor), 0, sb.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            textView.setCompoundDrawables(null, null, getRestrictedPadlock(context), null);
+7 −0
Original line number Diff line number Diff line
@@ -218,6 +218,13 @@ public class Utils {
        return list.getDefaultColor();
    }

    /**
     * This method computes disabled color from normal color
     *
     * @param context
     * @param inputColor normal color.
     * @return disabled color.
     */
    @ColorInt
    public static int getDisabled(Context context, int inputColor) {
        return applyAlphaAttr(context, android.R.attr.disabledAlpha, inputColor);
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settingslib.utils;

import android.content.Context;
import android.content.res.TypedArray;

/** Utility class for getting color attribute **/
public class ColorUtil {

    /**
     * Returns android:disabledAlpha value in context
     */
    public static float getDisabledAlpha(Context context) {
        final TypedArray ta = context.obtainStyledAttributes(
                new int[]{android.R.attr.disabledAlpha});
        final float alpha = ta.getFloat(0, 0);
        ta.recycle();
        return alpha;
    }
}