summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/notification
diff options
context:
space:
mode:
authorGeorge Hodulik <georgehodulik@google.com>2017-12-14 11:28:04 -0800
committerGeorge Hodulik <georgehodulik@google.com>2018-01-16 11:56:13 -0800
commitfc1c96bde840c352fb6811641bf941e175a607dd (patch)
tree1206df119f263b0f28815b0a8d187cda734ea18e /src/com/android/launcher3/notification
parent07b1d670f21745525c4a6df1cf8c2172ad9bdec2 (diff)
downloadandroid_packages_apps_Trebuchet-fc1c96bde840c352fb6811641bf941e175a607dd.tar.gz
android_packages_apps_Trebuchet-fc1c96bde840c352fb6811641bf941e175a607dd.tar.bz2
android_packages_apps_Trebuchet-fc1c96bde840c352fb6811641bf941e175a607dd.zip
Added StatusBarNotificationsListener interface.
Change-Id: I62da2da4169835edf043bc085583adfb027bebbe
Diffstat (limited to 'src/com/android/launcher3/notification')
-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);
+ }
}