use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project platform_frameworks_base by android.
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;
}
use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project platform_frameworks_base by android.
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);
}
}
use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project platform_frameworks_base by android.
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;
}
use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project platform_frameworks_base by android.
the class DividerView method fling.
private void fling(int position, float velocity, boolean avoidDismissStart, boolean logMetrics) {
SnapTarget snapTarget = mSnapAlgorithm.calculateSnapTarget(position, velocity);
if (avoidDismissStart && snapTarget == mSnapAlgorithm.getDismissStartTarget()) {
snapTarget = mSnapAlgorithm.getFirstSplitTarget();
}
if (logMetrics) {
logResizeEvent(snapTarget);
}
ValueAnimator anim = getFlingAnimator(position, snapTarget, 0);
mFlingAnimationUtils.apply(anim, position, snapTarget.position, velocity);
anim.start();
}
use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project platform_frameworks_base by android.
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);
}
Aggregations