From e32e8641d693f661d1177160a46a7809820e59d9 Mon Sep 17 00:00:00 2001 From: Andras Kloczl Date: Tue, 3 Aug 2021 12:57:13 +0200 Subject: [PATCH] Fix Workspace item move issues when using Talkback - fix the crash when an item was moved onto the right panel - fix the issue that prevented the user from moving an item from the left panel Test: manual Bug: 194903736 Change-Id: Ib41f5d6d08e8815a52631ef952d32dcf899455e2 --- src/com/android/launcher3/Workspace.java | 13 ++++++++----- .../LauncherAccessibilityDelegate.java | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 9a8b80d4c5..d0f6c6e8e2 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1775,7 +1775,7 @@ public class Workspace extends PagedView boolean droppedOnOriginalCell = false; - int snapScreen = -1; + boolean snappedToNewPage = false; boolean resizeOnDrop = false; Runnable onCompleteRunnable = null; if (d.dragSource != this || mDragInfo == null) { @@ -1857,11 +1857,14 @@ public class Workspace extends PagedView } if (foundCell) { - if (getScreenIdForPageIndex(mCurrentPage) != screenId && !hasMovedIntoHotseat) { - snapScreen = getPageIndexForScreenId(screenId); + int targetScreenIndex = getPageIndexForScreenId(screenId); + int snapScreen = getLeftmostVisiblePageForIndex(targetScreenIndex); + // On large screen devices two pages can be shown at the same time, and snap + // isn't needed if the source and target screens appear at the same time + if (snapScreen != mCurrentPage && !hasMovedIntoHotseat) { snapToPage(snapScreen); + snappedToNewPage = true; } - final ItemInfo info = (ItemInfo) cell.getTag(); if (hasMovedLayouts) { // Reparent the view @@ -1953,7 +1956,7 @@ public class Workspace extends PagedView ANIMATE_INTO_POSITION_AND_DISAPPEAR; animateWidgetDrop(info, parent, d.dragView, null, animationType, cell, false); } else { - int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION; + int duration = snappedToNewPage ? ADJACENT_SCREEN_DROP_DURATION : -1; mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration, this); } diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java index 9faac5b7ef..0fb5e778d0 100644 --- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java @@ -188,7 +188,8 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme private boolean itemSupportsAccessibleDrag(ItemInfo item) { if (item instanceof WorkspaceItemInfo) { // Support the action unless the item is in a context menu. - return item.screenId >= 0 && item.container != Favorites.CONTAINER_HOTSEAT_PREDICTION; + return (item.screenId >= 0 || item.screenId == Workspace.LEFT_PANEL_ID) + && item.container != Favorites.CONTAINER_HOTSEAT_PREDICTION; } return (item instanceof LauncherAppWidgetInfo) || (item instanceof FolderInfo);