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

Commit 34942ab7 authored by Tony Mak's avatar Tony Mak
Browse files

Use the correct drawable to badge user icon

Also, ic_corp_user_badge is now tinted by default color, insteaad
on white by default.

Test: Create managed user, observe the icon is now blue on white.
Test: Wifi data usage, observe the icon of "All work apps" are now
grey instead of white.

FIXES: 71568987
Merged-In:Ic6c8ed15644c6e7894f2a84320077a3962603b5b

Change-Id: Ic6c8ed15644c6e7894f2a84320077a3962603b5b
parent 4b306e5e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
        android:width="36dp"
        android:height="36dp"
        android:viewportWidth="36.0"
        android:viewportHeight="36.0">
        android:viewportHeight="36.0"
        android:tint="?attr/colorControlNormal">
    <path
        android:pathData="M16.3,11.3h3.4v1.7h-3.4z"
        android:fillColor="#FFFFFF"/>
+1 −2
Original line number Diff line number Diff line
package com.android.settingslib;

import android.annotation.ColorInt;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
@@ -142,7 +141,7 @@ public class Utils {
    public static Drawable getUserIcon(Context context, UserManager um, UserInfo user) {
        final int iconSize = UserIconDrawable.getSizeForList(context);
        if (user.isManagedProfile()) {
            Drawable drawable =  UserIconDrawable.getManagedUserBadgeDrawable(context);
            Drawable drawable =  UserIconDrawable.getManagedUserDrawable(context);
            drawable.setBounds(0, 0, iconSize, iconSize);
            return drawable;
        }
+17 −8
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settingslib.drawable;

import android.annotation.DrawableRes;
import android.annotation.NonNull;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -36,6 +37,7 @@ import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;

import com.android.settingslib.R;

@@ -69,15 +71,23 @@ public class UserIconDrawable extends Drawable implements Drawable.Callback {
    private float mBadgeMargin;

    /**
     * Gets the system default managed-user badge as a drawable
     * Gets the system default managed-user badge as a drawable. This drawable is tint-able.
     * For badging purpose, consider
     * {@link android.content.pm.PackageManager#getUserBadgedDrawableForDensity(Drawable, UserHandle, Rect, int)}.
     *
     * @param context
     * @return drawable containing just the badge
     */
    public static Drawable getManagedUserBadgeDrawable(Context context) {
        int displayDensity = context.getResources().getDisplayMetrics().densityDpi;
    public static Drawable getManagedUserDrawable(Context context) {
        return getDrawableForDisplayDensity
                (context, com.android.internal.R.drawable.ic_corp_user_badge);
    }

    private static Drawable getDrawableForDisplayDensity(
            Context context, @DrawableRes int drawable) {
        int density = context.getResources().getDisplayMetrics().densityDpi;
        return context.getResources().getDrawableForDensity(
                com.android.internal.R.drawable.ic_corp_user_badge,
                displayDensity, context.getTheme());
                drawable, density, context.getTheme());
    }

    /**
@@ -164,7 +174,8 @@ public class UserIconDrawable extends Drawable implements Drawable.Callback {
        boolean isManaged = context.getSystemService(DevicePolicyManager.class)
                .getProfileOwnerAsUser(userId) != null;
        if (isManaged) {
            badge = getManagedUserBadgeDrawable(context);
            badge = getDrawableForDisplayDensity(
                    context, com.android.internal.R.drawable.ic_corp_badge_case);
        }
        return setBadge(badge);
    }
@@ -322,7 +333,6 @@ public class UserIconDrawable extends Drawable implements Drawable.Callback {
                    mIntrinsicRadius, mIconPaint);
            canvas.restoreToCount(saveId);
        }

        if (mFrameColor != null) {
            mFramePaint.setColor(mFrameColor.getColorForState(getState(), Color.TRANSPARENT));
        }
@@ -343,7 +353,6 @@ public class UserIconDrawable extends Drawable implements Drawable.Callback {
            final float borderRadius = mBadge.getBounds().width() * 0.5f + mBadgeMargin;
            canvas.drawCircle(badgeLeft + mBadgeRadius, badgeTop + mBadgeRadius,
                    borderRadius, mClearPaint);

            mBadge.draw(canvas);
        }
    }