Search in sources :

Example 31 with PagedOrientationHandler

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

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 32 with PagedOrientationHandler

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

the class RecentsView method getSplitSelectTranslation.

/**
 * Returns how much additional translation there should be for each of the child TaskViews.
 * Note that the translation can be its primary or secondary dimension.
 */
public float getSplitSelectTranslation() {
    int splitPosition = getSplitPlaceholder().getActiveSplitStagePosition();
    if (!shouldShiftThumbnailsForSplitSelect()) {
        return 0f;
    }
    PagedOrientationHandler orientationHandler = getPagedOrientationHandler();
    int direction = orientationHandler.getSplitTranslationDirectionFactor(splitPosition, mActivity.getDeviceProfile());
    return mActivity.getResources().getDimension(R.dimen.split_placeholder_size) * direction;
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 33 with PagedOrientationHandler

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

the class RecentsView method onRotateInSplitSelectionState.

protected void onRotateInSplitSelectionState() {
    mOrientationHandler.getInitialSplitPlaceholderBounds(mSplitPlaceholderSize, mActivity.getDeviceProfile(), mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect);
    mTempRectF.set(mTempRect);
    // TODO(194414938) set correct corner radius
    if (mFirstFloatingTaskView != null) {
        mFirstFloatingTaskView.updateOrientationHandler(mOrientationHandler);
        mFirstFloatingTaskView.update(mTempRectF, /*progress=*/
        1f, /*windowRadius=*/
        0f);
    }
    PagedOrientationHandler orientationHandler = getPagedOrientationHandler();
    Pair<FloatProperty, FloatProperty> taskViewsFloat = orientationHandler.getSplitSelectTaskOffset(TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION, mActivity.getDeviceProfile());
    taskViewsFloat.first.set(this, getSplitSelectTranslation());
    taskViewsFloat.second.set(this, 0f);
    applySplitPrimaryScrollOffset();
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) FloatProperty(android.util.FloatProperty)

Example 34 with PagedOrientationHandler

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

the class TaskView method setOrientationState.

public void setOrientationState(RecentsOrientedState orientationState) {
    PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
    boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
    LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams();
    DeviceProfile deviceProfile = mActivity.getDeviceProfile();
    snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
    boolean isGridTask = isGridTask();
    int taskIconHeight = deviceProfile.overviewTaskIconSizePx;
    int taskMargin = isGridTask ? deviceProfile.overviewTaskMarginGridPx : deviceProfile.overviewTaskMarginPx;
    int taskIconMargin = snapshotParams.topMargin - taskIconHeight - taskMargin;
    LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
    orientationHandler.setIconAndSnapshotParams(mIconView, taskIconMargin, taskIconHeight, snapshotParams, isRtl);
    mSnapshotView.setLayoutParams(snapshotParams);
    iconParams.width = iconParams.height = taskIconHeight;
    mIconView.setLayoutParams(iconParams);
    mIconView.setRotation(orientationHandler.getDegreesRotated());
    int iconDrawableSize = isGridTask ? deviceProfile.overviewTaskIconDrawableSizeGridPx : deviceProfile.overviewTaskIconDrawableSizePx;
    mIconView.setDrawableSize(iconDrawableSize, iconDrawableSize);
    snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
    mSnapshotView.setLayoutParams(snapshotParams);
    mSnapshotView.getTaskOverlay().updateOrientationState(orientationState);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 35 with PagedOrientationHandler

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

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();
    }
    if (isGoingUp) {
        if (mCurrentAnimation.getProgressFraction() < ANIMATION_PROGRESS_FRACTION_MIDPOINT) {
            // Halve the value when dismissing, as we are animating the drag across the full
            // length for only the first half of the progress
            mCurrentAnimation.setPlayFraction(Utilities.boundToRange(totalDisplacement * mProgressMultiplier / 2, 0, 1));
        } else {
            // Set mOverrideVelocity to control task dismiss velocity in onDragEnd
            int velocityDimenId = R.dimen.default_task_dismiss_drag_velocity;
            if (mRecentsView.showAsGrid()) {
                if (mTaskBeingDragged.isFocusedTask()) {
                    velocityDimenId = R.dimen.default_task_dismiss_drag_velocity_grid_focus_task;
                } else {
                    velocityDimenId = R.dimen.default_task_dismiss_drag_velocity_grid;
                }
            }
            mOverrideVelocity = -mTaskBeingDragged.getResources().getDimension(velocityDimenId);
            // Once halfway through task dismissal interpolation, switch from reversible
            // dragging-task animation to playing the remaining task translation animations
            final long now = SystemClock.uptimeMillis();
            MotionEvent upAction = MotionEvent.obtain(now, now, MotionEvent.ACTION_UP, 0.0f, 0.0f, 0);
            mDetector.onTouchEvent(upAction);
            upAction.recycle();
        }
    } else {
        mCurrentAnimation.setPlayFraction(Utilities.boundToRange(totalDisplacement * mProgressMultiplier, 0, 1));
    }
    return true;
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) MotionEvent(android.view.MotionEvent)

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