From 4d1a0e2a7b859672a6aac52e9fd909d42a12b895 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Thu, 25 Jul 2019 20:26:54 -0700 Subject: show dot on shortcut when incoming notification contains exactly the same shortcut id Bug: 132336512 Change-Id: Iddf4cfe8ad60c12e8de8b171bed392f1bb0a6761 Merged-In: Iddf4cfe8ad60c12e8de8b171bed392f1bb0a6761 --- .../launcher3/shortcuts/DeepShortcutManager.java | 45 ++++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'src_shortcuts_overrides') diff --git a/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java index 6b6f70d7b..f42bafe5e 100644 --- a/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java +++ b/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java @@ -30,6 +30,7 @@ import android.util.Log; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherSettings; import com.android.launcher3.WorkspaceItemInfo; +import com.android.launcher3.notification.NotificationKeyData; import java.util.ArrayList; import java.util.Collections; @@ -64,10 +65,40 @@ public class DeepShortcutManager { } public static boolean supportsShortcuts(ItemInfo info) { - boolean isItemPromise = info instanceof WorkspaceItemInfo - && ((WorkspaceItemInfo) info).hasPromiseIconUi(); - return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION - && !info.isDisabled() && !isItemPromise; + return isActive(info) && isApp(info); + } + + public static boolean supportsNotificationDots( + ItemInfo info, List notifications) { + if (!isActive(info)) { + return false; + } + return isApp(info) || (isPinnedShortcut(info) + && shouldShowNotificationDotForPinnedShortcut(info, notifications)); + } + + private static boolean isApp(ItemInfo info) { + return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; + } + + private static boolean isPinnedShortcut(ItemInfo info) { + return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT + && info.container != ItemInfo.NO_ID + && info instanceof WorkspaceItemInfo; + } + + private static boolean shouldShowNotificationDotForPinnedShortcut( + ItemInfo info, List notifications) { + String shortcutId = ((WorkspaceItemInfo) info).getDeepShortcutId(); + if (shortcutId == null) { + return false; + } + for (NotificationKeyData notification : notifications) { + if (shortcutId.equals(notification.shortcutId)) { + return true; + } + } + return false; } public boolean wasLastCallSuccess() { @@ -183,6 +214,12 @@ public class DeepShortcutManager { return shortcutIds; } + private static boolean isActive(ItemInfo info) { + boolean isLoading = info instanceof WorkspaceItemInfo + && ((WorkspaceItemInfo) info).hasPromiseIconUi(); + return !isLoading && !info.isDisabled(); + } + /** * Query the system server for all the shortcuts matching the given parameters. * If packageName == null, we query for all shortcuts with the passed flags, regardless of app. -- cgit v1.2.3