Snap for 9010891 from 14aa82a02a to udc-release

Change-Id: I9aff77d5eefa31778b0cfc17f0720d45a31fc406
This commit is contained in:
Android Build Coastguard Worker committed 2022-08-31 01:26:03 +00:00
commit 0b5e1b2414
11 files changed
+140 -99

No files matched your search

@@ -30,15 +30,16 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TR
import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET;
import static com.android.quickstep.views.RecentsView.FIRST_FLOATING_TASK_TRANSLATE_OFFSCREEN;
import static com.android.quickstep.views.RecentsView.OVERVIEW_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_GRID_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
import static com.android.quickstep.views.RecentsView.SPLIT_INSTRUCTIONS_FADE;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_THUMBNAIL_SPLASH_ALPHA;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.FloatProperty;
import android.view.animation.Interpolator;
import androidx.annotation.NonNull;
@@ -78,7 +79,7 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
getTaskModalnessProperty().set(mRecentsView, state.getOverviewModalness());
RECENTS_GRID_PROGRESS.set(mRecentsView,
state.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile()) ? 1f : 0f);
OVERVIEW_PROGRESS.set(mRecentsView, state == LauncherState.OVERVIEW ? 1f : 0f);
TASK_THUMBNAIL_SPLASH_ALPHA.set(mRecentsView, state.showTaskThumbnailSplash() ? 1f : 0f);
}
@Override
@@ -157,13 +158,19 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
mRecentsView, getTaskModalnessProperty(),
toState.getOverviewModalness(),
config.getInterpolator(ANIM_OVERVIEW_MODAL, LINEAR));
boolean showAsGrid = toState.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile());
setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS, showAsGrid ? 1f : 0f,
showAsGrid ? INSTANT : FINAL_FRAME);
boolean toOverview = toState == LauncherState.OVERVIEW;
setter.setFloat(mRecentsView, OVERVIEW_PROGRESS, toOverview ? 1f : 0f,
toOverview ? INSTANT : FINAL_FRAME);
LauncherState fromState = mLauncher.getStateManager().getState();
setter.setFloat(mRecentsView, TASK_THUMBNAIL_SPLASH_ALPHA,
toState.showTaskThumbnailSplash() ? 1f : 0f,
!toState.showTaskThumbnailSplash() && fromState == LauncherState.QUICK_SWITCH
? LINEAR : INSTANT);
boolean showAsGrid = toState.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile());
Interpolator gridProgressInterpolator = showAsGrid
? fromState == LauncherState.QUICK_SWITCH ? LINEAR : INSTANT
: FINAL_FRAME;
setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS, showAsGrid ? 1f : 0f,
gridProgressInterpolator);
}
abstract FloatProperty getTaskModalnessProperty();
@@ -82,6 +82,11 @@ public class BackgroundAppState extends OverviewState {
return false;
}
@Override
public boolean showTaskThumbnailSplash() {
return true;
}
@Override
protected float getDepthUnchecked(Context context) {
return 1;
@@ -48,6 +48,7 @@ import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_THUMBNAIL_SPLASH_ALPHA;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
import android.animation.Animator;
@@ -225,6 +226,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
// Set RecentView's initial properties.
RECENTS_SCALE_PROPERTY.set(mRecentsView, fromState.getOverviewScaleAndOffset(mLauncher)[0]);
ADJACENT_PAGE_HORIZONTAL_OFFSET.set(mRecentsView, 1f);
TASK_THUMBNAIL_SPLASH_ALPHA.set(mRecentsView, fromState.showTaskThumbnailSplash() ? 1f : 0);
mRecentsView.setContentAlpha(1);
mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());
mLauncher.getActionsView().getVisibilityAlpha().setValue(
@@ -1027,77 +1027,89 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
return false;
}
private GestureEndTarget calculateEndTarget(PointF velocity, float endVelocity,
boolean isFlingY, boolean isCancel) {
private GestureEndTarget calculateEndTarget(
PointF velocity, float endVelocity, boolean isFlingY, boolean isCancel) {
if (mGestureState.isHandlingAtomicEvent()) {
// Button mode, this is only used to go to recents
// Button mode, this is only used to go to recents.
return RECENTS;
}
final GestureEndTarget endTarget;
final boolean goingToNewTask;
if (mRecentsView != null) {
if (!hasTargets()) {
// If there are no running tasks, then we can assume that this is a continuation of
// the last gesture, but after the recents animation has finished
goingToNewTask = true;
} else {
final int runningTaskIndex = mRecentsView.getRunningTaskIndex();
final int taskToLaunch = mRecentsView.getNextPage();
goingToNewTask = runningTaskIndex >= 0 && taskToLaunch != runningTaskIndex;
}
} else {
goingToNewTask = false;
}
final boolean reachedOverviewThreshold = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW;
final boolean isFlingX = Math.abs(velocity.x) > mContext.getResources()
.getDimension(R.dimen.quickstep_fling_threshold_speed);
if (!isFlingY) {
if (isCancel) {
endTarget = LAST_TASK;
} else if (mDeviceState.isFullyGesturalNavMode()) {
if (goingToNewTask && isFlingX) {
// Flinging towards new task takes precedence over mIsMotionPaused (which only
// checks y-velocity).
endTarget = NEW_TASK;
} else if (mIsMotionPaused) {
endTarget = RECENTS;
} else if (goingToNewTask) {
endTarget = NEW_TASK;
} else {
endTarget = !reachedOverviewThreshold ? LAST_TASK : HOME;
}
} else {
endTarget = reachedOverviewThreshold && mGestureStarted
? RECENTS
: goingToNewTask
? NEW_TASK
: LAST_TASK;
}
} else {
// If swiping at a diagonal, base end target on the faster velocity.
boolean isSwipeUp = endVelocity < 0;
boolean willGoToNewTaskOnSwipeUp =
goingToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity);
if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp && !willGoToNewTaskOnSwipeUp) {
endTarget = HOME;
} else if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp) {
// If swiping at a diagonal, base end target on the faster velocity.
endTarget = NEW_TASK;
} else if (isSwipeUp) {
endTarget = !reachedOverviewThreshold && willGoToNewTaskOnSwipeUp
? NEW_TASK : RECENTS;
} else {
endTarget = goingToNewTask ? NEW_TASK : LAST_TASK;
}
GestureEndTarget endTarget;
if (isCancel) {
endTarget = LAST_TASK;
} else if (isFlingY) {
endTarget = calculateEndTargetForFlingY(velocity, endVelocity);
} else {
endTarget = calculateEndTargetForNonFling(velocity);
}
if (mDeviceState.isOverviewDisabled() && (endTarget == RECENTS || endTarget == LAST_TASK)) {
if (mDeviceState.isOverviewDisabled() && endTarget == RECENTS) {
return LAST_TASK;
}
return endTarget;
}
private GestureEndTarget calculateEndTargetForFlingY(PointF velocity, float endVelocity) {
final boolean isScrollingToNewTask = isScrollingToNewTask();
final boolean isSwipeUp = endVelocity < 0;
if (!isSwipeUp) {
return isScrollingToNewTask ? NEW_TASK : LAST_TASK;
}
// If swiping upward at a diagonal, base end target on the faster velocity direction.
boolean willGoToNewTask =
isScrollingToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity);
if (!mDeviceState.isFullyGesturalNavMode()) {
return (!hasReachedOverviewThreshold() && willGoToNewTask) ? NEW_TASK : RECENTS;
}
return willGoToNewTask ? NEW_TASK : HOME;
}
private GestureEndTarget calculateEndTargetForNonFling(PointF velocity) {
final boolean isScrollingToNewTask = isScrollingToNewTask();
final boolean reachedOverviewThreshold = hasReachedOverviewThreshold();
if (!mDeviceState.isFullyGesturalNavMode()) {
return reachedOverviewThreshold && mGestureStarted
? RECENTS
: (isScrollingToNewTask ? NEW_TASK : LAST_TASK);
}
// Fully gestural mode.
final boolean isFlingX = Math.abs(velocity.x) > mContext.getResources()
.getDimension(R.dimen.quickstep_fling_threshold_speed);
if (isScrollingToNewTask && isFlingX) {
// Flinging towards new task takes precedence over mIsMotionPaused (which only
// checks y-velocity).
return NEW_TASK;
} else if (mIsMotionPaused) {
return RECENTS;
} else if (isScrollingToNewTask) {
return NEW_TASK;
} else if (reachedOverviewThreshold) {
return HOME;
}
return LAST_TASK;
}
private boolean isScrollingToNewTask() {
if (mRecentsView == null) {
return false;
}
if (!hasTargets()) {
// If there are no running tasks, then we can assume that this is a continuation of
// the last gesture, but after the recents animation has finished.
return true;
}
int runningTaskIndex = mRecentsView.getRunningTaskIndex();
return runningTaskIndex >= 0 && mRecentsView.getNextPage() != runningTaskIndex;
}
private boolean hasReachedOverviewThreshold() {
return mCurrentShift.value > MIN_PROGRESS_FOR_OVERVIEW;
}
@UiThread
private void handleNormalGestureEnd(float endVelocity, boolean isFling, PointF velocity,
boolean isCancel) {
@@ -27,13 +27,13 @@ import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
import static com.android.quickstep.fallback.RecentsState.OVERVIEW_SPLIT_SELECT;
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET;
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
import static com.android.quickstep.views.RecentsView.OVERVIEW_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_GRID_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
import static com.android.quickstep.views.RecentsView.TASK_MODALNESS;
import static com.android.quickstep.views.RecentsView.TASK_PRIMARY_SPLIT_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_SPLIT_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_THUMBNAIL_SPLASH_ALPHA;
import static com.android.quickstep.views.TaskView.FLAG_UPDATE_ALL;
import android.util.FloatProperty;
@@ -106,8 +106,8 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
boolean showAsGrid = state.displayOverviewTasksAsGrid(mActivity.getDeviceProfile());
setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS, showAsGrid ? 1f : 0f,
showAsGrid ? INSTANT : FINAL_FRAME);
setter.setFloat(mRecentsView, OVERVIEW_PROGRESS, state == RecentsState.DEFAULT ? 1f : 0f,
INSTANT);
setter.setFloat(mRecentsView, TASK_THUMBNAIL_SPLASH_ALPHA,
state.showTaskThumbnailSplash() ? 1f : 0f, INSTANT);
setter.setViewBackgroundColor(mActivity.getScrimView(), state.getScrimColor(mActivity),
config.getInterpolator(ANIM_SCRIM_FADE, LINEAR));
@@ -41,6 +41,7 @@ public class RecentsState implements BaseState<RecentsState> {
private static final int FLAG_SCRIM = BaseState.getFlag(5);
private static final int FLAG_LIVE_TILE = BaseState.getFlag(6);
private static final int FLAG_OVERVIEW_UI = BaseState.getFlag(7);
private static final int FLAG_TASK_THUMBNAIL_SPLASH = BaseState.getFlag(8);
public static final RecentsState DEFAULT = new RecentsState(0,
FLAG_DISABLE_RESTORE | FLAG_CLEAR_ALL_BUTTON | FLAG_OVERVIEW_ACTIONS | FLAG_SHOW_AS_GRID
@@ -49,7 +50,8 @@ public class RecentsState implements BaseState<RecentsState> {
FLAG_DISABLE_RESTORE | FLAG_CLEAR_ALL_BUTTON | FLAG_OVERVIEW_ACTIONS | FLAG_MODAL
| FLAG_SHOW_AS_GRID | FLAG_SCRIM | FLAG_LIVE_TILE | FLAG_OVERVIEW_UI);
public static final RecentsState BACKGROUND_APP = new BackgroundAppState(2,
FLAG_DISABLE_RESTORE | FLAG_NON_INTERACTIVE | FLAG_FULL_SCREEN | FLAG_OVERVIEW_UI);
FLAG_DISABLE_RESTORE | FLAG_NON_INTERACTIVE | FLAG_FULL_SCREEN | FLAG_OVERVIEW_UI
| FLAG_TASK_THUMBNAIL_SPLASH);
public static final RecentsState HOME = new RecentsState(3, 0);
public static final RecentsState BG_LAUNCHER = new LauncherState(4, 0);
public static final RecentsState OVERVIEW_SPLIT_SELECT = new RecentsState(5,
@@ -139,6 +141,11 @@ public class RecentsState implements BaseState<RecentsState> {
return hasFlag(FLAG_SHOW_AS_GRID) && deviceProfile.isTablet;
}
@Override
public boolean showTaskThumbnailSplash() {
return hasFlag(FLAG_TASK_THUMBNAIL_SPLASH);
}
/**
* True if the state has overview panel visible.
*/
@@ -319,6 +319,6 @@ public class GroupedTaskView extends TaskView {
protected void applyThumbnailSplashAlpha() {
super.applyThumbnailSplashAlpha();
mSnapshotView2.setSplashAlpha(
Utilities.mapToRange(mOverviewProgress, 0f, 1f, 1f, 0f, LINEAR));
Utilities.mapToRange(mTaskThumbnailSplashAlpha, 0f, 1f, 1f, 0f, LINEAR));
}
}
@@ -381,19 +381,19 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
};
/**
* Progress to and from the OVERVIEW state, where being in OverviewState has a value of 1, and
* being in any other LauncherState has a value of 0.
* Alpha of the task thumbnail splash, where being in BackgroundAppState has a value of 1, and
* being in any other state has a value of 0.
*/
public static final FloatProperty<RecentsView> OVERVIEW_PROGRESS =
new FloatProperty<RecentsView>("overviewProgress") {
public static final FloatProperty<RecentsView> TASK_THUMBNAIL_SPLASH_ALPHA =
new FloatProperty<RecentsView>("taskThumbnailSplashAlpha") {
@Override
public void setValue(RecentsView view, float overviewProgress) {
view.setOverviewProgress(overviewProgress);
public void setValue(RecentsView view, float taskThumbnailSplashAlpha) {
view.setTaskThumbnailSplashAlpha(taskThumbnailSplashAlpha);
}
@Override
public Float get(RecentsView view) {
return view.mOverviewProgress;
return view.mTaskThumbnailSplashAlpha;
}
};
@@ -520,7 +520,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
protected float mTaskViewsSecondarySplitTranslation = 0;
// Progress from 0 to 1 where 0 is a carousel and 1 is a 2 row grid.
private float mGridProgress = 0;
private float mOverviewProgress = 0;
private float mTaskThumbnailSplashAlpha = 0;
private boolean mShowAsGridLastOnLayout = false;
private final IntSet mTopRowIdSet = new IntSet();
@@ -1647,6 +1647,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
taskView.setStableAlpha(mContentAlpha);
taskView.setFullscreenProgress(mFullscreenProgress);
taskView.setModalness(mTaskModalness);
taskView.setTaskThumbnailSplashAlpha(mTaskThumbnailSplashAlpha);
}
}
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
@@ -2250,8 +2251,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
updateGridProperties();
}
if (mSizeStrategy.stateFromGestureEndTarget(endTarget)
.displayOverviewTasksAsGrid(mActivity.getDeviceProfile())) {
BaseState<?> endState = mSizeStrategy.stateFromGestureEndTarget(endTarget);
if (endState.displayOverviewTasksAsGrid(mActivity.getDeviceProfile())) {
TaskView runningTaskView = getRunningTaskView();
float runningTaskPrimaryGridTranslation = 0;
if (runningTaskView != null) {
@@ -2275,11 +2276,12 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
}
}
}
int overviewProgress = isOverviewEndTarget ? 1 : 0;
int splashAlpha = endState.showTaskThumbnailSplash() ? 1 : 0;
if (animatorSet == null) {
setOverviewProgress(overviewProgress);
setTaskThumbnailSplashAlpha(splashAlpha);
} else {
animatorSet.play(ObjectAnimator.ofFloat(this, OVERVIEW_PROGRESS, overviewProgress));
animatorSet.play(
ObjectAnimator.ofFloat(this, TASK_THUMBNAIL_SPLASH_ALPHA, splashAlpha));
}
}
@@ -2730,15 +2732,15 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
mClearAllButton.setGridProgress(gridProgress);
}
private void setOverviewProgress(float overviewProgress) {
private void setTaskThumbnailSplashAlpha(float taskThumbnailSplashAlpha) {
int taskCount = getTaskViewCount();
if (taskCount == 0) {
return;
}
mOverviewProgress = overviewProgress;
mTaskThumbnailSplashAlpha = taskThumbnailSplashAlpha;
for (int i = 0; i < taskCount; i++) {
requireTaskViewAt(i).setOverviewProgress(overviewProgress);
requireTaskViewAt(i).setTaskThumbnailSplashAlpha(taskThumbnailSplashAlpha);
}
}
@@ -4341,6 +4343,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
* If launching one of the adjacent tasks, parallax the center task and other adjacent task
* to the right.
*/
@SuppressLint("Recycle")
public AnimatorSet createAdjacentPageAnimForTaskLaunch(TaskView tv) {
AnimatorSet anim = new AnimatorSet();
@@ -4384,7 +4387,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
properties));
}
}
anim.play(ObjectAnimator.ofFloat(recentsView, OVERVIEW_PROGRESS, 1, 0));
anim.play(ObjectAnimator.ofFloat(recentsView, TASK_THUMBNAIL_SPLASH_ALPHA, 0, 1));
return anim;
}
@@ -4444,7 +4447,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
BACKGROUND_APP.getDepth(mActivity));
anim.play(depthAnimator);
}
anim.play(ObjectAnimator.ofFloat(this, OVERVIEW_PROGRESS, 1f, 0f));
anim.play(ObjectAnimator.ofFloat(this, TASK_THUMBNAIL_SPLASH_ALPHA, 0f, 1f));
anim.play(progressAnim);
anim.setInterpolator(interpolator);
@@ -330,7 +330,7 @@ public class TaskView extends FrameLayout implements Reusable {
protected final DigitalWellBeingToast mDigitalWellBeingToast;
private float mFullscreenProgress;
private float mGridProgress;
protected float mOverviewProgress;
protected float mTaskThumbnailSplashAlpha;
private float mNonGridScale = 1;
private float mDismissScale = 1;
protected final FullscreenDrawParams mCurrentFullscreenParams;
@@ -1056,18 +1056,15 @@ public class TaskView extends FrameLayout implements Reusable {
}
/**
* Updates progress of task view for entering/exiting overview on swipe up/down.
*
* <p>Updates the alpha of any splash screen over the thumbnail if it exists.
* Updates alpha of task thumbnail splash on swipe up/down.
*/
public void setOverviewProgress(float overviewProgress) {
mOverviewProgress = overviewProgress;
public void setTaskThumbnailSplashAlpha(float taskThumbnailSplashAlpha) {
mTaskThumbnailSplashAlpha = taskThumbnailSplashAlpha;
applyThumbnailSplashAlpha();
}
protected void applyThumbnailSplashAlpha() {
mSnapshotView.setSplashAlpha(
Utilities.mapToRange(mOverviewProgress, 0f, 1f, 1f, 0f, LINEAR));
mSnapshotView.setSplashAlpha(Utilities.boundToRange(mTaskThumbnailSplashAlpha, 0f, 1f));
}
private void setSplitSelectTranslationX(float x) {
@@ -231,6 +231,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
@PortraitLandscape
@ScreenRecord // b/238461765
public void testSwitchToOverview() throws Exception {
startTestAppsWithCheck();
assertNotNull("Workspace.switchToOverview() returned null",
mLauncher.goHome().switchToOverview());
assertTrue("Launcher internal state didn't switch to Overview",
@@ -63,4 +63,11 @@ public interface BaseState<T extends BaseState> {
default boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) {
return false;
}
/**
* For this state, whether tasks should show the thumbnail splash.
*/
default boolean showTaskThumbnailSplash() {
return false;
}
}