Removing UI dependency from LauncherModel in case of 2-panel layout

Bug: 175939730
Bug: 192431856
Bug: 185515153
Test: Manual
Change-Id: I8baa1cf9e5a8a04d5b8bc38c1f4b0755265cd8a9
This commit is contained in:
Sunny Goyal
2021-07-15 14:31:58 -07:00
parent 12a0357c31
commit 12e3f1f2f7
14 changed files with 110 additions and 449 deletions

View File

@@ -15,6 +15,9 @@
*/
package com.android.launcher3.model;
import static com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID;
import static com.android.launcher3.WorkspaceLayoutManager.LEFT_PANEL_ID;
import android.content.Intent;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
@@ -27,6 +30,7 @@ import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.model.BgDataModel.Callbacks;
import com.android.launcher3.model.data.AppInfo;
@@ -38,6 +42,7 @@ import com.android.launcher3.pm.InstallSessionHelper;
import com.android.launcher3.pm.PackageInstallInfo;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.PackageManagerHelper;
import java.util.ArrayList;
@@ -291,11 +296,15 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
boolean found = false;
int screenCount = workspaceScreens.size();
int firstScreenToCheck = dataModel.isLeftPanelShown ? 2 : 1;
// Search on the screens for empty space
for (int screen = firstScreenToCheck; screen < screenCount; screen++) {
// First check the preferred screen.
IntSet screensToExclude = IntSet.wrap(LEFT_PANEL_ID);
if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
screensToExclude.add(FIRST_SCREEN_ID);
}
for (int screen = 0; screen < screenCount; screen++) {
screenId = workspaceScreens.get(screen);
if (findNextAvailableIconSpaceInScreen(
if (!screensToExclude.contains(screenId) && findNextAvailableIconSpaceInScreen(
app, screenItems.get(screenId), coordinates, spanX, spanY)) {
// We found a space for it
found = true;