From e3e7e63902bb2b280d1af47d975afedbeec6d094 Mon Sep 17 00:00:00 2001 From: Sreyas Date: Wed, 29 Jan 2020 10:42:10 -0800 Subject: [PATCH] OverviewActions: Fix action buttons in place Forcing OverviewActions buttons to appear as if it is shown only once in overview screen by overlapping all instances in the same spot. Change-Id: I195d5455d5eb9f12a19c352169bc995849e59281 --- .../com/android/quickstep/views/TaskView.java | 30 +++++++++++++++++-- src/com/android/launcher3/PagedView.java | 7 +++++ 2 files changed, 35 insertions(+), 2 deletions(-) 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 58e36bc8d0..5954b86446 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 @@ -243,6 +243,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { getResources().getDimensionPixelSize(R.dimen.overview_actions_height), Gravity.BOTTOM); addView(mActionsView, params); + mActionsView.setAlpha(0); } } } @@ -447,7 +448,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mIconView.setScaleX(scale); mIconView.setScaleY(scale); - if (mActionsView != null) { + + if (mActionsView != null && isRunningTask()) { mActionsView.setAlpha(scale); } @@ -523,9 +525,11 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { public void onPageScroll(ScrollState scrollState) { float curveInterpolation = CURVE_INTERPOLATOR.getInterpolation(scrollState.linearInterpolation); + float curveScaleForCurveInterpolation = getCurveScaleForCurveInterpolation( + curveInterpolation); mSnapshotView.setDimAlpha(curveInterpolation * MAX_PAGE_SCRIM_ALPHA); - setCurveScale(getCurveScaleForCurveInterpolation(curveInterpolation)); + setCurveScale(curveScaleForCurveInterpolation); mFooterAlpha = Utilities.boundToRange(1.0f - 2 * scrollState.linearInterpolation, 0f, 1f); for (FooterWrapper footer : mFooters) { @@ -539,6 +543,28 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mMenuView.setScaleX(getScaleX()); mMenuView.setScaleY(getScaleY()); } + + // This is not the proper implementation and will be replaced with a proper layout. + if (mActionsView != null) { + if (mFocusTransitionProgress == 1f) { + mActionsView.setAlpha(1 - curveInterpolation / MAX_PAGE_SCRIM_ALPHA); + } + maintainActionViewPosition(curveScaleForCurveInterpolation); + } + + } + + private void maintainActionViewPosition(float curveScaleForCurveInterpolation) { + float inverseCurveScaleFactor = curveScaleForCurveInterpolation == 0 ? 0 : + (1f / curveScaleForCurveInterpolation); + mActionsView.setScaleX(inverseCurveScaleFactor); + mActionsView.setScaleY(inverseCurveScaleFactor); + mActionsView.setTranslationX(inverseCurveScaleFactor * (-getX() + + getRecentsView().getScrollX() + getRecentsView().scrollOffsetLeft())); + mActionsView.setTranslationY( + (1f - curveScaleForCurveInterpolation) * (mSnapshotView.getHeight() + + mActionsView.getHeight()) / 2f + + inverseCurveScaleFactor * (-getTranslationY())); } diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index a1888bfd08..ae4eae9179 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -245,6 +245,13 @@ public abstract class PagedView extends ViewGrou forceFinishScroller(true); } + /** + * Returns left offset of a page. This is the gap between pages and prevents overlap. + */ + public int scrollOffsetLeft() { + return mInsets.left + getPaddingLeft(); + } + private void abortScrollerAnimation(boolean resetNextPage) { mScroller.abortAnimation(); // We need to clean up the next page here to avoid computeScrollHelper from