From 18751b649d02fd1e613c294e52193623b42f69e7 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Mon, 31 Jul 2017 17:25:27 -0700 Subject: Landscape launcher grid/all apps to spec. * Moves FastScroller to the right. Bug: 64160529 Change-Id: Ie0dfc0a2f0f2d6f6366e4f299769148d76017782 --- src/com/android/launcher3/DeviceProfile.java | 110 ++++++++++++++++----------- 1 file changed, 65 insertions(+), 45 deletions(-) (limited to 'src/com') diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 6dfb1901e..60c19bc5d 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -75,6 +75,7 @@ public class DeviceProfile { // Workspace private final int desiredWorkspaceLeftRightMarginPx; public final int cellLayoutPaddingLeftRightPx; + public final int cellLayoutBottomPaddingPx; public final int edgeMarginPx; public final Rect defaultWidgetPadding; private final int defaultPageSpacingPx; @@ -84,7 +85,8 @@ public class DeviceProfile { // Page indicator private int pageIndicatorSizePx; - private final int pageIndicatorLandGutterPx; + private final int pageIndicatorLandLeftNavBarGutterPx; + private final int pageIndicatorLandRightNavBarGutterPx; private final int pageIndicatorLandWorkspaceOffsetPx; // Workspace icons @@ -113,13 +115,16 @@ public class DeviceProfile { // Hotseat public int hotseatCellHeightPx; - public int hotseatBarHeightPx; + // In portrait: size = height, in landscape: size = width + public int hotseatBarSizePx; public int hotseatBarTopPaddingPx; + public int hotseatBarBottomPaddingPx; + + public int hotseatBarLeftNavBarLeftPaddingPx; public int hotseatBarLeftNavBarRightPaddingPx; + + public int hotseatBarRightNavBarLeftPaddingPx; public int hotseatBarRightNavBarRightPaddingPx; - public int hotseatBarBottomPaddingPx; - public int hotseatLandLeftNavBarGutterPx; - public int hotseatLandRightNavBarGutterPx; // All apps public int allAppsCellHeightPx; @@ -177,10 +182,14 @@ public class DeviceProfile { desiredWorkspaceLeftRightMarginPx = isVerticalBarLayout() ? 0 : edgeMarginPx; cellLayoutPaddingLeftRightPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_padding); + cellLayoutBottomPaddingPx = + res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_bottom_padding); pageIndicatorSizePx = res.getDimensionPixelSize( R.dimen.dynamic_grid_min_page_indicator_size); - pageIndicatorLandGutterPx = res.getDimensionPixelSize( - R.dimen.dynamic_grid_page_indicator_gutter_width); + pageIndicatorLandLeftNavBarGutterPx = res.getDimensionPixelSize( + R.dimen.dynamic_grid_page_indicator_land_left_nav_bar_gutter_width); + pageIndicatorLandRightNavBarGutterPx = res.getDimensionPixelSize( + R.dimen.dynamic_grid_page_indicator_land_right_nav_bar_gutter_width); pageIndicatorLandWorkspaceOffsetPx = res.getDimensionPixelSize(R.dimen.all_apps_caret_workspace_offset); defaultPageSpacingPx = @@ -213,16 +222,15 @@ public class DeviceProfile { R.dimen.dynamic_grid_hotseat_land_left_nav_bar_right_padding); hotseatBarRightNavBarRightPaddingPx = res.getDimensionPixelSize( R.dimen.dynamic_grid_hotseat_land_right_nav_bar_right_padding); - hotseatBarHeightPx = isVerticalBarLayout() - ? res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_height) - : res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_height) + hotseatBarLeftNavBarLeftPaddingPx = res.getDimensionPixelSize( + R.dimen.dynamic_grid_hotseat_land_left_nav_bar_left_padding); + hotseatBarRightNavBarLeftPaddingPx = res.getDimensionPixelSize( + R.dimen.dynamic_grid_hotseat_land_right_nav_bar_left_padding); + hotseatBarSizePx = isVerticalBarLayout() + ? Utilities.pxFromDp(inv.iconSize, dm) + : res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_size) + hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx; - hotseatLandLeftNavBarGutterPx = res.getDimensionPixelSize( - R.dimen.dynamic_grid_hotseat_land_left_nav_bar_gutter_width); - hotseatLandRightNavBarGutterPx = res.getDimensionPixelSize( - R.dimen.dynamic_grid_hotseat_land_right_nav_bar_gutter_width); - // Determine sizes. widthPx = width; heightPx = height; @@ -246,7 +254,7 @@ public class DeviceProfile { // in portrait mode closer together by adding more height to the hotseat. // Note: This calculation was created after noticing a pattern in the design spec. int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx; - hotseatBarHeightPx += extraSpace - pageIndicatorSizePx; + hotseatBarSizePx += extraSpace - pageIndicatorSizePx; // Recalculate the available dimensions using the new hotseat size. updateAvailableDimensions(dm, res); @@ -332,11 +340,16 @@ public class DeviceProfile { } private void updateIconSize(float scale, Resources res, DisplayMetrics dm) { + // Workspace float invIconSizePx = isVerticalBarLayout() ? inv.landscapeIconSize : inv.iconSize; iconSizePx = (int) (Utilities.pxFromDp(invIconSizePx, dm) * scale); iconTextSizePx = (int) (Utilities.pxFromSp(inv.iconTextSize, dm) * scale); iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale); + cellWidthPx = iconSizePx + iconDrawablePaddingPx; + cellHeightPx = iconSizePx + iconDrawablePaddingPx + + Utilities.calculateTextHeight(iconTextSizePx); + // All apps allAppsIconTextSizePx = iconTextSizePx; allAppsIconSizePx = iconSizePx; @@ -348,15 +361,14 @@ public class DeviceProfile { adjustToHideWorkspaceLabels(); } - cellWidthPx = iconSizePx + iconDrawablePaddingPx; - cellHeightPx = iconSizePx + iconDrawablePaddingPx - + Utilities.calculateTextHeight(iconTextSizePx); - // Hotseat + if (isVerticalBarLayout()) { + hotseatBarSizePx = iconSizePx; + } hotseatCellHeightPx = iconSizePx + iconDrawablePaddingPx; if (!isVerticalBarLayout()) { - int expectedWorkspaceHeight = availableHeightPx - hotseatBarHeightPx + int expectedWorkspaceHeight = availableHeightPx - hotseatBarSizePx - pageIndicatorSizePx - topWorkspacePadding; float minRequiredHeight = dropTargetBarSizePx + workspaceSpringLoadedBottomSpace; workspaceSpringLoadShrinkFactor = Math.min( @@ -449,9 +461,10 @@ public class DeviceProfile { // Since we are only concerned with the overall padding, layout direction does // not matter. Point padding = getTotalWorkspacePadding(); - int cellPadding = cellLayoutPaddingLeftRightPx * 2; - result.x = calculateCellWidth(availableWidthPx - padding.x - cellPadding, inv.numColumns); - result.y = calculateCellHeight(availableHeightPx - padding.y, inv.numRows); + result.x = calculateCellWidth(availableWidthPx - padding.x + - cellLayoutPaddingLeftRightPx * 2, inv.numColumns); + result.y = calculateCellHeight(availableHeightPx - padding.y + - cellLayoutBottomPaddingPx, inv.numRows); return result; } @@ -467,20 +480,21 @@ public class DeviceProfile { Rect padding = recycle == null ? new Rect() : recycle; if (isVerticalBarLayout()) { if (mInsets.left > 0) { - padding.set(mInsets.left + pageIndicatorLandGutterPx, + padding.set(mInsets.left + pageIndicatorLandLeftNavBarGutterPx, 0, - hotseatBarHeightPx + hotseatLandLeftNavBarGutterPx - + hotseatBarLeftNavBarRightPaddingPx - mInsets.left, + hotseatBarSizePx + hotseatBarLeftNavBarRightPaddingPx + + hotseatBarLeftNavBarLeftPaddingPx + - mInsets.left, edgeMarginPx); } else { - padding.set(pageIndicatorLandGutterPx, + padding.set(pageIndicatorLandRightNavBarGutterPx, 0, - hotseatBarHeightPx + hotseatLandRightNavBarGutterPx - + hotseatBarRightNavBarRightPaddingPx, + hotseatBarSizePx + hotseatBarRightNavBarRightPaddingPx + + hotseatBarRightNavBarLeftPaddingPx, edgeMarginPx); } } else { - int paddingBottom = hotseatBarHeightPx + pageIndicatorSizePx; + int paddingBottom = hotseatBarSizePx + pageIndicatorSizePx; if (isTablet) { // Pad the left and right of the workspace to ensure consistent spacing // between all icons @@ -515,14 +529,14 @@ public class DeviceProfile { // Folders should only appear right of the drop target bar and left of the hotseat return new Rect(mInsets.left + dropTargetBarSizePx + edgeMarginPx, mInsets.top, - mInsets.left + availableWidthPx - hotseatBarHeightPx - edgeMarginPx, + mInsets.left + availableWidthPx - hotseatBarSizePx - edgeMarginPx, mInsets.top + availableHeightPx); } else { // Folders should only appear below the drop target bar and above the hotseat return new Rect(mInsets.left, mInsets.top + dropTargetBarSizePx + edgeMarginPx, mInsets.left + availableWidthPx, - mInsets.top + availableHeightPx - hotseatBarHeightPx + mInsets.top + availableHeightPx - hotseatBarSizePx - pageIndicatorSizePx - edgeMarginPx); } } @@ -609,38 +623,44 @@ public class DeviceProfile { if (hasVerticalBarLayout) { // Vertical hotseat -- The hotseat is fixed in the layout to be on the right of the // screen regardless of RTL - lp.gravity = Gravity.RIGHT; - lp.width = hotseatBarHeightPx + mInsets.left + mInsets.right; - lp.height = LayoutParams.MATCH_PARENT; - int paddingRight = mInsets.left > 0 ? hotseatBarLeftNavBarRightPaddingPx : hotseatBarRightNavBarRightPaddingPx; + int paddingLeft = mInsets.left > 0 + ? hotseatBarLeftNavBarLeftPaddingPx + : hotseatBarRightNavBarLeftPaddingPx; - hotseat.getLayout().setPadding(mInsets.left + cellLayoutPaddingLeftRightPx, - mInsets.top, mInsets.right + paddingRight + cellLayoutPaddingLeftRightPx, - workspacePadding.bottom); + lp.gravity = Gravity.RIGHT; + lp.width = hotseatBarSizePx + mInsets.left + mInsets.right + + paddingLeft + paddingRight; + lp.height = LayoutParams.MATCH_PARENT; + + hotseat.getLayout().setPadding(mInsets.left + cellLayoutPaddingLeftRightPx + + paddingLeft, + mInsets.top, + mInsets.right + cellLayoutPaddingLeftRightPx + paddingRight, + workspacePadding.bottom + cellLayoutBottomPaddingPx); } else if (isTablet) { // Pad the hotseat with the workspace padding calculated above lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; - lp.height = hotseatBarHeightPx + mInsets.bottom; + lp.height = hotseatBarSizePx + mInsets.bottom; hotseat.getLayout().setPadding(hotseatAdjustment + workspacePadding.left + cellLayoutPaddingLeftRightPx, hotseatBarTopPaddingPx, hotseatAdjustment + workspacePadding.right + cellLayoutPaddingLeftRightPx, - hotseatBarBottomPaddingPx + mInsets.bottom); + hotseatBarBottomPaddingPx + mInsets.bottom + cellLayoutBottomPaddingPx); } else { // For phones, layout the hotseat without any bottom margin // to ensure that we have space for the folders lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; - lp.height = hotseatBarHeightPx + mInsets.bottom; + lp.height = hotseatBarSizePx + mInsets.bottom; hotseat.getLayout().setPadding(hotseatAdjustment + workspacePadding.left + cellLayoutPaddingLeftRightPx, hotseatBarTopPaddingPx, hotseatAdjustment + workspacePadding.right + cellLayoutPaddingLeftRightPx, - hotseatBarBottomPaddingPx + mInsets.bottom); + hotseatBarBottomPaddingPx + mInsets.bottom + cellLayoutBottomPaddingPx); } hotseat.setLayoutParams(lp); @@ -659,7 +679,7 @@ public class DeviceProfile { // Put the page indicators above the hotseat lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; lp.height = pageIndicatorSizePx; - lp.bottomMargin = hotseatBarHeightPx + mInsets.bottom; + lp.bottomMargin = hotseatBarSizePx + mInsets.bottom; } pageIndicator.setLayoutParams(lp); } -- cgit v1.2.3