From 9a8d11f930ced4c2706db150b7bbbb21330bd68d Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 11 Jan 2017 09:53:12 -0800 Subject: 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 --- src/com/android/launcher3/BubbleTextView.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/com/android/launcher3/BubbleTextView.java') diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index b8b43c9c3..77572c7f7 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -39,6 +39,8 @@ import android.widget.TextView; 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 @@ public class BubbleTextView extends TextView applyIconAndLabel(info.iconBitmap, info); setTag(info); if (promiseStateChanged || info.isPromise()) { - applyState(promiseStateChanged); + applyPromiseState(promiseStateChanged); } } @@ -470,7 +472,7 @@ public class BubbleTextView extends TextView 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 @@ public class BubbleTextView extends TextView 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 class BubbleTextView extends TextView } } + 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) && -- cgit v1.2.3