Search in sources :

Example 11 with SnapTarget

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

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)

Example 12 with SnapTarget

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

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

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

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)

Example 14 with SnapTarget

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

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)

Example 15 with SnapTarget

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

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)

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