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

Commit 9f77a717 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Add extra utility method to RestrictedLockUtils.

Change-Id: I558c975e5b35622cc7a4c1e8a8b16e6492ce983f
parent 0c575969
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -215,6 +215,25 @@ public class RestrictedLockUtils {
        textView.setText(sb);
    }

    /**
     * Takes a {@link android.widget.TextView} and applies an alpha so that the text looks like
     * disabled and appends a padlock to the text. This assumes that there are no
     * ForegroundColorSpans and RestrictedLockImageSpans used on the TextView.
     */
    public static void setTextViewAsDisabledByAdmin(Context context,
            TextView textView, boolean disabled) {
        final SpannableStringBuilder sb = new SpannableStringBuilder(textView.getText());
        removeExistingRestrictedSpans(sb);
        if (disabled) {
            final int disabledColor = context.getColor(R.color.disabled_text_color);
            sb.setSpan(new ForegroundColorSpan(disabledColor), 0, sb.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            final ImageSpan image = new RestrictedLockImageSpan(context);
            sb.append(" ", image, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        textView.setText(sb);
    }

    public static class EnforcedAdmin {
        public ComponentName component = null;
        public int userId = UserHandle.USER_NULL;