diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml index c16792a2e4..7b2ed8bc65 100644 --- a/res/values-sw720dp/dimens.xml +++ b/res/values-sw720dp/dimens.xml @@ -31,6 +31,7 @@ 24dp 20dp 32dp + 32dp 110dp 48dp diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 766dca35c2..8403af46b7 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -241,6 +241,7 @@ 16dp 8dp 28dp + 0dp 30dp diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 3ddc90e7bd..95d94fa160 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -215,6 +215,7 @@ public class DeviceProfile { public int dropTargetHorizontalPaddingPx; public int dropTargetVerticalPaddingPx; public int dropTargetGapPx; + public int dropTargetButtonWorkspaceEdgeGapPx; // Insets private final Rect mInsets = new Rect(); @@ -342,6 +343,8 @@ public class DeviceProfile { dropTargetVerticalPaddingPx = res.getDimensionPixelSize( R.dimen.drop_target_button_drawable_vertical_padding); dropTargetGapPx = res.getDimensionPixelSize(R.dimen.drop_target_button_gap); + dropTargetButtonWorkspaceEdgeGapPx = res.getDimensionPixelSize( + R.dimen.drop_target_button_workspace_edge_gap); workspaceSpringLoadedBottomSpace = res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space); diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java index dbddb26651..d908440bc8 100644 --- a/src/com/android/launcher3/DropTargetBar.java +++ b/src/com/android/launcher3/DropTargetBar.java @@ -186,14 +186,13 @@ public class DropTargetBar extends FrameLayout availableWidth = scaledPanelWidth - halfButtonGap / 2; } else { // Both buttons plus the button gap do not display past the edge of the scaled - // workspace. - availableWidth = (scaledPanelWidth - dp.dropTargetGapPx) / 2; + // workspace, less a pre-defined gap from the edge of the workspace. + availableWidth = scaledPanelWidth - dp.dropTargetGapPx + - 2 * dp.dropTargetButtonWorkspaceEdgeGapPx; } int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); firstButton.measure(widthSpec, heightSpec); - secondButton.measure(widthSpec, heightSpec); - if (!mIsVertical) { // Remove icons and put the button's text on two lines if text is truncated. if (firstButton.isTextTruncated(availableWidth)) { @@ -202,6 +201,14 @@ public class DropTargetBar extends FrameLayout firstButton.setPadding(horizontalPadding, verticalPadding / 2, horizontalPadding, verticalPadding / 2); } + } + + if (!dp.isTwoPanels) { + availableWidth -= firstButton.getMeasuredWidth() + dp.dropTargetGapPx; + widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); + } + secondButton.measure(widthSpec, heightSpec); + if (!mIsVertical) { if (secondButton.isTextTruncated(availableWidth)) { secondButton.setIconVisible(false); secondButton.setTextMultiLine(true); @@ -243,13 +250,30 @@ public class DropTargetBar extends FrameLayout int buttonGap = dp.dropTargetGapPx; ButtonDropTarget leftButton = mTempTargets[0]; - leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0, - barCenter - (buttonGap / 2), leftButton.getMeasuredHeight()); - ButtonDropTarget rightButton = mTempTargets[1]; - rightButton.layout(barCenter + (buttonGap / 2), 0, - barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(), - rightButton.getMeasuredHeight()); + if (dp.isTwoPanels) { + leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0, + barCenter - (buttonGap / 2), leftButton.getMeasuredHeight()); + rightButton.layout(barCenter + (buttonGap / 2), 0, + barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(), + rightButton.getMeasuredHeight()); + } else { + int scaledPanelWidth = (int) (dp.getCellLayoutWidth() * scale); + + int leftButtonWidth = leftButton.getMeasuredWidth(); + int rightButtonWidth = rightButton.getMeasuredWidth(); + int extraSpace = scaledPanelWidth - leftButtonWidth - rightButtonWidth - buttonGap; + + int leftButtonStart = barCenter - (scaledPanelWidth / 2) + extraSpace / 2; + int leftButtonEnd = leftButtonStart + leftButtonWidth; + int rightButtonStart = leftButtonEnd + buttonGap; + int rightButtonEnd = rightButtonStart + rightButtonWidth; + + leftButton.layout(leftButtonStart, 0, leftButtonEnd, + leftButton.getMeasuredHeight()); + rightButton.layout(rightButtonStart, 0, rightButtonEnd, + rightButton.getMeasuredHeight()); + } } } @@ -318,7 +342,7 @@ public class DropTargetBar extends FrameLayout } public ButtonDropTarget[] getDropTargets() { - return mDropTargets; + return getVisibility() == View.VISIBLE ? mDropTargets : new ButtonDropTarget[0]; } @Override