Close the shortcuts container in various places.
- Mostly everywhere folders are closed
- Implements DragListener so we can close the container when dragging
the original icon or shortcuts from the container. We actually just
hide the container in onDragStart() and really remove it in
onDragEnd(). This avoids interfering with touch events and thus
allows us to remove the hack of explicitly setting the DragLayer's
controller when dragging shortcuts (since it will do it on intercept).
Bug: 30080537
Change-Id: Iccc2afba2a990a613bc588d57c4d8c1b7c65224b
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 763daf4..717b059 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -116,6 +116,7 @@
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.shortcuts.DeepShortcutManager;
+import com.android.launcher3.shortcuts.DeepShortcutsContainer;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.PackageManagerHelper;
@@ -1245,6 +1246,9 @@
// Close any open folders
closeFolder();
+ // Close any shortcuts containers
+ closeShortcutsContainer();
+
// Stop resizing any widgets
mWorkspace.exitWidgetResizeMode();
@@ -1840,6 +1844,7 @@
mWorkspace.exitWidgetResizeMode();
closeFolder(alreadyOnHome);
+ closeShortcutsContainer();
exitSpringLoadedDragMode();
// If we are already on home, then just animate back to the workspace,
@@ -1927,6 +1932,8 @@
// TODO: Move folderInfo.isOpened out of the model and make it a UI state.
closeFolder(false);
+ closeShortcutsContainer();
+
if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 &&
mWaitingForResult) {
ContentValues itemValues = new ContentValues();
@@ -2423,7 +2430,9 @@
return;
}
- if (isAppsViewVisible()) {
+ if (getOpenShortcutsContainer() != null) {
+ closeShortcutsContainer();
+ } else if (isAppsViewVisible()) {
showWorkspace(true);
} else if (isWidgetsViewVisible()) {
showOverviewMode(true);
@@ -3090,6 +3099,21 @@
getDragLayer().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
+ public void closeShortcutsContainer() {
+ DeepShortcutsContainer deepShortcutsContainer = getOpenShortcutsContainer();
+ if (deepShortcutsContainer != null) {
+ mDragController.removeDragListener(deepShortcutsContainer);
+ mDragLayer.removeView(deepShortcutsContainer);
+ }
+ }
+
+ /**
+ * @return The open shortcuts container, or null if there is none
+ */
+ public DeepShortcutsContainer getOpenShortcutsContainer() {
+ return (DeepShortcutsContainer) mDragLayer.findViewById(R.id.deep_shortcuts_container);
+ }
+
@Override
public boolean onLongClick(View v) {
if (!isDraggingEnabled()) return false;
@@ -3351,6 +3375,7 @@
mUserPresent = false;
updateAutoAdvanceState();
closeFolder();
+ closeShortcutsContainer();
// Send an accessibility event to announce the context change
getWindow().getDecorView()