Search in sources :

Example 81 with FolderInfo

use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class FirstScreenBroadcast method sendBroadcastToInstaller.

/**
 * @param installerPackageName Package name of the package installer.
 * @param packages List of packages with active sessions for this package installer.
 * @param firstScreenItems List of items on the first screen.
 */
private void sendBroadcastToInstaller(Context context, String installerPackageName, Set<String> packages, List<ItemInfo> firstScreenItems) {
    Set<String> folderItems = new HashSet<>();
    Set<String> workspaceItems = new HashSet<>();
    Set<String> hotseatItems = new HashSet<>();
    Set<String> widgetItems = new HashSet<>();
    for (ItemInfo info : firstScreenItems) {
        if (info instanceof FolderInfo) {
            FolderInfo folderInfo = (FolderInfo) info;
            String folderItemInfoPackage;
            for (ItemInfo folderItemInfo : folderInfo.contents) {
                folderItemInfoPackage = getPackageName(folderItemInfo);
                if (folderItemInfoPackage != null && packages.contains(folderItemInfoPackage)) {
                    folderItems.add(folderItemInfoPackage);
                }
            }
        }
        String packageName = getPackageName(info);
        if (packageName == null || !packages.contains(packageName)) {
            continue;
        }
        if (info instanceof LauncherAppWidgetInfo) {
            widgetItems.add(packageName);
        } else if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
            hotseatItems.add(packageName);
        } else if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
            workspaceItems.add(packageName);
        }
    }
    if (DEBUG) {
        printList(installerPackageName, "Folder item", folderItems);
        printList(installerPackageName, "Workspace item", workspaceItems);
        printList(installerPackageName, "Hotseat item", hotseatItems);
        printList(installerPackageName, "Widget item", widgetItems);
    }
    context.sendBroadcast(new Intent(ACTION_FIRST_SCREEN_ACTIVE_INSTALLS).setPackage(installerPackageName).putStringArrayListExtra(FOLDER_ITEM_EXTRA, new ArrayList<>(folderItems)).putStringArrayListExtra(WORKSPACE_ITEM_EXTRA, new ArrayList<>(workspaceItems)).putStringArrayListExtra(HOTSEAT_ITEM_EXTRA, new ArrayList<>(hotseatItems)).putStringArrayListExtra(WIDGET_ITEM_EXTRA, new ArrayList<>(widgetItems)).putExtra(VERIFICATION_TOKEN_EXTRA, PendingIntent.getActivity(context, 0, new Intent(), FLAG_ONE_SHOT | FLAG_IMMUTABLE)));
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) ArrayList(java.util.ArrayList) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) FolderInfo(com.android.launcher3.model.data.FolderInfo) HashSet(java.util.HashSet)

Example 82 with FolderInfo

use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class BgDataModel method findOrMakeFolder.

/**
 * Return an existing FolderInfo object if we have encountered this ID previously,
 * or make a new one.
 */
public synchronized FolderInfo findOrMakeFolder(int id) {
    // See if a placeholder was created for us already
    FolderInfo folderInfo = folders.get(id);
    if (folderInfo == null) {
        // No placeholder -- create a new instance
        folderInfo = new FolderInfo();
        folders.put(id, folderInfo);
    }
    return folderInfo;
}
Also used : FolderInfo(com.android.launcher3.model.data.FolderInfo)

Example 83 with FolderInfo

use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class ItemClickHandler method onClick.

private static void onClick(View v) {
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null)
        return;
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!launcher.getWorkspace().isFinishedSwitchingState())
        return;
    Object tag = v.getTag();
    if (tag instanceof WorkspaceItemInfo) {
        onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher);
    } else if (tag instanceof FolderInfo) {
        if (v instanceof FolderIcon) {
            onClickFolderIcon(v);
        }
    } else if (tag instanceof AppInfo) {
        startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher);
    } else if (tag instanceof LauncherAppWidgetInfo) {
        if (v instanceof PendingAppWidgetHostView) {
            onClickPendingWidget((PendingAppWidgetHostView) v, launcher);
        }
    } else if (tag instanceof SearchActionItemInfo) {
        onClickSearchAction(launcher, (SearchActionItemInfo) tag);
    }
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) Launcher(com.android.launcher3.Launcher) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 84 with FolderInfo

use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherBindableItemsContainer method updateRestoreItems.

/**
 * Called to update restored items as a result of
 * {@link com.android.launcher3.model.BgDataModel.Callbacks#bindRestoreItemsChange(HashSet)}}
 */
default void updateRestoreItems(final HashSet<ItemInfo> updates, ActivityContext context) {
    ItemOperator op = (info, v) -> {
        if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView && updates.contains(info)) {
            ((BubbleTextView) v).applyLoadingState(false);
        } else if (v instanceof PendingAppWidgetHostView && info instanceof LauncherAppWidgetInfo && updates.contains(info)) {
            ((PendingAppWidgetHostView) v).applyState();
        } else if (v instanceof FolderIcon && info instanceof FolderInfo) {
            ((FolderIcon) v).updatePreviewItems(updates::contains);
        }
        // process all the shortcuts
        return false;
    };
    mapOverItems(op);
    Folder folder = Folder.getOpen(context);
    if (folder != null) {
        folder.iterateOverItems(op);
    }
}
Also used : Folder(com.android.launcher3.folder.Folder) ActivityContext(com.android.launcher3.views.ActivityContext) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) Drawable(android.graphics.drawable.Drawable) BubbleTextView(com.android.launcher3.BubbleTextView) HashSet(java.util.HashSet) List(java.util.List) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) FolderIcon(com.android.launcher3.folder.FolderIcon) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) BubbleTextView(com.android.launcher3.BubbleTextView) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 85 with FolderInfo

use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherBindableItemsContainer method updateWorkspaceItems.

/**
 * Called to update workspace items as a result of
 * {@link com.android.launcher3.model.BgDataModel.Callbacks#bindWorkspaceItemsChanged(List)}
 */
default void updateWorkspaceItems(List<WorkspaceItemInfo> shortcuts, ActivityContext context) {
    final HashSet<WorkspaceItemInfo> updates = new HashSet<>(shortcuts);
    ItemOperator op = (info, v) -> {
        if (v instanceof BubbleTextView && updates.contains(info)) {
            WorkspaceItemInfo si = (WorkspaceItemInfo) info;
            BubbleTextView shortcut = (BubbleTextView) v;
            Drawable oldIcon = shortcut.getIcon();
            boolean oldPromiseState = (oldIcon instanceof PreloadIconDrawable) && ((PreloadIconDrawable) oldIcon).hasNotCompleted();
            shortcut.applyFromWorkspaceItem(si, si.isPromise() != oldPromiseState);
        } else if (info instanceof FolderInfo && v instanceof FolderIcon) {
            ((FolderIcon) v).updatePreviewItems(updates::contains);
        }
        // Iterate all items
        return false;
    };
    mapOverItems(op);
    Folder openFolder = Folder.getOpen(context);
    if (openFolder != null) {
        openFolder.iterateOverItems(op);
    }
}
Also used : Folder(com.android.launcher3.folder.Folder) ActivityContext(com.android.launcher3.views.ActivityContext) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) Drawable(android.graphics.drawable.Drawable) BubbleTextView(com.android.launcher3.BubbleTextView) HashSet(java.util.HashSet) List(java.util.List) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) FolderIcon(com.android.launcher3.folder.FolderIcon) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) BubbleTextView(com.android.launcher3.BubbleTextView) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) HashSet(java.util.HashSet)

Aggregations

FolderInfo (com.android.launcher3.model.data.FolderInfo)152 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)121 ItemInfo (com.android.launcher3.model.data.ItemInfo)100 View (android.view.View)98 FolderIcon (com.android.launcher3.folder.FolderIcon)73 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)65 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)61 ArrayList (java.util.ArrayList)59 AppWidgetHostView (android.appwidget.AppWidgetHostView)55 DragView (com.android.launcher3.dragndrop.DragView)51 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)50 Point (android.graphics.Point)47 AppInfo (com.android.launcher3.model.data.AppInfo)41 SuppressLint (android.annotation.SuppressLint)39 Rect (android.graphics.Rect)28 Folder (com.android.launcher3.folder.Folder)28 IntArray (com.android.launcher3.util.IntArray)28 HashSet (java.util.HashSet)28 UserHandle (android.os.UserHandle)27 Intent (android.content.Intent)26