Search in sources :

Example 96 with Folder

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

the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_folder.

@Test
public void testCustomProfileLoaded_with_folder() throws Exception {
    writeLayout(new LauncherLayoutBuilder().atHotseat(0).putFolder(android.R.string.copy).addApp(SETTINGS_APP, SETTINGS_APP).addApp(SETTINGS_APP, SETTINGS_APP).addApp(SETTINGS_APP, SETTINGS_APP).build());
    // Launch the home activity
    mDevice.pressHome();
    mLauncher.getWorkspace().getHotseatFolder("Folder: Copy");
}
Also used : LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Example 97 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by ArrowOS.

the class Workspace method updateNotificationDots.

public void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
    final PackageUserKey packageUserKey = new PackageUserKey(null, null);
    Predicate<ItemInfo> matcher = info -> !packageUserKey.updateFromItemInfo(info) || updatedDots.test(packageUserKey);
    ItemOperator op = (info, v) -> {
        if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView) {
            if (matcher.test(info)) {
                ((BubbleTextView) v).applyDotState(info, true);
            }
        } else if (info instanceof FolderInfo && v instanceof FolderIcon) {
            FolderInfo fi = (FolderInfo) info;
            if (fi.contents.stream().anyMatch(matcher)) {
                FolderDotInfo folderDotInfo = new FolderDotInfo();
                for (WorkspaceItemInfo si : fi.contents) {
                    folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
                }
                ((FolderIcon) v).setDotInfo(folderDotInfo);
            }
        }
        // process all the shortcuts
        return false;
    };
    mapOverItems(op);
    Folder folder = Folder.getOpen(mLauncher);
    if (folder != null) {
        folder.iterateOverItems(op);
    }
}
Also used : BitmapRenderer(com.android.launcher3.icons.BitmapRenderer) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) 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) Log(android.util.Log) WallpaperOffsetInterpolator(com.android.launcher3.util.WallpaperOffsetInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) OverlayEdgeEffect(com.android.launcher3.util.OverlayEdgeEffect) Nullable(androidx.annotation.Nullable) 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) AppWidgetHostViewDragListener(com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) 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) AnimatorListeners.forSuccessCallback(com.android.launcher3.anim.AnimatorListeners.forSuccessCallback) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) IntArray(com.android.launcher3.util.IntArray) ProviderChangedListener(com.android.launcher3.widget.LauncherAppWidgetHost.ProviderChangedListener) Parcelable(android.os.Parcelable) InstanceId(com.android.launcher3.logging.InstanceId) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) DragController(com.android.launcher3.dragndrop.DragController) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) StateManager(com.android.launcher3.statemanager.StateManager) FeatureFlags(com.android.launcher3.config.FeatureFlags) IntSet(com.android.launcher3.util.IntSet) LauncherAppWidgetHost(com.android.launcher3.widget.LauncherAppWidgetHost) LAUNCHER_SWIPERIGHT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPERIGHT) WorkspaceTouchListener(com.android.launcher3.touch.WorkspaceTouchListener) RunnableList(com.android.launcher3.util.RunnableList) 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) 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) EdgeEffectCompat(com.android.launcher3.util.EdgeEffectCompat) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) SparseArray(android.util.SparseArray) WidgetSizes(com.android.launcher3.widget.util.WidgetSizes) List(java.util.List) 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) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) LauncherBindableItemsContainer(com.android.launcher3.util.LauncherBindableItemsContainer) 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) Iterator(java.util.Iterator) LayoutInflater(android.view.LayoutInflater) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) Consumer(java.util.function.Consumer) StatsLogManager(com.android.launcher3.logging.StatsLogManager) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) 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) HINT_STATE(com.android.launcher3.LauncherState.HINT_STATE) Collections(java.util.Collections) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DragView(com.android.launcher3.dragndrop.DragView) Resources(android.content.res.Resources) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) PackageUserKey(com.android.launcher3.util.PackageUserKey) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 98 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by ArrowOS.

the class Workspace method scrollRight.

@Override
public boolean scrollRight() {
    boolean result = false;
    if (!mIsSwitchingState && workspaceInScrollableState()) {
        result = super.scrollRight();
    }
    Folder openFolder = Folder.getOpen(mLauncher);
    if (openFolder != null) {
        openFolder.completeDragExit();
    }
    return result;
}
Also used : Folder(com.android.launcher3.folder.Folder)

Example 99 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by ArrowOS.

the class Workspace method scrollLeft.

@Override
public boolean scrollLeft() {
    boolean result = false;
    if (!mIsSwitchingState && workspaceInScrollableState()) {
        result = super.scrollLeft();
    }
    Folder openFolder = Folder.getOpen(mLauncher);
    if (openFolder != null) {
        openFolder.completeDragExit();
    }
    return result;
}
Also used : Folder(com.android.launcher3.folder.Folder)

Example 100 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by ArrowOS.

the class Workspace method onDrop.

@Override
public void onDrop(final DragObject d, DragOptions options) {
    mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter);
    CellLayout dropTargetLayout = mDropToLayout;
    // We want the point to be mapped to the dragTarget.
    if (dropTargetLayout != null) {
        mapPointFromDropLayout(dropTargetLayout, mDragViewVisualCenter);
    }
    boolean droppedOnOriginalCell = false;
    boolean snappedToNewPage = false;
    boolean resizeOnDrop = false;
    Runnable onCompleteRunnable = null;
    if (d.dragSource != this || mDragInfo == null) {
        final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1] };
        onDropExternal(touchXY, dropTargetLayout, d);
    } else {
        final View cell = mDragInfo.cell;
        boolean droppedOnOriginalCellDuringTransition = false;
        if (dropTargetLayout != null && !d.cancelled) {
            // Move internally
            boolean hasMovedLayouts = (getParentCellLayoutForView(cell) != dropTargetLayout);
            boolean hasMovedIntoHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
            int container = hasMovedIntoHotseat ? LauncherSettings.Favorites.CONTAINER_HOTSEAT : LauncherSettings.Favorites.CONTAINER_DESKTOP;
            int screenId = (mTargetCell[0] < 0) ? mDragInfo.screenId : getIdForScreen(dropTargetLayout);
            int spanX = mDragInfo != null ? mDragInfo.spanX : 1;
            int spanY = mDragInfo != null ? mDragInfo.spanY : 1;
            // First we find the cell nearest to point at which the item is
            // dropped, without any consideration to whether there is an item there.
            mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], spanX, spanY, dropTargetLayout, mTargetCell);
            float distance = dropTargetLayout.getDistanceFromWorkspaceCellVisualCenter(mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
            // cell also contains a shortcut, then create a folder with the two shortcuts.
            if (createUserFolderIfNecessary(cell, container, dropTargetLayout, mTargetCell, distance, false, d) || addToExistingFolderIfNecessary(cell, dropTargetLayout, mTargetCell, distance, d, false)) {
                mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
                return;
            }
            // Aside from the special case where we're dropping a shortcut onto a shortcut,
            // we need to find the nearest cell location that is vacant
            ItemInfo item = d.dragInfo;
            int minSpanX = item.spanX;
            int minSpanY = item.spanY;
            if (item.minSpanX > 0 && item.minSpanY > 0) {
                minSpanX = item.minSpanX;
                minSpanY = item.minSpanY;
            }
            droppedOnOriginalCell = item.screenId == screenId && item.container == container && item.cellX == mTargetCell[0] && item.cellY == mTargetCell[1];
            droppedOnOriginalCellDuringTransition = droppedOnOriginalCell && mIsSwitchingState;
            // When quickly moving an item, a user may accidentally rearrange their
            // workspace. So instead we move the icon back safely to its original position.
            boolean returnToOriginalCellToPreventShuffling = !isFinishedSwitchingState() && !droppedOnOriginalCellDuringTransition && !dropTargetLayout.isRegionVacant(mTargetCell[0], mTargetCell[1], spanX, spanY);
            int[] resultSpan = new int[2];
            if (returnToOriginalCellToPreventShuffling) {
                mTargetCell[0] = mTargetCell[1] = -1;
            } else {
                mTargetCell = dropTargetLayout.performReorder((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY, cell, mTargetCell, resultSpan, CellLayout.MODE_ON_DROP);
            }
            boolean foundCell = mTargetCell[0] >= 0 && mTargetCell[1] >= 0;
            // if the widget resizes on drop
            if (foundCell && (cell instanceof AppWidgetHostView) && (resultSpan[0] != item.spanX || resultSpan[1] != item.spanY)) {
                resizeOnDrop = true;
                item.spanX = resultSpan[0];
                item.spanY = resultSpan[1];
                AppWidgetHostView awhv = (AppWidgetHostView) cell;
                WidgetSizes.updateWidgetSizeRanges(awhv, mLauncher, resultSpan[0], resultSpan[1]);
            }
            if (foundCell) {
                int targetScreenIndex = getPageIndexForScreenId(screenId);
                int snapScreen = getLeftmostVisiblePageForIndex(targetScreenIndex);
                // isn't needed if the source and target screens appear at the same time
                if (snapScreen != mCurrentPage && !hasMovedIntoHotseat) {
                    snapToPage(snapScreen);
                    snappedToNewPage = true;
                }
                final ItemInfo info = (ItemInfo) cell.getTag();
                if (hasMovedLayouts) {
                    // Reparent the view
                    CellLayout parentCell = getParentCellLayoutForView(cell);
                    if (parentCell != null) {
                        parentCell.removeView(cell);
                    } else if (mDragInfo.cell instanceof LauncherAppWidgetHostView) {
                        d.dragView.detachContentView(/* reattachToPreviousParent= */
                        false);
                    } else if (FeatureFlags.IS_STUDIO_BUILD) {
                        throw new NullPointerException("mDragInfo.cell has null parent");
                    }
                    addInScreen(cell, container, screenId, mTargetCell[0], mTargetCell[1], info.spanX, info.spanY);
                }
                // update the item's position after drop
                CellLayout.LayoutParams lp = (CellLayout.LayoutParams) cell.getLayoutParams();
                lp.cellX = lp.tmpCellX = mTargetCell[0];
                lp.cellY = lp.tmpCellY = mTargetCell[1];
                lp.cellHSpan = item.spanX;
                lp.cellVSpan = item.spanY;
                lp.isLockedToGrid = true;
                if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT && cell instanceof LauncherAppWidgetHostView) {
                    final CellLayout cellLayout = dropTargetLayout;
                    // We post this call so that the widget has a chance to be placed
                    // in its final location
                    final LauncherAppWidgetHostView hostView = (LauncherAppWidgetHostView) cell;
                    AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo();
                    if (pInfo != null && !options.isAccessibleDrag) {
                        onCompleteRunnable = () -> {
                            if (!isPageInTransition()) {
                                AppWidgetResizeFrame.showForWidget(hostView, cellLayout);
                            }
                        };
                    }
                }
                mLauncher.getModelWriter().modifyItemInDatabase(info, container, screenId, lp.cellX, lp.cellY, item.spanX, item.spanY);
            } else {
                if (!returnToOriginalCellToPreventShuffling) {
                    onNoCellFound(dropTargetLayout, d.dragInfo, d.logInstanceId);
                }
                if (mDragInfo.cell instanceof LauncherAppWidgetHostView) {
                    d.dragView.detachContentView(/* reattachToPreviousParent= */
                    true);
                }
                // If we can't find a drop location, we return the item to its original position
                CellLayout.LayoutParams lp = (CellLayout.LayoutParams) cell.getLayoutParams();
                mTargetCell[0] = lp.cellX;
                mTargetCell[1] = lp.cellY;
                CellLayout layout = (CellLayout) cell.getParent().getParent();
                layout.markCellsAsOccupiedForView(cell);
            }
        } else {
            // When drag is cancelled, reattach content view back to its original parent.
            if (mDragInfo.cell instanceof LauncherAppWidgetHostView) {
                d.dragView.detachContentView(/* reattachToPreviousParent= */
                true);
            }
        }
        final CellLayout parent = (CellLayout) cell.getParent().getParent();
        if (d.dragView.hasDrawn()) {
            if (droppedOnOriginalCellDuringTransition) {
                // Animate the item to its original position, while simultaneously exiting
                // spring-loaded mode so the page meets the icon where it was picked up.
                final RunnableList callbackList = new RunnableList();
                final Runnable onCompleteCallback = onCompleteRunnable;
                mLauncher.getDragController().animateDragViewToOriginalPosition(/* onComplete= */
                callbackList::executeAllAndDestroy, cell, SPRING_LOADED.getTransitionDuration(mLauncher));
                mLauncher.getStateManager().goToState(NORMAL, /* delay= */
                0, onCompleteCallback == null ? null : forSuccessCallback(() -> callbackList.add(onCompleteCallback)));
                mLauncher.getDropTargetBar().onDragEnd();
                parent.onDropChild(cell);
                return;
            }
            final ItemInfo info = (ItemInfo) cell.getTag();
            boolean isWidget = info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
            if (isWidget) {
                int animationType = resizeOnDrop ? ANIMATE_INTO_POSITION_AND_RESIZE : ANIMATE_INTO_POSITION_AND_DISAPPEAR;
                animateWidgetDrop(info, parent, d.dragView, null, animationType, cell, false);
            } else {
                int duration = snappedToNewPage ? ADJACENT_SCREEN_DROP_DURATION : -1;
                mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration, this);
            }
        } else {
            d.deferDragViewCleanupPostAnimation = false;
            cell.setVisibility(VISIBLE);
        }
        parent.onDropChild(cell);
        mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY, onCompleteRunnable == null ? null : forSuccessCallback(onCompleteRunnable));
        mStatsLogManager.logger().withItemInfo(d.dragInfo).withInstanceId(d.logInstanceId).log(LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED);
    }
    if (d.stateAnnouncer != null && !droppedOnOriginalCell) {
        d.stateAnnouncer.completeAction(R.string.item_moved);
    }
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) DraggableView(com.android.launcher3.dragndrop.DraggableView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) RunnableList(com.android.launcher3.util.RunnableList) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

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