Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0cf067ef authored by Jordan Silva's avatar Jordan Silva
Browse files

Fix translation when focused task or desktop task is dismissed. (3/4)

This CL uses the same logic used for handheld dissmiss translation to fix the following cases when large tile is enabled for desktop task:
- When the LAST focused task is dismissed (i.e., no other task in the grid), translate all large tiles from the right side to the left, to occupy the dismissed focused task position.
- When Desktop Task is dismissed, translate focused task and grid from the left to the right side to occupy the dismissed desktop task position.
- When 2 tasks are visible in recents (i.e., 1 focused task, 1 desktop task) and the user dismisses the desktop task while in Clear All Button page (page 2), the focused task translates when no translation should be done, due to snapping to ClearAllButton page on Tablet. To fix this we introduced a logic in getOffsetToDismissedTask to use the previous page for the calculation when the grid snaps to Clear All Button page.

Bug: 353948136
Fix: 353948182
Flag: com.android.launcher3.enable_large_desktop_windowing_tile
Test: OverviewDesktopTaskImageTest
Change-Id: If8b06410c26a8f817d84ec6a635a66b2941e3ae9
parent 49e27e52
Loading
Loading
Loading
Loading
+21 −18
Original line number Diff line number Diff line
@@ -3609,10 +3609,10 @@ public abstract class RecentsView<
        float dismissedTaskWidth = 0;
        float nextFocusedTaskWidth = 0;

        // Non-grid specific properties.
        int[] oldScroll = new int[count];
        int[] newScroll = new int[count];
        int scrollDiffPerPage = 0;
        // Non-grid specific properties.
        boolean needsCurveUpdates = false;

        if (showAsGrid) {
@@ -3642,14 +3642,14 @@ public abstract class RecentsView<
                    }
                }
            }
        } else {
        }

        getPageScrolls(oldScroll, false, SIMPLE_SCROLL_LOGIC);
        getPageScrolls(newScroll, false,
                v -> v.getVisibility() != GONE && v != dismissedTaskView);
        if (count > 1) {
            scrollDiffPerPage = Math.abs(oldScroll[1] - oldScroll[0]);
        }
        }

        float dismissTranslationInterpolationEnd = 1;
        boolean closeGapBetweenClearAll = false;
@@ -3800,7 +3800,9 @@ public abstract class RecentsView<
                        addDismissedTaskAnimations(dismissedTaskView, duration, anim);
                    }
                }
            } else if (!showAsGrid) {
            } else if (!showAsGrid || (enableLargeDesktopWindowingTile()
                    && dismissedTaskView.isLargeTile()
                    && nextFocusedTaskView == null)) {
                int offset = getOffsetToDismissedTask(scrollDiffPerPage, dismissedIndex, taskCount);
                int scrollDiff = newScroll[i] - oldScroll[i] + offset;
                if (scrollDiff != 0) {
@@ -3812,18 +3814,16 @@ public abstract class RecentsView<
                            splitTimings);
                    needsCurveUpdates = true;
                }
            } else if (child instanceof TaskView) {
                TaskView taskView = (TaskView) child;
            } else if (child instanceof TaskView taskView) {
                if (isFocusedTaskDismissed) {
                    if (nextFocusedTaskView != null &&
                            !isSameGridRow(taskView, nextFocusedTaskView)) {
                        continue;
                    }
                } else {
                    if (i < dismissedIndex || !isSameGridRow(taskView, dismissedTaskView)) {
                } else if (i < dismissedIndex || !isSameGridRow(taskView, dismissedTaskView)) {
                    continue;
                }
                }

                // Animate task with index >= dismissed index and in the same row as the
                // dismissed index or next focused index. Offset successive task dismissal
                // durations for a staggered effect.
@@ -4134,15 +4134,18 @@ public abstract class RecentsView<
     * - Dragging an adjacent page on the left side (right side for RTL)
     */
    private int getOffsetToDismissedTask(int scrollDiffPerPage, int dismissedIndex, int taskCount) {
        // When mCurrentPage is ClearAllButton, use the last TaskView instead to calculate
        // offset.
        int currentPage = mCurrentPage == taskCount ? taskCount - 1 : mCurrentPage;
        int offset = mIsRtl ? scrollDiffPerPage : 0;
        if (mCurrentPage == dismissedIndex) {
        if (currentPage == dismissedIndex) {
            int lastPage = taskCount - 1;
            if (mCurrentPage == lastPage) {
            if (currentPage == lastPage) {
                offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
            }
        } else {
            // Dismissing an adjacent page.
            int negativeAdjacent = mCurrentPage - 1; // (Right in RTL, left in LTR)
            int negativeAdjacent = currentPage - 1; // (Right in RTL, left in LTR)
            if (dismissedIndex == negativeAdjacent) {
                offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
            }