Search in sources :

Example 71 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

the class Launcher method addFolder.

/**
 * Creates and adds new folder to CellLayout
 */
public FolderIcon addFolder(CellLayout layout, int container, final int screenId, int cellX, int cellY) {
    final FolderInfo folderInfo = new FolderInfo();
    // Update the model
    getModelWriter().addItemToDatabase(folderInfo, container, screenId, cellX, cellY);
    // Create the view
    FolderIcon newFolder = FolderIcon.inflateFolderAndIcon(R.layout.folder_icon, this, layout, folderInfo);
    mWorkspace.addInScreen(newFolder, folderInfo);
    // Force measure the new folder icon
    CellLayout parent = mWorkspace.getParentCellLayoutForView(newFolder);
    parent.getShortcutsAndWidgets().measureChild(newFolder);
    return newFolder;
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) FolderInfo(com.android.launcher3.model.data.FolderInfo)

Example 72 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

the class ItemClickHandler method onClickFolderIcon.

/**
 * Event handler for a folder icon click.
 *
 * @param v The view that was clicked. Must be an instance of {@link FolderIcon}.
 */
private static void onClickFolderIcon(View v) {
    Folder folder = ((FolderIcon) v).getFolder();
    if (!folder.isOpen() && !folder.isDestroyed()) {
        // Open the requested folder
        folder.animateOpen();
        StatsLogManager.newInstance(v.getContext()).logger().withItemInfo(folder.mInfo).log(LAUNCHER_FOLDER_OPEN);
    }
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) Folder(com.android.launcher3.folder.Folder)

Example 73 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon 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 74 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon 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 75 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon 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

FolderIcon (com.android.launcher3.folder.FolderIcon)124 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)82 View (android.view.View)81 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)70 AppWidgetHostView (android.appwidget.AppWidgetHostView)62 FolderInfo (com.android.launcher3.model.data.FolderInfo)58 DragView (com.android.launcher3.dragndrop.DragView)57 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)55 ItemInfo (com.android.launcher3.model.data.ItemInfo)48 SuppressLint (android.annotation.SuppressLint)42 BubbleTextView (com.android.launcher3.BubbleTextView)41 Folder (com.android.launcher3.folder.Folder)40 Point (android.graphics.Point)37 Rect (android.graphics.Rect)37 DraggableView (com.android.launcher3.dragndrop.DraggableView)35 Drawable (android.graphics.drawable.Drawable)33 PreviewBackground (com.android.launcher3.folder.PreviewBackground)33 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)30 ArrayList (java.util.ArrayList)27 PreloadIconDrawable (com.android.launcher3.graphics.PreloadIconDrawable)25