Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a6d8ae2 authored by Deepanshu Gupta's avatar Deepanshu Gupta Committed by Android Git Automerger
Browse files

am 33996b98: Merge "Support framework menus in ActionBar" into lmp-dev automerge: c23487aa

* commit '33996b98':
  Support framework menus in ActionBar
parents 5ad07639 33996b98
Loading
Loading
Loading
Loading
+19 −6
Original line number Original line Diff line number Diff line
@@ -32,7 +32,6 @@ import com.android.internal.widget.ActionBarView;
import com.android.internal.widget.DecorToolbar;
import com.android.internal.widget.DecorToolbar;
import com.android.layoutlib.bridge.android.BridgeContext;
import com.android.layoutlib.bridge.android.BridgeContext;
import com.android.layoutlib.bridge.impl.ResourceHelper;
import com.android.layoutlib.bridge.impl.ResourceHelper;
import com.android.resources.ResourceType;


import android.app.ActionBar;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.ActionBar.Tab;
@@ -49,6 +48,9 @@ import android.widget.ActionMenuPresenter;
import android.widget.Toolbar;
import android.widget.Toolbar;
import android.widget.Toolbar_Accessor;
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}.
 * A common API to access {@link ToolbarActionBar} and {@link WindowDecorActionBar}.
 */
 */
@@ -128,15 +130,26 @@ public abstract class CustomActionBarWrapper {
        MenuInflater inflater = new MenuInflater(getActionMenuContext());
        MenuInflater inflater = new MenuInflater(getActionMenuContext());
        MenuBuilder menuBuilder = getMenuBuilder();
        MenuBuilder menuBuilder = getMenuBuilder();
        for (String name : mCallback.getMenuIdNames()) {
        for (String name : mCallback.getMenuIdNames()) {
            if (mContext.getRenderResources().getProjectResource(ResourceType.MENU, name)
            int id = -1;
                    != null) {
            if (name.startsWith(ANDROID_NS_NAME_PREFIX)) {
                int id = mContext.getProjectResourceValue(ResourceType.MENU, name, -1);
                // 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) {
            if (id > -1) {
                inflater.inflate(id, menuBuilder);
                inflater.inflate(id, menuBuilder);
            }
            }
        }
        }
    }
    }
    }


    /**
    /**
     * The context used for the ActionBar and the menus in the ActionBarView.
     * The context used for the ActionBar and the menus in the ActionBarView.