summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2011-12-07 16:23:28 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-12-07 16:23:28 -0800
commit475655ea5900df19bbf31a9b2f7bd99dbeeef1a9 (patch)
tree6976a54e316ee70ca75690727ebd332751959e54
parent90f53da6809bd97f48551c066ee404b0f75079b4 (diff)
parent265b9a66542148e0ff13971001cb9461065e1e0e (diff)
downloadandroid_packages_apps_Trebuchet-475655ea5900df19bbf31a9b2f7bd99dbeeef1a9.tar.gz
android_packages_apps_Trebuchet-475655ea5900df19bbf31a9b2f7bd99dbeeef1a9.tar.bz2
android_packages_apps_Trebuchet-475655ea5900df19bbf31a9b2f7bd99dbeeef1a9.zip
Merge "Scaling PagedView fling constants by density (issue 5594666)"
-rw-r--r--src/com/android/launcher2/PagedView.java25
-rw-r--r--src/com/android/launcher2/Workspace.java5
2 files changed, 21 insertions, 9 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 3f5652e1d..1d91f3c96 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -67,14 +67,20 @@ public abstract class PagedView extends ViewGroup {
private static final float OVERSCROLL_ACCELERATE_FACTOR = 2;
private static final float OVERSCROLL_DAMP_FACTOR = 0.14f;
- private static final int MINIMUM_SNAP_VELOCITY = 2200;
- private static final int MIN_FLING_VELOCITY = 250;
+
private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f;
// The page is moved more than halfway, automatically move to the next page on touch up.
private static final float SIGNIFICANT_MOVE_THRESHOLD = 0.4f;
- // the velocity at which a fling gesture will cause us to snap to the next page
- protected int mSnapVelocity = 500;
+ // The following constants need to be scaled based on density. The scaled versions will be
+ // assigned to the corresponding member variables below.
+ private static final int FLING_THRESHOLD_VELOCITY = 500;
+ private static final int MIN_SNAP_VELOCITY = 1500;
+ private static final int MIN_FLING_VELOCITY = 250;
+
+ protected int mFlingThresholdVelocity;
+ protected int mMinFlingVelocity;
+ protected int mMinSnapVelocity;
protected float mDensity;
protected float mSmoothingTime;
@@ -242,6 +248,10 @@ public abstract class PagedView extends ViewGroup {
mPagingTouchSlop = configuration.getScaledPagingTouchSlop();
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mDensity = getResources().getDisplayMetrics().density;
+
+ mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
+ mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * mDensity);
+ mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * mDensity);
}
public void setPageSwitchListener(PageSwitchListener pageSwitchListener) {
@@ -1208,12 +1218,11 @@ public abstract class PagedView extends ViewGroup {
final int pageWidth = getScaledMeasuredWidth(getPageAt(mCurrentPage));
boolean isSignificantMove = Math.abs(deltaX) > pageWidth *
SIGNIFICANT_MOVE_THRESHOLD;
- final int snapVelocity = mSnapVelocity;
mTotalMotionX += Math.abs(mLastMotionX + mLastMotionXRemainder - x);
boolean isFling = mTotalMotionX > MIN_LENGTH_FOR_FLING &&
- Math.abs(velocityX) > snapVelocity;
+ Math.abs(velocityX) > mFlingThresholdVelocity;
// In the case that the page is moved far to one direction and then is flung
// in the opposite direction, we use a threshold to determine whether we should
@@ -1434,7 +1443,7 @@ public abstract class PagedView extends ViewGroup {
int delta = newX - mUnboundedScrollX;
int duration = 0;
- if (Math.abs(velocity) < MIN_FLING_VELOCITY) {
+ if (Math.abs(velocity) < mMinFlingVelocity) {
// If the velocity is low enough, then treat this more as an automatic page advance
// as opposed to an apparent physical response to flinging
snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION);
@@ -1450,7 +1459,7 @@ public abstract class PagedView extends ViewGroup {
distanceInfluenceForSnapDuration(distanceRatio);
velocity = Math.abs(velocity);
- velocity = Math.max(MINIMUM_SNAP_VELOCITY, velocity);
+ velocity = Math.max(mMinSnapVelocity, velocity);
// we want the page's snap velocity to approximately match the velocity at which the
// user flings, so we scale the duration by a value near to the derivative of the scroll
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 467cec04c..fa3dfcbff 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -94,6 +94,7 @@ public class Workspace extends SmoothPagedView
private static final int BACKGROUND_FADE_OUT_DURATION = 350;
private static final int ADJACENT_SCREEN_DROP_DURATION = 300;
+ private static final int FLING_THRESHOLD_VELOCITY = 500;
// These animators are used to fade the children's outlines
private ObjectAnimator mChildrenOutlineFadeInAnimation;
@@ -409,13 +410,15 @@ public class Workspace extends SmoothPagedView
}
};
- mSnapVelocity = 600;
mWallpaperOffset = new WallpaperOffsetInterpolator();
Display display = mLauncher.getWindowManager().getDefaultDisplay();
mDisplayWidth = display.getWidth();
mDisplayHeight = display.getHeight();
mWallpaperTravelWidth = (int) (mDisplayWidth *
wallpaperTravelToScreenWidthRatio(mDisplayWidth, mDisplayHeight));
+
+ mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
+
}
@Override