mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user