Add twoPanelId attribute for responsive grid in device profile
Three new attributes were created to be used in device profile. These attributes will provide the responsive specs for two panel devices.
Fix: 292204121
Flag: ENABLE_RESPONSIVE_WORKSPACE
Test: DeviceProfileDumpTest
Test: DeviceProfileResponsiveDumpTest
Test: DeviceProfileResponsiveAlternativeDisplaysDumpTest
Change-Id: I35c93e16dde043b0fd611b81bf2de74e3621818e
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 9803779..4d75fb8 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -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">
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 54965e8..42372f1 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -543,7 +543,8 @@
// 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 @@
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,
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 4eaacdc..dac6120 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -180,9 +180,15 @@
@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 @@
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 @@
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 @@
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,