diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2014-05-13 17:40:55 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-13 17:40:55 +0000 |
commit | 5dae7fda38850a5146a6b8a4edbfd9aa96aea484 (patch) | |
tree | 2ff0aa711df76a2b006bd200b408ce1754ac106f /tools | |
parent | b6de60e0020dbed906b1d275de17f8c615b2b242 (diff) | |
parent | 9359dc2e7d6bc671af3fee0c1dc540dd3685365c (diff) | |
download | frameworks_base-5dae7fda38850a5146a6b8a4edbfd9aa96aea484.zip frameworks_base-5dae7fda38850a5146a6b8a4edbfd9aa96aea484.tar.gz frameworks_base-5dae7fda38850a5146a6b8a4edbfd9aa96aea484.tar.bz2 |
am 9359dc2e: am 2d3fa7ba: Support actionProviderClass attribute for menus [DO NOT MERGE]
* commit '9359dc2e7d6bc671af3fee0c1dc540dd3685365c':
Support actionProviderClass attribute for menus [DO NOT MERGE]
Diffstat (limited to 'tools')
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/internal/view/menu/BridgeMenuItemImpl.java | 23 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java | 6 |
2 files changed, 26 insertions, 3 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/internal/view/menu/BridgeMenuItemImpl.java b/tools/layoutlib/bridge/src/com/android/internal/view/menu/BridgeMenuItemImpl.java index 4bef424..cdb839a 100644 --- a/tools/layoutlib/bridge/src/com/android/internal/view/menu/BridgeMenuItemImpl.java +++ b/tools/layoutlib/bridge/src/com/android/internal/view/menu/BridgeMenuItemImpl.java @@ -16,6 +16,12 @@ package com.android.internal.view.menu; +import com.android.layoutlib.bridge.android.BridgeContext; + +import android.content.Context; +import android.view.ContextThemeWrapper; +import android.view.View; + /** * An extension of the {@link MenuItemImpl} to store the view cookie also. */ @@ -27,6 +33,7 @@ public class BridgeMenuItemImpl extends MenuItemImpl { * at the time of rendering. */ private Object viewCookie; + private BridgeContext mContext; /** * Instantiates this menu item. @@ -34,14 +41,28 @@ public class BridgeMenuItemImpl extends MenuItemImpl { BridgeMenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering, CharSequence title, int showAsAction) { super(menu, group, id, categoryOrder, ordering, title, showAsAction); + Context context = menu.getContext(); + if (context instanceof ContextThemeWrapper) { + context = ((ContextThemeWrapper) context).getBaseContext(); + } + if (context instanceof BridgeContext) { + mContext = ((BridgeContext) context); + } } - public Object getViewCookie() { return viewCookie; } public void setViewCookie(Object viewCookie) { + // If the menu item has an associated action provider view, + // directly set the cookie in the view to cookie map stored in BridgeContext. + View actionView = getActionView(); + if (actionView != null && mContext != null) { + mContext.addViewKey(actionView, viewCookie); + // We don't need to add the view cookie to the this item now. But there's no harm in + // storing it, in case we need it in the future. + } this.viewCookie = viewCookie; } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java index 997fca1..97b07c7 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java @@ -26,6 +26,7 @@ import com.android.ide.common.rendering.api.SystemViewCookie; import com.android.internal.R; import com.android.internal.app.ActionBarImpl; import com.android.internal.util.Predicate; +import com.android.internal.view.menu.ActionMenuView; import com.android.internal.view.menu.MenuBuilder; import com.android.internal.view.menu.MenuBuilderAccessor; import com.android.internal.view.menu.MenuItemImpl; @@ -180,8 +181,9 @@ public class ActionBarLayout extends LinearLayout { Predicate<View> overflowMenuButtonTest = new Predicate<View>() { @Override public boolean apply(View view) { - return view.getClass().getName() - .equals("android.widget.ActionMenuPresenter$OverflowMenuButton"); + ViewGroup.LayoutParams lp = view.getLayoutParams(); + return lp instanceof ActionMenuView.LayoutParams && + ((ActionMenuView.LayoutParams) lp).isOverflowButton; } }; View overflowMenu = null; |