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

Commit 51c5b4f2 authored by Brandon Dayauon's avatar Brandon Dayauon Committed by Android (Google) Code Review
Browse files

Merge "Revert "Revert "Create creation flag to not show any user badge ..."" into main

parents 92f48650 ad8b94d3
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -43,9 +43,11 @@ public class BitmapInfo {

    public static final int FLAG_THEMED = 1 << 0;
    public static final int FLAG_NO_BADGE = 1 << 1;
    public static final int FLAG_SKIP_USER_BADGE = 1 << 2;
    @IntDef(flag = true, value = {
            FLAG_THEMED,
            FLAG_NO_BADGE,
            FLAG_SKIP_USER_BADGE,
    })
    public @interface DrawableCreationFlags {}

@@ -155,20 +157,32 @@ public class BitmapInfo {
        drawable.mDisabledAlpha = GraphicsUtils.getFloat(context, R.attr.disabledIconAlpha, 1f);
        drawable.mCreationFlags = creationFlags;
        if ((creationFlags & FLAG_NO_BADGE) == 0) {
            Drawable badge = getBadgeDrawable(context, (creationFlags & FLAG_THEMED) != 0);
            Drawable badge = getBadgeDrawable(context, (creationFlags & FLAG_THEMED) != 0,
                    (creationFlags & FLAG_SKIP_USER_BADGE) != 0);
            if (badge != null) {
                drawable.setBadge(badge);
            }
        }
    }

    public Drawable getBadgeDrawable(Context context, boolean isThemed) {
        return getBadgeDrawable(context, isThemed, false);
    }

    /**
     * Returns a drawable representing the badge for this info
     */
    @Nullable
    public Drawable getBadgeDrawable(Context context, boolean isThemed) {
    private Drawable getBadgeDrawable(Context context, boolean isThemed, boolean skipUserBadge) {
        if (badgeInfo != null) {
            return badgeInfo.newIcon(context, isThemed ? FLAG_THEMED : 0);
            int creationFlag = isThemed ? FLAG_THEMED : 0;
            if (skipUserBadge) {
                creationFlag |= FLAG_SKIP_USER_BADGE;
            }
            return badgeInfo.newIcon(context, creationFlag);
        }
        if (skipUserBadge) {
            return null;
        } else if ((flags & FLAG_INSTANT) != 0) {
            return new UserBadgeDrawable(context, R.drawable.ic_instant_app_badge,
                    R.color.badge_tint_instant, isThemed);