Search in sources :

Example 81 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.

the class FolderPagedView method findNearestArea.

/**
 * @return the rank of the cell nearest to the provided pixel position.
 */
public int findNearestArea(int pixelX, int pixelY) {
    int pageIndex = getNextPage();
    CellLayout page = getPageAt(pageIndex);
    page.findNearestArea(pixelX, pixelY, 1, 1, sTmpArray);
    if (mFolder.isLayoutRtl()) {
        sTmpArray[0] = page.getCountX() - sTmpArray[0] - 1;
    }
    return Math.min(mAllocatedContentSize - 1, pageIndex * mOrganizer.getMaxItemsPerPage() + sTmpArray[1] * mGridCountX + sTmpArray[0]);
}
Also used : CellLayout(com.android.launcher3.CellLayout) SuppressLint(android.annotation.SuppressLint)

Example 82 with CellLayout

use of com.android.launcher3.CellLayout 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 83 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.

the class Folder method replaceFolderWithFinalItem.

@Thunk
void replaceFolderWithFinalItem() {
    // Add the last remaining child to the workspace in place of the folder
    Runnable onCompleteRunnable = new Runnable() {

        @Override
        public void run() {
            int itemCount = getItemCount();
            if (itemCount <= 1) {
                View newIcon = null;
                WorkspaceItemInfo finalItem = null;
                if (itemCount == 1) {
                    // Move the item from the folder to the workspace, in the position of the
                    // folder
                    CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screenId);
                    finalItem = mInfo.contents.remove(0);
                    newIcon = mLauncher.createShortcut(cellLayout, finalItem);
                    mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem, mInfo.container, mInfo.screenId, mInfo.cellX, mInfo.cellY);
                }
                // Remove the folder
                mLauncher.removeItem(mFolderIcon, mInfo, true);
                if (mFolderIcon instanceof DropTarget) {
                    mDragController.removeDropTarget((DropTarget) mFolderIcon);
                }
                if (newIcon != null) {
                    // We add the child after removing the folder to prevent both from existing
                    // at the same time in the CellLayout.  We need to add the new item with
                    // addInScreenFromBind() to ensure that hotseat items are placed correctly.
                    mLauncher.getWorkspace().addInScreenFromBind(newIcon, mInfo);
                    // Focus the newly created child
                    newIcon.requestFocus();
                }
                if (finalItem != null) {
                    mLauncher.folderConvertedToItem(mFolderIcon.getFolder(), finalItem);
                }
            }
        }
    };
    View finalChild = mContent.getLastItem();
    if (finalChild != null) {
        mFolderIcon.performDestroyAnimation(onCompleteRunnable);
    } else {
        onCompleteRunnable.run();
    }
    mDestroyed = true;
}
Also used : CellLayout(com.android.launcher3.CellLayout) DropTarget(com.android.launcher3.DropTarget) 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) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Thunk(com.android.launcher3.util.Thunk)

Example 84 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.

the class FolderPagedView method setFixedSize.

public void setFixedSize(int width, int height) {
    width -= (getPaddingLeft() + getPaddingRight());
    height -= (getPaddingTop() + getPaddingBottom());
    for (int i = getChildCount() - 1; i >= 0; i--) {
        ((CellLayout) getChildAt(i)).setFixedSize(width, height);
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout) SuppressLint(android.annotation.SuppressLint)

Example 85 with CellLayout

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

Aggregations

CellLayout (com.android.launcher3.CellLayout)178 View (android.view.View)169 SuppressLint (android.annotation.SuppressLint)126 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)124 AppWidgetHostView (android.appwidget.AppWidgetHostView)105 Point (android.graphics.Point)95 DragView (com.android.launcher3.dragndrop.DragView)91 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)87 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)86 ItemInfo (com.android.launcher3.model.data.ItemInfo)73 BubbleTextView (com.android.launcher3.BubbleTextView)62 Rect (android.graphics.Rect)60 FolderIcon (com.android.launcher3.folder.FolderIcon)52 DragLayer (com.android.launcher3.dragndrop.DragLayer)50 ArrayList (java.util.ArrayList)48 FolderInfo (com.android.launcher3.model.data.FolderInfo)45 Workspace (com.android.launcher3.Workspace)43 DraggableView (com.android.launcher3.dragndrop.DraggableView)43 Animator (android.animation.Animator)42 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40