Search in sources :

Example 1 with ArrowPopup

use of com.android.launcher3.popup.ArrowPopup in project android_packages_apps_Launcher3 by crdroidandroid.

the class StatefulActivity method onStop.

@Override
protected void onStop() {
    BaseDragLayer dragLayer = getDragLayer();
    final boolean wasActive = isUserActive();
    final STATE_TYPE origState = getStateManager().getState();
    final int origDragLayerChildCount = dragLayer.getChildCount();
    super.onStop();
    if (!isChangingConfigurations()) {
        getStateManager().moveToRestState();
    }
    // Workaround for b/78520668, explicitly trim memory once UI is hidden
    onTrimMemory(TRIM_MEMORY_UI_HIDDEN);
    if (wasActive) {
        // The expected condition is that this activity is stopped because the device goes to
        // sleep and the UI may have noticeable changes.
        dragLayer.post(() -> {
            if ((!getStateManager().isInStableState(origState) || // The drag layer may be animating (e.g. dismissing QSB).
            dragLayer.getAlpha() < 1 || // Maybe an ArrowPopup is closed.
            dragLayer.getChildCount() != origDragLayerChildCount)) {
                onUiChangedWhileSleeping();
            }
        });
    }
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer)

Example 2 with ArrowPopup

use of com.android.launcher3.popup.ArrowPopup in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherAccessibilityDelegate method performAction.

/**
 * Performs the provided action on the host
 */
protected boolean performAction(final View host, final ItemInfo item, int action, boolean fromKeyboard) {
    if (action == ACTION_LONG_CLICK) {
        if (PopupContainerWithArrow.canShow(host, item)) {
            // Long press should be consumed for workspace items, and it should invoke the
            // Shortcuts / Notifications / Actions pop-up menu, and not start a drag as the
            // standard long press path does.
            PopupContainerWithArrow.showForIcon((BubbleTextView) host);
            return true;
        }
    } else if (action == MOVE) {
        return beginAccessibleDrag(host, item, fromKeyboard);
    } else if (action == ADD_TO_WORKSPACE) {
        final int[] coordinates = new int[2];
        final int screenId = findSpaceOnWorkspace(item, coordinates);
        mLauncher.getStateManager().goToState(NORMAL, true, forSuccessCallback(() -> {
            if (item instanceof AppInfo) {
                WorkspaceItemInfo info = ((AppInfo) item).makeWorkspaceItem();
                mLauncher.getModelWriter().addItemToDatabase(info, Favorites.CONTAINER_DESKTOP, screenId, coordinates[0], coordinates[1]);
                mLauncher.bindItems(Collections.singletonList(info), /* forceAnimateIcons= */
                true, /* focusFirstItemForAccessibility= */
                true);
                announceConfirmation(R.string.item_added_to_workspace);
            } else if (item instanceof PendingAddItemInfo) {
                PendingAddItemInfo info = (PendingAddItemInfo) item;
                Workspace workspace = mLauncher.getWorkspace();
                workspace.snapToPage(workspace.getPageIndexForScreenId(screenId));
                mLauncher.addPendingItem(info, Favorites.CONTAINER_DESKTOP, screenId, coordinates, info.spanX, info.spanY);
            }
        }));
        return true;
    } else if (action == MOVE_TO_WORKSPACE) {
        Folder folder = Folder.getOpen(mLauncher);
        folder.close(true);
        WorkspaceItemInfo info = (WorkspaceItemInfo) item;
        folder.getInfo().remove(info, false);
        final int[] coordinates = new int[2];
        final int screenId = findSpaceOnWorkspace(item, coordinates);
        mLauncher.getModelWriter().moveItemInDatabase(info, Favorites.CONTAINER_DESKTOP, screenId, coordinates[0], coordinates[1]);
        // Bind the item in next frame so that if a new workspace page was created,
        // it will get laid out.
        new Handler().post(() -> {
            mLauncher.bindItems(Collections.singletonList(item), true);
            announceConfirmation(R.string.item_moved);
        });
        return true;
    } else if (action == RESIZE) {
        final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) item;
        List<OptionItem> actions = getSupportedResizeActions(host, info);
        Rect pos = new Rect();
        mLauncher.getDragLayer().getDescendantRectRelativeToSelf(host, pos);
        ArrowPopup popup = OptionsPopupView.show(mLauncher, new RectF(pos), actions, false);
        popup.requestFocus();
        popup.setOnCloseCallback(host::requestFocus);
        return true;
    } else if (action == DEEP_SHORTCUTS || action == SHORTCUTS_AND_NOTIFICATIONS) {
        return PopupContainerWithArrow.showForIcon((BubbleTextView) host) != null;
    } else {
        for (ButtonDropTarget dropTarget : mLauncher.getDropTargetBar().getDropTargets()) {
            if (dropTarget.supportsAccessibilityDrop(item, host) && action == dropTarget.getAccessibilityAction()) {
                dropTarget.onAccessibilityDrop(host, item);
                return true;
            }
        }
    }
    return false;
}
Also used : Rect(android.graphics.Rect) OptionItem(com.android.launcher3.views.OptionsPopupView.OptionItem) ArrowPopup(com.android.launcher3.popup.ArrowPopup) Handler(android.os.Handler) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) Folder(com.android.launcher3.folder.Folder) Point(android.graphics.Point) AppInfo(com.android.launcher3.model.data.AppInfo) RectF(android.graphics.RectF) PendingAddItemInfo(com.android.launcher3.PendingAddItemInfo) ButtonDropTarget(com.android.launcher3.ButtonDropTarget) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Workspace(com.android.launcher3.Workspace)

Aggregations

Point (android.graphics.Point)1 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 Handler (android.os.Handler)1 ButtonDropTarget (com.android.launcher3.ButtonDropTarget)1 PendingAddItemInfo (com.android.launcher3.PendingAddItemInfo)1 Workspace (com.android.launcher3.Workspace)1 Folder (com.android.launcher3.folder.Folder)1 AppInfo (com.android.launcher3.model.data.AppInfo)1 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)1 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)1 ArrowPopup (com.android.launcher3.popup.ArrowPopup)1 BaseDragLayer (com.android.launcher3.views.BaseDragLayer)1 OptionItem (com.android.launcher3.views.OptionsPopupView.OptionItem)1