Merge "Adding support for non-zero left insets" into ub-launcher3-calgary
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -63,18 +63,18 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo {
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
|
||||
|
||||
Rect paddingLand = idp.landscapeProfile.getWorkspacePadding();
|
||||
Rect paddingPort = idp.portraitProfile.getWorkspacePadding();
|
||||
Point paddingLand = idp.landscapeProfile.getTotalWorkspacePadding();
|
||||
Point paddingPort = idp.portraitProfile.getTotalWorkspacePadding();
|
||||
|
||||
// Always assume we're working with the smallest span to make sure we
|
||||
// reserve enough space in both orientations.
|
||||
float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min(
|
||||
idp.landscapeProfile.widthPx - paddingLand.left - paddingLand.right,
|
||||
idp.portraitProfile.widthPx - paddingPort.left - paddingPort.right),
|
||||
idp.landscapeProfile.widthPx - paddingLand.x,
|
||||
idp.portraitProfile.widthPx - paddingPort.x),
|
||||
idp.numColumns);
|
||||
float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min(
|
||||
idp.landscapeProfile.heightPx - paddingLand.top - paddingLand.bottom,
|
||||
idp.portraitProfile.heightPx - paddingPort.top - paddingPort.bottom),
|
||||
idp.landscapeProfile.heightPx - paddingLand.y,
|
||||
idp.portraitProfile.heightPx - paddingPort.y),
|
||||
idp.numRows);
|
||||
|
||||
// We want to account for the extra amount of padding that we are adding to the widget
|
||||
|
||||
@@ -15,7 +15,9 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
|
||||
private final Paint mOpaquePaint;
|
||||
@ViewDebug.ExportedProperty(category = "launcher")
|
||||
private boolean mDrawRightInsetBar;
|
||||
private boolean mDrawSideInsetBar;
|
||||
@ViewDebug.ExportedProperty(category = "launcher")
|
||||
private int mLeftInsetBarWidth;
|
||||
@ViewDebug.ExportedProperty(category = "launcher")
|
||||
private int mRightInsetBarWidth;
|
||||
|
||||
@@ -42,13 +44,14 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
@TargetApi(23)
|
||||
@Override
|
||||
protected boolean fitSystemWindows(Rect insets) {
|
||||
mDrawRightInsetBar = insets.right > 0 &&
|
||||
mDrawSideInsetBar = (insets.right > 0 || insets.left > 0) &&
|
||||
(!Utilities.ATLEAST_MARSHMALLOW ||
|
||||
getContext().getSystemService(ActivityManager.class).isLowRamDevice());
|
||||
mRightInsetBarWidth = insets.right;
|
||||
setInsets(mDrawRightInsetBar ? new Rect(0, insets.top, 0, insets.bottom) : insets);
|
||||
mLeftInsetBarWidth = insets.left;
|
||||
setInsets(mDrawSideInsetBar ? new Rect(0, insets.top, 0, insets.bottom) : insets);
|
||||
|
||||
if (mAlignedView != null && mDrawRightInsetBar) {
|
||||
if (mAlignedView != null && mDrawSideInsetBar) {
|
||||
// Apply margins on aligned view to handle left/right insets.
|
||||
MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams();
|
||||
if (lp.leftMargin != insets.left || lp.rightMargin != insets.right) {
|
||||
@@ -66,9 +69,14 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
super.dispatchDraw(canvas);
|
||||
|
||||
// If the right inset is opaque, draw a black rectangle to ensure that is stays opaque.
|
||||
if (mDrawRightInsetBar) {
|
||||
int width = getWidth();
|
||||
canvas.drawRect(width - mRightInsetBarWidth, 0, width, getHeight(), mOpaquePaint);
|
||||
if (mDrawSideInsetBar) {
|
||||
if (mRightInsetBarWidth > 0) {
|
||||
int width = getWidth();
|
||||
canvas.drawRect(width - mRightInsetBarWidth, 0, width, getHeight(), mOpaquePaint);
|
||||
}
|
||||
if (mLeftInsetBarWidth > 0) {
|
||||
canvas.drawRect(0, 0, mLeftInsetBarWidth, getHeight(), mOpaquePaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,7 +357,16 @@ public class Workspace extends PagedView
|
||||
|
||||
@Override
|
||||
public void setInsets(Rect insets) {
|
||||
int extraLeftPadding = insets.left - mInsets.left;
|
||||
mInsets.set(insets);
|
||||
if (extraLeftPadding != 0) {
|
||||
/**
|
||||
* Initial layout assumes that the insets is on the right,
|
||||
* {@link DeviceProfile#getWorkspacePadding()}. Compensate for the difference.
|
||||
*/
|
||||
setPadding(getPaddingLeft() + extraLeftPadding, getPaddingTop(),
|
||||
getPaddingRight() - extraLeftPadding, getPaddingBottom());
|
||||
}
|
||||
|
||||
CellLayout customScreen = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
|
||||
if (customScreen != null) {
|
||||
@@ -550,8 +559,9 @@ public class Workspace extends PagedView
|
||||
// Add the first page
|
||||
CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, 0);
|
||||
|
||||
if (!mIsRtl || !mLauncher.getDeviceProfile().isVerticalBarLayout()) {
|
||||
// Let the cell layout extend the start padding.
|
||||
if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
|
||||
// Let the cell layout extend the start padding. On transposed layout, there is page
|
||||
// indicator on left and hotseat on right, as such workspace does not touch the edge.
|
||||
((LayoutParams) firstPage.getLayoutParams()).matchStartEdge = true;
|
||||
firstPage.setPaddingRelative(getPaddingStart(), 0, 0, 0);
|
||||
}
|
||||
@@ -3087,7 +3097,11 @@ public class Workspace extends PagedView
|
||||
mTempXY[0] = x;
|
||||
mTempXY[1] = y;
|
||||
mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY, true);
|
||||
return mLauncher.getDeviceProfile().isInHotseatRect(mTempXY[0], mTempXY[1]);
|
||||
View hotseat = mLauncher.getHotseat();
|
||||
return mTempXY[0] >= hotseat.getLeft() &&
|
||||
mTempXY[0] <= hotseat.getRight() &&
|
||||
mTempXY[1] >= hotseat.getTop() &&
|
||||
mTempXY[1] <= hotseat.getBottom();
|
||||
}
|
||||
|
||||
void mapPointFromSelfToHotseatLayout(Hotseat hotseat, float[] xy) {
|
||||
|
||||
@@ -1052,7 +1052,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
||||
int top = Math.min(Math.max(sTempRect.top, centeredTop),
|
||||
sTempRect.top + sTempRect.height() - height);
|
||||
|
||||
int distFromEdgeOfScreen = grid.getWorkspacePadding().left + getPaddingLeft();
|
||||
int distFromEdgeOfScreen = mLauncher.getWorkspace().getPaddingLeft() + getPaddingLeft();
|
||||
|
||||
if (grid.isPhone && (grid.availableWidthPx - width) < 4 * distFromEdgeOfScreen) {
|
||||
// Center the folder if it is very close to being centered anyway, by virtue of
|
||||
@@ -1091,10 +1091,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
||||
|
||||
private int getContentAreaHeight() {
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
Rect workspacePadding = grid.getWorkspacePadding();
|
||||
int maxContentAreaHeight = grid.availableHeightPx -
|
||||
workspacePadding.top - workspacePadding.bottom -
|
||||
mFooterHeight;
|
||||
int maxContentAreaHeight = grid.availableHeightPx
|
||||
- grid.getTotalWorkspacePadding().y - mFooterHeight;
|
||||
int height = Math.min(maxContentAreaHeight,
|
||||
mContent.getDesiredHeight());
|
||||
return Math.max(height, MIN_CONTENT_DIMEN);
|
||||
|
||||
Reference in New Issue
Block a user