Merge "launcher: create attrs for more horizontal margin options" into sc-v2-dev
This commit is contained in:
@@ -177,7 +177,7 @@
|
|||||||
<attr name="minWidthDps" format="float" />
|
<attr name="minWidthDps" format="float" />
|
||||||
<attr name="minHeightDps" format="float" />
|
<attr name="minHeightDps" format="float" />
|
||||||
|
|
||||||
<!-- These min cell values are only used if GridDisplayOption#isScalable is true-->
|
<!-- These min cell values are only used if GridDisplayOption#isScalable is true -->
|
||||||
<attr name="minCellHeightDps" format="float" />
|
<attr name="minCellHeightDps" format="float" />
|
||||||
<attr name="minCellWidthDps" format="float" />
|
<attr name="minCellWidthDps" format="float" />
|
||||||
<!-- twoPanelPortraitMinCellWidthDps defaults to minCellHeightDps, if not specified -->
|
<!-- twoPanelPortraitMinCellWidthDps defaults to minCellHeightDps, if not specified -->
|
||||||
@@ -223,6 +223,12 @@
|
|||||||
<!-- allAppsIconTextSize defaults to iconTextSize, if not specified -->
|
<!-- allAppsIconTextSize defaults to iconTextSize, if not specified -->
|
||||||
<attr name="allAppsIconTextSize" format="float" />
|
<attr name="allAppsIconTextSize" format="float" />
|
||||||
|
|
||||||
|
<!-- Margin on left and right of the workspace when GridDisplayOption#isScalable is true -->
|
||||||
|
<attr name="horizontalMargin" format="float"/>
|
||||||
|
<!-- twoPanelLandscapeHorizontalMargin defaults to horizontalMargin if not specified -->
|
||||||
|
<attr name="twoPanelLandscapeHorizontalMargin" format="float"/>
|
||||||
|
<!-- twoPanelPortraitHorizontalMargin defaults to horizontalMargin if not specified -->
|
||||||
|
<attr name="twoPanelPortraitHorizontalMargin" format="float"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="CellLayout">
|
<declare-styleable name="CellLayout">
|
||||||
|
|||||||
@@ -29,9 +29,6 @@
|
|||||||
<dimen name="dynamic_grid_cell_layout_padding">5.5dp</dimen>
|
<dimen name="dynamic_grid_cell_layout_padding">5.5dp</dimen>
|
||||||
<dimen name="dynamic_grid_cell_padding_x">8dp</dimen>
|
<dimen name="dynamic_grid_cell_padding_x">8dp</dimen>
|
||||||
|
|
||||||
<dimen name="two_panels_home_side_padding_landscape">36dp</dimen>
|
|
||||||
<dimen name="two_panels_home_side_padding_portrait">9dp</dimen>
|
|
||||||
|
|
||||||
<!-- Hotseat -->
|
<!-- Hotseat -->
|
||||||
<dimen name="dynamic_grid_hotseat_top_padding">8dp</dimen>
|
<dimen name="dynamic_grid_hotseat_top_padding">8dp</dimen>
|
||||||
<dimen name="dynamic_grid_hotseat_bottom_padding">2dp</dimen>
|
<dimen name="dynamic_grid_hotseat_bottom_padding">2dp</dimen>
|
||||||
@@ -41,7 +38,6 @@
|
|||||||
<dimen name="dynamic_grid_hotseat_side_padding">0dp</dimen>
|
<dimen name="dynamic_grid_hotseat_side_padding">0dp</dimen>
|
||||||
|
|
||||||
<!-- Scalable Grid -->
|
<!-- Scalable Grid -->
|
||||||
<dimen name="scalable_grid_left_right_margin">22dp</dimen>
|
|
||||||
<dimen name="scalable_grid_qsb_bottom_margin">42dp</dimen>
|
<dimen name="scalable_grid_qsb_bottom_margin">42dp</dimen>
|
||||||
|
|
||||||
<!-- Workspace page indicator -->
|
<!-- Workspace page indicator -->
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ public class DeviceProfile {
|
|||||||
private static final int PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER = 4;
|
private static final int PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER = 4;
|
||||||
|
|
||||||
// Workspace
|
// Workspace
|
||||||
public final int desiredWorkspaceLeftRightOriginalPx;
|
public final int desiredWorkspaceHorizontalMarginOriginalPx;
|
||||||
public int desiredWorkspaceLeftRightMarginPx;
|
public int desiredWorkspaceHorizontalMarginPx;
|
||||||
public final int cellLayoutBorderSpacingOriginalPx;
|
public final int cellLayoutBorderSpacingOriginalPx;
|
||||||
public int cellLayoutBorderSpacingPx;
|
public int cellLayoutBorderSpacingPx;
|
||||||
public final int cellLayoutPaddingLeftRightPx;
|
public final int cellLayoutPaddingLeftRightPx;
|
||||||
@@ -270,11 +270,8 @@ public class DeviceProfile {
|
|||||||
|
|
||||||
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
|
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
|
||||||
|
|
||||||
desiredWorkspaceLeftRightMarginPx = isVerticalBarLayout() ? 0 : isScalableGrid
|
desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
|
||||||
? res.getDimensionPixelSize(R.dimen.scalable_grid_left_right_margin)
|
desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
|
||||||
: res.getDimensionPixelSize(R.dimen.dynamic_grid_left_right_margin);
|
|
||||||
desiredWorkspaceLeftRightOriginalPx = desiredWorkspaceLeftRightMarginPx;
|
|
||||||
|
|
||||||
|
|
||||||
allAppsOpenVerticalTranslate = res.getDimensionPixelSize(
|
allAppsOpenVerticalTranslate = res.getDimensionPixelSize(
|
||||||
R.dimen.all_apps_open_vertical_translate);
|
R.dimen.all_apps_open_vertical_translate);
|
||||||
@@ -446,6 +443,29 @@ public class DeviceProfile {
|
|||||||
new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE);
|
new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getHorizontalMarginPx(InvariantDeviceProfile idp, Resources res) {
|
||||||
|
if (isVerticalBarLayout()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int horizontalMarginPx;
|
||||||
|
|
||||||
|
if (isScalableGrid) {
|
||||||
|
if (isTwoPanels) {
|
||||||
|
if (isLandscape) {
|
||||||
|
horizontalMarginPx = pxFromDp(idp.twoPanelLandscapeHorizontalMargin, mMetrics);
|
||||||
|
} else {
|
||||||
|
horizontalMarginPx = pxFromDp(idp.twoPanelPortraitHorizontalMargin, mMetrics);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
horizontalMarginPx = pxFromDp(idp.horizontalMargin, mMetrics);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
horizontalMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_left_right_margin);
|
||||||
|
}
|
||||||
|
return horizontalMarginPx;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateHotseatIconSize(int hotseatIconSizePx) {
|
private void updateHotseatIconSize(int hotseatIconSizePx) {
|
||||||
// Ensure there is enough space for folder icons, which have a slightly larger radius.
|
// Ensure there is enough space for folder icons, which have a slightly larger radius.
|
||||||
hotseatCellHeightPx = (int) Math.ceil(hotseatIconSizePx * ICON_OVERLAP_FACTOR);
|
hotseatCellHeightPx = (int) Math.ceil(hotseatIconSizePx * ICON_OVERLAP_FACTOR);
|
||||||
@@ -554,7 +574,7 @@ public class DeviceProfile {
|
|||||||
allAppsLeftRightPadding = Math.max(1, (availableWidthPx - usedWidth) / 2);
|
allAppsLeftRightPadding = Math.max(1, (availableWidthPx - usedWidth) / 2);
|
||||||
} else {
|
} else {
|
||||||
allAppsLeftRightPadding =
|
allAppsLeftRightPadding =
|
||||||
desiredWorkspaceLeftRightMarginPx + cellLayoutPaddingLeftRightPx;
|
desiredWorkspaceHorizontalMarginPx + cellLayoutPaddingLeftRightPx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,7 +601,7 @@ public class DeviceProfile {
|
|||||||
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
|
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
|
||||||
float usedWidth = (cellWidthPx * numColumns)
|
float usedWidth = (cellWidthPx * numColumns)
|
||||||
+ (cellLayoutBorderSpacingPx * (numColumns - 1))
|
+ (cellLayoutBorderSpacingPx * (numColumns - 1))
|
||||||
+ (desiredWorkspaceLeftRightMarginPx * 2);
|
+ (desiredWorkspaceHorizontalMarginPx * 2);
|
||||||
// We do not subtract padding here, as we also scale the workspace padding if needed.
|
// We do not subtract padding here, as we also scale the workspace padding if needed.
|
||||||
scaleX = availableWidthPx / usedWidth;
|
scaleX = availableWidthPx / usedWidth;
|
||||||
shouldScale = true;
|
shouldScale = true;
|
||||||
@@ -647,7 +667,8 @@ public class DeviceProfile {
|
|||||||
int cellContentHeight = iconSizePx + iconDrawablePaddingPx
|
int cellContentHeight = iconSizePx + iconDrawablePaddingPx
|
||||||
+ Utilities.calculateTextHeight(iconTextSizePx);
|
+ Utilities.calculateTextHeight(iconTextSizePx);
|
||||||
cellYPaddingPx = Math.max(0, cellHeightPx - cellContentHeight) / 2;
|
cellYPaddingPx = Math.max(0, cellHeightPx - cellContentHeight) / 2;
|
||||||
desiredWorkspaceLeftRightMarginPx = (int) (desiredWorkspaceLeftRightOriginalPx * scale);
|
desiredWorkspaceHorizontalMarginPx =
|
||||||
|
(int) (desiredWorkspaceHorizontalMarginOriginalPx * scale);
|
||||||
} else {
|
} else {
|
||||||
cellWidthPx = iconSizePx + iconDrawablePaddingPx;
|
cellWidthPx = iconSizePx + iconDrawablePaddingPx;
|
||||||
cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR)
|
cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR)
|
||||||
@@ -851,9 +872,9 @@ public class DeviceProfile {
|
|||||||
int paddingBottom = hotseatTop + workspacePageIndicatorHeight
|
int paddingBottom = hotseatTop + workspacePageIndicatorHeight
|
||||||
+ workspaceBottomPadding - mWorkspacePageIndicatorOverlapWorkspace;
|
+ workspaceBottomPadding - mWorkspacePageIndicatorOverlapWorkspace;
|
||||||
|
|
||||||
padding.set(desiredWorkspaceLeftRightMarginPx,
|
padding.set(desiredWorkspaceHorizontalMarginPx,
|
||||||
(isScalableGrid ? workspaceTopPadding : edgeMarginPx),
|
(isScalableGrid ? workspaceTopPadding : edgeMarginPx),
|
||||||
desiredWorkspaceLeftRightMarginPx,
|
desiredWorkspaceHorizontalMarginPx,
|
||||||
paddingBottom);
|
paddingBottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1081,8 +1102,8 @@ public class DeviceProfile {
|
|||||||
|
|
||||||
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacingPx",
|
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacingPx",
|
||||||
cellLayoutBorderSpacingPx));
|
cellLayoutBorderSpacingPx));
|
||||||
writer.println(prefix + pxToDpStr("desiredWorkspaceLeftRightMarginPx",
|
writer.println(prefix + pxToDpStr("desiredWorkspaceHorizontalMarginPx",
|
||||||
desiredWorkspaceLeftRightMarginPx));
|
desiredWorkspaceHorizontalMarginPx));
|
||||||
|
|
||||||
writer.println(prefix + pxToDpStr("allAppsIconSizePx", allAppsIconSizePx));
|
writer.println(prefix + pxToDpStr("allAppsIconSizePx", allAppsIconSizePx));
|
||||||
writer.println(prefix + pxToDpStr("allAppsIconTextSizePx", allAppsIconTextSizePx));
|
writer.println(prefix + pxToDpStr("allAppsIconTextSizePx", allAppsIconTextSizePx));
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ public class InvariantDeviceProfile {
|
|||||||
public float twoPanelLandscapeMinCellHeightDps;
|
public float twoPanelLandscapeMinCellHeightDps;
|
||||||
public float twoPanelLandscapeMinCellWidthDps;
|
public float twoPanelLandscapeMinCellWidthDps;
|
||||||
public float borderSpacing;
|
public float borderSpacing;
|
||||||
|
public float horizontalMargin;
|
||||||
|
public float twoPanelLandscapeHorizontalMargin;
|
||||||
|
public float twoPanelPortraitHorizontalMargin;
|
||||||
|
|
||||||
private SparseArray<TypedValue> mExtraAttrs;
|
private SparseArray<TypedValue> mExtraAttrs;
|
||||||
|
|
||||||
@@ -289,6 +292,10 @@ public class InvariantDeviceProfile {
|
|||||||
borderSpacing = displayOption.borderSpacing;
|
borderSpacing = displayOption.borderSpacing;
|
||||||
allAppsCellSpacing = displayOption.allAppsCellSpacing;
|
allAppsCellSpacing = displayOption.allAppsCellSpacing;
|
||||||
|
|
||||||
|
horizontalMargin = displayOption.horizontalMargin;
|
||||||
|
twoPanelLandscapeHorizontalMargin = displayOption.twoPanelLandscapeHorizontalMargin;
|
||||||
|
twoPanelPortraitHorizontalMargin = displayOption.twoPanelPortraitHorizontalMargin;
|
||||||
|
|
||||||
numShownHotseatIcons = closestProfile.numHotseatIcons;
|
numShownHotseatIcons = closestProfile.numHotseatIcons;
|
||||||
numDatabaseHotseatIcons = isSplitDisplay
|
numDatabaseHotseatIcons = isSplitDisplay
|
||||||
? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
|
? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
|
||||||
@@ -728,6 +735,10 @@ public class InvariantDeviceProfile {
|
|||||||
private float allAppsCellSpacing;
|
private float allAppsCellSpacing;
|
||||||
private float borderSpacing;
|
private float borderSpacing;
|
||||||
|
|
||||||
|
private float horizontalMargin;
|
||||||
|
private float twoPanelLandscapeHorizontalMargin;
|
||||||
|
private float twoPanelPortraitHorizontalMargin;
|
||||||
|
|
||||||
private final float[] iconSizes = new float[COUNT_TOTAL];
|
private final float[] iconSizes = new float[COUNT_TOTAL];
|
||||||
private final float[] textSizes = new float[COUNT_TOTAL];
|
private final float[] textSizes = new float[COUNT_TOTAL];
|
||||||
|
|
||||||
@@ -790,6 +801,14 @@ public class InvariantDeviceProfile {
|
|||||||
a.getFloat(R.styleable.ProfileDisplayOption_twoPanelLandscapeIconTextSize,
|
a.getFloat(R.styleable.ProfileDisplayOption_twoPanelLandscapeIconTextSize,
|
||||||
textSizes[INDEX_LANDSCAPE]);
|
textSizes[INDEX_LANDSCAPE]);
|
||||||
|
|
||||||
|
horizontalMargin = a.getFloat(R.styleable.ProfileDisplayOption_horizontalMargin, 0);
|
||||||
|
twoPanelLandscapeHorizontalMargin = a.getFloat(
|
||||||
|
R.styleable.ProfileDisplayOption_twoPanelLandscapeHorizontalMargin,
|
||||||
|
horizontalMargin);
|
||||||
|
twoPanelPortraitHorizontalMargin = a.getFloat(
|
||||||
|
R.styleable.ProfileDisplayOption_twoPanelPortraitHorizontalMargin,
|
||||||
|
horizontalMargin);
|
||||||
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -820,6 +839,9 @@ public class InvariantDeviceProfile {
|
|||||||
twoPanelLandscapeMinCellWidthDps *= w;
|
twoPanelLandscapeMinCellWidthDps *= w;
|
||||||
borderSpacing *= w;
|
borderSpacing *= w;
|
||||||
allAppsCellSpacing *= w;
|
allAppsCellSpacing *= w;
|
||||||
|
horizontalMargin *= w;
|
||||||
|
twoPanelLandscapeHorizontalMargin *= w;
|
||||||
|
twoPanelPortraitHorizontalMargin *= w;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,6 +858,9 @@ public class InvariantDeviceProfile {
|
|||||||
twoPanelLandscapeMinCellWidthDps += p.twoPanelLandscapeMinCellWidthDps;
|
twoPanelLandscapeMinCellWidthDps += p.twoPanelLandscapeMinCellWidthDps;
|
||||||
borderSpacing += p.borderSpacing;
|
borderSpacing += p.borderSpacing;
|
||||||
allAppsCellSpacing += p.allAppsCellSpacing;
|
allAppsCellSpacing += p.allAppsCellSpacing;
|
||||||
|
horizontalMargin += p.horizontalMargin;
|
||||||
|
twoPanelLandscapeHorizontalMargin += p.twoPanelLandscapeHorizontalMargin;
|
||||||
|
twoPanelPortraitHorizontalMargin += p.twoPanelPortraitHorizontalMargin;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
final View child = getChildAt(i);
|
final View child = getChildAt(i);
|
||||||
if (child == mAppsView) {
|
if (child == mAppsView) {
|
||||||
int padding = 2 * (grid.desiredWorkspaceLeftRightMarginPx
|
int padding = 2 * (grid.desiredWorkspaceHorizontalMarginPx
|
||||||
+ grid.cellLayoutPaddingLeftRightPx);
|
+ grid.cellLayoutPaddingLeftRightPx);
|
||||||
|
|
||||||
int maxWidth = grid.allAppsCellWidthPx * grid.numShownAllAppsColumns + padding;
|
int maxWidth = grid.allAppsCellWidthPx * grid.numShownAllAppsColumns + padding;
|
||||||
|
|||||||
Reference in New Issue
Block a user