diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java index c17ae0910a..3bea35da97 100644 --- a/src/com/android/launcher3/widget/BaseWidgetSheet.java +++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java @@ -16,8 +16,6 @@ package com.android.launcher3.widget; import static com.android.app.animation.Interpolators.EMPHASIZED; -import static com.android.launcher3.Flags.enableCategorizedWidgetSuggestions; -import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker; import static com.android.launcher3.Flags.enableWidgetTapToAdd; import static com.android.launcher3.LauncherPrefs.WIDGETS_EDUCATION_TIP_SEEN; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGET_ADD_BUTTON_TAP; @@ -272,19 +270,8 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView MeasureSpec.getSize(heightMeasureSpec)); } - private int getTabletHorizontalMargin(DeviceProfile deviceProfile) { - // All bottom-sheets showing widgets will be full-width across all devices. - if (enableCategorizedWidgetSuggestions()) { - return 0; - } - if (deviceProfile.isLandscape && !deviceProfile.isTwoPanels) { - return getResources().getDimensionPixelSize( - R.dimen.widget_picker_landscape_tablet_left_right_margin); - } - if (deviceProfile.isTwoPanels && enableUnfoldedTwoPanePicker()) { - return getResources().getDimensionPixelSize( - R.dimen.widget_picker_two_panels_left_right_margin); - } + /** Returns the horizontal margins to be applied to the widget sheet. **/ + protected int getTabletHorizontalMargin(DeviceProfile deviceProfile) { return deviceProfile.allAppsLeftRightMargin; } diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java index 14985bf148..9f3f1272c1 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java @@ -39,6 +39,7 @@ import android.widget.ScrollView; import androidx.annotation.NonNull; import androidx.annotation.Px; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.model.data.PackageItemInfo; @@ -153,6 +154,26 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { mFastScroller.setVisibility(GONE); } + @Override + protected int getTabletHorizontalMargin(DeviceProfile deviceProfile) { + if (enableCategorizedWidgetSuggestions()) { + // two pane picker is full width for fold as well as tablet. + return getResources().getDimensionPixelSize( + R.dimen.widget_picker_two_panels_left_right_margin); + } + if (deviceProfile.isTwoPanels && enableUnfoldedTwoPanePicker()) { + // enableUnfoldedTwoPanePicker made two pane picker full-width for fold only. + return getResources().getDimensionPixelSize( + R.dimen.widget_picker_two_panels_left_right_margin); + } + if (deviceProfile.isLandscape && !deviceProfile.isTwoPanels) { + // non-fold tablet landscape margins (ag/22163531) + return getResources().getDimensionPixelSize( + R.dimen.widget_picker_landscape_tablet_left_right_margin); + } + return deviceProfile.allAppsLeftRightMargin; + } + @Override protected void onUserSwipeToDismissProgressChanged() { super.onUserSwipeToDismissProgressChanged();