Fixing drag-n-drop for folders in hotseat.
The current drag-n-drop model assums that when a folder is open
it completely covers the folderIcon and its not possible to drop
anything on the icon. But its not true when a folder is in the
hotseat.
> When DnD finishes revert folder to the normal state
> Ensure that only one folder is open at a time
> Prevent folder icon from moving when the folder is open
Bug: 13646281,14680549
Change-Id: I016a4c3f0d9b57c388eaa28f40df9e7b7bbab5fc
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 42e145b..9ad87c3 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3112,10 +3112,19 @@
*/
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 @@
if (parent != null) {
FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo);
shrinkAndFadeInFolderIcon(fi);
+ if (fi != null) {
+ ((CellLayout.LayoutParams) fi.getLayoutParams()).canReorder = true;
+ }
}
folder.animateClosed();