Search in sources :

Example 26 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Trebuchet by LineageOS.

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();
    });
    ShiftedBitmapDrawable badge = new ShiftedBitmapDrawable(badgeBmp, 0, 0);
    ShiftedBitmapDrawable foreground = new ShiftedBitmapDrawable(previewBitmap, 0, 0);
    return new FolderAdaptiveIcon(new ColorDrawable(bg.getBgColor()), foreground, badge, mask);
}
Also used : Path(android.graphics.Path) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) ColorDrawable(android.graphics.drawable.ColorDrawable) PreviewBackground(com.android.launcher3.folder.PreviewBackground) ShiftedBitmapDrawable(com.android.launcher3.graphics.ShiftedBitmapDrawable) Point(android.graphics.Point)

Example 27 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Trebuchet by LineageOS.

the class Folder method shouldUseHardwareLayerForAnimation.

private boolean shouldUseHardwareLayerForAnimation(CellLayout currentCellLayout) {
    if (ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS.get())
        return true;
    int folderCount = 0;
    final ShortcutAndWidgetContainer container = currentCellLayout.getShortcutsAndWidgets();
    for (int i = container.getChildCount() - 1; i >= 0; --i) {
        final View child = container.getChildAt(i);
        if (child instanceof AppWidgetHostView)
            return false;
        if (child instanceof FolderIcon)
            ++folderCount;
    }
    return folderCount >= MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION;
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) ClipPathView(com.android.launcher3.views.ClipPathView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) PagedView(com.android.launcher3.PagedView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) SuppressLint(android.annotation.SuppressLint)

Example 28 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Trebuchet by LineageOS.

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.getCompoundDrawables()[1];
            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 29 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Trebuchet by LineageOS.

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 30 with FolderIcon

use of com.android.launcher3.tapl.FolderIcon in project Neo-Launcher by NeoApplications.

the class BubbleTextView method shouldTextBeVisible.

public boolean shouldTextBeVisible() {
    // Text should be visible everywhere but the hotseat.
    Object tag = getParent() instanceof FolderIcon ? ((View) getParent()).getTag() : getTag();
    ItemInfo info = tag instanceof ItemInfo ? (ItemInfo) tag : null;
    return info == null || info.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT;
}
Also used : PackageItemInfo(com.android.launcher3.model.PackageItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon)

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