Merge "Center drop target button alignment across devices" into tm-dev am: 179c289a6c am: 7ca1b38d7e am: 6329b20f43
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18580267 Change-Id: Id121a4eb31fda98107b3c622c907c105c288d0ef Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
ea9554cd21
4 files changed
+40
-11
No files matched your search
@@ -31,6 +31,7 @@
|
|||||||
<dimen name="drop_target_button_drawable_horizontal_padding">24dp</dimen>
|
<dimen name="drop_target_button_drawable_horizontal_padding">24dp</dimen>
|
||||||
<dimen name="drop_target_button_drawable_vertical_padding">20dp</dimen>
|
<dimen name="drop_target_button_drawable_vertical_padding">20dp</dimen>
|
||||||
<dimen name="drop_target_button_gap">32dp</dimen>
|
<dimen name="drop_target_button_gap">32dp</dimen>
|
||||||
|
<dimen name="drop_target_button_workspace_edge_gap">32dp</dimen>
|
||||||
<dimen name="drop_target_top_margin">110dp</dimen>
|
<dimen name="drop_target_top_margin">110dp</dimen>
|
||||||
<dimen name="drop_target_bottom_margin">48dp</dimen>
|
<dimen name="drop_target_bottom_margin">48dp</dimen>
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,7 @@
|
|||||||
<dimen name="drop_target_button_drawable_horizontal_padding">16dp</dimen>
|
<dimen name="drop_target_button_drawable_horizontal_padding">16dp</dimen>
|
||||||
<dimen name="drop_target_button_drawable_vertical_padding">8dp</dimen>
|
<dimen name="drop_target_button_drawable_vertical_padding">8dp</dimen>
|
||||||
<dimen name="drop_target_button_gap">28dp</dimen>
|
<dimen name="drop_target_button_gap">28dp</dimen>
|
||||||
|
<dimen name="drop_target_button_workspace_edge_gap">0dp</dimen>
|
||||||
|
|
||||||
<!-- the distance an icon must be dragged before button drop targets accept it -->
|
<!-- the distance an icon must be dragged before button drop targets accept it -->
|
||||||
<dimen name="drag_distanceThreshold">30dp</dimen>
|
<dimen name="drag_distanceThreshold">30dp</dimen>
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ public class DeviceProfile {
|
|||||||
public int dropTargetHorizontalPaddingPx;
|
public int dropTargetHorizontalPaddingPx;
|
||||||
public int dropTargetVerticalPaddingPx;
|
public int dropTargetVerticalPaddingPx;
|
||||||
public int dropTargetGapPx;
|
public int dropTargetGapPx;
|
||||||
|
public int dropTargetButtonWorkspaceEdgeGapPx;
|
||||||
|
|
||||||
// Insets
|
// Insets
|
||||||
private final Rect mInsets = new Rect();
|
private final Rect mInsets = new Rect();
|
||||||
@@ -348,6 +349,8 @@ public class DeviceProfile {
|
|||||||
dropTargetVerticalPaddingPx = res.getDimensionPixelSize(
|
dropTargetVerticalPaddingPx = res.getDimensionPixelSize(
|
||||||
R.dimen.drop_target_button_drawable_vertical_padding);
|
R.dimen.drop_target_button_drawable_vertical_padding);
|
||||||
dropTargetGapPx = res.getDimensionPixelSize(R.dimen.drop_target_button_gap);
|
dropTargetGapPx = res.getDimensionPixelSize(R.dimen.drop_target_button_gap);
|
||||||
|
dropTargetButtonWorkspaceEdgeGapPx = res.getDimensionPixelSize(
|
||||||
|
R.dimen.drop_target_button_workspace_edge_gap);
|
||||||
|
|
||||||
workspaceSpringLoadedBottomSpace =
|
workspaceSpringLoadedBottomSpace =
|
||||||
res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
|
res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
|
||||||
|
|||||||
@@ -186,14 +186,13 @@ public class DropTargetBar extends FrameLayout
|
|||||||
availableWidth = scaledPanelWidth - halfButtonGap / 2;
|
availableWidth = scaledPanelWidth - halfButtonGap / 2;
|
||||||
} else {
|
} else {
|
||||||
// Both buttons plus the button gap do not display past the edge of the scaled
|
// Both buttons plus the button gap do not display past the edge of the scaled
|
||||||
// workspace.
|
// workspace, less a pre-defined gap from the edge of the workspace.
|
||||||
availableWidth = (scaledPanelWidth - dp.dropTargetGapPx) / 2;
|
availableWidth = scaledPanelWidth - dp.dropTargetGapPx
|
||||||
|
- 2 * dp.dropTargetButtonWorkspaceEdgeGapPx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
|
int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
|
||||||
firstButton.measure(widthSpec, heightSpec);
|
firstButton.measure(widthSpec, heightSpec);
|
||||||
secondButton.measure(widthSpec, heightSpec);
|
|
||||||
|
|
||||||
if (!mIsVertical) {
|
if (!mIsVertical) {
|
||||||
// Remove icons and put the button's text on two lines if text is truncated.
|
// Remove icons and put the button's text on two lines if text is truncated.
|
||||||
if (firstButton.isTextTruncated(availableWidth)) {
|
if (firstButton.isTextTruncated(availableWidth)) {
|
||||||
@@ -202,6 +201,14 @@ public class DropTargetBar extends FrameLayout
|
|||||||
firstButton.setPadding(horizontalPadding, verticalPadding / 2,
|
firstButton.setPadding(horizontalPadding, verticalPadding / 2,
|
||||||
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)) {
|
if (secondButton.isTextTruncated(availableWidth)) {
|
||||||
secondButton.setIconVisible(false);
|
secondButton.setIconVisible(false);
|
||||||
secondButton.setTextMultiLine(true);
|
secondButton.setTextMultiLine(true);
|
||||||
@@ -243,13 +250,30 @@ public class DropTargetBar extends FrameLayout
|
|||||||
int buttonGap = dp.dropTargetGapPx;
|
int buttonGap = dp.dropTargetGapPx;
|
||||||
|
|
||||||
ButtonDropTarget leftButton = mTempTargets[0];
|
ButtonDropTarget leftButton = mTempTargets[0];
|
||||||
leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
|
|
||||||
barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
|
|
||||||
|
|
||||||
ButtonDropTarget rightButton = mTempTargets[1];
|
ButtonDropTarget rightButton = mTempTargets[1];
|
||||||
rightButton.layout(barCenter + (buttonGap / 2), 0,
|
if (dp.isTwoPanels) {
|
||||||
barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(),
|
leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
|
||||||
rightButton.getMeasuredHeight());
|
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() {
|
public ButtonDropTarget[] getDropTargets() {
|
||||||
return mDropTargets;
|
return getVisibility() == View.VISIBLE ? mDropTargets : new ButtonDropTarget[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user