Loading core/java/android/app/Fragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -883,7 +883,7 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener public void setHasOptionsMenu(boolean hasMenu) { if (mHasMenu != hasMenu) { mHasMenu = hasMenu; if (isAdded() && !isHidden()) { if (isAdded() && !isHidden() && isResumed()) { mActivity.invalidateOptionsMenu(); } } Loading core/java/android/app/FragmentManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -978,7 +978,7 @@ final class FragmentManagerImpl extends FragmentManager { } } if (mNeedMenuInvalidate && mActivity != null) { if (mNeedMenuInvalidate && mActivity != null && mCurState == Fragment.RESUMED) { mActivity.invalidateOptionsMenu(); mNeedMenuInvalidate = false; } Loading core/java/com/android/internal/view/menu/ActionMenuView.java +12 −10 Original line number Diff line number Diff line Loading @@ -36,8 +36,8 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo private boolean mReserveOverflow; private ActionMenuPresenter mPresenter; private boolean mUpdateContentsBeforeMeasure; private boolean mFormatItems; private int mFormatItemsWidth; private int mMinCellSize; private int mMeasuredExtraWidth; Loading Loading @@ -70,20 +70,22 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo } } @Override public void requestLayout() { // Layout can influence how many action items fit. mUpdateContentsBeforeMeasure = true; super.requestLayout(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // If we've been given an exact size to match, apply special formatting during layout. final boolean wasFormatted = mFormatItems; mFormatItems = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; if (mUpdateContentsBeforeMeasure && mMenu != null) { if (wasFormatted != mFormatItems) { mFormatItemsWidth = 0; // Reset this when switching modes } // Special formatting can change whether items can fit as action buttons. // Kick the menu and update presenters when this changes. final int widthSize = MeasureSpec.getMode(widthMeasureSpec); if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) { mFormatItemsWidth = widthSize; mMenu.onItemsChanged(true); mUpdateContentsBeforeMeasure = false; } if (mFormatItems) { Loading core/java/com/android/internal/view/menu/MenuBuilder.java +2 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Parcelable; import android.util.Log; import android.util.SparseArray; import android.view.ActionProvider; import android.view.ContextMenu.ContextMenuInfo; Loading @@ -47,7 +48,7 @@ import java.util.concurrent.CopyOnWriteArrayList; * standard menu UI. */ public class MenuBuilder implements Menu { private static final String LOGTAG = "MenuBuilder"; private static final String TAG = "MenuBuilder"; private static final String PRESENTER_KEY = "android:menu:presenters"; private static final String ACTION_VIEW_STATES_KEY = "android:menu:actionviewstates"; Loading policy/src/com/android/internal/policy/impl/PhoneWindow.java +6 −4 Original line number Diff line number Diff line Loading @@ -374,13 +374,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { st.menu.startDispatchingItemsChanged(); return false; } st.menu.startDispatchingItemsChanged(); // Set the proper keymap KeyCharacterMap kmap = KeyCharacterMap.load( event != null ? event.getDeviceId() : KeyCharacterMap.VIRTUAL_KEYBOARD); st.qwertyMode = kmap.getKeyboardType() != KeyCharacterMap.NUMERIC; st.menu.setQwertyMode(st.qwertyMode); st.menu.startDispatchingItemsChanged(); } // Set other state Loading Loading @@ -454,8 +454,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (featureId == FEATURE_OPTIONS_PANEL && mActionBar != null && mActionBar.isOverflowReserved()) { if (mActionBar.getVisibility() == View.VISIBLE) { // Invalidate the options menu, we want a prepare event that the app can respond to. invalidatePanelMenu(FEATURE_OPTIONS_PANEL); mActionBar.showOverflowMenu(); } } else { Loading Loading @@ -664,6 +662,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (savedActionViewStates.size() > 0) { st.frozenActionViewState = savedActionViewStates; } // This will be started again when the panel is prepared. st.menu.stopDispatchingItemsChanged(); st.menu.clear(); } st.refreshMenuContent = true; Loading Loading @@ -2657,7 +2657,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // being called in the middle of onCreate or similar. mDecor.post(new Runnable() { public void run() { if (!isDestroyed()) { // Invalidate if the panel menu hasn't been created before this. PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false); if (!isDestroyed() && (st == null || st.menu == null)) { invalidatePanelMenu(FEATURE_ACTION_BAR); } } Loading Loading
core/java/android/app/Fragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -883,7 +883,7 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener public void setHasOptionsMenu(boolean hasMenu) { if (mHasMenu != hasMenu) { mHasMenu = hasMenu; if (isAdded() && !isHidden()) { if (isAdded() && !isHidden() && isResumed()) { mActivity.invalidateOptionsMenu(); } } Loading
core/java/android/app/FragmentManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -978,7 +978,7 @@ final class FragmentManagerImpl extends FragmentManager { } } if (mNeedMenuInvalidate && mActivity != null) { if (mNeedMenuInvalidate && mActivity != null && mCurState == Fragment.RESUMED) { mActivity.invalidateOptionsMenu(); mNeedMenuInvalidate = false; } Loading
core/java/com/android/internal/view/menu/ActionMenuView.java +12 −10 Original line number Diff line number Diff line Loading @@ -36,8 +36,8 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo private boolean mReserveOverflow; private ActionMenuPresenter mPresenter; private boolean mUpdateContentsBeforeMeasure; private boolean mFormatItems; private int mFormatItemsWidth; private int mMinCellSize; private int mMeasuredExtraWidth; Loading Loading @@ -70,20 +70,22 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo } } @Override public void requestLayout() { // Layout can influence how many action items fit. mUpdateContentsBeforeMeasure = true; super.requestLayout(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // If we've been given an exact size to match, apply special formatting during layout. final boolean wasFormatted = mFormatItems; mFormatItems = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; if (mUpdateContentsBeforeMeasure && mMenu != null) { if (wasFormatted != mFormatItems) { mFormatItemsWidth = 0; // Reset this when switching modes } // Special formatting can change whether items can fit as action buttons. // Kick the menu and update presenters when this changes. final int widthSize = MeasureSpec.getMode(widthMeasureSpec); if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) { mFormatItemsWidth = widthSize; mMenu.onItemsChanged(true); mUpdateContentsBeforeMeasure = false; } if (mFormatItems) { Loading
core/java/com/android/internal/view/menu/MenuBuilder.java +2 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Parcelable; import android.util.Log; import android.util.SparseArray; import android.view.ActionProvider; import android.view.ContextMenu.ContextMenuInfo; Loading @@ -47,7 +48,7 @@ import java.util.concurrent.CopyOnWriteArrayList; * standard menu UI. */ public class MenuBuilder implements Menu { private static final String LOGTAG = "MenuBuilder"; private static final String TAG = "MenuBuilder"; private static final String PRESENTER_KEY = "android:menu:presenters"; private static final String ACTION_VIEW_STATES_KEY = "android:menu:actionviewstates"; Loading
policy/src/com/android/internal/policy/impl/PhoneWindow.java +6 −4 Original line number Diff line number Diff line Loading @@ -374,13 +374,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { st.menu.startDispatchingItemsChanged(); return false; } st.menu.startDispatchingItemsChanged(); // Set the proper keymap KeyCharacterMap kmap = KeyCharacterMap.load( event != null ? event.getDeviceId() : KeyCharacterMap.VIRTUAL_KEYBOARD); st.qwertyMode = kmap.getKeyboardType() != KeyCharacterMap.NUMERIC; st.menu.setQwertyMode(st.qwertyMode); st.menu.startDispatchingItemsChanged(); } // Set other state Loading Loading @@ -454,8 +454,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (featureId == FEATURE_OPTIONS_PANEL && mActionBar != null && mActionBar.isOverflowReserved()) { if (mActionBar.getVisibility() == View.VISIBLE) { // Invalidate the options menu, we want a prepare event that the app can respond to. invalidatePanelMenu(FEATURE_OPTIONS_PANEL); mActionBar.showOverflowMenu(); } } else { Loading Loading @@ -664,6 +662,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (savedActionViewStates.size() > 0) { st.frozenActionViewState = savedActionViewStates; } // This will be started again when the panel is prepared. st.menu.stopDispatchingItemsChanged(); st.menu.clear(); } st.refreshMenuContent = true; Loading Loading @@ -2657,7 +2657,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // being called in the middle of onCreate or similar. mDecor.post(new Runnable() { public void run() { if (!isDestroyed()) { // Invalidate if the panel menu hasn't been created before this. PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false); if (!isDestroyed() && (st == null || st.menu == null)) { invalidatePanelMenu(FEATURE_ACTION_BAR); } } Loading