Moving DeviceProfile properties into DeviceProperties data class

Bug: 419264653
Flag: EXEMPT refactor
Test: DeviceProfileDumpTest
Test: All Image tests
Change-Id: I638f88cd76b926917965dbf9e70b5bdfff5971e0
This commit is contained in:
Sebastian Franco committed 2025-05-23 10:42:26 -07:00
1 parent 48e7365190
commit e1111e28c2
127 files changed
+726 -596

No files matched your search

+23 -22
View File
@@ -85,8 +85,9 @@ public class DropTargetBar extends FrameLayout
@Override
public void setInsets(Rect insets) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
DeviceProfile grid = mLauncher.getDeviceProfile();
mIsVertical = grid.isVerticalBarLayout();
DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
mIsVertical = deviceProfile.isVerticalBarLayout();
int widthPx = deviceProfile.getDeviceProperties().getWidthPx();
lp.leftMargin = insets.left;
lp.topMargin = insets.top;
@@ -95,25 +96,25 @@ public class DropTargetBar extends FrameLayout
int tooltipLocation = TOOLTIP_DEFAULT;
int horizontalMargin;
if (grid.isTablet) {
if (deviceProfile.getDeviceProperties().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;
horizontalMargin = ((widthPx - 2 * deviceProfile.edgeMarginPx
- (deviceProfile.inv.numColumns * deviceProfile.cellWidthPx))
/ (2 * (deviceProfile.inv.numColumns + 1)))
+ deviceProfile.edgeMarginPx;
} else {
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;
lp.topMargin += deviceProfile.dropTargetBarTopMarginPx;
lp.bottomMargin += deviceProfile.dropTargetBarBottomMarginPx;
lp.width = deviceProfile.getDeviceProperties().getAvailableWidthPx() - 2 * horizontalMargin;
if (mIsVertical) {
lp.leftMargin = (grid.widthPx - lp.width) / 2;
lp.rightMargin = (grid.widthPx - lp.width) / 2;
lp.leftMargin = (widthPx - lp.width) / 2;
lp.rightMargin = (widthPx - lp.width) / 2;
}
lp.height = grid.dropTargetBarSizePx;
lp.height = deviceProfile.dropTargetBarSizePx;
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
DeviceProfile dp = mLauncher.getDeviceProfile();
@@ -121,7 +122,7 @@ public class DropTargetBar extends FrameLayout
int verticalPadding = dp.dropTargetVerticalPaddingPx;
setLayoutParams(lp);
for (ButtonDropTarget button : mDropTargets) {
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.dropTargetTextSizePx);
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, deviceProfile.dropTargetTextSizePx);
button.setToolTipLocation(tooltipLocation);
button.setPadding(horizontalPadding, verticalPadding, horizontalPadding,
verticalPadding);
@@ -175,15 +176,15 @@ public class DropTargetBar extends FrameLayout
// Reset second button padding in case it was previously changed to multi-line text.
secondButton.setPadding(horizontalPadding, verticalPadding, horizontalPadding,
verticalPadding);
int availableWidth;
if (dp.isTwoPanels) {
if (dp.getDeviceProperties().isTwoPanels()) {
// Each button for two panel fits to half the width of the screen excluding the
// center gap between the buttons.
availableWidth = (dp.availableWidthPx - dp.dropTargetGapPx) / 2;
availableWidth = (dp.getDeviceProperties().getAvailableWidthPx() - dp.dropTargetGapPx) / 2;
} else {
// Both buttons plus the button gap do not display past the edge of the screen.
availableWidth = dp.availableWidthPx - dp.dropTargetGapPx;
availableWidth = dp.getDeviceProperties().getAvailableWidthPx() - dp.dropTargetGapPx;
}
int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
@@ -199,7 +200,7 @@ public class DropTargetBar extends FrameLayout
}
}
if (!dp.isTwoPanels) {
if (!dp.getDeviceProperties().isTwoPanels()) {
availableWidth -= firstButton.getMeasuredWidth() + dp.dropTargetGapPx;
widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
}
@@ -239,11 +240,11 @@ public class DropTargetBar extends FrameLayout
float scale = dp.getWorkspaceSpringLoadScale(mLauncher);
Workspace<?> ws = mLauncher.getWorkspace();
int barCenter;
if (dp.isTwoPanels) {
if (dp.getDeviceProperties().isTwoPanels()) {
barCenter = (right - left) / 2;
} else {
int workspaceCenter = (ws.getLeft() + ws.getRight()) / 2;
int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.widthPx
int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.getDeviceProperties().getWidthPx()
- dp.getInsets().right - dp.workspacePadding.right)) / 2;
int cellLayoutCenterOffset = (int) ((cellLayoutCenter - workspaceCenter) * scale);
barCenter = workspaceCenter + cellLayoutCenterOffset - left;
@@ -258,7 +259,7 @@ public class DropTargetBar extends FrameLayout
ButtonDropTarget leftButton = mTempTargets[0];
ButtonDropTarget rightButton = mTempTargets[1];
if (dp.isTwoPanels) {
if (dp.getDeviceProperties().isTwoPanels()) {
leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
rightButton.layout(barCenter + (buttonGap / 2), 0,