Updating icon badging logic

Bug: 201682172
Test: Manual
Change-Id: I57421b0c77e12f1cd464e532d2a1383c2cf93981
This commit is contained in:
Sunny Goyal
2021-11-24 18:07:04 -08:00
parent a930bca528
commit d872a97bd0
21 changed files with 71 additions and 171 deletions

View File

@@ -18,6 +18,8 @@ package com.android.launcher3;
import static com.android.launcher3.config.FeatureFlags.ENABLE_ICON_LABEL_AUTO_SCALING;
import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon;
import static com.android.launcher3.icons.BitmapInfo.FLAG_NO_BADGE;
import static com.android.launcher3.icons.BitmapInfo.FLAG_THEMED;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
import android.animation.Animator;
@@ -144,6 +146,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
private final boolean mIsRtl;
private final int mIconSize;
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mHideBadge = false;
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mIsIconVisible = true;
@ViewDebug.ExportedProperty(category = "launcher")
@@ -241,6 +245,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
public void setHideBadge(boolean hideBadge) {
mHideBadge = hideBadge;
}
/**
* Resets the view so it can be recycled.
*/
@@ -364,7 +372,11 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
protected void applyIconAndLabel(ItemInfoWithIcon info) {
boolean useTheme = mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER
|| mDisplay == DISPLAY_TASKBAR;
FastBitmapDrawable iconDrawable = info.newIcon(getContext(), useTheme);
int flags = useTheme ? FLAG_THEMED : 0;
if (mHideBadge) {
flags |= FLAG_NO_BADGE;
}
FastBitmapDrawable iconDrawable = info.newIcon(getContext(), flags);
mDotParams.color = IconPalette.getMutedColor(iconDrawable.getIconColor(), 0.54f);
setIcon(iconDrawable);