diff options
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 84 |
1 files changed, 59 insertions, 25 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 47e172f71..d9bff5e19 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -33,9 +33,7 @@ import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.content.res.Resources; import android.content.res.TypedArray; -import android.graphics.Camera; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -78,9 +76,6 @@ public class Workspace extends SmoothPagedView private static final int BACKGROUND_FADE_OUT_DURATION = 300; private static final int BACKGROUND_FADE_IN_DURATION = 100; - static final int SCROLL_RIGHT = 0; - static final int SCROLL_LEFT = 1; - // These animators are used to fade the private ObjectAnimator<Float> mBackgroundFadeIn; private ObjectAnimator<Float> mBackgroundFadeOut; @@ -126,11 +121,14 @@ public class Workspace extends SmoothPagedView private Drawable mPreviousIndicator; private Drawable mNextIndicator; - // State variable that indicated whether the pages are small (ie when you're + // State variable that indicates whether the pages are small (ie when you're // in all apps or customize mode) private boolean mIsSmall; + private AnimatorListener mUnshrinkAnimationListener; + private boolean mInScrollArea = false; + /** * Used to inflate the Workspace from XML. * @@ -389,7 +387,7 @@ public class Workspace extends SmoothPagedView return super.onInterceptTouchEvent(ev); } - protected void pageBeginMoving() { + protected void onPageBeginMoving() { if (mNextPage != INVALID_PAGE) { // we're snapping to a particular screen enableChildrenCache(mCurrentPage, mNextPage); @@ -401,9 +399,13 @@ public class Workspace extends SmoothPagedView showOutlines(); } - protected void pageEndMoving() { + protected void onPageEndMoving() { clearChildrenCache(); - hideOutlines(); + + // Hide the outlines, as long as we're not dragging + if (!mDragController.dragging()) { + hideOutlines(); + } } @Override @@ -500,11 +502,11 @@ public class Workspace extends SmoothPagedView getRelativeChildOffset(mCurrentPage) + halfScreenSize); float scrollProgress = Math.abs(delta/(pageWidth*1.0f + mPageSpacing)); - int scrollDirection = delta > 0 ? SCROLL_LEFT : SCROLL_RIGHT; + boolean scrollRight = (delta <= 0); float rotation; - if (scrollDirection == SCROLL_RIGHT) { + if (scrollRight) { rotation = -scrollProgress * WORKSPACE_ROTATION; cur.setRotationY(rotation); cur.setScaleX(getScaleXForRotation(rotation)); @@ -933,6 +935,7 @@ public class Workspace extends SmoothPagedView public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo) { getCurrentDropLayout().onDragEnter(dragView); + showOutlines(); } public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, int yOffset, @@ -1050,6 +1053,7 @@ public class Workspace extends SmoothPagedView mDragTargetLayout.onDragExit(); } mDragTargetLayout = bestMatchingScreen; + // TODO: Should we be calling mDragTargetLayout.onDragEnter() here? } return bestMatchingScreen; } @@ -1103,23 +1107,27 @@ public class Workspace extends SmoothPagedView } } } - if (currentLayout != mDragTargetLayout) { - if (mDragTargetLayout != null) { - mDragTargetLayout.onDragExit(); + + // When touch is inside the scroll area, skip dragOver actions for the current screen + if (!mInScrollArea) { + if (currentLayout != mDragTargetLayout) { + if (mDragTargetLayout != null) { + mDragTargetLayout.onDragExit(); + } currentLayout.onDragEnter(dragView); + mDragTargetLayout = currentLayout; } - mDragTargetLayout = currentLayout; - } - // only visualize the drop locations for moving icons within the home screen on tablet - // on phone, we also visualize icons dragged in from All Apps - if ((!LauncherApplication.isScreenXLarge() || source == this) - && mDragTargetLayout != null) { - final View child = (mDragInfo == null) ? null : mDragInfo.cell; - int localOriginX = originX - (mDragTargetLayout.getLeft() - mScrollX); - int localOriginY = originY - (mDragTargetLayout.getTop() - mScrollY); - mDragTargetLayout.visualizeDropLocation( - child, localOriginX, localOriginY, item.spanX, item.spanY); + // only visualize the drop locations for moving icons within the home screen on tablet + // on phone, we also visualize icons dragged in from All Apps + if ((!LauncherApplication.isScreenXLarge() || source == this) + && mDragTargetLayout != null) { + final View child = (mDragInfo == null) ? null : mDragInfo.cell; + int localOriginX = originX - (mDragTargetLayout.getLeft() - mScrollX); + int localOriginY = originY - (mDragTargetLayout.getTop() - mScrollY); + mDragTargetLayout.visualizeDropLocation( + child, localOriginX, localOriginY, item.spanX, item.spanY); + } } } @@ -1129,6 +1137,9 @@ public class Workspace extends SmoothPagedView mDragTargetLayout.onDragExit(); mDragTargetLayout = null; } + if (!mIsPageMoving) { + hideOutlines(); + } } private void onDropExternal(int x, int y, Object dragInfo, @@ -1342,6 +1353,29 @@ public class Workspace extends SmoothPagedView } } + @Override + public void onEnterScrollArea(int direction) { + mInScrollArea = true; + final int screen = getCurrentPage() + ((direction == DragController.SCROLL_LEFT) ? -1 : 1); + if (0 <= screen && screen < getChildCount()) { + ((CellLayout) getChildAt(screen)).setHover(true); + } + + if (mDragTargetLayout != null) { + mDragTargetLayout.onDragExit(); + mDragTargetLayout = null; + } + } + + @Override + public void onExitScrollArea() { + mInScrollArea = false; + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + ((CellLayout) getChildAt(i)).setHover(false); + } + } + public Folder getFolderForTag(Object tag) { final int screenCount = getChildCount(); for (int screen = 0; screen < screenCount; screen++) { |