Merge "Speed up All Apps -> Workspace transition"
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index a120ac5..8658eeb 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -47,7 +47,8 @@
/** Indicates the drag is a copy. */
public static int DRAG_ACTION_COPY = 1;
- private static final int SCROLL_DELAY = 600;
+ private static final int SCROLL_DELAY = 500;
+ private static final int RESCROLL_DELAY = 750;
private static final int VIBRATE_DURATION = 35;
private static final boolean PROFILE_DRAWING_DURING_DRAG = false;
@@ -388,6 +389,7 @@
private void endDrag() {
if (mDragging) {
mDragging = false;
+ clearScrollRunnable();
for (DragListener listener : mListeners) {
listener.onDragEnd();
}
@@ -456,6 +458,15 @@
return mMoveTarget != null && mMoveTarget.dispatchUnhandledMove(focused, direction);
}
+ private void clearScrollRunnable() {
+ mHandler.removeCallbacks(mScrollRunnable);
+ if (mScrollState == SCROLL_WAITING_IN_ZONE) {
+ mScrollState = SCROLL_OUTSIDE_ZONE;
+ mScrollRunnable.setDirection(SCROLL_RIGHT);
+ mDragScroller.onExitScrollArea();
+ }
+ }
+
private void handleMoveEvent(int x, int y) {
mDragObject.dragView.move(x, y);
@@ -491,30 +502,32 @@
Math.sqrt(Math.pow(mLastTouch[0] - x, 2) + Math.pow(mLastTouch[1] - y, 2));
mLastTouch[0] = x;
mLastTouch[1] = y;
+ final int delay = mDistanceSinceScroll < slop ? RESCROLL_DELAY : SCROLL_DELAY;
if (x < mScrollZone) {
- if (mScrollState == SCROLL_OUTSIDE_ZONE && mDistanceSinceScroll > slop) {
+ if (mScrollState == SCROLL_OUTSIDE_ZONE) {
mScrollState = SCROLL_WAITING_IN_ZONE;
if (mDragScroller.onEnterScrollArea(x, y, SCROLL_LEFT)) {
mScrollRunnable.setDirection(SCROLL_LEFT);
- mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
+ mHandler.postDelayed(mScrollRunnable, delay);
}
}
} else if (x > mScrollView.getWidth() - mScrollZone) {
- if (mScrollState == SCROLL_OUTSIDE_ZONE && mDistanceSinceScroll > slop) {
+ if (mScrollState == SCROLL_OUTSIDE_ZONE) {
mScrollState = SCROLL_WAITING_IN_ZONE;
if (mDragScroller.onEnterScrollArea(x, y, SCROLL_RIGHT)) {
mScrollRunnable.setDirection(SCROLL_RIGHT);
- mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
+ mHandler.postDelayed(mScrollRunnable, delay);
}
}
} else {
- if (mScrollState == SCROLL_WAITING_IN_ZONE) {
- mScrollState = SCROLL_OUTSIDE_ZONE;
- mScrollRunnable.setDirection(SCROLL_RIGHT);
- mHandler.removeCallbacks(mScrollRunnable);
- mDragScroller.onExitScrollArea();
- }
+ clearScrollRunnable();
+ }
+ }
+
+ public void forceMoveEvent() {
+ if (mDragging) {
+ handleMoveEvent(mDragObject.x, mDragObject.y);
}
}
@@ -558,6 +571,7 @@
endDrag();
break;
case MotionEvent.ACTION_CANCEL:
+ mHandler.removeCallbacks(mScrollRunnable);
cancelDrag();
break;
}
@@ -681,6 +695,11 @@
mScrollState = SCROLL_OUTSIDE_ZONE;
mDistanceSinceScroll = 0;
mDragScroller.onExitScrollArea();
+
+ if (isDragging()) {
+ // Force an update so that we can requeue the scroller if necessary
+ forceMoveEvent();
+ }
}
}
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index dd94175..a3063b6 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -222,11 +222,7 @@
}
void remove() {
- post(new Runnable() {
- public void run() {
- mDragLayer.removeView(DragView.this);
- }
- });
+ mDragLayer.removeView(DragView.this);
}
int[] getPosition(int[] result) {
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 331bc14..548b394 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -50,15 +50,7 @@
}
protected void drawableStateChanged() {
- if (isPressed()) {
- if (getAlpha() != 0.5f) {
- setAlpha(0.5f);
- }
- } else {
- if (getAlpha() != 1f) {
- setAlpha(1f);
- }
- }
+ setAlpha(isPressed() ? 0.5f : 1f);
super.drawableStateChanged();
}
}
diff --git a/src/com/android/launcher2/SpringLoadedDragController.java b/src/com/android/launcher2/SpringLoadedDragController.java
index 358362c..d96aab7 100644
--- a/src/com/android/launcher2/SpringLoadedDragController.java
+++ b/src/com/android/launcher2/SpringLoadedDragController.java
@@ -18,7 +18,7 @@
public class SpringLoadedDragController implements OnAlarmListener {
// how long the user must hover over a mini-screen before it unshrinks
- final long ENTER_SPRING_LOAD_HOVER_TIME = 550;
+ final long ENTER_SPRING_LOAD_HOVER_TIME = 500;
final long ENTER_SPRING_LOAD_CANCEL_HOVER_TIME = 950;
final long EXIT_SPRING_LOAD_HOVER_TIME = 200;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 2e54153..4ecc1a5 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -689,9 +689,15 @@
clearChildrenCache();
}
- // Hide the outlines, as long as we're not dragging
- if (!mDragController.dragging()) {
- // Only hide page outlines as we pan if we are on large screen
+
+ if (mDragController.isDragging()) {
+ if (isSmall()) {
+ // If we are in springloaded mode, then force an event to check if the current touch
+ // is under a new page (to scroll to)
+ mDragController.forceMoveEvent();
+ }
+ } else {
+ // If we are not mid-dragging, hide the page outlines if we are on a large screen
if (LauncherApplication.isScreenLarge()) {
hideOutlines();
}
@@ -1264,8 +1270,9 @@
final int paddingTop = mPaddingTop + offset;
final int paddingBottom = mPaddingBottom + offset;
- final CellLayout leftPage = (CellLayout) getChildAt(mCurrentPage - 1);
- final CellLayout rightPage = (CellLayout) getChildAt(mCurrentPage + 1);
+ final int page = (mNextPage != INVALID_PAGE ? mNextPage : mCurrentPage);
+ final CellLayout leftPage = (CellLayout) getChildAt(page - 1);
+ final CellLayout rightPage = (CellLayout) getChildAt(page + 1);
if (leftPage != null && leftPage.getIsDragOverlapping()) {
final Drawable d = getResources().getDrawable(R.drawable.page_hover_left_holo);
@@ -2476,7 +2483,11 @@
v.getMatrix().invert(mTempInverseMatrix);
cachedInverseMatrix = mTempInverseMatrix;
}
- xy[0] = xy[0] + mScrollX - v.getLeft();
+ int scrollX = mScrollX;
+ if (mNextPage != INVALID_PAGE) {
+ scrollX = mScroller.getFinalX();
+ }
+ xy[0] = xy[0] + scrollX - v.getLeft();
xy[1] = xy[1] + mScrollY - v.getTop();
cachedInverseMatrix.mapPoints(xy);
}
@@ -2498,7 +2509,11 @@
*/
void mapPointFromChildToSelf(View v, float[] xy) {
v.getMatrix().mapPoints(xy);
- xy[0] -= (mScrollX - v.getLeft());
+ int scrollX = mScrollX;
+ if (mNextPage != INVALID_PAGE) {
+ scrollX = mScroller.getFinalX();
+ }
+ xy[0] -= (scrollX - v.getLeft());
xy[1] -= (mScrollY - v.getTop());
}
@@ -3152,11 +3167,12 @@
if (!isSmall() && !mIsSwitchingState) {
mInScrollArea = true;
- final int page = mCurrentPage + (direction == DragController.SCROLL_LEFT ? -1 : 1);
- final CellLayout layout = (CellLayout) getChildAt(page);
+ final int page = (mNextPage != INVALID_PAGE ? mNextPage : mCurrentPage) +
+ (direction == DragController.SCROLL_LEFT ? -1 : 1);
cancelFolderCreation();
- if (layout != null) {
+ if (0 <= page && page < getChildCount()) {
+ CellLayout layout = (CellLayout) getChildAt(page);
// Exit the current layout and mark the overlapping layout
if (mDragTargetLayout != null) {
mDragTargetLayout.setIsDragOverlapping(false);