Search in sources :

Example 1 with DotInfo

use of com.android.launcher3.dot.DotInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupContainerWithArrow method updateNotificationHeader.

private void updateNotificationHeader() {
    ItemInfoWithIcon itemInfo = (ItemInfoWithIcon) mOriginalIcon.getTag();
    DotInfo dotInfo = mLauncher.getDotInfoForItem(itemInfo);
    if (mNotificationContainer != null && dotInfo != null) {
        mNotificationContainer.updateHeader(dotInfo.getNotificationCount());
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 2 with DotInfo

use of com.android.launcher3.dot.DotInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupDataProvider method onNotificationPosted.

@Override
public void onNotificationPosted(PackageUserKey postedPackageUserKey, NotificationKeyData notificationKey) {
    DotInfo dotInfo = mPackageUserToDotInfos.get(postedPackageUserKey);
    if (dotInfo == null) {
        dotInfo = new DotInfo();
        mPackageUserToDotInfos.put(postedPackageUserKey, dotInfo);
    }
    if (dotInfo.addOrUpdateNotificationKey(notificationKey)) {
        updateNotificationDots(postedPackageUserKey::equals);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo)

Example 3 with DotInfo

use of com.android.launcher3.dot.DotInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupDataProvider method onNotificationRemoved.

@Override
public void onNotificationRemoved(PackageUserKey removedPackageUserKey, NotificationKeyData notificationKey) {
    DotInfo oldDotInfo = mPackageUserToDotInfos.get(removedPackageUserKey);
    if (oldDotInfo != null && oldDotInfo.removeNotificationKey(notificationKey)) {
        if (oldDotInfo.getNotificationKeys().size() == 0) {
            mPackageUserToDotInfos.remove(removedPackageUserKey);
        }
        updateNotificationDots(removedPackageUserKey::equals);
        trimNotifications(mPackageUserToDotInfos);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo)

Example 4 with DotInfo

use of com.android.launcher3.dot.DotInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupDataProvider method onNotificationFullRefresh.

@Override
public void onNotificationFullRefresh(List<StatusBarNotification> activeNotifications) {
    if (activeNotifications == null)
        return;
    // This will contain the PackageUserKeys which have updated dots.
    HashMap<PackageUserKey, DotInfo> updatedDots = new HashMap<>(mPackageUserToDotInfos);
    mPackageUserToDotInfos.clear();
    for (StatusBarNotification notification : activeNotifications) {
        PackageUserKey packageUserKey = PackageUserKey.fromNotification(notification);
        DotInfo dotInfo = mPackageUserToDotInfos.get(packageUserKey);
        if (dotInfo == null) {
            dotInfo = new DotInfo();
            mPackageUserToDotInfos.put(packageUserKey, dotInfo);
        }
        dotInfo.addOrUpdateNotificationKey(NotificationKeyData.fromNotification(notification));
    }
    // Add and remove from updatedDots so it contains the PackageUserKeys of updated dots.
    for (PackageUserKey packageUserKey : mPackageUserToDotInfos.keySet()) {
        DotInfo prevDot = updatedDots.get(packageUserKey);
        DotInfo newDot = mPackageUserToDotInfos.get(packageUserKey);
        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).
            // Note that if the dot was removed entirely, we wouldn't reach this point because
            // this loop only includes active notifications added above.
            updatedDots.remove(packageUserKey);
        }
    }
    if (!updatedDots.isEmpty()) {
        updateNotificationDots(updatedDots::containsKey);
    }
    trimNotifications(updatedDots);
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) StatusBarNotification(android.service.notification.StatusBarNotification) HashMap(java.util.HashMap) PackageUserKey(com.android.launcher3.util.PackageUserKey)

Example 5 with DotInfo

use of com.android.launcher3.dot.DotInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupDataProvider method getDotInfoForItem.

@Nullable
public DotInfo getDotInfoForItem(@NonNull ItemInfo info) {
    if (!ShortcutUtil.supportsShortcuts(info)) {
        return null;
    }
    DotInfo dotInfo = mPackageUserToDotInfos.get(PackageUserKey.fromItemInfo(info));
    if (dotInfo == null) {
        return null;
    }
    List<NotificationKeyData> notifications = getNotificationsForItem(info, dotInfo.getNotificationKeys());
    if (notifications.isEmpty()) {
        return null;
    }
    return dotInfo;
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) NotificationKeyData(com.android.launcher3.notification.NotificationKeyData) Nullable(androidx.annotation.Nullable)

Aggregations

DotInfo (com.android.launcher3.dot.DotInfo)5 StatusBarNotification (android.service.notification.StatusBarNotification)1 Nullable (androidx.annotation.Nullable)1 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)1 NotificationKeyData (com.android.launcher3.notification.NotificationKeyData)1 PackageUserKey (com.android.launcher3.util.PackageUserKey)1 HashMap (java.util.HashMap)1