Adding support for non-zero left insets

Bug: 29613069
Change-Id: Ifdf9bcce7ecdedc510f3be8a4dc10eb8da7c4bf1
This commit is contained in:
Sunny Goyal
2016-07-06 09:47:56 -07:00
parent 27731e4d7d
commit 6c2975e7e3
5 changed files with 56 additions and 41 deletions

View File

@@ -194,9 +194,7 @@ public class DeviceProfile {
updateIconSize(1f, drawablePadding, res, dm);
float usedHeight = (cellHeightPx * inv.numRows);
// We only care about the top and bottom workspace padding, which is not affected by RTL.
Rect workspacePadding = getWorkspacePadding();
int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom);
int maxHeight = (availableHeightPx - getTotalWorkspacePadding().y);
if (usedHeight > maxHeight) {
scale = maxHeight / usedHeight;
drawablePadding = 0;
@@ -291,15 +289,23 @@ public class DeviceProfile {
Point result = new Point();
// Since we are only concerned with the overall padding, layout direction does
// not matter.
Rect padding = getWorkspacePadding();
result.x = calculateCellWidth(availableWidthPx - padding.left - padding.right,
inv.numColumns);
result.y = calculateCellHeight(availableHeightPx - padding.top - padding.bottom,
inv.numRows);
Point padding = getTotalWorkspacePadding();
result.x = calculateCellWidth(availableWidthPx - padding.x, inv.numColumns);
result.y = calculateCellHeight(availableHeightPx - padding.y, inv.numRows);
return result;
}
/** Returns the workspace padding in the specified orientation */
public Point getTotalWorkspacePadding() {
Rect padding = getWorkspacePadding();
return new Point(padding.left + padding.right, padding.top + padding.bottom);
}
/**
* Returns the workspace padding in the specified orientation.
* Note that it assumes that while in verticalBarLayout, the nav bar is on the right, as such
* this value is not reliable.
* Use {@link #getTotalWorkspacePadding()} instead.
*/
public Rect getWorkspacePadding() {
Rect padding = new Rect();
if (isVerticalBarLayout()) {
@@ -353,17 +359,6 @@ public class DeviceProfile {
return zoneHeight;
}
// The rect returned will be extended to below the system ui that covers the workspace
public boolean isInHotseatRect(int x, int y) {
if (isVerticalBarLayout()) {
return (x >= (availableWidthPx - hotseatBarHeightPx))
&& (y >= 0) && (y <= availableHeightPx);
} else {
return (x >= 0) && (x <= availableWidthPx)
&& (y >= (availableHeightPx - hotseatBarHeightPx));
}
}
public static int calculateCellWidth(int width, int countX) {
return width / countX;
}