summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/notification/NotificationListener.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/notification/NotificationListener.java')
-rw-r--r--src/com/android/launcher3/notification/NotificationListener.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java
index 7b70df77e..114b2b8df 100644
--- a/src/com/android/launcher3/notification/NotificationListener.java
+++ b/src/com/android/launcher3/notification/NotificationListener.java
@@ -62,6 +62,7 @@ public class NotificationListener extends NotificationListenerService {
private static NotificationListener sNotificationListenerInstance = null;
private static NotificationsChangedListener sNotificationsChangedListener;
+ private static StatusBarNotificationsChangedListener sStatusBarNotificationsChangedListener;
private static boolean sIsConnected;
private static boolean sIsCreated;
@@ -180,10 +181,19 @@ public class NotificationListener extends NotificationListenerService {
}
}
+ public static void setStatusBarNotificationsChangedListener
+ (StatusBarNotificationsChangedListener listener) {
+ sStatusBarNotificationsChangedListener = listener;
+ }
+
public static void removeNotificationsChangedListener() {
sNotificationsChangedListener = null;
}
+ public static void removeStatusBarNotificationsChangedListener() {
+ sStatusBarNotificationsChangedListener = null;
+ }
+
@Override
public void onListenerConnected() {
super.onListenerConnected();
@@ -205,7 +215,10 @@ public class NotificationListener extends NotificationListenerService {
public void onNotificationPosted(final StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
mWorkerHandler.obtainMessage(MSG_NOTIFICATION_POSTED, new NotificationPostedMsg(sbn))
- .sendToTarget();
+ .sendToTarget();
+ if (sStatusBarNotificationsChangedListener != null) {
+ sStatusBarNotificationsChangedListener.onNotificationPosted(sbn);
+ }
}
/**
@@ -227,10 +240,13 @@ public class NotificationListener extends NotificationListenerService {
public void onNotificationRemoved(final StatusBarNotification sbn) {
super.onNotificationRemoved(sbn);
Pair<PackageUserKey, NotificationKeyData> packageUserKeyAndNotificationKey
- = new Pair<>(PackageUserKey.fromNotification(sbn),
- NotificationKeyData.fromNotification(sbn));
+ = new Pair<>(PackageUserKey.fromNotification(sbn),
+ NotificationKeyData.fromNotification(sbn));
mWorkerHandler.obtainMessage(MSG_NOTIFICATION_REMOVED, packageUserKeyAndNotificationKey)
- .sendToTarget();
+ .sendToTarget();
+ if (sStatusBarNotificationsChangedListener != null) {
+ sStatusBarNotificationsChangedListener.onNotificationRemoved(sbn);
+ }
NotificationGroup notificationGroup = mNotificationGroupMap.get(sbn.getGroupKey());
if (notificationGroup != null) {
@@ -318,4 +334,9 @@ public class NotificationListener extends NotificationListenerService {
NotificationKeyData notificationKey);
void onNotificationFullRefresh(List<StatusBarNotification> activeNotifications);
}
+
+ public interface StatusBarNotificationsChangedListener {
+ void onNotificationPosted(StatusBarNotification sbn);
+ void onNotificationRemoved(StatusBarNotification sbn);
+ }
}