Loading core/java/android/view/MenuInflater.java +8 −15 Original line number Diff line number Diff line Loading @@ -54,23 +54,13 @@ public class MenuInflater { private Context mContext; private int mDefaultShowAsAction; /** * Constructs a menu inflater. * * @see Activity#getMenuInflater() */ public MenuInflater(Context context) { this(context, MenuItem.SHOW_AS_ACTION_NEVER); } /** * @hide used internally to change the default showAsAction setting in action modes */ public MenuInflater(Context context, int defaultShowAsAction) { mContext = context; mDefaultShowAsAction = defaultShowAsAction; } /** Loading Loading @@ -256,6 +246,7 @@ public class MenuInflater { * - 0: never * - 1: ifRoom * - 2: always * - -1: Safe sentinel for "no value". */ private int itemShowAsAction; Loading @@ -272,7 +263,6 @@ public class MenuInflater { public MenuState(final Menu menu) { this.menu = menu; this.itemShowAsAction = mDefaultShowAsAction; resetGroup(); } Loading Loading @@ -333,7 +323,7 @@ public class MenuInflater { itemChecked = a.getBoolean(com.android.internal.R.styleable.MenuItem_checked, defaultItemChecked); itemVisible = a.getBoolean(com.android.internal.R.styleable.MenuItem_visible, groupVisible); itemEnabled = a.getBoolean(com.android.internal.R.styleable.MenuItem_enabled, groupEnabled); itemShowAsAction = a.getInt(com.android.internal.R.styleable.MenuItem_showAsAction, 0); itemShowAsAction = a.getInt(com.android.internal.R.styleable.MenuItem_showAsAction, -1); itemListenerMethodName = a.getString(com.android.internal.R.styleable.MenuItem_onClick); a.recycle(); Loading @@ -357,8 +347,11 @@ public class MenuInflater { .setTitleCondensed(itemTitleCondensed) .setIcon(itemIconResId) .setAlphabeticShortcut(itemAlphabeticShortcut) .setNumericShortcut(itemNumericShortcut) .setShowAsAction(itemShowAsAction); .setNumericShortcut(itemNumericShortcut); if (itemShowAsAction >= 0) { item.setShowAsAction(itemShowAsAction); } if (itemListenerMethodName != null) { if (mContext.isRestricted()) { Loading core/java/com/android/internal/app/ActionBarImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -429,13 +429,14 @@ public class ActionBarImpl extends ActionBar { public ActionModeImpl(ActionMode.Callback callback) { mCallback = callback; mMenu = new MenuBuilder(mActionView.getContext()); mMenu = new MenuBuilder(mActionView.getContext()) .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mMenu.setCallback(this); } @Override public MenuInflater getMenuInflater() { return new MenuInflater(mContext, MenuItem.SHOW_AS_ACTION_IF_ROOM); return new MenuInflater(mContext); } @Override Loading core/java/com/android/internal/view/StandaloneActionMode.java +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call mContextView = view; mCallback = callback; mMenu = new MenuBuilder(context); mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mMenu.setCallback(this); } Loading Loading @@ -112,7 +112,7 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call @Override public MenuInflater getMenuInflater() { return new MenuInflater(mContext, MenuItem.SHOW_AS_ACTION_IF_ROOM); return new MenuInflater(mContext); } public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { Loading core/java/com/android/internal/view/menu/MenuBuilder.java +12 −1 Original line number Diff line number Diff line Loading @@ -170,6 +170,11 @@ public class MenuBuilder implements Menu { */ private boolean mReserveActionOverflow; /** * Default value for how added items should show in the action list. */ private int mDefaultShowAsAction = MenuItem.SHOW_AS_ACTION_NEVER; /** * Current use case is Context Menus: As Views populate the context menu, each one has * extra information that should be passed along. This is the current menu info that Loading Loading @@ -328,6 +333,11 @@ public class MenuBuilder implements Menu { (mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); } public MenuBuilder setDefaultShowAsAction(int defaultShowAsAction) { mDefaultShowAsAction = defaultShowAsAction; return this; } public void setCallback(Callback callback) { mCallback = callback; } Loading Loading @@ -411,7 +421,8 @@ public class MenuBuilder implements Menu { private MenuItem addInternal(int group, int id, int categoryOrder, CharSequence title) { final int ordering = getOrdering(categoryOrder); final MenuItemImpl item = new MenuItemImpl(this, group, id, categoryOrder, ordering, title); final MenuItemImpl item = new MenuItemImpl(this, group, id, categoryOrder, ordering, title, mDefaultShowAsAction); if (mCurrentMenuInfo != null) { // Pass along the current menu info Loading core/java/com/android/internal/view/menu/MenuItemImpl.java +2 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ public final class MenuItemImpl implements MenuItem { * @param title The text to display for the item. */ MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering, CharSequence title) { CharSequence title, int showAsAction) { if (sPrependShortcutLabel == null) { // This is instantiated from the UI thread, so no chance of sync issues Loading @@ -129,6 +129,7 @@ public final class MenuItemImpl implements MenuItem { mCategoryOrder = categoryOrder; mOrdering = ordering; mTitle = title; mShowAsAction = showAsAction; } /** Loading Loading
core/java/android/view/MenuInflater.java +8 −15 Original line number Diff line number Diff line Loading @@ -54,23 +54,13 @@ public class MenuInflater { private Context mContext; private int mDefaultShowAsAction; /** * Constructs a menu inflater. * * @see Activity#getMenuInflater() */ public MenuInflater(Context context) { this(context, MenuItem.SHOW_AS_ACTION_NEVER); } /** * @hide used internally to change the default showAsAction setting in action modes */ public MenuInflater(Context context, int defaultShowAsAction) { mContext = context; mDefaultShowAsAction = defaultShowAsAction; } /** Loading Loading @@ -256,6 +246,7 @@ public class MenuInflater { * - 0: never * - 1: ifRoom * - 2: always * - -1: Safe sentinel for "no value". */ private int itemShowAsAction; Loading @@ -272,7 +263,6 @@ public class MenuInflater { public MenuState(final Menu menu) { this.menu = menu; this.itemShowAsAction = mDefaultShowAsAction; resetGroup(); } Loading Loading @@ -333,7 +323,7 @@ public class MenuInflater { itemChecked = a.getBoolean(com.android.internal.R.styleable.MenuItem_checked, defaultItemChecked); itemVisible = a.getBoolean(com.android.internal.R.styleable.MenuItem_visible, groupVisible); itemEnabled = a.getBoolean(com.android.internal.R.styleable.MenuItem_enabled, groupEnabled); itemShowAsAction = a.getInt(com.android.internal.R.styleable.MenuItem_showAsAction, 0); itemShowAsAction = a.getInt(com.android.internal.R.styleable.MenuItem_showAsAction, -1); itemListenerMethodName = a.getString(com.android.internal.R.styleable.MenuItem_onClick); a.recycle(); Loading @@ -357,8 +347,11 @@ public class MenuInflater { .setTitleCondensed(itemTitleCondensed) .setIcon(itemIconResId) .setAlphabeticShortcut(itemAlphabeticShortcut) .setNumericShortcut(itemNumericShortcut) .setShowAsAction(itemShowAsAction); .setNumericShortcut(itemNumericShortcut); if (itemShowAsAction >= 0) { item.setShowAsAction(itemShowAsAction); } if (itemListenerMethodName != null) { if (mContext.isRestricted()) { Loading
core/java/com/android/internal/app/ActionBarImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -429,13 +429,14 @@ public class ActionBarImpl extends ActionBar { public ActionModeImpl(ActionMode.Callback callback) { mCallback = callback; mMenu = new MenuBuilder(mActionView.getContext()); mMenu = new MenuBuilder(mActionView.getContext()) .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mMenu.setCallback(this); } @Override public MenuInflater getMenuInflater() { return new MenuInflater(mContext, MenuItem.SHOW_AS_ACTION_IF_ROOM); return new MenuInflater(mContext); } @Override Loading
core/java/com/android/internal/view/StandaloneActionMode.java +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call mContextView = view; mCallback = callback; mMenu = new MenuBuilder(context); mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mMenu.setCallback(this); } Loading Loading @@ -112,7 +112,7 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call @Override public MenuInflater getMenuInflater() { return new MenuInflater(mContext, MenuItem.SHOW_AS_ACTION_IF_ROOM); return new MenuInflater(mContext); } public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { Loading
core/java/com/android/internal/view/menu/MenuBuilder.java +12 −1 Original line number Diff line number Diff line Loading @@ -170,6 +170,11 @@ public class MenuBuilder implements Menu { */ private boolean mReserveActionOverflow; /** * Default value for how added items should show in the action list. */ private int mDefaultShowAsAction = MenuItem.SHOW_AS_ACTION_NEVER; /** * Current use case is Context Menus: As Views populate the context menu, each one has * extra information that should be passed along. This is the current menu info that Loading Loading @@ -328,6 +333,11 @@ public class MenuBuilder implements Menu { (mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); } public MenuBuilder setDefaultShowAsAction(int defaultShowAsAction) { mDefaultShowAsAction = defaultShowAsAction; return this; } public void setCallback(Callback callback) { mCallback = callback; } Loading Loading @@ -411,7 +421,8 @@ public class MenuBuilder implements Menu { private MenuItem addInternal(int group, int id, int categoryOrder, CharSequence title) { final int ordering = getOrdering(categoryOrder); final MenuItemImpl item = new MenuItemImpl(this, group, id, categoryOrder, ordering, title); final MenuItemImpl item = new MenuItemImpl(this, group, id, categoryOrder, ordering, title, mDefaultShowAsAction); if (mCurrentMenuInfo != null) { // Pass along the current menu info Loading
core/java/com/android/internal/view/menu/MenuItemImpl.java +2 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ public final class MenuItemImpl implements MenuItem { * @param title The text to display for the item. */ MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering, CharSequence title) { CharSequence title, int showAsAction) { if (sPrependShortcutLabel == null) { // This is instantiated from the UI thread, so no chance of sync issues Loading @@ -129,6 +129,7 @@ public final class MenuItemImpl implements MenuItem { mCategoryOrder = categoryOrder; mOrdering = ordering; mTitle = title; mShowAsAction = showAsAction; } /** Loading