Loading src/com/android/launcher3/allapps/AllAppsTransitionController.java +14 −6 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private float mShiftRange; // changes depending on the orientation private float mProgress; // [0, 1], mShiftRange * mProgress = shiftCurrent private float mVelocityForCaret; private float mContainerVelocity; private static final float DEFAULT_SHIFT_RANGE = 10; Loading Loading @@ -208,7 +208,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul return false; // early termination. } mVelocityForCaret = velocity; mContainerVelocity = velocity; float shift = Math.min(Math.max(0, mShiftStart + displacement), mShiftRange); setProgress(shift / mShiftRange); Loading Loading @@ -305,9 +305,10 @@ public class AllAppsTransitionController implements TouchController, VerticalPul } /** * @param progress value between 0 and 1 * @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace */ public void setProgress(float progress) { float shiftPrevious = mProgress * mShiftRange; mProgress = progress; float shiftCurrent = progress * mShiftRange; Loading Loading @@ -339,6 +340,15 @@ public class AllAppsTransitionController implements TouchController, VerticalPul interpolation); updateCaret(progress); updateLightStatusBar(shiftCurrent); if (!mDetector.isDraggingState()) { mContainerVelocity = mDetector.computeVelocity(shiftCurrent - shiftPrevious, System.currentTimeMillis()); } } public float getContainerVelocity() { return mContainerVelocity; } public float getProgress() { Loading @@ -361,7 +371,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul return; } if (mDetector.isIdleState()) { mVelocityForCaret = -VerticalPullDetector.RELEASE_VELOCITY_PX_MS; preparePull(true); mAnimationDuration = duration; mShiftStart = mAppsView.getTranslationY(); Loading Loading @@ -434,7 +443,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul } Interpolator interpolator; if (mDetector.isIdleState()) { mVelocityForCaret = VerticalPullDetector.RELEASE_VELOCITY_PX_MS; preparePull(true); mAnimationDuration = duration; mShiftStart = mAppsView.getTranslationY(); Loading Loading @@ -513,7 +521,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul if (0f < shift && shift < 1f && !mLauncher.useVerticalBarLayout()) { // How fast are we moving as a percentage of the minimum fling velocity? final float pctOfFlingVelocity = Math.max(-1, Math.min( mVelocityForCaret / VerticalPullDetector.RELEASE_VELOCITY_PX_MS, 1)); mContainerVelocity / VerticalPullDetector.RELEASE_VELOCITY_PX_MS, 1)); mCaretDrawable.setCaretProgress(pctOfFlingVelocity); Loading src/com/android/launcher3/allapps/VerticalPullDetector.java +16 −19 Original line number Diff line number Diff line Loading @@ -93,10 +93,9 @@ public class VerticalPullDetector { private float mDownX; private float mDownY; private float mDownMillis; private float mLastY; private float mLastMillis; private long mCurrentMillis; private float mVelocity; private float mLastDisplacement; Loading Loading @@ -153,7 +152,6 @@ public class VerticalPullDetector { public boolean onTouchEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: mDownMillis = ev.getDownTime(); mDownX = ev.getX(); mDownY = ev.getY(); mLastDisplacement = 0; Loading @@ -167,7 +165,7 @@ public class VerticalPullDetector { case MotionEvent.ACTION_MOVE: mDisplacementX = ev.getX() - mDownX; mDisplacementY = ev.getY() - mDownY; mVelocity = computeVelocity(ev, mVelocity); computeVelocity(ev); // handle state and listener calls. if (mState != ScrollState.DRAGGING && shouldScrollStart()) { Loading @@ -190,10 +188,7 @@ public class VerticalPullDetector { } // Do house keeping. mLastDisplacement = mDisplacementY; mLastY = ev.getY(); mLastMillis = ev.getEventTime(); return true; } Loading Loading @@ -245,21 +240,23 @@ public class VerticalPullDetector { /** * Computes the damped velocity using the two motion events and the previous velocity. */ private float computeVelocity(MotionEvent to, float previousVelocity) { float delta = computeDelta(to); float deltaTimeMillis = to.getEventTime() - mLastMillis; float velocity = (deltaTimeMillis > 0) ? (delta / deltaTimeMillis) : 0; if (Math.abs(previousVelocity) < 0.001f) { return velocity; private float computeVelocity(MotionEvent to) { return computeVelocity(to.getY() - mLastY, to.getEventTime()); } public float computeVelocity(float delta, long currentMillis) { long previousMillis = mCurrentMillis; mCurrentMillis = currentMillis; float deltaTimeMillis = mCurrentMillis - previousMillis; float velocity = (deltaTimeMillis > 0) ? (delta / deltaTimeMillis) : 0; if (Math.abs(mVelocity) < 0.001f) { mVelocity = velocity; } else { float alpha = computeDampeningFactor(deltaTimeMillis); return interpolate(previousVelocity, velocity, alpha); mVelocity = interpolate(mVelocity, velocity, alpha); } private float computeDelta(MotionEvent to) { return to.getY() - mLastY; return mVelocity; } /** Loading Loading
src/com/android/launcher3/allapps/AllAppsTransitionController.java +14 −6 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private float mShiftRange; // changes depending on the orientation private float mProgress; // [0, 1], mShiftRange * mProgress = shiftCurrent private float mVelocityForCaret; private float mContainerVelocity; private static final float DEFAULT_SHIFT_RANGE = 10; Loading Loading @@ -208,7 +208,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul return false; // early termination. } mVelocityForCaret = velocity; mContainerVelocity = velocity; float shift = Math.min(Math.max(0, mShiftStart + displacement), mShiftRange); setProgress(shift / mShiftRange); Loading Loading @@ -305,9 +305,10 @@ public class AllAppsTransitionController implements TouchController, VerticalPul } /** * @param progress value between 0 and 1 * @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace */ public void setProgress(float progress) { float shiftPrevious = mProgress * mShiftRange; mProgress = progress; float shiftCurrent = progress * mShiftRange; Loading Loading @@ -339,6 +340,15 @@ public class AllAppsTransitionController implements TouchController, VerticalPul interpolation); updateCaret(progress); updateLightStatusBar(shiftCurrent); if (!mDetector.isDraggingState()) { mContainerVelocity = mDetector.computeVelocity(shiftCurrent - shiftPrevious, System.currentTimeMillis()); } } public float getContainerVelocity() { return mContainerVelocity; } public float getProgress() { Loading @@ -361,7 +371,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul return; } if (mDetector.isIdleState()) { mVelocityForCaret = -VerticalPullDetector.RELEASE_VELOCITY_PX_MS; preparePull(true); mAnimationDuration = duration; mShiftStart = mAppsView.getTranslationY(); Loading Loading @@ -434,7 +443,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul } Interpolator interpolator; if (mDetector.isIdleState()) { mVelocityForCaret = VerticalPullDetector.RELEASE_VELOCITY_PX_MS; preparePull(true); mAnimationDuration = duration; mShiftStart = mAppsView.getTranslationY(); Loading Loading @@ -513,7 +521,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul if (0f < shift && shift < 1f && !mLauncher.useVerticalBarLayout()) { // How fast are we moving as a percentage of the minimum fling velocity? final float pctOfFlingVelocity = Math.max(-1, Math.min( mVelocityForCaret / VerticalPullDetector.RELEASE_VELOCITY_PX_MS, 1)); mContainerVelocity / VerticalPullDetector.RELEASE_VELOCITY_PX_MS, 1)); mCaretDrawable.setCaretProgress(pctOfFlingVelocity); Loading
src/com/android/launcher3/allapps/VerticalPullDetector.java +16 −19 Original line number Diff line number Diff line Loading @@ -93,10 +93,9 @@ public class VerticalPullDetector { private float mDownX; private float mDownY; private float mDownMillis; private float mLastY; private float mLastMillis; private long mCurrentMillis; private float mVelocity; private float mLastDisplacement; Loading Loading @@ -153,7 +152,6 @@ public class VerticalPullDetector { public boolean onTouchEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: mDownMillis = ev.getDownTime(); mDownX = ev.getX(); mDownY = ev.getY(); mLastDisplacement = 0; Loading @@ -167,7 +165,7 @@ public class VerticalPullDetector { case MotionEvent.ACTION_MOVE: mDisplacementX = ev.getX() - mDownX; mDisplacementY = ev.getY() - mDownY; mVelocity = computeVelocity(ev, mVelocity); computeVelocity(ev); // handle state and listener calls. if (mState != ScrollState.DRAGGING && shouldScrollStart()) { Loading @@ -190,10 +188,7 @@ public class VerticalPullDetector { } // Do house keeping. mLastDisplacement = mDisplacementY; mLastY = ev.getY(); mLastMillis = ev.getEventTime(); return true; } Loading Loading @@ -245,21 +240,23 @@ public class VerticalPullDetector { /** * Computes the damped velocity using the two motion events and the previous velocity. */ private float computeVelocity(MotionEvent to, float previousVelocity) { float delta = computeDelta(to); float deltaTimeMillis = to.getEventTime() - mLastMillis; float velocity = (deltaTimeMillis > 0) ? (delta / deltaTimeMillis) : 0; if (Math.abs(previousVelocity) < 0.001f) { return velocity; private float computeVelocity(MotionEvent to) { return computeVelocity(to.getY() - mLastY, to.getEventTime()); } public float computeVelocity(float delta, long currentMillis) { long previousMillis = mCurrentMillis; mCurrentMillis = currentMillis; float deltaTimeMillis = mCurrentMillis - previousMillis; float velocity = (deltaTimeMillis > 0) ? (delta / deltaTimeMillis) : 0; if (Math.abs(mVelocity) < 0.001f) { mVelocity = velocity; } else { float alpha = computeDampeningFactor(deltaTimeMillis); return interpolate(previousVelocity, velocity, alpha); mVelocity = interpolate(mVelocity, velocity, alpha); } private float computeDelta(MotionEvent to) { return to.getY() - mLastY; return mVelocity; } /** Loading