OSDN Git Service

Fix longpress crash.
authorDan Sandler <dsandler@android.com>
Mon, 13 Jan 2014 19:30:14 +0000 (14:30 -0500)
committerDan Sandler <dsandler@android.com>
Tue, 14 Jan 2014 16:12:38 +0000 (11:12 -0500)
The AllApps button doesn't usually accept longpresses, but
you can trick it into trying by holding one finger on it and
another on another icon in the hotseat. This patch defends
against that and bails out if the longpressed item has the
all apps rank (position in hotseat).

Bug: 11740833
Change-Id: I99785ccbc9e6dc6be2a9e56289b3cc0275fbb65c

src/com/android/launcher3/Launcher.java

index 765fca4..aadcd87 100644 (file)
@@ -2781,7 +2781,8 @@ public class Launcher extends Activity
         // The hotseat touch handling does not go through Workspace, and we always allow long press
         // on hotseat items.
         final View itemUnderLongClick = longClickCellInfo.cell;
-        boolean allowLongPress = isHotseatLayout(v) || mWorkspace.allowLongPress();
+        final boolean inHotseat = isHotseatLayout(v);
+        boolean allowLongPress = inHotseat || mWorkspace.allowLongPress();
         if (allowLongPress && !mDragController.isDragging()) {
             if (itemUnderLongClick == null) {
                 // User long pressed on empty space
@@ -2794,7 +2795,11 @@ public class Launcher extends Activity
                     mWorkspace.enterOverviewMode();
                 }
             } else {
-                if (!(itemUnderLongClick instanceof Folder)) {
+                final boolean isAllAppsButton = inHotseat && isAllAppsButtonRank(
+                        mHotseat.getOrderInHotseat(
+                                longClickCellInfo.cellX,
+                                longClickCellInfo.cellY));
+                if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) {
                     // User long pressed on an item
                     mWorkspace.startDrag(longClickCellInfo);
                 }