use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Trebuchet by LineageOS.
the class TaskViewTouchController method onDragStart.
@Override
public void onDragStart(boolean start, float startDisplacement) {
PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
if (mCurrentAnimation == null) {
reInitAnimationController(orientationHandler.isGoingUp(startDisplacement, mIsRtl));
mDisplacementShift = 0;
} else {
mDisplacementShift = mCurrentAnimation.getProgressFraction() / mProgressMultiplier;
mCurrentAnimation.pause();
}
mFlingBlockCheck.unblockFling();
}
use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Trebuchet by LineageOS.
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();
}
mCurrentAnimation.setPlayFraction(Utilities.boundToRange(totalDisplacement * mProgressMultiplier, 0, 1));
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
if (mRecentsView.getCurrentPage() != 0 || isGoingUp) {
mRecentsView.redrawLiveTile(true);
}
}
return true;
}
use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Trebuchet by LineageOS.
the class TaskViewTouchController method reInitAnimationController.
private void reInitAnimationController(boolean goingUp) {
if (mCurrentAnimation != null && mCurrentAnimationIsGoingUp == goingUp) {
// No need to init
return;
}
int scrollDirections = mDetector.getScrollDirections();
if (goingUp && ((scrollDirections & DIRECTION_POSITIVE) == 0) || !goingUp && ((scrollDirections & DIRECTION_NEGATIVE) == 0)) {
// Trying to re-init in an unsupported direction.
return;
}
if (mCurrentAnimation != null) {
mCurrentAnimation.setPlayFraction(0);
}
if (mPendingAnimation != null) {
mPendingAnimation.finish(false, Touch.SWIPE);
mPendingAnimation = null;
}
PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
mCurrentAnimationIsGoingUp = goingUp;
BaseDragLayer dl = mActivity.getDragLayer();
final int secondaryLayerDimension = orientationHandler.getSecondaryDimension(dl);
long maxDuration = 2 * secondaryLayerDimension;
int verticalFactor = orientationHandler.getTaskDragDisplacementFactor(mIsRtl);
int secondaryTaskDimension = orientationHandler.getSecondaryDimension(mTaskBeingDragged);
// The interpolator controlling the most prominent visual movement. We use this to determine
// whether we passed SUCCESS_TRANSITION_PROGRESS.
final Interpolator currentInterpolator;
if (goingUp) {
currentInterpolator = Interpolators.LINEAR;
mPendingAnimation = mRecentsView.createTaskDismissAnimation(mTaskBeingDragged, true, /* animateTaskView */
true, /* removeTask */
maxDuration);
mEndDisplacement = -secondaryTaskDimension;
} else {
currentInterpolator = Interpolators.ZOOM_IN;
mPendingAnimation = mRecentsView.createTaskLaunchAnimation(mTaskBeingDragged, maxDuration, currentInterpolator);
// Since the thumbnail is what is filling the screen, based the end displacement on it.
View thumbnailView = mTaskBeingDragged.getThumbnail();
mTempCords[1] = orientationHandler.getSecondaryDimension(thumbnailView);
dl.getDescendantCoordRelativeToSelf(thumbnailView, mTempCords);
mEndDisplacement = secondaryLayerDimension - mTempCords[1];
}
mEndDisplacement *= verticalFactor;
if (mCurrentAnimation != null) {
mCurrentAnimation.setOnCancelRunnable(null);
}
mCurrentAnimation = mPendingAnimation.createPlaybackController().setOnCancelRunnable(this::clearState);
// Setting this interpolator doesn't affect the visual motion, but is used to determine
// whether we successfully reached the target state in onDragEnd().
mCurrentAnimation.getTarget().setInterpolator(currentInterpolator);
onUserControlledAnimationCreated(mCurrentAnimation);
mCurrentAnimation.getTarget().addListener(this);
mCurrentAnimation.dispatchOnStart();
mProgressMultiplier = 1 / mEndDisplacement;
}
use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by AOSPA.
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();
}
}
use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ArrowOS.
the class TaskMenuView method setPosition.
private void setPosition(float x, float y, int overscrollShift) {
PagedOrientationHandler pagedOrientationHandler = mTaskView.getPagedOrientationHandler();
// Inset due to margin
PointF additionalInset = pagedOrientationHandler.getAdditionalInsetForTaskMenu(mTaskInsetMargin);
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
int taskTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
float adjustedY = y + taskTopMargin - additionalInset.y;
float adjustedX = x - additionalInset.x;
// Changing pivot to make computations easier
// NOTE: Changing the pivots means the rotated view gets rotated about the new pivots set,
// which would render the X and Y position set here incorrect
setPivotX(0);
if (deviceProfile.overviewShowAsGrid) {
// In tablet, set pivotY to original position without mThumbnailTopMargin adjustment.
setPivotY(-taskTopMargin);
} else {
setPivotY(0);
}
setRotation(pagedOrientationHandler.getDegreesRotated());
setX(pagedOrientationHandler.getTaskMenuX(adjustedX, mTaskContainer.getThumbnailView(), overscrollShift, deviceProfile));
setY(pagedOrientationHandler.getTaskMenuY(adjustedY, mTaskContainer.getThumbnailView(), overscrollShift));
// TODO(b/193432925) temporary menu placement for split screen task menus
TaskIdAttributeContainer[] taskIdAttributeContainers = mTaskView.getTaskIdAttributeContainers();
if (taskIdAttributeContainers[0].getStagePosition() != STAGE_POSITION_UNDEFINED) {
if (mTaskContainer.getStagePosition() != STAGE_POSITION_BOTTOM_OR_RIGHT) {
return;
}
Rect r = new Rect();
mTaskContainer.getThumbnailView().getBoundsOnScreen(r);
if (deviceProfile.isLandscape) {
setX(r.left);
} else {
setY(r.top);
}
}
}
Aggregations