FastBitmapDrawable can draw an icon badge (notification count)
- Added BadgeInfo to contain data to be shown in a badge
(currently just notification count).
- Added BadgeRenderer in DeviceProfile to contain things
relevant to drawing the badge, such as size and Paint's.
- Added IconPalette to compute colors for the badge based
on a dominant color (will also be used for notifications)
- FastBitmapDrawable uses these classes to draw the badge.
Bug: 32410600
Change-Id: I6595a4879943357590f7d20c22594691a573ecaf
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index b8b43c9..77572c7 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -39,6 +39,8 @@
import com.android.launcher3.IconCache.IconLoadRequest;
import com.android.launcher3.IconCache.ItemInfoUpdateReceiver;
+import com.android.launcher3.badge.BadgeRenderer;
+import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.DrawableFactory;
import com.android.launcher3.graphics.HolographicOutlineHelper;
@@ -164,7 +166,7 @@
applyIconAndLabel(info.iconBitmap, info);
setTag(info);
if (promiseStateChanged || info.isPromise()) {
- applyState(promiseStateChanged);
+ applyPromiseState(promiseStateChanged);
}
}
@@ -470,7 +472,7 @@
mLongPressHelper.cancelLongPress();
}
- public void applyState(boolean promiseStateChanged) {
+ public void applyPromiseState(boolean promiseStateChanged) {
if (getTag() instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) getTag();
final boolean isPromise = info.isPromise();
@@ -479,8 +481,8 @@
info.getInstallProgress() : 0)) : 100;
setContentDescription(progressLevel > 0 ?
- getContext().getString(R.string.app_downloading_title, info.title,
- NumberFormat.getPercentInstance().format(progressLevel * 0.01)) :
+ getContext().getString(R.string.app_downloading_title, info.title,
+ NumberFormat.getPercentInstance().format(progressLevel * 0.01)) :
getContext().getString(R.string.app_waiting_download_title, info.title));
if (mIcon != null) {
@@ -500,6 +502,13 @@
}
}
+ public void applyBadgeState(BadgeInfo badgeInfo) {
+ if (mIcon instanceof FastBitmapDrawable) {
+ BadgeRenderer badgeRenderer = mLauncher.getDeviceProfile().mBadgeRenderer;
+ ((FastBitmapDrawable) mIcon).applyIconBadge(badgeInfo, badgeRenderer);
+ }
+ }
+
private Theme getPreloaderTheme() {
Object tag = getTag();
int style = ((tag != null) && (tag instanceof ShortcutInfo) &&