diff options
author | Adam Powell <adamp@google.com> | 2010-11-30 14:09:55 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2010-12-01 13:03:44 -0800 |
commit | 8515ee846bd76aee86ec5ddfcc4dd1e626dd999c (patch) | |
tree | 6129914d14a3995b7fcfaa77a8de8ad3cbba941a /policy/src | |
parent | fff4ab09b6c69e437537f322aaca7829f009ff1d (diff) | |
download | frameworks_base-8515ee846bd76aee86ec5ddfcc4dd1e626dd999c.zip frameworks_base-8515ee846bd76aee86ec5ddfcc4dd1e626dd999c.tar.gz frameworks_base-8515ee846bd76aee86ec5ddfcc4dd1e626dd999c.tar.bz2 |
Fix bug 3240444 - add OnMenuVisibilityListener for action bar.
Fix bug 3180015 - leaking window handles on configuration change for
action bar dropdown menus
Rename ActionBar.NavigationCallback to something more consistent with
the rest of the API.
Change-Id: Ic1fb4c07484c57a72649b30e27d220b18cda6cdf
Diffstat (limited to 'policy/src')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindow.java | 84 |
1 files changed, 80 insertions, 4 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index cd8a065..138dff7 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -160,6 +160,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private ContextMenuBuilder mContextMenu; private MenuDialogHelper mContextMenuHelper; + private ActionButtonSubmenu mActionButtonPopup; + private boolean mClosingActionMenu; private int mVolumeControlStreamType = AudioManager.USE_DEFAULT_STREAM_TYPE; @@ -542,6 +544,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (doCallback) { callOnPanelClosed(st.featureId, st, null); } + } else if (st.featureId == FEATURE_OPTIONS_PANEL && doCallback && + mActionBar != null) { + checkCloseActionMenu(st.menu); } st.isPrepared = false; st.isHandled = false; @@ -563,6 +568,27 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } } + private void checkCloseActionMenu(Menu menu) { + if (mClosingActionMenu) { + return; + } + + boolean closed = false; + mClosingActionMenu = true; + if (mActionBar.isOverflowMenuOpen() && mActionBar.hideOverflowMenu()) { + closed = true; + } + if (mActionButtonPopup != null) { + mActionButtonPopup.dismiss(); + closed = true; + } + Callback cb = getCallback(); + if (cb != null && closed) { + cb.onPanelClosed(FEATURE_ACTION_BAR, menu); + } + mClosingActionMenu = false; + } + @Override public final void togglePanel(int featureId, KeyEvent event) { PanelFeatureState st = getPanelState(featureId, true); @@ -842,7 +868,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // The window manager will give us a valid window token new MenuDialogHelper(subMenu).show(null); } else { - new MenuPopupHelper(getContext(), subMenu).show(); + mActionButtonPopup = new ActionButtonSubmenu(getContext(), subMenu); + mActionButtonPopup.show(); + Callback cb = getCallback(); + if (cb != null) { + cb.onMenuOpened(FEATURE_ACTION_BAR, subMenu); + } } return true; @@ -854,16 +885,21 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private void reopenMenu(boolean toggleMenuMode) { if (mActionBar != null) { + final Callback cb = getCallback(); if (!mActionBar.isOverflowMenuShowing() || !toggleMenuMode) { - final Callback cb = getCallback(); if (cb != null) { final PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true); if (cb.onPreparePanel(FEATURE_OPTIONS_PANEL, st.createdPanelView, st.menu)) { - mActionBar.showOverflowMenu(); + cb.onMenuOpened(FEATURE_ACTION_BAR, st.menu); + mActionBar.openOverflowMenu(); } } } else { mActionBar.hideOverflowMenu(); + if (cb != null) { + final PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true); + cb.onPanelClosed(FEATURE_ACTION_BAR, st.menu); + } } return; } @@ -2042,8 +2078,23 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (cb != null && mFeatureId < 0) { cb.onDetachedFromWindow(); } + + if (mActionButtonPopup != null) { + if (mActionButtonPopup.isShowing()) { + mActionButtonPopup.dismiss(); + } + mActionButtonPopup = null; + } } - + + @Override + protected void onConfigurationChanged(Configuration newConfig) { + if (mActionButtonPopup != null) { + mActionButtonPopup.dismiss(); + post(mActionButtonPopup); + } + } + @Override public void onCloseSystemDialogs(String reason) { if (mFeatureId >= 0) { @@ -2921,4 +2972,29 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { void sendCloseSystemWindows(String reason) { PhoneWindowManager.sendCloseSystemWindows(getContext(), reason); } + + private class ActionButtonSubmenu extends MenuPopupHelper implements Runnable { + private SubMenuBuilder mSubMenu; + + public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) { + super(context, subMenu); + mSubMenu = subMenu; + } + + @Override + public void onDismiss() { + super.onDismiss(); + mSubMenu.getCallback().onCloseSubMenu(mSubMenu); + mActionButtonPopup = null; + } + + @Override + public void run() { + show(); + Callback cb = getCallback(); + if (cb != null) { + cb.onMenuOpened(FEATURE_ACTION_BAR, mSubMenu); + } + } + } } |