Don't keep around shortcuts for archived chats.

This commit is contained in:
Alex Hart
2022-04-08 11:57:46 -03:00
committed by Cody Henthorne
parent a44a105cbc
commit a87aa0fbe2
4 changed files with 21 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* ConversationUtil encapsulates support for Android 11+'s new Conversations system
@@ -140,6 +141,14 @@ public final class ConversationUtil {
return Math.min(ShortcutManagerCompat.getMaxShortcutCountPerActivity(context), 150);
}
/**
* Removes the long-lived shortcuts for the given set of recipients.
*/
@WorkerThread
public static void removeLongLivedShortcuts(@NonNull Context context, @NonNull Collection<RecipientId> recipients) {
ShortcutManagerCompat.removeLongLivedShortcuts(context, recipients.stream().map(ConversationUtil::getShortcutId).collect(Collectors.toList()));
}
/**
* Sets the shortcuts to match the provided recipient list. This call may fail due to getting
* rate-limited.