show dot in deep shortcuts when notification contains exactly identical

set of person

Bug: 132336512
Change-Id: I975524e28168c10a186cdc24b188c161faf433cf
This commit is contained in:
Pinyao Ting
2019-07-26 12:28:38 -07:00
parent 1a4b815cd8
commit 49a3e699f9
13 changed files with 144 additions and 58 deletions

View File

@@ -17,12 +17,18 @@
package com.android.launcher3.notification;
import android.app.Notification;
import android.app.Person;
import android.service.notification.StatusBarNotification;
import com.android.launcher3.Utilities;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* The key data associated with the notification, used to determine what to include
@@ -34,19 +40,25 @@ public class NotificationKeyData {
public final String notificationKey;
public final String shortcutId;
public int count;
@NonNull public final String[] personKeysFromNotification;
private NotificationKeyData(String notificationKey, String shortcutId, int count) {
private NotificationKeyData(String notificationKey, String shortcutId, int count,
String[] personKeysFromNotification) {
this.notificationKey = notificationKey;
this.shortcutId = shortcutId;
this.count = Math.max(1, count);
this.personKeysFromNotification = personKeysFromNotification;
}
public static NotificationKeyData fromNotification(StatusBarNotification sbn) {
Notification notif = sbn.getNotification();
return new NotificationKeyData(sbn.getKey(), notif.getShortcutId(), notif.number);
return new NotificationKeyData(sbn.getKey(), notif.getShortcutId(), notif.number,
extractPersonKeyOnly(notif.extras.getParcelableArrayList(
Notification.EXTRA_PEOPLE_LIST)));
}
public static List<String> extractKeysOnly(@NonNull List<NotificationKeyData> notificationKeys) {
public static List<String> extractKeysOnly(
@NonNull List<NotificationKeyData> notificationKeys) {
List<String> keysOnly = new ArrayList<>(notificationKeys.size());
for (NotificationKeyData notificationKeyData : notificationKeys) {
keysOnly.add(notificationKeyData.notificationKey);
@@ -54,6 +66,13 @@ public class NotificationKeyData {
return keysOnly;
}
private static String[] extractPersonKeyOnly(@Nullable ArrayList<Person> people) {
if (people == null || people.isEmpty()) {
return Utilities.EMPTY_STRING_ARRAY;
}
return people.stream().map(Person::getKey).sorted().toArray(String[]::new);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof NotificationKeyData)) {