@Override public void dispatchInvalidateOptionsMenu() { if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); if (mMenu == null) { Context context = mActivity; if (mActionBar != null) { TypedValue outValue = new TypedValue(); mActivity.getTheme().resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true); if (outValue.resourceId != 0) { // We are unable to test if this is the same as our current theme // so we just wrap it and hope that if the attribute was specified // then the user is intentionally specifying an alternate theme. context = new ContextThemeWrapper(context, outValue.resourceId); } } mMenu = new MenuBuilder(context); mMenu.setCallback(mMenuBuilderCallback); } mMenu.stopDispatchingItemsChanged(); mMenu.clear(); if (!callbackCreateOptionsMenu(mMenu)) { mMenu = null; if (mActionBar != null) { if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu] setting action bar menu to null"); mActionBar.setMenu(null, mMenuPresenterCallback); } return; } if (!callbackPrepareOptionsMenu(mMenu)) { if (mActionBar != null) { if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu] setting action bar menu to null"); mActionBar.setMenu(null, mMenuPresenterCallback); } mMenu.startDispatchingItemsChanged(); return; } // TODO figure out KeyEvent? See PhoneWindow#preparePanel KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC); mMenu.startDispatchingItemsChanged(); if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu] setting action bar menu to " + mMenu); mActionBar.setMenu(mMenu, mMenuPresenterCallback); }
@Override public void dispatchStop() { if (DEBUG) Log.d(TAG, "[dispatchStop]"); if (aActionBar != null) { aActionBar.setShowHideAnimationEnabled(false); } }
@Override public void dispatchPostResume() { if (DEBUG) Log.d(TAG, "[dispatchPostResume]"); if (aActionBar != null) { aActionBar.setShowHideAnimationEnabled(true); } }
@Override public void dispatchConfigurationChanged(Configuration newConfig) { if (DEBUG) Log.d(TAG, "[dispatchConfigurationChanged] newConfig: " + newConfig); if (aActionBar != null) { aActionBar.onConfigurationChanged(newConfig); } }
@Override public void dispatchPanelClosed(int featureId, android.view.Menu menu) { if (DEBUG) Log.d(TAG, "[dispatchPanelClosed] featureId: " + featureId + ", menu: " + menu); if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { if (aActionBar != null) { aActionBar.dispatchMenuVisibilityChanged(false); } } }
@Override public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) { if (DEBUG) Log.d(TAG, "[dispatchMenuOpened] featureId: " + featureId + ", menu: " + menu); if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { if (aActionBar != null) { aActionBar.dispatchMenuVisibilityChanged(true); } return true; } return false; }
@Override public ActionMode startActionMode(ActionMode.Callback callback) { if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); if (mActionMode != null) { mActionMode.finish(); } final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); ActionMode mode = null; // Emulate Activity's onWindowStartingActionMode: initActionBar(); if (aActionBar != null) { mode = aActionBar.startActionMode(wrappedCallback); } if (mode != null) { mActionMode = mode; } else { if (mActionModeView == null) { ViewStub stub = (ViewStub) mDecor.findViewById(R.id.abs__action_mode_bar_stub); if (stub != null) { mActionModeView = (ActionBarContextView) stub.inflate(); } } if (mActionModeView != null) { mActionModeView.killMode(); mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true); if (callback.onCreateActionMode(mode, mode.getMenu())) { mode.invalidate(); mActionModeView.initForMode(mode); mActionModeView.setVisibility(View.VISIBLE); mActionMode = mode; mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } else { mActionMode = null; } } } if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) { ((OnActionModeStartedListener) mActivity).onActionModeStarted(mActionMode); } return mActionMode; }
@Override protected Context getThemedContext() { return aActionBar.getThemedContext(); }