mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Update widget picker row logic to resolve cropping
Using pixels instead of cell spans for calculating the widget picker row binding logic. Before: https://screenshot.googleplex.com/3uXX2m7xWh3om5t Now: https://screenshot.googleplex.com/C593mrQfqTahNrQ Test: Manual Fix: 269790954 Change-Id: Ib591a6f6d3cf8b72766e0714b9bc8ceb86b2ba4f
This commit is contained in:
@@ -33,6 +33,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.GuardedBy;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.Px;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
@@ -61,7 +62,7 @@ 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;
|
||||
public static final int DEFAULT_MAX_HORIZONTAL_SPANS = 4;
|
||||
|
||||
protected static final String KEY_WIDGETS_EDUCATION_TIP_SEEN =
|
||||
"launcher.widgets_education_tip_seen";
|
||||
@@ -70,15 +71,18 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
|
||||
/* Touch handling related member variables. */
|
||||
private Toast mWidgetInstructionToast;
|
||||
|
||||
private int mContentHorizontalMarginInPx;
|
||||
@Px protected int mContentHorizontalMargin;
|
||||
@Px protected int mWidgetCellHorizontalPadding;
|
||||
|
||||
protected int mNavBarScrimHeight;
|
||||
private final Paint mNavBarScrimPaint;
|
||||
|
||||
public BaseWidgetSheet(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mContentHorizontalMarginInPx = getResources().getDimensionPixelSize(
|
||||
mContentHorizontalMargin = getResources().getDimensionPixelSize(
|
||||
R.dimen.widget_list_horizontal_margin);
|
||||
mWidgetCellHorizontalPadding = getResources().getDimensionPixelSize(
|
||||
R.dimen.widget_cell_horizontal_padding);
|
||||
mNavBarScrimPaint = new Paint();
|
||||
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
|
||||
}
|
||||
@@ -138,11 +142,11 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
|
||||
@Override
|
||||
public void setInsets(Rect insets) {
|
||||
mInsets.set(insets);
|
||||
int contentHorizontalMarginInPx = getResources().getDimensionPixelSize(
|
||||
@Px int contentHorizontalMargin = getResources().getDimensionPixelSize(
|
||||
R.dimen.widget_list_horizontal_margin);
|
||||
if (contentHorizontalMarginInPx != mContentHorizontalMarginInPx) {
|
||||
onContentHorizontalMarginChanged(contentHorizontalMarginInPx);
|
||||
mContentHorizontalMarginInPx = contentHorizontalMarginInPx;
|
||||
if (contentHorizontalMargin != mContentHorizontalMargin) {
|
||||
onContentHorizontalMarginChanged(contentHorizontalMargin);
|
||||
mContentHorizontalMargin = contentHorizontalMargin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,19 +202,6 @@ 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
|
||||
- (2 * mContentHorizontalMarginInPx);
|
||||
Point cellSize = deviceProfile.getCellSize();
|
||||
if (cellSize.x > 0) {
|
||||
return availableWidth / cellSize.x;
|
||||
}
|
||||
return DEFAULT_MAX_HORIZONTAL_SPANS;
|
||||
}
|
||||
|
||||
private boolean beginDraggingWidget(WidgetCell v) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.NO_DROP_TARGET, "2");
|
||||
|
||||
Reference in New Issue
Block a user