Merge "Merge "Adjust edit state drop targets, workspace scaling, and margins per device type and orientation." into tm-dev am: 016dd3656d"
This commit is contained in:
committed by
Android (Google) Code Review
commit
64055c792a
@@ -17,6 +17,6 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<corners android:radius="28dp" />
|
||||
<corners android:radius="80dp" />
|
||||
<stroke android:width="2dp" android:color="?attr/workspaceAccentColor" />
|
||||
</shape>
|
||||
@@ -22,8 +22,22 @@
|
||||
<dimen name="fastscroll_popup_text_size">24dp</dimen>
|
||||
|
||||
<!-- Dynamic grid -->
|
||||
<dimen name="dynamic_grid_edge_margin">15.28dp</dimen>
|
||||
<dimen name="dynamic_grid_icon_drawable_padding">4dp</dimen>
|
||||
<dimen name="dynamic_grid_drop_target_size">36dp</dimen>
|
||||
<dimen name="cell_layout_padding">20dp</dimen>
|
||||
|
||||
<!-- Hotseat -->
|
||||
<dimen name="dynamic_grid_hotseat_side_padding">16dp</dimen>
|
||||
<dimen name="spring_loaded_hotseat_top_margin">45dp</dimen>
|
||||
|
||||
<!-- Dragging -->
|
||||
<dimen name="drop_target_button_gap">28dp</dimen>
|
||||
<dimen name="drop_target_button_drawable_horizontal_padding">16dp</dimen>
|
||||
<dimen name="drop_target_button_drawable_vertical_padding">2dp</dimen>
|
||||
<dimen name="drop_target_top_margin">6dp</dimen>
|
||||
<dimen name="drop_target_bottom_margin">6dp</dimen>
|
||||
|
||||
<!-- Workspace grid visualization parameters -->
|
||||
<dimen name="grid_visualization_horizontal_cell_spacing">24dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2022 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- Hotseat -->
|
||||
<dimen name="spring_loaded_hotseat_top_margin">44dp</dimen>
|
||||
|
||||
<!-- Dynamic grid -->
|
||||
<dimen name="dynamic_grid_edge_margin">11.33dp</dimen>
|
||||
<dimen name="cell_layout_padding">11.33dp</dimen>
|
||||
|
||||
<!-- Dragging -->
|
||||
<dimen name="drop_target_top_margin">0dp</dimen>
|
||||
<dimen name="drop_target_bottom_margin">16dp</dimen>
|
||||
</resources>
|
||||
@@ -32,8 +32,22 @@
|
||||
<dimen name="fastscroll_popup_text_size">32dp</dimen>
|
||||
|
||||
<!-- Dynamic grid -->
|
||||
<dimen name="dynamic_grid_edge_margin">9dp</dimen>
|
||||
<dimen name="dynamic_grid_icon_drawable_padding">7dp</dimen>
|
||||
<dimen name="cell_layout_padding">9dp</dimen>
|
||||
|
||||
|
||||
<!-- Hotseat -->
|
||||
<dimen name="dynamic_grid_hotseat_side_padding">0dp</dimen>
|
||||
<dimen name="spring_loaded_hotseat_top_margin">97dp</dimen>
|
||||
|
||||
<!-- Dragging -->
|
||||
<dimen name="drop_target_top_margin">34dp</dimen>
|
||||
<dimen name="drop_target_bottom_margin">16dp</dimen>
|
||||
<dimen name="drop_target_button_drawable_horizontal_padding">16dp</dimen>
|
||||
<dimen name="drop_target_button_drawable_vertical_padding">16dp</dimen>
|
||||
<dimen name="dynamic_grid_drop_target_size">56dp</dimen>
|
||||
|
||||
<!-- Workspace grid visualization parameters -->
|
||||
<dimen name="grid_visualization_horizontal_cell_spacing">6dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -15,9 +15,16 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- Widget picker-->
|
||||
<!-- Dragging-->
|
||||
<dimen name="drop_target_top_margin">0dp</dimen>
|
||||
<dimen name="drop_target_bottom_margin">32dp</dimen>
|
||||
<!-- Dynamic grid -->
|
||||
<dimen name="dynamic_grid_edge_margin">21.93dp</dimen>
|
||||
<dimen name="cell_layout_padding">29.33dp</dimen>
|
||||
<!-- Hotseat -->
|
||||
<dimen name="spring_loaded_hotseat_top_margin">64dp</dimen>
|
||||
<!-- Widget picker-->
|
||||
<dimen name="widget_list_horizontal_margin">49dp</dimen>
|
||||
|
||||
<!-- Bottom sheet-->
|
||||
<!-- Bottom sheet-->
|
||||
<dimen name="bottom_sheet_extra_top_padding">0dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -17,6 +17,19 @@
|
||||
<resources>
|
||||
<!-- AllApps -->
|
||||
<dimen name="all_apps_bottom_sheet_horizontal_padding">65dp</dimen>
|
||||
<!-- Dynamic grid -->
|
||||
<dimen name="dynamic_grid_edge_margin">27.59dp</dimen>
|
||||
<dimen name="cell_layout_padding">36dp</dimen>
|
||||
<!-- Dragging -->
|
||||
<dimen name="drop_target_text_size">20sp</dimen>
|
||||
<dimen name="dynamic_grid_drop_target_size">72dp</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_gap">32dp</dimen>
|
||||
<dimen name="drop_target_top_margin">32dp</dimen>
|
||||
<dimen name="drop_target_bottom_margin">32dp</dimen>
|
||||
<!-- Hotseat -->
|
||||
<dimen name="spring_loaded_hotseat_top_margin">164dp</dimen>
|
||||
|
||||
<!-- Widget picker-->
|
||||
<dimen name="widget_list_horizontal_margin">30dp</dimen>
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
<item type="id" name="drag_event_parity" />
|
||||
|
||||
<!-- AllApps & Launcher transitions -->
|
||||
<!-- Out of 100, the percent to shrink the workspace during spring loaded mode. -->
|
||||
<integer name="config_workspaceSpringLoadShrinkPercentage">85</integer>
|
||||
|
||||
<!-- The duration of the animation from search hint to text entry -->
|
||||
<integer name="config_searchHintAnimationDuration">50</integer>
|
||||
|
||||
|
||||
+12
-5
@@ -19,14 +19,14 @@
|
||||
<dimen name="click_shadow_elevation">4dp</dimen>
|
||||
|
||||
<!-- Dynamic Grid -->
|
||||
<dimen name="dynamic_grid_edge_margin">8dp</dimen>
|
||||
<dimen name="dynamic_grid_edge_margin">10.77dp</dimen>
|
||||
<dimen name="dynamic_grid_left_right_margin">8dp</dimen>
|
||||
<dimen name="dynamic_grid_icon_drawable_padding">7dp</dimen>
|
||||
<!-- Minimum space between workspace and hotseat in spring loaded mode -->
|
||||
<dimen name="dynamic_grid_min_spring_loaded_space">8dp</dimen>
|
||||
|
||||
<dimen name="dynamic_grid_cell_border_spacing">16dp</dimen>
|
||||
<dimen name="dynamic_grid_cell_layout_padding">5.5dp</dimen>
|
||||
<dimen name="cell_layout_padding">10.77dp</dimen>
|
||||
<dimen name="dynamic_grid_cell_padding_x">8dp</dimen>
|
||||
|
||||
<!-- Hotseat -->
|
||||
@@ -34,6 +34,7 @@
|
||||
<dimen name="dynamic_grid_hotseat_bottom_padding">2dp</dimen>
|
||||
<dimen name="dynamic_grid_hotseat_bottom_tall_padding">0dp</dimen>
|
||||
<dimen name="inline_qsb_bottom_margin">0dp</dimen>
|
||||
<dimen name="spring_loaded_hotseat_top_margin">76dp</dimen>
|
||||
|
||||
<!-- Qsb -->
|
||||
<!-- Used for adjusting the position of QSB when placed in hotseat. This is a ratio and a higher
|
||||
@@ -55,8 +56,10 @@
|
||||
<dimen name="workspace_page_indicator_overlap_workspace">0dp</dimen>
|
||||
|
||||
<!-- Drop target bar -->
|
||||
<dimen name="dynamic_grid_drop_target_size">52dp</dimen>
|
||||
<dimen name="dynamic_grid_drop_target_size">56dp</dimen>
|
||||
<dimen name="drop_target_vertical_gap">20dp</dimen>
|
||||
<dimen name="drop_target_top_margin">36dp</dimen>
|
||||
<dimen name="drop_target_bottom_margin">16dp</dimen>
|
||||
|
||||
<!-- App Widget resize frame -->
|
||||
<dimen name="widget_handle_margin">13dp</dimen>
|
||||
@@ -206,6 +209,9 @@
|
||||
<dimen name="drop_target_shadow_elevation">2dp</dimen>
|
||||
<dimen name="drop_target_bar_margin_horizontal">4dp</dimen>
|
||||
<dimen name="drop_target_button_drawable_padding">8dp</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_gap">22dp</dimen>
|
||||
|
||||
<!-- the distance an icon must be dragged before button drop targets accept it -->
|
||||
<dimen name="drag_distanceThreshold">30dp</dimen>
|
||||
@@ -358,8 +364,9 @@
|
||||
|
||||
|
||||
<!-- Workspace grid visualization parameters -->
|
||||
<dimen name="grid_visualization_rounding_radius">22dp</dimen>
|
||||
<dimen name="grid_visualization_cell_spacing">6dp</dimen>
|
||||
<dimen name="grid_visualization_rounding_radius">28dp</dimen>
|
||||
<dimen name="grid_visualization_horizontal_cell_spacing">6dp</dimen>
|
||||
<dimen name="grid_visualization_vertical_cell_spacing">6dp</dimen>
|
||||
|
||||
<!-- Search results related parameters -->
|
||||
<dimen name="search_row_icon_size">48dp</dimen>
|
||||
|
||||
@@ -148,7 +148,8 @@ public class CellLayout extends ViewGroup {
|
||||
private boolean mVisualizeDropLocation = true;
|
||||
private RectF mVisualizeGridRect = new RectF();
|
||||
private Paint mVisualizeGridPaint = new Paint();
|
||||
private int mGridVisualizationPadding;
|
||||
private int mGridVisualizationPaddingX;
|
||||
private int mGridVisualizationPaddingY;
|
||||
private int mGridVisualizationRoundingRadius;
|
||||
private float mGridAlpha = 0f;
|
||||
private int mGridColor = 0;
|
||||
@@ -275,8 +276,10 @@ public class CellLayout extends ViewGroup {
|
||||
mBackground.setAlpha(0);
|
||||
|
||||
mGridColor = Themes.getAttrColor(getContext(), R.attr.workspaceAccentColor);
|
||||
mGridVisualizationPadding =
|
||||
res.getDimensionPixelSize(R.dimen.grid_visualization_cell_spacing);
|
||||
mGridVisualizationPaddingX = res.getDimensionPixelSize(
|
||||
R.dimen.grid_visualization_horizontal_cell_spacing);
|
||||
mGridVisualizationPaddingY = res.getDimensionPixelSize(
|
||||
R.dimen.grid_visualization_vertical_cell_spacing);
|
||||
mGridVisualizationRoundingRadius =
|
||||
res.getDimensionPixelSize(R.dimen.grid_visualization_rounding_radius);
|
||||
mReorderPreviewAnimationMagnitude = (REORDER_PREVIEW_MAGNITUDE * deviceProfile.iconSizePx);
|
||||
@@ -573,8 +576,8 @@ public class CellLayout extends ViewGroup {
|
||||
|
||||
protected void visualizeGrid(Canvas canvas) {
|
||||
DeviceProfile dp = mActivity.getDeviceProfile();
|
||||
int paddingX = (int) Math.min((mCellWidth - dp.iconSizePx) / 2, mGridVisualizationPadding);
|
||||
int paddingY = (int) Math.min((mCellHeight - dp.iconSizePx) / 2, mGridVisualizationPadding);
|
||||
int paddingX = Math.min((mCellWidth - dp.iconSizePx) / 2, mGridVisualizationPaddingX);
|
||||
int paddingY = Math.min((mCellHeight - dp.iconSizePx) / 2, mGridVisualizationPaddingY);
|
||||
mVisualizeGridRect.set(paddingX, paddingY,
|
||||
mCellWidth - paddingX,
|
||||
mCellHeight - paddingY);
|
||||
|
||||
@@ -94,18 +94,16 @@ public class DeviceProfile {
|
||||
private static final float TALL_DEVICE_EXTRA_SPACE_THRESHOLD_DP = 252;
|
||||
private static final float TALL_DEVICE_MORE_EXTRA_SPACE_THRESHOLD_DP = 268;
|
||||
|
||||
// To evenly space the icons, increase the left/right margins for tablets in portrait mode.
|
||||
private static final int PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER = 4;
|
||||
|
||||
// Workspace
|
||||
public final int desiredWorkspaceHorizontalMarginOriginalPx;
|
||||
public int desiredWorkspaceHorizontalMarginPx;
|
||||
public Point cellLayoutBorderSpaceOriginalPx;
|
||||
public Point cellLayoutBorderSpacePx;
|
||||
public final int cellLayoutPaddingLeftRightPx;
|
||||
public final int cellLayoutBottomPaddingPx;
|
||||
public Rect cellLayoutPaddingPx = new Rect();
|
||||
|
||||
public final int edgeMarginPx;
|
||||
public float workspaceSpringLoadShrinkFactor;
|
||||
public float workspaceSpringLoadShrunkTop;
|
||||
public float workspaceSpringLoadShrunkBottom;
|
||||
public final int workspaceSpringLoadedBottomSpace;
|
||||
|
||||
private final int extraSpace;
|
||||
@@ -161,6 +159,7 @@ public class DeviceProfile {
|
||||
public int hotseatBarSizePx;
|
||||
public int hotseatBarTopPaddingPx;
|
||||
public final int hotseatBarBottomPaddingPx;
|
||||
public int springLoadedHotseatBarTopMarginPx;
|
||||
// Start is the side next to the nav bar, end is the side next to the workspace
|
||||
public final int hotseatBarSidePaddingStartPx;
|
||||
public final int hotseatBarSidePaddingEndPx;
|
||||
@@ -206,8 +205,13 @@ public class DeviceProfile {
|
||||
|
||||
// Drop Target
|
||||
public int dropTargetBarSizePx;
|
||||
public int dropTargetBarTopMarginPx;
|
||||
public int dropTargetBarBottomMarginPx;
|
||||
public int dropTargetDragPaddingPx;
|
||||
public int dropTargetTextSizePx;
|
||||
public int dropTargetHorizontalPaddingPx;
|
||||
public int dropTargetVerticalPaddingPx;
|
||||
public int dropTargetGapPx;
|
||||
|
||||
// Insets
|
||||
private final Rect mInsets = new Rect();
|
||||
@@ -319,23 +323,6 @@ public class DeviceProfile {
|
||||
folderCellLayoutBorderSpacePx = new Point(folderCellLayoutBorderSpaceOriginalPx,
|
||||
folderCellLayoutBorderSpaceOriginalPx);
|
||||
|
||||
int cellLayoutPaddingLeftRightMultiplier = !isVerticalBarLayout() && isTablet
|
||||
? PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER : 1;
|
||||
int cellLayoutPadding = isScalableGrid
|
||||
? 0
|
||||
: res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_padding);
|
||||
|
||||
if (isTwoPanels) {
|
||||
cellLayoutPaddingLeftRightPx = 0;
|
||||
cellLayoutBottomPaddingPx = 0;
|
||||
} else if (isLandscape) {
|
||||
cellLayoutPaddingLeftRightPx = 0;
|
||||
cellLayoutBottomPaddingPx = cellLayoutPadding;
|
||||
} else {
|
||||
cellLayoutPaddingLeftRightPx = cellLayoutPaddingLeftRightMultiplier * cellLayoutPadding;
|
||||
cellLayoutBottomPaddingPx = 0;
|
||||
}
|
||||
|
||||
workspacePageIndicatorHeight = res.getDimensionPixelSize(
|
||||
R.dimen.workspace_page_indicator_height);
|
||||
mWorkspacePageIndicatorOverlapWorkspace =
|
||||
@@ -345,8 +332,15 @@ public class DeviceProfile {
|
||||
res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
|
||||
|
||||
dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size);
|
||||
dropTargetBarTopMarginPx = res.getDimensionPixelSize(R.dimen.drop_target_top_margin);
|
||||
dropTargetBarBottomMarginPx = res.getDimensionPixelSize(R.dimen.drop_target_bottom_margin);
|
||||
dropTargetDragPaddingPx = res.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
|
||||
dropTargetTextSizePx = res.getDimensionPixelSize(R.dimen.drop_target_text_size);
|
||||
dropTargetHorizontalPaddingPx = res.getDimensionPixelSize(
|
||||
R.dimen.drop_target_button_drawable_horizontal_padding);
|
||||
dropTargetVerticalPaddingPx = res.getDimensionPixelSize(
|
||||
R.dimen.drop_target_button_drawable_vertical_padding);
|
||||
dropTargetGapPx = res.getDimensionPixelSize(R.dimen.drop_target_button_gap);
|
||||
|
||||
workspaceSpringLoadedBottomSpace =
|
||||
res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
|
||||
@@ -384,6 +378,8 @@ public class DeviceProfile {
|
||||
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
|
||||
qsbWidth = 0;
|
||||
}
|
||||
springLoadedHotseatBarTopMarginPx = res.getDimensionPixelSize(
|
||||
R.dimen.spring_loaded_hotseat_top_margin);
|
||||
hotseatBarSidePaddingEndPx =
|
||||
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
|
||||
// Add a bit of space between nav bar and hotseat in vertical bar layout.
|
||||
@@ -477,6 +473,12 @@ public class DeviceProfile {
|
||||
// Recalculate the available dimensions using the new hotseat size.
|
||||
updateAvailableDimensions(res);
|
||||
}
|
||||
|
||||
int cellLayoutPadding =
|
||||
isTwoPanels ? cellLayoutBorderSpacePx.x / 2 : res.getDimensionPixelSize(
|
||||
R.dimen.cell_layout_padding);
|
||||
cellLayoutPaddingPx = new Rect(cellLayoutPadding, cellLayoutPadding, cellLayoutPadding,
|
||||
cellLayoutPadding);
|
||||
updateWorkspacePadding();
|
||||
|
||||
flingToDeleteThresholdVelocity = res.getDimensionPixelSize(
|
||||
@@ -589,7 +591,6 @@ public class DeviceProfile {
|
||||
float appWidgetScaleX = (float) profile.getCellSize().x / getCellSize().x;
|
||||
float appWidgetScaleY = (float) profile.getCellSize().y / getCellSize().y;
|
||||
profile.appWidgetScale.set(appWidgetScaleX, appWidgetScaleY);
|
||||
profile.updateWorkspacePadding();
|
||||
|
||||
return profile;
|
||||
}
|
||||
@@ -624,18 +625,18 @@ public class DeviceProfile {
|
||||
}
|
||||
|
||||
private void updateAllAppsWidth(Resources res) {
|
||||
|
||||
int cellLayoutHorizontalPadding =
|
||||
(cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2;
|
||||
if (isTablet) {
|
||||
allAppsLeftRightPadding =
|
||||
res.getDimensionPixelSize(R.dimen.all_apps_bottom_sheet_horizontal_padding)
|
||||
+ cellLayoutPaddingLeftRightPx;
|
||||
allAppsLeftRightPadding = res.getDimensionPixelSize(
|
||||
R.dimen.all_apps_bottom_sheet_horizontal_padding) + cellLayoutHorizontalPadding;
|
||||
int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
|
||||
+ (allAppsBorderSpacePx.x * (numShownAllAppsColumns + 1))
|
||||
+ allAppsLeftRightPadding * 2;
|
||||
allAppsLeftRightMargin = Math.max(1, (availableWidthPx - usedWidth) / 2);
|
||||
} else {
|
||||
allAppsLeftRightPadding =
|
||||
desiredWorkspaceHorizontalMarginPx + cellLayoutPaddingLeftRightPx;
|
||||
desiredWorkspaceHorizontalMarginPx + cellLayoutHorizontalPadding;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,11 +646,12 @@ public class DeviceProfile {
|
||||
private int updateAvailableDimensions(Resources res) {
|
||||
updateIconSize(1f, res);
|
||||
|
||||
updateWorkspacePadding();
|
||||
Point workspacePadding = getTotalWorkspacePadding();
|
||||
|
||||
// Check to see if the icons fit within the available height.
|
||||
float usedHeight = getCellLayoutHeight();
|
||||
final int maxHeight = availableHeightPx - workspacePadding.y;
|
||||
final int maxHeight = getWorkspaceHeight(workspacePadding);
|
||||
float extraHeight = Math.max(0, maxHeight - usedHeight);
|
||||
float scaleY = maxHeight / usedHeight;
|
||||
boolean shouldScale = scaleY < 1f;
|
||||
@@ -659,10 +661,7 @@ public class DeviceProfile {
|
||||
// We scale to fit the cellWidth and cellHeight in the available space.
|
||||
// The benefit of scalable grids is that we can get consistent aspect ratios between
|
||||
// devices.
|
||||
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
|
||||
float usedWidth = (cellWidthPx * numColumns)
|
||||
+ (cellLayoutBorderSpacePx.x * (numColumns - 1))
|
||||
+ (desiredWorkspaceHorizontalMarginPx * 2);
|
||||
float usedWidth = getCellLayoutWidth() + (desiredWorkspaceHorizontalMarginPx * 2);
|
||||
// We do not subtract padding here, as we also scale the workspace padding if needed.
|
||||
scaleX = availableWidthPx / usedWidth;
|
||||
shouldScale = true;
|
||||
@@ -679,7 +678,14 @@ public class DeviceProfile {
|
||||
}
|
||||
|
||||
private int getCellLayoutHeight() {
|
||||
return (cellHeightPx * inv.numRows) + (cellLayoutBorderSpacePx.y * (inv.numRows - 1));
|
||||
return (cellHeightPx * inv.numRows) + (cellLayoutBorderSpacePx.y * (inv.numRows - 1))
|
||||
+ cellLayoutPaddingPx.top + cellLayoutPaddingPx.bottom;
|
||||
}
|
||||
|
||||
private int getCellLayoutWidth() {
|
||||
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
|
||||
return (cellWidthPx * numColumns) + (cellLayoutBorderSpacePx.x * (numColumns - 1))
|
||||
+ cellLayoutPaddingPx.left + cellLayoutPaddingPx.right;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -739,18 +745,6 @@ public class DeviceProfile {
|
||||
}
|
||||
updateHotseatIconSize(iconSizePx);
|
||||
|
||||
if (!isVerticalLayout) {
|
||||
int expectedWorkspaceHeight = availableHeightPx - hotseatBarSizePx
|
||||
- workspacePageIndicatorHeight - edgeMarginPx;
|
||||
float minRequiredHeight = dropTargetBarSizePx + workspaceSpringLoadedBottomSpace;
|
||||
workspaceSpringLoadShrinkFactor = Math.min(
|
||||
res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f,
|
||||
1 - (minRequiredHeight / expectedWorkspaceHeight));
|
||||
} else {
|
||||
workspaceSpringLoadShrinkFactor =
|
||||
res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
|
||||
}
|
||||
|
||||
// Folder icon
|
||||
folderIconSizePx = IconNormalizer.getNormalizedCircleSize(iconSizePx);
|
||||
folderIconOffsetYPx = (iconSizePx - folderIconSizePx) / 2;
|
||||
@@ -851,7 +845,6 @@ public class DeviceProfile {
|
||||
|
||||
public void updateInsets(Rect insets) {
|
||||
mInsets.set(insets);
|
||||
updateWorkspacePadding();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -878,23 +871,62 @@ public class DeviceProfile {
|
||||
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
|
||||
int screenWidthPx = getWorkspaceWidth(padding);
|
||||
result.x = calculateCellWidth(screenWidthPx, cellLayoutBorderSpacePx.x, numColumns);
|
||||
result.y = calculateCellHeight(availableHeightPx - padding.y
|
||||
- cellLayoutBottomPaddingPx, cellLayoutBorderSpacePx.y, inv.numRows);
|
||||
int screenHeightPx = getWorkspaceHeight(padding);
|
||||
result.y = calculateCellHeight(screenHeightPx, cellLayoutBorderSpacePx.y, inv.numRows);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the space in px from the bottom of last item in the vertical-bar hotseat to the
|
||||
* bottom of the screen.
|
||||
*/
|
||||
public int getVerticalHotseatLastItemBottomOffset() {
|
||||
int cellHeight = calculateCellHeight(
|
||||
heightPx - mHotseatPadding.top - mHotseatPadding.bottom, hotseatBorderSpace,
|
||||
numShownHotseatIcons);
|
||||
int hotseatSize = (cellHeight * numShownHotseatIcons)
|
||||
+ (hotseatBorderSpace * (numShownHotseatIcons - 1));
|
||||
int extraHotseatEndSpacing = (heightPx - hotseatSize) / 2;
|
||||
int extraIconEndSpacing = (cellHeight - iconSizePx) / 2;
|
||||
return extraHotseatEndSpacing + extraIconEndSpacing + mHotseatPadding.bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scaled top of the workspace in px for the spring-loaded edit state.
|
||||
*/
|
||||
public float getWorkspaceSpringLoadShrunkTop() {
|
||||
workspaceSpringLoadShrunkTop = mInsets.top + dropTargetBarTopMarginPx + dropTargetBarSizePx
|
||||
+ dropTargetBarBottomMarginPx;
|
||||
return workspaceSpringLoadShrunkTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scaled bottom of the workspace in px for the spring-loaded edit state.
|
||||
*/
|
||||
public float getWorkspaceSpringLoadShrunkBottom() {
|
||||
int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx;
|
||||
workspaceSpringLoadShrunkBottom =
|
||||
heightPx - (isVerticalBarLayout() ? getVerticalHotseatLastItemBottomOffset()
|
||||
: topOfHotseat);
|
||||
return workspaceSpringLoadShrunkBottom;
|
||||
}
|
||||
|
||||
public int getWorkspaceWidth() {
|
||||
return getWorkspaceWidth(getTotalWorkspacePadding());
|
||||
}
|
||||
|
||||
public int getWorkspaceWidth(Point workspacePadding) {
|
||||
int cellLayoutTotalPadding =
|
||||
isTwoPanels ? 4 * cellLayoutPaddingLeftRightPx : 2 * cellLayoutPaddingLeftRightPx;
|
||||
(isTwoPanels ? 2 : 1) * (cellLayoutPaddingPx.left + cellLayoutPaddingPx.right);
|
||||
return availableWidthPx - workspacePadding.x - cellLayoutTotalPadding;
|
||||
}
|
||||
|
||||
private int getWorkspaceHeight(Point workspacePadding) {
|
||||
return availableHeightPx - workspacePadding.y - (cellLayoutPaddingPx.top
|
||||
+ cellLayoutPaddingPx.bottom);
|
||||
}
|
||||
|
||||
public Point getTotalWorkspacePadding() {
|
||||
updateWorkspacePadding();
|
||||
return new Point(workspacePadding.left + workspacePadding.right,
|
||||
workspacePadding.top + workspacePadding.bottom);
|
||||
}
|
||||
@@ -920,12 +952,26 @@ public class DeviceProfile {
|
||||
int hotseatTop = hotseatBarSizePx;
|
||||
int paddingBottom = hotseatTop + workspacePageIndicatorHeight
|
||||
+ workspaceBottomPadding - mWorkspacePageIndicatorOverlapWorkspace;
|
||||
int paddingTop = workspaceTopPadding + (isScalableGrid ? 0 : edgeMarginPx);
|
||||
int paddingSide = desiredWorkspaceHorizontalMarginPx;
|
||||
|
||||
padding.set(desiredWorkspaceHorizontalMarginPx,
|
||||
workspaceTopPadding + (isScalableGrid ? 0 : edgeMarginPx),
|
||||
desiredWorkspaceHorizontalMarginPx,
|
||||
paddingBottom);
|
||||
padding.set(paddingSide, paddingTop, paddingSide, paddingBottom);
|
||||
}
|
||||
insetPadding(workspacePadding, cellLayoutPaddingPx);
|
||||
}
|
||||
|
||||
private void insetPadding(Rect paddings, Rect insets) {
|
||||
insets.left = Math.min(insets.left, paddings.left);
|
||||
paddings.left -= insets.left;
|
||||
|
||||
insets.top = Math.min(insets.top, paddings.top);
|
||||
paddings.top -= insets.top;
|
||||
|
||||
insets.right = Math.min(insets.right, paddings.right);
|
||||
paddings.right -= insets.right;
|
||||
|
||||
insets.bottom = Math.min(insets.bottom, paddings.bottom);
|
||||
paddings.bottom -= insets.bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -933,12 +979,14 @@ public class DeviceProfile {
|
||||
*/
|
||||
public Rect getHotseatLayoutPadding(Context context) {
|
||||
if (isVerticalBarLayout()) {
|
||||
int paddingTop = Math.max(mInsets.top - cellLayoutPaddingPx.top, 0);
|
||||
int paddingBottom = Math.max(mInsets.bottom - cellLayoutPaddingPx.bottom, 0);
|
||||
if (isSeascape()) {
|
||||
mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx,
|
||||
mInsets.top, hotseatBarSidePaddingEndPx, mInsets.bottom);
|
||||
mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx, paddingTop,
|
||||
hotseatBarSidePaddingEndPx, paddingBottom);
|
||||
} else {
|
||||
mHotseatPadding.set(hotseatBarSidePaddingEndPx, mInsets.top,
|
||||
mInsets.right + hotseatBarSidePaddingStartPx, mInsets.bottom);
|
||||
mHotseatPadding.set(hotseatBarSidePaddingEndPx, paddingTop,
|
||||
mInsets.right + hotseatBarSidePaddingStartPx, paddingBottom);
|
||||
}
|
||||
} else if (isTaskbarPresent) {
|
||||
int hotseatHeight = workspacePadding.bottom;
|
||||
@@ -977,14 +1025,12 @@ public class DeviceProfile {
|
||||
float workspaceCellWidth = (float) widthPx / inv.numColumns;
|
||||
float hotseatCellWidth = (float) widthPx / numShownHotseatIcons;
|
||||
int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
|
||||
mHotseatPadding.set(
|
||||
hotseatAdjustment + workspacePadding.left + cellLayoutPaddingLeftRightPx
|
||||
+ mInsets.left,
|
||||
hotseatBarTopPaddingPx,
|
||||
hotseatAdjustment + workspacePadding.right + cellLayoutPaddingLeftRightPx
|
||||
mHotseatPadding.set(hotseatAdjustment + workspacePadding.left + cellLayoutPaddingPx.left
|
||||
+ mInsets.left, hotseatBarTopPaddingPx,
|
||||
hotseatAdjustment + workspacePadding.right + cellLayoutPaddingPx.right
|
||||
+ mInsets.right,
|
||||
hotseatBarSizePx - hotseatCellHeightPx - hotseatBarTopPaddingPx
|
||||
+ cellLayoutBottomPaddingPx + mInsets.bottom);
|
||||
+ mInsets.bottom);
|
||||
}
|
||||
return mHotseatPadding;
|
||||
}
|
||||
@@ -1068,6 +1114,8 @@ public class DeviceProfile {
|
||||
.getInfo().rotation == Surface.ROTATION_270;
|
||||
if (mIsSeascape != isSeascape) {
|
||||
mIsSeascape = isSeascape;
|
||||
// Hotseat changing sides requires updating workspace left/right paddings
|
||||
updateWorkspacePadding();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1146,6 +1194,11 @@ public class DeviceProfile {
|
||||
cellLayoutBorderSpacePx.x));
|
||||
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Vertical",
|
||||
cellLayoutBorderSpacePx.y));
|
||||
writer.println(prefix + pxToDpStr("cellLayoutPaddingPx.left", cellLayoutPaddingPx.left));
|
||||
writer.println(prefix + pxToDpStr("cellLayoutPaddingPx.top", cellLayoutPaddingPx.top));
|
||||
writer.println(prefix + pxToDpStr("cellLayoutPaddingPx.right", cellLayoutPaddingPx.right));
|
||||
writer.println(
|
||||
prefix + pxToDpStr("cellLayoutPaddingPx.bottom", cellLayoutPaddingPx.bottom));
|
||||
|
||||
writer.println(prefix + pxToDpStr("iconSizePx", iconSizePx));
|
||||
writer.println(prefix + pxToDpStr("iconTextSizePx", iconTextSizePx));
|
||||
@@ -1182,6 +1235,12 @@ public class DeviceProfile {
|
||||
hotseatBarSidePaddingStartPx));
|
||||
writer.println(prefix + pxToDpStr("hotseatBarSidePaddingEndPx",
|
||||
hotseatBarSidePaddingEndPx));
|
||||
writer.println(prefix + pxToDpStr("springLoadedHotseatBarTopMarginPx",
|
||||
springLoadedHotseatBarTopMarginPx));
|
||||
writer.println(prefix + pxToDpStr("mHotseatPadding.top", mHotseatPadding.top));
|
||||
writer.println(prefix + pxToDpStr("mHotseatPadding.bottom", mHotseatPadding.bottom));
|
||||
writer.println(prefix + pxToDpStr("mHotseatPadding.left", mHotseatPadding.left));
|
||||
writer.println(prefix + pxToDpStr("mHotseatPadding.right", mHotseatPadding.right));
|
||||
writer.println(prefix + "\tnumShownHotseatIcons: " + numShownHotseatIcons);
|
||||
writer.println(prefix + pxToDpStr("hotseatBorderSpace", hotseatBorderSpace));
|
||||
writer.println(prefix + "\tisQsbInline: " + isQsbInline);
|
||||
@@ -1232,6 +1291,16 @@ public class DeviceProfile {
|
||||
writer.println(prefix + pxToDpStr("overviewPageSpacing", overviewPageSpacing));
|
||||
writer.println(prefix + pxToDpStr("overviewRowSpacing", overviewRowSpacing));
|
||||
writer.println(prefix + pxToDpStr("overviewGridSideMargin", overviewGridSideMargin));
|
||||
|
||||
writer.println(prefix + pxToDpStr("dropTargetBarTopMarginPx", dropTargetBarTopMarginPx));
|
||||
writer.println(prefix + pxToDpStr("dropTargetBarSizePx", dropTargetBarSizePx));
|
||||
writer.println(
|
||||
prefix + pxToDpStr("dropTargetBarBottomMarginPx", dropTargetBarBottomMarginPx));
|
||||
|
||||
writer.println(
|
||||
prefix + pxToDpStr("workspaceSpringLoadShrunkTop", workspaceSpringLoadShrunkTop));
|
||||
writer.println(prefix + pxToDpStr("workspaceSpringLoadShrunkBottom",
|
||||
workspaceSpringLoadShrunkBottom));
|
||||
}
|
||||
|
||||
private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) {
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.ButtonDropTarget.TOOLTIP_DEFAULT;
|
||||
import static com.android.launcher3.ButtonDropTarget.TOOLTIP_LEFT;
|
||||
import static com.android.launcher3.ButtonDropTarget.TOOLTIP_RIGHT;
|
||||
import static com.android.launcher3.anim.AlphaUpdateListener.updateVisibility;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
@@ -41,6 +39,8 @@ import com.android.launcher3.dragndrop.DragController.DragListener;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* The top bar containing various drop targets: Delete/App Info/Uninstall.
|
||||
*/
|
||||
@@ -94,30 +94,28 @@ public class DropTargetBar extends FrameLayout
|
||||
lp.rightMargin = insets.right;
|
||||
int tooltipLocation = TOOLTIP_DEFAULT;
|
||||
|
||||
if (grid.isVerticalBarLayout()) {
|
||||
lp.width = grid.dropTargetBarSizePx;
|
||||
lp.height = grid.availableHeightPx - 2 * grid.edgeMarginPx;
|
||||
lp.gravity = grid.isSeascape() ? Gravity.RIGHT : Gravity.LEFT;
|
||||
tooltipLocation = grid.isSeascape() ? TOOLTIP_LEFT : TOOLTIP_RIGHT;
|
||||
int horizontalMargin;
|
||||
if (grid.isTablet) {
|
||||
// XXX: If the icon size changes across orientations, we will have to take
|
||||
// that into account here too.
|
||||
horizontalMargin = ((grid.widthPx - 2 * grid.edgeMarginPx
|
||||
- (grid.inv.numColumns * grid.cellWidthPx))
|
||||
/ (2 * (grid.inv.numColumns + 1)))
|
||||
+ grid.edgeMarginPx;
|
||||
} else {
|
||||
int gap;
|
||||
if (grid.isTablet) {
|
||||
// XXX: If the icon size changes across orientations, we will have to take
|
||||
// that into account here too.
|
||||
gap = ((grid.widthPx - 2 * grid.edgeMarginPx
|
||||
- (grid.inv.numColumns * grid.cellWidthPx))
|
||||
/ (2 * (grid.inv.numColumns + 1)))
|
||||
+ grid.edgeMarginPx;
|
||||
} else {
|
||||
gap = getContext().getResources()
|
||||
.getDimensionPixelSize(R.dimen.drop_target_bar_margin_horizontal);
|
||||
}
|
||||
lp.width = grid.availableWidthPx - 2 * gap;
|
||||
|
||||
lp.topMargin += grid.edgeMarginPx;
|
||||
lp.height = grid.dropTargetBarSizePx;
|
||||
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
|
||||
horizontalMargin = getContext().getResources()
|
||||
.getDimensionPixelSize(R.dimen.drop_target_bar_margin_horizontal);
|
||||
}
|
||||
lp.topMargin += grid.dropTargetBarTopMarginPx;
|
||||
lp.bottomMargin += grid.dropTargetBarBottomMarginPx;
|
||||
lp.width = grid.availableWidthPx - 2 * horizontalMargin;
|
||||
if (mIsVertical) {
|
||||
lp.leftMargin = (grid.widthPx - lp.width) / 2;
|
||||
lp.rightMargin = (grid.widthPx - lp.width) / 2;
|
||||
}
|
||||
lp.height = grid.dropTargetBarSizePx;
|
||||
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
|
||||
|
||||
setLayoutParams(lp);
|
||||
for (ButtonDropTarget button : mDropTargets) {
|
||||
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.dropTargetTextSizePx);
|
||||
@@ -139,19 +137,7 @@ public class DropTargetBar extends FrameLayout
|
||||
int height = MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
int visibleCount = getVisibleButtonsCount();
|
||||
if (visibleCount == 0) {
|
||||
// do nothing
|
||||
} else if (mIsVertical) {
|
||||
int widthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
|
||||
int heightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
|
||||
|
||||
for (ButtonDropTarget button : mDropTargets) {
|
||||
if (button.getVisibility() != GONE) {
|
||||
button.setTextVisible(false);
|
||||
button.measure(widthSpec, heightSpec);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (visibleCount > 0) {
|
||||
int availableWidth = width / visibleCount;
|
||||
boolean textVisible = true;
|
||||
for (ButtonDropTarget buttons : mDropTargets) {
|
||||
@@ -176,31 +162,91 @@ public class DropTargetBar extends FrameLayout
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
int visibleCount = getVisibleButtonsCount();
|
||||
if (visibleCount == 0) {
|
||||
// do nothing
|
||||
} else if (mIsVertical) {
|
||||
int gap = getResources().getDimensionPixelSize(R.dimen.drop_target_vertical_gap);
|
||||
int start = gap;
|
||||
int end;
|
||||
return;
|
||||
}
|
||||
|
||||
for (ButtonDropTarget button : mDropTargets) {
|
||||
if (button.getVisibility() != GONE) {
|
||||
end = start + button.getMeasuredHeight();
|
||||
button.layout(0, start, button.getMeasuredWidth(), end);
|
||||
start = end + gap;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int frameSize = (right - left) / visibleCount;
|
||||
Launcher launcher = Launcher.getLauncher(getContext());
|
||||
Workspace workspace = launcher.getWorkspace();
|
||||
DeviceProfile dp = launcher.getDeviceProfile();
|
||||
int buttonHorizontalPadding = dp.dropTargetHorizontalPaddingPx;
|
||||
int buttonVerticalPadding = dp.dropTargetVerticalPaddingPx;
|
||||
int barCenter = (right - left) / 2;
|
||||
|
||||
int start = frameSize / 2;
|
||||
int halfWidth;
|
||||
for (ButtonDropTarget button : mDropTargets) {
|
||||
if (button.getVisibility() != GONE) {
|
||||
halfWidth = button.getMeasuredWidth() / 2;
|
||||
button.layout(start - halfWidth, 0,
|
||||
start + halfWidth, button.getMeasuredHeight());
|
||||
start = start + frameSize;
|
||||
ButtonDropTarget[] visibleButtons = Arrays.stream(mDropTargets)
|
||||
.filter(b -> b.getVisibility() != GONE)
|
||||
.toArray(ButtonDropTarget[]::new);
|
||||
Arrays.stream(visibleButtons).forEach(
|
||||
b -> b.setPadding(buttonHorizontalPadding, buttonVerticalPadding,
|
||||
buttonHorizontalPadding, buttonVerticalPadding));
|
||||
|
||||
if (visibleCount == 1) {
|
||||
ButtonDropTarget button = visibleButtons[0];
|
||||
button.layout(barCenter - (button.getMeasuredWidth() / 2), 0,
|
||||
barCenter + (button.getMeasuredWidth() / 2), button.getMeasuredHeight());
|
||||
} else if (visibleCount == 2) {
|
||||
int buttonGap = dp.dropTargetGapPx;
|
||||
|
||||
if (dp.isTwoPanels) {
|
||||
ButtonDropTarget leftButton = visibleButtons[0];
|
||||
leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
|
||||
barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
|
||||
|
||||
ButtonDropTarget rightButton = visibleButtons[1];
|
||||
rightButton.layout(barCenter + (buttonGap / 2), 0,
|
||||
barCenter + rightButton.getMeasuredWidth() + (buttonGap / 2),
|
||||
rightButton.getMeasuredHeight());
|
||||
} else if (dp.isTablet) {
|
||||
int numberOfMargins = visibleCount - 1;
|
||||
int buttonWidths = Arrays.stream(mDropTargets)
|
||||
.filter(b -> b.getVisibility() != GONE)
|
||||
.mapToInt(ButtonDropTarget::getMeasuredWidth)
|
||||
.sum();
|
||||
int totalWidth = buttonWidths + (numberOfMargins * buttonGap);
|
||||
int buttonsStartMargin = barCenter - (totalWidth / 2);
|
||||
|
||||
int start = buttonsStartMargin;
|
||||
for (ButtonDropTarget button : visibleButtons) {
|
||||
int margin = (start != buttonsStartMargin) ? buttonGap : 0;
|
||||
button.layout(start + margin, 0, start + margin + button.getMeasuredWidth(),
|
||||
button.getMeasuredHeight());
|
||||
start += button.getMeasuredWidth() + margin;
|
||||
}
|
||||
} else if (mIsVertical) {
|
||||
// Center buttons over workspace, not screen.
|
||||
int verticalCenter = (workspace.getRight() - workspace.getLeft()) / 2;
|
||||
ButtonDropTarget leftButton = visibleButtons[0];
|
||||
leftButton.layout(verticalCenter - leftButton.getMeasuredWidth() - (buttonGap / 2),
|
||||
0, verticalCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
|
||||
|
||||
ButtonDropTarget rightButton = visibleButtons[1];
|
||||
rightButton.layout(verticalCenter + (buttonGap / 2), 0,
|
||||
verticalCenter + rightButton.getMeasuredWidth() + (buttonGap / 2),
|
||||
rightButton.getMeasuredHeight());
|
||||
} else if (dp.isPhone) {
|
||||
// Buttons aligned to outer edges of scaled workspace.
|
||||
float shrunkTop = dp.getWorkspaceSpringLoadShrunkTop();
|
||||
float shrunkBottom = dp.getWorkspaceSpringLoadShrunkBottom();
|
||||
float scale =
|
||||
(shrunkBottom - shrunkTop) / launcher.getWorkspace().getNormalChildHeight();
|
||||
int workspaceWidth = (int) (launcher.getWorkspace().getNormalChildWidth() * scale);
|
||||
int start = barCenter - (workspaceWidth / 2);
|
||||
int end = barCenter + (workspaceWidth / 2);
|
||||
|
||||
ButtonDropTarget leftButton = visibleButtons[0];
|
||||
ButtonDropTarget rightButton = visibleButtons[1];
|
||||
|
||||
// If the text within the buttons is too long, the buttons can overlap
|
||||
int overlap = start + leftButton.getMeasuredWidth() + rightButton.getMeasuredWidth()
|
||||
- end;
|
||||
if (overlap > 0) {
|
||||
start -= overlap / 2;
|
||||
end += overlap / 2;
|
||||
}
|
||||
|
||||
leftButton.layout(start, 0, start + leftButton.getMeasuredWidth(),
|
||||
leftButton.getMeasuredHeight());
|
||||
rightButton.layout(end - rightButton.getMeasuredWidth(), 0, end,
|
||||
rightButton.getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,37 +324,14 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
setPageSpacing(Math.max(maxInsets, maxPadding));
|
||||
}
|
||||
|
||||
updateWorkspaceScreensPadding();
|
||||
updateCellLayoutPadding();
|
||||
updateWorkspaceWidgetsSizes();
|
||||
}
|
||||
|
||||
private void updateWorkspaceScreensPadding() {
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
|
||||
int paddingBottom = grid.cellLayoutBottomPaddingPx;
|
||||
|
||||
int panelCount = getPanelCount();
|
||||
int rightPanelModulus = mIsRtl ? 0 : panelCount - 1;
|
||||
int leftPanelModulus = mIsRtl ? panelCount - 1 : 0;
|
||||
int numberOfScreens = mScreenOrder.size();
|
||||
for (int i = 0; i < numberOfScreens; i++) {
|
||||
int paddingLeft = paddingLeftRight;
|
||||
int paddingRight = paddingLeftRight;
|
||||
// Add missing cellLayout border in-between panels.
|
||||
if (panelCount > 1) {
|
||||
if (i % panelCount == leftPanelModulus) {
|
||||
paddingRight += grid.cellLayoutBorderSpacePx.x / 2;
|
||||
} else if (i % panelCount == rightPanelModulus) { // right side panel
|
||||
paddingLeft += grid.cellLayoutBorderSpacePx.x / 2;
|
||||
} else { // middle panel
|
||||
paddingLeft += grid.cellLayoutBorderSpacePx.x / 2;
|
||||
paddingRight += grid.cellLayoutBorderSpacePx.x / 2;
|
||||
}
|
||||
}
|
||||
// SparseArrayMap doesn't keep the order
|
||||
mWorkspaceScreens.get(mScreenOrder.get(i))
|
||||
.setPadding(paddingLeft, 0, paddingRight, paddingBottom);
|
||||
}
|
||||
private void updateCellLayoutPadding() {
|
||||
Rect padding = mLauncher.getDeviceProfile().cellLayoutPaddingPx;
|
||||
mWorkspaceScreens.forEach(
|
||||
s -> s.setPadding(padding.left, padding.top, padding.right, padding.bottom));
|
||||
}
|
||||
|
||||
private void updateWorkspaceWidgetsSizes() {
|
||||
@@ -652,7 +629,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
mLauncher.getStateManager().getState(), newScreen, insertIndex);
|
||||
|
||||
updatePageScrollValues();
|
||||
updateWorkspaceScreensPadding();
|
||||
updateCellLayoutPadding();
|
||||
return newScreen;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,21 +225,21 @@ public class LauncherPreviewRenderer extends ContextWrapper
|
||||
mHotseat.resetLayout(false);
|
||||
|
||||
CellLayout firstScreen = mRootView.findViewById(R.id.workspace);
|
||||
firstScreen.setPadding(mDp.workspacePadding.left + mDp.cellLayoutPaddingLeftRightPx,
|
||||
mDp.workspacePadding.top,
|
||||
firstScreen.setPadding(mDp.workspacePadding.left + mDp.cellLayoutPaddingPx.left,
|
||||
mDp.workspacePadding.top + mDp.cellLayoutPaddingPx.top,
|
||||
(mDp.isTwoPanels ? mDp.cellLayoutBorderSpacePx.x / 2
|
||||
: mDp.workspacePadding.right) + mDp.cellLayoutPaddingLeftRightPx,
|
||||
mDp.workspacePadding.bottom
|
||||
: mDp.workspacePadding.right) + mDp.cellLayoutPaddingPx.right,
|
||||
mDp.workspacePadding.bottom + mDp.cellLayoutPaddingPx.bottom
|
||||
);
|
||||
mWorkspaceScreens.put(FIRST_SCREEN_ID, firstScreen);
|
||||
|
||||
if (mDp.isTwoPanels) {
|
||||
CellLayout rightPanel = mRootView.findViewById(R.id.workspace_right);
|
||||
rightPanel.setPadding(
|
||||
mDp.cellLayoutBorderSpacePx.x / 2 + mDp.cellLayoutPaddingLeftRightPx,
|
||||
mDp.workspacePadding.top,
|
||||
mDp.workspacePadding.right + mDp.cellLayoutPaddingLeftRightPx,
|
||||
mDp.workspacePadding.bottom
|
||||
mDp.cellLayoutBorderSpacePx.x / 2 + mDp.cellLayoutPaddingPx.left,
|
||||
mDp.workspacePadding.top + mDp.cellLayoutPaddingPx.top,
|
||||
mDp.workspacePadding.right + mDp.cellLayoutPaddingPx.right,
|
||||
mDp.workspacePadding.bottom + mDp.cellLayoutPaddingPx.bottom
|
||||
);
|
||||
mWorkspaceScreens.put(Workspace.SECOND_SCREEN_ID, rightPanel);
|
||||
}
|
||||
|
||||
@@ -113,13 +113,17 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
if (child == mAppsView) {
|
||||
int padding = 2 * (grid.desiredWorkspaceHorizontalMarginPx
|
||||
+ grid.cellLayoutPaddingLeftRightPx);
|
||||
int horizontalPadding = (2 * grid.desiredWorkspaceHorizontalMarginPx)
|
||||
+ grid.cellLayoutPaddingPx.left + grid.cellLayoutPaddingPx.right;
|
||||
int verticalPadding =
|
||||
grid.cellLayoutPaddingPx.top + grid.cellLayoutPaddingPx.bottom;
|
||||
|
||||
int maxWidth = grid.allAppsCellWidthPx * grid.numShownAllAppsColumns + padding;
|
||||
int maxWidth =
|
||||
grid.allAppsCellWidthPx * grid.numShownAllAppsColumns + horizontalPadding;
|
||||
int appsWidth = Math.min(width, maxWidth);
|
||||
|
||||
int maxHeight = grid.allAppsCellHeightPx * grid.numShownAllAppsColumns + padding;
|
||||
int maxHeight =
|
||||
grid.allAppsCellHeightPx * grid.numShownAllAppsColumns + verticalPadding;
|
||||
int appsHeight = Math.min(height, maxHeight);
|
||||
|
||||
mAppsView.measure(
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.launcher3.states;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
@@ -52,28 +51,15 @@ public class SpringLoadedState extends LauncherState {
|
||||
return super.getWorkspaceScaleAndTranslation(launcher);
|
||||
}
|
||||
|
||||
if (grid.isVerticalBarLayout()) {
|
||||
float scale = grid.workspaceSpringLoadShrinkFactor;
|
||||
return new ScaleAndTranslation(scale, 0, 0);
|
||||
}
|
||||
|
||||
float scale = grid.workspaceSpringLoadShrinkFactor;
|
||||
Rect insets = launcher.getDragLayer().getInsets();
|
||||
|
||||
float scaledHeight = scale * ws.getNormalChildHeight();
|
||||
float shrunkTop = insets.top + grid.dropTargetBarSizePx;
|
||||
float shrunkBottom = ws.getMeasuredHeight() - insets.bottom
|
||||
- grid.workspacePadding.bottom
|
||||
- grid.workspaceSpringLoadedBottomSpace;
|
||||
float totalShrunkSpace = shrunkBottom - shrunkTop;
|
||||
|
||||
float desiredCellTop = shrunkTop + (totalShrunkSpace - scaledHeight) / 2;
|
||||
float shrunkTop = grid.getWorkspaceSpringLoadShrunkTop();
|
||||
float shrunkBottom = grid.getWorkspaceSpringLoadShrunkBottom();
|
||||
float scale = (shrunkBottom - shrunkTop) / ws.getNormalChildHeight();
|
||||
|
||||
float halfHeight = ws.getHeight() / 2;
|
||||
float myCenter = ws.getTop() + halfHeight;
|
||||
float cellTopFromCenter = halfHeight - ws.getChildAt(0).getTop();
|
||||
float actualCellTop = myCenter - cellTopFromCenter * scale;
|
||||
return new ScaleAndTranslation(scale, 0, (desiredCellTop - actualCellTop) / scale);
|
||||
return new ScaleAndTranslation(scale, 0, (shrunkTop - actualCellTop) / scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user