Add NotificationListener to launcher.
- NotificationListener extends NotificationListenerService, and is
added to the manifest.
- Added PopupDataProvider, which contains logic for storing and
interacting with data that goes into the long-press popup menu
(shortcuts and notifications). A follow-up CL will rename
DeepShortcutsContainer to a generic PopupContainerWithArrow.
- If Launcher has notification access, NotificationListener will
get callbacks when notifications are posted and removed; upon
receiving these callbacks, NotificationListener passes them to
PopupDataProvider via a NotificationsChangedListener interface.
- Upon receiving the changed notifications, PopupDataProvider maps
them to the corresponding package/user and tells launcher to
update relevant icons on the workspace and all apps.
This is guarded by FeatureFlags.BADGE_ICONS.
Bug: 32410600
Change-Id: I59aeb31a7f92399c9c4b831ab551e51e13f44f5c
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index b3e59f9..587d445 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -30,12 +30,13 @@
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
+import android.util.Log;
import android.util.SparseArray;
import android.view.animation.DecelerateInterpolator;
-import com.android.launcher3.graphics.IconPalette;
-import com.android.launcher3.badge.BadgeRenderer;
import com.android.launcher3.badge.BadgeInfo;
+import com.android.launcher3.badge.BadgeRenderer;
+import com.android.launcher3.graphics.IconPalette;
public class FastBitmapDrawable extends Drawable {
private static final float DISABLED_DESATURATION = 1f;
@@ -123,13 +124,17 @@
}
public void applyIconBadge(BadgeInfo badgeInfo, BadgeRenderer badgeRenderer) {
+ boolean wasBadged = mBadgeInfo != null;
+ boolean isBadged = badgeInfo != null;
mBadgeInfo = badgeInfo;
mBadgeRenderer = badgeRenderer;
- if (mIconPalette == null) {
- mIconPalette = IconPalette.fromDominantColor(Utilities
- .findDominantColorByHue(mBitmap, 20));
+ if (wasBadged || isBadged) {
+ if (mBadgeInfo != null && mIconPalette == null) {
+ mIconPalette = IconPalette.fromDominantColor(Utilities
+ .findDominantColorByHue(mBitmap, 20));
+ }
+ invalidateSelf();
}
- invalidateSelf();
}
@Override
@@ -157,7 +162,7 @@
}
private boolean hasBadge() {
- return mBadgeInfo != null && mBadgeInfo.getNotificationCount() != null;
+ return mBadgeInfo != null && mBadgeInfo.getNotificationCount() != 0;
}
@Override