Merge "When doing the special case migration where cells shift up, only modify workspace items" into main

This commit is contained in:
Treehugger Robot
2025-01-30 10:28:11 -08:00
committed by Android (Google) Code Review
3 changed files with 9 additions and 6 deletions
@@ -24,7 +24,7 @@ import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET;
import static com.android.launcher3.model.LoaderTask.SMARTSPACE_ON_HOME_SCREEN;
import static com.android.launcher3.provider.LauncherDbUtils.copyTable;
import static com.android.launcher3.provider.LauncherDbUtils.dropTable;
import static com.android.launcher3.provider.LauncherDbUtils.shiftTableByXCells;
import static com.android.launcher3.provider.LauncherDbUtils.shiftWorkspaceByXCells;
import android.content.ComponentName;
import android.content.ContentValues;
@@ -143,7 +143,7 @@ public class GridSizeMigrationDBController {
// We want to add the extra row(s) to the top of the screen, so we shift the grid
// down.
if (oneGridSpecs()) {
shiftTableByXCells(
shiftWorkspaceByXCells(
target.getWritableDatabase(),
(destDeviceState.getRows() - srcDeviceState.getRows()),
TABLE_NAME);
@@ -35,7 +35,7 @@ import com.android.launcher3.model.GridSizeMigrationDBController.DbReader
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction
import com.android.launcher3.provider.LauncherDbUtils.copyTable
import com.android.launcher3.provider.LauncherDbUtils.dropTable
import com.android.launcher3.provider.LauncherDbUtils.shiftTableByXCells
import com.android.launcher3.provider.LauncherDbUtils.shiftWorkspaceByXCells
import com.android.launcher3.util.CellAndSpan
import com.android.launcher3.util.GridOccupancy
import com.android.launcher3.util.IntArray
@@ -82,7 +82,7 @@ class GridSizeMigrationLogic {
if (shouldMigrateToStrtictlyTallerGrid) {
Log.d(TAG, "Migrating to strictly taller grid")
if (oneGridSpecs()) {
shiftTableByXCells(
shiftWorkspaceByXCells(
target.writableDatabase,
(destDeviceState.rows - srcDeviceState.rows),
TABLE_NAME,
@@ -28,6 +28,7 @@ import android.os.UserManager
import android.text.TextUtils
import com.android.launcher3.LauncherAppState
import com.android.launcher3.LauncherSettings
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP
import com.android.launcher3.Utilities
import com.android.launcher3.icons.IconCache
import com.android.launcher3.model.LoaderCursor
@@ -132,8 +133,10 @@ object LauncherDbUtils {
}
@JvmStatic
fun shiftTableByXCells(db: SQLiteDatabase, x: Int, toTable: String) {
db.run { execSQL("UPDATE $toTable SET cellY = cellY + $x") }
fun shiftWorkspaceByXCells(db: SQLiteDatabase, x: Int, toTable: String) {
db.run {
execSQL("UPDATE $toTable SET cellY = cellY + $x WHERE container = $CONTAINER_DESKTOP")
}
}
/**