Search in sources :

Example 31 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by AOSPA.

the class Folder method onDropCompleted.

@Override
public void onDropCompleted(final View target, final DragObject d, final boolean success) {
    if (success) {
        if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && target != this) {
            replaceFolderWithFinalItem();
        }
    } else {
        // The drag failed, we need to return the item to the folder
        WorkspaceItemInfo info = (WorkspaceItemInfo) d.dragInfo;
        View icon = (mCurrentDragView != null && mCurrentDragView.getTag() == info) ? mCurrentDragView : mContent.createNewView(info);
        ArrayList<View> views = getIconsInReadingOrder();
        info.rank = Utilities.boundToRange(info.rank, 0, views.size());
        views.add(info.rank, icon);
        mContent.arrangeChildren(views);
        mItemsInvalidated = true;
        try (SuppressInfoChanges s = new SuppressInfoChanges()) {
            mFolderIcon.onDrop(d, true);
        }
    }
    if (target != this) {
        if (mOnExitAlarm.alarmPending()) {
            mOnExitAlarm.cancelAlarm();
            if (!success) {
                mSuppressFolderDeletion = true;
            }
            mScrollPauseAlarm.cancelAlarm();
            completeDragExit();
        }
    }
    mDeleteFolderOnDropCompleted = false;
    mDragInProgress = false;
    mItemAddedBackToSelfViaIcon = false;
    mCurrentDragView = null;
    // Reordering may have occured, and we need to save the new item locations. We do this once
    // at the end to prevent unnecessary database operations.
    updateItemLocationsInDatabaseBatch(false);
    // been refreshed yet.
    if (getItemCount() <= mContent.itemsPerPage()) {
        // Show the animation, next time something is added to the folder.
        mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, false, mLauncherDelegate.getModelWriter());
    }
}
Also used : 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) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 32 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Trebuchet by LineageOS.

the class Workspace method createUserFolderIfNecessary.

boolean createUserFolderIfNecessary(View newView, int container, CellLayout target, int[] targetCell, float distance, boolean external, DragObject d) {
    if (distance > mMaxDistanceForFolderCreation)
        return false;
    View v = target.getChildAt(targetCell[0], targetCell[1]);
    boolean hasntMoved = false;
    if (mDragInfo != null) {
        CellLayout cellParent = getParentCellLayoutForView(mDragInfo.cell);
        hasntMoved = (mDragInfo.cellX == targetCell[0] && mDragInfo.cellY == targetCell[1]) && (cellParent == target);
    }
    if (v == null || hasntMoved || !mCreateUserFolderOnDrop)
        return false;
    mCreateUserFolderOnDrop = false;
    final int screenId = getIdForScreen(target);
    boolean aboveShortcut = (v.getTag() instanceof WorkspaceItemInfo);
    boolean willBecomeShortcut = (newView.getTag() instanceof WorkspaceItemInfo);
    if (aboveShortcut && willBecomeShortcut) {
        WorkspaceItemInfo sourceInfo = (WorkspaceItemInfo) newView.getTag();
        WorkspaceItemInfo destInfo = (WorkspaceItemInfo) v.getTag();
        // if the drag started here, we need to remove it from the workspace
        if (!external) {
            getParentCellLayoutForView(mDragInfo.cell).removeView(mDragInfo.cell);
        }
        Rect folderLocation = new Rect();
        float scale = mLauncher.getDragLayer().getDescendantRectRelativeToSelf(v, folderLocation);
        target.removeView(v);
        mStatsLogManager.logger().withItemInfo(destInfo).withInstanceId(d.logInstanceId).log(LauncherEvent.LAUNCHER_ITEM_DROP_FOLDER_CREATED);
        FolderIcon fi = mLauncher.addFolder(target, container, screenId, targetCell[0], targetCell[1]);
        destInfo.cellX = -1;
        destInfo.cellY = -1;
        sourceInfo.cellX = -1;
        sourceInfo.cellY = -1;
        // If the dragView is null, we can't animate
        boolean animate = d != null;
        if (animate) {
            // In order to keep everything continuous, we hand off the currently rendered
            // folder background to the newly created icon. This preserves animation state.
            fi.setFolderBackground(mFolderCreateBg);
            mFolderCreateBg = new PreviewBackground();
            fi.performCreateAnimation(destInfo, v, sourceInfo, d, folderLocation, scale);
        } else {
            fi.prepareCreateAnimation(v);
            fi.addItem(destInfo);
            fi.addItem(sourceInfo);
        }
        mLauncher.folderCreatedFromItem(fi.getFolder(), destInfo);
        return true;
    }
    return false;
}
Also used : Rect(android.graphics.Rect) PreviewBackground(com.android.launcher3.folder.PreviewBackground) FolderIcon(com.android.launcher3.folder.FolderIcon) 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) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 33 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherAccessibilityDelegate method addSupportedActions.

public void addSupportedActions(View host, AccessibilityNodeInfo info, boolean fromKeyboard) {
    if (!(host.getTag() instanceof ItemInfo))
        return;
    ItemInfo item = (ItemInfo) host.getTag();
    if (host instanceof AccessibilityActionHandler) {
        ((AccessibilityActionHandler) host).addSupportedAccessibilityActions(info);
    }
    // exposed as a direct shortcut
    if (!fromKeyboard && ShortcutUtil.supportsShortcuts(item)) {
        info.addAction(mActions.get(NotificationListener.getInstanceIfConnected() != null ? SHORTCUTS_AND_NOTIFICATIONS : DEEP_SHORTCUTS));
    }
    for (ButtonDropTarget target : mLauncher.getDropTargetBar().getDropTargets()) {
        if (target.supportsAccessibilityDrop(item, host)) {
            info.addAction(mActions.get(target.getAccessibilityAction()));
        }
    }
    // Do not add move actions for keyboard request as this uses virtual nodes.
    if (!fromKeyboard && itemSupportsAccessibleDrag(item)) {
        info.addAction(mActions.get(MOVE));
        if (item.container >= 0) {
            info.addAction(mActions.get(MOVE_TO_WORKSPACE));
        } else if (item instanceof LauncherAppWidgetInfo) {
            if (!getSupportedResizeActions(host, (LauncherAppWidgetInfo) item).isEmpty()) {
                info.addAction(mActions.get(RESIZE));
            }
        }
    }
    if (!fromKeyboard && !itemSupportsLongClick(host, item)) {
        info.setLongClickable(false);
        info.removeAction(AccessibilityAction.ACTION_LONG_CLICK);
    }
    if ((item instanceof AppInfo) || (item instanceof PendingAddItemInfo)) {
        info.addAction(mActions.get(ADD_TO_WORKSPACE));
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) PendingAddItemInfo(com.android.launcher3.PendingAddItemInfo) ButtonDropTarget(com.android.launcher3.ButtonDropTarget) PendingAddItemInfo(com.android.launcher3.PendingAddItemInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 34 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target 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 35 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Trebuchet by LineageOS.

the class TaskViewUtils method findTaskViewToLaunch.

/**
 * Try to find a TaskView that corresponds with the component of the launched view.
 *
 * If this method returns a non-null TaskView, it will be used in composeRecentsLaunchAnimation.
 * Otherwise, we will assume we are using a normal app transition, but it's possible that the
 * opening remote target (which we don't get until onAnimationStart) will resolve to a TaskView.
 */
public static TaskView findTaskViewToLaunch(BaseDraggingActivity activity, View v, RemoteAnimationTargetCompat[] targets) {
    RecentsView recentsView = activity.getOverviewPanel();
    if (v instanceof TaskView) {
        TaskView taskView = (TaskView) v;
        return recentsView.isTaskViewVisible(taskView) ? taskView : null;
    }
    // the task id of the opening task and see if we can find a match.
    if (v.getTag() instanceof ItemInfo) {
        ItemInfo itemInfo = (ItemInfo) v.getTag();
        ComponentName componentName = itemInfo.getTargetComponent();
        int userId = itemInfo.user.getIdentifier();
        if (componentName != null) {
            for (int i = 0; i < recentsView.getTaskViewCount(); i++) {
                TaskView taskView = recentsView.getTaskViewAt(i);
                if (recentsView.isTaskViewVisible(taskView)) {
                    Task.TaskKey key = taskView.getTask().key;
                    if (componentName.equals(key.getComponent()) && userId == key.userId) {
                        return taskView;
                    }
                }
            }
        }
    }
    if (targets == null) {
        return null;
    }
    // Resolve the opening task id
    int openingTaskId = -1;
    for (RemoteAnimationTargetCompat target : targets) {
        if (target.mode == MODE_OPENING) {
            openingTaskId = target.taskId;
            break;
        }
    }
    // If there is no opening task id, fall back to the normal app icon launch animation
    if (openingTaskId == -1) {
        return null;
    }
    // If the opening task id is not currently visible in overview, then fall back to normal app
    // icon launch animation
    TaskView taskView = recentsView.getTaskView(openingTaskId);
    if (taskView == null || !recentsView.isTaskViewVisible(taskView)) {
        return null;
    }
    return taskView;
}
Also used : TaskView(com.android.quickstep.views.TaskView) Task(com.android.systemui.shared.recents.model.Task) ItemInfo(com.android.launcher3.model.data.ItemInfo) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) RecentsView(com.android.quickstep.views.RecentsView) ComponentName(android.content.ComponentName)

Aggregations

View (android.view.View)85 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)59 Point (android.graphics.Point)42 Rect (android.graphics.Rect)41 AppWidgetHostView (android.appwidget.AppWidgetHostView)40 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)38 ItemInfo (com.android.launcher3.model.data.ItemInfo)37 Animator (android.animation.Animator)35 ValueAnimator (android.animation.ValueAnimator)35 Target (com.android.launcher3.userevent.nano.LauncherLogProto.Target)35 BubbleTextView (com.android.launcher3.BubbleTextView)34 DropTarget (com.android.launcher3.DropTarget)32 DragView (com.android.launcher3.dragndrop.DragView)30 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)30 AnimatorSet (android.animation.AnimatorSet)29 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)29 ComponentName (android.content.ComponentName)28 ObjectAnimator (android.animation.ObjectAnimator)27 DraggableView (com.android.launcher3.dragndrop.DraggableView)26 AppInfo (com.android.launcher3.model.data.AppInfo)26