diff options
author | Tony Wickham <twickham@google.com> | 2017-02-17 17:03:30 -0800 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2017-03-01 09:35:17 -0800 |
commit | d670b995d28615113687e432f6c098aa4cf7b303 (patch) | |
tree | 4106aea5f603573cef0f23c889564fa9f6ed2fa3 | |
parent | 7f3526a1a4d5d3578d4648abb1422646d23c6080 (diff) | |
download | android_packages_apps_Trebuchet-d670b995d28615113687e432f6c098aa4cf7b303.tar.gz android_packages_apps_Trebuchet-d670b995d28615113687e432f6c098aa4cf7b303.tar.bz2 android_packages_apps_Trebuchet-d670b995d28615113687e432f6c098aa4cf7b303.zip |
Respect badge settings to filter out badges
Bug: 35405389
Bug: 32410600
Change-Id: I8e7b928a6cf7d9a66df8cb056bd73eaa45f68e6c
-rw-r--r-- | src/com/android/launcher3/notification/NotificationListener.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java index a627d238e..9b881548a 100644 --- a/src/com/android/launcher3/notification/NotificationListener.java +++ b/src/com/android/launcher3/notification/NotificationListener.java @@ -55,6 +55,8 @@ public class NotificationListener extends NotificationListenerService { private final Handler mWorkerHandler; private final Handler mUiHandler; + private Ranking mTempRanking = new Ranking(); + private Handler.Callback mWorkerCallback = new Handler.Callback() { @Override public boolean handleMessage(Message message) { @@ -166,7 +168,7 @@ public class NotificationListener extends NotificationListenerService { NotificationPostedMsg(StatusBarNotification sbn) { packageUserKey = PackageUserKey.fromNotification(sbn); notificationKey = sbn.getKey(); - shouldBeFilteredOut = shouldBeFilteredOut(sbn.getNotification()); + shouldBeFilteredOut = shouldBeFilteredOut(sbn); } } @@ -190,14 +192,14 @@ public class NotificationListener extends NotificationListenerService { * Filter out notifications that don't have an intent * or are headers for grouped notifications. * - * TODO: use the system concept of a badged notification instead + * @see #shouldBeFilteredOut(StatusBarNotification) */ private List<StatusBarNotification> filterNotifications( StatusBarNotification[] notifications) { if (notifications == null) return null; Set<Integer> removedNotifications = new HashSet<>(); for (int i = 0; i < notifications.length; i++) { - if (shouldBeFilteredOut(notifications[i].getNotification())) { + if (shouldBeFilteredOut(notifications[i])) { removedNotifications.add(i); } } @@ -211,7 +213,12 @@ public class NotificationListener extends NotificationListenerService { return filteredNotifications; } - private boolean shouldBeFilteredOut(Notification notification) { + private boolean shouldBeFilteredOut(StatusBarNotification sbn) { + getCurrentRanking().getRanking(sbn.getKey(), mTempRanking); + if (!mTempRanking.canShowBadge()) { + return true; + } + Notification notification = sbn.getNotification(); boolean isGroupHeader = (notification.flags & Notification.FLAG_GROUP_SUMMARY) != 0; return (notification.contentIntent == null || isGroupHeader); } |