diff options
author | Winson Chung <winsonc@google.com> | 2011-05-02 13:35:34 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-05-02 16:46:44 -0700 |
commit | fc79c8067e21e55fce3802a63e15ee4c6f11d595 (patch) | |
tree | ab88db769f49af5cb2a8773079ab92f7839aa028 /src/com/android/launcher2/AppsCustomizePagedView.java | |
parent | 8ef487680042fc3045323223b15449b2bf40e8e3 (diff) | |
download | android_packages_apps_Trebuchet-fc79c8067e21e55fce3802a63e15ee4c6f11d595.tar.gz android_packages_apps_Trebuchet-fc79c8067e21e55fce3802a63e15ee4c6f11d595.tar.bz2 android_packages_apps_Trebuchet-fc79c8067e21e55fce3802a63e15ee4c6f11d595.zip |
Fixing drag and drop issues with AppsCustomize pane.
- Fixing issue with no-more-space error not showing
- Returning to first page of AllApps when leaving and coming back
Change-Id: If3fb1ba1abae9d453bb71214e44170df91a52189
Diffstat (limited to 'src/com/android/launcher2/AppsCustomizePagedView.java')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 38 |
1 files changed, 34 insertions, 4 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() { |