diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index e8e83288cd..07fcf48a07 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -121,8 +121,7 @@ public final class RecentsViewStateController extends private void handleSplitSelectionState(@NonNull LauncherState toState, @NonNull PendingAnimation builder, boolean animate) { if (toState != OVERVIEW_SPLIT_SELECT) { - // Not going to split, nothing to do but ensure taskviews are at correct offset - mRecentsView.resetSplitPrimaryScrollOffset(); + // Not going to split return; } @@ -153,8 +152,6 @@ public final class RecentsViewStateController extends as.start(); as.end(); } - - mRecentsView.applySplitPrimaryScrollOffset(); } private void setAlphas(PropertySetter propertySetter, StateAnimationConfig config, diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java index 062e50e30b..11b1ab8ec9 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java @@ -130,15 +130,9 @@ public class FallbackRecentsStateController implements StateHandler 0) { TaskView taskView = requireTaskViewAt(0); @@ -1733,12 +1720,12 @@ public abstract class RecentsView 0 && mTopRowIdSet.size() >= (taskCount - 1) / 2f; - // Pick the next focused task from the preferred row. - for (int i = 0; i < taskCount; i++) { - TaskView taskView = requireTaskViewAt(i); - if (taskView == dismissedTaskView) { - continue; + if (isFocusedTaskDismissed) { + if (isSplitSelectionActive()) { + isStagingFocusedTask = true; + } else { + nextFocusedTaskFromTop = + mTopRowIdSet.size() > 0 && mTopRowIdSet.size() >= (taskCount - 1) / 2f; + // Pick the next focused task from the preferred row. + for (int i = 0; i < taskCount; i++) { + TaskView taskView = requireTaskViewAt(i); + if (taskView == dismissedTaskView) { + continue; + } + boolean isTopRow = mTopRowIdSet.contains(taskView.getTaskViewId()); + if ((nextFocusedTaskFromTop && isTopRow + || (!nextFocusedTaskFromTop && !isTopRow))) { + nextFocusedTaskView = taskView; + break; + } } - boolean isTopRow = mTopRowIdSet.contains(taskView.getTaskViewId()); - if ((nextFocusedTaskFromTop && isTopRow - || (!nextFocusedTaskFromTop && !isTopRow))) { - nextFocusedTaskView = taskView; - break; + if (nextFocusedTaskView != null) { + nextFocusedTaskWidth = + nextFocusedTaskView.getLayoutParams().width + mPageSpacing; } } - if (nextFocusedTaskView != null) { - nextFocusedTaskWidth = - nextFocusedTaskView.getLayoutParams().width + mPageSpacing; - } } } else { getPageScrolls(oldScroll, false, SIMPLE_SCROLL_LOGIC); @@ -3246,8 +3252,6 @@ public abstract class RecentsView topGridRowSize; boolean dismissedTaskFromTop = mTopRowIdSet.contains(dismissedTaskViewId); boolean dismissedTaskFromBottom = !dismissedTaskFromTop && !isFocusedTaskDismissed; + if (dismissedTaskFromTop || (isFocusedTaskDismissed && nextFocusedTaskFromTop)) { + topGridRowSize--; + } + if (dismissedTaskFromBottom || (isFocusedTaskDismissed && !nextFocusedTaskFromTop)) { + bottomGridRowSize--; + } + int longRowWidth = Math.max(topGridRowSize, bottomGridRowSize) + * (mLastComputedGridTaskSize.width() + mPageSpacing) + + (isStagingFocusedTask ? 0 : mLastComputedTaskSize.width() + mPageSpacing); + float gapWidth = 0; if ((topRowLonger && dismissedTaskFromTop) || (bottomRowLonger && dismissedTaskFromBottom)) { gapWidth = dismissedTaskWidth; - } else if ((topRowLonger && nextFocusedTaskFromTop) - || (bottomRowLonger && !nextFocusedTaskFromTop)) { + } else if (nextFocusedTaskView != null + && ((topRowLonger && nextFocusedTaskFromTop) + || (bottomRowLonger && !nextFocusedTaskFromTop))) { gapWidth = nextFocusedTaskWidth; } if (gapWidth > 0) { - if (taskCount > 2) { - // Compensate the removed gap. - longGridRowWidthDiff += mIsRtl ? -gapWidth : gapWidth; - if (isClearAllHidden) { - // If ClearAllButton isn't fully shown, snap to the last task. - snapToLastTask = true; + if (mClearAllShortTotalWidthTranslation == 0) { + // Compensate the removed gap if we don't already have shortTotalCompensation, + // and adjust accordingly to the new shortTotalCompensation after dismiss. + int newClearAllShortTotalWidthTranslation = 0; + if (longRowWidth < mLastComputedGridSize.width()) { + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); + newClearAllShortTotalWidthTranslation = + (mIsRtl + ? mLastComputedTaskSize.right + : deviceProfile.widthPx - mLastComputedTaskSize.left) + - longRowWidth - deviceProfile.overviewGridSideMargin; } - } else { - // If only focused task will be left, snap to focused task instead. - longGridRowWidthDiff += getSnapToFocusedTaskScrollDiff(isClearAllHidden); + float gapCompensation = gapWidth - newClearAllShortTotalWidthTranslation; + longGridRowWidthDiff += mIsRtl ? -gapCompensation : gapCompensation; + } + if (isClearAllHidden) { + // If ClearAllButton isn't fully shown, snap to the last task. + snapToLastTask = true; } } - if (mClearAllButton.getAlpha() != 0f && isLandscapeSplit) { - // ClearAllButton will not be available in split select, snap to last task instead. - snapToLastTask = true; + if (isLandscapeSplit && !isStagingFocusedTask) { + // LastTask's scroll is the minimum scroll in split select, if current scroll is + // beyond that, we'll need to snap to last task instead. + TaskView lastTask = getLastGridTaskView(); + if (lastTask != null) { + int primaryScroll = mOrientationHandler.getPrimaryScroll(this); + int lastTaskScroll = getScrollForPage(indexOfChild(lastTask)); + if ((mIsRtl && primaryScroll < lastTaskScroll) + || (!mIsRtl && primaryScroll > lastTaskScroll)) { + snapToLastTask = true; + } + } } if (snapToLastTask) { longGridRowWidthDiff += getSnapToLastTaskScrollDiff(); - if (isSplitPlaceholderLastInGrid) { - // Shift all the tasks to make space for split placeholder. - longGridRowWidthDiff += mIsRtl ? mSplitPlaceholderSize : -mSplitPlaceholderSize; - } } else if (isLandscapeSplit && currentPageSnapsToEndOfGrid) { // Use last task as reference point for scroll diff and snapping calculation as it's // the only invariant point in landscape split screen. @@ -3452,8 +3480,6 @@ public abstract class RecentsView lastTaskScroll)) { pageScroll = lastTaskScroll; @@ -5283,8 +5251,7 @@ public abstract class RecentsView= 0 && (mIsRtl diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index fb856058db..b9aaef63ca 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -375,7 +375,6 @@ public class TaskView extends FrameLayout implements Reusable { // Used when in SplitScreenSelectState private float mSplitSelectTranslationY; private float mSplitSelectTranslationX; - private float mSplitSelectScrollOffsetPrimary; @Nullable private ObjectAnimator mIconAndDimAnimator; @@ -1297,10 +1296,6 @@ public class TaskView extends FrameLayout implements Reusable { applyTranslationY(); } - public void setSplitScrollOffsetPrimary(float splitSelectScrollOffsetPrimary) { - mSplitSelectScrollOffsetPrimary = splitSelectScrollOffsetPrimary; - } - private void setDismissTranslationX(float x) { mDismissTranslationX = x; applyTranslationX(); @@ -1364,19 +1359,18 @@ public class TaskView extends FrameLayout implements Reusable { applyTranslationX(); } - public float getScrollAdjustment(boolean fullscreenEnabled, boolean gridEnabled) { + public float getScrollAdjustment(boolean gridEnabled) { float scrollAdjustment = 0; if (gridEnabled) { scrollAdjustment += mGridTranslationX; } else { scrollAdjustment += getPrimaryNonGridTranslationProperty().get(this); } - scrollAdjustment += mSplitSelectScrollOffsetPrimary; return scrollAdjustment; } - public float getOffsetAdjustment(boolean fullscreenEnabled, boolean gridEnabled) { - return getScrollAdjustment(fullscreenEnabled, gridEnabled); + public float getOffsetAdjustment(boolean gridEnabled) { + return getScrollAdjustment(gridEnabled); } public float getSizeAdjustment(boolean fullscreenEnabled) {