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

Commit 1960ea4a authored by Adam Cohen's avatar Adam Cohen
Browse files

Fix CellLayout UNSPECIFIED exception (issue 11627191)

Change-Id: Id2f840a804c51e8c61bb28882796059584e4c8bb
parent 84a465aa
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -119,6 +119,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
    private int DRAG_MODE_REORDER = 1;
    private int mDragMode = DRAG_MODE_NONE;

    // We avoid measuring the scroll view with a 0 width or height, as this
    // results in CellLayout being measured as UNSPECIFIED, which it does
    // not support.
    private static final int MIN_CONTENT_DIMEN = 5;

    private boolean mDestroyed;

    private AutoScrollHelper mAutoScrollHelper;
@@ -959,8 +964,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
        int maxContentAreaHeight = grid.availableHeightPx -
                workspacePadding.top - workspacePadding.bottom -
                mFolderNameHeight;
        return Math.min(maxContentAreaHeight,
        int height = Math.min(maxContentAreaHeight,
                mContent.getDesiredHeight());
        return Math.max(height, MIN_CONTENT_DIMEN);
    }

    private int getContentAreaWidth() {
        return Math.max(mContent.getDesiredWidth(), MIN_CONTENT_DIMEN);
    }

    private int getFolderHeight() {
@@ -972,11 +982,12 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
        int height = getFolderHeight();
        int contentAreaWidthSpec = MeasureSpec.makeMeasureSpec(mContent.getDesiredWidth(),
        int contentAreaWidthSpec = MeasureSpec.makeMeasureSpec(getContentAreaWidth(),
                MeasureSpec.EXACTLY);
        int contentAreaHeightSpec = MeasureSpec.makeMeasureSpec(getContentAreaHeight(),
                MeasureSpec.EXACTLY);
        mContent.setFixedSize(mContent.getDesiredWidth(), mContent.getDesiredHeight());

        mContent.setFixedSize(getContentAreaWidth(), getContentAreaHeight());
        mScrollView.measure(contentAreaWidthSpec, contentAreaHeightSpec);
        mFolderName.measure(contentAreaWidthSpec,
                MeasureSpec.makeMeasureSpec(mFolderNameHeight, MeasureSpec.EXACTLY));