Handle page offset for grid overview

- Use TaskView's actual position with grid/fullscreen translation considered for taskPosition calculation
- Shift taskPosition by midpoint scroll, and no longer assumes midpoint is on middle of the screen
- Handle situation that TaskView is on left/right of midpoint, making the calculation generic to be able to handle grid situation

Bug: 175939487
Test: Launch modal view with wide/, RTL/non-RTL, orientation/simulated landscape combinations
Change-Id: Idd0cc9c5e24f453d830e1420319a38d3d784270d
This commit is contained in:
Alex Chau
2021-04-13 21:59:42 +01:00
parent def4ff1570
commit 9594c6987f
5 changed files with 150 additions and 46 deletions
@@ -987,20 +987,30 @@ public class TaskView extends FrameLayout implements Reusable {
private void applyTranslationX() {
setTranslationX(mDismissTranslationX + mTaskOffsetTranslationX + mTaskResistanceTranslationX
+ getFullscreenTrans(mFullscreenTranslationX)
+ getNonFullscreenTrans(mNonFullscreenTranslationX)
+ getGridTrans(mGridTranslationX));
+ getPersistentTranslationX());
}
private void applyTranslationY() {
setTranslationY(
mDismissTranslationY + mTaskOffsetTranslationY + mTaskResistanceTranslationY
+ getGridTrans(mGridTranslationY) + mBoxTranslationY);
setTranslationY(mDismissTranslationY + mTaskOffsetTranslationY + mTaskResistanceTranslationY
+ getPersistentTranslationY());
}
private float getGridTrans(float endTranslation) {
float progress = ACCEL_DEACCEL.getInterpolation(mGridProgress);
return Utilities.mapRange(progress, 0, endTranslation);
/**
* Returns addition of translationX that is persistent (e.g. fullscreen and grid), and does not
* change according to a temporary state (e.g. task offset).
*/
public float getPersistentTranslationX() {
return getFullscreenTrans(mFullscreenTranslationX)
+ getNonFullscreenTrans(mNonFullscreenTranslationX)
+ getGridTrans(mGridTranslationX);
}
/**
* Returns addition of translationY that is persistent (e.g. fullscreen and grid), and does not
* change according to a temporary state (e.g. task offset).
*/
public float getPersistentTranslationY() {
return getGridTrans(mGridTranslationY) + mBoxTranslationY;
}
public FloatProperty<TaskView> getPrimaryDismissTranslationProperty() {
@@ -1275,6 +1285,11 @@ public class TaskView extends FrameLayout implements Reusable {
return endTranslation - getFullscreenTrans(endTranslation);
}
private float getGridTrans(float endTranslation) {
float progress = ACCEL_DEACCEL.getInterpolation(mGridProgress);
return Utilities.mapRange(progress, 0, endTranslation);
}
public boolean isRunningTask() {
if (getRecentsView() == null) {
return false;