diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/DragLayer.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 35 |
2 files changed, 43 insertions, 6 deletions
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index 809a65138..7fbde5471 100644 --- a/src/com/android/launcher2/DragLayer.java +++ b/src/com/android/launcher2/DragLayer.java @@ -342,11 +342,16 @@ public class DragLayer extends FrameLayout { final int fromY = r.top; animateViewIntoPosition(dragView, fromX, fromY, pos[0], pos[1], scale, - onFinishRunnable, true); + onFinishRunnable, true, -1); } public void animateViewIntoPosition(DragView dragView, final View child, final Runnable onFinishAnimationRunnable) { + animateViewIntoPosition(dragView, child, -1, onFinishAnimationRunnable); + } + + public void animateViewIntoPosition(DragView dragView, final View child, int duration, + final Runnable onFinishAnimationRunnable) { ((CellLayoutChildren) child.getParent()).measureChild(child); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams(); @@ -396,16 +401,17 @@ public class DragLayer extends FrameLayout { oa.start(); } }; - animateViewIntoPosition(dragView, fromX, fromY, toX, toY, scale, onCompleteRunnable, true); + animateViewIntoPosition(dragView, fromX, fromY, toX, toY, scale, + onCompleteRunnable, true, duration); } private void animateViewIntoPosition(final View view, final int fromX, final int fromY, final int toX, final int toY, float finalScale, Runnable onCompleteRunnable, - boolean fadeOut) { + boolean fadeOut, int duration) { Rect from = new Rect(fromX, fromY, fromX + view.getMeasuredWidth(), fromY + view.getMeasuredHeight()); Rect to = new Rect(toX, toY, toX + view.getMeasuredWidth(), toY + view.getMeasuredHeight()); - animateView(view, from, to, 1f, finalScale, -1, null, null, onCompleteRunnable, true); + animateView(view, from, to, 1f, finalScale, duration, null, null, onCompleteRunnable, true); } /** diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 57d176047..c10bd1aea 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -97,6 +97,8 @@ public class Workspace extends SmoothPagedView private static final int BACKGROUND_FADE_OUT_DURATION = 350; private static final int BACKGROUND_FADE_IN_DURATION = 350; + private static final int ADJACENT_SCREEN_DROP_DURATION = 300; + // These animators are used to fade the children's outlines private ObjectAnimator mChildrenOutlineFadeInAnimation; private ObjectAnimator mChildrenOutlineFadeOutAnimation; @@ -213,6 +215,9 @@ public class Workspace extends SmoothPagedView final static float TOUCH_SLOP_DAMPING_FACTOR = 4; // These variables are used for storing the initial and final values during workspace animations + private int mSavedScrollX; + private float mSavedRotationY; + private float mSavedTranslationX; private float mCurrentScaleX; private float mCurrentScaleY; private float mCurrentRotationY; @@ -2293,6 +2298,7 @@ public class Workspace extends SmoothPagedView } CellLayout dropTargetLayout = mDragTargetLayout; + int snapScreen = -1; if (d.dragSource != this) { final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1] }; @@ -2344,10 +2350,10 @@ public class Workspace extends SmoothPagedView dropTargetLayout, mTargetCell); if (dropInscrollArea && mState != State.SPRING_LOADED) { + snapScreen = screen; snapToPage(screen); } - if (mTargetCell[0] >= 0 && mTargetCell[1] >= 0) { if (hasMovedLayouts) { // Reparent the view @@ -2410,8 +2416,11 @@ public class Workspace extends SmoothPagedView }; mAnimatingViewIntoPlace = true; if (d.dragView.hasDrawn()) { - mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, + int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION; + setFinalScrollForPageChange(snapScreen); + mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration, disableHardwareLayersRunnable); + resetFinalScrollForPageChange(snapScreen); } else { cell.setVisibility(VISIBLE); } @@ -2419,6 +2428,28 @@ public class Workspace extends SmoothPagedView } } + public void setFinalScrollForPageChange(int screen) { + if (screen >= 0) { + mSavedScrollX = getScrollX(); + CellLayout cl = (CellLayout) getChildAt(screen); + mSavedTranslationX = cl.getTranslationX(); + mSavedRotationY = cl.getRotationY(); + final int newX = getChildOffset(screen) - getRelativeChildOffset(screen); + setScrollX(newX); + cl.setTranslationX(0f); + cl.setRotationY(0f); + } + } + + public void resetFinalScrollForPageChange(int screen) { + if (screen >= 0) { + CellLayout cl = (CellLayout) getChildAt(screen); + setScrollX(mSavedScrollX); + cl.setTranslationX(mSavedTranslationX); + cl.setRotationY(mSavedRotationY); + } + } + public void getViewLocationRelativeToSelf(View v, int[] location) { getLocationInWindow(location); int x = location[0]; |