diff options
21 files changed, 27 insertions, 156 deletions
diff --git a/res/drawable-hdpi/page_hover_left.9.png b/res/drawable-hdpi/page_hover_left.9.png Binary files differdeleted file mode 100644 index 3f11d0b33..000000000 --- a/res/drawable-hdpi/page_hover_left.9.png +++ /dev/null diff --git a/res/drawable-hdpi/page_hover_left_active.9.png b/res/drawable-hdpi/page_hover_left_active.9.png Binary files differdeleted file mode 100644 index abe4c31a9..000000000 --- a/res/drawable-hdpi/page_hover_left_active.9.png +++ /dev/null diff --git a/res/drawable-hdpi/page_hover_right.9.png b/res/drawable-hdpi/page_hover_right.9.png Binary files differdeleted file mode 100644 index 3bcf19195..000000000 --- a/res/drawable-hdpi/page_hover_right.9.png +++ /dev/null diff --git a/res/drawable-hdpi/page_hover_right_active.9.png b/res/drawable-hdpi/page_hover_right_active.9.png Binary files differdeleted file mode 100644 index 101e4dc0f..000000000 --- a/res/drawable-hdpi/page_hover_right_active.9.png +++ /dev/null diff --git a/res/drawable-mdpi/page_hover_left.9.png b/res/drawable-mdpi/page_hover_left.9.png Binary files differdeleted file mode 100644 index 2b6094cf6..000000000 --- a/res/drawable-mdpi/page_hover_left.9.png +++ /dev/null diff --git a/res/drawable-mdpi/page_hover_left_active.9.png b/res/drawable-mdpi/page_hover_left_active.9.png Binary files differdeleted file mode 100644 index 9eb00a282..000000000 --- a/res/drawable-mdpi/page_hover_left_active.9.png +++ /dev/null diff --git a/res/drawable-mdpi/page_hover_right.9.png b/res/drawable-mdpi/page_hover_right.9.png Binary files differdeleted file mode 100644 index c2e598351..000000000 --- a/res/drawable-mdpi/page_hover_right.9.png +++ /dev/null diff --git a/res/drawable-mdpi/page_hover_right_active.9.png b/res/drawable-mdpi/page_hover_right_active.9.png Binary files differdeleted file mode 100644 index d2771a1a5..000000000 --- a/res/drawable-mdpi/page_hover_right_active.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/page_hover_left.9.png b/res/drawable-xhdpi/page_hover_left.9.png Binary files differdeleted file mode 100644 index dbcc0abd2..000000000 --- a/res/drawable-xhdpi/page_hover_left.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/page_hover_left_active.9.png b/res/drawable-xhdpi/page_hover_left_active.9.png Binary files differdeleted file mode 100644 index 3233efe28..000000000 --- a/res/drawable-xhdpi/page_hover_left_active.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/page_hover_right.9.png b/res/drawable-xhdpi/page_hover_right.9.png Binary files differdeleted file mode 100644 index d82f809bf..000000000 --- a/res/drawable-xhdpi/page_hover_right.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/page_hover_right_active.9.png b/res/drawable-xhdpi/page_hover_right_active.9.png Binary files differdeleted file mode 100644 index 819ea195c..000000000 --- a/res/drawable-xhdpi/page_hover_right_active.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/page_hover_left.9.png b/res/drawable-xxhdpi/page_hover_left.9.png Binary files differdeleted file mode 100644 index c81f86c02..000000000 --- a/res/drawable-xxhdpi/page_hover_left.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/page_hover_left_active.9.png b/res/drawable-xxhdpi/page_hover_left_active.9.png Binary files differdeleted file mode 100644 index 858a3b2ab..000000000 --- a/res/drawable-xxhdpi/page_hover_left_active.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/page_hover_right.9.png b/res/drawable-xxhdpi/page_hover_right.9.png Binary files differdeleted file mode 100644 index c5297703e..000000000 --- a/res/drawable-xxhdpi/page_hover_right.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/page_hover_right_active.9.png b/res/drawable-xxhdpi/page_hover_right_active.9.png Binary files differdeleted file mode 100644 index 99005536b..000000000 --- a/res/drawable-xxhdpi/page_hover_right_active.9.png +++ /dev/null diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index fd744dc85..a2f26a33a 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -199,7 +199,8 @@ public class Launcher extends Activity public static final String USER_HAS_MIGRATED = "launcher.user_migrated_from_old_data"; /** The different states that Launcher can be in. */ - enum State { NONE, WORKSPACE, APPS, APPS_SPRING_LOADED, WIDGETS, WIDGETS_SPRING_LOADED } + enum State { NONE, WORKSPACE, WORKSPACE_SPRING_LOADED, APPS, APPS_SPRING_LOADED, + WIDGETS, WIDGETS_SPRING_LOADED } @Thunk State mState = State.WORKSPACE; @Thunk LauncherStateTransitionAnimation mStateTransitionAnimation; @@ -1380,7 +1381,6 @@ public class Launcher extends Activity // Setup the drag controller (drop targets have to be added in reverse order in priority) dragController.setDragScoller(mWorkspace); - dragController.setScrollView(mDragLayer); dragController.setMoveTarget(mWorkspace); dragController.addDropTarget(mWorkspace); if (mSearchDropTargetBar != null) { @@ -3332,20 +3332,26 @@ public class Launcher extends Activity public void enterSpringLoadedDragMode() { if (LOGD) Log.d(TAG, String.format("enterSpringLoadedDragMode [mState=%s", mState.name())); - if (mState == State.WORKSPACE || mState == State.APPS_SPRING_LOADED || - mState == State.WIDGETS_SPRING_LOADED) { + if (isStateSpringLoaded()) { return; } mStateTransitionAnimation.startAnimationToWorkspace(mState, mWorkspace.getState(), Workspace.State.SPRING_LOADED, true /* animated */, null /* onCompleteRunnable */); - mState = isAppsViewVisible() ? State.APPS_SPRING_LOADED : State.WIDGETS_SPRING_LOADED; + + if (isAppsViewVisible()) { + mState = State.APPS_SPRING_LOADED; + } else if (isWidgetsViewVisible()) { + mState = State.WIDGETS_SPRING_LOADED; + } else { + mState = State.WORKSPACE_SPRING_LOADED; + } } public void exitSpringLoadedDragModeDelayed(final boolean successfulDrop, int delay, final Runnable onCompleteRunnable) { - if (mState != State.APPS_SPRING_LOADED && mState != State.WIDGETS_SPRING_LOADED) return; + if (!isStateSpringLoaded()) return; mHandler.postDelayed(new Runnable() { @Override @@ -3365,12 +3371,19 @@ public class Launcher extends Activity }, delay); } + private boolean isStateSpringLoaded() { + return mState == State.WORKSPACE_SPRING_LOADED || mState == State.APPS_SPRING_LOADED + || mState == State.WIDGETS_SPRING_LOADED; + } + void exitSpringLoadedDragMode() { if (mState == State.APPS_SPRING_LOADED) { showAppsView(true /* animated */, false /* resetListToTop */, false /* updatePredictedApps */, false /* focusSearchBar */); } else if (mState == State.WIDGETS_SPRING_LOADED) { showWidgetsView(true, false); + } else if (mState == State.WORKSPACE_SPRING_LOADED) { + showWorkspace(true); } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 14fb3fc59..fa149a9d0 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2356,6 +2356,8 @@ public class Workspace extends PagedView dv.setIntrinsicIconScaleFactor(source.getIntrinsicIconScaleFactor()); b.recycle(); + + mLauncher.enterSpringLoadedDragMode(); } public void beginExternalDragShared(View child, DragSource source) { @@ -2404,6 +2406,8 @@ public class Workspace extends PagedView // Recycle temporary bitmaps tmpB.recycle(); + + mLauncher.enterSpringLoadedDragMode(); } public boolean transitionStateShouldAllowDrop() { @@ -2861,10 +2865,6 @@ public class Workspace extends PagedView CellLayout layout = getCurrentDropLayout(); setCurrentDropLayout(layout); setCurrentDragOverlappingLayout(layout); - - if (!workspaceInModalState()) { - mLauncher.getDragLayer().showPageHints(); - } } @Override @@ -2899,8 +2899,6 @@ public class Workspace extends PagedView setCurrentDragOverlappingLayout(null); mSpringLoadedDragController.cancel(); - - mLauncher.getDragLayer().hidePageHints(); } private void enfoceDragParity(String event, int update, int expectedValue) { @@ -3735,6 +3733,9 @@ public class Workspace extends PagedView } mDragOutline = null; mDragInfo = null; + + mLauncher.exitSpringLoadedDragModeDelayed(success, + Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); } /** diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 41b4e047c..979a7332b 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -477,8 +477,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc // Start the drag mLauncher.getWorkspace().beginDragShared(v, mIconLastTouchPos, this, false); - // Enter spring loaded mode - mLauncher.enterSpringLoadedDragMode(); return false; } diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index 8777dc6ae..e72f3415a 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -82,7 +82,6 @@ public class DragController implements DragDriver.EventListener { // temporaries to avoid gc thrash private Rect mRectTemp = new Rect(); private final int[] mCoordinatesTemp = new int[2]; - private final boolean mIsRtl; /** * Drag driver for the current drag/drop operation, or null if there is no active DND operation. @@ -99,11 +98,6 @@ public class DragController implements DragDriver.EventListener { /** Y coordinate of the down event. */ private int mMotionDownY; - /** the area at the edge of the screen that makes the workspace go left - * or right while you're dragging. - */ - private final int mScrollZone; - private DropTarget.DragObject mDragObject; /** Who can receive drop events */ @@ -114,9 +108,6 @@ public class DragController implements DragDriver.EventListener { /** The window token used as the parent for the DragView. */ private IBinder mWindowToken; - /** The view that will be scrolled when dragging to the left and right edges of the screen. */ - private View mScrollView; - private View mMoveTarget; @Thunk DragScroller mDragScroller; @@ -129,7 +120,6 @@ public class DragController implements DragDriver.EventListener { @Thunk int mLastTouch[] = new int[2]; @Thunk long mLastTouchUpTime = -1; - @Thunk int mDistanceSinceScroll = 0; private int mTmpPoint[] = new int[2]; private Rect mDragLayerRect = new Rect(); @@ -159,19 +149,15 @@ public class DragController implements DragDriver.EventListener { /** * Used to create a new DragLayer from XML. - * - * @param context The application's context. */ public DragController(Launcher launcher) { Resources r = launcher.getResources(); mLauncher = launcher; mHandler = new Handler(); - mScrollZone = r.getDimensionPixelSize(R.dimen.scroll_zone); mVelocityTracker = VelocityTracker.obtain(); mFlingToDeleteThresholdVelocity = r.getDimensionPixelSize(R.dimen.drag_flingToDeleteMinVelocity); - mIsRtl = Utilities.isRtl(r); } /** @@ -559,7 +545,6 @@ public class DragController implements DragDriver.EventListener { mScrollState = SCROLL_OUTSIDE_ZONE; mScrollRunnable.setDirection(SCROLL_RIGHT); mDragScroller.onExitScrollArea(); - mLauncher.getDragLayer().onExitScrollArea(); } } @@ -573,11 +558,8 @@ public class DragController implements DragDriver.EventListener { mDragObject.y = coordinates[1]; checkTouchMove(dropTarget); - // Check if we are hovering over the scroll areas - mDistanceSinceScroll += Math.hypot(mLastTouch[0] - x, mLastTouch[1] - y); mLastTouch[0] = x; mLastTouch[1] = y; - checkScrollState(x, y); } public void forceTouchMove() { @@ -605,36 +587,6 @@ public class DragController implements DragDriver.EventListener { mLastDropTarget = dropTarget; } - @Thunk void checkScrollState(int x, int y) { - final int slop = ViewConfiguration.get(mLauncher).getScaledWindowTouchSlop(); - final int delay = mDistanceSinceScroll < slop ? RESCROLL_DELAY : SCROLL_DELAY; - final DragLayer dragLayer = mLauncher.getDragLayer(); - final int forwardDirection = mIsRtl ? SCROLL_RIGHT : SCROLL_LEFT; - final int backwardsDirection = mIsRtl ? SCROLL_LEFT : SCROLL_RIGHT; - - if (x < mScrollZone) { - if (mScrollState == SCROLL_OUTSIDE_ZONE) { - mScrollState = SCROLL_WAITING_IN_ZONE; - if (mDragScroller.onEnterScrollArea(x, y, forwardDirection)) { - dragLayer.onEnterScrollArea(forwardDirection); - mScrollRunnable.setDirection(forwardDirection); - mHandler.postDelayed(mScrollRunnable, delay); - } - } - } else if (x > mScrollView.getWidth() - mScrollZone) { - if (mScrollState == SCROLL_OUTSIDE_ZONE) { - mScrollState = SCROLL_WAITING_IN_ZONE; - if (mDragScroller.onEnterScrollArea(x, y, backwardsDirection)) { - dragLayer.onEnterScrollArea(backwardsDirection); - mScrollRunnable.setDirection(backwardsDirection); - mHandler.postDelayed(mScrollRunnable, delay); - } - } - } else { - clearScrollRunnable(); - } - } - /** * Call this from a drag source view. */ @@ -656,13 +608,6 @@ public class DragController implements DragDriver.EventListener { // Remember where the motion event started mMotionDownX = dragLayerX; mMotionDownY = dragLayerY; - - if ((dragLayerX < mScrollZone) || (dragLayerX > mScrollView.getWidth() - mScrollZone)) { - mScrollState = SCROLL_WAITING_IN_ZONE; - mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY); - } else { - mScrollState = SCROLL_OUTSIDE_ZONE; - } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: @@ -847,13 +792,6 @@ public class DragController implements DragDriver.EventListener { } } - /** - * Set which view scrolls for touch events near the edge of the screen. - */ - public void setScrollView(View v) { - mScrollView = v; - } - private class ScrollRunnable implements Runnable { private int mDirection; @@ -868,14 +806,7 @@ public class DragController implements DragDriver.EventListener { mDragScroller.scrollRight(); } mScrollState = SCROLL_OUTSIDE_ZONE; - mDistanceSinceScroll = 0; mDragScroller.onExitScrollArea(); - mLauncher.getDragLayer().onExitScrollArea(); - - if (isDragging()) { - // Check the scroll again so that we can requeue the scroller if necessary - checkScrollState(mLastTouch[0], mLastTouch[1]); - } } } diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 741d5e662..6b6bef42f 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -102,15 +102,6 @@ public class DragLayer extends InsettableFrameLayout { // Darkening scrim private float mBackgroundAlpha = 0; - // Related to adjacent page hints - private final Rect mScrollChildPosition = new Rect(); - private boolean mInScrollArea; - private boolean mShowPageHints; - private Drawable mLeftHoverDrawable; - private Drawable mRightHoverDrawable; - private Drawable mLeftHoverDrawableActive; - private Drawable mRightHoverDrawableActive; - private boolean mBlockTouches = false; /** @@ -126,12 +117,7 @@ public class DragLayer extends InsettableFrameLayout { setMotionEventSplittingEnabled(false); setChildrenDrawingOrderEnabled(true); - final Resources res = getResources(); - mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left); - mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right); - mLeftHoverDrawableActive = res.getDrawable(R.drawable.page_hover_left_active); - mRightHoverDrawableActive = res.getDrawable(R.drawable.page_hover_right_active); - mIsRtl = Utilities.isRtl(res); + mIsRtl = Utilities.isRtl(getResources()); } public void setup(Launcher launcher, DragController controller) { @@ -895,29 +881,6 @@ public class DragLayer extends InsettableFrameLayout { } } - void onEnterScrollArea(int direction) { - mInScrollArea = true; - invalidate(); - } - - void onExitScrollArea() { - mInScrollArea = false; - invalidate(); - } - - public void showPageHints() { - mShowPageHints = true; - Workspace workspace = mLauncher.getWorkspace(); - getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.numCustomPages()), - mScrollChildPosition); - invalidate(); - } - - public void hidePageHints() { - mShowPageHints = false; - invalidate(); - } - @Override protected void dispatchDraw(Canvas canvas) { // Draw the background below children. @@ -929,41 +892,6 @@ public class DragLayer extends InsettableFrameLayout { super.dispatchDraw(canvas); } - private void drawPageHints(Canvas canvas) { - if (mShowPageHints) { - Workspace workspace = mLauncher.getWorkspace(); - int width = getMeasuredWidth(); - int page = workspace.getNextPage(); - CellLayout leftPage = (CellLayout) workspace.getChildAt(mIsRtl ? page + 1 : page - 1); - CellLayout rightPage = (CellLayout) workspace.getChildAt(mIsRtl ? page - 1 : page + 1); - - if (leftPage != null && leftPage.isDragTarget()) { - Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ? - mLeftHoverDrawableActive : mLeftHoverDrawable; - left.setBounds(0, mScrollChildPosition.top, - left.getIntrinsicWidth(), mScrollChildPosition.bottom); - left.draw(canvas); - } - if (rightPage != null && rightPage.isDragTarget()) { - Drawable right = mInScrollArea && rightPage.getIsDragOverlapping() ? - mRightHoverDrawableActive : mRightHoverDrawable; - right.setBounds(width - right.getIntrinsicWidth(), - mScrollChildPosition.top, width, mScrollChildPosition.bottom); - right.draw(canvas); - } - } - } - - protected boolean drawChild(Canvas canvas, View child, long drawingTime) { - boolean ret = super.drawChild(canvas, child, drawingTime); - - // We want to draw the page hints above the workspace, but below the drag view. - if (child instanceof Workspace) { - drawPageHints(canvas); - } - return ret; - } - public void setBackgroundAlpha(float alpha) { if (alpha != mBackgroundAlpha) { mBackgroundAlpha = alpha; |