Merge "Fix issue with spring loaded mode" into honeycomb
diff --git a/src/com/android/launcher2/SpringLoadedDragController.java b/src/com/android/launcher2/SpringLoadedDragController.java
index a734258..9007581 100644
--- a/src/com/android/launcher2/SpringLoadedDragController.java
+++ b/src/com/android/launcher2/SpringLoadedDragController.java
@@ -26,6 +26,8 @@
// the screen the user is currently hovering over, if any
private CellLayout mScreen;
private Launcher mLauncher;
+ boolean mFinishedAnimation = false;
+ boolean mWaitingToReenter = false;
public SpringLoadedDragController(Launcher launcher) {
mLauncher = launcher;
@@ -33,9 +35,16 @@
mAlarm.setOnAlarmListener(this);
}
- public void onDragEnter(CellLayout cl) {
+ public void onDragEnter(CellLayout cl, boolean isSpringLoaded) {
mScreen = cl;
mAlarm.setAlarm(ENTER_SPRING_LOAD_HOVER_TIME);
+ mFinishedAnimation = isSpringLoaded;
+ mWaitingToReenter = false;
+ }
+
+ public void onEnterSpringLoadedMode(boolean waitToReenter) {
+ mFinishedAnimation = true;
+ mWaitingToReenter = waitToReenter;
}
public void onDragExit() {
@@ -43,7 +52,9 @@
mScreen.onDragExit();
}
mScreen = null;
- mAlarm.setAlarm(EXIT_SPRING_LOAD_HOVER_TIME);
+ if (mFinishedAnimation && !mWaitingToReenter) {
+ mAlarm.setAlarm(EXIT_SPRING_LOAD_HOVER_TIME);
+ }
}
// this is called when our timer runs out
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 270027b..842f2f3 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -209,6 +209,13 @@
boolean mUpdateWallpaperOffsetImmediately = false;
boolean mSyncWallpaperOffsetWithScroll = true;
+ // info about the last drag
+ private DragView mLastDragView;
+ private int mLastDragOriginX;
+ private int mLastDragOriginY;
+ private int mLastDragXOffset;
+ private int mLastDragYOffset;
+
/**
* Used to inflate the Workspace from XML.
*
@@ -275,11 +282,19 @@
mIsInUnshrinkAnimation = true;
disableCacheUpdates();
}
+
@Override
public void onAnimationEnd(Animator animation) {
mIsInUnshrinkAnimation = false;
mSyncWallpaperOffsetWithScroll = true;
- if (mShrinkState != ShrinkState.SPRING_LOADED) {
+ if (mShrinkState == ShrinkState.SPRING_LOADED) {
+ View layout = null;
+ if (mLastDragView != null) {
+ layout = findMatchingPageForDragOver(mLastDragView, mLastDragOriginX,
+ mLastDragOriginY, mLastDragXOffset, mLastDragYOffset);
+ }
+ mSpringLoadedDragController.onEnterSpringLoadedMode(layout == null);
+ } else {
mDrawCustomizeTrayBackground = false;
}
enableCacheUpdates();
@@ -1499,6 +1514,7 @@
// we call this method whenever a drag and drop in Launcher finishes, even if Workspace was
// never dragged over
public void onDragStopped(boolean success) {
+ mLastDragView = null;
// In the success case, DragController has already called onDragExit()
if (!success) {
doDragExit();
@@ -2338,8 +2354,12 @@
int originY = y - yOffset;
boolean shrunken = mIsSmall || mIsInUnshrinkAnimation;
if (shrunken) {
- layout = findMatchingPageForDragOver(
- dragView, originX, originY, xOffset, yOffset);
+ mLastDragView = dragView;
+ mLastDragOriginX = originX;
+ mLastDragOriginY = originY;
+ mLastDragXOffset = xOffset;
+ mLastDragYOffset = yOffset;
+ layout = findMatchingPageForDragOver(dragView, originX, originY, xOffset, yOffset);
if (layout != mDragTargetLayout) {
if (mDragTargetLayout != null) {
@@ -2349,7 +2369,8 @@
mDragTargetLayout = layout;
if (mDragTargetLayout != null && mDragTargetLayout.getAcceptsDrops()) {
mDragTargetLayout.setIsDragOverlapping(true);
- mSpringLoadedDragController.onDragEnter(mDragTargetLayout);
+ mSpringLoadedDragController.onDragEnter(
+ mDragTargetLayout, mShrinkState == ShrinkState.SPRING_LOADED);
}
}
} else {