am 1a4c4334
: Merge "Fix bug 5396097 - menu theme consistency" into ics-mr0
* commit '1a4c4334f02152c96cfc71136dc31085826c6894': Fix bug 5396097 - menu theme consistency
This commit is contained in:
@ -31,9 +31,6 @@ import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -71,8 +68,8 @@ public class ActionMenuPresenter extends BaseMenuPresenter
|
||||
final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback();
|
||||
int mOpenSubMenuId;
|
||||
|
||||
public ActionMenuPresenter() {
|
||||
super(com.android.internal.R.layout.action_menu_layout,
|
||||
public ActionMenuPresenter(Context context) {
|
||||
super(context, com.android.internal.R.layout.action_menu_layout,
|
||||
com.android.internal.R.layout.action_menu_item_layout);
|
||||
}
|
||||
|
||||
@ -98,7 +95,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter
|
||||
int width = mWidthLimit;
|
||||
if (mReserveOverflow) {
|
||||
if (mOverflowButton == null) {
|
||||
mOverflowButton = new OverflowMenuButton(mContext);
|
||||
mOverflowButton = new OverflowMenuButton(mSystemContext);
|
||||
final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||
mOverflowButton.measure(spec, spec);
|
||||
}
|
||||
@ -215,7 +212,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter
|
||||
|
||||
if (hasOverflow) {
|
||||
if (mOverflowButton == null) {
|
||||
mOverflowButton = new OverflowMenuButton(mContext);
|
||||
mOverflowButton = new OverflowMenuButton(mSystemContext);
|
||||
}
|
||||
ViewGroup parent = (ViewGroup) mOverflowButton.getParent();
|
||||
if (parent != mMenuView) {
|
||||
|
@ -29,8 +29,10 @@ import java.util.ArrayList;
|
||||
* be reused if possible when items change.
|
||||
*/
|
||||
public abstract class BaseMenuPresenter implements MenuPresenter {
|
||||
protected Context mSystemContext;
|
||||
protected Context mContext;
|
||||
protected MenuBuilder mMenu;
|
||||
protected LayoutInflater mSystemInflater;
|
||||
protected LayoutInflater mInflater;
|
||||
private Callback mCallback;
|
||||
|
||||
@ -44,10 +46,13 @@ public abstract class BaseMenuPresenter implements MenuPresenter {
|
||||
/**
|
||||
* Construct a new BaseMenuPresenter.
|
||||
*
|
||||
* @param context Context for generating system-supplied views
|
||||
* @param menuLayoutRes Layout resource ID for the menu container view
|
||||
* @param itemLayoutRes Layout resource ID for a single item view
|
||||
*/
|
||||
public BaseMenuPresenter(int menuLayoutRes, int itemLayoutRes) {
|
||||
public BaseMenuPresenter(Context context, int menuLayoutRes, int itemLayoutRes) {
|
||||
mSystemContext = context;
|
||||
mSystemInflater = LayoutInflater.from(context);
|
||||
mMenuLayoutRes = menuLayoutRes;
|
||||
mItemLayoutRes = itemLayoutRes;
|
||||
}
|
||||
@ -62,7 +67,7 @@ public abstract class BaseMenuPresenter implements MenuPresenter {
|
||||
@Override
|
||||
public MenuView getMenuView(ViewGroup root) {
|
||||
if (mMenuView == null) {
|
||||
mMenuView = (MenuView) mInflater.inflate(mMenuLayoutRes, root, false);
|
||||
mMenuView = (MenuView) mSystemInflater.inflate(mMenuLayoutRes, root, false);
|
||||
mMenuView.initialize(mMenu);
|
||||
updateMenuView(true);
|
||||
}
|
||||
@ -138,7 +143,7 @@ public abstract class BaseMenuPresenter implements MenuPresenter {
|
||||
* @return The new item view
|
||||
*/
|
||||
public MenuView.ItemView createItemView(ViewGroup parent) {
|
||||
return (MenuView.ItemView) mInflater.inflate(mItemLayoutRes, parent, false);
|
||||
return (MenuView.ItemView) mSystemInflater.inflate(mItemLayoutRes, parent, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,8 +43,8 @@ public class IconMenuPresenter extends BaseMenuPresenter {
|
||||
private static final String VIEWS_TAG = "android:menu:icon";
|
||||
private static final String OPEN_SUBMENU_KEY = "android:menu:icon:submenu";
|
||||
|
||||
public IconMenuPresenter() {
|
||||
super(com.android.internal.R.layout.icon_menu_layout,
|
||||
public IconMenuPresenter(Context context) {
|
||||
super(context, com.android.internal.R.layout.icon_menu_layout,
|
||||
com.android.internal.R.layout.icon_menu_item_layout);
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
|
||||
});
|
||||
|
||||
final MenuBuilder menu = (MenuBuilder) mode.getMenu();
|
||||
mActionMenuPresenter = new ActionMenuPresenter();
|
||||
mActionMenuPresenter = new ActionMenuPresenter(mContext);
|
||||
mActionMenuPresenter.setReserveOverflow(true);
|
||||
|
||||
final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
|
||||
|
@ -373,7 +373,7 @@ public class ActionBarView extends AbsActionBarView {
|
||||
}
|
||||
}
|
||||
if (mActionMenuPresenter == null) {
|
||||
mActionMenuPresenter = new ActionMenuPresenter();
|
||||
mActionMenuPresenter = new ActionMenuPresenter(mContext);
|
||||
mActionMenuPresenter.setCallback(cb);
|
||||
mActionMenuPresenter.setId(com.android.internal.R.id.action_menu_presenter);
|
||||
mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
|
||||
|
@ -1084,8 +1084,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
|
||||
MenuView menuView = st.isInListMode()
|
||||
? st.getListMenuView(mPanelMenuPresenterCallback)
|
||||
: st.getIconMenuView(mPanelMenuPresenterCallback);
|
||||
? st.getListMenuView(getContext(), mPanelMenuPresenterCallback)
|
||||
: st.getIconMenuView(getContext(), mPanelMenuPresenterCallback);
|
||||
|
||||
st.shownPanelView = (View) menuView;
|
||||
|
||||
@ -3251,11 +3251,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
MenuView getListMenuView(MenuPresenter.Callback cb) {
|
||||
MenuView getListMenuView(Context context, MenuPresenter.Callback cb) {
|
||||
if (menu == null) return null;
|
||||
|
||||
if (!isCompact) {
|
||||
getIconMenuView(cb); // Need this initialized to know where our offset goes
|
||||
getIconMenuView(context, cb); // Need this initialized to know where our offset goes
|
||||
}
|
||||
|
||||
if (listMenuPresenter == null) {
|
||||
@ -3275,11 +3275,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
return result;
|
||||
}
|
||||
|
||||
MenuView getIconMenuView(MenuPresenter.Callback cb) {
|
||||
MenuView getIconMenuView(Context context, MenuPresenter.Callback cb) {
|
||||
if (menu == null) return null;
|
||||
|
||||
if (iconMenuPresenter == null) {
|
||||
iconMenuPresenter = new IconMenuPresenter();
|
||||
iconMenuPresenter = new IconMenuPresenter(context);
|
||||
iconMenuPresenter.setCallback(cb);
|
||||
iconMenuPresenter.setId(com.android.internal.R.id.icon_menu_presenter);
|
||||
menu.addMenuPresenter(iconMenuPresenter);
|
||||
|
Reference in New Issue
Block a user