summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/AllAppsTransitionController.java
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2016-08-03 22:28:30 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-08-03 22:28:30 +0000
commit5a5eb846c410c6ed6c1c0fb01edf82e118c35830 (patch)
tree1f754a2cf21a57febcafa4989a4a0dc716246010 /src/com/android/launcher3/allapps/AllAppsTransitionController.java
parent40a29161aec5f07a089e7cc4e4c804b23ca50b57 (diff)
parent191e9d1b297f3a5dd2953f00c9cf9eac364fcf69 (diff)
downloadandroid_packages_apps_Trebuchet-5a5eb846c410c6ed6c1c0fb01edf82e118c35830.tar.gz
android_packages_apps_Trebuchet-5a5eb846c410c6ed6c1c0fb01edf82e118c35830.tar.bz2
android_packages_apps_Trebuchet-5a5eb846c410c6ed6c1c0fb01edf82e118c35830.zip
Merge "Change interpolation logic to all apps transitioning on fling b/30486958" into ub-launcher3-calgary
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsTransitionController.java')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsTransitionController.java60
1 files changed, 47 insertions, 13 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index e46b889dc..b0a62e1de 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -17,7 +17,6 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
-import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
@@ -42,11 +41,12 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f);
private final Interpolator mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
- private final Interpolator mScrollInterpolator = new PagedView.ScrollInterpolator();
+ private final ScrollInterpolator mScrollInterpolator = new ScrollInterpolator();
private static final float ANIMATION_DURATION = 1200;
-
private static final float PARALLAX_COEFFICIENT = .125f;
+ private static final float FAST_FLING_PX_MS = 10;
+ private static final int SINGLE_FRAME_MS = 16;
private AllAppsContainerView mAppsView;
private int mAllAppsBackgroundColor;
@@ -72,6 +72,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private float mShiftRange; // changes depending on the orientation
private float mProgress; // [0, 1], mShiftRange * mProgress = shiftCurrent
+ // Velocity of the container. Unit is in px/ms.
private float mContainerVelocity;
private static final float DEFAULT_SHIFT_RANGE = 10;
@@ -343,7 +344,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private void calculateDuration(float velocity, float disp) {
// TODO: make these values constants after tuning.
- float velocityDivisor = Math.max(1.5f, Math.abs(0.5f * velocity));
+ float velocityDivisor = Math.max(2f, Math.abs(0.5f * velocity));
float travelDistance = Math.max(0.2f, disp / mShiftRange);
mAnimationDuration = (long) Math.max(100, ANIMATION_DURATION / velocityDivisor * travelDistance);
if (DBG) {
@@ -351,22 +352,29 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
}
}
- public void animateToAllApps(AnimatorSet animationOut, long duration) {
- Interpolator interpolator;
+ public boolean animateToAllApps(AnimatorSet animationOut, long duration) {
+ boolean shouldPost = true;
if (animationOut == null) {
- return;
+ return shouldPost;
}
+ Interpolator interpolator;
if (mDetector.isIdleState()) {
preparePull(true);
mAnimationDuration = duration;
mShiftStart = mAppsView.getTranslationY();
interpolator = mFastOutSlowInInterpolator;
} else {
+ mScrollInterpolator.setVelocityAtZero(Math.abs(mContainerVelocity));
interpolator = mScrollInterpolator;
+ float nextFrameProgress = mProgress + mContainerVelocity * SINGLE_FRAME_MS / mShiftRange;
+ if (nextFrameProgress >= 0f) {
+ mProgress = nextFrameProgress;
+ }
+ shouldPost = false;
}
- final float fromAllAppsTop = mAppsView.getTranslationY();
+
ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress",
- fromAllAppsTop / mShiftRange, 0f);
+ mProgress, 0f);
driftAndAlpha.setDuration(mAnimationDuration);
driftAndAlpha.setInterpolator(interpolator);
animationOut.play(driftAndAlpha);
@@ -391,6 +399,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
}
});
mCurrentAnimation = animationOut;
+ return shouldPost;
}
public void showDiscoveryBounce() {
@@ -426,9 +435,10 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
});
}
- public void animateToWorkspace(AnimatorSet animationOut, long duration) {
+ public boolean animateToWorkspace(AnimatorSet animationOut, long duration) {
+ boolean shouldPost = true;
if (animationOut == null) {
- return;
+ return shouldPost;
}
Interpolator interpolator;
if (mDetector.isIdleState()) {
@@ -437,12 +447,17 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
mShiftStart = mAppsView.getTranslationY();
interpolator = mFastOutSlowInInterpolator;
} else {
+ mScrollInterpolator.setVelocityAtZero(Math.abs(mContainerVelocity));
interpolator = mScrollInterpolator;
+ float nextFrameProgress = mProgress + mContainerVelocity * SINGLE_FRAME_MS / mShiftRange;
+ if (nextFrameProgress <= 1f) {
+ mProgress = nextFrameProgress;
+ }
+ shouldPost = false;
}
- final float fromAllAppsTop = mAppsView.getTranslationY();
ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress",
- fromAllAppsTop / mShiftRange, 1f);
+ mProgress, 1f);
driftAndAlpha.setDuration(mAnimationDuration);
driftAndAlpha.setInterpolator(interpolator);
animationOut.play(driftAndAlpha);
@@ -467,6 +482,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
}
});
mCurrentAnimation = animationOut;
+ return shouldPost;
}
public void finishPullUp() {
@@ -522,4 +538,22 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
}
setProgress(mProgress);
}
+
+ static class ScrollInterpolator implements Interpolator {
+
+ boolean mSteeper;
+
+ public void setVelocityAtZero(float velocity) {
+ mSteeper = velocity > FAST_FLING_PX_MS;
+ }
+
+ public float getInterpolation(float t) {
+ t -= 1.0f;
+ float output = t * t * t;
+ if (mSteeper) {
+ output *= t * t; // Make interpolation initial slope steeper
+ }
+ return output + 1;
+ }
+ }
}