Merge "Remove focus task" into tm-qpr-dev

This commit is contained in:
Alex Chau
2023-02-25 11:25:34 +00:00
committed by Android (Google) Code Review
10 changed files with 82 additions and 58 deletions

View File

@@ -678,7 +678,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
@Override
public void onMotionPauseDetected() {
mHasMotionEverBeenPaused = true;
maybeUpdateRecentsAttachedState(true/* animate */, true/* moveFocusedTask */);
maybeUpdateRecentsAttachedState(true/* animate */, true/* moveRunningTask */);
Optional.ofNullable(mActivityInterface.getTaskbarController())
.ifPresent(TaskbarUIController::startTranslationSpring);
performHapticFeedback();
@@ -696,7 +696,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
}
private void maybeUpdateRecentsAttachedState(boolean animate) {
maybeUpdateRecentsAttachedState(animate, false /* moveFocusedTask */);
maybeUpdateRecentsAttachedState(animate, false /* moveRunningTask */);
}
/**
@@ -706,9 +706,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
*
* Note this method has no effect unless the navigation mode is NO_BUTTON.
* @param animate whether to animate when attaching RecentsView
* @param moveFocusedTask whether to move focused task to front when attaching
* @param moveRunningTask whether to move running task to front when attaching
*/
private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveFocusedTask) {
private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveRunningTask) {
if (!mDeviceState.isFullyGesturalNavMode() || mRecentsView == null) {
return;
}
@@ -727,11 +727,11 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
} else {
recentsAttachedToAppWindow = mHasMotionEverBeenPaused || mIsLikelyToStartNewTask;
}
if (moveFocusedTask && !mAnimationFactory.hasRecentsEverAttachedToAppWindow()
if (moveRunningTask && !mAnimationFactory.hasRecentsEverAttachedToAppWindow()
&& recentsAttachedToAppWindow) {
// Only move focused task if RecentsView has never been attached before, to avoid
// Only move running task if RecentsView has never been attached before, to avoid
// TaskView jumping to new position as we move the tasks.
mRecentsView.moveFocusedTaskToFront();
mRecentsView.moveRunningTaskToFront();
}
mAnimationFactory.setRecentsAttachedToAppWindow(recentsAttachedToAppWindow, animate);

View File

@@ -231,17 +231,20 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
/**
* Calculates the taskView size for the provided device configuration.
*/
public final void calculateTaskSize(Context context, DeviceProfile dp, Rect outRect) {
Resources res = context.getResources();
float maxScale = res.getFloat(R.dimen.overview_max_scale);
public final void calculateTaskSize(Context context, DeviceProfile dp, Rect outRect,
PagedOrientationHandler orientedState) {
if (dp.isTablet) {
Rect gridRect = new Rect();
calculateGridSize(dp, gridRect);
calculateTaskSizeInternal(context, dp, gridRect, maxScale, Gravity.CENTER, outRect);
if (FeatureFlags.ENABLE_GRID_ONLY_OVERVIEW.get()) {
calculateGridTaskSize(context, dp, outRect, orientedState);
} else {
calculateFocusTaskSize(context, dp, outRect);
}
} else {
Resources res = context.getResources();
float maxScale = res.getFloat(R.dimen.overview_max_scale);
int taskMargin = dp.overviewTaskMarginPx;
calculateTaskSizeInternal(context, dp,
calculateTaskSizeInternal(
dp,
dp.overviewTaskThumbnailTopMarginPx,
dp.getOverviewActionsClaimedSpace(),
res.getDimensionPixelSize(R.dimen.overview_minimum_next_prev_size) + taskMargin,
@@ -251,7 +254,15 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
}
}
private void calculateTaskSizeInternal(Context context, DeviceProfile dp, int claimedSpaceAbove,
private void calculateFocusTaskSize(Context context, DeviceProfile dp, Rect outRect) {
Resources res = context.getResources();
float maxScale = res.getFloat(R.dimen.overview_max_scale);
Rect gridRect = new Rect();
calculateGridSize(dp, gridRect);
calculateTaskSizeInternal(dp, gridRect, maxScale, Gravity.CENTER, outRect);
}
private void calculateTaskSizeInternal(DeviceProfile dp, int claimedSpaceAbove,
int claimedSpaceBelow, int minimumHorizontalPadding, float maxScale, int gravity,
Rect outRect) {
Rect insets = dp.getInsets();
@@ -264,10 +275,10 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
minimumHorizontalPadding,
claimedSpaceBelow);
calculateTaskSizeInternal(context, dp, potentialTaskRect, maxScale, gravity, outRect);
calculateTaskSizeInternal(dp, potentialTaskRect, maxScale, gravity, outRect);
}
private void calculateTaskSizeInternal(Context context, DeviceProfile dp,
private void calculateTaskSizeInternal(DeviceProfile dp,
Rect potentialTaskRect, float maxScale, int gravity, Rect outRect) {
PointF taskDimension = getTaskDimension(dp);
@@ -318,12 +329,15 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
public final void calculateGridTaskSize(Context context, DeviceProfile dp, Rect outRect,
PagedOrientationHandler orientedState) {
Resources res = context.getResources();
Rect taskRect = new Rect();
calculateTaskSize(context, dp, taskRect);
Rect potentialTaskRect = new Rect();
if (FeatureFlags.ENABLE_GRID_ONLY_OVERVIEW.get()) {
calculateGridSize(dp, potentialTaskRect);
} else {
calculateFocusTaskSize(context, dp, potentialTaskRect);
}
float rowHeight =
(taskRect.height() + dp.overviewTaskThumbnailTopMarginPx - dp.overviewRowSpacing)
/ 2f;
float rowHeight = (potentialTaskRect.height() + dp.overviewTaskThumbnailTopMarginPx
- dp.overviewRowSpacing) / 2f;
PointF taskDimension = getTaskDimension(dp);
float scale = (rowHeight - dp.overviewTaskThumbnailTopMarginPx) / taskDimension.y;
@@ -332,14 +346,15 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
int gravity = Gravity.TOP;
gravity |= orientedState.getRecentsRtlSetting(res) ? Gravity.RIGHT : Gravity.LEFT;
Gravity.apply(gravity, outWidth, outHeight, taskRect, outRect);
Gravity.apply(gravity, outWidth, outHeight, potentialTaskRect, outRect);
}
/**
* Calculates the modal taskView size for the provided device configuration
*/
public final void calculateModalTaskSize(Context context, DeviceProfile dp, Rect outRect) {
calculateTaskSize(context, dp, outRect);
public final void calculateModalTaskSize(Context context, DeviceProfile dp, Rect outRect,
PagedOrientationHandler orientedState) {
calculateTaskSize(context, dp, outRect, orientedState);
boolean isGridOnlyOverview = dp.isTablet && FeatureFlags.ENABLE_GRID_ONLY_OVERVIEW.get();
int claimedSpaceBelow = isGridOnlyOverview
? dp.overviewActionsTopMarginPx + dp.overviewActionsHeight + dp.stashedTaskbarSize
@@ -351,7 +366,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
Math.round((dp.availableWidthPx - outRect.width() * maxScale) / 2);
}
calculateTaskSizeInternal(
context, dp,
dp,
dp.overviewTaskMarginPx,
claimedSpaceBelow,
minimumHorizontalPadding,

View File

@@ -61,7 +61,7 @@ public final class FallbackActivityInterface extends
@Override
public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect,
PagedOrientationHandler orientationHandler) {
calculateTaskSize(context, dp, outRect);
calculateTaskSize(context, dp, outRect, orientationHandler);
if (dp.isVerticalBarLayout() && DisplayController.getNavigationMode(context) != NO_BUTTON) {
return dp.isSeascape() ? outRect.left : (dp.widthPx - outRect.right);
} else {

View File

@@ -18,7 +18,6 @@ package com.android.quickstep;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.QUICK_SWITCH_FROM_HOME;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -73,7 +72,7 @@ public final class LauncherActivityInterface extends
@Override
public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect,
PagedOrientationHandler orientationHandler) {
calculateTaskSize(context, dp, outRect);
calculateTaskSize(context, dp, outRect, orientationHandler);
if (dp.isVerticalBarLayout()
&& DisplayController.getNavigationMode(context) != NavigationMode.NO_BUTTON) {
return dp.isSeascape() ? outRect.left : (dp.widthPx - outRect.right);

View File

@@ -283,7 +283,7 @@ public class OverviewCommandHelper {
RecentsView<?, ?> visibleRecentsView = activityInterface.getVisibleRecentsView();
if (visibleRecentsView != null) {
visibleRecentsView.moveFocusedTaskToFront();
visibleRecentsView.moveRunningTaskToFront();
}
if (mTaskAnimationManager.isRecentsAnimationRunning()) {
cmd.mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(gestureState);

View File

@@ -59,7 +59,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
}
Rect focusedTaskRect = new Rect();
LauncherActivityInterface.INSTANCE.calculateTaskSize(mContext, mDeviceProfile,
focusedTaskRect);
focusedTaskRect, PagedOrientationHandler.PORTRAIT);
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.height());
return response;
}

View File

@@ -158,7 +158,8 @@ public class AnimatorControllerWithResistance {
Rect startRect = new Rect();
PagedOrientationHandler orientationHandler = params.recentsOrientedState
.getOrientationHandler();
LauncherActivityInterface.INSTANCE.calculateTaskSize(params.context, params.dp, startRect);
LauncherActivityInterface.INSTANCE.calculateTaskSize(params.context, params.dp, startRect,
orientationHandler);
long distanceToCover = startRect.bottom;
PendingAnimation resistAnim = params.resistAnim != null
? params.resistAnim

View File

@@ -43,7 +43,8 @@ public class LayoutUtils {
PagedOrientationHandler orientationHandler) {
// Track the bottom of the window.
Rect taskSize = new Rect();
LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize);
LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize,
orientationHandler);
return orientationHandler.getDistanceToBottomOfRect(dp, taskSize);
}

View File

@@ -157,7 +157,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
mSizeStrategy.calculateGridTaskSize(mContext, mDp, mTaskRect,
mOrientationState.getOrientationHandler());
} else {
mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect);
mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect,
mOrientationState.getOrientationHandler());
}
Rect fullTaskSize;

View File

@@ -1480,20 +1480,20 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
}
/**
* Moves the focused task to the front of the carousel in tablets, to minimize animation
* required to focus the task in grid.
* Moves the running task to the front of the carousel in tablets, to minimize animation
* required to move the running task in grid.
*/
public void moveFocusedTaskToFront() {
public void moveRunningTaskToFront() {
if (!mActivity.getDeviceProfile().isTablet) {
return;
}
TaskView focusedTaskView = getFocusedTaskView();
if (focusedTaskView == null) {
TaskView runningTaskView = getRunningTaskView();
if (runningTaskView == null) {
return;
}
if (indexOfChild(focusedTaskView) != mCurrentPage) {
if (indexOfChild(runningTaskView) != mCurrentPage) {
return;
}
@@ -1505,20 +1505,20 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
int currentPageScroll = getScrollForPage(mCurrentPage);
mCurrentPageScrollDiff = primaryScroll - currentPageScroll;
mMovingTaskView = focusedTaskView;
removeView(focusedTaskView);
mMovingTaskView = runningTaskView;
removeView(runningTaskView);
mMovingTaskView = null;
focusedTaskView.resetPersistentViewTransforms();
runningTaskView.resetPersistentViewTransforms();
int frontTaskIndex = 0;
if (DesktopTaskView.DESKTOP_IS_PROTO2_ENABLED && !focusedTaskView.isDesktopTask()) {
if (DesktopTaskView.DESKTOP_IS_PROTO2_ENABLED && !runningTaskView.isDesktopTask()) {
// If desktop mode is enabled, desktop task view is pinned at first position.
// Move focused task to position 1
// Move running task to position 1
frontTaskIndex = 1;
}
addView(focusedTaskView, frontTaskIndex);
addView(runningTaskView, frontTaskIndex);
setCurrentPage(frontTaskIndex);
updateGridProperties();
updateTaskSize();
}
@Override
@@ -1665,8 +1665,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
newFocusedTaskView = getTaskViewAt(1);
}
}
mFocusedTaskViewId =
newFocusedTaskView != null ? newFocusedTaskView.getTaskViewId() : INVALID_TASK_ID;
mFocusedTaskViewId = newFocusedTaskView != null && !ENABLE_GRID_ONLY_OVERVIEW.get()
? newFocusedTaskView.getTaskViewId() : INVALID_TASK_ID;
updateTaskSize();
updateChildTaskOrientations();
@@ -1781,7 +1781,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
* Returns the number of tasks in the bottom row of the overview grid.
*/
public int getBottomRowTaskCountForTablet() {
return getTaskViewCount() - mTopRowIdSet.size() - 1;
return getTaskViewCount() - mTopRowIdSet.size() - (ENABLE_GRID_ONLY_OVERVIEW.get() ? 0 : 1);
}
protected void onTaskStackUpdated() {
@@ -1987,7 +1987,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
}
public void getTaskSize(Rect outRect) {
mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), outRect);
mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), outRect,
mOrientationHandler);
mLastComputedTaskSize.set(outRect);
}
@@ -2032,7 +2033,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
/** Gets the task size for modal state. */
public void getModalTaskSize(Rect outRect) {
mSizeStrategy.calculateModalTaskSize(mActivity, mActivity.getDeviceProfile(), outRect);
mSizeStrategy.calculateModalTaskSize(mActivity, mActivity.getDeviceProfile(), outRect,
mOrientationHandler);
}
@Override
@@ -2574,7 +2576,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
boolean runningTaskTileHidden = mRunningTaskTileHidden;
setCurrentTask(runningTaskViewId);
mFocusedTaskViewId = runningTaskViewId;
mFocusedTaskViewId = ENABLE_GRID_ONLY_OVERVIEW.get() ? INVALID_TASK_ID : runningTaskViewId;
runOnPageScrollsInitialized(() -> setCurrentPage(getRunningTaskIndex()));
setRunningTaskViewShowScreenshot(false);
setRunningTaskHidden(runningTaskTileHidden);
@@ -3263,7 +3265,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
float longGridRowWidthDiff = 0;
int topGridRowSize = mTopRowIdSet.size();
int bottomGridRowSize = taskCount - mTopRowIdSet.size() - 1;
int bottomGridRowSize = taskCount - mTopRowIdSet.size()
- (ENABLE_GRID_ONLY_OVERVIEW.get() ? 0 : 1);
boolean topRowLonger = topGridRowSize > bottomGridRowSize;
boolean bottomRowLonger = bottomGridRowSize > topGridRowSize;
boolean dismissedTaskFromTop = mTopRowIdSet.contains(dismissedTaskViewId);
@@ -3275,8 +3278,10 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
bottomGridRowSize--;
}
int longRowWidth = Math.max(topGridRowSize, bottomGridRowSize)
* (mLastComputedGridTaskSize.width() + mPageSpacing)
+ (isStagingFocusedTask ? 0 : mLastComputedTaskSize.width() + mPageSpacing);
* (mLastComputedGridTaskSize.width() + mPageSpacing);
if (!ENABLE_GRID_ONLY_OVERVIEW.get() && !isStagingFocusedTask) {
longRowWidth += mLastComputedTaskSize.width() + mPageSpacing;
}
float gapWidth = 0;
if ((topRowLonger && dismissedTaskFromTop)
@@ -3683,7 +3688,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
} else {
// Update focus task and its size.
if (finalIsFocusedTaskDismissed && finalNextFocusedTaskView != null) {
mFocusedTaskViewId = finalNextFocusedTaskView.getTaskViewId();
mFocusedTaskViewId = ENABLE_GRID_ONLY_OVERVIEW.get()
? INVALID_TASK_ID
: finalNextFocusedTaskView.getTaskViewId();
mTopRowIdSet.remove(mFocusedTaskViewId);
finalNextFocusedTaskView.animateIconScaleAndDimIntoView();
}