From 1d5929dd823d846ec62597d5c8116913beb062ad Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 9 Sep 2021 17:47:26 +0100 Subject: [PATCH] Fix wrong screenId when committing emptyScreens - Need to increment newScreenId whenever the screen is already bound - Also cleaned up placeholder on w1 as we now have page pairing logic Bug: 199160559 Bug: 175939730 Fix: 199131780 Test: drag and drop after clear data Change-Id: Ic42f3bddfa6cf11b8b726d6181ed2477defde19d --- .../default_workspace_splitdisplay_5x5.xml | 107 ------------------ res/xml/device_profiles.xml | 3 +- src/com/android/launcher3/Workspace.java | 19 ++-- 3 files changed, 8 insertions(+), 121 deletions(-) delete mode 100644 res/xml/default_workspace_splitdisplay_5x5.xml diff --git a/res/xml/default_workspace_splitdisplay_5x5.xml b/res/xml/default_workspace_splitdisplay_5x5.xml deleted file mode 100644 index 162367be86..0000000000 --- a/res/xml/default_workspace_splitdisplay_5x5.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml index d8ee6f204f..256999cd7f 100644 --- a/res/xml/device_profiles.xml +++ b/res/xml/device_profiles.xml @@ -105,8 +105,7 @@ launcher:numFolderColumns="4" launcher:numHotseatIcons="5" launcher:dbFile="launcher.db" - launcher:defaultLayoutId="@xml/default_workspace_5x5" - launcher:defaultSplitDisplayLayoutId="@xml/default_workspace_splitdisplay_5x5" > + launcher:defaultLayoutId="@xml/default_workspace_5x5" > mWorkspaceScreens.remove(emptyScreenId); mScreenOrder.removeValue(emptyScreenId); - int newScreenId = LauncherSettings.Settings.call(getContext().getContentResolver(), - LauncherSettings.Settings.METHOD_NEW_SCREEN_ID) - .getInt(LauncherSettings.Settings.EXTRA_VALUE); - - - // When two panel home is enabled and the last page (the page on the right) doesn't - // have any items, then Launcher database doesn't know about this page because it was added - // by Launcher::bindAddScreens but wasn't inserted into the database. LauncherSettings's - // generate new screen ID method will return the ID for the left page, - // so we need to increment it. - if (isTwoPanelEnabled() && emptyScreenId == EXTRA_EMPTY_SCREEN_ID && newScreenId % 2 == 1) { - newScreenId++; + int newScreenId = -1; + // Launcher database isn't aware of empty pages that are already bound, so we need to + // skip those IDs manually. + while (newScreenId == -1 || mWorkspaceScreens.containsKey(newScreenId)) { + newScreenId = LauncherSettings.Settings.call(getContext().getContentResolver(), + LauncherSettings.Settings.METHOD_NEW_SCREEN_ID) + .getInt(LauncherSettings.Settings.EXTRA_VALUE); } mWorkspaceScreens.put(newScreenId, cl);