Merge "Add border space to all apps cells" into tm-dev

This commit is contained in:
Thales Lima
2022-03-30 16:42:46 +00:00
committed by Android (Google) Code Review
3 changed files with 89 additions and 31 deletions
+34 -8
View File
@@ -258,14 +258,6 @@
<attr name="allAppsCellHeightTwoPanelLandscape" format="float" />
<!-- defaults to allAppsCellWidth, if not specified -->
<attr name="allAppsCellWidthTwoPanelLandscape" format="float" />
<!-- defaults to borderSpace, if not specified -->
<attr name="allAppsBorderSpace" format="float" />
<!-- defaults to allAppsBorderSpace, if not specified -->
<attr name="allAppsBorderSpaceLandscape" format="float" />
<!-- defaults to allAppsBorderSpace, if not specified -->
<attr name="allAppsBorderSpaceTwoPanelPortrait" format="float" />
<!-- defaults to allAppsBorderSpace, if not specified -->
<attr name="allAppsBorderSpaceTwoPanelLandscape" format="float" />
<!-- The following values are only enabled if grid is supported. -->
<!-- defaults to iconImageSize, if not specified -->
<attr name="allAppsIconSize" format="float" />
@@ -280,6 +272,40 @@
<!-- defaults to allAppsIconTextSize, if not specified -->
<attr name="allAppsIconTextSizeTwoPanelLandscape" format="float" />
<!-- defaults to borderSpace, if not specified -->
<!-- space to be used horizontally and vertically -->
<attr name="allAppsBorderSpace" format="float" />
<!-- space to the right of the cell, defaults to allAppsBorderSpace if not specified -->
<attr name="allAppsBorderSpaceHorizontal" format="float" />
<!-- space below the cell, defaults to allAppsBorderSpace if not specified -->
<attr name="allAppsBorderSpaceVertical" format="float" />
<!-- space to be used horizontally and vertically,
defaults to allAppsBorderSpace if not specified -->
<attr name="allAppsBorderSpaceLandscape" format="float" />
<!-- space to the right of the cell, defaults to allAppsBorderSpaceLandscape
if not specified -->
<attr name="allAppsBorderSpaceLandscapeHorizontal" format="float" />
<!-- space below the cell, defaults to allAppsBorderSpaceLandscape if not specified -->
<attr name="allAppsBorderSpaceLandscapeVertical" format="float" />
<!-- space to be used horizontally and vertically in two panels,
defaults to allAppsBorderSpace if not specified -->
<attr name="allAppsBorderSpaceTwoPanelPortrait" format="float" />
<!-- space to the right of the cell in two panels, defaults to
allAppsBorderSpaceTwoPanelPortrait if not specified -->
<attr name="allAppsBorderSpaceTwoPanelPortraitHorizontal" format="float" />
<!-- space below the cell in two panels, defaults to allAppsBorderSpaceTwoPanelPortrait
if not specified -->
<attr name="allAppsBorderSpaceTwoPanelPortraitVertical" format="float" />
<!-- space to be used horizontally and vertically in two panels,
defaults to allAppsBorderSpace if not specified -->
<attr name="allAppsBorderSpaceTwoPanelLandscape" format="float" />
<!-- space to the right of the cell in two panels, defaults to
allAppsBorderSpaceTwoPanelLandscape if not specified -->
<attr name="allAppsBorderSpaceTwoPanelLandscapeHorizontal" format="float" />
<!-- space below the cell in two panels, defaults to allAppsBorderSpaceTwoPanelLandscape
if not specified -->
<attr name="allAppsBorderSpaceTwoPanelLandscapeVertical" format="float" />
<!-- defaults to borderSpaceDps, if not specified -->
<attr name="hotseatBorderSpace" format="float" />
<!-- defaults to hotseatBorderSpace, if not specified -->
+19 -12
View File
@@ -319,7 +319,7 @@ public class DeviceProfile {
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics),
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics));
cellLayoutBorderSpaceOriginalPx = new Point(cellLayoutBorderSpacePx);
folderCellLayoutBorderSpaceOriginalPx = pxFromDp(inv.folderBorderSpace, mMetrics, 1f);
folderCellLayoutBorderSpaceOriginalPx = pxFromDp(inv.folderBorderSpace, mMetrics);
folderCellLayoutBorderSpacePx = new Point(folderCellLayoutBorderSpaceOriginalPx,
folderCellLayoutBorderSpaceOriginalPx);
@@ -525,21 +525,21 @@ public class DeviceProfile {
}
private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) {
return getCellLayoutBorderSpace(idp, 1f);
}
private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp, float scale) {
if (!isScalableGrid) {
return new Point(0, 0);
}
int horizontalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].x, mMetrics);
int verticalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].y, mMetrics);
int horizontalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].x, mMetrics, scale);
int verticalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].y, mMetrics, scale);
return new Point(horizontalSpacePx, verticalSpacePx);
}
private Point getCellLayoutBorderSpaceScaled(InvariantDeviceProfile idp, float scale) {
Point original = getCellLayoutBorderSpace(idp);
return new Point((int) (original.x * scale), (int) (original.y * scale));
}
public Info getDisplayInfo() {
return mInfo;
}
@@ -708,7 +708,7 @@ public class DeviceProfile {
iconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * iconScale);
iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * iconScale);
cellLayoutBorderSpacePx = getCellLayoutBorderSpaceScaled(inv, scale);
cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv, scale);
if (isScalableGrid) {
cellWidthPx = pxFromDp(inv.minCellSize[mTypeIndex].x, mMetrics, scale);
@@ -756,15 +756,22 @@ public class DeviceProfile {
* Updates the iconSize for allApps* variants.
*/
public void updateAllAppsIconSize(float scale, Resources res) {
//TODO(b/218638090): remove the tablet condition once we have phone specs
if (isScalableGrid && isTablet) {
allAppsBorderSpacePx = new Point(
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics, scale),
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics, scale));
if (isScalableGrid) {
allAppsIconSizePx =
pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics);
allAppsIconTextSizePx =
pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics);
allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
// AllApps cells don't have real space between cells,
// so we add the border space to the cell height
allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics, scale)
+ allAppsBorderSpacePx.y;
// but width is just the cell,
// the border is added in #updateAllAppsContainerWidth
allAppsCellWidthPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].x, mMetrics, scale);
allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics, scale);
} else {
float invIconSizeDp = inv.iconSize[mTypeIndex];
float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
@@ -900,19 +900,44 @@ public class InvariantDeviceProfile {
allAppsCellSize[INDEX_DEFAULT].y);
allAppsCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
x = y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpace,
borderSpace);
allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y);
x = y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscape,
allAppsBorderSpaces[INDEX_DEFAULT].x);
allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y);
x = y = a.getFloat(
float allAppsBorderSpace = a.getFloat(
R.styleable.ProfileDisplayOption_allAppsBorderSpace, borderSpace);
float allAppsBorderSpaceLandscape = a.getFloat(
R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscape,
allAppsBorderSpace);
float allAppsBorderSpaceTwoPanelPortrait = a.getFloat(
R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortrait,
allAppsBorderSpaces[INDEX_DEFAULT].x);
allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
x = y = a.getFloat(
allAppsBorderSpace);
float allAppsBorderSpaceTwoPanelLandscape = a.getFloat(
R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscape,
allAppsBorderSpaces[INDEX_DEFAULT].x);
allAppsBorderSpace);
x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceHorizontal,
allAppsBorderSpace);
y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceVertical,
allAppsBorderSpace);
allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y);
x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeHorizontal,
allAppsBorderSpaceLandscape);
y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeVertical,
allAppsBorderSpaceLandscape);
allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y);
x = a.getFloat(
R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitHorizontal,
allAppsBorderSpaceTwoPanelPortrait);
y = a.getFloat(
R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitVertical,
allAppsBorderSpaceTwoPanelPortrait);
allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
x = a.getFloat(
R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeHorizontal,
allAppsBorderSpaceTwoPanelLandscape);
y = a.getFloat(
R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeVertical,
allAppsBorderSpaceTwoPanelLandscape);
allAppsBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
iconSizes[INDEX_DEFAULT] =