From 5662a653da81d73f11578e4f9825c75717269a12 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 15 Jan 2021 09:02:22 -0800 Subject: [PATCH] Separate TaskView translationX into dismiss + offset translations - Previously, these both setTranslationX() directly, meaning one could clobber the other. Now they are set independently and aggregated to setTranslationX(). - For fake landscape, we actually are setting translationY, so had to create both translationX and translationY properties, and set the appropriate one via the current orientation handler's "primary" dimension. Fixes: 176766821 Change-Id: I204f039331dd43bbbf87bf6a2249238daf4d9877 --- .../android/quickstep/views/RecentsView.java | 11 ++- .../com/android/quickstep/views/TaskView.java | 99 +++++++++++++++++++ .../touch/LandscapePagedViewHandler.java | 4 +- .../touch/PagedOrientationHandler.java | 4 +- .../touch/PortraitPagedViewHandler.java | 4 +- 5 files changed, 113 insertions(+), 9 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 0130cae47b..23941fadc7 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -73,7 +73,6 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.AttributeSet; import android.util.FloatProperty; -import android.util.Property; import android.util.SparseBooleanArray; import android.view.HapticFeedbackConstants; import android.view.KeyEvent; @@ -1488,7 +1487,9 @@ public abstract class RecentsView extends PagedView } int scrollDiff = newScroll[i] - oldScroll[i] + offset; if (scrollDiff != 0) { - Property translationProperty = mOrientationHandler.getPrimaryViewTranslate(); + FloatProperty translationProperty = child instanceof TaskView + ? ((TaskView) child).getPrimaryFillDismissGapTranslationProperty() + : mOrientationHandler.getPrimaryViewTranslate(); ResourceProvider rp = DynamicResource.provider(mActivity); SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_END) @@ -1883,7 +1884,11 @@ public abstract class RecentsView extends PagedView ? modalLeftOffsetSize : modalRightOffsetSize; float totalTranslation = translation + modalTranslation; - mOrientationHandler.getPrimaryViewTranslate().set(getChildAt(i), + View child = getChildAt(i); + FloatProperty translationProperty = child instanceof TaskView + ? ((TaskView) child).getPrimaryTaskOffsetTranslationProperty() + : mOrientationHandler.getPrimaryViewTranslate(); + translationProperty.set(child, totalTranslation * mOrientationHandler.getPrimaryTranslationDirectionFactor()); } updateCurveProperties(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index 0bc6e5166f..a8f2a1cd0e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -153,6 +153,58 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { } }; + private static final FloatProperty FILL_DISMISS_GAP_TRANSLATION_X = + new FloatProperty("fillDismissGapTranslationX") { + @Override + public void setValue(TaskView taskView, float v) { + taskView.setFillDismissGapTranslationX(v); + } + + @Override + public Float get(TaskView taskView) { + return taskView.mFillDismissGapTranslationX; + } + }; + + private static final FloatProperty FILL_DISMISS_GAP_TRANSLATION_Y = + new FloatProperty("fillDismissGapTranslationY") { + @Override + public void setValue(TaskView taskView, float v) { + taskView.setFillDismissGapTranslationY(v); + } + + @Override + public Float get(TaskView taskView) { + return taskView.mFillDismissGapTranslationY; + } + }; + + private static final FloatProperty TASK_OFFSET_TRANSLATION_X = + new FloatProperty("taskOffsetTranslationX") { + @Override + public void setValue(TaskView taskView, float v) { + taskView.setTaskOffsetTranslationX(v); + } + + @Override + public Float get(TaskView taskView) { + return taskView.mTaskOffsetTranslationX; + } + }; + + private static final FloatProperty TASK_OFFSET_TRANSLATION_Y = + new FloatProperty("taskOffsetTranslationY") { + @Override + public void setValue(TaskView taskView, float v) { + taskView.setTaskOffsetTranslationY(v); + } + + @Override + public Float get(TaskView taskView) { + return taskView.mTaskOffsetTranslationY; + } + }; + private final OnAttachStateChangeListener mTaskMenuStateListener = new OnAttachStateChangeListener() { @Override @@ -180,6 +232,13 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { private final FullscreenDrawParams mCurrentFullscreenParams; private final BaseDraggingActivity mActivity; + // Various causes of changing primary translation, which we aggregate to setTranslationX/Y(). + // TODO: We should do this for secondary translation properties as well. + private float mFillDismissGapTranslationX; + private float mFillDismissGapTranslationY; + private float mTaskOffsetTranslationX; + private float mTaskOffsetTranslationY; + private ObjectAnimator mIconAndDimAnimator; private float mIconScaleAnimStartProgress = 0; private float mFocusTransitionProgress = 1; @@ -619,6 +678,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { protected void resetViewTransforms() { setCurveScale(1); + mFillDismissGapTranslationX = mTaskOffsetTranslationX = 0f; + mFillDismissGapTranslationY = mTaskOffsetTranslationY = 0f; setTranslationX(0f); setTranslationY(0f); setTranslationZ(0); @@ -835,6 +896,44 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { return mCurveScale; } + private void setFillDismissGapTranslationX(float x) { + mFillDismissGapTranslationX = x; + applyTranslationX(); + } + + private void setFillDismissGapTranslationY(float y) { + mFillDismissGapTranslationY = y; + applyTranslationY(); + } + + private void setTaskOffsetTranslationX(float x) { + mTaskOffsetTranslationX = x; + applyTranslationX(); + } + + private void setTaskOffsetTranslationY(float y) { + mTaskOffsetTranslationY = y; + applyTranslationY(); + } + + private void applyTranslationX() { + setTranslationX(mFillDismissGapTranslationX + mTaskOffsetTranslationX); + } + + private void applyTranslationY() { + setTranslationY(mFillDismissGapTranslationY + mTaskOffsetTranslationY); + } + + public FloatProperty getPrimaryFillDismissGapTranslationProperty() { + return getPagedOrientationHandler().getPrimaryValue( + FILL_DISMISS_GAP_TRANSLATION_X, FILL_DISMISS_GAP_TRANSLATION_Y); + } + + public FloatProperty getPrimaryTaskOffsetTranslationProperty() { + return getPagedOrientationHandler().getPrimaryValue( + TASK_OFFSET_TRANSLATION_X, TASK_OFFSET_TRANSLATION_Y); + } + @Override public boolean hasOverlappingRendering() { // TODO: Clip-out the icon region from the thumbnail, since they are overlapping. diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index e64d2bb0f9..bfa24ebf35 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -42,12 +42,12 @@ import com.android.launcher3.util.OverScroller; public class LandscapePagedViewHandler implements PagedOrientationHandler { @Override - public int getPrimaryValue(int x, int y) { + public T getPrimaryValue(T x, T y) { return y; } @Override - public int getSecondaryValue(int x, int y) { + public T getSecondaryValue(T x, T y) { return x; } diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index e4a24072f0..e7d2ad5c3d 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -83,8 +83,8 @@ public interface PagedOrientationHandler { boolean getRecentsRtlSetting(Resources resources); float getDegreesRotated(); int getRotation(); - int getPrimaryValue(int x, int y); - int getSecondaryValue(int x, int y); + T getPrimaryValue(T x, T y); + T getSecondaryValue(T x, T y); void delegateScrollTo(PagedView pagedView, int secondaryScroll, int primaryScroll); /** Uses {@params pagedView}.getScroll[X|Y]() method for the secondary amount*/ void delegateScrollTo(PagedView pagedView, int primaryScroll); diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index e4662de3b3..e5a89679e2 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -40,12 +40,12 @@ import com.android.launcher3.util.OverScroller; public class PortraitPagedViewHandler implements PagedOrientationHandler { @Override - public int getPrimaryValue(int x, int y) { + public T getPrimaryValue(T x, T y) { return x; } @Override - public int getSecondaryValue(int x, int y) { + public T getSecondaryValue(T x, T y) { return y; }