summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2014-11-04 01:08:39 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-04 01:08:39 +0000
commit9a6d8ae25522f88191e8b7d817c1d4e5816b642b (patch)
tree4f1e1698c77fb9f0c765a62c1e8e1688568a871e
parent5ad076396c43b2d26f9c020f0914623972cadd0e (diff)
parent33996b98787c4625f9cd4a8e38e6a88458773276 (diff)
downloadframeworks_base-9a6d8ae25522f88191e8b7d817c1d4e5816b642b.zip
frameworks_base-9a6d8ae25522f88191e8b7d817c1d4e5816b642b.tar.gz
frameworks_base-9a6d8ae25522f88191e8b7d817c1d4e5816b642b.tar.bz2
am 33996b98: Merge "Support framework menus in ActionBar" into lmp-dev automerge: c23487a
* commit '33996b98787c4625f9cd4a8e38e6a88458773276': Support framework menus in ActionBar
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomActionBarWrapper.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomActionBarWrapper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomActionBarWrapper.java
index f3fc397..f283e34 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomActionBarWrapper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomActionBarWrapper.java
@@ -32,7 +32,6 @@ import com.android.internal.widget.ActionBarView;
import com.android.internal.widget.DecorToolbar;
import com.android.layoutlib.bridge.android.BridgeContext;
import com.android.layoutlib.bridge.impl.ResourceHelper;
-import com.android.resources.ResourceType;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
@@ -49,6 +48,9 @@ import android.widget.ActionMenuPresenter;
import android.widget.Toolbar;
import android.widget.Toolbar_Accessor;
+import static com.android.SdkConstants.ANDROID_NS_NAME_PREFIX;
+import static com.android.resources.ResourceType.MENU;
+
/**
* A common API to access {@link ToolbarActionBar} and {@link WindowDecorActionBar}.
*/
@@ -128,13 +130,24 @@ public abstract class CustomActionBarWrapper {
MenuInflater inflater = new MenuInflater(getActionMenuContext());
MenuBuilder menuBuilder = getMenuBuilder();
for (String name : mCallback.getMenuIdNames()) {
- if (mContext.getRenderResources().getProjectResource(ResourceType.MENU, name)
- != null) {
- int id = mContext.getProjectResourceValue(ResourceType.MENU, name, -1);
- if (id > -1) {
- inflater.inflate(id, menuBuilder);
+ int id = -1;
+ if (name.startsWith(ANDROID_NS_NAME_PREFIX)) {
+ // Framework menu.
+ name = name.substring(ANDROID_NS_NAME_PREFIX.length());
+ if (mContext.getRenderResources().getFrameworkResource(MENU, name) != null) {
+ // We need to check for the existence of the menu first, since getting the id
+ // never returns the default value. It creates a new value if one is not found.
+ id = mContext.getFrameworkResourceValue(MENU, name, -1);
+ }
+ } else {
+ // Project menu.
+ if (mContext.getRenderResources().getProjectResource(MENU, name) != null) {
+ id = mContext.getProjectResourceValue(MENU, name, -1);
}
}
+ if (id > -1) {
+ inflater.inflate(id, menuBuilder);
+ }
}
}