diff options
author | Santiago Etchebehere <santie@google.com> | 2018-06-15 16:42:19 -0700 |
---|---|---|
committer | Santiago Etchebehere <santie@google.com> | 2018-06-15 23:55:03 +0000 |
commit | 260b4cbd908a5faad86c1d816cd7158d454626e1 (patch) | |
tree | 3ca8536a8e597dbb8f0f4e39e5e75e7a130a0f90 | |
parent | 73088c2aaee6e43b20e7b57ffae04fa3d05d7178 (diff) | |
download | android_packages_apps_Trebuchet-260b4cbd908a5faad86c1d816cd7158d454626e1.tar.gz android_packages_apps_Trebuchet-260b4cbd908a5faad86c1d816cd7158d454626e1.tar.bz2 android_packages_apps_Trebuchet-260b4cbd908a5faad86c1d816cd7158d454626e1.zip |
Revert "Adding overscroll effect in recents list"
This reverts commit 4d6b1a95a13fd6f5b293ba97051bc645fab95334.
Bug: 110279118
Change-Id: I794b2c7af076d63901f2286fd2ff3d06c6e39fee
-rw-r--r-- | quickstep/src/com/android/quickstep/views/RecentsView.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherScroller.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 66 |
3 files changed, 61 insertions, 13 deletions
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index f7f496fef..1650b53a8 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -259,8 +259,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setPageSpacing(getResources().getDimensionPixelSize(R.dimen.recents_page_spacing)); - setEnableFreeScroll(true); - setEnableOverscroll(true); + enableFreeScroll(true); + setClipToOutline(true); mFastFlingVelocity = getResources() .getDimensionPixelSize(R.dimen.recents_fast_fling_velocity); diff --git a/src/com/android/launcher3/LauncherScroller.java b/src/com/android/launcher3/LauncherScroller.java index af87550ea..a9b49556b 100644 --- a/src/com/android/launcher3/LauncherScroller.java +++ b/src/com/android/launcher3/LauncherScroller.java @@ -459,13 +459,13 @@ public class LauncherScroller { return Math.log(INFLEXION * Math.abs(velocity) / (mFlingFriction * mPhysicalCoeff)); } - public int getSplineFlingDuration(float velocity) { + private int getSplineFlingDuration(float velocity) { final double l = getSplineDeceleration(velocity); final double decelMinusOne = DECELERATION_RATE - 1.0; return (int) (1000.0 * Math.exp(l / decelMinusOne)); } - public double getSplineFlingDistance(float velocity) { + private double getSplineFlingDistance(float velocity) { final double l = getSplineDeceleration(velocity); final double decelMinusOne = DECELERATION_RATE - 1.0; return mFlingFriction * mPhysicalCoeff * Math.exp(DECELERATION_RATE / decelMinusOne * l); diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 0cb653900..db5dc6635 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -63,6 +63,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou protected static final ComputePageScrollsLogic SIMPLE_SCROLL_LOGIC = (v) -> v.getVisibility() != GONE; public static final int PAGE_SNAP_ANIMATION_DURATION = 750; + public static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950; // OverScroll constants private final static int OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION = 270; @@ -82,6 +83,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou public static final int INVALID_RESTORE_PAGE = -1001; private boolean mFreeScroll = false; + private boolean mSettleOnPageInFreeScroll = false; protected int mFlingThresholdVelocity; protected int mMinFlingVelocity; @@ -354,6 +356,17 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou @Override public void scrollTo(int x, int y) { + // In free scroll mode, we clamp the scrollX + if (mFreeScroll) { + // If the scroller is trying to move to a location beyond the maximum allowed + // in the free scroll mode, we make sure to end the scroll operation. + if (!mScroller.isFinished() && (x > mMaxScrollX || x < 0)) { + forceFinishScroller(false); + } + + x = Utilities.boundToRange(x, 0, mMaxScrollX); + } + mUnboundedScrollX = x; boolean isXBeforeFirstPage = mIsRtl ? (x > mMaxScrollX) : (x < 0); @@ -1013,7 +1026,13 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou dampedOverScroll(amount); } - protected void setEnableFreeScroll(boolean freeScroll) { + + protected void enableFreeScroll(boolean settleOnPageInFreeScroll) { + setEnableFreeScroll(true); + mSettleOnPageInFreeScroll = settleOnPageInFreeScroll; + } + + private void setEnableFreeScroll(boolean freeScroll) { boolean wasFreeScroll = mFreeScroll; mFreeScroll = freeScroll; @@ -1022,6 +1041,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou } else if (wasFreeScroll) { snapToPage(getNextPage()); } + + setEnableOverscroll(!freeScroll); } protected void setEnableOverscroll(boolean enable) { @@ -1134,15 +1155,42 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou snapToDestination(); } } else { - int unscaledScrollX = getScrollX() - (int) Math.round( - mScroller.getSplineFlingDistance(velocityX) * Math.signum(velocityX)); - int duration = mScroller.getSplineFlingDuration(velocityX); - int finalPage = getPageNearestToCenterOfScreen(unscaledScrollX); - if ((isFling || isSignificantMove) && (finalPage != mCurrentPage)) { - snapToPage(finalPage, duration); - } else { - snapToDestination(); + if (!mScroller.isFinished()) { + abortScrollerAnimation(true); + } + + float scaleX = getScaleX(); + int vX = (int) (-velocityX * scaleX); + int initialScrollX = (int) (getScrollX() * scaleX); + + mScroller.setInterpolator(mDefaultInterpolator); + mScroller.fling(initialScrollX, + getScrollY(), vX, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0); + int unscaledScrollX = (int) (mScroller.getFinalX() / scaleX); + mNextPage = getPageNearestToCenterOfScreen(unscaledScrollX); + int firstPageScroll = getScrollForPage(!mIsRtl ? 0 : getPageCount() - 1); + int lastPageScroll = getScrollForPage(!mIsRtl ? getPageCount() - 1 : 0); + if (mSettleOnPageInFreeScroll && unscaledScrollX > 0 + && unscaledScrollX < mMaxScrollX) { + // If scrolling ends in the half of the added space that is closer to the + // end, settle to the end. Otherwise snap to the nearest page. + // If flinging past one of the ends, don't change the velocity as it will + // get stopped at the end anyway. + final int finalX = unscaledScrollX < firstPageScroll / 2 ? + 0 : + unscaledScrollX > (lastPageScroll + mMaxScrollX) / 2 ? + mMaxScrollX : + getScrollForPage(mNextPage); + + mScroller.setFinalX((int) (finalX * getScaleX())); + // Ensure the scroll/snap doesn't happen too fast; + int extraScrollDuration = OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION + - mScroller.getDuration(); + if (extraScrollDuration > 0) { + mScroller.extendDuration(extraScrollDuration); + } } + invalidate(); } onScrollInteractionEnd(); } else if (mTouchState == TOUCH_STATE_PREV_PAGE) { |