Set the widgets pickers' width to at most 80% of screen width on
large screen devices
Test: Phone: Open the full widgets picker and observe the width of
the widgets picker fills the device screen width.
Large screen devices: Open the bottom widgets picker and observe
the width of the widgets picker only takes at most 80% of the
devices' screen width.
Same behavior is observed for bottom widgets picker.
Bug: 186425352
Change-Id: I801b73ea031a290fb6a7295dca826ac91841877e
diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java
index 9f0b9d9..a5c142d 100644
--- a/src/com/android/launcher3/widget/BaseWidgetSheet.java
+++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java
@@ -51,6 +51,11 @@
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 @@
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);