diff options
Diffstat (limited to 'src/com/android/launcher3/Workspace.java')
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 87840a7bd..132f42d5f 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -194,6 +194,7 @@ public class Workspace extends SmoothPagedView private final int[] mTempXY = new int[2]; private int[] mTempVisiblePagesRange = new int[2]; private boolean mOverscrollTransformsSet; + private float mLastOverscrollPivotX; public static final int DRAG_BITMAP_PADDING = 2; private boolean mWorkspaceFadeInAdjacentScreens; @@ -1035,12 +1036,14 @@ public class Workspace extends SmoothPagedView if (mCustomContentCallbacks != null) { mCustomContentCallbacks.onShow(); mCustomContentShowTime = System.currentTimeMillis(); + mLauncher.setVoiceButtonProxyVisible(false); } } else if (hasCustomContent() && getNextPage() != 0 && mCustomContentShowing) { mCustomContentShowing = false; if (mCustomContentCallbacks != null) { mCustomContentCallbacks.onHide(); mLauncher.resetQSBScroll(); + mLauncher.setVoiceButtonProxyVisible(true); } } }; @@ -1413,22 +1416,20 @@ public class Workspace extends SmoothPagedView final float rightBiasedPivot = 0.75f; final int lowerIndex = 0; final int upperIndex = getChildCount() - 1; - if (isRtl) { - index = mOverScrollX < 0 ? upperIndex : lowerIndex; - pivotX = (index == 0 ? leftBiasedPivot : rightBiasedPivot); - } else { - index = mOverScrollX < 0 ? lowerIndex : upperIndex; - pivotX = (index == 0 ? rightBiasedPivot : leftBiasedPivot); - } + + final boolean isLeftPage = mOverScrollX < 0; + index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex; + pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot; CellLayout cl = (CellLayout) getChildAt(index); float scrollProgress = getScrollProgress(screenCenter, cl, index); - final boolean isLeftPage = (isRtl ? index > 0 : index == 0); cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage); float rotation = -WORKSPACE_OVERSCROLL_ROTATION * scrollProgress; cl.setRotationY(rotation); - if (!mOverscrollTransformsSet) { + + if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) { mOverscrollTransformsSet = true; + mLastOverscrollPivotX = pivotX; cl.setCameraDistance(mDensity * mCameraDistance); cl.setPivotX(cl.getMeasuredWidth() * pivotX); cl.setPivotY(cl.getMeasuredHeight() * 0.5f); @@ -1747,25 +1748,17 @@ public class Workspace extends SmoothPagedView protected void onStartReordering() { super.onStartReordering(); - int count = getChildCount(); - for (int i = 0; i < count; i++) { - ((CellLayout) getChildAt(i)).setUseActiveGlowBackground(true); - } showOutlines(); - // Reordering handles its own animations, disable the automatic ones. setLayoutTransition(null); } protected void onEndReordering() { super.onEndReordering(); - int count = getChildCount(); - for (int i = 0; i < count; i++) { - ((CellLayout) getChildAt(i)).setUseActiveGlowBackground(false); - } - hideOutlines(); + hideOutlines(); mScreenOrder.clear(); + int count = getChildCount(); for (int i = 0; i < count; i++) { CellLayout cl = ((CellLayout) getChildAt(i)); mScreenOrder.add(getIdForScreen(cl)); @@ -1781,9 +1774,13 @@ public class Workspace extends SmoothPagedView return mState == State.OVERVIEW; } - public void enterOverviewMode() { + public boolean enterOverviewMode() { + if (mTouchState != TOUCH_STATE_REST) { + return false; + } mLauncher.onInteractionBegin(); enableOverviewMode(true, -1, true); + return true; } public void exitOverviewMode(boolean animated) { @@ -2644,8 +2641,8 @@ public class Workspace extends SmoothPagedView } } - LauncherModel.moveItemInDatabase(mLauncher, info, container, screenId, lp.cellX, - lp.cellY); + LauncherModel.modifyItemInDatabase(mLauncher, info, container, screenId, lp.cellX, + lp.cellY, item.spanX, item.spanY); } else { // If we can't find a drop location, we return the item to its original position CellLayout.LayoutParams lp = (CellLayout.LayoutParams) cell.getLayoutParams(); @@ -2744,6 +2741,8 @@ public class Workspace extends SmoothPagedView } } + /** Return a rect that has the cellWidth/cellHeight (left, top), and + * widthGap/heightGap (right, bottom) */ static Rect getCellLayoutMetrics(Launcher launcher, int orientation) { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); @@ -2755,24 +2754,28 @@ public class Workspace extends SmoothPagedView display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) grid.numColumns; int countY = (int) grid.numRows; + int constrainedLongEdge = largestSize.y; + int constrainedShortEdge = smallestSize.y; if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.LANDSCAPE); - int width = largestSize.x - padding.left - padding.right; - int height = smallestSize.y - padding.top - padding.bottom; + int width = constrainedLongEdge - padding.left - padding.right; + int height = constrainedShortEdge - padding.top - padding.bottom; mLandscapeCellLayoutMetrics = new Rect(); - CellLayout.getMetrics(mLandscapeCellLayoutMetrics, width, height, - countX, countY); + mLandscapeCellLayoutMetrics.set( + grid.calculateCellWidth(width, countX), + grid.calculateCellHeight(height, countY), 0, 0); } return mLandscapeCellLayoutMetrics; } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.PORTRAIT); - int width = smallestSize.x - padding.left - padding.right; - int height = largestSize.y - padding.top - padding.bottom; + int width = constrainedShortEdge - padding.left - padding.right; + int height = constrainedLongEdge - padding.top - padding.bottom; mPortraitCellLayoutMetrics = new Rect(); - CellLayout.getMetrics(mPortraitCellLayoutMetrics, width, height, - countX, countY); + mPortraitCellLayoutMetrics.set( + grid.calculateCellWidth(width, countX), + grid.calculateCellHeight(height, countY), 0, 0); } return mPortraitCellLayoutMetrics; } @@ -3114,9 +3117,18 @@ public class Workspace extends SmoothPagedView ItemInfo info = (ItemInfo) d.dragInfo; + int minSpanX = item.spanX; + int minSpanY = item.spanY; + if (item.minSpanX > 0 && item.minSpanY > 0) { + minSpanX = item.minSpanX; + minSpanY = item.minSpanY; + } + mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], - (int) mDragViewVisualCenter[1], item.spanX, item.spanY, + (int) mDragViewVisualCenter[1], minSpanX, minSpanY, mDragTargetLayout, mTargetCell); + int reorderX = mTargetCell[0]; + int reorderY = mTargetCell[1]; setCurrentDropOverCell(mTargetCell[0], mTargetCell[1]); @@ -3129,13 +3141,6 @@ public class Workspace extends SmoothPagedView manageFolderFeedback(info, mDragTargetLayout, mTargetCell, targetCellDistance, dragOverView); - int minSpanX = item.spanX; - int minSpanY = item.spanY; - if (item.minSpanX > 0 && item.minSpanY > 0) { - minSpanX = item.minSpanX; - minSpanY = item.minSpanY; - } - boolean nearestDropOccupied = mDragTargetLayout.isNearestDropLocationOccupied((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], item.spanX, item.spanY, child, mTargetCell); @@ -3146,8 +3151,8 @@ public class Workspace extends SmoothPagedView mTargetCell[0], mTargetCell[1], item.spanX, item.spanY, false, d.dragView.getDragVisualizeOffset(), d.dragView.getDragRegion()); } else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER) - && !mReorderAlarm.alarmPending() && (mLastReorderX != mTargetCell[0] || - mLastReorderY != mTargetCell[1])) { + && !mReorderAlarm.alarmPending() && (mLastReorderX != reorderX || + mLastReorderY != reorderY)) { // Otherwise, if we aren't adding to or creating a folder and there's no pending // reorder, then we schedule a reorder @@ -3246,7 +3251,8 @@ public class Workspace extends SmoothPagedView public void onAlarm(Alarm alarm) { int[] resultSpan = new int[2]; mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], - (int) mDragViewVisualCenter[1], spanX, spanY, mDragTargetLayout, mTargetCell); + (int) mDragViewVisualCenter[1], minSpanX, minSpanY, mDragTargetLayout, + mTargetCell); mLastReorderX = mTargetCell[0]; mLastReorderY = mTargetCell[1]; |