Search in sources :

Example 91 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_404Launcher by P-404.

the class PackageUserKeyTest method fromPackageItemInfo_shouldCreateExpectedObject.

@Test
public void fromPackageItemInfo_shouldCreateExpectedObject() {
    PackageUserKey packageUserKey = PackageUserKey.fromPackageItemInfo(new PackageItemInfo(TEST_PACKAGE, UserHandle.CURRENT));
    assertThat(packageUserKey.mPackageName).isEqualTo(TEST_PACKAGE);
    assertThat(packageUserKey.mWidgetCategory).isEqualTo(NO_CATEGORY);
    assertThat(packageUserKey.mUser).isEqualTo(UserHandle.CURRENT);
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 92 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_404Launcher by P-404.

the class WidgetsModel method getAllWidgetsWithoutShortcuts.

/**
 * Returns a mapping of packages to their widgets without static shortcuts.
 */
public synchronized Map<PackageUserKey, List<WidgetItem>> getAllWidgetsWithoutShortcuts() {
    Map<PackageUserKey, List<WidgetItem>> packagesToWidgets = new HashMap<>();
    mWidgetsList.forEach((packageItemInfo, widgetsAndShortcuts) -> {
        List<WidgetItem> widgets = widgetsAndShortcuts.stream().filter(item -> item.widgetInfo != null).collect(toList());
        if (widgets.size() > 0) {
            packagesToWidgets.put(new PackageUserKey(packageItemInfo.packageName, packageItemInfo.user), widgets);
        }
    });
    return packagesToWidgets;
}
Also used : Context(android.content.Context) Arrays(java.util.Arrays) NO_CATEGORY(com.android.launcher3.widget.WidgetSections.NO_CATEGORY) PackageManager(android.content.pm.PackageManager) AppFilter(com.android.launcher3.AppFilter) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Pair(android.util.Pair) Preconditions(com.android.launcher3.util.Preconditions) HashMap(java.util.HashMap) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) IconCache(com.android.launcher3.icons.IconCache) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) ArrayList(java.util.ArrayList) Collectors.mapping(java.util.stream.Collectors.mapping) UserHandle(android.os.UserHandle) Map(java.util.Map) Log(android.util.Log) ArrayMap(androidx.collection.ArrayMap) ShortcutConfigActivityInfo.queryList(com.android.launcher3.pm.ShortcutConfigActivityInfo.queryList) Utilities(com.android.launcher3.Utilities) WidgetsDiffReporter(com.android.launcher3.widget.picker.WidgetsDiffReporter) Iterator(java.util.Iterator) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) ComponentName(android.content.ComponentName) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) Predicate(java.util.function.Predicate) LauncherAppState(com.android.launcher3.LauncherAppState) Collection(java.util.Collection) PackageUserKey(com.android.launcher3.util.PackageUserKey) WIDGET_FEATURE_HIDE_FROM_PICKER(android.appwidget.AppWidgetProviderInfo.WIDGET_FEATURE_HIDE_FROM_PICKER) Set(java.util.Set) FeatureFlags(com.android.launcher3.config.FeatureFlags) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) AlphabeticIndexCompat(com.android.launcher3.compat.AlphabeticIndexCompat) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) IntSet(com.android.launcher3.util.IntSet) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Nullable(androidx.annotation.Nullable) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ShortcutConfigActivityInfo(com.android.launcher3.pm.ShortcutConfigActivityInfo) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) ComponentWithLabelAndIcon(com.android.launcher3.icons.ComponentWithLabelAndIcon) WidgetSections(com.android.launcher3.widget.WidgetSections) Entry(java.util.Map.Entry) HashMap(java.util.HashMap) PackageUserKey(com.android.launcher3.util.PackageUserKey) ArrayList(java.util.ArrayList) ShortcutConfigActivityInfo.queryList(com.android.launcher3.pm.ShortcutConfigActivityInfo.queryList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List)

Example 93 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_404Launcher by P-404.

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)

Example 94 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey 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 95 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey 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)

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