mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Add support for having more hotseat icons in the DB than we show
Split InvariantDeviceProfile#numHotseatIcons into two variables: numDatabaseHotseatIcons and numShownHotseatIcons. These are generally the same, but different DisplayOptions within the same GridOption can choose to show different numbers of hotseat icons while sharing the same database. numDatabaseHotseatIcons is used for all reading/writing/migrating purposes, while numShownHotseatIcons determines how many Hotseat icons to show in the UI. Test: Existing tests pass, added two new migration tests Bug: 184789479 Bug: 171917176 Change-Id: I54583504f61a47a4444b6a637ebb7e3ab31528b7
This commit is contained in:
@@ -122,7 +122,14 @@ public class InvariantDeviceProfile {
|
||||
/**
|
||||
* Number of icons inside the hotseat area.
|
||||
*/
|
||||
public int numHotseatIcons;
|
||||
protected int numShownHotseatIcons;
|
||||
|
||||
/**
|
||||
* Number of icons inside the hotseat area that is stored in the database. This is greater than
|
||||
* or equal to numnShownHotseatIcons, allowing for a seamless transition between two hotseat
|
||||
* sizes that share the same DB.
|
||||
*/
|
||||
public int numDatabaseHotseatIcons;
|
||||
|
||||
/**
|
||||
* Number of columns in the all apps list.
|
||||
@@ -165,7 +172,8 @@ public class InvariantDeviceProfile {
|
||||
iconBitmapSize = p.iconBitmapSize;
|
||||
iconTextSize = p.iconTextSize;
|
||||
landscapeIconTextSize = p.landscapeIconTextSize;
|
||||
numHotseatIcons = p.numHotseatIcons;
|
||||
numShownHotseatIcons = p.numShownHotseatIcons;
|
||||
numDatabaseHotseatIcons = p.numDatabaseHotseatIcons;
|
||||
numAllAppsColumns = p.numAllAppsColumns;
|
||||
isScalable = p.isScalable;
|
||||
devicePaddingId = p.devicePaddingId;
|
||||
@@ -190,7 +198,7 @@ public class InvariantDeviceProfile {
|
||||
Utilities.getPrefs(context).edit().putString(KEY_IDP_GRID_NAME, newGridName).apply();
|
||||
}
|
||||
Utilities.getPrefs(context).edit()
|
||||
.putInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, numHotseatIcons)
|
||||
.putInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, numDatabaseHotseatIcons)
|
||||
.putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, getPointString(numColumns, numRows))
|
||||
.apply();
|
||||
|
||||
@@ -229,6 +237,7 @@ public class InvariantDeviceProfile {
|
||||
.add(myDisplayOption);
|
||||
result.iconSize = defaultDisplayOption.iconSize;
|
||||
result.landscapeIconSize = defaultDisplayOption.landscapeIconSize;
|
||||
result.numShownHotseatIcons = myDisplayOption.numShownHotseatIcons;
|
||||
if (defaultDisplayOption.allAppsIconSize < myDisplayOption.allAppsIconSize) {
|
||||
result.allAppsIconSize = defaultDisplayOption.allAppsIconSize;
|
||||
result.numAllAppsColumns = defaultDisplayOption.numAllAppsColumns;
|
||||
@@ -279,7 +288,7 @@ public class InvariantDeviceProfile {
|
||||
GridOption closestProfile = displayOption.grid;
|
||||
numRows = closestProfile.numRows;
|
||||
numColumns = closestProfile.numColumns;
|
||||
numHotseatIcons = closestProfile.numHotseatIcons;
|
||||
numDatabaseHotseatIcons = closestProfile.numDatabaseHotseatIcons;
|
||||
dbFile = closestProfile.dbFile;
|
||||
defaultLayoutId = closestProfile.defaultLayoutId;
|
||||
demoModeLayoutId = closestProfile.demoModeLayoutId;
|
||||
@@ -301,6 +310,7 @@ public class InvariantDeviceProfile {
|
||||
minCellHeight = displayOption.minCellHeight;
|
||||
minCellWidth = displayOption.minCellWidth;
|
||||
borderSpacing = displayOption.borderSpacing;
|
||||
numShownHotseatIcons = Math.round(displayOption.numShownHotseatIcons);
|
||||
numAllAppsColumns = Math.round(displayOption.numAllAppsColumns);
|
||||
|
||||
if (Utilities.isGridOptionsEnabled(context)) {
|
||||
@@ -391,7 +401,7 @@ public class InvariantDeviceProfile {
|
||||
numColumns != oldProfile.numColumns ||
|
||||
numFolderColumns != oldProfile.numFolderColumns ||
|
||||
numFolderRows != oldProfile.numFolderRows ||
|
||||
numHotseatIcons != oldProfile.numHotseatIcons) {
|
||||
numDatabaseHotseatIcons != oldProfile.numDatabaseHotseatIcons) {
|
||||
changeFlags |= CHANGE_FLAG_GRID;
|
||||
}
|
||||
|
||||
@@ -619,7 +629,7 @@ public class InvariantDeviceProfile {
|
||||
private final int numFolderRows;
|
||||
private final int numFolderColumns;
|
||||
|
||||
private final int numHotseatIcons;
|
||||
private final int numDatabaseHotseatIcons;
|
||||
|
||||
private final String dbFile;
|
||||
|
||||
@@ -645,7 +655,7 @@ public class InvariantDeviceProfile {
|
||||
R.styleable.GridDisplayOption_defaultLayoutId, 0);
|
||||
demoModeLayoutId = a.getResourceId(
|
||||
R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
|
||||
numHotseatIcons = a.getInt(
|
||||
numDatabaseHotseatIcons = a.getInt(
|
||||
R.styleable.GridDisplayOption_numHotseatIcons, numColumns);
|
||||
numFolderRows = a.getInt(
|
||||
R.styleable.GridDisplayOption_numFolderRows, numRows);
|
||||
@@ -673,6 +683,7 @@ public class InvariantDeviceProfile {
|
||||
private final float minHeightDps;
|
||||
private final boolean canBeDefault;
|
||||
|
||||
private float numShownHotseatIcons;
|
||||
private float numAllAppsColumns;
|
||||
private float minCellHeight;
|
||||
private float minCellWidth;
|
||||
@@ -695,6 +706,8 @@ public class InvariantDeviceProfile {
|
||||
minHeightDps = a.getFloat(R.styleable.ProfileDisplayOption_minHeightDps, 0);
|
||||
canBeDefault = a.getBoolean(
|
||||
R.styleable.ProfileDisplayOption_canBeDefault, false);
|
||||
numShownHotseatIcons = a.getInt(R.styleable.ProfileDisplayOption_numShownHotseatIcons,
|
||||
grid.numDatabaseHotseatIcons);
|
||||
numAllAppsColumns = a.getInt(R.styleable.ProfileDisplayOption_numAllAppsColumns,
|
||||
grid.numColumns);
|
||||
|
||||
@@ -725,6 +738,7 @@ public class InvariantDeviceProfile {
|
||||
minWidthDps = 0;
|
||||
minHeightDps = 0;
|
||||
canBeDefault = false;
|
||||
numShownHotseatIcons = 0;
|
||||
numAllAppsColumns = 0;
|
||||
minCellHeight = 0;
|
||||
minCellWidth = 0;
|
||||
@@ -732,6 +746,7 @@ public class InvariantDeviceProfile {
|
||||
}
|
||||
|
||||
private DisplayOption multiply(float w) {
|
||||
numShownHotseatIcons *= w;
|
||||
numAllAppsColumns *= w;
|
||||
iconSize *= w;
|
||||
landscapeIconSize *= w;
|
||||
@@ -746,6 +761,7 @@ public class InvariantDeviceProfile {
|
||||
}
|
||||
|
||||
private DisplayOption add(DisplayOption p) {
|
||||
numShownHotseatIcons += p.numShownHotseatIcons;
|
||||
numAllAppsColumns += p.numAllAppsColumns;
|
||||
iconSize += p.iconSize;
|
||||
landscapeIconSize += p.landscapeIconSize;
|
||||
|
||||
Reference in New Issue
Block a user