diff options
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 38 | ||||
-rw-r--r-- | src/com/android/launcher2/AppsCustomizeTabHost.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 6 |
3 files changed, 50 insertions, 6 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index f0a712a55..5f86f7e2f 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -362,14 +362,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen protected boolean beginDragging(View v) { if (!super.beginDragging(v)) return false; + // Hide the pane so that the user can drop onto the workspace, we must do this first, + // due to how the drop target layout is computed when we start dragging to the workspace. + mLauncher.showWorkspace(true); + if (v instanceof PagedViewIcon) { beginDraggingApplication(v); } else if (v instanceof PagedViewWidget) { beginDraggingWidget(v); } - // Hide the pane so that the user can drop onto the workspace - mLauncher.showWorkspace(true); return true; } private void endDragging(boolean success) { @@ -401,6 +403,27 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen @Override public void onDropCompleted(View target, Object dragInfo, boolean success) { endDragging(success); + + // Display an error message if the drag failed due to there not being enough space on the + // target layout we were dropping on. + if (!success) { + boolean showOutOfSpaceMessage = false; + if (target instanceof Workspace) { + int currentScreen = mLauncher.getCurrentWorkspaceScreen(); + Workspace workspace = (Workspace) target; + CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen); + ItemInfo itemInfo = (ItemInfo) dragInfo; + if (layout != null) { + layout.calculateSpans(itemInfo); + showOutOfSpaceMessage = + !layout.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY); + } + } + // TODO-APPS_CUSTOMIZE: We need to handle this for folders as well later. + if (showOutOfSpaceMessage) { + mLauncher.showOutOfSpaceMessage(); + } + } } public void setContentType(ContentType type) { @@ -717,8 +740,15 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } @Override public void reset() { - setCurrentPage(0); - invalidatePageData(); + if (mContentType != ContentType.Applications) { + // Reset to the first page of the Apps pane + AppsCustomizeTabHost tabs = (AppsCustomizeTabHost) + mLauncher.findViewById(R.id.apps_customize_pane); + tabs.setCurrentTabByTag(tabs.getTabTagForContentType(ContentType.Applications)); + } else { + setCurrentPage(0); + invalidatePageData(); + } } @Override public void dumpState() { diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index 5820ce710..15920c34a 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -96,6 +96,18 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona } /** + * Returns the tab tag for a given content type. + */ + public String getTabTagForContentType(AppsCustomizePagedView.ContentType type) { + if (type == AppsCustomizePagedView.ContentType.Applications) { + return APPS_TAB_TAG; + } else if (type == AppsCustomizePagedView.ContentType.Widgets) { + return WIDGETS_TAB_TAG; + } + return APPS_TAB_TAG; + } + + /** * Disable focus on anything under this view in the hierarchy if we are not visible. */ @Override diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index dc22d847c..2d15ffa18 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -2391,7 +2391,9 @@ public class Workspace extends SmoothPagedView if (source != this) { final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1] }; - if ((mIsSmall || mIsInUnshrinkAnimation) && !mLauncher.isAllAppsVisible()) { + if (LauncherApplication.isScreenXLarge() + && (mIsSmall || mIsInUnshrinkAnimation) + && !mLauncher.isAllAppsVisible()) { // When the workspace is shrunk and the drop comes from customize, don't actually // add the item to the screen -- customize will do this itself ((ItemInfo) dragInfo).dropPos = touchXY; @@ -2893,7 +2895,7 @@ public class Workspace extends SmoothPagedView mLastDragYOffset = yOffset; layout = findMatchingPageForDragOver(dragView, left, top, xOffset, yOffset); - if (layout != mDragTargetLayout) { + if (layout != null && layout != mDragTargetLayout) { if (mDragTargetLayout != null) { mDragTargetLayout.setIsDragOverlapping(false); mSpringLoadedDragController.onDragExit(); |