Fix getPagesToBindSynchronously returning wrong page pairs
- Use WorkSpace.getPagePair instead for accurate value
Bug: 191657065
Test: manual
Change-Id: I584f1705fb5ed2f0d2bd776eb6cf4f60c69238ac
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 5be93b2..1354a7a 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2112,19 +2112,19 @@
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;
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index b1a9b76..6ec48e5 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -920,12 +920,8 @@
/**
* 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 {