Search in sources :

Example 16 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by crdroidandroid.

the class DividerView method onBusEvent.

public final void onBusEvent(UndockingTaskEvent undockingTaskEvent) {
    int dockSide = mWindowManagerProxy.getDockSide();
    if (dockSide != WindowManager.DOCKED_INVALID && !mDockedStackMinimized) {
        startDragging(false, /* animate */
        false);
        SnapTarget target = dockSideTopLeft(dockSide) ? mSnapAlgorithm.getDismissEndTarget() : mSnapAlgorithm.getDismissStartTarget();
        // Don't start immediately - give a little bit time to settle the drag resize change.
        mExitAnimationRunning = true;
        mExitStartPosition = getCurrentPosition();
        stopDragging(mExitStartPosition, target, 336, /* duration */
        100, /* startDelay */
        0, /* endDelay */
        Interpolators.FAST_OUT_SLOW_IN);
    }
}
Also used : SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 17 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by AOSPA.

the class DividerView method resizeStack.

public void resizeStack(int position, int taskPosition, SnapTarget taskSnapTarget) {
    calculateBoundsForPosition(position, mDockSide, mDockedRect);
    if (mDockedRect.equals(mLastResizeRect) && !mEntranceAnimationRunning) {
        return;
    }
    // Make sure shadows are updated
    if (mBackground.getZ() > 0f) {
        mBackground.invalidate();
    }
    mLastResizeRect.set(mDockedRect);
    if (mEntranceAnimationRunning && taskPosition != TASK_POSITION_SAME) {
        if (mCurrentAnimator != null) {
            calculateBoundsForPosition(taskPosition, mDockSide, mDockedTaskRect);
        } else {
            calculateBoundsForPosition(isHorizontalDivision() ? mDisplayHeight : mDisplayWidth, mDockSide, mDockedTaskRect);
        }
        calculateBoundsForPosition(taskPosition, DockedDividerUtils.invertDockSide(mDockSide), mOtherTaskRect);
        mWindowManagerProxy.resizeDockedStack(mDockedRect, mDockedTaskRect, null, mOtherTaskRect, null);
    } else if (mExitAnimationRunning && taskPosition != TASK_POSITION_SAME) {
        calculateBoundsForPosition(taskPosition, mDockSide, mDockedTaskRect);
        calculateBoundsForPosition(mExitStartPosition, DockedDividerUtils.invertDockSide(mDockSide), mOtherTaskRect);
        mOtherInsetRect.set(mOtherTaskRect);
        applyExitAnimationParallax(mOtherTaskRect, position);
        mWindowManagerProxy.resizeDockedStack(mDockedRect, mDockedTaskRect, null, mOtherTaskRect, mOtherInsetRect);
    } else if (taskPosition != TASK_POSITION_SAME) {
        calculateBoundsForPosition(position, DockedDividerUtils.invertDockSide(mDockSide), mOtherRect);
        int dockSideInverted = DockedDividerUtils.invertDockSide(mDockSide);
        int taskPositionDocked = restrictDismissingTaskPosition(taskPosition, mDockSide, taskSnapTarget);
        int taskPositionOther = restrictDismissingTaskPosition(taskPosition, dockSideInverted, taskSnapTarget);
        calculateBoundsForPosition(taskPositionDocked, mDockSide, mDockedTaskRect);
        calculateBoundsForPosition(taskPositionOther, dockSideInverted, mOtherTaskRect);
        mDisplayRect.set(0, 0, mDisplayWidth, mDisplayHeight);
        alignTopLeft(mDockedRect, mDockedTaskRect);
        alignTopLeft(mOtherRect, mOtherTaskRect);
        mDockedInsetRect.set(mDockedTaskRect);
        mOtherInsetRect.set(mOtherTaskRect);
        if (dockSideTopLeft(mDockSide)) {
            alignTopLeft(mDisplayRect, mDockedInsetRect);
            alignBottomRight(mDisplayRect, mOtherInsetRect);
        } else {
            alignBottomRight(mDisplayRect, mDockedInsetRect);
            alignTopLeft(mDisplayRect, mOtherInsetRect);
        }
        applyDismissingParallax(mDockedTaskRect, mDockSide, taskSnapTarget, position, taskPositionDocked);
        applyDismissingParallax(mOtherTaskRect, dockSideInverted, taskSnapTarget, position, taskPositionOther);
        mWindowManagerProxy.resizeDockedStack(mDockedRect, mDockedTaskRect, mDockedInsetRect, mOtherTaskRect, mOtherInsetRect);
    } else {
        mWindowManagerProxy.resizeDockedStack(mDockedRect, null, null, null, null);
    }
    SnapTarget closestDismissTarget = mSnapAlgorithm.getClosestDismissTarget(position);
    float dimFraction = getDimFraction(position, closestDismissTarget);
    mWindowManagerProxy.setResizeDimLayer(dimFraction != 0f, getStackIdForDismissTarget(closestDismissTarget), dimFraction);
}
Also used : SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 18 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by AOSPA.

the class DividerView method applyDismissingParallax.

/**
     * Applies a parallax to the task when dismissing.
     */
private void applyDismissingParallax(Rect taskRect, int dockSide, SnapTarget snapTarget, int position, int taskPosition) {
    float fraction = Math.min(1, Math.max(0, mSnapAlgorithm.calculateDismissingFraction(position)));
    SnapTarget dismissTarget = null;
    SnapTarget splitTarget = null;
    int start = 0;
    if (position <= mSnapAlgorithm.getLastSplitTarget().position && dockSideTopLeft(dockSide)) {
        dismissTarget = mSnapAlgorithm.getDismissStartTarget();
        splitTarget = mSnapAlgorithm.getFirstSplitTarget();
        start = taskPosition;
    } else if (position >= mSnapAlgorithm.getLastSplitTarget().position && dockSideBottomRight(dockSide)) {
        dismissTarget = mSnapAlgorithm.getDismissEndTarget();
        splitTarget = mSnapAlgorithm.getLastSplitTarget();
        start = splitTarget.position;
    }
    if (dismissTarget != null && fraction > 0f && isDismissing(splitTarget, position, dockSide)) {
        fraction = calculateParallaxDismissingFraction(fraction, dockSide);
        int offsetPosition = (int) (start + fraction * (dismissTarget.position - splitTarget.position));
        int width = taskRect.width();
        int height = taskRect.height();
        switch(dockSide) {
            case WindowManager.DOCKED_LEFT:
                taskRect.left = offsetPosition - width;
                taskRect.right = offsetPosition;
                break;
            case WindowManager.DOCKED_RIGHT:
                taskRect.left = offsetPosition + mDividerSize;
                taskRect.right = offsetPosition + width + mDividerSize;
                break;
            case WindowManager.DOCKED_TOP:
                taskRect.top = offsetPosition - height;
                taskRect.bottom = offsetPosition;
                break;
            case WindowManager.DOCKED_BOTTOM:
                taskRect.top = offsetPosition + mDividerSize;
                taskRect.bottom = offsetPosition + height + mDividerSize;
                break;
        }
    }
}
Also used : SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 19 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by AOSPA.

the class DividerView method onBusEvent.

public final void onBusEvent(UndockingTaskEvent undockingTaskEvent) {
    int dockSide = mWindowManagerProxy.getDockSide();
    if (dockSide != WindowManager.DOCKED_INVALID && !mDockedStackMinimized) {
        startDragging(false, /* animate */
        false);
        SnapTarget target = dockSideTopLeft(dockSide) ? mSnapAlgorithm.getDismissEndTarget() : mSnapAlgorithm.getDismissStartTarget();
        // Don't start immediately - give a little bit time to settle the drag resize change.
        mExitAnimationRunning = true;
        mExitStartPosition = getCurrentPosition();
        stopDragging(mExitStartPosition, target, 336, /* duration */
        100, /* startDelay */
        0, /* endDelay */
        Interpolators.FAST_OUT_SLOW_IN);
    }
}
Also used : SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 20 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by AOSPA.

the class NavigationBarGestureHelper method handleDragActionMoveEvent.

private boolean handleDragActionMoveEvent(MotionEvent event) {
    mVelocityTracker.addMovement(event);
    int x = (int) event.getX();
    int y = (int) event.getY();
    int xDiff = Math.abs(x - mTouchDownX);
    int yDiff = Math.abs(y - mTouchDownY);
    if (mDivider == null || mRecentsComponent == null) {
        return false;
    }
    if (!mDockWindowTouchSlopExceeded) {
        boolean touchSlopExceeded = !mIsVertical ? yDiff > mScrollTouchSlop && yDiff > xDiff : xDiff > mScrollTouchSlop && xDiff > yDiff;
        if (mDownOnRecents && touchSlopExceeded && mDivider.getView().getWindowManagerProxy().getDockSide() == DOCKED_INVALID) {
            Rect initialBounds = null;
            int dragMode = calculateDragMode();
            int createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
            if (dragMode == DRAG_MODE_DIVIDER) {
                initialBounds = new Rect();
                mDivider.getView().calculateBoundsForPosition(mIsVertical ? (int) event.getRawX() : (int) event.getRawY(), mDivider.getView().isHorizontalDivision() ? DOCKED_TOP : DOCKED_LEFT, initialBounds);
            } else if (dragMode == DRAG_MODE_RECENTS && mTouchDownX < mContext.getResources().getDisplayMetrics().widthPixels / 2) {
                createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
            }
            boolean docked = mRecentsComponent.dockTopTask(dragMode, createMode, initialBounds, MetricsEvent.ACTION_WINDOW_DOCK_SWIPE);
            if (docked) {
                mDragMode = dragMode;
                if (mDragMode == DRAG_MODE_DIVIDER) {
                    mDivider.getView().startDragging(false, /* animate */
                    true);
                }
                mDockWindowTouchSlopExceeded = true;
                return true;
            }
        }
    } else {
        if (mDragMode == DRAG_MODE_DIVIDER) {
            int position = !mIsVertical ? (int) event.getRawY() : (int) event.getRawX();
            SnapTarget snapTarget = mDivider.getView().getSnapAlgorithm().calculateSnapTarget(position, 0f, /* velocity */
            false);
            mDivider.getView().resizeStack(position, snapTarget.position, snapTarget);
        } else if (mDragMode == DRAG_MODE_RECENTS) {
            mRecentsComponent.onDraggingInRecents(event.getRawY());
        }
    }
    return false;
}
Also used : Rect(android.graphics.Rect) SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Aggregations

SnapTarget (com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)34 ValueAnimator (android.animation.ValueAnimator)5 Rect (android.graphics.Rect)5 DisplayInfo (android.view.DisplayInfo)4 DividerSnapAlgorithm (com.android.internal.policy.DividerSnapAlgorithm)4