Merge "Add twoPanelId attribute for responsive grid in device profile" into udc-qpr-dev

This commit is contained in:
Thales Lima
2023-07-24 21:24:00 +00:00
committed by Android (Google) Code Review
3 changed files with 33 additions and 3 deletions

View File

@@ -205,13 +205,16 @@
<!-- File that contains the specs for the workspace.
Needs FeatureFlags.ENABLE_RESPONSIVE_WORKSPACE enabled -->
<attr name="workspaceSpecsId" format="reference" />
<attr name="workspaceSpecsTwoPanelId" format="reference" />
<!-- File that contains the specs for all apps.
Needs FeatureFlags.ENABLE_RESPONSIVE_WORKSPACE enabled -->
<attr name="allAppsSpecsId" format="reference" />
<attr name="allAppsSpecsTwoPanelId" format="reference" />
<!-- File that contains the specs for the workspace.
Needs FeatureFlags.ENABLE_RESPONSIVE_WORKSPACE enabled -->
<attr name="folderSpecsId" format="reference" />
<attr name="folderSpecsTwoPanelId" format="reference" />
<!-- By default all categories are enabled -->
<attr name="deviceCategory" format="integer">

View File

@@ -543,7 +543,8 @@ public class DeviceProfile {
// for the available height to be correct
if (mIsResponsiveGrid) {
WorkspaceSpecs workspaceSpecs = WorkspaceSpecs.create(
new ResourceHelper(context, inv.workspaceSpecsId));
new ResourceHelper(context,
isTwoPanels ? inv.workspaceSpecsTwoPanelId : inv.workspaceSpecsId));
int availableResponsiveWidth =
availableWidthPx - (isVerticalBarLayout() ? hotseatBarSizePx : 0);
int numColumns = getPanelCount() * inv.numColumns;
@@ -557,14 +558,16 @@ public class DeviceProfile {
availableResponsiveHeight);
AllAppsSpecs allAppsSpecs = AllAppsSpecs.create(
new ResourceHelper(context, inv.allAppsSpecsId));
new ResourceHelper(context,
isTwoPanels ? inv.allAppsSpecsTwoPanelId : inv.allAppsSpecsId));
mAllAppsResponsiveWidthSpec = allAppsSpecs.getCalculatedWidthSpec(numColumns,
mResponsiveWidthSpec.getAvailableSpace(), mResponsiveWidthSpec);
mAllAppsResponsiveHeightSpec = allAppsSpecs.getCalculatedHeightSpec(inv.numRows,
mResponsiveHeightSpec.getAvailableSpace(), mResponsiveHeightSpec);
FolderSpecs folderSpecs = FolderSpecs.create(
new ResourceHelper(context, inv.folderSpecsId));
new ResourceHelper(context,
isTwoPanels ? inv.folderSpecsTwoPanelId : inv.folderSpecsId));
mResponsiveFolderWidthSpec = folderSpecs.getCalculatedWidthSpec(inv.numFolderColumns,
mResponsiveWidthSpec.getAvailableSpace(), mResponsiveWidthSpec);
mResponsiveFolderHeightSpec = folderSpecs.getCalculatedHeightSpec(inv.numFolderRows,

View File

@@ -180,9 +180,15 @@ public class InvariantDeviceProfile {
@XmlRes
public int workspaceSpecsId = INVALID_RESOURCE_HANDLE;
@XmlRes
public int workspaceSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
@XmlRes
public int allAppsSpecsId = INVALID_RESOURCE_HANDLE;
@XmlRes
public int allAppsSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
@XmlRes
public int folderSpecsId = INVALID_RESOURCE_HANDLE;
@XmlRes
public int folderSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
public String dbFile;
public int defaultLayoutId;
@@ -357,8 +363,11 @@ public class InvariantDeviceProfile {
isScalable = closestProfile.isScalable;
devicePaddingId = closestProfile.devicePaddingId;
workspaceSpecsId = closestProfile.mWorkspaceSpecsId;
workspaceSpecsTwoPanelId = closestProfile.mWorkspaceSpecsTwoPanelId;
allAppsSpecsId = closestProfile.mAllAppsSpecsId;
allAppsSpecsTwoPanelId = closestProfile.mAllAppsSpecsTwoPanelId;
folderSpecsId = closestProfile.mFolderSpecsId;
folderSpecsTwoPanelId = closestProfile.mFolderSpecsTwoPanelId;
this.deviceType = deviceType;
inlineNavButtonsEndSpacing = closestProfile.inlineNavButtonsEndSpacing;
@@ -805,8 +814,11 @@ public class InvariantDeviceProfile {
private final boolean isScalable;
private final int devicePaddingId;
private final int mWorkspaceSpecsId;
private final int mWorkspaceSpecsTwoPanelId;
private final int mAllAppsSpecsId;
private final int mAllAppsSpecsTwoPanelId;
private final int mFolderSpecsId;
private final int mFolderSpecsTwoPanelId;
public GridOption(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(
@@ -871,14 +883,26 @@ public class InvariantDeviceProfile {
if (FeatureFlags.ENABLE_RESPONSIVE_WORKSPACE.get()) {
mWorkspaceSpecsId = a.getResourceId(
R.styleable.GridDisplayOption_workspaceSpecsId, INVALID_RESOURCE_HANDLE);
mWorkspaceSpecsTwoPanelId = a.getResourceId(
R.styleable.GridDisplayOption_workspaceSpecsTwoPanelId,
INVALID_RESOURCE_HANDLE);
mAllAppsSpecsId = a.getResourceId(
R.styleable.GridDisplayOption_allAppsSpecsId, INVALID_RESOURCE_HANDLE);
mAllAppsSpecsTwoPanelId = a.getResourceId(
R.styleable.GridDisplayOption_allAppsSpecsTwoPanelId,
INVALID_RESOURCE_HANDLE);
mFolderSpecsId = a.getResourceId(
R.styleable.GridDisplayOption_folderSpecsId, INVALID_RESOURCE_HANDLE);
mFolderSpecsTwoPanelId = a.getResourceId(
R.styleable.GridDisplayOption_folderSpecsTwoPanelId,
INVALID_RESOURCE_HANDLE);
} else {
mWorkspaceSpecsId = INVALID_RESOURCE_HANDLE;
mWorkspaceSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
mAllAppsSpecsId = INVALID_RESOURCE_HANDLE;
mAllAppsSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
mFolderSpecsId = INVALID_RESOURCE_HANDLE;
mFolderSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
}
int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb,