use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ArrowOS.
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 RecentsView method getSplitSelectTranslation.
/**
* Returns how much additional translation there should be for each of the child TaskViews.
* Note that the translation can be its primary or secondary dimension.
*/
public float getSplitSelectTranslation() {
int splitPosition = getSplitPlaceholder().getActiveSplitStagePosition();
if (!shouldShiftThumbnailsForSplitSelect()) {
return 0f;
}
PagedOrientationHandler orientationHandler = getPagedOrientationHandler();
int direction = orientationHandler.getSplitTranslationDirectionFactor(splitPosition, mActivity.getDeviceProfile());
return mActivity.getResources().getDimension(R.dimen.split_placeholder_size) * direction;
}
use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ArrowOS.
the class RecentsView method onRotateInSplitSelectionState.
protected void onRotateInSplitSelectionState() {
mOrientationHandler.getInitialSplitPlaceholderBounds(mSplitPlaceholderSize, mActivity.getDeviceProfile(), mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect);
mTempRectF.set(mTempRect);
// TODO(194414938) set correct corner radius
if (mFirstFloatingTaskView != null) {
mFirstFloatingTaskView.updateOrientationHandler(mOrientationHandler);
mFirstFloatingTaskView.update(mTempRectF, /*progress=*/
1f, /*windowRadius=*/
0f);
}
PagedOrientationHandler orientationHandler = getPagedOrientationHandler();
Pair<FloatProperty, FloatProperty> taskViewsFloat = orientationHandler.getSplitSelectTaskOffset(TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION, mActivity.getDeviceProfile());
taskViewsFloat.first.set(this, getSplitSelectTranslation());
taskViewsFloat.second.set(this, 0f);
applySplitPrimaryScrollOffset();
}
use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ArrowOS.
the class TaskView method setOrientationState.
public void setOrientationState(RecentsOrientedState orientationState) {
PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams();
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
boolean isGridTask = isGridTask();
int taskIconHeight = deviceProfile.overviewTaskIconSizePx;
int taskMargin = isGridTask ? deviceProfile.overviewTaskMarginGridPx : deviceProfile.overviewTaskMarginPx;
int taskIconMargin = snapshotParams.topMargin - taskIconHeight - taskMargin;
LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
orientationHandler.setIconAndSnapshotParams(mIconView, taskIconMargin, taskIconHeight, snapshotParams, isRtl);
mSnapshotView.setLayoutParams(snapshotParams);
iconParams.width = iconParams.height = taskIconHeight;
mIconView.setLayoutParams(iconParams);
mIconView.setRotation(orientationHandler.getDegreesRotated());
int iconDrawableSize = isGridTask ? deviceProfile.overviewTaskIconDrawableSizeGridPx : deviceProfile.overviewTaskIconDrawableSizePx;
mIconView.setDrawableSize(iconDrawableSize, iconDrawableSize);
snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
mSnapshotView.setLayoutParams(snapshotParams);
mSnapshotView.getTaskOverlay().updateOrientationState(orientationState);
}
use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ProtonAOSP.
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();
}
if (isGoingUp) {
if (mCurrentAnimation.getProgressFraction() < ANIMATION_PROGRESS_FRACTION_MIDPOINT) {
// Halve the value when dismissing, as we are animating the drag across the full
// length for only the first half of the progress
mCurrentAnimation.setPlayFraction(Utilities.boundToRange(totalDisplacement * mProgressMultiplier / 2, 0, 1));
} else {
// Set mOverrideVelocity to control task dismiss velocity in onDragEnd
int velocityDimenId = R.dimen.default_task_dismiss_drag_velocity;
if (mRecentsView.showAsGrid()) {
if (mTaskBeingDragged.isFocusedTask()) {
velocityDimenId = R.dimen.default_task_dismiss_drag_velocity_grid_focus_task;
} else {
velocityDimenId = R.dimen.default_task_dismiss_drag_velocity_grid;
}
}
mOverrideVelocity = -mTaskBeingDragged.getResources().getDimension(velocityDimenId);
// Once halfway through task dismissal interpolation, switch from reversible
// dragging-task animation to playing the remaining task translation animations
final long now = SystemClock.uptimeMillis();
MotionEvent upAction = MotionEvent.obtain(now, now, MotionEvent.ACTION_UP, 0.0f, 0.0f, 0);
mDetector.onTouchEvent(upAction);
upAction.recycle();
}
} else {
mCurrentAnimation.setPlayFraction(Utilities.boundToRange(totalDisplacement * mProgressMultiplier, 0, 1));
}
return true;
}
Aggregations