Search in sources :

Example 26 with SnapTarget

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

the class TaskStack method snapDockedStackAfterRotation.

/**
     * Snaps the bounds after rotation to the closest snap target for the docked stack.
     */
private void snapDockedStackAfterRotation(Rect outBounds) {
    // Calculate the current position.
    final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
    final int dividerSize = mService.getDefaultDisplayContentLocked().getDockedDividerController().getContentWidth();
    final int dockSide = getDockSide(outBounds);
    final int dividerPosition = DockedDividerUtils.calculatePositionForBounds(outBounds, dockSide, dividerSize);
    final int displayWidth = mDisplayContent.getDisplayInfo().logicalWidth;
    final int displayHeight = mDisplayContent.getDisplayInfo().logicalHeight;
    // Snap the position to a target.
    final int rotation = displayInfo.rotation;
    final int orientation = mService.mCurConfiguration.orientation;
    mService.mPolicy.getStableInsetsLw(rotation, displayWidth, displayHeight, outBounds);
    final DividerSnapAlgorithm algorithm = new DividerSnapAlgorithm(mService.mContext.getResources(), displayWidth, displayHeight, dividerSize, orientation == Configuration.ORIENTATION_PORTRAIT, outBounds);
    final SnapTarget target = algorithm.calculateNonDismissingSnapTarget(dividerPosition);
    // Recalculate the bounds based on the position of the target.
    DockedDividerUtils.calculateBoundsForPosition(target.position, dockSide, outBounds, displayInfo.logicalWidth, displayInfo.logicalHeight, dividerSize);
}
Also used : DisplayInfo(android.view.DisplayInfo) DividerSnapAlgorithm(com.android.internal.policy.DividerSnapAlgorithm) SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 27 with SnapTarget

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

the class DividerView method onTouch.

@Override
public boolean onTouch(View v, MotionEvent event) {
    convertToScreenCoordinates(event);
    mGestureDetector.onTouchEvent(event);
    final int action = event.getAction() & MotionEvent.ACTION_MASK;
    switch(action) {
        case MotionEvent.ACTION_DOWN:
            mVelocityTracker = VelocityTracker.obtain();
            mVelocityTracker.addMovement(event);
            mStartX = (int) event.getX();
            mStartY = (int) event.getY();
            boolean result = startDragging(true, /* animate */
            true);
            if (!result) {
                // Weren't able to start dragging successfully, so cancel it again.
                stopDragging();
            }
            mStartPosition = getCurrentPosition();
            mMoving = false;
            return result;
        case MotionEvent.ACTION_MOVE:
            mVelocityTracker.addMovement(event);
            int x = (int) event.getX();
            int y = (int) event.getY();
            boolean exceededTouchSlop = isHorizontalDivision() && Math.abs(y - mStartY) > mTouchSlop || (!isHorizontalDivision() && Math.abs(x - mStartX) > mTouchSlop);
            if (!mMoving && exceededTouchSlop) {
                mStartX = x;
                mStartY = y;
                mMoving = true;
            }
            if (mMoving && mDockSide != WindowManager.DOCKED_INVALID) {
                SnapTarget snapTarget = mSnapAlgorithm.calculateSnapTarget(mStartPosition, 0, /* velocity */
                false);
                resizeStackDelayed(calculatePosition(x, y), mStartPosition, snapTarget);
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mVelocityTracker.addMovement(event);
            x = (int) event.getRawX();
            y = (int) event.getRawY();
            mVelocityTracker.computeCurrentVelocity(1000);
            int position = calculatePosition(x, y);
            stopDragging(position, isHorizontalDivision() ? mVelocityTracker.getYVelocity() : mVelocityTracker.getXVelocity(), false, /* avoidDismissStart */
            true);
            mMoving = false;
            break;
    }
    return true;
}
Also used : SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 28 with SnapTarget

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

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 29 with SnapTarget

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

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 30 with SnapTarget

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

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)

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