OSDN Git Service

Fixing issue 5043360, double haptic feedback
authorAdam Cohen <adamcohen@google.com>
Mon, 1 Aug 2011 19:12:49 +0000 (12:12 -0700)
committerAdam Cohen <adamcohen@google.com>
Mon, 1 Aug 2011 19:12:49 +0000 (12:12 -0700)
-> Minor code cleanup in Folder.java

Change-Id: I62267078bfdab9f37fdef28448a63760db1fc1fb

src/com/android/launcher2/Folder.java
src/com/android/launcher2/Launcher.java

index 652c8b0..45730e0 100644 (file)
@@ -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<ShortcutInfo> 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);
index 400c881..34cbf1a 100644 (file)
@@ -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);
                 }
             }