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

Commit 62f129b8 authored by Alex Chau's avatar Alex Chau
Browse files

Fix getPagesToBindSynchronously returning wrong page pairs

- Use WorkSpace.getPagePair instead for accurate value

Bug: 191657065
Test: manual
Change-Id: I584f1705fb5ed2f0d2bd776eb6cf4f60c69238ac
parent 4926bf70
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -2112,19 +2112,19 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
            actualIds.add(id);
        }
        int firstId = visibleIds.getArray().get(0);
        int pairId = mWorkspace.getPagePair(firstId);
        // Double check that actual screenIds contains the visibleId, as empty screens are hidden
        // in single panel.
        if (actualIds.contains(firstId)) {
            result.add(firstId);

            if (mDeviceProfile.isTwoPanels) {
                int index = actualIds.indexOf(firstId);
                int nextIndex = (index / 2) * 2;
                if (nextIndex == index) {
                    nextIndex++;
                }
                if (nextIndex < actualIds.size()) {
                    result.add(actualIds.get(nextIndex));
                }
            }
            if (mDeviceProfile.isTwoPanels && actualIds.contains(pairId)) {
                result.add(pairId);
            }
        } else if (LauncherAppState.getIDP(this).supportedProfiles.stream().anyMatch(
                deviceProfile -> deviceProfile.isTwoPanels) && actualIds.contains(pairId)) {
            // Add the right panel if left panel is hidden when switching display, due to empty
            // pages being hidden in single panel.
            result.add(pairId);
        }
        return result;
    }
+0 −4
Original line number Diff line number Diff line
@@ -920,12 +920,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>

    /**
     * Returns the page that is shown together with the given page when two panel is enabled.
     * @throws IllegalStateException if called while two panel home isn't enabled.
     */
    public int getPagePair(int page) {
        if (!isTwoPanelEnabled()) {
            throw new IllegalStateException("Two panel home isn't enabled.");
        }
        if (page % 2 == 0) {
            return page + 1;
        } else {