summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-05-30 11:09:04 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-30 11:09:04 -0700
commit2d45431516a65d7c74a84d86d585d1dab0883aed (patch)
tree15aa3ee521aacc57cec534f05bd0c6e6694d01f9
parentb06791667c60296040734cb4ec2c01ed38edf62a (diff)
parent0db9d46c9a298bbc21e19d23bbe77e67b7567638 (diff)
downloadandroid_packages_apps_Trebuchet-2d45431516a65d7c74a84d86d585d1dab0883aed.zip
android_packages_apps_Trebuchet-2d45431516a65d7c74a84d86d585d1dab0883aed.tar.gz
android_packages_apps_Trebuchet-2d45431516a65d7c74a84d86d585d1dab0883aed.tar.bz2
am 0db9d46c: Merge "Lowering the threshold for flinging on larger devices. (Bug 6575670)" into jb-dev
* commit '0db9d46c9a298bbc21e19d23bbe77e67b7567638': Lowering the threshold for flinging on larger devices. (Bug 6575670)
-rw-r--r--res/values-sw600dp/config.xml3
-rw-r--r--res/values/config.xml3
-rw-r--r--src/com/android/launcher2/DeleteDropTarget.java18
-rw-r--r--src/com/android/launcher2/DragController.java12
4 files changed, 23 insertions, 13 deletions
diff --git a/res/values-sw600dp/config.xml b/res/values-sw600dp/config.xml
index a701e69..a463d73 100644
--- a/res/values-sw600dp/config.xml
+++ b/res/values-sw600dp/config.xml
@@ -4,6 +4,9 @@
<integer name="hotseat_cell_count">7</integer>
<integer name="hotseat_all_apps_index">3</integer>
+<!-- DragController -->
+ <integer name="config_flingToDeleteMinVelocity">-1000</integer>
+
<!-- Folders -->
<!-- Folder max bounds and max number of items. Note: folder_max_count_x * folder_max_count_y
>= folder_max_num_items. When these are set to -1, they are automatically determined. -->
diff --git a/res/values/config.xml b/res/values/config.xml
index bfd2bf5..a8d80fe 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -4,6 +4,9 @@
<bool name="is_large_screen">false</bool>
<bool name="allow_rotation">false</bool>
+<!-- DragController -->
+ <integer name="config_flingToDeleteMinVelocity">-1500</integer>
+
<!-- AllApps/Customize/AppsCustomize -->
<!-- The alpha of the AppsCustomize bg in spring loaded mode -->
<integer name="config_appsCustomizeSpringLoadedBgAlpha">45</integer>
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java
index 1edc2ab..949c035 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/android/launcher2/DeleteDropTarget.java
@@ -39,7 +39,8 @@ import com.android.launcher.R;
public class DeleteDropTarget extends ButtonDropTarget {
private static int DELETE_ANIMATION_DURATION = 285;
- private static int FLIND_DELETE_ANIMATION_DURATION = 350;
+ private static int FLING_DELETE_ANIMATION_DURATION = 350;
+ private static float FLING_TO_DELETE_FRICTION = 0.035f;
private static int MODE_FLING_DELETE_TO_TRASH = 0;
private static int MODE_FLING_DELETE_ALONG_VECTOR = 1;
@@ -311,22 +312,22 @@ public class DeleteDropTarget extends ButtonDropTarget {
* progressively.
*/
private static class FlingAlongVectorAnimatorUpdateListener implements AnimatorUpdateListener {
- private static float FRICTION = 0.93f;
-
private DragLayer mDragLayer;
private PointF mVelocity;
private Rect mFrom;
private long mPrevTime;
private boolean mHasOffsetForScale;
+ private float mFriction;
private final TimeInterpolator mAlphaInterpolator = new DecelerateInterpolator(0.75f);
public FlingAlongVectorAnimatorUpdateListener(DragLayer dragLayer, PointF vel, Rect from,
- long startTime) {
+ long startTime, float friction) {
mDragLayer = dragLayer;
mVelocity = vel;
mFrom = from;
mPrevTime = startTime;
+ mFriction = 1f - (dragLayer.getResources().getDisplayMetrics().density * friction);
}
@Override
@@ -352,8 +353,8 @@ public class DeleteDropTarget extends ButtonDropTarget {
dragView.setTranslationY(mFrom.top);
dragView.setAlpha(1f - mAlphaInterpolator.getInterpolation(t));
- mVelocity.x *= FRICTION;
- mVelocity.y *= FRICTION;
+ mVelocity.x *= mFriction;
+ mVelocity.y *= mFriction;
mPrevTime = curTime;
}
};
@@ -363,7 +364,8 @@ public class DeleteDropTarget extends ButtonDropTarget {
final Rect from = new Rect();
dragLayer.getViewRectRelativeToSelf(d.dragView, from);
- return new FlingAlongVectorAnimatorUpdateListener(dragLayer, vel, from, startTime);
+ return new FlingAlongVectorAnimatorUpdateListener(dragLayer, vel, from, startTime,
+ FLING_TO_DELETE_FRICTION);
}
public void onFlingToDelete(final DragObject d, int x, int y, PointF vel) {
@@ -385,7 +387,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
final ViewConfiguration config = ViewConfiguration.get(mLauncher);
final DragLayer dragLayer = mLauncher.getDragLayer();
- final int duration = FLIND_DELETE_ANIMATION_DURATION;
+ final int duration = FLING_DELETE_ANIMATION_DURATION;
final long startTime = AnimationUtils.currentAnimationTimeMillis();
// NOTE: Because it takes time for the first frame of animation to actually be
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 1b0ccf5..84f1515 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -17,6 +17,7 @@
package com.android.launcher2;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.PointF;
@@ -62,7 +63,6 @@ public class DragController {
static final int SCROLL_RIGHT = 1;
private static final float MAX_FLING_DEGREES = 35f;
- private static final int FLING_TO_DELETE_THRESHOLD_Y_VELOCITY = -1500;
private Launcher mLauncher;
private Handler mHandler;
@@ -146,14 +146,16 @@ public class DragController {
* @param context The application's context.
*/
public DragController(Launcher launcher) {
+ Resources r = launcher.getResources();
mLauncher = launcher;
mHandler = new Handler();
- mScrollZone = launcher.getResources().getDimensionPixelSize(R.dimen.scroll_zone);
+ mScrollZone = r.getDimensionPixelSize(R.dimen.scroll_zone);
mVelocityTracker = VelocityTracker.obtain();
- mVibrator = (Vibrator)launcher.getSystemService(Context.VIBRATOR_SERVICE);
+ mVibrator = (Vibrator) launcher.getSystemService(Context.VIBRATOR_SERVICE);
- float density = launcher.getResources().getDisplayMetrics().density;
- mFlingToDeleteThresholdVelocity = (int) (FLING_TO_DELETE_THRESHOLD_Y_VELOCITY * density);
+ float density = r.getDisplayMetrics().density;
+ mFlingToDeleteThresholdVelocity =
+ (int) (r.getInteger(R.integer.config_flingToDeleteMinVelocity) * density);
}
public boolean dragging() {