summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/notification/NotificationListener.java40
-rw-r--r--src/com/android/launcher3/popup/PopupDataProvider.java23
2 files changed, 40 insertions, 23 deletions
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java
index 206bb31d4..5c16176f5 100644
--- a/src/com/android/launcher3/notification/NotificationListener.java
+++ b/src/com/android/launcher3/notification/NotificationListener.java
@@ -80,9 +80,9 @@ public class NotificationListener extends NotificationListenerService {
switch (message.what) {
case MSG_NOTIFICATION_POSTED:
if (sNotificationsChangedListener != null) {
- Pair<PackageUserKey, String> pair
- = (Pair<PackageUserKey, String>) message.obj;
- sNotificationsChangedListener.onNotificationPosted(pair.first, pair.second);
+ NotificationPostedMsg msg = (NotificationPostedMsg) message.obj;
+ sNotificationsChangedListener.onNotificationPosted(msg.packageUserKey,
+ msg.notificationKey, msg.shouldBeFilteredOut);
}
break;
case MSG_NOTIFICATION_REMOVED:
@@ -149,23 +149,32 @@ public class NotificationListener extends NotificationListenerService {
@Override
public void onNotificationPosted(final StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
- if (!shouldBeFilteredOut(sbn.getNotification())) {
- Pair<PackageUserKey, String> packageUserKeyAndNotificationKey
- = new Pair<>(PackageUserKey.fromNotification(sbn), sbn.getKey());
- mWorkerHandler.obtainMessage(MSG_NOTIFICATION_POSTED, packageUserKeyAndNotificationKey)
- .sendToTarget();
+ mWorkerHandler.obtainMessage(MSG_NOTIFICATION_POSTED, new NotificationPostedMsg(sbn))
+ .sendToTarget();
+ }
+
+ /**
+ * An object containing data to send to MSG_NOTIFICATION_POSTED targets.
+ */
+ private class NotificationPostedMsg {
+ PackageUserKey packageUserKey;
+ String notificationKey;
+ boolean shouldBeFilteredOut;
+
+ NotificationPostedMsg(StatusBarNotification sbn) {
+ packageUserKey = PackageUserKey.fromNotification(sbn);
+ notificationKey = sbn.getKey();
+ shouldBeFilteredOut = shouldBeFilteredOut(sbn.getNotification());
}
}
@Override
public void onNotificationRemoved(final StatusBarNotification sbn) {
super.onNotificationRemoved(sbn);
- if (!shouldBeFilteredOut(sbn.getNotification())) {
- Pair<PackageUserKey, String> packageUserKeyAndNotificationKey
- = new Pair<>(PackageUserKey.fromNotification(sbn), sbn.getKey());
- mWorkerHandler.obtainMessage(MSG_NOTIFICATION_REMOVED, packageUserKeyAndNotificationKey)
- .sendToTarget();
- }
+ Pair<PackageUserKey, String> packageUserKeyAndNotificationKey
+ = new Pair<>(PackageUserKey.fromNotification(sbn), sbn.getKey());
+ mWorkerHandler.obtainMessage(MSG_NOTIFICATION_REMOVED, packageUserKeyAndNotificationKey)
+ .sendToTarget();
}
/** This makes a potentially expensive binder call and should be run on a background thread. */
@@ -206,7 +215,8 @@ public class NotificationListener extends NotificationListenerService {
}
public interface NotificationsChangedListener {
- void onNotificationPosted(PackageUserKey postedPackageUserKey, String notificationKey);
+ void onNotificationPosted(PackageUserKey postedPackageUserKey, String notificationKey,
+ boolean shouldBeFilteredOut);
void onNotificationRemoved(PackageUserKey removedPackageUserKey, String notificationKey);
void onNotificationFullRefresh(List<StatusBarNotification> activeNotifications);
}
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java
index c754fda99..e314b646b 100644
--- a/src/com/android/launcher3/popup/PopupDataProvider.java
+++ b/src/com/android/launcher3/popup/PopupDataProvider.java
@@ -58,19 +58,26 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
}
@Override
- public void onNotificationPosted(PackageUserKey postedPackageUserKey, String notificationKey) {
+ public void onNotificationPosted(PackageUserKey postedPackageUserKey, String notificationKey,
+ boolean shouldBeFilteredOut) {
BadgeInfo badgeInfo = mPackageUserToBadgeInfos.get(postedPackageUserKey);
- boolean notificationWasAdded; // As opposed to updated.
+ boolean notificationWasAddedOrRemoved; // As opposed to updated.
if (badgeInfo == null) {
- BadgeInfo newBadgeInfo = new BadgeInfo(postedPackageUserKey);
- newBadgeInfo.addNotificationKeyIfNotExists(notificationKey);
- mPackageUserToBadgeInfos.put(postedPackageUserKey, newBadgeInfo);
- notificationWasAdded = true;
+ if (!shouldBeFilteredOut) {
+ BadgeInfo newBadgeInfo = new BadgeInfo(postedPackageUserKey);
+ newBadgeInfo.addNotificationKeyIfNotExists(notificationKey);
+ mPackageUserToBadgeInfos.put(postedPackageUserKey, newBadgeInfo);
+ notificationWasAddedOrRemoved = true;
+ } else {
+ notificationWasAddedOrRemoved = false;
+ }
} else {
- notificationWasAdded = badgeInfo.addNotificationKeyIfNotExists(notificationKey);
+ notificationWasAddedOrRemoved = shouldBeFilteredOut
+ ? badgeInfo.removeNotificationKey(notificationKey)
+ : badgeInfo.addNotificationKeyIfNotExists(notificationKey);
}
updateLauncherIconBadges(Utilities.singletonHashSet(postedPackageUserKey),
- notificationWasAdded);
+ notificationWasAddedOrRemoved);
}
@Override