Fix getPagesToBindSynchronously returning wrong page pairs

- Use WorkSpace.getPagePair instead for accurate value

Bug: 191657065
Test: manual
Change-Id: I584f1705fb5ed2f0d2bd776eb6cf4f60c69238ac
This commit is contained in:
Alex Chau
2021-09-03 16:54:27 +01:00
parent 4926bf706a
commit 62f129b878
2 changed files with 10 additions and 14 deletions
+10 -10
View File
@@ -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;
}
-4
View File
@@ -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 {