summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/SmoothPagedView.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2010-09-30 14:11:56 -0700
committerAdam Cohen <adamcohen@google.com>2010-09-30 14:15:10 -0700
commitf34bab59fc0260f926aec44d044883dce1b4191f (patch)
tree221a1add2ac33ff3f986434744c4f999edbebfdf /src/com/android/launcher2/SmoothPagedView.java
parent3fb4fc921f1e599c01be68af648d85892cb904c1 (diff)
downloadandroid_packages_apps_Trebuchet-f34bab59fc0260f926aec44d044883dce1b4191f.tar.gz
android_packages_apps_Trebuchet-f34bab59fc0260f926aec44d044883dce1b4191f.tar.bz2
android_packages_apps_Trebuchet-f34bab59fc0260f926aec44d044883dce1b4191f.zip
-Added 3D effect to home screen scrolling
-Added background outline fade in / out -Modified the feel of scrolling: now using quintic interpolator and modified the influence of scroll velocity Change-Id: Ifddcab5223ac20be7d9f800ccf09442d9b4db781 Conflicts: src/com/android/launcher2/CellLayout.java
Diffstat (limited to 'src/com/android/launcher2/SmoothPagedView.java')
-rw-r--r--src/com/android/launcher2/SmoothPagedView.java58
1 files changed, 46 insertions, 12 deletions
diff --git a/src/com/android/launcher2/SmoothPagedView.java b/src/com/android/launcher2/SmoothPagedView.java
index 5f80f2587..56037ffb8 100644
--- a/src/com/android/launcher2/SmoothPagedView.java
+++ b/src/com/android/launcher2/SmoothPagedView.java
@@ -26,11 +26,15 @@ public abstract class SmoothPagedView extends PagedView {
private static final float SMOOTHING_SPEED = 0.75f;
private static final float SMOOTHING_CONSTANT = (float) (0.016 / Math.log(SMOOTHING_SPEED));
+ private float mBaseLineFlingVelocity;
+ private float mFlingVelocityInfluence;
- private static final float BASELINE_FLING_VELOCITY = 2500.f;
- private static final float FLING_VELOCITY_INFLUENCE = 0.4f;
+ static final int OVERSHOOT_MODE = 0;
+ static final int QUINTIC_MODE = 1;
- private WorkspaceOvershootInterpolator mScrollInterpolator;
+ int mScrollMode;
+
+ private Interpolator mScrollInterpolator;
private static class WorkspaceOvershootInterpolator implements Interpolator {
private static final float DEFAULT_TENSION = 1.3f;
@@ -56,6 +60,16 @@ public abstract class SmoothPagedView extends PagedView {
}
}
+ private static class QuinticInterpolator implements Interpolator {
+ public QuinticInterpolator() {
+ }
+
+ public float getInterpolation(float t) {
+ t -= 1.0f;
+ return t*t*t*t*t + 1;
+ }
+ }
+
/**
* Used to inflate the Workspace from XML.
*
@@ -83,14 +97,27 @@ public abstract class SmoothPagedView extends PagedView {
mDeferScrollUpdate = true;
}
+ protected int getScrollMode() {
+ return OVERSHOOT_MODE;
+ }
+
/**
* Initializes various states for this workspace.
*/
@Override
protected void init() {
super.init();
- mScrollInterpolator = new WorkspaceOvershootInterpolator();
- // overwrite the previous mScroller
+
+ mScrollMode = getScrollMode();
+ if (mScrollMode == QUINTIC_MODE) {
+ mBaseLineFlingVelocity = 700.0f;
+ mFlingVelocityInfluence = 0.8f;
+ mScrollInterpolator = new QuinticInterpolator();
+ } else { // QUINTIC_MODE
+ mBaseLineFlingVelocity = 2500.0f;
+ mFlingVelocityInfluence = 0.4f;
+ mScrollInterpolator = new WorkspaceOvershootInterpolator();
+ }
mScroller = new Scroller(getContext(), mScrollInterpolator);
}
@@ -112,25 +139,32 @@ public abstract class SmoothPagedView extends PagedView {
final int screenDelta = Math.max(1, Math.abs(whichPage - mCurrentPage));
final int newX = getChildOffset(whichPage) - getRelativeChildOffset(whichPage);
final int delta = newX - mScrollX;
- int duration = (screenDelta + 1) * 100;
+ int duration;
+ if (mScrollMode == OVERSHOOT_MODE) {
+ duration = (screenDelta + 1) * 100;
+ } else { // QUINTIC_MODE
+ duration = Math.round(Math.abs(delta) * 0.6f);
+ }
if (!mScroller.isFinished()) {
mScroller.abortAnimation();
}
- if (settle) {
- mScrollInterpolator.setDistance(screenDelta);
- } else {
- mScrollInterpolator.disableSettle();
+ if (mScrollMode == OVERSHOOT_MODE) {
+ if (settle) {
+ ((WorkspaceOvershootInterpolator) mScrollInterpolator).setDistance(screenDelta);
+ } else {
+ ((WorkspaceOvershootInterpolator) mScrollInterpolator).disableSettle();
+ }
}
velocity = Math.abs(velocity);
if (velocity > 0) {
- duration += (duration / (velocity / BASELINE_FLING_VELOCITY))
- * FLING_VELOCITY_INFLUENCE;
+ duration += (duration / (velocity / mBaseLineFlingVelocity)) * mFlingVelocityInfluence;
} else {
duration += 100;
}
+
snapToPage(whichPage, delta, duration);
}