Merge "Adding small animation features" into jb-mr2-dev
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index d1db230..b99b39a 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -36,7 +36,6 @@
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 @@
private boolean mWasHomeEnabled; // Was it enabled before action view expansion?
private MenuBuilder mOptionsMenu;
+ private boolean mMenuPrepared;
private ActionBarContextView mContextView;
@@ -164,7 +164,10 @@
private final OnClickListener mUpClickListener = new OnClickListener() {
public void onClick(View v) {
- mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
+ if (mMenuPrepared) {
+ // Only invoke the window callback if the options menu has been initialized.
+ mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
+ }
}
};
@@ -402,6 +405,10 @@
mCallback = callback;
}
+ public void setMenuPrepared() {
+ mMenuPrepared = true;
+ }
+
public void setMenu(Menu menu, MenuPresenter.Callback cb) {
if (menu == mOptionsMenu) return;
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index ad5e20b..6b28e8e 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -380,6 +380,15 @@
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 @@
}
}
- if (mActionBar != null) {
+ if (isActionBarMenu && mActionBar != null) {
if (mActionMenuPresenterCallback == null) {
mActionMenuPresenterCallback = new ActionMenuPresenterCallback();
}
@@ -405,7 +414,7 @@
// 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 @@
}
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);