use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ProtonAOSP.
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);
}
use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ProtonAOSP.
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);
}
}
use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ProtonAOSP.
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);
}
}
use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ProtonAOSP.
the class InstallSessionTracker method pushSessionDisplayToLauncher.
private SessionInfo pushSessionDisplayToLauncher(int sessionId, InstallSessionHelper helper, Callback callback) {
SessionInfo session = helper.getVerifiedSessionInfo(sessionId);
if (session != null && session.getAppPackageName() != null) {
PackageUserKey key = new PackageUserKey(session.getAppPackageName(), getUserHandle(session));
getActiveSessionMap(helper).put(session.getSessionId(), key);
callback.onUpdateSessionDisplay(key, session);
return session;
}
return null;
}
use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ProtonAOSP.
the class Workspace method updateNotificationDots.
public void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
final PackageUserKey packageUserKey = new PackageUserKey(null, null);
Predicate<ItemInfo> matcher = info -> !packageUserKey.updateFromItemInfo(info) || updatedDots.test(packageUserKey);
ItemOperator op = (info, v) -> {
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView) {
if (matcher.test(info)) {
((BubbleTextView) v).applyDotState(info, true);
}
} else if (info instanceof FolderInfo && v instanceof FolderIcon) {
FolderInfo fi = (FolderInfo) info;
if (fi.contents.stream().anyMatch(matcher)) {
FolderDotInfo folderDotInfo = new FolderDotInfo();
for (WorkspaceItemInfo si : fi.contents) {
folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
}
((FolderIcon) v).setDotInfo(folderDotInfo);
}
}
// process all the shortcuts
return false;
};
mapOverItems(op);
Folder folder = Folder.getOpen(mLauncher);
if (folder != null) {
folder.iterateOverItems(op);
}
}
Aggregations