Merge "Don't show icons in overlay popup menus." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
203222ea60
@@ -347,14 +347,21 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
|
||||
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
final MenuAdapter adapter = new MenuAdapter(menu, inflater, mOverflowOnly);
|
||||
|
||||
// Apply "force show icon" setting; if the menu being shown is the top level menu, apply the
|
||||
// setting set on this CascadingMenuPopup by its creating code. If it's a submenu, or if no
|
||||
// "force" setting was explicitly set, determine the setting by examining the items.
|
||||
// Apply "force show icon" setting. There are 4 cases:
|
||||
// (1) This is the top level menu. Only add spacing for icons if forced.
|
||||
// (2) This is a submenu. Add spacing if any of the visible menu items has an icon.
|
||||
// (3) This is a top level menu that is not an overflow menu. Add spacing if any of the
|
||||
// visible menu items has an icon.
|
||||
// (4) This is an overflow menu or a top level menu that doesn't have "force" set.
|
||||
// Don't allow spacing.
|
||||
if (!isShowing() && mForceShowIcon) {
|
||||
adapter.setForceShowIcon(mForceShowIcon);
|
||||
} else {
|
||||
adapter.setForceShowIcon(MenuPopup.shouldPreserveIconSpacing(menu));
|
||||
// Case 1
|
||||
adapter.setForceShowIcon(true);
|
||||
} else if (isShowing() || !isShowing() && !mForceShowIcon && !mOverflowOnly) {
|
||||
// Case 2 or 3
|
||||
adapter.setForceShowIcon(MenuPopup.shouldPreserveIconSpacing(menu));
|
||||
}
|
||||
// Case 4: Else, don't allow spacing for icons.
|
||||
|
||||
final int menuWidth = measureIndividualMenuWidth(adapter, null, mContext, mMenuMaxWidth);
|
||||
final MenuPopupWindow popupWindow = createPopupWindow();
|
||||
@@ -734,4 +741,4 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
|
||||
return window.getListView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,11 @@ public abstract class MenuPopup implements ShowableListMenu, MenuPresenter,
|
||||
/**
|
||||
* Returns whether icon spacing needs to be preserved for the given menu, based on whether any
|
||||
* of its items contains an icon.
|
||||
*
|
||||
* NOTE: This should only be used for non-overflow-only menus, because this method does not
|
||||
* take into account whether the menu items are being shown as part of the popup or or being
|
||||
* shown as actions in the action bar.
|
||||
*
|
||||
* @param menu
|
||||
* @return Whether to preserve icon spacing.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user