Search in sources :

Example 61 with PackageUserKey

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);
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) StatusBarNotification(android.service.notification.StatusBarNotification) HashMap(java.util.HashMap) PackageUserKey(com.android.launcher3.util.PackageUserKey)

Example 62 with PackageUserKey

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);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo)

Example 63 with PackageUserKey

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);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo)

Example 64 with PackageUserKey

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;
}
Also used : SessionInfo(android.content.pm.PackageInstaller.SessionInfo) PackageUserKey(com.android.launcher3.util.PackageUserKey)

Example 65 with PackageUserKey

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);
    }
}
Also used : BitmapRenderer(com.android.launcher3.icons.BitmapRenderer) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) LAUNCHER_SWIPELEFT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPELEFT) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Drawable(android.graphics.drawable.Drawable) DraggableView(com.android.launcher3.dragndrop.DraggableView) WallpaperManager(android.app.WallpaperManager) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) LayoutTransition(android.animation.LayoutTransition) Interpolators(com.android.launcher3.anim.Interpolators) LauncherAtom(com.android.launcher3.logger.LauncherAtom) Handler(android.os.Handler) Log(android.util.Log) WallpaperOffsetInterpolator(com.android.launcher3.util.WallpaperOffsetInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) OverlayEdgeEffect(com.android.launcher3.util.OverlayEdgeEffect) Nullable(androidx.annotation.Nullable) Message(android.os.Message) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) NORMAL(com.android.launcher3.LauncherState.NORMAL) AccessibleDragListenerAdapter(com.android.launcher3.accessibility.AccessibleDragListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) AppWidgetHostViewDragListener(com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) SpringLoadedDragController(com.android.launcher3.dragndrop.SpringLoadedDragController) ArrayList(java.util.ArrayList) FLAG_MULTI_PAGE(com.android.launcher3.LauncherState.FLAG_MULTI_PAGE) PreviewBackground(com.android.launcher3.folder.PreviewBackground) AppWidgetHostView(android.appwidget.AppWidgetHostView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimatorListeners.forSuccessCallback(com.android.launcher3.anim.AnimatorListeners.forSuccessCallback) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) IntArray(com.android.launcher3.util.IntArray) ProviderChangedListener(com.android.launcher3.widget.LauncherAppWidgetHost.ProviderChangedListener) Parcelable(android.os.Parcelable) InstanceId(com.android.launcher3.logging.InstanceId) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) DragController(com.android.launcher3.dragndrop.DragController) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) StateManager(com.android.launcher3.statemanager.StateManager) FeatureFlags(com.android.launcher3.config.FeatureFlags) IntSet(com.android.launcher3.util.IntSet) LauncherAppWidgetHost(com.android.launcher3.widget.LauncherAppWidgetHost) LAUNCHER_SWIPERIGHT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPERIGHT) WorkspaceTouchListener(com.android.launcher3.touch.WorkspaceTouchListener) RunnableList(com.android.launcher3.util.RunnableList) DragPreviewProvider(com.android.launcher3.graphics.DragPreviewProvider) ValueAnimator(android.animation.ValueAnimator) WorkspaceAccessibilityHelper(com.android.launcher3.accessibility.WorkspaceAccessibilityHelper) Rect(android.graphics.Rect) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) Animator(android.animation.Animator) SPRING_LOADED(com.android.launcher3.LauncherState.SPRING_LOADED) FLAG_WORKSPACE_INACCESSIBLE(com.android.launcher3.LauncherState.FLAG_WORKSPACE_INACCESSIBLE) AttributeSet(android.util.AttributeSet) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) LauncherEvent(com.android.launcher3.logging.StatsLogManager.LauncherEvent) Predicate(java.util.function.Predicate) EdgeEffectCompat(com.android.launcher3.util.EdgeEffectCompat) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) SparseArray(android.util.SparseArray) WidgetSizes(com.android.launcher3.widget.util.WidgetSizes) List(java.util.List) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) LAUNCHER_STATE_HOME(com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) ALPHA_INDEX_OVERLAY(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AppInfo(com.android.launcher3.model.data.AppInfo) LauncherOverlay(com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) LauncherBindableItemsContainer(com.android.launcher3.util.LauncherBindableItemsContainer) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED(com.android.launcher3.LauncherState.FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED) DragLayer(com.android.launcher3.dragndrop.DragLayer) Executors(com.android.launcher3.util.Executors) Iterator(java.util.Iterator) LayoutInflater(android.view.LayoutInflater) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) Consumer(java.util.function.Consumer) StatsLogManager(com.android.launcher3.logging.StatsLogManager) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) Bitmap(android.graphics.Bitmap) WorkspacePageIndicator(com.android.launcher3.pageindicators.WorkspacePageIndicator) StateHandler(com.android.launcher3.statemanager.StateManager.StateHandler) ViewTreeObserver(android.view.ViewTreeObserver) IntSparseArrayMap(com.android.launcher3.util.IntSparseArrayMap) Thunk(com.android.launcher3.util.Thunk) HINT_STATE(com.android.launcher3.LauncherState.HINT_STATE) Collections(java.util.Collections) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DragView(com.android.launcher3.dragndrop.DragView) Resources(android.content.res.Resources) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) PackageUserKey(com.android.launcher3.util.PackageUserKey) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

PackageUserKey (com.android.launcher3.util.PackageUserKey)94 ArrayList (java.util.ArrayList)53 Context (android.content.Context)42 ComponentName (android.content.ComponentName)39 UserHandle (android.os.UserHandle)35 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)31 HashMap (java.util.HashMap)31 HashSet (java.util.HashSet)31 List (java.util.List)29 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)26 IconCache (com.android.launcher3.icons.IconCache)24 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)24 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)24 DotInfo (com.android.launcher3.dot.DotInfo)22 Log (android.util.Log)21 FeatureFlags (com.android.launcher3.config.FeatureFlags)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 IntSet (com.android.launcher3.util.IntSet)21 Predicate (java.util.function.Predicate)21 Test (org.junit.Test)21