mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Refactor device padding to be set per grid option
- Fixes bug where devices with scaled grids were not
getting the correct deivce padding.
- Also fix bug where device padding was invalid.
Added validation check when processing paddings to prevent
this from happening again.
Bug: 175329686
Test: manual, enable debug flag,
run and verify no crash from validation check
Change-Id: I35b019c40667c08de4fad95ac4b05b2d8f8a0e74
This commit is contained in:
@@ -132,6 +132,7 @@ public class InvariantDeviceProfile {
|
||||
* Do not query directly. see {@link DeviceProfile#isScalableGrid}.
|
||||
*/
|
||||
protected boolean isScalable;
|
||||
public int devicePaddingId;
|
||||
|
||||
public String dbFile;
|
||||
public int defaultLayoutId;
|
||||
@@ -140,7 +141,7 @@ public class InvariantDeviceProfile {
|
||||
public DeviceProfile landscapeProfile;
|
||||
public DeviceProfile portraitProfile;
|
||||
|
||||
public DevicePaddings devicePaddings;
|
||||
@Nullable public DevicePaddings devicePaddings;
|
||||
|
||||
public Point defaultWallpaperSize;
|
||||
public Rect defaultWidgetPadding;
|
||||
@@ -165,6 +166,7 @@ public class InvariantDeviceProfile {
|
||||
numHotseatIcons = p.numHotseatIcons;
|
||||
numAllAppsColumns = p.numAllAppsColumns;
|
||||
isScalable = p.isScalable;
|
||||
devicePaddingId = p.devicePaddingId;
|
||||
minCellHeight = p.minCellHeight;
|
||||
minCellWidth = p.minCellWidth;
|
||||
borderSpacing = p.borderSpacing;
|
||||
@@ -231,7 +233,6 @@ public class InvariantDeviceProfile {
|
||||
result.minCellWidth = defaultDisplayOption.minCellWidth;
|
||||
result.borderSpacing = defaultDisplayOption.borderSpacing;
|
||||
|
||||
devicePaddings = new DevicePaddings(context);
|
||||
initGrid(context, myInfo, result);
|
||||
}
|
||||
|
||||
@@ -262,7 +263,6 @@ public class InvariantDeviceProfile {
|
||||
ArrayList<DisplayOption> allOptions = getPredefinedDeviceProfiles(context, gridName);
|
||||
|
||||
DisplayOption displayOption = invDistWeightedInterpolate(displayInfo, allOptions);
|
||||
devicePaddings = new DevicePaddings(context);
|
||||
initGrid(context, displayInfo, displayOption);
|
||||
return displayOption.grid.name;
|
||||
}
|
||||
@@ -280,6 +280,7 @@ public class InvariantDeviceProfile {
|
||||
numFolderColumns = closestProfile.numFolderColumns;
|
||||
numAllAppsColumns = closestProfile.numAllAppsColumns;
|
||||
isScalable = closestProfile.isScalable;
|
||||
devicePaddingId = closestProfile.devicePaddingId;
|
||||
|
||||
mExtraAttrs = closestProfile.extraAttrs;
|
||||
|
||||
@@ -302,6 +303,10 @@ public class InvariantDeviceProfile {
|
||||
allAppsIconTextSize = iconTextSize;
|
||||
}
|
||||
|
||||
if (devicePaddingId != 0) {
|
||||
devicePaddings = new DevicePaddings(context, devicePaddingId);
|
||||
}
|
||||
|
||||
// If the partner customization apk contains any grid overrides, apply them
|
||||
// Supported overrides: numRows, numColumns, iconSize
|
||||
applyPartnerDeviceProfileOverrides(context, displayInfo.metrics);
|
||||
@@ -615,6 +620,7 @@ public class InvariantDeviceProfile {
|
||||
private final int demoModeLayoutId;
|
||||
|
||||
private final boolean isScalable;
|
||||
private final int devicePaddingId;
|
||||
|
||||
private final SparseArray<TypedValue> extraAttrs;
|
||||
|
||||
@@ -641,6 +647,8 @@ public class InvariantDeviceProfile {
|
||||
|
||||
isScalable = a.getBoolean(
|
||||
R.styleable.GridDisplayOption_isScalable, false);
|
||||
devicePaddingId = a.getResourceId(
|
||||
R.styleable.GridDisplayOption_devicePaddingId, 0);
|
||||
|
||||
a.recycle();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user