Merge "Updating current page when changing the frescroll mode" into ub-launcher3-calgary
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 51ee47a..baf5e1f 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -113,7 +113,8 @@
private float mBackgroundAlpha;
- private static final int BACKGROUND_ACTIVATE_DURATION = 120;
+ private static final int BACKGROUND_ACTIVATE_DURATION =
+ FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? 120 : 0;
private final TransitionDrawable mBackground;
// These values allow a fixed measurement to be set on the CellLayout.
diff --git a/src/com/android/launcher3/PinchToOverviewListener.java b/src/com/android/launcher3/PinchToOverviewListener.java
index 74e6b39..f32c845 100644
--- a/src/com/android/launcher3/PinchToOverviewListener.java
+++ b/src/com/android/launcher3/PinchToOverviewListener.java
@@ -33,6 +33,11 @@
public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
private static final float OVERVIEW_PROGRESS = 0f;
private static final float WORKSPACE_PROGRESS = 1f;
+ /**
+ * The velocity threshold at which a pinch will be completed instead of canceled,
+ * even if the first threshold has not been passed. Measured in progress / millisecond
+ */
+ private static final float FLING_VELOCITY = 0.003f;
private ScaleGestureDetector mPinchDetector;
private Launcher mLauncher;
@@ -110,17 +115,20 @@
public void onScaleEnd(ScaleGestureDetector detector) {
super.onScaleEnd(detector);
+ float progressVelocity = mProgressDelta / mTimeDelta;
float passedThreshold = mThresholdManager.getPassedThreshold();
+ boolean isFling = mWorkspace.isInOverviewMode() && progressVelocity >= FLING_VELOCITY
+ || !mWorkspace.isInOverviewMode() && progressVelocity <= -FLING_VELOCITY;
+ boolean shouldCancelPinch = !isFling && passedThreshold < PinchThresholdManager.THRESHOLD_ONE;
// If we are going towards overview, mPreviousProgress is how much further we need to
// go, since it is going from 1 to 0. If we are going to workspace, we want
// 1 - mPreviousProgress.
float remainingProgress = mPreviousProgress;
- if (mWorkspace.isInOverviewMode() || passedThreshold < PinchThresholdManager.THRESHOLD_ONE) {
+ if (mWorkspace.isInOverviewMode() || shouldCancelPinch) {
remainingProgress = 1f - mPreviousProgress;
}
- int duration = computeDuration(remainingProgress, mProgressDelta, mTimeDelta);
-
- if (passedThreshold < PinchThresholdManager.THRESHOLD_ONE) {
+ int duration = computeDuration(remainingProgress, progressVelocity);
+ if (shouldCancelPinch) {
cancelPinch(mPreviousProgress, duration);
} else if (passedThreshold < PinchThresholdManager.THRESHOLD_THREE) {
float toProgress = mWorkspace.isInOverviewMode() ?
@@ -138,8 +146,8 @@
* Compute the amount of time required to complete the transition based on the current pinch
* speed. If this time is too long, instead return the normal duration, ignoring the speed.
*/
- private int computeDuration(float remainingProgress, float progressDelta, long timeDelta) {
- float progressSpeed = Math.abs(progressDelta) / timeDelta;
+ private int computeDuration(float remainingProgress, float progressVelocity) {
+ float progressSpeed = Math.abs(progressVelocity);
int remainingMillis = (int) (remainingProgress / progressSpeed);
return Math.min(remainingMillis, mAnimationManager.getNormalOverviewTransitionDuration());
}