diff options
author | Adam Powell <adamp@google.com> | 2011-07-11 21:19:59 -0700 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2011-07-12 11:35:15 -0700 |
commit | 11ed1d6cae9214335c92ac38498a4e6c7d1c8324 (patch) | |
tree | 0d86d48c169298f22b3b3d2f1d23df790bf2cf2d /policy | |
parent | eb982f3991c43da52bc202929b1f70d2e3320d1c (diff) | |
download | frameworks_base-11ed1d6cae9214335c92ac38498a4e6c7d1c8324.zip frameworks_base-11ed1d6cae9214335c92ac38498a4e6c7d1c8324.tar.gz frameworks_base-11ed1d6cae9214335c92ac38498a4e6c7d1c8324.tar.bz2 |
Fix bugs around restoring submenu state after activity teardown/restore
Change-Id: I6cb5b3cad39b141dff84b8e0ca62f8f0a76a03b1
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindow.java | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 7f6327d..dff0556 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -1555,9 +1555,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // We restore the panel if it was last open; we skip it if it // now is open, to avoid a race condition if the user immediately // opens it when we are resuming. - if ((st != null) && !st.isOpen && st.wasLastOpen) { - st.isInExpandedMode = st.wasLastExpanded; - openPanel(st, null); + if (st != null) { + st.applyFrozenState(); + if (!st.isOpen && st.wasLastOpen) { + st.isInExpandedMode = st.wasLastExpanded; + openPanel(st, null); + } } } } @@ -2235,6 +2238,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } mActionModePopup = null; } + + PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false); + if (st != null && st.menu != null) { + st.menu.close(); + } } @Override @@ -3046,46 +3054,33 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { getIconMenuView(cb); // Need this initialized to know where our offset goes - boolean init = false; if (expandedMenuPresenter == null) { expandedMenuPresenter = new ListMenuPresenter( com.android.internal.R.layout.list_menu_item_layout, com.android.internal.R.style.Theme_ExpandedMenu); expandedMenuPresenter.setCallback(cb); + expandedMenuPresenter.setId(com.android.internal.R.id.list_menu_presenter); menu.addMenuPresenter(expandedMenuPresenter); - init = true; } expandedMenuPresenter.setItemIndexOffset(iconMenuPresenter.getNumActualItemsShown()); MenuView result = expandedMenuPresenter.getMenuView(decorView); - if (init && frozenMenuState != null) { - expandedMenuPresenter.restoreHierarchyState(frozenMenuState); - // Once we initialize the expanded menu we're done with the frozen state - // since we will have also restored any icon menu state. - frozenMenuState = null; - } - return result; } MenuView getIconMenuView(MenuPresenter.Callback cb) { if (menu == null) return null; - boolean init = false; if (iconMenuPresenter == null) { iconMenuPresenter = new IconMenuPresenter(); iconMenuPresenter.setCallback(cb); + iconMenuPresenter.setId(com.android.internal.R.id.icon_menu_presenter); menu.addMenuPresenter(iconMenuPresenter); - init = true; } MenuView result = iconMenuPresenter.getMenuView(decorView); - if (init && frozenMenuState != null) { - iconMenuPresenter.restoreHierarchyState(frozenMenuState); - } - return result; } @@ -3097,12 +3092,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (menu != null) { savedState.menuState = new Bundle(); - if (iconMenuPresenter != null) { - iconMenuPresenter.saveHierarchyState(savedState.menuState); - } - if (expandedMenuPresenter != null) { - expandedMenuPresenter.saveHierarchyState(savedState.menuState); - } + menu.savePresenterStates(savedState.menuState); } return savedState; @@ -3127,6 +3117,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { decorView = null; } + void applyFrozenState() { + if (menu != null && frozenMenuState != null) { + menu.restorePresenterStates(frozenMenuState); + frozenMenuState = null; + } + } + private static class SavedState implements Parcelable { int featureId; boolean isOpen; |