Fix grid resetting when changing size
This commit is contained in:
1 parent
516dd1eaa0
commit
44bd593acd
6 files changed
+74
-33
No files matched your search
@@ -93,6 +93,11 @@ public class InvariantDeviceProfile {
|
||||
private static final int CONFIG_ICON_MASK_RES_ID = Resources.getSystem().getIdentifier(
|
||||
"config_icon_mask", "string", "android");
|
||||
|
||||
/**
|
||||
* Original profile before preference overrides
|
||||
*/
|
||||
public GridOption closestProfile;
|
||||
|
||||
/**
|
||||
* Number of icons per row and column in the workspace.
|
||||
*/
|
||||
@@ -243,7 +248,7 @@ public class InvariantDeviceProfile {
|
||||
|
||||
private void initGrid(
|
||||
Context context, DefaultDisplay.Info displayInfo, DisplayOption displayOption) {
|
||||
GridOption closestProfile = displayOption.grid;
|
||||
closestProfile = displayOption.grid;
|
||||
numRows = closestProfile.numRows;
|
||||
numColumns = closestProfile.numColumns;
|
||||
numHotseatIcons = closestProfile.numHotseatIcons;
|
||||
@@ -274,7 +279,7 @@ public class InvariantDeviceProfile {
|
||||
// If the partner customization apk contains any grid overrides, apply them
|
||||
// Supported overrides: numRows, numColumns, iconSize
|
||||
applyPartnerDeviceProfileOverrides(context, displayInfo.metrics);
|
||||
DeviceProfileOverrides.getINSTANCE().get(context).apply(this, displayInfo.metrics);
|
||||
DeviceProfileOverrides.getINSTANCE().get(context).apply(this, closestProfile);
|
||||
|
||||
Point realSize = new Point(displayInfo.realSize);
|
||||
// The real size never changes. smallSide and largeSide will remain the
|
||||
@@ -340,7 +345,16 @@ public class InvariantDeviceProfile {
|
||||
MAIN_EXECUTOR.execute(() -> onConfigChanged(appContext));
|
||||
}
|
||||
|
||||
public void onPreferencesChanged(Context context, int changeFlags) {
|
||||
Context appContext = context.getApplicationContext();
|
||||
MAIN_EXECUTOR.execute(() -> onConfigChanged(appContext, changeFlags));
|
||||
}
|
||||
|
||||
private void onConfigChanged(Context context) {
|
||||
onConfigChanged(context, 0);
|
||||
}
|
||||
|
||||
private void onConfigChanged(Context context, int changeFlags) {
|
||||
// Config changes, what shall we do?
|
||||
InvariantDeviceProfile oldProfile = new InvariantDeviceProfile(this);
|
||||
|
||||
@@ -348,7 +362,6 @@ public class InvariantDeviceProfile {
|
||||
String gridName = getCurrentGridName(context);
|
||||
initGrid(context, gridName);
|
||||
|
||||
int changeFlags = 0;
|
||||
if (numRows != oldProfile.numRows ||
|
||||
numColumns != oldProfile.numColumns ||
|
||||
numFolderColumns != oldProfile.numFolderColumns ||
|
||||
@@ -578,13 +591,13 @@ public class InvariantDeviceProfile {
|
||||
public final int numRows;
|
||||
public final int numColumns;
|
||||
|
||||
private final int numFolderRows;
|
||||
private final int numFolderColumns;
|
||||
public final int numFolderRows;
|
||||
public final int numFolderColumns;
|
||||
|
||||
private final int numHotseatIcons;
|
||||
public final int numHotseatIcons;
|
||||
|
||||
private final String dbFile;
|
||||
private final int numAllAppsColumns;
|
||||
public final int numAllAppsColumns;
|
||||
|
||||
private final int defaultLayoutId;
|
||||
private final int demoModeLayoutId;
|
||||
|
||||
Reference in new issue
Block a user