Search in sources :

Example 31 with FolderInfo

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

the class Workspace method updateShortcuts.

void updateShortcuts(ArrayList<WorkspaceItemInfo> shortcuts) {
    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(mLauncher);
    if (openFolder != null) {
        openFolder.iterateOverItems(op);
    }
}
Also used : BitmapRenderer(com.android.launcher3.icons.BitmapRenderer) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) OVERVIEW(com.android.launcher3.LauncherState.OVERVIEW) LAUNCHER_SWIPELEFT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPELEFT) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Drawable(android.graphics.drawable.Drawable) DraggableView(com.android.launcher3.dragndrop.DraggableView) WallpaperManager(android.app.WallpaperManager) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) LayoutTransition(android.animation.LayoutTransition) Interpolators(com.android.launcher3.anim.Interpolators) LauncherAtom(com.android.launcher3.logger.LauncherAtom) Handler(android.os.Handler) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) Log(android.util.Log) WallpaperOffsetInterpolator(com.android.launcher3.util.WallpaperOffsetInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Message(android.os.Message) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) NORMAL(com.android.launcher3.LauncherState.NORMAL) AccessibleDragListenerAdapter(com.android.launcher3.accessibility.AccessibleDragListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) SpringLoadedDragController(com.android.launcher3.dragndrop.SpringLoadedDragController) ArrayList(java.util.ArrayList) FLAG_MULTI_PAGE(com.android.launcher3.LauncherState.FLAG_MULTI_PAGE) PreviewBackground(com.android.launcher3.folder.PreviewBackground) AppWidgetHostView(android.appwidget.AppWidgetHostView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) IntArray(com.android.launcher3.util.IntArray) Parcelable(android.os.Parcelable) DragController(com.android.launcher3.dragndrop.DragController) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) LAUNCHER_SWIPERIGHT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPERIGHT) WorkspaceTouchListener(com.android.launcher3.touch.WorkspaceTouchListener) DragPreviewProvider(com.android.launcher3.graphics.DragPreviewProvider) ValueAnimator(android.animation.ValueAnimator) WorkspaceAccessibilityHelper(com.android.launcher3.accessibility.WorkspaceAccessibilityHelper) Rect(android.graphics.Rect) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) Animator(android.animation.Animator) ProviderChangedListener(com.android.launcher3.LauncherAppWidgetHost.ProviderChangedListener) SPRING_LOADED(com.android.launcher3.LauncherState.SPRING_LOADED) FLAG_WORKSPACE_INACCESSIBLE(com.android.launcher3.LauncherState.FLAG_WORKSPACE_INACCESSIBLE) AttributeSet(android.util.AttributeSet) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) LauncherEvent(com.android.launcher3.logging.StatsLogManager.LauncherEvent) Predicate(java.util.function.Predicate) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) SparseArray(android.util.SparseArray) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) LAUNCHER_STATE_HOME(com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) ALPHA_INDEX_OVERLAY(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AppInfo(com.android.launcher3.model.data.AppInfo) LauncherOverlay(com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) HashSet(java.util.HashSet) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED(com.android.launcher3.LauncherState.FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED) DragLayer(com.android.launcher3.dragndrop.DragLayer) Executors(com.android.launcher3.util.Executors) ADAPTIVE_ICON_WINDOW_ANIM(com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM) Action(com.android.launcher3.userevent.nano.LauncherLogProto.Action) ContainerType(com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType) LayoutInflater(android.view.LayoutInflater) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) StatsLogManager(com.android.launcher3.logging.StatsLogManager) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) Bitmap(android.graphics.Bitmap) WorkspacePageIndicator(com.android.launcher3.pageindicators.WorkspacePageIndicator) StateHandler(com.android.launcher3.statemanager.StateManager.StateHandler) ViewTreeObserver(android.view.ViewTreeObserver) IntSparseArrayMap(com.android.launcher3.util.IntSparseArrayMap) Thunk(com.android.launcher3.util.Thunk) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DragView(com.android.launcher3.dragndrop.DragView) Resources(android.content.res.Resources) FolderIcon(com.android.launcher3.folder.FolderIcon) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) 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)

Example 32 with FolderInfo

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

the class WorkspaceAccessibilityHelper method intersectsValidDropTarget.

/**
 * Find the virtual view id corresponding to the top left corner of any drop region by which
 * the passed id is contained. For an icon, this is simply
 */
@Override
protected int intersectsValidDropTarget(int id) {
    int mCountX = mView.getCountX();
    int mCountY = mView.getCountY();
    int x = id % mCountX;
    int y = id / mCountX;
    LauncherAccessibilityDelegate.DragInfo dragInfo = mDelegate.getDragInfo();
    if (dragInfo.dragType == DragType.WIDGET && !mView.acceptsWidget()) {
        return INVALID_POSITION;
    }
    if (dragInfo.dragType == DragType.WIDGET) {
        // For a widget, every cell must be vacant. In addition, we will return any valid
        // drop target by which the passed id is contained.
        boolean fits = false;
        // These represent the amount that we can back off if we hit a problem. They
        // get consumed as we move up and to the right, trying new regions.
        int spanX = dragInfo.info.spanX;
        int spanY = dragInfo.info.spanY;
        for (int m = 0; m < spanX; m++) {
            for (int n = 0; n < spanY; n++) {
                fits = true;
                int x0 = x - m;
                int y0 = y - n;
                if (x0 < 0 || y0 < 0)
                    continue;
                for (int i = x0; i < x0 + spanX; i++) {
                    if (!fits)
                        break;
                    for (int j = y0; j < y0 + spanY; j++) {
                        if (i >= mCountX || j >= mCountY || mView.isOccupied(i, j)) {
                            fits = false;
                            break;
                        }
                    }
                }
                if (fits) {
                    return x0 + mCountX * y0;
                }
            }
        }
        return INVALID_POSITION;
    } else {
        // For an icon, we simply check the view directly below
        View child = mView.getChildAt(x, y);
        if (child == null || child == dragInfo.item) {
            // Empty cell. Good for an icon or folder.
            return id;
        } else if (dragInfo.dragType != DragType.FOLDER) {
            // For icons, we can consider cells that have another icon or a folder.
            ItemInfo info = (ItemInfo) child.getTag();
            if (info instanceof AppInfo || info instanceof FolderInfo || info instanceof WorkspaceItemInfo) {
                return id;
            }
        }
        return INVALID_POSITION;
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) View(android.view.View) FolderInfo(com.android.launcher3.model.data.FolderInfo) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 33 with FolderInfo

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

the class Launcher method removeItem.

/**
 * Unbinds the view for the specified item, and removes the item and all its children.
 *
 * @param v the view being removed.
 * @param itemInfo the {@link ItemInfo} for this view.
 * @param deleteFromDb whether or not to delete this item from the db.
 */
public boolean removeItem(View v, final ItemInfo itemInfo, boolean deleteFromDb) {
    if (itemInfo instanceof WorkspaceItemInfo) {
        // Remove the shortcut from the folder before removing it from launcher
        View folderIcon = mWorkspace.getHomescreenIconByItemId(itemInfo.container);
        if (folderIcon instanceof FolderIcon) {
            ((FolderInfo) folderIcon.getTag()).remove((WorkspaceItemInfo) itemInfo, true);
        } else {
            mWorkspace.removeWorkspaceItem(v);
        }
        if (deleteFromDb) {
            getModelWriter().deleteItemFromDatabase(itemInfo);
        }
    } else if (itemInfo instanceof FolderInfo) {
        final FolderInfo folderInfo = (FolderInfo) itemInfo;
        if (v instanceof FolderIcon) {
            ((FolderIcon) v).removeListeners();
        }
        mWorkspace.removeWorkspaceItem(v);
        if (deleteFromDb) {
            getModelWriter().deleteFolderAndContentsFromDatabase(folderInfo);
        }
    } else if (itemInfo instanceof LauncherAppWidgetInfo) {
        final LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo) itemInfo;
        mWorkspace.removeWorkspaceItem(v);
        if (deleteFromDb) {
            getModelWriter().deleteWidgetInfo(widgetInfo, getAppWidgetHost());
        }
    } else {
        return false;
    }
    return true;
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) QsbContainerView(com.android.launcher3.qsb.QsbContainerView) FloatingSurfaceView(com.android.launcher3.views.FloatingSurfaceView) AppWidgetHostView(android.appwidget.AppWidgetHostView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) ScrimView(com.android.launcher3.views.ScrimView) DragView(com.android.launcher3.dragndrop.DragView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 34 with FolderInfo

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

the class Launcher method completeAddShortcut.

/**
 * Add a shortcut to the workspace or to a Folder.
 *
 * @param data The intent describing the shortcut.
 */
private void completeAddShortcut(Intent data, int container, int screenId, int cellX, int cellY, PendingRequestArgs args) {
    if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT || args.getPendingIntent().getComponent() == null) {
        return;
    }
    int[] cellXY = mTmpAddItemCellCoordinates;
    CellLayout layout = getCellLayout(container, screenId);
    WorkspaceItemInfo info = null;
    if (Utilities.ATLEAST_OREO) {
        info = PinRequestHelper.createWorkspaceItemFromPinItemRequest(this, PinRequestHelper.getPinItemRequest(data), 0);
    }
    if (info == null) {
        // Legacy shortcuts are only supported for primary profile.
        info = Process.myUserHandle().equals(args.user) ? InstallShortcutReceiver.fromShortcutIntent(this, data) : null;
        if (info == null) {
            Log.e(TAG, "Unable to parse a valid custom shortcut result");
            return;
        } else if (!new PackageManagerHelper(this).hasPermissionForActivity(info.intent, args.getPendingIntent().getComponent().getPackageName())) {
            // The app is trying to add a shortcut without sufficient permissions
            Log.e(TAG, "Ignoring malicious intent " + info.intent.toUri(0));
            return;
        }
    }
    if (container < 0) {
        // Adding a shortcut to the Workspace.
        final View view = createShortcut(info);
        boolean foundCellSpan = false;
        // First we check if we already know the exact location where we want to add this item.
        if (cellX >= 0 && cellY >= 0) {
            cellXY[0] = cellX;
            cellXY[1] = cellY;
            foundCellSpan = true;
            DragObject dragObject = new DragObject(getApplicationContext());
            dragObject.dragInfo = info;
            // If appropriate, either create a folder or add to an existing folder
            if (mWorkspace.createUserFolderIfNecessary(view, container, layout, cellXY, 0, true, dragObject)) {
                return;
            }
            if (mWorkspace.addToExistingFolderIfNecessary(view, layout, cellXY, 0, dragObject, true)) {
                return;
            }
        } else {
            foundCellSpan = layout.findCellForSpan(cellXY, 1, 1);
        }
        if (!foundCellSpan) {
            mWorkspace.onNoCellFound(layout);
            return;
        }
        getModelWriter().addItemToDatabase(info, container, screenId, cellXY[0], cellXY[1]);
        mWorkspace.addInScreen(view, info);
    } else {
        // Adding a shortcut to a Folder.
        FolderIcon folderIcon = findFolderIcon(container);
        if (folderIcon != null) {
            FolderInfo folderInfo = (FolderInfo) folderIcon.getTag();
            folderInfo.add(info, args.rank, false);
        } else {
            Log.e(TAG, "Could not find folder with id " + container + " to add shortcut.");
        }
    }
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) DragObject(com.android.launcher3.DropTarget.DragObject) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) QsbContainerView(com.android.launcher3.qsb.QsbContainerView) FloatingSurfaceView(com.android.launcher3.views.FloatingSurfaceView) AppWidgetHostView(android.appwidget.AppWidgetHostView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) ScrimView(com.android.launcher3.views.ScrimView) DragView(com.android.launcher3.dragndrop.DragView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 35 with FolderInfo

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

the class ItemInfoMatcher method filterItemInfos.

/**
 * Filters {@param infos} to those satisfying the {@link #matches(ItemInfo, ComponentName)}.
 */
default HashSet<ItemInfo> filterItemInfos(Iterable<ItemInfo> infos) {
    HashSet<ItemInfo> filtered = new HashSet<>();
    for (ItemInfo i : infos) {
        if (i instanceof WorkspaceItemInfo) {
            WorkspaceItemInfo info = (WorkspaceItemInfo) i;
            ComponentName cn = info.getTargetComponent();
            if (cn != null && matches(info, cn)) {
                filtered.add(info);
            }
        } else if (i instanceof FolderInfo) {
            FolderInfo info = (FolderInfo) i;
            for (WorkspaceItemInfo s : info.contents) {
                ComponentName cn = s.getTargetComponent();
                if (cn != null && matches(s, cn)) {
                    filtered.add(s);
                }
            }
        } else if (i instanceof LauncherAppWidgetInfo) {
            LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) i;
            ComponentName cn = info.providerName;
            if (cn != null && matches(info, cn)) {
                filtered.add(info);
            }
        }
    }
    return filtered;
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) ComponentName(android.content.ComponentName) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) FolderInfo(com.android.launcher3.model.data.FolderInfo) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

FolderInfo (com.android.launcher3.model.data.FolderInfo)152 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)121 ItemInfo (com.android.launcher3.model.data.ItemInfo)100 View (android.view.View)98 FolderIcon (com.android.launcher3.folder.FolderIcon)73 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)65 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)61 ArrayList (java.util.ArrayList)59 AppWidgetHostView (android.appwidget.AppWidgetHostView)55 DragView (com.android.launcher3.dragndrop.DragView)51 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)50 Point (android.graphics.Point)47 AppInfo (com.android.launcher3.model.data.AppInfo)41 SuppressLint (android.annotation.SuppressLint)39 Rect (android.graphics.Rect)28 Folder (com.android.launcher3.folder.Folder)28 IntArray (com.android.launcher3.util.IntArray)28 HashSet (java.util.HashSet)28 UserHandle (android.os.UserHandle)27 Intent (android.content.Intent)26