From b25d7588276030a30cf584b393bcbd0f9656cf4a Mon Sep 17 00:00:00 2001 From: Federico Baron Date: Thu, 2 Mar 2023 14:10:09 -0800 Subject: [PATCH] Widget picker closes and reopens when switching orientation on phones when it's not necessary Widget picker closes and reopens when switching orientation on phones when it's not necessary. We should only close and reopen widget picker if it's tablet since that's when we want to inflate either the regular widget picker or the two pane widget picker. When we're on a phone, we always want to inflate the regular widget picker, so closing and re-inflating is not needed. Fix: 271474746 Test: Change orientation in phones vs tablets. Verify that both still work. Change-Id: I6062b056c4e7675bc830b6884761ec1f2eb20b1d --- .../launcher3/widget/picker/WidgetsFullSheet.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index f8068aac77..77781bd967 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -201,6 +201,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet private TextView mHeaderTitle; private FrameLayout mRightPane; private WidgetsListTableViewHolderBinder mWidgetsListTableViewHolderBinder; + private DeviceProfile mDeviceProfile; private final boolean mIsTwoPane; private int mOrientation; @@ -210,8 +211,10 @@ public class WidgetsFullSheet extends BaseWidgetSheet public WidgetsFullSheet(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - DeviceProfile dp = Launcher.getLauncher(context).getDeviceProfile(); - mIsTwoPane = dp.isTablet && dp.isLandscape && LARGE_SCREEN_WIDGET_PICKER.get(); + mDeviceProfile = Launcher.getLauncher(context).getDeviceProfile(); + mIsTwoPane = mDeviceProfile.isTablet + && mDeviceProfile.isLandscape + && LARGE_SCREEN_WIDGET_PICKER.get(); mHasWorkProfile = context.getSystemService(LauncherApps.class).getProfiles().size() > 1; mAdapters.put(AdapterHolder.PRIMARY, new AdapterHolder(AdapterHolder.PRIMARY)); mAdapters.put(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK)); @@ -874,7 +877,9 @@ public class WidgetsFullSheet extends BaseWidgetSheet } // Checks the orientation of the screen - if (LARGE_SCREEN_WIDGET_PICKER.get() && mOrientation != newConfig.orientation) { + if (LARGE_SCREEN_WIDGET_PICKER.get() + && mOrientation != newConfig.orientation + && mDeviceProfile.isTablet) { mOrientation = newConfig.orientation; handleClose(false); show(Launcher.getLauncher(getContext()), false);