Search in sources :

Example 91 with Folder

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

the class FolderIcon method drawLeaveBehindIfExists.

public void drawLeaveBehindIfExists() {
    if (isInAppDrawer()) {
        return;
    }
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
    // While the folder is open, the position of the icon cannot change.
    lp.canReorder = false;
    if (mInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        CellLayout cl = (CellLayout) getParent().getParent();
        cl.setFolderLeaveBehindCell(lp.cellX, lp.cellY);
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout)

Example 92 with Folder

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

the class PreviewItemManager method setDrawable.

private void setDrawable(PreviewItemDrawingParams p, WorkspaceItemInfo item) {
    if (item.hasPromiseIconUi()) {
        PreloadIconDrawable drawable = mDrawableFactory.newPendingIcon(mContext, item);
        drawable.setLevel(item.getInstallProgress());
        p.drawable = drawable;
    } else {
        p.drawable = mDrawableFactory.newIcon(mContext, item);
    }
    p.drawable.setBounds(0, 0, mIconSize, mIconSize);
    p.item = item;
    // Set the callback to FolderIcon as it is responsible to drawing the icon. The
    // callback will be released when the folder is opened.
    p.drawable.setCallback(mIcon);
}
Also used : PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable)

Example 93 with Folder

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

the class GridSizeMigrationTask method loadHotseatEntries.

private ArrayList<DbEntry> loadHotseatEntries() {
    Cursor c = queryWorkspace(new String[] { // 0
    Favorites._ID, // 1
    Favorites.ITEM_TYPE, // 2
    Favorites.INTENT, // 3
    Favorites.SCREEN }, Favorites.CONTAINER + " = " + Favorites.CONTAINER_HOTSEAT);
    final int indexId = c.getColumnIndexOrThrow(Favorites._ID);
    final int indexItemType = c.getColumnIndexOrThrow(Favorites.ITEM_TYPE);
    final int indexIntent = c.getColumnIndexOrThrow(Favorites.INTENT);
    final int indexScreen = c.getColumnIndexOrThrow(Favorites.SCREEN);
    ArrayList<DbEntry> entries = new ArrayList<>();
    while (c.moveToNext()) {
        DbEntry entry = new DbEntry();
        entry.id = c.getInt(indexId);
        entry.itemType = c.getInt(indexItemType);
        entry.screenId = c.getInt(indexScreen);
        if (entry.screenId >= mSrcHotseatSize) {
            mEntryToRemove.add(entry.id);
            continue;
        }
        try {
            // calculate weight
            switch(entry.itemType) {
                case Favorites.ITEM_TYPE_SHORTCUT:
                case Favorites.ITEM_TYPE_DEEP_SHORTCUT:
                case Favorites.ITEM_TYPE_APPLICATION:
                    {
                        verifyIntent(c.getString(indexIntent));
                        entry.weight = entry.itemType == Favorites.ITEM_TYPE_APPLICATION ? WT_APPLICATION : WT_SHORTCUT;
                        break;
                    }
                case Favorites.ITEM_TYPE_FOLDER:
                    {
                        int total = getFolderItemsCount(entry.id);
                        if (total == 0) {
                            throw new Exception("Folder is empty");
                        }
                        entry.weight = WT_FOLDER_FACTOR * total;
                        break;
                    }
                default:
                    throw new Exception("Invalid item type");
            }
        } catch (Exception e) {
            if (DEBUG) {
                Log.d(TAG, "Removing item " + entry.id, e);
            }
            mEntryToRemove.add(entry.id);
            continue;
        }
        entries.add(entry);
    }
    c.close();
    return entries;
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Utilities.parsePoint(com.android.launcher3.Utilities.parsePoint) Point(android.graphics.Point)

Example 94 with Folder

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

the class GridSizeMigrationTask method getFolderItemsCount.

/**
 * @return the number of valid items in the folder.
 */
private int getFolderItemsCount(int folderId) {
    Cursor c = queryWorkspace(new String[] { Favorites._ID, Favorites.INTENT }, Favorites.CONTAINER + " = " + folderId);
    int total = 0;
    while (c.moveToNext()) {
        try {
            verifyIntent(c.getString(1));
            total++;
        } catch (Exception e) {
            mEntryToRemove.add(c.getInt(0));
        }
    }
    c.close();
    return total;
}
Also used : Cursor(android.database.Cursor) Utilities.parsePoint(com.android.launcher3.Utilities.parsePoint) Point(android.graphics.Point)

Example 95 with Folder

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

the class PopupContainerWithArrow method onLongClick.

@Override
public boolean onLongClick(View v) {
    if (!ItemLongClickListener.canStartDrag(mLauncher))
        return false;
    // Return early if not the correct view
    if (!(v.getParent() instanceof DeepShortcutView))
        return false;
    // Long clicked on a shortcut.
    DeepShortcutView sv = (DeepShortcutView) v.getParent();
    sv.setWillDrawIcon(false);
    // Move the icon to align with the center-top of the touch point
    Point iconShift = new Point();
    iconShift.x = mIconLastTouchPos.x - sv.getIconCenter().x;
    iconShift.y = mIconLastTouchPos.y - mLauncher.getDeviceProfile().iconSizePx;
    DragView dv = mLauncher.getWorkspace().beginDragShared(sv.getIconView(), this, sv.getFinalInfo(), new ShortcutDragPreviewProvider(sv.getIconView(), iconShift), new DragOptions());
    dv.animateShift(-iconShift.x, -iconShift.y);
    // TODO: support dragging from within folder without having to close it
    AbstractFloatingView.closeOpenContainer(mLauncher, AbstractFloatingView.TYPE_FOLDER);
    return false;
}
Also used : DragOptions(com.android.launcher3.dragndrop.DragOptions) DragView(com.android.launcher3.dragndrop.DragView) ShortcutDragPreviewProvider(com.android.launcher3.shortcuts.ShortcutDragPreviewProvider) Point(android.graphics.Point) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView)

Aggregations

View (android.view.View)119 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)112 FolderInfo (com.android.launcher3.model.data.FolderInfo)93 ItemInfo (com.android.launcher3.model.data.ItemInfo)86 Point (android.graphics.Point)83 FolderIcon (com.android.launcher3.folder.FolderIcon)83 Folder (com.android.launcher3.folder.Folder)82 AppWidgetHostView (android.appwidget.AppWidgetHostView)80 SuppressLint (android.annotation.SuppressLint)73 DragView (com.android.launcher3.dragndrop.DragView)64 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)64 Rect (android.graphics.Rect)63 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)61 BubbleTextView (com.android.launcher3.BubbleTextView)56 ArrayList (java.util.ArrayList)49 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)47 Animator (android.animation.Animator)40 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 Drawable (android.graphics.drawable.Drawable)37 CellLayout (com.android.launcher3.CellLayout)37