Animate scrolling grid into place when there is a gap between last tasks

and clear all.

- Stagger animation starts
- Adds a grid translation property to TaskView for animating these
translations.

Also fixes an issue where the gap between clear all and focused task is
greater than spacing between grid tasks and clear all.

Test: manual
Fix: 188793333
Change-Id: Ib2ba8b1b84dc63c4ba186bd0b9b4962d3c66ce5a
This commit is contained in:
Pat Manning
2021-08-06 14:24:56 +00:00
committed by Alex Chau
parent 8bcbb662bb
commit 96dad8b039
3 changed files with 244 additions and 46 deletions
@@ -343,6 +343,19 @@ public class TaskView extends FrameLayout implements Reusable {
}
};
public static final FloatProperty<TaskView> GRID_END_TRANSLATION_X =
new FloatProperty<TaskView>("gridEndTranslationX") {
@Override
public void setValue(TaskView taskView, float v) {
taskView.setGridEndTranslationX(v);
}
@Override
public Float get(TaskView taskView) {
return taskView.mGridEndTranslationX;
}
};
public static final FloatProperty<TaskView> SNAPSHOT_SCALE =
new FloatProperty<TaskView>("snapshotScale") {
@Override
@@ -381,6 +394,8 @@ public class TaskView extends FrameLayout implements Reusable {
// The following grid translations scales with mGridProgress.
private float mGridTranslationX;
private float mGridTranslationY;
// The following grid translation is used to animate closing the gap between grid and clear all.
private float mGridEndTranslationX;
// Applied as a complement to gridTranslation, for adjusting the carousel overview and quick
// switch.
private float mNonGridTranslationX;
@@ -950,8 +965,8 @@ public class TaskView extends FrameLayout implements Reusable {
protected void resetViewTransforms() {
// fullscreenTranslation and accumulatedTranslation should not be reset, as
// resetViewTransforms is called during Quickswitch scrolling.
mDismissTranslationX = mTaskOffsetTranslationX = mTaskResistanceTranslationX =
mSplitSelectTranslationX = 0f;
mDismissTranslationX = mTaskOffsetTranslationX =
mTaskResistanceTranslationX = mSplitSelectTranslationX = mGridEndTranslationX = 0f;
mDismissTranslationY = mTaskOffsetTranslationY = mTaskResistanceTranslationY =
mSplitSelectTranslationY = 0f;
setSnapshotScale(1f);
@@ -1162,6 +1177,11 @@ public class TaskView extends FrameLayout implements Reusable {
return mGridTranslationY;
}
private void setGridEndTranslationX(float gridEndTranslationX) {
mGridEndTranslationX = gridEndTranslationX;
applyTranslationX();
}
public float getScrollAdjustment(boolean fullscreenEnabled, boolean gridEnabled) {
float scrollAdjustment = 0;
if (gridEnabled) {
@@ -1191,7 +1211,7 @@ public class TaskView extends FrameLayout implements Reusable {
private void applyTranslationX() {
setTranslationX(mDismissTranslationX + mTaskOffsetTranslationX + mTaskResistanceTranslationX
+ mSplitSelectTranslationX + getPersistentTranslationX());
+ mSplitSelectTranslationX + mGridEndTranslationX + getPersistentTranslationX());
}
private void applyTranslationY() {