Loading packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java +2 −1 Original line number Diff line number Diff line Loading @@ -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); Loading packages/SettingsLib/src/com/android/settingslib/Utils.java +7 −0 Original line number Diff line number Diff line Loading @@ -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); Loading packages/SettingsLib/src/com/android/settingslib/utils/ColorUtil.java 0 → 100644 +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; } } Loading
packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java +2 −1 Original line number Diff line number Diff line Loading @@ -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); Loading
packages/SettingsLib/src/com/android/settingslib/Utils.java +7 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
packages/SettingsLib/src/com/android/settingslib/utils/ColorUtil.java 0 → 100644 +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; } }