Search in sources :

Example 6 with Target

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

the class DragController method findDropTarget.

private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
    mDragObject.x = x;
    mDragObject.y = y;
    final Rect r = mRectTemp;
    final ArrayList<DropTarget> dropTargets = mDropTargets;
    final int count = dropTargets.size();
    for (int i = count - 1; i >= 0; i--) {
        DropTarget target = dropTargets.get(i);
        if (!target.isDropEnabled())
            continue;
        target.getHitRectRelativeToDragLayer(r);
        if (r.contains(x, y)) {
            dropCoordinates[0] = x;
            dropCoordinates[1] = y;
            mActivity.getDragLayer().mapCoordInSelfToDescendant((View) target, dropCoordinates);
            return target;
        }
    }
    // Pass all unhandled drag to workspace. Workspace finds the correct
    // cell layout to drop to in the existing drag/drop logic.
    dropCoordinates[0] = x;
    dropCoordinates[1] = y;
    return getDefaultDropTarget(dropCoordinates);
}
Also used : Rect(android.graphics.Rect) DropTarget(com.android.launcher3.DropTarget) Point(android.graphics.Point)

Example 7 with Target

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

the class Workspace method addToExistingFolderIfNecessary.

boolean addToExistingFolderIfNecessary(View newView, CellLayout target, int[] targetCell, float distance, DragObject d, boolean external) {
    if (distance > mMaxDistanceForFolderCreation)
        return false;
    View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
    if (!mAddToExistingFolderOnDrop)
        return false;
    mAddToExistingFolderOnDrop = false;
    if (dropOverView instanceof FolderIcon) {
        FolderIcon fi = (FolderIcon) dropOverView;
        if (fi.acceptDrop(d.dragInfo)) {
            mStatsLogManager.logger().withItemInfo(fi.mInfo).withInstanceId(d.logInstanceId).log(LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED_ON_FOLDER_ICON);
            fi.onDrop(d, false);
            // if the drag started here, we need to remove it from the workspace
            if (!external) {
                getParentCellLayoutForView(mDragInfo.cell).removeView(mDragInfo.cell);
            }
            return true;
        }
    }
    return false;
}
Also used : 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)

Example 8 with Target

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

the class Workspace method onDropCompleted.

/**
 * Called at the end of a drag which originated on the workspace.
 */
public void onDropCompleted(final View target, final DragObject d, final boolean success) {
    if (success) {
        if (target != this && mDragInfo != null) {
            removeWorkspaceItem(mDragInfo.cell);
        }
    } else if (mDragInfo != null) {
        // When drag is cancelled, reattach content view back to its original parent.
        if (mDragInfo.cell instanceof LauncherAppWidgetHostView && d.dragView != null) {
            d.dragView.detachContentView(/* reattachToPreviousParent= */
            true);
        }
        final CellLayout cellLayout = mLauncher.getCellLayout(mDragInfo.container, mDragInfo.screenId);
        if (cellLayout != null) {
            cellLayout.onDropChild(mDragInfo.cell);
        } else if (FeatureFlags.IS_STUDIO_BUILD) {
            throw new RuntimeException("Invalid state: cellLayout == null in " + "Workspace#onDropCompleted. Please file a bug. ");
        }
    }
    View cell = getHomescreenIconByItemId(d.originalDragInfo.id);
    if (d.cancelled && cell != null) {
        cell.setVisibility(VISIBLE);
    }
    mDragInfo = null;
}
Also used : LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) 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)

Example 9 with Target

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

the class TaskViewTouchController method reInitAnimationController.

private void reInitAnimationController(boolean goingUp) {
    if (mCurrentAnimation != null && mCurrentAnimationIsGoingUp == goingUp) {
        // No need to init
        return;
    }
    if ((goingUp && !mAllowGoingUp) || (!goingUp && !mAllowGoingDown)) {
        // Trying to re-init in an unsupported direction.
        return;
    }
    if (mCurrentAnimation != null) {
        mCurrentAnimation.setPlayFraction(0);
        mCurrentAnimation.getTarget().removeListener(this);
        mCurrentAnimation.dispatchOnCancel();
    }
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    mCurrentAnimationIsGoingUp = goingUp;
    BaseDragLayer dl = mActivity.getDragLayer();
    final int secondaryLayerDimension = orientationHandler.getSecondaryDimension(dl);
    long maxDuration = 2 * secondaryLayerDimension;
    int verticalFactor = orientationHandler.getTaskDragDisplacementFactor(mIsRtl);
    int secondaryTaskDimension = orientationHandler.getSecondaryDimension(mTaskBeingDragged);
    // The interpolator controlling the most prominent visual movement. We use this to determine
    // whether we passed SUCCESS_TRANSITION_PROGRESS.
    final Interpolator currentInterpolator;
    PendingAnimation pa;
    if (goingUp) {
        currentInterpolator = Interpolators.LINEAR;
        pa = mRecentsView.createTaskDismissAnimation(mTaskBeingDragged, true, /* animateTaskView */
        true, /* removeTask */
        maxDuration);
        mEndDisplacement = -secondaryTaskDimension;
    } else {
        currentInterpolator = Interpolators.ZOOM_IN;
        pa = mRecentsView.createTaskLaunchAnimation(mTaskBeingDragged, maxDuration, currentInterpolator);
        // Since the thumbnail is what is filling the screen, based the end displacement on it.
        View thumbnailView = mTaskBeingDragged.getThumbnail();
        mTempCords[1] = orientationHandler.getSecondaryDimension(thumbnailView);
        dl.getDescendantCoordRelativeToSelf(thumbnailView, mTempCords);
        mEndDisplacement = secondaryLayerDimension - mTempCords[1];
    }
    mEndDisplacement *= verticalFactor;
    mCurrentAnimation = pa.createPlaybackController();
    // Setting this interpolator doesn't affect the visual motion, but is used to determine
    // whether we successfully reached the target state in onDragEnd().
    mCurrentAnimation.getTarget().setInterpolator(currentInterpolator);
    onUserControlledAnimationCreated(mCurrentAnimation);
    mCurrentAnimation.getTarget().addListener(this);
    mCurrentAnimation.dispatchOnStart();
    mProgressMultiplier = 1 / mEndDisplacement;
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) Interpolator(android.view.animation.Interpolator) TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 10 with Target

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

the class AbsSwipeUpHandler method handleNormalGestureEnd.

@UiThread
private void handleNormalGestureEnd(float endVelocity, boolean isFling, PointF velocity, boolean isCancel) {
    long duration = MAX_SWIPE_DURATION;
    float currentShift = mCurrentShift.value;
    final GestureEndTarget endTarget = calculateEndTarget(velocity, endVelocity, isFling, isCancel);
    // Set the state, but don't notify until the animation completes
    mGestureState.setEndTarget(endTarget, false);
    float endShift = endTarget.isLauncher ? 1 : 0;
    final float startShift;
    if (!isFling) {
        long expectedDuration = Math.abs(Math.round((endShift - currentShift) * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
        duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
        startShift = currentShift;
    } else {
        startShift = Utilities.boundToRange(currentShift - velocity.y * getSingleFrameMs(mContext) / mTransitionDragLength, 0, mDragLengthFactor);
        if (mTransitionDragLength > 0) {
            float distanceToTravel = (endShift - currentShift) * mTransitionDragLength;
            // we want the page's snap velocity to approximately match the velocity at
            // which the user flings, so we scale the duration by a value near to the
            // derivative of the scroll interpolator at zero, ie. 2.
            long baseDuration = Math.round(Math.abs(distanceToTravel / velocity.y));
            duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
        }
    }
    Interpolator interpolator;
    S state = mActivityInterface.stateFromGestureEndTarget(endTarget);
    if (state.displayOverviewTasksAsGrid(mDp)) {
        interpolator = ACCEL_DEACCEL;
    } else if (endTarget == RECENTS) {
        interpolator = OVERSHOOT_1_2;
    } else {
        interpolator = DEACCEL;
    }
    if (endTarget.isLauncher) {
        mInputConsumerProxy.enable();
    }
    if (endTarget == HOME) {
        duration = HOME_DURATION;
        // Early detach the nav bar once the endTarget is determined as HOME
        if (mRecentsAnimationController != null) {
            mRecentsAnimationController.detachNavigationBarFromApp(true);
        }
    } else if (endTarget == RECENTS) {
        if (mRecentsView != null) {
            int nearestPage = mRecentsView.getDestinationPage();
            boolean isScrolling = false;
            // Update page scroll before snapping to page to make sure we snapped to the
            // position calculated with target gesture in mind.
            mRecentsView.updateScrollSynchronously();
            if (mRecentsView.getNextPage() != nearestPage) {
                // We shouldn't really scroll to the next page when swiping up to recents.
                // Only allow settling on the next page if it's nearest to the center.
                mRecentsView.snapToPage(nearestPage, Math.toIntExact(duration));
                isScrolling = true;
            }
            if (mRecentsView.getScroller().getDuration() > MAX_SWIPE_DURATION) {
                mRecentsView.snapToPage(mRecentsView.getNextPage(), (int) MAX_SWIPE_DURATION);
                isScrolling = true;
            }
            if (!mGestureState.isHandlingAtomicEvent() || isScrolling) {
                duration = Math.max(duration, mRecentsView.getScroller().getDuration());
            }
        }
    }
    // or resumeLastTask().
    if (mRecentsView != null) {
        mRecentsView.setOnPageTransitionEndCallback(() -> mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED));
    } else {
        mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
    }
    animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity);
}
Also used : DEBUG_STATES(com.android.quickstep.MultiStateCallback.DEBUG_STATES) RECENTS(com.android.quickstep.GestureState.GestureEndTarget.RECENTS) CLOSE_SYSTEM_WINDOWS_REASON_RECENTS(com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS) STATE_HANDLER_INVISIBILITY_FLAGS(com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS) Interpolator(android.view.animation.Interpolator) GestureEndTarget(com.android.quickstep.GestureState.GestureEndTarget) UiThread(androidx.annotation.UiThread)

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