From 05e0f40e50574f50678a9e1461cb245cddc46abb Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Mon, 1 Aug 2011 12:12:49 -0700 Subject: Fixing issue 5043360, double haptic feedback -> Minor code cleanup in Folder.java Change-Id: I62267078bfdab9f37fdef28448a63760db1fc1fb --- src/com/android/launcher2/Folder.java | 28 +++++++++++++++------------- src/com/android/launcher2/Launcher.java | 2 -- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index 652c8b03d..45730e018 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -101,7 +101,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private boolean mDragInProgress = false; private boolean mDeleteFolderOnDropCompleted = false; private boolean mSuppressFolderDeletion = false; - private boolean mItemAddedBackToSelf = false; + private boolean mItemAddedBackToSelfViaIcon = false; private boolean mIsEditingName = false; private InputMethodManager mInputMethodManager; @@ -221,7 +221,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mContent.removeView(mCurrentDragView); mInfo.remove(mCurrentDragInfo); mDragInProgress = true; - mItemAddedBackToSelf = false; + mItemAddedBackToSelfViaIcon = false; } return true; } @@ -297,12 +297,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mContent.requestLayout(); } - void onClose() { - DragLayer parent = (DragLayer) getParent(); - parent.removeView(Folder.this); - clearFocus(); - } - void bind(FolderInfo info) { mInfo = info; ArrayList children = info.contents; @@ -465,7 +459,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - onClose(); onCloseComplete(); mState = STATE_SMALL; } @@ -662,7 +655,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void onDropCompleted(View target, DragObject d, boolean success) { if (success) { - if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelf) { + if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon) { replaceFolderWithFinalItem(); } } else { @@ -684,7 +677,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } mDeleteFolderOnDropCompleted = false; mDragInProgress = false; - mItemAddedBackToSelf = false; + mItemAddedBackToSelfViaIcon = false; mCurrentDragInfo = null; mCurrentDragView = null; mSuppressOnAdd = false; @@ -692,7 +685,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void notifyDrop() { if (mDragInProgress) { - mItemAddedBackToSelf = true; + mItemAddedBackToSelfViaIcon = true; } } @@ -853,6 +846,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } private void onCloseComplete() { + DragLayer parent = (DragLayer) getParent(); + parent.removeView(Folder.this); + clearFocus(); + if (mRearrangeOnClose) { setupContentForNumItems(getItemCount()); mRearrangeOnClose = false; @@ -908,7 +905,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } else { item = (ShortcutInfo) d.dragInfo; } - // Dragged from self onto self + // Dragged from self onto self, currently this is the only path possible, however + // we keep this as a distinct code path. if (item == mCurrentDragInfo) { ShortcutInfo si = (ShortcutInfo) mCurrentDragView.getTag(); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mCurrentDragView.getLayoutParams(); @@ -929,6 +927,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void onAdd(ShortcutInfo item) { mItemsInvalidated = true; + // If the item was dropped onto this open folder, we have done the work associated + // with adding the item to the folder, as indicated by mSuppressOnAdd being set if (mSuppressOnAdd) return; if (!findAndSetEmptyCells(item)) { // The current layout is full, can we expand it? @@ -942,6 +942,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void onRemove(ShortcutInfo item) { mItemsInvalidated = true; + // If this item is being dragged from this open folder, we have already handled + // the work associated with removing the item, so we don't have to do anything here. if (item == mCurrentDragInfo) return; View v = getViewForInfo(item); mContent.removeView(v); diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 400c8813a..34cbf1a73 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1828,8 +1828,6 @@ public final class Launcher extends Activity } else { if (!(itemUnderLongClick instanceof Folder)) { // User long pressed on an item - mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, - HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); mWorkspace.startDrag(longClickCellInfo); } } -- cgit v1.2.3