Merge "Moving taskbar lifecycle to TouchInteractionService" into sc-dev
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index ad20c30..632bb4c 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -39,6 +39,11 @@
<dimen name="overview_grid_focus_vertical_margin">90dp</dimen>
<dimen name="split_placeholder_size">110dp</dimen>
+ <!-- These speeds are in dp/s -->
+ <dimen name="max_task_dismiss_drag_velocity">2.25dp</dimen>
+ <dimen name="default_task_dismiss_drag_velocity">1.75dp</dimen>
+ <dimen name="default_task_dismiss_drag_velocity_grid">0.75dp</dimen>
+
<dimen name="recents_page_spacing">16dp</dimen>
<dimen name="recents_clear_all_deadzone_vertical_margin">70dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 65dee55..80754a0 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -75,7 +75,6 @@
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.util.ActivityOptionsWrapper;
-import com.android.launcher3.util.DynamicResource;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.RunnableList;
@@ -86,8 +85,8 @@
import com.android.quickstep.TaskViewUtils;
import com.android.quickstep.util.MultiValueUpdateListener;
import com.android.quickstep.util.RemoteAnimationProvider;
-import com.android.quickstep.util.StaggeredWorkspaceAnim;
import com.android.quickstep.util.SurfaceTransactionApplier;
+import com.android.quickstep.util.WorkspaceRevealAnim;
import com.android.quickstep.views.FloatingWidgetView;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.ActivityCompat;
@@ -1213,10 +1212,7 @@
}
});
} else {
- float velocityPxPerS = DynamicResource.provider(mLauncher)
- .getDimension(R.dimen.unlock_staggered_velocity_dp_per_s);
- anim.play(new StaggeredWorkspaceAnim(mLauncher, velocityPxPerS, false)
- .getAnimators());
+ anim.play(new WorkspaceRevealAnim(mLauncher, false).getAnimators());
}
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java
index 0014b85..3a8de3c 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java
@@ -19,13 +19,13 @@
import android.app.ActivityTaskManager;
import android.app.PendingIntent;
import android.content.Intent;
-import android.os.Build;
import android.os.RemoteException;
import android.util.Log;
import android.util.Pair;
import android.view.View;
import android.widget.RemoteViews;
+import com.android.launcher3.Utilities;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
@@ -41,6 +41,7 @@
mLauncher = launcher;
}
+ @SuppressWarnings("NewApi")
@Override
public boolean onInteraction(View view, PendingIntent pendingIntent,
RemoteViews.RemoteResponse remoteResponse) {
@@ -53,7 +54,7 @@
Pair<Intent, ActivityOptions> options = remoteResponse.getLaunchOptions(hostView);
ActivityOptionsWrapper activityOptions = mLauncher.getAppTransitionManager()
.getActivityLaunchOptions(mLauncher, hostView);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !pendingIntent.isActivity()) {
+ if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) {
// In the event this pending intent eventually launches an activity, i.e. a trampoline,
// use the Quickstep transition animation.
try {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
index 77c2611..01c9e76 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.graphics.Color;
+import android.os.SystemProperties;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
@@ -84,7 +85,8 @@
@Override
protected float getDepthUnchecked(Context context) {
- return 1f;
+ //TODO revert when b/178661709 is fixed
+ return SystemProperties.getBoolean("ro.launcher.depth.appLaunch", true) ? 1 : 0;
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index 45791a3..8c128c8 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.graphics.Rect;
+import android.os.SystemProperties;
import android.view.View;
import com.android.launcher3.DeviceProfile;
@@ -127,7 +128,8 @@
@Override
protected float getDepthUnchecked(Context context) {
- return 1f;
+ //TODO revert when b/178661709 is fixed
+ return SystemProperties.getBoolean("ro.launcher.depth.overview", true) ? 1 : 0;
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
index 5837a70..40c3e02 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
@@ -73,7 +73,7 @@
import com.android.quickstep.util.AnimatorControllerWithResistance;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.util.MotionPauseDetector;
-import com.android.quickstep.util.StaggeredWorkspaceAnim;
+import com.android.quickstep.util.WorkspaceRevealAnim;
import com.android.quickstep.views.LauncherRecentsView;
/**
@@ -384,8 +384,7 @@
updateNonOverviewAnim(targetState, config);
nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
- new StaggeredWorkspaceAnim(mLauncher, velocity.y, false /* animateOverviewScrim */)
- .start();
+ new WorkspaceRevealAnim(mLauncher, false /* animateOverviewScrim */).start();
} else {
boolean canceled = targetState == NORMAL;
if (canceled) {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
index 70b3870..c6ea953 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
@@ -28,6 +28,7 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.LauncherAnimUtils;
+import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
@@ -50,6 +51,10 @@
extends AnimatorListenerAdapter implements TouchController,
SingleAxisSwipeDetector.Listener {
+ private static final float ANIMATION_PROGRESS_FRACTION_MIDPOINT = 0.5f;
+ private static final long MIN_TASK_DISMISS_ANIMATION_DURATION = 300;
+ private static final long MAX_TASK_DISMISS_ANIMATION_DURATION = 600;
+
protected final T mActivity;
private final SingleAxisSwipeDetector mDetector;
private final RecentsView mRecentsView;
@@ -277,14 +282,32 @@
} else {
mFlingBlockCheck.onEvent();
}
- mCurrentAnimation.setPlayFraction(Utilities.boundToRange(
- totalDisplacement * mProgressMultiplier, 0, 1));
+
+ // Once halfway through task dismissal interpolation, switch from reversible dragging-task
+ // animation to playing the remaining task translation animations
+ if (mCurrentAnimation.getProgressFraction() < ANIMATION_PROGRESS_FRACTION_MIDPOINT) {
+ // Halve the value 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 {
+ float dragVelocity = -mTaskBeingDragged.getResources().getDimension(
+ mRecentsView.showAsGrid() ? R.dimen.default_task_dismiss_drag_velocity_grid
+ : R.dimen.default_task_dismiss_drag_velocity);
+ onDragEnd(dragVelocity);
+ return true;
+ }
return true;
}
@Override
public void onDragEnd(float velocity) {
+ // Limit velocity, as very large scalar values make animations play too quickly
+ float maxTaskDismissDragVelocity = mTaskBeingDragged.getResources().getDimension(
+ R.dimen.max_task_dismiss_drag_velocity);
+ velocity = Utilities.boundToRange(velocity, -maxTaskDismissDragVelocity,
+ maxTaskDismissDragVelocity);
boolean fling = mDetector.isFling(velocity);
final boolean goingToEnd;
boolean blockedFling = fling && mFlingBlockCheck.isBlocked();
@@ -305,6 +328,11 @@
if (blockedFling && !goingToEnd) {
animationDuration *= LauncherAnimUtils.blockedFlingDurationFactor(velocity);
}
+ // Due to very high or low velocity dismissals, animation durations can be inconsistently
+ // long or short. Bound the duration for animation of task translations for a more
+ // standardized feel.
+ animationDuration = Utilities.boundToRange(animationDuration,
+ MIN_TASK_DISMISS_ANIMATION_DURATION, MAX_TASK_DISMISS_ANIMATION_DURATION);
mCurrentAnimation.setEndAction(this::clearState);
mCurrentAnimation.startWithVelocity(mActivity, goingToEnd,
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 1317b4c..e0f430d 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -102,10 +102,10 @@
import com.android.quickstep.util.ProtoTracer;
import com.android.quickstep.util.RecentsOrientedState;
import com.android.quickstep.util.RectFSpringAnim;
-import com.android.quickstep.util.StaggeredWorkspaceAnim;
import com.android.quickstep.util.SurfaceTransactionApplier;
import com.android.quickstep.util.SwipePipToHomeAnimator;
import com.android.quickstep.util.TransformParams;
+import com.android.quickstep.util.WorkspaceRevealAnim;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -201,7 +201,7 @@
STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_LAUNCHER_STARTED;
public static final long MAX_SWIPE_DURATION = 350;
- public static final long HOME_DURATION = StaggeredWorkspaceAnim.DURATION_MS;
+ public static final long HOME_DURATION = WorkspaceRevealAnim.DURATION_MS;
public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.7f;
private static final float SWIPE_DURATION_MULTIPLIER =
@@ -1126,6 +1126,7 @@
windowAnim.start(mContext, velocityPxPerMs);
mRunningWindowAnim = RunningWindowAnim.wrap(windowAnim);
}
+ homeAnimFactory.setSwipeVelocity(velocityPxPerMs.y);
homeAnimFactory.playAtomicAnimation(velocityPxPerMs.y);
mLauncherTransitionController = null;
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index f125063..811af7e 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -18,13 +18,14 @@
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.Utilities.boundToRange;
import static com.android.launcher3.Utilities.dpToPx;
-import static com.android.launcher3.Utilities.mapToRange;
-import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.PROTOTYPE_APP_CLOSE;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
import static com.android.launcher3.views.FloatingIconView.getFloatingIconView;
+import static java.lang.Math.round;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
@@ -52,10 +53,12 @@
import com.android.launcher3.util.DynamicResource;
import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.views.FloatingIconView;
+import com.android.launcher3.views.FloatingView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.quickstep.util.AppCloseConfig;
import com.android.quickstep.util.RectFSpringAnim;
import com.android.quickstep.util.StaggeredWorkspaceAnim;
+import com.android.quickstep.util.WorkspaceRevealAnim;
import com.android.quickstep.views.FloatingWidgetView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
@@ -112,10 +115,6 @@
private HomeAnimationFactory createIconHomeAnimationFactory(View workspaceView) {
final ResourceProvider rp = DynamicResource.provider(mActivity);
final float transY = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp));
- float dpPerSecond = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp_per_s));
- final float launcherAlphaMax =
- rp.getFloat(R.dimen.swipe_up_launcher_alpha_max_progress);
-
RectF iconLocation = new RectF();
FloatingIconView floatingIconView = getFloatingIconView(mActivity, workspaceView,
true /* hideOriginal */, iconLocation, false /* isOpening */);
@@ -123,73 +122,25 @@
// We want the window alpha to be 0 once this threshold is met, so that the
// FolderIconView can be seen morphing into the icon shape.
float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
- return new LauncherHomeAnimationFactory() {
+
+ return new FloatingViewHomeAnimationFactory(floatingIconView) {
// There is a delay in loading the icon, so we need to keep the window
// opaque until it is ready.
private boolean mIsFloatingIconReady = false;
- private @Nullable ValueAnimator mBounceBackAnimator;
-
@Override
public RectF getWindowTargetRect() {
- if (PROTOTYPE_APP_CLOSE.get()) {
- // We want the target rect to be at this offset position, so that all
- // launcher content can spring back upwards.
- floatingIconView.setPositionOffsetY(transY);
- }
+ super.getWindowTargetRect();
return iconLocation;
}
@Override
public void setAnimation(RectFSpringAnim anim) {
+ super.setAnimation(anim);
anim.addAnimatorListener(floatingIconView);
floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
floatingIconView.setFastFinishRunnable(anim::end);
- if (PROTOTYPE_APP_CLOSE.get()) {
- mBounceBackAnimator = bounceBackToRestingPosition();
- // Use a spring to put drag layer translation back to 0.
- anim.addAnimatorListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- floatingIconView.setPositionOffsetY(0);
- mBounceBackAnimator.start();
- }
- });
-
- Workspace workspace = mActivity.getWorkspace();
- workspace.setPivotToScaleWithSelf(mActivity.getHotseat());
- }
- }
-
- private ValueAnimator bounceBackToRestingPosition() {
- DragLayer dl = mActivity.getDragLayer();
- Workspace workspace = mActivity.getWorkspace();
- Hotseat hotseat = mActivity.getHotseat();
-
- final float startValue = transY;
- final float endValue = 0;
- // Ensures the velocity is always aligned with the direction.
- float pixelPerSecond = Math.abs(dpPerSecond) * Math.signum(endValue - transY);
-
- ValueAnimator springTransY = new SpringAnimationBuilder(dl.getContext())
- .setStiffness(rp.getFloat(R.dimen.swipe_up_trans_y_stiffness))
- .setDampingRatio(rp.getFloat(R.dimen.swipe_up_trans_y_damping))
- .setMinimumVisibleChange(1f)
- .setStartValue(startValue)
- .setEndValue(endValue)
- .setStartVelocity(pixelPerSecond)
- .build(dl, VIEW_TRANSLATE_Y);
- springTransY.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- dl.setTranslationY(0f);
- dl.setAlpha(1f);
- SCALE_PROPERTY.set(workspace, 1f);
- SCALE_PROPERTY.set(hotseat, 1f);
- }
- });
- return springTransY;
}
@Override
@@ -204,34 +155,15 @@
@Override
public void update(@Nullable AppCloseConfig config, RectF currentRect,
float progress, float radius) {
+ super.update(config, currentRect, progress, radius);
int fgAlpha = 255;
if (config != null && PROTOTYPE_APP_CLOSE.get()) {
- DragLayer dl = mActivity.getDragLayer();
- float translationY = config.getWorkspaceTransY();
- dl.setTranslationY(translationY);
-
- float alpha = mapToRange(progress, 0, launcherAlphaMax, 0, 1f, LINEAR);
- dl.setAlpha(Math.min(alpha, 1f));
-
- float scale = Math.min(1f, config.getWorkspaceScale());
- SCALE_PROPERTY.set(mActivity.getWorkspace(), scale);
- SCALE_PROPERTY.set(mActivity.getHotseat(), scale);
- SCALE_PROPERTY.set(mActivity.getAppsView(), scale);
-
progress = config.getInterpolatedProgress();
fgAlpha = config.getFgAlpha();
}
floatingIconView.update(1f, fgAlpha, currentRect, progress,
windowAlphaThreshold, radius, false);
}
-
- @Override
- public void onCancel() {
- floatingIconView.fastFinish();
- if (mBounceBackAnimator != null) {
- mBounceBackAnimator.cancel();
- }
- }
};
}
@@ -246,10 +178,11 @@
hostView, backgroundLocation, windowSize,
mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent);
- return new LauncherHomeAnimationFactory() {
+ return new FloatingViewHomeAnimationFactory(floatingWidgetView) {
@Override
public RectF getWindowTargetRect() {
+ super.getWindowTargetRect();
return backgroundLocation;
}
@@ -260,6 +193,8 @@
@Override
public void setAnimation(RectFSpringAnim anim) {
+ super.setAnimation(anim);
+
anim.addAnimatorListener(floatingWidgetView);
floatingWidgetView.setOnTargetChangeListener(anim::onTargetPositionChanged);
floatingWidgetView.setFastFinishRunnable(anim::end);
@@ -273,15 +208,11 @@
@Override
public void update(@Nullable AppCloseConfig config, RectF currentRect,
float progress, float radius) {
+ super.update(config, currentRect, progress, radius);
floatingWidgetView.update(currentRect, 1 /* floatingWidgetAlpha */,
config != null ? config.getFgAlpha() : 1f /* foregroundAlpha */,
0 /* fallbackBackgroundAlpha */, 1 - progress);
}
-
- @Override
- public void onCancel() {
- floatingWidgetView.fastFinish();
- }
};
}
@@ -323,6 +254,120 @@
true /* toRecents */, callback, true /* sendUserLeaveHint */);
}
+ private class FloatingViewHomeAnimationFactory extends LauncherHomeAnimationFactory {
+
+ private final float mTransY;
+ private final FloatingView mFloatingView;
+ private ValueAnimator mBounceBackAnimator;
+ private final AnimatorSet mWorkspaceReveal;
+
+ FloatingViewHomeAnimationFactory(FloatingView floatingView) {
+ mFloatingView = floatingView;
+
+ ResourceProvider rp = DynamicResource.provider(mActivity);
+ mTransY = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp));
+
+ mWorkspaceReveal = PROTOTYPE_APP_CLOSE.get()
+ ? new WorkspaceRevealAnim(mActivity, true /* animateScrim */).getAnimators()
+ : null;
+ }
+
+ @Override
+ public @NonNull RectF getWindowTargetRect() {
+ if (PROTOTYPE_APP_CLOSE.get()) {
+ // We want the target rect to be at this offset position, so that all
+ // launcher content can spring back upwards.
+ mFloatingView.setPositionOffsetY(mTransY);
+ }
+ return super.getWindowTargetRect();
+ }
+
+ @Override
+ public boolean shouldPlayAtomicWorkspaceReveal() {
+ return false;
+ }
+
+ @Override
+ public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress,
+ float radius) {
+ if (config != null && PROTOTYPE_APP_CLOSE.get()) {
+ DragLayer dl = mActivity.getDragLayer();
+ float translationY = config.getWorkspaceTransY();
+ dl.setTranslationY(translationY);
+
+ long duration = mWorkspaceReveal.getDuration();
+ long playTime = boundToRange(round(duration * progress), 0, duration);
+ mWorkspaceReveal.setCurrentPlayTime(playTime);
+ }
+ }
+
+ protected void bounceBackToRestingPosition() {
+ final float startValue = mTransY;
+ final float endValue = 0;
+ // Ensures the velocity is always aligned with the direction.
+ float pixelPerSecond = Math.abs(mSwipeVelocity) * Math.signum(endValue - mTransY);
+
+ DragLayer dl = mActivity.getDragLayer();
+ Workspace workspace = mActivity.getWorkspace();
+ Hotseat hotseat = mActivity.getHotseat();
+
+ ResourceProvider rp = DynamicResource.provider(mActivity);
+ ValueAnimator springTransY = new SpringAnimationBuilder(dl.getContext())
+ .setStiffness(rp.getFloat(R.dimen.swipe_up_trans_y_stiffness))
+ .setDampingRatio(rp.getFloat(R.dimen.swipe_up_trans_y_damping))
+ .setMinimumVisibleChange(1f)
+ .setStartValue(startValue)
+ .setEndValue(endValue)
+ .setStartVelocity(pixelPerSecond)
+ .build(dl, VIEW_TRANSLATE_Y);
+ springTransY.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ dl.setTranslationY(0f);
+ dl.setAlpha(1f);
+ SCALE_PROPERTY.set(workspace, 1f);
+ SCALE_PROPERTY.set(hotseat, 1f);
+ }
+ });
+
+ mBounceBackAnimator = springTransY;
+ mBounceBackAnimator.start();
+ }
+
+ @Override
+ public void setAnimation(RectFSpringAnim anim) {
+ if (PROTOTYPE_APP_CLOSE.get()) {
+ // Use a spring to put drag layer translation back to 0.
+ anim.addAnimatorListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mFloatingView.setPositionOffsetY(0);
+ bounceBackToRestingPosition();
+ }
+ });
+
+ // Will be updated manually below so that the two animations are in sync.
+ mWorkspaceReveal.start();
+ mWorkspaceReveal.pause();
+
+ anim.addAnimatorListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mWorkspaceReveal.end();
+ }
+ });
+ }
+ }
+
+ @Override
+ public void onCancel() {
+ mFloatingView.fastFinish();
+ if (mBounceBackAnimator != null) {
+ mBounceBackAnimator.cancel();
+ }
+ }
+ }
+
private class LauncherHomeAnimationFactory extends HomeAnimationFactory {
@NonNull
@Override
@@ -336,8 +381,12 @@
@Override
public void playAtomicAnimation(float velocity) {
- new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */,
- !PROTOTYPE_APP_CLOSE.get()).start();
+ if (!PROTOTYPE_APP_CLOSE.get()) {
+ new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */)
+ .start();
+ } else if (shouldPlayAtomicWorkspaceReveal()) {
+ new WorkspaceRevealAnim(mActivity, true).start();
+ }
}
@Override
diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
index 29a00d1..b79e934 100644
--- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
+++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
@@ -129,6 +129,7 @@
}
protected abstract class HomeAnimationFactory {
+ protected float mSwipeVelocity;
public @NonNull RectF getWindowTargetRect() {
PagedOrientationHandler orientationHandler = getOrientationHandler();
@@ -152,10 +153,18 @@
public abstract @NonNull AnimatorPlaybackController createActivityAnimationToHome();
+ public void setSwipeVelocity(float velocity) {
+ mSwipeVelocity = velocity;
+ }
+
public void playAtomicAnimation(float velocity) {
// No-op
}
+ public boolean shouldPlayAtomicWorkspaceReveal() {
+ return true;
+ }
+
public void setAnimation(RectFSpringAnim anim) { }
public boolean keepWindowOpaque() { return false; }
diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
index 76f43c9..6f681b3 100644
--- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
@@ -45,8 +45,8 @@
private static final String LOG_TAG = "AllSetActivity";
private static final String URI_SYSTEM_NAVIGATION_SETTING =
"#Intent;action=com.android.settings.SEARCH_RESULT_TRAMPOLINE;S.:settings:fragment_args_key=gesture_system_navigation_input_summary;S.:settings:show_fragment=com.android.settings.gestures.SystemNavigationGestureSettings;end";
- private static final String EXTRA_ACCENT_COLOR_DARK_MODE = "accent_color_dark_mode";
- private static final String EXTRA_ACCENT_COLOR_LIGHT_MODE = "accent_color_light_mode";
+ private static final String EXTRA_ACCENT_COLOR_DARK_MODE = "suwColorAccentDark";
+ private static final String EXTRA_ACCENT_COLOR_LIGHT_MODE = "suwColorAccentLight";
private int mAccentColor;
diff --git a/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java b/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java
index 10b7662..badb41a 100644
--- a/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java
+++ b/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java
@@ -30,7 +30,7 @@
/**
* Runs an animation from overview to home. Currently, this animation is just a wrapper around the
- * normal state transition and may play a {@link StaggeredWorkspaceAnim} if we're starting from an
+ * normal state transition and may play a {@link WorkspaceRevealAnim} if we're starting from an
* upward fling.
*/
public class OverviewToHomeAnim {
@@ -51,7 +51,7 @@
/**
* Starts the animation. If velocity < 0 (i.e. upwards), also plays a
- * {@link StaggeredWorkspaceAnim}.
+ * {@link WorkspaceRevealAnim}.
*/
public void animateWithVelocity(float velocity) {
StateManager<LauncherState> stateManager = mLauncher.getStateManager();
@@ -61,18 +61,18 @@
}
AnimatorSet anim = new AnimatorSet();
- boolean playStaggeredWorkspaceAnim = velocity < 0;
- if (playStaggeredWorkspaceAnim) {
- StaggeredWorkspaceAnim staggeredWorkspaceAnim = new StaggeredWorkspaceAnim(
- mLauncher, velocity, false /* animateOverviewScrim */);
- staggeredWorkspaceAnim.addAnimatorListener(new AnimationSuccessListener() {
+ boolean playWorkspaceRevealAnim = velocity < 0;
+ if (playWorkspaceRevealAnim) {
+ WorkspaceRevealAnim workspaceRevealAnim = new WorkspaceRevealAnim(mLauncher,
+ false /* animateOverviewScrim */);
+ workspaceRevealAnim.addAnimatorListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
mIsHomeStaggeredAnimFinished = true;
maybeOverviewToHomeAnimComplete();
}
});
- anim.play(staggeredWorkspaceAnim.getAnimators());
+ anim.play(workspaceRevealAnim.getAnimators());
} else {
mIsHomeStaggeredAnimFinished = true;
}
diff --git a/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java b/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java
new file mode 100644
index 0000000..50da93b
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.quickstep.util;
+
+import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
+import static com.android.launcher3.LauncherState.BACKGROUND_APP;
+import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
+import static com.android.launcher3.states.StateAnimationConfig.SKIP_DEPTH_CONTROLLER;
+import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
+import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM;
+
+import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
+import android.view.View;
+
+import com.android.launcher3.BaseQuickstepLauncher;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
+import com.android.launcher3.Workspace;
+import com.android.launcher3.anim.Interpolators;
+import com.android.launcher3.anim.PendingAnimation;
+import com.android.launcher3.statehandlers.DepthController;
+import com.android.launcher3.states.StateAnimationConfig;
+import com.android.launcher3.util.DynamicResource;
+import com.android.quickstep.views.RecentsView;
+import com.android.systemui.plugins.ResourceProvider;
+
+/**
+ * Creates an animation that reveals the workspace.
+ * This is used in conjunction with the swipe up to home animation.
+ */
+public class WorkspaceRevealAnim {
+
+ // Should be used for animations running alongside this WorkspaceRevealAnim.
+ public static final int DURATION_MS = 350;
+
+ private final float mScaleStart;
+ private final AnimatorSet mAnimators = new AnimatorSet();
+
+ public WorkspaceRevealAnim(Launcher launcher, boolean animateOverviewScrim) {
+ prepareToAnimate(launcher, animateOverviewScrim);
+
+ ResourceProvider rp = DynamicResource.provider(launcher);
+ mScaleStart = rp.getFloat(R.dimen.swipe_up_scale_start);
+
+ Workspace workspace = launcher.getWorkspace();
+ workspace.setPivotToScaleWithSelf(launcher.getHotseat());
+
+ // Add reveal animations.
+ addRevealAnimatorsForView(workspace);
+ addRevealAnimatorsForView(launcher.getHotseat());
+
+ // Add overview scrim animation.
+ if (animateOverviewScrim) {
+ PendingAnimation overviewScrimBuilder = new PendingAnimation(DURATION_MS);
+ launcher.getWorkspace().getStateTransitionAnimation()
+ .setScrim(overviewScrimBuilder, NORMAL, new StateAnimationConfig());
+ mAnimators.play(overviewScrimBuilder.buildAnim());
+ }
+
+ // Add depth controller animation.
+ if (launcher instanceof BaseQuickstepLauncher) {
+ PendingAnimation depthBuilder = new PendingAnimation(DURATION_MS);
+ DepthController depth = ((BaseQuickstepLauncher) launcher).getDepthController();
+ depth.setStateWithAnimation(NORMAL, new StateAnimationConfig(), depthBuilder);
+ mAnimators.play(depthBuilder.buildAnim());
+ }
+
+ // Add sysui scrim animation.
+ mAnimators.play(launcher.getRootView().getSysUiScrim().createSysuiMultiplierAnim(0f, 1f));
+
+ mAnimators.setDuration(DURATION_MS);
+ mAnimators.setInterpolator(Interpolators.DECELERATED_EASE);
+ }
+
+ private void addRevealAnimatorsForView(View v) {
+ ObjectAnimator scale = ObjectAnimator.ofFloat(v, SCALE_PROPERTY, mScaleStart, 1f);
+ scale.setDuration(DURATION_MS);
+ scale.setInterpolator(Interpolators.DECELERATED_EASE);
+ mAnimators.play(scale);
+
+ ObjectAnimator alpha = ObjectAnimator.ofFloat(v, View.ALPHA, 0, 1f);
+ alpha.setDuration(DURATION_MS);
+ alpha.setInterpolator(Interpolators.DECELERATED_EASE);
+ mAnimators.play(alpha);
+ }
+
+ /**
+ * Setup workspace with 0 duration.
+ */
+ private void prepareToAnimate(Launcher launcher, boolean animateOverviewScrim) {
+ StateAnimationConfig config = new StateAnimationConfig();
+ config.animFlags = SKIP_OVERVIEW | SKIP_DEPTH_CONTROLLER | SKIP_SCRIM;
+ config.duration = 0;
+ // setRecentsAttachedToAppWindow() will animate recents out.
+ launcher.getStateManager().createAtomicAnimation(BACKGROUND_APP, NORMAL, config).start();
+
+ // Stop scrolling so that it doesn't interfere with the translation offscreen.
+ launcher.<RecentsView>getOverviewPanel().getScroller().forceFinished(true);
+
+ if (animateOverviewScrim) {
+ launcher.getWorkspace().getStateTransitionAnimation()
+ .setScrim(NO_ANIM_PROPERTY_SETTER, BACKGROUND_APP, config);
+ }
+ }
+
+ public AnimatorSet getAnimators() {
+ return mAnimators;
+ }
+
+ public WorkspaceRevealAnim addAnimatorListener(Animator.AnimatorListener listener) {
+ mAnimators.addListener(listener);
+ return this;
+ }
+
+ /**
+ * Starts the animation.
+ */
+ public void start() {
+ mAnimators.start();
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
index 121e094..0012dd8 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
@@ -34,6 +34,7 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.views.FloatingView;
import com.android.launcher3.views.ListenerView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.RoundedCornerEnforcement;
@@ -41,7 +42,7 @@
/** A view that mimics an App Widget through a launch animation. */
@TargetApi(Build.VERSION_CODES.S)
public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
- OnGlobalLayoutListener {
+ OnGlobalLayoutListener, FloatingView {
private static final Matrix sTmpMatrix = new Matrix();
private final Launcher mLauncher;
@@ -59,6 +60,8 @@
private Runnable mOnTargetChangeRunnable;
private boolean mAppTargetIsTranslucent;
+ private float mIconOffsetY;
+
public FloatingWidgetView(Context context) {
this(context, null);
}
@@ -129,6 +132,7 @@
}
/** Callback at the end or early exit of the animation. */
+ @Override
public void fastFinish() {
if (isUninitialized()) return;
Runnable fastFinishRunnable = mFastFinishRunnable;
@@ -192,6 +196,12 @@
positionViews();
}
+ @Override
+ public void setPositionOffsetY(float y) {
+ mIconOffsetY = y;
+ onGlobalLayout();
+ }
+
/** Sets the layout parameters of the floating view and its background view child. */
private void positionViews() {
LayoutParams layoutParams = (LayoutParams) getLayoutParams();
@@ -200,7 +210,7 @@
// FloatingWidgetView layout is forced LTR
mBackgroundView.setTranslationX(mBackgroundPosition.left);
- mBackgroundView.setTranslationY(mBackgroundPosition.top);
+ mBackgroundView.setTranslationY(mBackgroundPosition.top + mIconOffsetY);
LayoutParams backgroundParams = (LayoutParams) mBackgroundView.getLayoutParams();
backgroundParams.leftMargin = 0;
backgroundParams.topMargin = 0;
@@ -215,7 +225,8 @@
sTmpMatrix.setTranslate(-mBackgroundOffset.left - mAppWidgetView.getLeft(),
-mBackgroundOffset.top - mAppWidgetView.getTop());
sTmpMatrix.postScale(foregroundScale, foregroundScale);
- sTmpMatrix.postTranslate(mBackgroundPosition.left, mBackgroundPosition.top);
+ sTmpMatrix.postTranslate(mBackgroundPosition.left, mBackgroundPosition.top
+ + mIconOffsetY);
mForegroundOverlayView.setMatrix(sTmpMatrix);
}
}
@@ -240,6 +251,7 @@
}
private void recycle() {
+ mIconOffsetY = 0;
mEndRunnable = null;
mFastFinishRunnable = null;
mOnTargetChangeRunnable = null;
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 7cd2a6a..4cdae27 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -32,11 +32,12 @@
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.anim.Interpolators.ACCEL;
+import static com.android.launcher3.anim.Interpolators.ACCEL_0_5;
import static com.android.launcher3.anim.Interpolators.ACCEL_0_75;
-import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
+import static com.android.launcher3.anim.Interpolators.clampToProgress;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_CLEAR_ALL;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_DISMISS_SWIPE_UP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN;
@@ -336,6 +337,11 @@
// OverScroll constants
private static final int OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION = 270;
+ private static final int DISMISS_TASK_DURATION = 300;
+ private static final int ADDITION_TASK_DURATION = 200;
+ private static final float INITIAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET = 0.55f;
+ private static final float ADDITIONAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET = 0.05f;
+
protected final RecentsOrientedState mOrientationState;
protected final BaseActivityInterface<STATE_TYPE, ACTIVITY_TYPE> mSizeStrategy;
protected RecentsAnimationController mRecentsAnimationController;
@@ -358,10 +364,6 @@
private final List<OnScrollChangedListener> mScrollListeners = new ArrayList<>();
private float mFullscreenScale;
- private static final int DISMISS_TASK_DURATION = 300;
- private static final int DISMISS_TASK_TRANSLATION_DURATION = 200;
- private static final int ADDITIONAL_DISMISS_TASK_TRANSLATION_DURATION = 75;
- private static final int ADDITION_TASK_DURATION = 200;
// The threshold at which we update the SystemUI flags when animating from the task into the app
public static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.85f;
@@ -1886,21 +1888,18 @@
* This method is used when no task dismissal has occurred.
*/
private void updateGridProperties() {
- updateGridProperties(null, -1);
+ updateGridProperties(false);
}
/**
* Updates TaskView and ClearAllButton scaling and translation required to turn into grid
* layout.
* This method only calculates the potential position and depends on {@link #setGridProgress} to
- * apply the actual scaling and translation. This adds task translation animations in the case
- * of task dismissals: e.g. when dismissedTask is not null.
+ * apply the actual scaling and translation.
*
- * @param dismissedTask the TaskView dismissed, possibly null
- * @param dismissedIndex the index at which the dismissedTask was prior to dismissal, if no
- * dismissal occurred, this is unused
+ * @param isTaskDismissal indicates if update was called due to task dismissal
*/
- private void updateGridProperties(TaskView dismissedTask, int dismissedIndex) {
+ private void updateGridProperties(boolean isTaskDismissal) {
int taskCount = getTaskViewCount();
if (taskCount == 0) {
return;
@@ -1940,10 +1939,6 @@
int snappedPage = getNextPage();
TaskView snappedTaskView = getTaskViewAtByAbsoluteIndex(snappedPage);
- boolean isTaskDismissal = dismissedTask != null;
- float dismissedTaskWidth =
- isTaskDismissal ? dismissedTask.getLayoutParams().width + mPageSpacing : 0;
-
if (!isTaskDismissal) {
mTopRowIdSet.clear();
}
@@ -2039,34 +2034,13 @@
snappedTaskGridTranslationX = gridTranslations[snappedPage - mTaskViewStartIndex];
}
- // Animate task dismissTranslationX for tasks with index >= dismissed index and in the
- // same row as the dismissed index, or if the dismissed task was the focused task. Offset
- // successive task dismissal durations for a staggered effect.
- ArrayList<Animator> gridTranslationAnimators = new ArrayList<>();
- boolean isFocusedTaskDismissed =
- isTaskDismissal && dismissedTask.getTask().key.id == mFocusedTaskId;
for (int i = 0; i < taskCount; i++) {
TaskView taskView = getTaskViewAt(i);
- if (isFocusedTaskDismissed || (i >= dismissedIndex && isSameGridRow(dismissedTask,
- taskView))) {
- Animator taskDismissAnimator = ObjectAnimator.ofFloat(taskView,
- taskView.getPrimaryDismissTranslationProperty(),
- mIsRtl ? -dismissedTaskWidth : dismissedTaskWidth, 0f);
- int additionalTranslationDuration =
- i >= dismissedIndex ? (ADDITIONAL_DISMISS_TASK_TRANSLATION_DURATION * (
- (i - dismissedIndex) / 2)) : 0;
- taskDismissAnimator.setDuration(
- DISMISS_TASK_TRANSLATION_DURATION + additionalTranslationDuration);
- gridTranslationAnimators.add(taskDismissAnimator);
- }
taskView.setGridTranslationX(gridTranslations[i] - snappedTaskGridTranslationX);
taskView.getPrimaryNonFullscreenTranslationProperty().set(taskView,
snappedTaskFullscreenScrollAdjustment);
taskView.getSecondaryNonFullscreenTranslationProperty().set(taskView, 0f);
}
- AnimatorSet gridTranslationAnimatorSet = new AnimatorSet();
- gridTranslationAnimatorSet.playTogether(gridTranslationAnimators);
- gridTranslationAnimatorSet.start();
// Use the accumulated translation of the row containing the last task.
float clearAllAccumulatedTranslation = topSet.contains(taskCount - 1)
@@ -2210,7 +2184,7 @@
PendingAnimation anim) {
// Use setFloat instead of setViewAlpha as we want to keep the view visible even when it's
// alpha is set to 0 so that it can be recycled in the view pool properly
- anim.setFloat(taskView, VIEW_ALPHA, 0, ACCEL_2);
+ anim.setFloat(taskView, VIEW_ALPHA, 0, clampToProgress(ACCEL, 0, 0.5f));
SplitSelectStateController splitController = mSplitPlaceholderView.getSplitController();
ResourceProvider rp = DynamicResource.provider(mActivity);
@@ -2246,8 +2220,10 @@
throw new IllegalStateException("Invalid split task translation: " + dir);
}
}
+ // Double translation distance so dismissal drag is the full height, as we only animate
+ // the drag for the first half of the progress.
anim.add(ObjectAnimator.ofFloat(taskView, dismissingTaskViewTranslate,
- positiveNegativeFactor * translateDistance).setDuration(duration), LINEAR, sp);
+ positiveNegativeFactor * translateDistance * 2).setDuration(duration), LINEAR, sp);
if (LIVE_TILE.get() && taskView.isRunningTask()) {
anim.addOnFrameCallback(() -> {
@@ -2283,6 +2259,11 @@
}
int draggedIndex = indexOfChild(taskView);
+ boolean isFocusedTaskDismissed = taskView.getTask().key.id == mFocusedTaskId;
+ if (isFocusedTaskDismissed && showAsGrid()) {
+ anim.setFloat(mActionsView, VIEW_ALPHA, 0, clampToProgress(ACCEL_0_5, 0, 0.5f));
+ }
+ float dismissedTaskWidth = taskView.getLayoutParams().width + mPageSpacing;
boolean needsCurveUpdates = false;
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
@@ -2291,7 +2272,7 @@
addDismissedTaskAnimations(taskView, duration, anim);
}
} else if (!showAsGrid()) {
- // For grid layout, don't animate other tasks when dismissing in grid for now.
+ // Compute scroll offsets from task dismissal for animation.
// If we just take newScroll - oldScroll, everything to the right of dragged task
// translates to the left. We need to offset this in some cases:
// - In RTL, add page offset to all pages, since we want pages to move to the right
@@ -2318,15 +2299,31 @@
? ((TaskView) child).getPrimaryDismissTranslationProperty()
: mOrientationHandler.getPrimaryViewTranslate();
- ResourceProvider rp = DynamicResource.provider(mActivity);
- SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_END)
- .setDampingRatio(
- rp.getFloat(R.dimen.dismiss_task_trans_x_damping_ratio))
- .setStiffness(rp.getFloat(R.dimen.dismiss_task_trans_x_stiffness));
- anim.add(ObjectAnimator.ofFloat(child, translationProperty, scrollDiff)
- .setDuration(duration), ACCEL, sp);
+ float additionalDismissDuration =
+ ADDITIONAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET * Math.abs(
+ i - draggedIndex);
+ anim.setFloat(child, translationProperty, scrollDiff, clampToProgress(LINEAR,
+ Utilities.boundToRange(INITIAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
+ + additionalDismissDuration, 0f, 1f), 1));
needsCurveUpdates = true;
}
+ } else if (child instanceof TaskView) {
+ // Animate task with index >= dismissed index and in the same row as the
+ // dismissed index, or if the dismissed task was the focused task. Offset
+ // successive task dismissal durations for a staggered effect.
+ if (isFocusedTaskDismissed || (i >= draggedIndex && isSameGridRow((TaskView) child,
+ taskView))) {
+ FloatProperty translationProperty =
+ ((TaskView) child).getPrimaryDismissTranslationProperty();
+ float additionalDismissDuration =
+ ADDITIONAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET * Math.abs(
+ i - draggedIndex);
+ anim.setFloat(child, translationProperty,
+ !mIsRtl ? -dismissedTaskWidth : dismissedTaskWidth,
+ clampToProgress(LINEAR, Utilities.boundToRange(
+ INITIAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
+ + additionalDismissDuration, 0f, 1f), 1));
+ }
}
}
@@ -2364,6 +2361,10 @@
}
}
+ // Reset task translations as they may have updated via animations in
+ // createTaskDismissAnimation
+ resetTaskVisuals();
+
int pageToSnapTo = mCurrentPage;
// Snap to start if focused task was dismissed, as after quick switch it could
// be at any page but the focused task always displays at the start.
@@ -2381,7 +2382,7 @@
} else {
snapToPageImmediately(pageToSnapTo);
// Grid got messed up, reapply.
- updateGridProperties(taskView, draggedIndex - mTaskViewStartIndex);
+ updateGridProperties(true);
if (showAsGrid() && getFocusedTaskView() == null
&& mActionsView.getVisibilityAlpha().getValue() == 1) {
animateActionsViewOut();
@@ -2391,9 +2392,6 @@
// immediately available.
onLayout(false /* changed */, getLeft(), getTop(), getRight(), getBottom());
}
- if (!showAsGrid()) {
- resetTaskVisuals();
- }
onDismissAnimationEnds();
mPendingAnimation = null;
}
@@ -2617,6 +2615,16 @@
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ if (LIVE_TILE.get()) {
+ switchToScreenshot(
+ () -> finishRecentsAnimation(true /* toRecents */,
+ this::onConfigurationChangedInternal));
+ } else {
+ onConfigurationChangedInternal();
+ }
+ }
+
+ private void onConfigurationChangedInternal() {
final int rotation = mActivity.getDisplay().getRotation();
if (mOrientationState.setRecentsRotation(rotation)) {
updateOrientationHandler();
@@ -3711,7 +3719,8 @@
return mColorTint;
}
- private boolean showAsGrid() {
+ /** Returns {@code true} if the overview tasks are displayed as a grid. */
+ public boolean showAsGrid() {
return mOverviewGridEnabled || (mCurrentGestureEndTarget != null
&& mSizeStrategy.stateFromGestureEndTarget(
mCurrentGestureEndTarget).displayOverviewTasksAsGrid(mActivity.getDeviceProfile()));
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index 32cd367..bff1013 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -215,6 +215,7 @@
RecentsView recentsView = mTaskView.getRecentsView();
recentsView.switchToScreenshot(null,
() -> recentsView.finishRecentsAnimation(true /* toRecents */,
+ false /* shouldPip */,
() -> menuOption.onClick(view)));
} else {
menuOption.onClick(view);
diff --git a/res/drawable/personal_work_tabs_ripple.xml b/res/drawable/personal_work_tabs_ripple.xml
new file mode 100644
index 0000000..2e57b80
--- /dev/null
+++ b/res/drawable/personal_work_tabs_ripple.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:attr/colorControlHighlight">
+ <shape android:shape="rectangle">
+ <solid android:color="@android:color/transparent" />
+ <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+ </shape>
+</ripple>
\ No newline at end of file
diff --git a/res/layout/all_apps_personal_work_tabs.xml b/res/layout/all_apps_personal_work_tabs.xml
index 750e101..31fa5cf 100644
--- a/res/layout/all_apps_personal_work_tabs.xml
+++ b/res/layout/all_apps_personal_work_tabs.xml
@@ -32,7 +32,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
- android:background="?android:attr/selectableItemBackground"
+ android:background="@drawable/personal_work_tabs_ripple"
android:text="@string/all_apps_personal_tab"
android:textColor="@color/all_apps_tab_text"
android:textSize="16sp" />
@@ -42,7 +42,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
- android:background="?android:attr/selectableItemBackground"
+ android:background="@drawable/personal_work_tabs_ripple"
android:text="@string/all_apps_work_tab"
android:textColor="@color/all_apps_tab_text"
android:textSize="16sp" />
diff --git a/res/layout/widgets_personal_work_tabs.xml b/res/layout/widgets_personal_work_tabs.xml
index f835b52..72d83e8 100644
--- a/res/layout/widgets_personal_work_tabs.xml
+++ b/res/layout/widgets_personal_work_tabs.xml
@@ -22,6 +22,7 @@
android:layout_height="@dimen/all_apps_header_pill_height"
android:layout_marginHorizontal="16dp"
android:orientation="horizontal"
+ android:background="@drawable/all_apps_tabs_background"
android:elevation="2dp"
style="@style/TextHeadline">
@@ -30,7 +31,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
- android:background="?android:attr/selectableItemBackground"
+ android:background="@drawable/personal_work_tabs_ripple"
android:text="@string/widgets_full_sheet_personal_tab"
android:textColor="@color/all_apps_tab_text"
android:textSize="14sp" />
@@ -40,7 +41,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
- android:background="?android:attr/selectableItemBackground"
+ android:background="@drawable/personal_work_tabs_ripple"
android:text="@string/widgets_full_sheet_work_tab"
android:textColor="@color/all_apps_tab_text"
android:textSize="14sp" />
diff --git a/res/values/config.xml b/res/values/config.xml
index 102d4e0..77c7e98 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -126,7 +126,7 @@
<item name="swipe_up_rect_xy_fling_friction" type="dimen" format="float">1.5</item>
- <item name="swipe_up_scale_start" type="dimen" format="float">0.98</item>
+ <item name="swipe_up_scale_start" type="dimen" format="float">0.88</item>
<item name="swipe_up_duration" type="dimen" format="float">400</item>
<item name="swipe_up_trans_y_dp" type="dimen" format="float">4.5</item>
diff --git a/res/values/id.xml b/res/values/id.xml
index 39c49bd..1bd40ce 100644
--- a/res/values/id.xml
+++ b/res/values/id.xml
@@ -15,6 +15,7 @@
limitations under the License.
-->
<resources>
+ <item type="id" name="apps_list_view_work" />
<item type="id" name="view_type_widgets_list" />
<item type="id" name="view_type_widgets_header" />
<item type="id" name="view_type_widgets_search_header" />
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 3fdcea5..1620d08 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -30,11 +30,13 @@
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
+import android.os.Parcelable;
import android.os.Process;
import android.text.Selection;
import android.text.SpannableStringBuilder;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -133,6 +135,7 @@
private int mHeaderColor;
+
public AllAppsContainerView(Context context) {
this(context, null);
}
@@ -169,6 +172,19 @@
mAllAppsStore.addUpdateListener(this::onAppsUpdated);
}
+ @Override
+ protected void dispatchRestoreInstanceState(SparseArray<Parcelable> sparseArray) {
+ try {
+ // Many slice view id is not properly assigned, and hence throws null
+ // pointer exception in the underneath method. Catching the exception
+ // simply doesn't restore these slice views. This doesn't have any
+ // user visible effect because because we query them again.
+ super.dispatchRestoreInstanceState(sparseArray);
+ } catch (Exception e) {
+ Log.e("AllAppsContainerView", "restoreInstanceState viewId = 0", e);
+ }
+ }
+
/**
* Sets the long click listener for icons
*/
@@ -436,6 +452,7 @@
setupWorkToggle();
mAH[AdapterHolder.MAIN].setup(mViewPager.getChildAt(0), mPersonalMatcher);
mAH[AdapterHolder.WORK].setup(mViewPager.getChildAt(1), mWorkMatcher);
+ mAH[AdapterHolder.WORK].recyclerView.setId(R.id.apps_list_view_work);
mViewPager.getPageIndicator().setActiveMarker(AdapterHolder.MAIN);
findViewById(R.id.tab_personal)
.setOnClickListener((View view) -> {
diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java
index 9d73bba..1e7b224 100644
--- a/src/com/android/launcher3/anim/Interpolators.java
+++ b/src/com/android/launcher3/anim/Interpolators.java
@@ -35,6 +35,7 @@
public static final Interpolator LINEAR = new LinearInterpolator();
public static final Interpolator ACCEL = new AccelerateInterpolator();
+ public static final Interpolator ACCEL_0_5 = new AccelerateInterpolator(0.5f);
public static final Interpolator ACCEL_0_75 = new AccelerateInterpolator(0.75f);
public static final Interpolator ACCEL_1_5 = new AccelerateInterpolator(1.5f);
public static final Interpolator ACCEL_2 = new AccelerateInterpolator(2);
@@ -149,11 +150,15 @@
*/
public static Interpolator clampToProgress(Interpolator interpolator, float lowerBound,
float upperBound) {
- if (upperBound <= lowerBound) {
- throw new IllegalArgumentException(String.format(
- "lowerBound (%f) must be less than upperBound (%f)", lowerBound, upperBound));
+ if (upperBound < lowerBound) {
+ throw new IllegalArgumentException(
+ String.format("upperBound (%f) must be greater than lowerBound (%f)",
+ upperBound, lowerBound));
}
return t -> {
+ if (t == lowerBound && t == upperBound) {
+ return t == 0f ? 0 : 1;
+ }
if (t < lowerBound) {
return 0;
}
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 81581fa..f973c2b 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -63,7 +63,7 @@
*/
@TargetApi(Build.VERSION_CODES.Q)
public class FloatingIconView extends FrameLayout implements
- Animator.AnimatorListener, OnGlobalLayoutListener {
+ Animator.AnimatorListener, OnGlobalLayoutListener, FloatingView {
private static final String TAG = FloatingIconView.class.getSimpleName();
@@ -443,6 +443,7 @@
mFastFinishRunnable = runnable;
}
+ @Override
public void fastFinish() {
if (mFastFinishRunnable != null) {
mFastFinishRunnable.run();
@@ -475,9 +476,7 @@
@Override
public void onAnimationRepeat(Animator animator) {}
- /**
- * Offsets and updates the position of this view by {@param y}.
- */
+ @Override
public void setPositionOffsetY(float y) {
mIconOffsetY = y;
onGlobalLayout();
diff --git a/src/com/android/launcher3/views/FloatingView.java b/src/com/android/launcher3/views/FloatingView.java
new file mode 100644
index 0000000..ea4fd15
--- /dev/null
+++ b/src/com/android/launcher3/views/FloatingView.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.views;
+
+/**
+ * Shared interface for floating views.
+ */
+public interface FloatingView {
+
+ /**
+ * Offsets and updates the position of this view by {@param y}.
+ */
+ void setPositionOffsetY(float y);
+
+ /**
+ * Fast finish the animation.
+ */
+ void fastFinish();
+}