Correct # of cells estimation that can fit horizontally in widgets

picker

Fix: 192661517
Test: check widgets are fit correctly in both full & bottom widgets
      picker in portrait and landscape in different grid settings.
Change-Id: Ic1b0589b7ccf62ff1ec1fd5713b4249ba58246a5
This commit is contained in:
Steven Ng committed 2021-07-08 16:23:38 +01:00
1 parent 277eb6fe59
commit 452e8b8512
3 files changed
+34 -17

No files matched your search

@@ -51,6 +51,8 @@ import com.android.launcher3.views.ArrowTipView;
public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
implements OnClickListener, OnLongClickListener, DragSource,
PopupDataProvider.PopupDataChangeListener, Insettable {
/** The default number of cells that can fit horizontally in a widget sheet. */
protected static final int DEFAULT_MAX_HORIZONTAL_SPANS = 4;
/**
* The maximum scale, [0, 1], of the device screen width that the widgets picker can consume
* on large screen devices.
@@ -152,6 +154,17 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
MeasureSpec.getSize(heightMeasureSpec));
}
/** Returns the number of cells that can fit horizontally in a given {@code content}. */
protected int computeMaxHorizontalSpans(View content, int contentHorizontalPaddingPx) {
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
int availableWidth = content.getMeasuredWidth() - contentHorizontalPaddingPx;
Point cellSize = deviceProfile.getCellSize();
if (cellSize.x > 0) {
return availableWidth / cellSize.x;
}
return DEFAULT_MAX_HORIZONTAL_SPANS;
}
private boolean beginDraggingWidget(WidgetCell v) {
// Get the widget preview as the drag representation
WidgetImageView image = v.getWidgetView();