Fix options list menu when Toolbar doesn't have items
When using a ToolbarActionBar, and there are 0 non-actions
items, it will return null in onCreatePanelView. This then
means that the 'window' will show it's list menu. As the
'window' doesn't know what is an action item or not,
it shows all items.
This CL fixes it by disabling the window list menu view
when a ToolbarActionBar is used. ToolbarActionBar's own
list menu view is unaffected.
BUG: 21718389
Change-Id: I8e8cb7915cc27abcf1e06a0ef09ac14129c4adce
diff --git a/v7/appcompat/src/android/support/v7/app/AppCompatDelegateImplV7.java b/v7/appcompat/src/android/support/v7/app/AppCompatDelegateImplV7.java
index abb665f..f4af232 100644
--- a/v7/appcompat/src/android/support/v7/app/AppCompatDelegateImplV7.java
+++ b/v7/appcompat/src/android/support/v7/app/AppCompatDelegateImplV7.java
@@ -1105,8 +1105,10 @@
mDecorContentParent.setMenuPrepared();
}
- if (st.createdPanelView == null) {
- // Init the panel state's menu--return false if init failed
+ if (st.createdPanelView == null &&
+ (!isActionBarMenu || !(peekSupportActionBar() instanceof ToolbarActionBar))) {
+ // Since ToolbarActionBar handles the list options menu itself, we only want to
+ // init this menu panel if we're not using a TAB.
if (st.menu == null || st.refreshMenuContent) {
if (st.menu == null) {
if (!initializePanelMenu(st) || (st.menu == null)) {