summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Workspace.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2010-11-24 14:50:01 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-24 14:50:01 -0800
commit2dbae21ee92f5c6744c362c48499ff96e5cace4d (patch)
tree9e7729825c03ae7ba27b6198812746db8fedc564 /src/com/android/launcher2/Workspace.java
parent5a05154d6b0dd49cda4b6507e7f768ab87d8f734 (diff)
parent9c6de3d7c3e7d40e1e443b6fd69e3077ab9e9673 (diff)
downloadandroid_packages_apps_Trebuchet-2dbae21ee92f5c6744c362c48499ff96e5cace4d.tar.gz
android_packages_apps_Trebuchet-2dbae21ee92f5c6744c362c48499ff96e5cace4d.tar.bz2
android_packages_apps_Trebuchet-2dbae21ee92f5c6744c362c48499ff96e5cace4d.zip
Merge "ignore drop position when dragging items to small screens"
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r--src/com/android/launcher2/Workspace.java80
1 files changed, 38 insertions, 42 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index bfe5718ea..d99e9af5a 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1168,24 +1168,14 @@ public class Workspace extends SmoothPagedView
updateWhichPagesAcceptDrops(mShrunkenState);
}
- // We call this when we trigger an unshrink by clicking on the CellLayout cl
- public void unshrink(CellLayout clThatWasClicked) {
- int newCurrentPage = mCurrentPage;
- final int screenCount = getChildCount();
- for (int i = 0; i < screenCount; i++) {
- if (getChildAt(i) == clThatWasClicked) {
- newCurrentPage = i;
- }
- }
- unshrink(newCurrentPage);
- }
-
@Override
protected boolean handlePagingClicks() {
return true;
}
- private void unshrink(int newCurrentPage) {
+ // We call this when we trigger an unshrink by clicking on the CellLayout cl
+ public void unshrink(CellLayout clThatWasClicked) {
+ int newCurrentPage = indexOfChild(clThatWasClicked);
if (mIsSmall) {
int newX = getChildOffset(newCurrentPage) - getRelativeChildOffset(newCurrentPage);
int delta = newX - mScrollX;
@@ -1528,7 +1518,13 @@ public class Workspace extends SmoothPagedView
}
if (source != this) {
- onDropExternal(originX, originY, dragInfo, mDragTargetLayout);
+ if (mIsSmall) {
+ // if we drag and drop to small screens, don't pass the touch x/y coords (when we
+ // enable spring-loaded adding, however, we do want to pass the touch x/y coords)
+ onDropExternal(-1, -1, dragInfo, mDragTargetLayout);
+ } else {
+ onDropExternal(originX, originY, dragInfo, mDragTargetLayout);
+ }
} else if (mDragInfo != null) {
final View cell = mDragInfo.cell;
CellLayout dropTargetLayout = mDragTargetLayout;
@@ -2045,6 +2041,7 @@ public class Workspace extends SmoothPagedView
PendingAddItemInfo info = (PendingAddItemInfo) dragInfo;
// When dragging and dropping from customization tray, we deal with creating
// widgets/shortcuts/folders in a slightly different way
+ // Only set touchXY if you are supporting spring loaded adding of items
int[] touchXY = new int[2];
touchXY[0] = x;
touchXY[1] = y;
@@ -2063,38 +2060,37 @@ public class Workspace extends SmoothPagedView
}
cellLayout.onDragExit();
cellLayout.animateDrop();
- return;
- }
+ } else {
+ // This is for other drag/drop cases, like dragging from All Apps
+ ItemInfo info = (ItemInfo) dragInfo;
- // This is for other drag/drop cases, like dragging from All Apps
- ItemInfo info = (ItemInfo) dragInfo;
+ View view = null;
- View view = null;
+ switch (info.itemType) {
+ case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
+ case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
+ if (info.container == NO_ID && info instanceof ApplicationInfo) {
+ // Came from all apps -- make a copy
+ info = new ShortcutInfo((ApplicationInfo) info);
+ }
+ view = mLauncher.createShortcut(R.layout.application, cellLayout,
+ (ShortcutInfo) info);
+ break;
+ case LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER:
+ view = FolderIcon.fromXml(R.layout.folder_icon, mLauncher,
+ cellLayout, (UserFolderInfo) info, mIconCache);
+ break;
+ default:
+ throw new IllegalStateException("Unknown item type: " + info.itemType);
+ }
- switch (info.itemType) {
- case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
- case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
- if (info.container == NO_ID && info instanceof ApplicationInfo) {
- // Came from all apps -- make a copy
- info = new ShortcutInfo((ApplicationInfo) info);
+ mTargetCell = new int[2];
+ if (x != -1 && y != -1) {
+ // when dragging and dropping, just find the closest free spot
+ cellLayout.findNearestVacantArea(x, y, 1, 1, mTargetCell);
+ } else {
+ cellLayout.findCellForSpan(mTargetCell, 1, 1);
}
- view = mLauncher.createShortcut(R.layout.application, cellLayout,
- (ShortcutInfo) info);
- break;
- case LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER:
- view = FolderIcon.fromXml(R.layout.folder_icon, mLauncher,
- cellLayout, (UserFolderInfo) info, mIconCache);
- break;
- default:
- throw new IllegalStateException("Unknown item type: " + info.itemType);
- }
-
- // If the view is null, it has already been added.
- if (view == null) {
- cellLayout.onDragExit();
- } else {
- mTargetCell = new int[]{x, y};
- cellLayout.findCellForSpan(mTargetCell, 1, 1);
addInScreen(view, indexOfChild(cellLayout), mTargetCell[0],
mTargetCell[1], info.spanX, info.spanY, insertAtFirst);
cellLayout.onDropChild(view);