Loading Android.bp +1 −3 Original line number Diff line number Diff line Loading @@ -228,7 +228,7 @@ filegroup { ], } // Common source files used to build go launcher // Common source files used to build go launcher except go/src files filegroup { name: "launcher-go-src-no-build-config", srcs: [ Loading @@ -236,8 +236,6 @@ filegroup { "src/**/*.kt", "quickstep/src/**/*.java", "quickstep/src/**/*.kt", "go/src/**/*.java", "go/src/**/*.kt", "go/quickstep/src/**/*.java", "go/quickstep/src/**/*.kt", ], Loading go/src/com/android/launcher3/util/AbsGridOccupancy.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.util; /** * Defines method to find the next vacant cell on a grid. * This uses the default top-down, left-right approach and can be over-written through * code swaps in different launchers. */ public abstract class AbsGridOccupancy { /** * Find the first vacant cell, if there is one. * * @param vacantOut Holds the x and y coordinate of the vacant cell * @param spanX Horizontal cell span. * @param spanY Vertical cell span. * * @return true if a vacant cell was found */ protected boolean findVacantCell(int[] vacantOut, boolean[][] cells, int countX, int countY, int spanX, int spanY) { for (int y = 0; (y + spanY) <= countY; y++) { for (int x = 0; (x + spanX) <= countX; x++) { boolean available = !cells[x][y]; out: for (int i = x; i < x + spanX; i++) { for (int j = y; j < y + spanY; j++) { available = available && !cells[i][j]; if (!available) break out; } } if (available) { vacantOut[0] = x; vacantOut[1] = y; return true; } } } return false; } } src/com/android/launcher3/Launcher.java +2 −2 Original line number Diff line number Diff line Loading @@ -3235,12 +3235,12 @@ public class Launcher extends StatefulActivity<LauncherState> /** Pauses view updates that should not be run during the app launch animation. */ public void pauseExpensiveViewUpdates() { // Pause page indicator animations as they lead to layer trashing. mWorkspace.getPageIndicator().pauseAnimations(); getWorkspace().getPageIndicator().pauseAnimations(); } /** Resumes view updates at the end of the app launch animation. */ public void resumeExpensiveViewUpdates() { mWorkspace.getPageIndicator().skipAnimationsToEnd(); getWorkspace().getPageIndicator().skipAnimationsToEnd(); } } src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +0 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static android.view.View.VISIBLE; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION; import static com.android.launcher3.model.ModelUtils.filterCurrentWorkspaceItems; import static com.android.launcher3.model.ModelUtils.getMissingHotseatRanks; import static com.android.launcher3.model.ModelUtils.sortWorkspaceItemsSpatially; import android.annotation.TargetApi; import android.app.Fragment; Loading Loading @@ -420,8 +419,6 @@ public class LauncherPreviewRenderer extends ContextWrapper currentWorkspaceItems, otherWorkspaceItems); filterCurrentWorkspaceItems(currentScreenIds, dataModel.appWidgets, currentAppWidgets, otherAppWidgets); sortWorkspaceItemsSpatially(mIdp, currentWorkspaceItems); for (ItemInfo itemInfo : currentWorkspaceItems) { switch (itemInfo.itemType) { case Favorites.ITEM_TYPE_APPLICATION: Loading src/com/android/launcher3/model/BaseLoaderResults.java +39 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.launcher3.model; import static com.android.launcher3.model.ItemInstallQueue.FLAG_LOADER_RUNNING; import static com.android.launcher3.model.ModelUtils.filterCurrentWorkspaceItems; import static com.android.launcher3.model.ModelUtils.sortWorkspaceItemsSpatially; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import android.os.Process; Loading @@ -27,6 +26,8 @@ import android.util.Log; 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.model.BgDataModel.Callbacks; import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.data.AppInfo; Loading Loading @@ -110,6 +111,42 @@ public abstract class BaseLoaderResults { public abstract void bindWidgets(); /** * Sorts the set of items by hotseat, workspace (spatially from top to bottom, left to right) */ protected void sortWorkspaceItemsSpatially(InvariantDeviceProfile profile, ArrayList<ItemInfo> workspaceItems) { final int screenCols = profile.numColumns; final int screenCellCount = profile.numColumns * profile.numRows; Collections.sort(workspaceItems, (lhs, rhs) -> { if (lhs.container == rhs.container) { // Within containers, order by their spatial position in that container switch (lhs.container) { case LauncherSettings.Favorites.CONTAINER_DESKTOP: { int lr = (lhs.screenId * screenCellCount + lhs.cellY * screenCols + lhs.cellX); int rr = (rhs.screenId * screenCellCount + +rhs.cellY * screenCols + rhs.cellX); return Integer.compare(lr, rr); } case LauncherSettings.Favorites.CONTAINER_HOTSEAT: { // We currently use the screen id as the rank return Integer.compare(lhs.screenId, rhs.screenId); } default: if (FeatureFlags.IS_STUDIO_BUILD) { throw new RuntimeException( "Unexpected container type when sorting workspace items."); } return 0; } } else { // Between containers, order by hotseat, desktop return Integer.compare(lhs.container, rhs.container); } }); } protected void executeCallbacksTask(CallbackTask task, Executor executor) { executor.execute(() -> { if (mMyBindingId != mBgDataModel.lastBindId) { Loading @@ -131,7 +168,7 @@ public abstract class BaseLoaderResults { return idleLock; } private static class WorkspaceBinder { private class WorkspaceBinder { private final Executor mUiExecutor; private final Callbacks mCallbacks; Loading Loading
Android.bp +1 −3 Original line number Diff line number Diff line Loading @@ -228,7 +228,7 @@ filegroup { ], } // Common source files used to build go launcher // Common source files used to build go launcher except go/src files filegroup { name: "launcher-go-src-no-build-config", srcs: [ Loading @@ -236,8 +236,6 @@ filegroup { "src/**/*.kt", "quickstep/src/**/*.java", "quickstep/src/**/*.kt", "go/src/**/*.java", "go/src/**/*.kt", "go/quickstep/src/**/*.java", "go/quickstep/src/**/*.kt", ], Loading
go/src/com/android/launcher3/util/AbsGridOccupancy.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.util; /** * Defines method to find the next vacant cell on a grid. * This uses the default top-down, left-right approach and can be over-written through * code swaps in different launchers. */ public abstract class AbsGridOccupancy { /** * Find the first vacant cell, if there is one. * * @param vacantOut Holds the x and y coordinate of the vacant cell * @param spanX Horizontal cell span. * @param spanY Vertical cell span. * * @return true if a vacant cell was found */ protected boolean findVacantCell(int[] vacantOut, boolean[][] cells, int countX, int countY, int spanX, int spanY) { for (int y = 0; (y + spanY) <= countY; y++) { for (int x = 0; (x + spanX) <= countX; x++) { boolean available = !cells[x][y]; out: for (int i = x; i < x + spanX; i++) { for (int j = y; j < y + spanY; j++) { available = available && !cells[i][j]; if (!available) break out; } } if (available) { vacantOut[0] = x; vacantOut[1] = y; return true; } } } return false; } }
src/com/android/launcher3/Launcher.java +2 −2 Original line number Diff line number Diff line Loading @@ -3235,12 +3235,12 @@ public class Launcher extends StatefulActivity<LauncherState> /** Pauses view updates that should not be run during the app launch animation. */ public void pauseExpensiveViewUpdates() { // Pause page indicator animations as they lead to layer trashing. mWorkspace.getPageIndicator().pauseAnimations(); getWorkspace().getPageIndicator().pauseAnimations(); } /** Resumes view updates at the end of the app launch animation. */ public void resumeExpensiveViewUpdates() { mWorkspace.getPageIndicator().skipAnimationsToEnd(); getWorkspace().getPageIndicator().skipAnimationsToEnd(); } }
src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +0 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static android.view.View.VISIBLE; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION; import static com.android.launcher3.model.ModelUtils.filterCurrentWorkspaceItems; import static com.android.launcher3.model.ModelUtils.getMissingHotseatRanks; import static com.android.launcher3.model.ModelUtils.sortWorkspaceItemsSpatially; import android.annotation.TargetApi; import android.app.Fragment; Loading Loading @@ -420,8 +419,6 @@ public class LauncherPreviewRenderer extends ContextWrapper currentWorkspaceItems, otherWorkspaceItems); filterCurrentWorkspaceItems(currentScreenIds, dataModel.appWidgets, currentAppWidgets, otherAppWidgets); sortWorkspaceItemsSpatially(mIdp, currentWorkspaceItems); for (ItemInfo itemInfo : currentWorkspaceItems) { switch (itemInfo.itemType) { case Favorites.ITEM_TYPE_APPLICATION: Loading
src/com/android/launcher3/model/BaseLoaderResults.java +39 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.launcher3.model; import static com.android.launcher3.model.ItemInstallQueue.FLAG_LOADER_RUNNING; import static com.android.launcher3.model.ModelUtils.filterCurrentWorkspaceItems; import static com.android.launcher3.model.ModelUtils.sortWorkspaceItemsSpatially; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import android.os.Process; Loading @@ -27,6 +26,8 @@ import android.util.Log; 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.model.BgDataModel.Callbacks; import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.data.AppInfo; Loading Loading @@ -110,6 +111,42 @@ public abstract class BaseLoaderResults { public abstract void bindWidgets(); /** * Sorts the set of items by hotseat, workspace (spatially from top to bottom, left to right) */ protected void sortWorkspaceItemsSpatially(InvariantDeviceProfile profile, ArrayList<ItemInfo> workspaceItems) { final int screenCols = profile.numColumns; final int screenCellCount = profile.numColumns * profile.numRows; Collections.sort(workspaceItems, (lhs, rhs) -> { if (lhs.container == rhs.container) { // Within containers, order by their spatial position in that container switch (lhs.container) { case LauncherSettings.Favorites.CONTAINER_DESKTOP: { int lr = (lhs.screenId * screenCellCount + lhs.cellY * screenCols + lhs.cellX); int rr = (rhs.screenId * screenCellCount + +rhs.cellY * screenCols + rhs.cellX); return Integer.compare(lr, rr); } case LauncherSettings.Favorites.CONTAINER_HOTSEAT: { // We currently use the screen id as the rank return Integer.compare(lhs.screenId, rhs.screenId); } default: if (FeatureFlags.IS_STUDIO_BUILD) { throw new RuntimeException( "Unexpected container type when sorting workspace items."); } return 0; } } else { // Between containers, order by hotseat, desktop return Integer.compare(lhs.container, rhs.container); } }); } protected void executeCallbacksTask(CallbackTask task, Executor executor) { executor.execute(() -> { if (mMyBindingId != mBgDataModel.lastBindId) { Loading @@ -131,7 +168,7 @@ public abstract class BaseLoaderResults { return idleLock; } private static class WorkspaceBinder { private class WorkspaceBinder { private final Executor mUiExecutor; private final Callbacks mCallbacks; Loading