summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/popup
diff options
context:
space:
mode:
authorPinyao Ting <pinyaoting@google.com>2019-07-30 11:50:54 -0700
committerPinyao Ting <pinyaoting@google.com>2019-08-01 02:47:24 +0000
commit0cd5bd5f950a044827fce628c5bff163005a3b55 (patch)
tree613cdb9c70d07c90bb4585fc83c9ddc0153e882b /src/com/android/launcher3/popup
parentb647d79e45fdc2d69b0d093497cb718968d307d4 (diff)
downloadandroid_packages_apps_Trebuchet-0cd5bd5f950a044827fce628c5bff163005a3b55.tar.gz
android_packages_apps_Trebuchet-0cd5bd5f950a044827fce628c5bff163005a3b55.tar.bz2
android_packages_apps_Trebuchet-0cd5bd5f950a044827fce628c5bff163005a3b55.zip
Ensure each dot contains only relevant notification to the shortcut
and displays system shortcut when long click on deep shortcut. In this CR we 1) for each shortcut, we filters the notifications to ensure we only get notifications with identical shortcutId. 2) allow system shortcut to be displayed when user long click on a DeepShortcut Bug: 132336512 Change-Id: Idc9eaed55e900ed4027a43ee9c3fd7dc6f4480b2
Diffstat (limited to 'src/com/android/launcher3/popup')
-rw-r--r--src/com/android/launcher3/popup/PopupDataProvider.java35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java
index dd496b02b..6e4883e41 100644
--- a/src/com/android/launcher3/popup/PopupDataProvider.java
+++ b/src/com/android/launcher3/popup/PopupDataProvider.java
@@ -38,6 +38,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
+import java.util.stream.Collectors;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -130,7 +131,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
for (PackageUserKey packageUserKey : mPackageUserToDotInfos.keySet()) {
DotInfo prevDot = updatedDots.get(packageUserKey);
DotInfo newDot = mPackageUserToDotInfos.get(packageUserKey);
- if (prevDot == null) {
+ if (prevDot == null
+ || prevDot.getNotificationCount() != newDot.getNotificationCount()) {
updatedDots.put(packageUserKey, newDot);
} else {
// No need to update the dot if it already existed (no visual change).
@@ -156,7 +158,7 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
}
public int getShortcutCountForItem(ItemInfo info) {
- if (!DeepShortcutManager.supportsShortcuts(info)) {
+ if (!DeepShortcutManager.supportsDeepShortcuts(info)) {
return 0;
}
ComponentName component = info.getTargetComponent();
@@ -169,10 +171,16 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
}
public @Nullable DotInfo getDotInfoForItem(@NonNull ItemInfo info) {
+ if (!DeepShortcutManager.supportsShortcuts(info)) {
+ return null;
+ }
DotInfo dotInfo = mPackageUserToDotInfos.get(PackageUserKey.fromItemInfo(info));
- List<NotificationKeyData> notifications =
- dotInfo == null ? Collections.EMPTY_LIST : dotInfo.getNotificationKeys();
- if (!DeepShortcutManager.supportsNotificationDots(info, notifications)) {
+ if (dotInfo == null) {
+ return null;
+ }
+ List<NotificationKeyData> notifications = getNotificationsForItem(
+ info, dotInfo.getNotificationKeys());
+ if (notifications.isEmpty()) {
return null;
}
return dotInfo;
@@ -180,7 +188,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
public @NonNull List<NotificationKeyData> getNotificationKeysForItem(ItemInfo info) {
DotInfo dotInfo = getDotInfoForItem(info);
- return dotInfo == null ? Collections.EMPTY_LIST : dotInfo.getNotificationKeys();
+ return dotInfo == null ? Collections.EMPTY_LIST
+ : getNotificationsForItem(info, dotInfo.getNotificationKeys());
}
/** This makes a potentially expensive binder call and should be run on a background thread. */
@@ -229,6 +238,20 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
return null;
}
+ /**
+ * Returns a list of notifications that are relevant to given ItemInfo.
+ */
+ public static @NonNull List<NotificationKeyData> getNotificationsForItem(
+ @NonNull ItemInfo info, @NonNull List<NotificationKeyData> notifications) {
+ String shortcutId = DeepShortcutManager.getShortcutIdIfApplicable(info);
+ if (shortcutId == null) {
+ return notifications;
+ }
+ return notifications.stream().filter((NotificationKeyData notification) ->
+ shortcutId.equals(notification.shortcutId)
+ ).collect(Collectors.toList());
+ }
+
public interface PopupDataChangeListener {
PopupDataChangeListener INSTANCE = new PopupDataChangeListener() { };