Search in sources :

Example 91 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_404Launcher by P-404.

the class LauncherPreviewRenderer method inflateAndAddFolder.

private void inflateAndAddFolder(FolderInfo info) {
    CellLayout screen = info.container == Favorites.CONTAINER_DESKTOP ? mWorkspaceScreens.get(info.screenId) : mHotseat;
    FolderIcon folderIcon = FolderIcon.inflateIcon(R.layout.folder_icon, this, screen, info);
    addInScreenFromBind(folderIcon, info);
}
Also used : CellLayout(com.android.launcher3.CellLayout) FolderIcon(com.android.launcher3.folder.FolderIcon)

Example 92 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_404Launcher by P-404.

the class FolderAdaptiveIcon method createDrawableOnUiThread.

private static FolderAdaptiveIcon createDrawableOnUiThread(FolderIcon icon, Point dragViewSize) {
    Preconditions.assertUIThread();
    icon.getPreviewBounds(sTmpRect);
    PreviewBackground bg = icon.getFolderBackground();
    // assume square
    assert (dragViewSize.x == dragViewSize.y);
    final int previewSize = sTmpRect.width();
    final int margin = (dragViewSize.x - previewSize) / 2;
    final float previewShiftX = -sTmpRect.left + margin;
    final float previewShiftY = -sTmpRect.top + margin;
    // Initialize badge, which consists of the outline stroke, shadow and dot; these
    // must be rendered above the foreground
    Bitmap badgeBmp = BitmapRenderer.createHardwareBitmap(dragViewSize.x, dragViewSize.y, (canvas) -> {
        canvas.save();
        canvas.translate(previewShiftX, previewShiftY);
        bg.drawShadow(canvas);
        bg.drawBackgroundStroke(canvas);
        icon.drawDot(canvas);
        canvas.restore();
    });
    // Initialize mask
    Path mask = new Path();
    Matrix m = new Matrix();
    m.setTranslate(previewShiftX, previewShiftY);
    bg.getClipPath().transform(m, mask);
    Bitmap previewBitmap = BitmapRenderer.createHardwareBitmap(dragViewSize.x, dragViewSize.y, (canvas) -> {
        canvas.save();
        canvas.translate(previewShiftX, previewShiftY);
        icon.getPreviewItemManager().draw(canvas);
        canvas.restore();
    });
    Bitmap bgBitmap = BitmapRenderer.createHardwareBitmap(dragViewSize.x, dragViewSize.y, (canvas) -> {
        Paint p = new Paint();
        p.setColor(bg.getBgColor());
        canvas.drawCircle(dragViewSize.x / 2f, dragViewSize.y / 2f, bg.getRadius(), p);
    });
    ShiftedBitmapDrawable badge = new ShiftedBitmapDrawable(badgeBmp, 0, 0);
    ShiftedBitmapDrawable foreground = new ShiftedBitmapDrawable(previewBitmap, 0, 0);
    ShiftedBitmapDrawable background = new ShiftedBitmapDrawable(bgBitmap, 0, 0);
    return new FolderAdaptiveIcon(background, foreground, badge, mask);
}
Also used : Path(android.graphics.Path) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) PreviewBackground(com.android.launcher3.folder.PreviewBackground) ShiftedBitmapDrawable(com.android.launcher3.graphics.ShiftedBitmapDrawable) Paint(android.graphics.Paint) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 93 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_404Launcher by P-404.

the class FolderPagedView method verifyVisibleHighResIcons.

/**
 * Ensures that all the icons on the given page are of high-res
 */
public void verifyVisibleHighResIcons(int pageNo) {
    CellLayout page = getPageAt(pageNo);
    if (page != null) {
        ShortcutAndWidgetContainer parent = page.getShortcutsAndWidgets();
        for (int i = parent.getChildCount() - 1; i >= 0; i--) {
            BubbleTextView icon = ((BubbleTextView) parent.getChildAt(i));
            icon.verifyHighRes();
            // Set the callback back to the actual icon, in case
            // it was captured by the FolderIcon
            Drawable d = icon.getIcon();
            if (d != null) {
                d.setCallback(icon);
            }
        }
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout) ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) Drawable(android.graphics.drawable.Drawable) BubbleTextView(com.android.launcher3.BubbleTextView) SuppressLint(android.annotation.SuppressLint)

Example 94 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_404Launcher by P-404.

the class PreviewItemManager method onDrop.

/**
 * Handles the case where items in the preview are either:
 *  - Moving into the preview
 *  - Moving into a new position
 *  - Moving out of the preview
 *
 * @param oldItems The list of items in the old preview.
 * @param newItems The list of items in the new preview.
 * @param dropped The item that was dropped onto the FolderIcon.
 */
public void onDrop(List<WorkspaceItemInfo> oldItems, List<WorkspaceItemInfo> newItems, WorkspaceItemInfo dropped) {
    int numItems = newItems.size();
    final ArrayList<PreviewItemDrawingParams> params = mFirstPageParams;
    buildParamsForPage(0, params, false);
    // New preview items for items that are moving in (except for the dropped item).
    List<WorkspaceItemInfo> moveIn = new ArrayList<>();
    for (WorkspaceItemInfo newItem : newItems) {
        if (!oldItems.contains(newItem) && !newItem.equals(dropped)) {
            moveIn.add(newItem);
        }
    }
    for (int i = 0; i < moveIn.size(); ++i) {
        int prevIndex = newItems.indexOf(moveIn.get(i));
        PreviewItemDrawingParams p = params.get(prevIndex);
        computePreviewItemDrawingParams(prevIndex, numItems, p);
        updateTransitionParam(p, moveIn.get(i), ENTER_INDEX, newItems.indexOf(moveIn.get(i)), numItems);
    }
    // Items that are moving into new positions within the preview.
    for (int newIndex = 0; newIndex < newItems.size(); ++newIndex) {
        int oldIndex = oldItems.indexOf(newItems.get(newIndex));
        if (oldIndex >= 0 && newIndex != oldIndex) {
            PreviewItemDrawingParams p = params.get(newIndex);
            updateTransitionParam(p, newItems.get(newIndex), oldIndex, newIndex, numItems);
        }
    }
    // Old preview items that need to be moved out.
    List<WorkspaceItemInfo> moveOut = new ArrayList<>(oldItems);
    moveOut.removeAll(newItems);
    for (int i = 0; i < moveOut.size(); ++i) {
        WorkspaceItemInfo item = moveOut.get(i);
        int oldIndex = oldItems.indexOf(item);
        PreviewItemDrawingParams p = computePreviewItemDrawingParams(oldIndex, numItems, null);
        updateTransitionParam(p, item, oldIndex, EXIT_INDEX, numItems);
        // We want these items first so that they are on drawn last.
        params.add(0, p);
    }
    for (int i = 0; i < params.size(); ++i) {
        if (params.get(i).anim != null) {
            params.get(i).anim.start();
        }
    }
}
Also used : ArrayList(java.util.ArrayList) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 95 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_404Launcher by P-404.

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)

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