Merge "Allow WidgetsBottomSheet to wrap its content" into sc-v2-dev am: c137171c8d

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15879754

Change-Id: Ia9c5c9a7164b81ede54df564fce1c64171d7fa06
This commit is contained in:
Steven Ng authored and Automerger Merge Worker committed 2021-09-22 13:45:07 +00:00
commit e1cceaeb2f
1 file changed
+2 -12
@@ -36,7 +36,6 @@ import android.widget.TableLayout;
import android.widget.TableRow; import android.widget.TableRow;
import android.widget.TextView; import android.widget.TextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.model.WidgetItem; import com.android.launcher3.model.WidgetItem;
@@ -70,7 +69,6 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
private static final long EDUCATION_TIP_DELAY_MS = 300; private static final long EDUCATION_TIP_DELAY_MS = 300;
private ItemInfo mOriginalItemInfo; private ItemInfo mOriginalItemInfo;
private final int mMaxTableHeight;
private int mMaxHorizontalSpan = DEFAULT_MAX_HORIZONTAL_SPANS; private int mMaxHorizontalSpan = DEFAULT_MAX_HORIZONTAL_SPANS;
private final int mWidgetCellHorizontalPadding; private final int mWidgetCellHorizontalPadding;
@@ -110,10 +108,6 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
public WidgetsBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) { public WidgetsBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
setWillNotDraw(false); setWillNotDraw(false);
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
// Set the max table height to 2 / 3 of the grid height so that the bottom picker won't
// take over the entire view vertically.
mMaxTableHeight = deviceProfile.inv.numRows * 2 / 3 * deviceProfile.cellHeightPx;
if (!hasSeenEducationTip()) { if (!hasSeenEducationTip()) {
addOnLayoutChangeListener(mLayoutChangeListenerToShowTips); addOnLayoutChangeListener(mLayoutChangeListenerToShowTips);
} }
@@ -162,13 +156,9 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
setTranslationShift(mTranslationShift); setTranslationShift(mTranslationShift);
// Ensure the scroll view height is not larger than mMaxTableHeight, which is a value
// smaller than the entire screen height.
ScrollView widgetsTableScrollView = findViewById(R.id.widgets_table_scroll_view); ScrollView widgetsTableScrollView = findViewById(R.id.widgets_table_scroll_view);
if (widgetsTableScrollView.getMeasuredHeight() > mMaxTableHeight) { TableLayout widgetsTable = findViewById(R.id.widgets_table);
ViewGroup.LayoutParams layoutParams = widgetsTableScrollView.getLayoutParams(); if (widgetsTable.getMeasuredHeight() > widgetsTableScrollView.getMeasuredHeight()) {
layoutParams.height = mMaxTableHeight;
widgetsTableScrollView.setLayoutParams(layoutParams);
findViewById(R.id.collapse_handle).setVisibility(VISIBLE); findViewById(R.id.collapse_handle).setVisibility(VISIBLE);
} }
} }