import com.android.launcher3.notification.NotificationInfo;
import com.android.launcher3.util.PackageUserKey;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
/**
* Contains data to be used in an icon badge.
* The keys of the notifications that this badge represents. These keys can later be
* used to retrieve {@link NotificationInfo}'s.
*/
- private Set<String> mNotificationKeys;
+ private List<String> mNotificationKeys;
public BadgeInfo(PackageUserKey packageUserKey) {
mPackageUserKey = packageUserKey;
- mNotificationKeys = new HashSet<>();
+ mNotificationKeys = new ArrayList<>();
}
/**
* Returns whether the notification was added (false if it already existed).
*/
- public boolean addNotificationKey(String notificationKey) {
+ public boolean addNotificationKeyIfNotExists(String notificationKey) {
+ if (mNotificationKeys.contains(notificationKey)) {
+ return false;
+ }
return mNotificationKeys.add(notificationKey);
}
return mNotificationKeys.remove(notificationKey);
}
- public Set<String> getNotificationKeys() {
+ public List<String> getNotificationKeys() {
return mNotificationKeys;
}
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* A {@link LinearLayout} that contains icons of notifications. If there is only one icon,
animation.start();
}
- public void trimNotifications(Set<String> notifications) {
+ public void trimNotifications(List<String> notifications) {
if (!isAttachedToWindow() || mIconRow.getChildCount() == 0) {
return;
}
import com.android.launcher3.graphics.IconPalette;
import com.android.launcher3.popup.PopupItemView;
-import java.util.HashSet;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import static com.android.launcher3.LauncherAnimUtils.animateViewHeight;
mFooter.applyColors(iconPalette);
}
- public void trimNotifications(final Set<String> notificationKeys) {
+ public void trimNotifications(final List<String> notificationKeys) {
boolean dismissedMainNotification = !notificationKeys.contains(
mMainView.getNotificationInfo().notificationKey);
if (dismissedMainNotification && !mAnimatingNextIcon) {
public void onIconAnimationEnd(NotificationInfo newMainNotification) {
if (newMainNotification != null) {
mMainView.applyNotificationInfo(newMainNotification, mIconView, mIconPalette);
- Set<String> footerNotificationKeys = new HashSet<>(notificationKeys);
+ // Remove the animated notification from the footer by calling trim
+ // TODO: Remove the notification in NotificationFooterLayout directly
+ // instead of relying on this hack.
+ List<String> footerNotificationKeys = new ArrayList<>(notificationKeys);
footerNotificationKeys.remove(newMainNotification.notificationKey);
mFooter.trimNotifications(footerNotificationKeys);
mMainView.setVisibility(VISIBLE);
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* Provides data for the popup menu that appears after long-clicking on apps.
BadgeInfo oldBadgeInfo = mPackageUserToBadgeInfos.get(postedPackageUserKey);
if (oldBadgeInfo == null) {
BadgeInfo newBadgeInfo = new BadgeInfo(postedPackageUserKey);
- newBadgeInfo.addNotificationKey(notificationKey);
+ newBadgeInfo.addNotificationKeyIfNotExists(notificationKey);
mPackageUserToBadgeInfos.put(postedPackageUserKey, newBadgeInfo);
mLauncher.updateIconBadges(Collections.singleton(postedPackageUserKey));
- } else if (oldBadgeInfo.addNotificationKey(notificationKey)) {
+ } else if (oldBadgeInfo.addNotificationKeyIfNotExists(notificationKey)) {
mLauncher.updateIconBadges(Collections.singleton(postedPackageUserKey));
}
}
badgeInfo = new BadgeInfo(packageUserKey);
mPackageUserToBadgeInfos.put(packageUserKey, badgeInfo);
}
- badgeInfo.addNotificationKey(notification.getKey());
+ badgeInfo.addNotificationKeyIfNotExists(notification.getKey());
}
// Add and remove from updatedBadges so it contains the PackageUserKeys of updated badges.
public String[] getNotificationKeysForItem(ItemInfo info) {
BadgeInfo badgeInfo = mPackageUserToBadgeInfos.get(PackageUserKey.fromItemInfo(info));
if (badgeInfo == null) { return new String[0]; }
- Set<String> notificationKeys = badgeInfo.getNotificationKeys();
+ List<String> notificationKeys = badgeInfo.getNotificationKeys();
return notificationKeys.toArray(new String[notificationKeys.size()]);
}