Merge "Set the widgets pickers' width to at most 80% of screen width on large screen devices" into sc-v2-dev

This commit is contained in:
Steven Ng
2021-06-29 17:18:35 +00:00
committed by Android (Google) Code Review
@@ -51,6 +51,11 @@ import com.android.launcher3.views.ArrowTipView;
public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
implements OnClickListener, OnLongClickListener, DragSource,
PopupDataProvider.PopupDataChangeListener, Insettable {
/**
* The maximum scale, [0, 1], of the device screen width that the widgets picker can consume
* on large screen devices.
*/
protected static final float MAX_WIDTH_SCALE_FOR_LARGER_SCREEN = 0.8f;
protected static final String KEY_WIDGETS_EDUCATION_TIP_SEEN =
"launcher.widgets_education_tip_seen";
@@ -131,6 +136,15 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
2 * (mInsets.left + mInsets.right));
}
if (deviceProfile.isTablet || deviceProfile.isTwoPanels) {
// In large screen devices, we restrict the width of the widgets picker to show part of
// the home screen. Let's ensure the minimum width used is at least the minimum width
// that isn't taken by the widgets picker.
int minUsedWidth = (int) (deviceProfile.availableWidthPx
* (1 - MAX_WIDTH_SCALE_FOR_LARGER_SCREEN));
widthUsed = Math.max(widthUsed, minUsedWidth);
}
int heightUsed = mInsets.top + deviceProfile.edgeMarginPx;
measureChildWithMargins(mContent, widthMeasureSpec,
widthUsed, heightMeasureSpec, heightUsed);