Search in sources :

Example 76 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Trebuchet by LineageOS.

the class TaskViewTouchController method onDragStart.

@Override
public void onDragStart(boolean start, float startDisplacement) {
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    if (mCurrentAnimation == null) {
        reInitAnimationController(orientationHandler.isGoingUp(startDisplacement, mIsRtl));
        mDisplacementShift = 0;
    } else {
        mDisplacementShift = mCurrentAnimation.getProgressFraction() / mProgressMultiplier;
        mCurrentAnimation.pause();
    }
    mFlingBlockCheck.unblockFling();
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 77 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Trebuchet by LineageOS.

the class TaskViewTouchController method onDrag.

@Override
public boolean onDrag(float displacement) {
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    float totalDisplacement = displacement + mDisplacementShift;
    boolean isGoingUp = totalDisplacement == 0 ? mCurrentAnimationIsGoingUp : orientationHandler.isGoingUp(totalDisplacement, mIsRtl);
    if (isGoingUp != mCurrentAnimationIsGoingUp) {
        reInitAnimationController(isGoingUp);
        mFlingBlockCheck.blockFling();
    } else {
        mFlingBlockCheck.onEvent();
    }
    mCurrentAnimation.setPlayFraction(Utilities.boundToRange(totalDisplacement * mProgressMultiplier, 0, 1));
    if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
        if (mRecentsView.getCurrentPage() != 0 || isGoingUp) {
            mRecentsView.redrawLiveTile(true);
        }
    }
    return true;
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 78 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Trebuchet by LineageOS.

the class TaskViewTouchController method reInitAnimationController.

private void reInitAnimationController(boolean goingUp) {
    if (mCurrentAnimation != null && mCurrentAnimationIsGoingUp == goingUp) {
        // No need to init
        return;
    }
    int scrollDirections = mDetector.getScrollDirections();
    if (goingUp && ((scrollDirections & DIRECTION_POSITIVE) == 0) || !goingUp && ((scrollDirections & DIRECTION_NEGATIVE) == 0)) {
        // Trying to re-init in an unsupported direction.
        return;
    }
    if (mCurrentAnimation != null) {
        mCurrentAnimation.setPlayFraction(0);
    }
    if (mPendingAnimation != null) {
        mPendingAnimation.finish(false, Touch.SWIPE);
        mPendingAnimation = null;
    }
    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;
    if (goingUp) {
        currentInterpolator = Interpolators.LINEAR;
        mPendingAnimation = mRecentsView.createTaskDismissAnimation(mTaskBeingDragged, true, /* animateTaskView */
        true, /* removeTask */
        maxDuration);
        mEndDisplacement = -secondaryTaskDimension;
    } else {
        currentInterpolator = Interpolators.ZOOM_IN;
        mPendingAnimation = 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;
    if (mCurrentAnimation != null) {
        mCurrentAnimation.setOnCancelRunnable(null);
    }
    mCurrentAnimation = mPendingAnimation.createPlaybackController().setOnCancelRunnable(this::clearState);
    // 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) 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 79 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by AOSPA.

the class RecentsViewStateController method handleSplitSelectionState.

/**
 * Create or dismiss split screen select animations.
 * @param builder if null then this will run the split select animations right away, otherwise
 *                will add animations to builder.
 */
private void handleSplitSelectionState(@NonNull LauncherState toState, @Nullable PendingAnimation builder) {
    LauncherState currentState = mLauncher.getStateManager().getState();
    boolean animate = builder != null;
    PagedOrientationHandler orientationHandler = ((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler();
    Pair<FloatProperty, FloatProperty> taskViewsFloat = orientationHandler.getSplitSelectTaskOffset(TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION, mLauncher.getDeviceProfile());
    if (isSplitSelectionState(currentState, toState)) {
        // Animation to "dismiss" selected taskView
        PendingAnimation splitSelectInitAnimation = mRecentsView.createSplitSelectInitAnimation();
        // Add properties to shift remaining taskViews to get out of placeholder view
        splitSelectInitAnimation.setFloat(mRecentsView, taskViewsFloat.first, toState.getSplitSelectTranslation(mLauncher), LINEAR);
        splitSelectInitAnimation.setFloat(mRecentsView, taskViewsFloat.second, 0, LINEAR);
        if (!animate && isSplitSelectionState(currentState, toState)) {
            splitSelectInitAnimation.buildAnim().start();
        } else if (animate && isSplitSelectionState(currentState, toState)) {
            builder.add(splitSelectInitAnimation.buildAnim());
        }
    }
    if (isSplitSelectionState(currentState, toState)) {
        mRecentsView.applySplitPrimaryScrollOffset();
    } else {
        mRecentsView.resetSplitPrimaryScrollOffset();
    }
}
Also used : LauncherState(com.android.launcher3.LauncherState) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) LauncherRecentsView(com.android.quickstep.views.LauncherRecentsView) RecentsView(com.android.quickstep.views.RecentsView) FloatProperty(android.util.FloatProperty)

Example 80 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskMenuView method setPosition.

private void setPosition(float x, float y, int overscrollShift) {
    PagedOrientationHandler pagedOrientationHandler = mTaskView.getPagedOrientationHandler();
    // Inset due to margin
    PointF additionalInset = pagedOrientationHandler.getAdditionalInsetForTaskMenu(mTaskInsetMargin);
    DeviceProfile deviceProfile = mActivity.getDeviceProfile();
    int taskTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
    float adjustedY = y + taskTopMargin - additionalInset.y;
    float adjustedX = x - additionalInset.x;
    // Changing pivot to make computations easier
    // NOTE: Changing the pivots means the rotated view gets rotated about the new pivots set,
    // which would render the X and Y position set here incorrect
    setPivotX(0);
    if (deviceProfile.overviewShowAsGrid) {
        // In tablet, set pivotY to original position without mThumbnailTopMargin adjustment.
        setPivotY(-taskTopMargin);
    } else {
        setPivotY(0);
    }
    setRotation(pagedOrientationHandler.getDegreesRotated());
    setX(pagedOrientationHandler.getTaskMenuX(adjustedX, mTaskContainer.getThumbnailView(), overscrollShift, deviceProfile));
    setY(pagedOrientationHandler.getTaskMenuY(adjustedY, mTaskContainer.getThumbnailView(), overscrollShift));
    // TODO(b/193432925) temporary menu placement for split screen task menus
    TaskIdAttributeContainer[] taskIdAttributeContainers = mTaskView.getTaskIdAttributeContainers();
    if (taskIdAttributeContainers[0].getStagePosition() != STAGE_POSITION_UNDEFINED) {
        if (mTaskContainer.getStagePosition() != STAGE_POSITION_BOTTOM_OR_RIGHT) {
            return;
        }
        Rect r = new Rect();
        mTaskContainer.getThumbnailView().getBoundsOnScreen(r);
        if (deviceProfile.isLandscape) {
            setX(r.left);
        } else {
            setY(r.top);
        }
    }
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) TaskIdAttributeContainer(com.android.quickstep.views.TaskView.TaskIdAttributeContainer) PointF(android.graphics.PointF)

Aggregations

PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)101 RecentsView (com.android.quickstep.views.RecentsView)25 DeviceProfile (com.android.launcher3.DeviceProfile)22 Rect (android.graphics.Rect)16 PendingAnimation (com.android.launcher3.anim.PendingAnimation)15 FloatProperty (android.util.FloatProperty)14 BaseDragLayer (com.android.launcher3.views.BaseDragLayer)12 PointF (android.graphics.PointF)11 RectF (android.graphics.RectF)11 Point (android.graphics.Point)9 TimeInterpolator (android.animation.TimeInterpolator)6 Matrix (android.graphics.Matrix)6 View (android.view.View)6 Interpolator (android.view.animation.Interpolator)6 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)6 TaskView (com.android.quickstep.views.TaskView)6 Context (android.content.Context)5 ShapeDrawable (android.graphics.drawable.ShapeDrawable)5 RectShape (android.graphics.drawable.shapes.RectShape)5 MotionEvent (android.view.MotionEvent)5