Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e54d62a authored by Steven Ng's avatar Steven Ng
Browse files

Allow WidgetsBottomSheet to wrap its content

Test: manual. See videos in b/200036849
Fix: 200036849
Change-Id: I64bc162834c715b48a4571ee95be7543e60bd6d8
parent 8b30227f
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.anim.PendingAnimation;
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 ItemInfo mOriginalItemInfo;
    private final int mMaxTableHeight;
    private int mMaxHorizontalSpan = DEFAULT_MAX_HORIZONTAL_SPANS;
    private final int mWidgetCellHorizontalPadding;

@@ -110,10 +108,6 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
    public WidgetsBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        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()) {
            addOnLayoutChangeListener(mLayoutChangeListenerToShowTips);
        }
@@ -162,13 +156,9 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {

        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);
        if (widgetsTableScrollView.getMeasuredHeight() > mMaxTableHeight) {
            ViewGroup.LayoutParams layoutParams = widgetsTableScrollView.getLayoutParams();
            layoutParams.height = mMaxTableHeight;
            widgetsTableScrollView.setLayoutParams(layoutParams);
        TableLayout widgetsTable = findViewById(R.id.widgets_table);
        if (widgetsTable.getMeasuredHeight() > widgetsTableScrollView.getMeasuredHeight()) {
            findViewById(R.id.collapse_handle).setVisibility(VISIBLE);
        }
    }