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

Commit bd84de8b authored by Brandon Dayauon's avatar Brandon Dayauon
Browse files

Create creation flag to not show any user badge when FLAGGED: FLAG_SKIP_USER_BADGE.

FLAG_SKIP_USER_BADGE to not show any badge based on the BITMAP_INFO flag.

bug: 276957152
Flag: n/a
Test: manual -
before: https://screenshot.googleplex.com/BXShenE2kGrZXtF
after: https://screenshot.googleplex.com/AVYxpDyJ7JGet8h
Change-Id: Iadaae9049abafb754af93eb8dbba9f0474f90832
parent f6b03684
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -41,9 +41,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 {}

@@ -153,20 +155,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 context.getDrawable(isThemed
                    ? R.drawable.ic_instant_app_badge_themed