am 728827ff
: Merge "Uphold common ordering expectations around action bar Home/Up dispatch" into jb-mr2-dev
* commit '728827ff472b72ed7a86971ed8e35a01ce5bc8bf': Uphold common ordering expectations around action bar Home/Up dispatch
This commit is contained in:
@ -36,7 +36,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@ -125,6 +124,7 @@ public class ActionBarView extends AbsActionBarView {
|
||||
private boolean mWasHomeEnabled; // Was it enabled before action view expansion?
|
||||
|
||||
private MenuBuilder mOptionsMenu;
|
||||
private boolean mMenuPrepared;
|
||||
|
||||
private ActionBarContextView mContextView;
|
||||
|
||||
@ -164,8 +164,11 @@ public class ActionBarView extends AbsActionBarView {
|
||||
|
||||
private final OnClickListener mUpClickListener = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
if (mMenuPrepared) {
|
||||
// Only invoke the window callback if the options menu has been initialized.
|
||||
mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public ActionBarView(Context context, AttributeSet attrs) {
|
||||
@ -402,6 +405,10 @@ public class ActionBarView extends AbsActionBarView {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public void setMenuPrepared() {
|
||||
mMenuPrepared = true;
|
||||
}
|
||||
|
||||
public void setMenu(Menu menu, MenuPresenter.Callback cb) {
|
||||
if (menu == mOptionsMenu) return;
|
||||
|
||||
|
@ -380,6 +380,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
st.createdPanelView = cb.onCreatePanelView(st.featureId);
|
||||
}
|
||||
|
||||
final boolean isActionBarMenu =
|
||||
(st.featureId == FEATURE_OPTIONS_PANEL || st.featureId == FEATURE_ACTION_BAR);
|
||||
|
||||
if (isActionBarMenu && mActionBar != null) {
|
||||
// Enforce ordering guarantees around events so that the action bar never
|
||||
// dispatches menu-related events before the panel is prepared.
|
||||
mActionBar.setMenuPrepared();
|
||||
}
|
||||
|
||||
if (st.createdPanelView == null) {
|
||||
// Init the panel state's menu--return false if init failed
|
||||
if (st.menu == null || st.refreshMenuContent) {
|
||||
@ -389,7 +398,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
if (mActionBar != null) {
|
||||
if (isActionBarMenu && mActionBar != null) {
|
||||
if (mActionMenuPresenterCallback == null) {
|
||||
mActionMenuPresenterCallback = new ActionMenuPresenterCallback();
|
||||
}
|
||||
@ -405,7 +414,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
// Ditch the menu created above
|
||||
st.setMenu(null);
|
||||
|
||||
if (mActionBar != null) {
|
||||
if (isActionBarMenu && mActionBar != null) {
|
||||
// Don't show it in the action bar either
|
||||
mActionBar.setMenu(null, mActionMenuPresenterCallback);
|
||||
}
|
||||
@ -430,7 +439,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
|
||||
if (!cb.onPreparePanel(st.featureId, st.createdPanelView, st.menu)) {
|
||||
if (mActionBar != null) {
|
||||
if (isActionBarMenu && mActionBar != null) {
|
||||
// The app didn't want to show the menu for now but it still exists.
|
||||
// Clear it out of the action bar.
|
||||
mActionBar.setMenu(null, mActionMenuPresenterCallback);
|
||||
|
Reference in New Issue
Block a user