Update widget picker two pane to support foldables

Bug: 301918659
Test: WidgetPickerImageTest
Flag: ACONFIG com.android.launcher3.enable_unfolded_two_pane_picker DEVELOPMENT
Change-Id: I5beecf4f8c46235f3e89c7bd8aed65fd292883ce
This commit is contained in:
fbaron
2023-11-29 16:04:25 -08:00
parent 52b5113e8d
commit eee16c7ac5
4 changed files with 185 additions and 38 deletions

View File

@@ -16,6 +16,7 @@
package com.android.launcher3.widget;
import static com.android.app.animation.Interpolators.EMPHASIZED;
import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker;
import static com.android.launcher3.LauncherPrefs.WIDGETS_EDUCATION_TIP_SEEN;
import android.content.Context;
@@ -182,12 +183,8 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<BaseActivity>
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
int widthUsed;
if (deviceProfile.isTablet) {
int margin = deviceProfile.allAppsLeftRightMargin;
if (deviceProfile.isLandscape && !deviceProfile.isTwoPanels) {
margin = getResources().getDimensionPixelSize(
R.dimen.widget_picker_landscape_tablet_left_right_margin);
}
widthUsed = Math.max(2 * margin, 2 * (mInsets.left + mInsets.right));
widthUsed = Math.max(2 * getTabletMargin(deviceProfile),
2 * (mInsets.left + mInsets.right));
} else if (mInsets.bottom > 0) {
widthUsed = mInsets.left + mInsets.right;
} else {
@@ -202,6 +199,18 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<BaseActivity>
MeasureSpec.getSize(heightMeasureSpec));
}
private int getTabletMargin(DeviceProfile deviceProfile) {
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);
}
return deviceProfile.allAppsLeftRightMargin;
}
@Override
protected Interpolator getIdleInterpolator() {
return mActivityContext.getDeviceProfile().isTablet