Search in sources :

Example 1 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler 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 2 with PagedOrientationHandler

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

the class TaskViewTouchController method onDragEnd.

@Override
public void onDragEnd(float velocity) {
    if (mOverrideVelocity != null) {
        velocity = mOverrideVelocity;
        mOverrideVelocity = null;
    }
    // Limit velocity, as very large scalar values make animations play too quickly
    float maxTaskDismissDragVelocity = mTaskBeingDragged.getResources().getDimension(R.dimen.max_task_dismiss_drag_velocity);
    velocity = Utilities.boundToRange(velocity, -maxTaskDismissDragVelocity, maxTaskDismissDragVelocity);
    boolean fling = mDetector.isFling(velocity);
    final boolean goingToEnd;
    boolean blockedFling = fling && mFlingBlockCheck.isBlocked();
    if (blockedFling) {
        fling = false;
    }
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    float progress = mCurrentAnimation.getProgressFraction();
    float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress();
    if (fling) {
        boolean goingUp = orientationHandler.isGoingUp(velocity, mIsRtl);
        goingToEnd = goingUp == mCurrentAnimationIsGoingUp;
    } else {
        goingToEnd = interpolatedProgress > SUCCESS_TRANSITION_PROGRESS;
    }
    long animationDuration = BaseSwipeDetector.calculateDuration(velocity, goingToEnd ? (1 - progress) : progress);
    if (blockedFling && !goingToEnd) {
        animationDuration *= LauncherAnimUtils.blockedFlingDurationFactor(velocity);
    }
    // Due to very high or low velocity dismissals, animation durations can be inconsistently
    // long or short. Bound the duration for animation of task translations for a more
    // standardized feel.
    animationDuration = Utilities.boundToRange(animationDuration, MIN_TASK_DISMISS_ANIMATION_DURATION, MAX_TASK_DISMISS_ANIMATION_DURATION);
    mCurrentAnimation.setEndAction(this::clearState);
    mCurrentAnimation.startWithVelocity(mActivity, goingToEnd, velocity * orientationHandler.getSecondaryTranslationDirectionFactor(), mEndDisplacement, animationDuration);
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 3 with PagedOrientationHandler

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

the class RecentsView method updateOrientationHandler.

private void updateOrientationHandler(boolean forceRecreateDragLayerControllers) {
    // Handle orientation changes.
    PagedOrientationHandler oldOrientationHandler = mOrientationHandler;
    mOrientationHandler = mOrientationState.getOrientationHandler();
    mIsRtl = mOrientationHandler.getRecentsRtlSetting(getResources());
    setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
    if (forceRecreateDragLayerControllers || !mOrientationHandler.equals(oldOrientationHandler)) {
        // Changed orientations, update controllers so they intercept accordingly.
        mActivity.getDragLayer().recreateControllers();
    }
    boolean isInLandscape = mOrientationState.getTouchRotation() != ROTATION_0 || mOrientationState.getRecentsActivityRotation() != ROTATION_0;
    mActionsView.updateHiddenFlags(HIDDEN_NON_ZERO_ROTATION, !mOrientationState.canRecentsActivityRotate() && isInLandscape);
    // Update TaskView's DeviceProfile dependent layout.
    updateChildTaskOrientations();
    // Recalculate DeviceProfile dependent layout.
    updateSizeAndPadding();
    requestLayout();
    // Reapply the current page to update page scrolls.
    setCurrentPage(mCurrentPage);
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 4 with PagedOrientationHandler

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

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);
    int taskTopMargin = mActivity.getDeviceProfile().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 (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
        // In tablet, set pivotY to original position without mThumbnailTopMargin adjustment.
        setPivotY(-taskTopMargin);
    } else {
        setPivotY(0);
    }
    setRotation(pagedOrientationHandler.getDegreesRotated());
    setX(pagedOrientationHandler.getTaskMenuX(adjustedX, mTaskView.getThumbnail(), overscrollShift));
    setY(pagedOrientationHandler.getTaskMenuY(adjustedY, mTaskView.getThumbnail(), overscrollShift));
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) PointF(android.graphics.PointF)

Example 5 with PagedOrientationHandler

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

the class TaskMenuView method orientAroundTaskView.

private void orientAroundTaskView(TaskView taskView) {
    PagedOrientationHandler orientationHandler = taskView.getPagedOrientationHandler();
    measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    orientationHandler.setTaskMenuAroundTaskView(this, mTaskInsetMargin);
    // Get Position
    mActivity.getDragLayer().getDescendantRectRelativeToSelf(taskView, sTempRect);
    Rect insets = mActivity.getDragLayer().getInsets();
    BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
    int padding = getResources().getDimensionPixelSize(R.dimen.task_menu_vertical_padding);
    params.width = orientationHandler.getTaskMenuWidth(taskView.getThumbnail()) - (2 * padding);
    // Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start
    params.gravity = Gravity.LEFT;
    setLayoutParams(params);
    setScaleX(taskView.getScaleX());
    setScaleY(taskView.getScaleY());
    // Set divider spacing
    ShapeDrawable divider = new ShapeDrawable(new RectShape());
    divider.getPaint().setColor(getResources().getColor(android.R.color.transparent));
    int dividerSpacing = (int) getResources().getDimension(R.dimen.task_menu_spacing);
    mOptionLayout.setShowDividers(SHOW_DIVIDER_MIDDLE);
    orientationHandler.setTaskOptionsMenuLayoutOrientation(mActivity.getDeviceProfile(), mOptionLayout, dividerSpacing, divider);
    setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, 0);
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) Rect(android.graphics.Rect) RectShape(android.graphics.drawable.shapes.RectShape) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) ShapeDrawable(android.graphics.drawable.ShapeDrawable)

Aggregations

PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)12 RecentsView (com.android.quickstep.views.RecentsView)4 PointF (android.graphics.PointF)2 Rect (android.graphics.Rect)2 FloatProperty (android.util.FloatProperty)2 DeviceProfile (com.android.launcher3.DeviceProfile)2 PendingAnimation (com.android.launcher3.anim.PendingAnimation)2 BaseDragLayer (com.android.launcher3.views.BaseDragLayer)2 TimeInterpolator (android.animation.TimeInterpolator)1 Context (android.content.Context)1 Matrix (android.graphics.Matrix)1 RectF (android.graphics.RectF)1 ShapeDrawable (android.graphics.drawable.ShapeDrawable)1 RectShape (android.graphics.drawable.shapes.RectShape)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 Interpolator (android.view.animation.Interpolator)1 Nullable (androidx.annotation.Nullable)1 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)1 Launcher (com.android.launcher3.Launcher)1