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

Commit 67056f7a authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Fix width of GA popup menu.

* Take into account padding when measuring width. Remove from max and
min and then add back.
* Find the maximum width for all entries, instead of just the first one.

Test: manual, English and Greek
Fixes: 156775638
Change-Id: Ie6754af18ce44ef33217a1d96aa4c460bb449d87
parent f7b69012
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -89,15 +89,19 @@ public class GlobalActionsPopupMenu extends ListPopupWindow {
            // width should be between [.5, .9] of screen
            int parentWidth = res.getSystem().getDisplayMetrics().widthPixels;
            int widthSpec = MeasureSpec.makeMeasureSpec(
                    (int) (parentWidth * 0.9), MeasureSpec.AT_MOST);
            View child = mAdapter.getView(0, null, listView);
                    (int) (parentWidth * 0.9) - 2 * mMenuHorizontalPadding, MeasureSpec.AT_MOST);
            int maxWidth = 0;
            for (int i = 0; i < mAdapter.getCount(); i++) {
                View child = mAdapter.getView(i, null, listView);
                child.measure(widthSpec, MeasureSpec.UNSPECIFIED);
            int width = Math.max(child.getMeasuredWidth(), (int) (parentWidth * 0.5));

                int w = child.getMeasuredWidth();
                maxWidth = Math.max(w, maxWidth);
            }
            int width = Math.max(maxWidth, (int) (parentWidth * 0.5) - 2 * mMenuHorizontalPadding);
            listView.setPadding(mMenuHorizontalPadding, mMenuVerticalPadding,
                    mMenuHorizontalPadding, mMenuVerticalPadding);

            setWidth(width);
            setWidth(width + 2 * mMenuHorizontalPadding);
            setHorizontalOffset(getAnchorView().getWidth() - mGlobalActionsSidePadding - width);
        }