diff --git a/res/layout/widgets_two_pane_sheet_foldable.xml b/res/layout/widgets_two_pane_sheet_foldable.xml deleted file mode 100644 index 93c0c7053e..0000000000 --- a/res/layout/widgets_two_pane_sheet_foldable.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index 583ef1ab20..e9a590b814 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -163,7 +163,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet private boolean mIsInSearchMode; private boolean mIsNoWidgetsViewNeeded; @Px private int mMaxSpanPerRow; - private DeviceProfile mDeviceProfile; + protected DeviceProfile mDeviceProfile; protected TextView mNoWidgetsView; protected StickyHeaderLayout mSearchScrollView; @@ -690,12 +690,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet // Enables two pane picker for unfolded foldables if the flag is on. || (activity.getDeviceProfile().isTwoPanels && enableUnfoldedTwoPanePicker()); - if (isTwoPane && activity.getDeviceProfile().isTwoPanels) { - return R.layout.widgets_two_pane_sheet_foldable; - } else if (isTwoPane) { - return R.layout.widgets_two_pane_sheet; - } - return R.layout.widgets_full_sheet; + return isTwoPane ? R.layout.widgets_two_pane_sheet : R.layout.widgets_full_sheet; } @Override diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java index d85737b28f..c3ab08c153 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.widget.picker; +import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker; + import android.content.Context; import android.graphics.Outline; import android.os.Process; @@ -23,12 +25,15 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewOutlineProvider; +import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ScrollView; import androidx.annotation.NonNull; +import androidx.annotation.Px; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.model.data.PackageItemInfo; import com.android.launcher3.recyclerview.ViewHolderBinder; import com.android.launcher3.util.PackageUserKey; @@ -46,6 +51,8 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { private static final int PERSONAL_TAB = 0; private static final int WORK_TAB = 1; + private static final int MINIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP = 268; + private static final int MAXIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP = 395; private static final String SUGGESTIONS_PACKAGE_NAME = "widgets_list_suggestions_entry"; private LinearLayout mSuggestedWidgetsContainer; @@ -116,6 +123,29 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { mFastScroller.setVisibility(GONE); } + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + if (changed && mDeviceProfile.isTwoPanels && enableUnfoldedTwoPanePicker()) { + LinearLayout layout = mContent.findViewById(R.id.linear_layout_container); + FrameLayout leftPane = layout.findViewById(R.id.recycler_view_container); + LinearLayout.LayoutParams layoutParams = (LayoutParams) leftPane.getLayoutParams(); + // Width is 1/3 of the sheet unless it's less than min width or max width + int leftPaneWidth = layout.getMeasuredWidth() / 3; + @Px int minLeftPaneWidthPx = Utilities.dpToPx(MINIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP); + @Px int maxLeftPaneWidthPx = Utilities.dpToPx(MAXIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP); + if (leftPaneWidth < minLeftPaneWidthPx) { + layoutParams.width = minLeftPaneWidthPx; + } else if (leftPaneWidth > maxLeftPaneWidthPx) { + layoutParams.width = maxLeftPaneWidthPx; + } else { + layoutParams.width = 0; + } + layoutParams.weight = layoutParams.width == 0 ? 0.33F : 0; + leftPane.setLayoutParams(layoutParams); + } + } + @Override public void onRecommendedWidgetsBound() { super.onRecommendedWidgetsBound();