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

Commit 7507d3d3 authored by Adam Powell's avatar Adam Powell
Browse files

Fix measurement issues with Spinner and ListPopupWindow

Bug 6132826 - make sure that our speculative measurement of list items
uses an accurate width MeasureSpec. This bug would sometimes affect
window sizing when measuring height if content could wrap in the
presence of restricted width.

Change-Id: Ie28573e952cac3dfa2b95e4691758c72f26b8fd9
parent 1881f27b
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -1080,6 +1080,8 @@ public class ListPopupWindow {
            if (!mDropDownVerticalOffsetSet) {
                mDropDownVerticalOffset = -mTempRect.top;
            }
        } else {
            mTempRect.setEmpty();
        }

        // Max height available on the screen for a popup.
@@ -1092,7 +1094,25 @@ public class ListPopupWindow {
            return maxHeight + padding;
        }

        final int listContent = mDropDownList.measureHeightOfChildren(MeasureSpec.UNSPECIFIED,
        final int childWidthSpec;
        switch (mDropDownWidth) {
            case ViewGroup.LayoutParams.WRAP_CONTENT:
                childWidthSpec = MeasureSpec.makeMeasureSpec(
                        mContext.getResources().getDisplayMetrics().widthPixels -
                        (mTempRect.left + mTempRect.right),
                        MeasureSpec.AT_MOST);
                break;
            case ViewGroup.LayoutParams.MATCH_PARENT:
                childWidthSpec = MeasureSpec.makeMeasureSpec(
                        mContext.getResources().getDisplayMetrics().widthPixels -
                        (mTempRect.left + mTempRect.right),
                        MeasureSpec.EXACTLY);
                break;
            default:
                childWidthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.EXACTLY);
                break;
        }
        final int listContent = mDropDownList.measureHeightOfChildren(childWidthSpec,
                0, ListView.NO_POSITION, maxHeight - otherHeights, -1);
        // add padding only if the list has items in it, that way we don't show
        // the popup if it is not needed
+0 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.database.DataSetObserver;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;