Source code
package android.support.v7.app;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBarDrawerToggle.Delegate;
import android.support.v7.appcompat.R;
import android.support.v7.internal.view.SupportMenuInflater;
import android.support.v7.internal.view.WindowCallbackWrapper;
import android.support.v7.internal.view.menu.MenuBuilder;
import android.support.v7.internal.widget.TintTypedArray;
import android.support.v7.view.ActionMode;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.Window;
import android.view.Window.Callback;
abstract class AppCompatDelegateImplBase extends AppCompatDelegate {
ActionBar mActionBar;
final AppCompatCallback mAppCompatCallback;
final Callback mAppCompatWindowCallback;
final Context mContext;
boolean mHasActionBar;
private boolean mIsDestroyed;
boolean mIsFloating;
MenuInflater mMenuInflater;
final Callback mOriginalWindowCallback = this.mWindow.getCallback();
boolean mOverlayActionBar;
boolean mOverlayActionMode;
boolean mThemeRead;
private CharSequence mTitle;
final Window mWindow;
boolean mWindowNoTitle;
private class ActionBarDrawableToggleImpl implements Delegate {
private ActionBarDrawableToggleImpl() {
}
public Drawable getThemeUpIndicator() {
TintTypedArray a = TintTypedArray.obtainStyledAttributes(getActionBarThemedContext(), null, new int[]{R.attr.homeAsUpIndicator});
Drawable result = a.getDrawable(0);
a.recycle();
return result;
}
public Context getActionBarThemedContext() {
return AppCompatDelegateImplBase.this.getActionBarThemedContext();
}
public boolean isNavigationVisible() {
ActionBar ab = AppCompatDelegateImplBase.this.getSupportActionBar();
return (ab == null || (ab.getDisplayOptions() & 4) == 0) ? false : true;
}
public void setActionBarUpIndicator(Drawable upDrawable, int contentDescRes) {
ActionBar ab = AppCompatDelegateImplBase.this.getSupportActionBar();
if (ab != null) {
ab.setHomeAsUpIndicator(upDrawable);
ab.setHomeActionContentDescription(contentDescRes);
}
}
public void setActionBarDescription(int contentDescRes) {
ActionBar ab = AppCompatDelegateImplBase.this.getSupportActionBar();
if (ab != null) {
ab.setHomeActionContentDescription(contentDescRes);
}
}
}
class AppCompatWindowCallbackBase extends WindowCallbackWrapper {
AppCompatWindowCallbackBase(Callback callback) {
super(callback);
}
public boolean dispatchKeyEvent(KeyEvent event) {
return AppCompatDelegateImplBase.this.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
}
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
return super.dispatchKeyShortcutEvent(event) || AppCompatDelegateImplBase.this.onKeyShortcut(event.getKeyCode(), event);
}
public boolean onCreatePanelMenu(int featureId, Menu menu) {
if (featureId != 0 || (menu instanceof MenuBuilder)) {
return super.onCreatePanelMenu(featureId, menu);
}
return false;
}
public void onContentChanged() {
}
public boolean onPreparePanel(int featureId, View view, Menu menu) {
MenuBuilder mb = menu instanceof MenuBuilder ? (MenuBuilder) menu : null;
if (featureId == 0 && mb == null) {
return false;
}
if (mb != null) {
mb.setOverrideVisibleItems(true);
}
boolean handled = super.onPreparePanel(featureId, view, menu);
if (mb == null) {
return handled;
}
mb.setOverrideVisibleItems(false);
return handled;
}
public boolean onMenuOpened(int featureId, Menu menu) {
super.onMenuOpened(featureId, menu);
AppCompatDelegateImplBase.this.onMenuOpened(featureId, menu);
return true;
}
public void onPanelClosed(int featureId, Menu menu) {
super.onPanelClosed(featureId, menu);
AppCompatDelegateImplBase.this.onPanelClosed(featureId, menu);
}
}
abstract boolean dispatchKeyEvent(KeyEvent keyEvent);
abstract void initWindowDecorActionBar();
abstract boolean onKeyShortcut(int i, KeyEvent keyEvent);
abstract boolean onMenuOpened(int i, Menu menu);
abstract void onPanelClosed(int i, Menu menu);
abstract void onTitleChanged(CharSequence charSequence);
abstract ActionMode startSupportActionModeFromWindow(ActionMode.Callback callback);
AppCompatDelegateImplBase(Context context, Window window, AppCompatCallback callback) {
this.mContext = context;
this.mWindow = window;
this.mAppCompatCallback = callback;
if (this.mOriginalWindowCallback instanceof AppCompatWindowCallbackBase) {
throw new IllegalStateException("AppCompat has already installed itself into the Window");
}
this.mAppCompatWindowCallback = wrapWindowCallback(this.mOriginalWindowCallback);
this.mWindow.setCallback(this.mAppCompatWindowCallback);
}
Callback wrapWindowCallback(Callback callback) {
return new AppCompatWindowCallbackBase(callback);
}
public ActionBar getSupportActionBar() {
initWindowDecorActionBar();
return this.mActionBar;
}
final ActionBar peekSupportActionBar() {
return this.mActionBar;
}
public MenuInflater getMenuInflater() {
if (this.mMenuInflater == null) {
initWindowDecorActionBar();
this.mMenuInflater = new SupportMenuInflater(this.mActionBar != null ? this.mActionBar.getThemedContext() : this.mContext);
}
return this.mMenuInflater;
}
public final Delegate getDrawerToggleDelegate() {
return new ActionBarDrawableToggleImpl();
}
final Context getActionBarThemedContext() {
Context context = null;
ActionBar ab = getSupportActionBar();
if (ab != null) {
context = ab.getThemedContext();
}
if (context == null) {
return this.mContext;
}
return context;
}
public final void onDestroy() {
this.mIsDestroyed = true;
}
public void setHandleNativeActionModesEnabled(boolean enabled) {
}
public boolean isHandleNativeActionModesEnabled() {
return false;
}
final boolean isDestroyed() {
return this.mIsDestroyed;
}
final Callback getWindowCallback() {
return this.mWindow.getCallback();
}
public final void setTitle(CharSequence title) {
this.mTitle = title;
onTitleChanged(title);
}
final CharSequence getTitle() {
if (this.mOriginalWindowCallback instanceof Activity) {
return ((Activity) this.mOriginalWindowCallback).getTitle();
}
return this.mTitle;
}
}