From 67056f7a5a7a8aef8b0cd6259f4c95cba9f7694d Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Thu, 21 May 2020 09:56:19 -0400 Subject: [PATCH] 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 --- .../globalactions/GlobalActionsPopupMenu.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsPopupMenu.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsPopupMenu.java index 02ea25128993a..d02f831a2bc92 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsPopupMenu.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsPopupMenu.java @@ -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); - child.measure(widthSpec, MeasureSpec.UNSPECIFIED); - int width = Math.max(child.getMeasuredWidth(), (int) (parentWidth * 0.5)); - + (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 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); }