summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-04-16 22:38:55 (GMT)
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-16 22:39:00 (GMT)
commitfb9ca2392894a3dea83570267f9597ac0750b9fd (patch)
treedbeffeec160b8753ddbe5e970936660cec315eba
parentfc3c1edf7bbc3f7cb23e79520731d13ccc2da046 (diff)
parentf406615354a92367481a60966b6b873cae37fe4c (diff)
downloadandroid_packages_apps_Trebuchet-fb9ca2392894a3dea83570267f9597ac0750b9fd.zip
android_packages_apps_Trebuchet-fb9ca2392894a3dea83570267f9597ac0750b9fd.tar.gz
android_packages_apps_Trebuchet-fb9ca2392894a3dea83570267f9597ac0750b9fd.tar.bz2
Merge "Fixing drag-n-drop for folders in hotseat." into ub-launcher3-burnaby
-rw-r--r--src/com/android/launcher3/DragController.java4
-rw-r--r--src/com/android/launcher3/Folder.java26
-rw-r--r--src/com/android/launcher3/Launcher.java12
3 files changed, 37 insertions, 5 deletions
diff --git a/src/com/android/launcher3/DragController.java b/src/com/android/launcher3/DragController.java
index eb16861..3473747 100644
--- a/src/com/android/launcher3/DragController.java
+++ b/src/com/android/launcher3/DragController.java
@@ -377,7 +377,7 @@ public class DragController {
// Only end the drag if we are not deferred
if (!isDeferred) {
- for (DragListener listener : mListeners) {
+ for (DragListener listener : new ArrayList<>(mListeners)) {
listener.onDragEnd();
}
}
@@ -394,7 +394,7 @@ public class DragController {
if (mDragObject.deferDragViewCleanupPostAnimation) {
// If we skipped calling onDragEnd() before, do it now
- for (DragListener listener : mListeners) {
+ for (DragListener listener : new ArrayList<>(mListeners)) {
listener.onDragEnd();
}
}
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 0eb1fd8..1163324 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -49,6 +49,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.TextView;
+import com.android.launcher3.DragController.DragListener;
import com.android.launcher3.FolderInfo.FolderListener;
import com.android.launcher3.Workspace.ItemOperator;
import com.android.launcher3.util.Thunk;
@@ -61,7 +62,7 @@ import java.util.Collections;
*/
public class Folder extends LinearLayout implements DragSource, View.OnClickListener,
View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener,
- View.OnFocusChangeListener {
+ View.OnFocusChangeListener, DragListener {
private static final String TAG = "Launcher.Folder";
/**
@@ -537,6 +538,20 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mScrollPauseAlarm.setAlarm(SORTED_STICKY_REORDER_DELAY);
}
+ // Since this folder opened by another controller, it might not get onDrop or
+ // onDropComplete. Perform cleanup once drag-n-drop ends.
+ mDragController.addDragListener(this);
+ }
+
+ @Override
+ public void onDragStart(DragSource source, Object info, int dragAction) { }
+
+ @Override
+ public void onDragEnd() {
+ if (mIsExternalDrag && mDragInProgress) {
+ completeDragExit();
+ }
+ mDragController.removeDragListener(this);
}
@Thunk void sendCustomAccessibilityEvent(int type, String text) {
@@ -678,11 +693,15 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
};
public void completeDragExit() {
- mLauncher.closeFolder();
+ if (mInfo.opened) {
+ mLauncher.closeFolder();
+ mRearrangeOnClose = true;
+ } else {
+ rearrangeChildren();
+ }
mCurrentDragInfo = null;
mCurrentDragView = null;
mSuppressOnAdd = false;
- mRearrangeOnClose = true;
mIsExternalDrag = false;
}
@@ -1124,6 +1143,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mSuppressOnAdd = false;
// Clear the drag info, as it is no longer being dragged.
mCurrentDragInfo = null;
+ mDragInProgress = false;
}
// This is used so the item doesn't immediately appear in the folder when added. In one case
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 5679dfc..3d8cf31 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3112,10 +3112,19 @@ public class Launcher extends Activity
*/
public void openFolder(FolderIcon folderIcon) {
Folder folder = folderIcon.getFolder();
+ Folder openFolder = mWorkspace != null ? mWorkspace.getOpenFolder() : null;
+ if (openFolder != null && openFolder != folder) {
+ // Close any open folder before opening a folder.
+ closeFolder();
+ }
+
FolderInfo info = folder.mInfo;
info.opened = true;
+ // While the folder is open, the position of the icon cannot change.
+ ((CellLayout.LayoutParams) folderIcon.getLayoutParams()).canReorder = false;
+
// Just verify that the folder hasn't already been added to the DragLayer.
// There was a one-off crash where the folder had a parent already.
if (folder.getParent() == null) {
@@ -3151,6 +3160,9 @@ public class Launcher extends Activity
if (parent != null) {
FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo);
shrinkAndFadeInFolderIcon(fi);
+ if (fi != null) {
+ ((CellLayout.LayoutParams) fi.getLayoutParams()).canReorder = true;
+ }
}
folder.animateClosed();