diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java index 95c67ddaa8..7c1e152173 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java @@ -388,34 +388,34 @@ public abstract class BaseAllAppsContainerView 0) { + if (deviceProfile.isTablet) { + int margin = deviceProfile.allAppsLeftRightMargin; + widthUsed = Math.max(2 * margin, 2 * (mInsets.left + mInsets.right)); + } else if (mInsets.bottom > 0) { widthUsed = mInsets.left + mInsets.right; } else { Rect padding = deviceProfile.workspacePadding; @@ -114,18 +116,8 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView 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. - */ - protected static final float MAX_WIDTH_SCALE_FOR_LARGER_SCREEN = 0.89f; protected static final String KEY_WIDGETS_EDUCATION_TIP_SEEN = "launcher.widgets_education_tip_seen"; @@ -70,10 +69,15 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView private int mContentHorizontalMarginInPx; + protected int mNavBarScrimHeight; + private final Paint mNavBarScrimPaint; + public BaseWidgetSheet(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mContentHorizontalMarginInPx = getResources().getDimensionPixelSize( R.dimen.widget_list_horizontal_margin); + mNavBarScrimPaint = new Paint(); + mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor)); } protected int getScrimColor(Context context) { @@ -83,6 +87,9 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); + WindowInsets windowInsets = WindowManagerProxy.INSTANCE.get(getContext()) + .normalizeWindowInsets(getContext(), getRootWindowInsets(), new Rect()); + mNavBarScrimHeight = getNavBarScrimHeight(windowInsets); mActivityContext.getPopupDataProvider().setChangeListener(this); } @@ -136,6 +143,30 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView } } + private int getNavBarScrimHeight(WindowInsets insets) { + if (Utilities.ATLEAST_Q) { + return insets.getTappableElementInsets().bottom; + } else { + return insets.getStableInsetBottom(); + } + } + + @Override + public WindowInsets onApplyWindowInsets(WindowInsets insets) { + mNavBarScrimHeight = getNavBarScrimHeight(insets); + return super.onApplyWindowInsets(insets); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + super.dispatchDraw(canvas); + + if (mNavBarScrimHeight > 0) { + canvas.drawRect(0, getHeight() - mNavBarScrimHeight, getWidth(), getHeight(), + mNavBarScrimPaint); + } + } + /** Called when the horizontal margin of the content view has changed. */ protected abstract void onContentHorizontalMarginChanged(int contentHorizontalMarginInPx); @@ -147,7 +178,10 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView protected void doMeasure(int widthMeasureSpec, int heightMeasureSpec) { DeviceProfile deviceProfile = mActivityContext.getDeviceProfile(); int widthUsed; - if (mInsets.bottom > 0) { + if (deviceProfile.isTablet) { + int margin = deviceProfile.allAppsLeftRightMargin; + widthUsed = Math.max(2 * margin, 2 * (mInsets.left + mInsets.right)); + } else if (mInsets.bottom > 0) { widthUsed = mInsets.left + mInsets.right; } else { Rect padding = deviceProfile.workspacePadding; @@ -155,15 +189,6 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView 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); - } - measureChildWithMargins(mContent, widthMeasureSpec, widthUsed, heightMeasureSpec, deviceProfile.bottomSheetTopPadding); setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java index b152ddc2d9..bf521cc7eb 100644 --- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java @@ -247,10 +247,12 @@ public class WidgetsBottomSheet extends BaseWidgetSheet { @Override public void setInsets(Rect insets) { super.setInsets(insets); + int bottomPadding = Math.max(insets.bottom, mNavBarScrimHeight); mContent.setPadding(mContent.getPaddingStart(), - mContent.getPaddingTop(), mContent.getPaddingEnd(), insets.bottom); - if (insets.bottom > 0) { + mContent.getPaddingTop(), mContent.getPaddingEnd(), + bottomPadding); + if (bottomPadding > 0) { setupNavBarColor(); } else { clearNavBarColor(); diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index 341cb5c93e..a49cdc005a 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -328,15 +328,15 @@ public class WidgetsFullSheet extends BaseWidgetSheet @Override public void setInsets(Rect insets) { super.setInsets(insets); - - setBottomPadding(mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView, insets.bottom); - setBottomPadding(mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView, insets.bottom); + int bottomPadding = Math.max(insets.bottom, mNavBarScrimHeight); + setBottomPadding(mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView, bottomPadding); + setBottomPadding(mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView, bottomPadding); if (mHasWorkProfile) { - setBottomPadding(mAdapters.get(AdapterHolder.WORK).mWidgetsRecyclerView, insets.bottom); + setBottomPadding(mAdapters.get(AdapterHolder.WORK).mWidgetsRecyclerView, bottomPadding); } - ((MarginLayoutParams) mNoWidgetsView.getLayoutParams()).bottomMargin = insets.bottom; + ((MarginLayoutParams) mNoWidgetsView.getLayoutParams()).bottomMargin = bottomPadding; - if (insets.bottom > 0) { + if (bottomPadding > 0) { setupNavBarColor(); } else { clearNavBarColor();