content: package androidx.appcompat.app;
  
  import android.app.Activity;
  import android.app.Dialog;
  import android.content.Context;
  import android.content.res.Configuration;
  import android.content.res.TypedArray;
  import android.graphics.drawable.Drawable;
  import android.util.AttributeSet;
  import android.util.TypedValue;
  import android.view.ContextThemeWrapper;
  import android.view.KeyCharacterMap;
  import android.view.KeyEvent;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.animation.AccelerateInterpolator;
  import android.view.animation.DecelerateInterpolator;
  import android.view.animation.Interpolator;
  import android.widget.SpinnerAdapter;
  import androidx.appcompat.R;
  import androidx.appcompat.app.ActionBar;
  import androidx.appcompat.content.res.AppCompatResources;
  import androidx.appcompat.view.ActionBarPolicy;
  import androidx.appcompat.view.ActionMode;
  import androidx.appcompat.view.SupportMenuInflater;
  import androidx.appcompat.view.ViewPropertyAnimatorCompatSet;
  import androidx.appcompat.view.menu.MenuBuilder;
  import androidx.appcompat.view.menu.MenuPopupHelper;
  import androidx.appcompat.view.menu.SubMenuBuilder;
  import androidx.appcompat.widget.ActionBarContainer;
  import androidx.appcompat.widget.ActionBarContextView;
  import androidx.appcompat.widget.ActionBarOverlayLayout;
  import androidx.appcompat.widget.DecorToolbar;
  import androidx.appcompat.widget.ScrollingTabContainerView;
  import androidx.appcompat.widget.Toolbar;
  import androidx.core.view.ViewCompat;
  import androidx.core.view.ViewPropertyAnimatorCompat;
  import androidx.core.view.ViewPropertyAnimatorListener;
  import androidx.core.view.ViewPropertyAnimatorListenerAdapter;
  import androidx.core.view.ViewPropertyAnimatorUpdateListener;
  import androidx.fragment.app.FragmentActivity;
  import androidx.fragment.app.FragmentTransaction;
  import java.lang.ref.WeakReference;
  import java.util.ArrayList;
  
  public class WindowDecorActionBar extends ActionBar implements ActionBarOverlayLayout.ActionBarVisibilityCallback {
      private static final long FADE_IN_DURATION_MS = 200;
      private static final long FADE_OUT_DURATION_MS = 100;
      private static final int INVALID_POSITION = -1;
      private static final String TAG = "WindowDecorActionBar";
      private static final Interpolator sHideInterpolator = new AccelerateInterpolator();
      private static final Interpolator sShowInterpolator = new DecelerateInterpolator();
      ActionModeImpl mActionMode;
      private Activity mActivity;
      ActionBarContainer mContainerView;
      boolean mContentAnimations = true;
      View mContentView;
      Context mContext;
      ActionBarContextView mContextView;
      private int mCurWindowVisibility = 0;
      ViewPropertyAnimatorCompatSet mCurrentShowAnim;
      DecorToolbar mDecorToolbar;
      ActionMode mDeferredDestroyActionMode;
      ActionMode.Callback mDeferredModeDestroyCallback;
      private boolean mDisplayHomeAsUpSet;
      private boolean mHasEmbeddedTabs;
      boolean mHiddenByApp;
      boolean mHiddenBySystem;
      final ViewPropertyAnimatorListener mHideListener = new ViewPropertyAnimatorListenerAdapter() {
          public void onAnimationEnd(View view) {
              if (WindowDecorActionBar.this.mContentAnimations && WindowDecorActionBar.this.mContentView != null) {
                  WindowDecorActionBar.this.mContentView.setTranslationY(0.0f);
                  WindowDecorActionBar.this.mContainerView.setTranslationY(0.0f);
              }
              WindowDecorActionBar.this.mContainerView.setVisibility(8);
              WindowDecorActionBar.this.mContainerView.setTransitioning(false);
              WindowDecorActionBar.this.mCurrentShowAnim = null;
              WindowDecorActionBar.this.completeDeferredDestroyActionMode();
              if (WindowDecorActionBar.this.mOverlayLayout != null) {
                  ViewCompat.requestApplyInsets(WindowDecorActionBar.this.mOverlayLayout);
              }
          }
      };
      boolean mHideOnContentScroll;
      private boolean mLastMenuVisibility;
      private ArrayList<ActionBar.OnMenuVisibilityListener> mMenuVisibilityListeners = new ArrayList<>();
      private boolean mNowShowing = true;
      ActionBarOverlayLayout mOverlayLayout;
      private int mSavedTabPosition = -1;
      private TabImpl mSelectedTab;
      private boolean mShowHideAnimationEnabled;
      final ViewPropertyAnimatorListener mShowListener = new ViewPropertyAnimatorListenerAdapter() {
          public void onAnimationEnd(View view) {
              WindowDecorActionBar.this.mCurrentShowAnim = null;
              WindowDecorActionBar.this.mContainerView.requestLayout();
          }
      };
      private boolean mShowingForMode;
      ScrollingTabContainerView mTabScrollView;
      private ArrayList<TabImpl> mTabs = new ArrayList<>();
      private Context mThemedContext;
      final ViewPropertyAnimatorUpdateListener mUpdateListener = new ViewPropertyAnimatorUpdateListener() {
          public void onAnimationUpdate(View view) {
              ((View) WindowDecorActionBar.this.mContainerView.getParent()).invalidate();
          }
      };
  
      public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
          private final Context mActionModeContext;
          private ActionMode.Callback mCallback;
          private WeakReference<View> mCustomView;
          private final MenuBuilder mMenu;
  
          public ActionModeImpl(Context context, ActionMode.Callback callback) {
              this.mActionModeContext = context;
              this.mCallback = callback;
              MenuBuilder defaultShowAsAction = new MenuBuilder(context).setDefaultShowAsAction(1);
              this.mMenu = defaultShowAsAction;
              defaultShowAsAction.setCallback(this);
          }
  
          public boolean dispatchOnCreate() {
              this.mMenu.stopDispatchingItemsChanged();
              try {
                  return this.mCallback.onCreateActionMode(this, this.mMenu);
              } finally {
                  this.mMenu.startDispatchingItemsChanged();
              }
          }
  
          public void finish() {
              if (WindowDecorActionBar.this.mActionMode == this) {
                  if (!WindowDecorActionBar.checkShowingFlags(WindowDecorActionBar.this.mHiddenByApp, WindowDecorActionBar.this.mHiddenBySystem, false)) {
                      WindowDecorActionBar.this.mDeferredDestroyActionMode = this;
                      WindowDecorActionBar.this.mDeferredModeDestroyCallback = this.mCallback;
                  } else {
                      this.mCallback.onDestroyActionMode(this);
                  }
                  this.mCallback = null;
                  WindowDecorActionBar.this.animateToMode(false);
                  WindowDecorActionBar.this.mContextView.closeMode();
                  WindowDecorActionBar.this.mOverlayLayout.setHideOnContentScrollEnabled(WindowDecorActionBar.this.mHideOnContentScroll);
                  WindowDecorActionBar.this.mActionMode = null;
              }
          }
  
          public View getCustomView() {
              WeakReference<View> weakReference = this.mCustomView;
              if (weakReference != null) {
                  return (View) weakReference.get();
              }
              return null;
          }
  
          public Menu getMenu() {
              return this.mMenu;
          }
  
          public MenuInflater getMenuInflater() {
              return new SupportMenuInflater(this.mActionModeContext);
          }
  
          public CharSequence getSubtitle() {
              return WindowDecorActionBar.this.mContextView.getSubtitle();
          }
  
          public CharSequence getTitle() {
              return WindowDecorActionBar.this.mContextView.getTitle();
          }
  
          public void invalidate() {
              if (WindowDecorActionBar.this.mActionMode == this) {
                  this.mMenu.stopDispatchingItemsChanged();
                  try {
                      this.mCallback.onPrepareActionMode(this, this.mMenu);
                  } finally {
                      this.mMenu.startDispatchingItemsChanged();
                  }
              }
          }
  
          public boolean isTitleOptional() {
              return WindowDecorActionBar.this.mContextView.isTitleOptional();
          }
  
          public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
          }
  
          public void onCloseSubMenu(SubMenuBuilder menu) {
          }
  
          public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
              ActionMode.Callback callback = this.mCallback;
              if (callback != null) {
                  return callback.onActionItemClicked(this, item);
              }
              return false;
          }
  
          public void onMenuModeChange(MenuBuilder menu) {
              if (this.mCallback != null) {
                  invalidate();
                  WindowDecorActionBar.this.mContextView.showOverflowMenu();
              }
          }
  
          public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
              if (this.mCallback == null) {
                  return false;
              }
              if (!subMenu.hasVisibleItems()) {
                  return true;
              }
              new MenuPopupHelper(WindowDecorActionBar.this.getThemedContext(), subMenu).show();
              return true;
          }
  
          public void setCustomView(View view) {
              WindowDecorActionBar.this.mContextView.setCustomView(view);
              this.mCustomView = new WeakReference<>(view);
          }
  
          public void setSubtitle(int resId) {
              setSubtitle((CharSequence) WindowDecorActionBar.this.mContext.getResources().getString(resId));
          }
  
          public void setSubtitle(CharSequence subtitle) {
              WindowDecorActionBar.this.mContextView.setSubtitle(subtitle);
          }
  
          public void setTitle(int resId) {
              setTitle((CharSequence) WindowDecorActionBar.this.mContext.getResources().getString(resId));
          }
  
          public void setTitle(CharSequence title) {
              WindowDecorActionBar.this.mContextView.setTitle(title);
          }
  
          public void setTitleOptionalHint(boolean titleOptional) {
              super.setTitleOptionalHint(titleOptional);
              WindowDecorActionBar.this.mContextView.setTitleOptional(titleOptional);
          }
      }
  
      public class TabImpl extends ActionBar.Tab {
          private ActionBar.TabListener mCallback;
          private CharSequence mContentDesc;
          private View mCustomView;
          private Drawable mIcon;
          private int mPosition = -1;
          private Object mTag;
          private CharSequence mText;
  
          public TabImpl() {
          }
  
          public ActionBar.TabListener getCallback() {
              return this.mCallback;
          }
  
          public CharSequence getContentDescription() {
              return this.mContentDesc;
          }
  
          public View getCustomView() {
              return this.mCustomView;
          }
  
          public Drawable getIcon() {
              return this.mIcon;
          }
  
          public int getPosition() {
              return this.mPosition;
          }
  
          public Object getTag() {
              return this.mTag;
          }
  
          public CharSequence getText() {
              return this.mText;
          }
  
          public void select() {
              WindowDecorActionBar.this.selectTab(this);
          }
  
          public ActionBar.Tab setContentDescription(int resId) {
              return setContentDescription(WindowDecorActionBar.this.mContext.getResources().getText(resId));
          }
  
          public ActionBar.Tab setContentDescription(CharSequence contentDesc) {
              this.mContentDesc = contentDesc;
              if (this.mPosition >= 0) {
                  WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition);
              }
              return this;
          }
  
          public ActionBar.Tab setCustomView(int layoutResId) {
              return setCustomView(LayoutInflater.from(WindowDecorActionBar.this.getThemedContext()).inflate(layoutResId, (ViewGroup) null));
          }
  
          public ActionBar.Tab setCustomView(View view) {
              this.mCustomView = view;
              if (this.mPosition >= 0) {
                  WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition);
              }
              return this;
          }
  
          public ActionBar.Tab setIcon(int resId) {
              return setIcon(AppCompatResources.getDrawable(WindowDecorActionBar.this.mContext, resId));
          }
  
          public ActionBar.Tab setIcon(Drawable icon) {
              this.mIcon = icon;
              if (this.mPosition >= 0) {
                  WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition);
              }
              return this;
          }
  
          public void setPosition(int position) {
              this.mPosition = position;
          }
  
          public ActionBar.Tab setTabListener(ActionBar.TabListener callback) {
              this.mCallback = callback;
              return this;
          }
  
          public ActionBar.Tab setTag(Object tag) {
              this.mTag = tag;
              return this;
          }
  
          public ActionBar.Tab setText(int resId) {
              return setText(WindowDecorActionBar.this.mContext.getResources().getText(resId));
          }
  
          public ActionBar.Tab setText(CharSequence text) {
              this.mText = text;
              if (this.mPosition >= 0) {
                  WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition);
              }
              return this;
          }
      }
  
      public WindowDecorActionBar(Activity activity, boolean overlayMode) {
          this.mActivity = activity;
          View decorView = activity.getWindow().getDecorView();
          init(decorView);
          if (!overlayMode) {
              this.mContentView = decorView.findViewById(16908290);
          }
      }
  
      public WindowDecorActionBar(Dialog dialog) {
          init(dialog.getWindow().getDecorView());
      }
  
      public WindowDecorActionBar(View layout) {
          init(layout);
      }
  
      static boolean checkShowingFlags(boolean hiddenByApp, boolean hiddenBySystem, boolean showingForMode) {
          if (showingForMode) {
              return true;
          }
          return !hiddenByApp && !hiddenBySystem;
      }
  
      private void cleanupTabs() {
          if (this.mSelectedTab != null) {
              selectTab((ActionBar.Tab) null);
          }
          this.mTabs.clear();
          ScrollingTabContainerView scrollingTabContainerView = this.mTabScrollView;
          if (scrollingTabContainerView != null) {
              scrollingTabContainerView.removeAllTabs();
          }
          this.mSavedTabPosition = -1;
      }
  
      private void configureTab(ActionBar.Tab tab, int position) {
          TabImpl tabImpl = (TabImpl) tab;
          if (tabImpl.getCallback() != null) {
              tabImpl.setPosition(position);
              this.mTabs.add(position, tabImpl);
              int size = this.mTabs.size();
              for (int i = position + 1; i < size; i++) {
                  this.mTabs.get(i).setPosition(i);
              }
              return;
          }
          throw new IllegalStateException("Action Bar Tab must have a Callback");
      }
  
      private void ensureTabsExist() {
          if (this.mTabScrollView == null) {
              ScrollingTabContainerView scrollingTabContainerView = new ScrollingTabContainerView(this.mContext);
              if (this.mHasEmbeddedTabs) {
                  scrollingTabContainerView.setVisibility(0);
                  this.mDecorToolbar.setEmbeddedTabView(scrollingTabContainerView);
              } else {
                  if (getNavigationMode() == 2) {
                      scrollingTabContainerView.setVisibility(0);
                      ActionBarOverlayLayout actionBarOverlayLayout = this.mOverlayLayout;
                      if (actionBarOverlayLayout != null) {
                          ViewCompat.requestApplyInsets(actionBarOverlayLayout);
                      }
                  } else {
                      scrollingTabContainerView.setVisibility(8);
                  }
                  this.mContainerView.setTabContainer(scrollingTabContainerView);
              }
              this.mTabScrollView = scrollingTabContainerView;
          }
      }
  
      private DecorToolbar getDecorToolbar(View view) {
          if (view instanceof DecorToolbar) {
              return (DecorToolbar) view;
          }
          if (view instanceof Toolbar) {
              return ((Toolbar) view).getWrapper();
          }
          throw new IllegalStateException("Can't make a decor toolbar out of " + (view != null ? view.getClass().getSimpleName() : "null"));
      }
  
      private void hideForActionMode() {
          if (this.mShowingForMode) {
              this.mShowingForMode = false;
              ActionBarOverlayLayout actionBarOverlayLayout = this.mOverlayLayout;
              if (actionBarOverlayLayout != null) {
                  actionBarOverlayLayout.setShowingForActionMode(false);
              }
              updateVisibility(false);
          }
      }
  
      private void init(View decor) {
          ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(R.id.decor_content_parent);
          this.mOverlayLayout = actionBarOverlayLayout;
          if (actionBarOverlayLayout != null) {
              actionBarOverlayLayout.setActionBarVisibilityCallback(this);
          }
          this.mDecorToolbar = getDecorToolbar(decor.findViewById(R.id.action_bar));
          this.mContextView = (ActionBarContextView) decor.findViewById(R.id.action_context_bar);
          ActionBarContainer actionBarContainer = (ActionBarContainer) decor.findViewById(R.id.action_bar_container);
          this.mContainerView = actionBarContainer;
          DecorToolbar decorToolbar = this.mDecorToolbar;
          if (decorToolbar == null || this.mContextView == null || actionBarContainer == null) {
              throw new IllegalStateException(getClass().getSimpleName() + " can only be used with a compatible window decor layout");
          }
          this.mContext = decorToolbar.getContext();
          boolean z = (this.mDecorToolbar.getDisplayOptions() & 4) != 0;
          if (z) {
              this.mDisplayHomeAsUpSet = true;
          }
          ActionBarPolicy actionBarPolicy = ActionBarPolicy.get(this.mContext);
          setHomeButtonEnabled(actionBarPolicy.enableHomeButtonByDefault() || z);
          setHasEmbeddedTabs(actionBarPolicy.hasEmbeddedTabs());
          TypedArray obtainStyledAttributes = this.mContext.obtainStyledAttributes((AttributeSet) null, R.styleable.ActionBar, R.attr.actionBarStyle, 0);
          if (obtainStyledAttributes.getBoolean(R.styleable.ActionBar_hideOnContentScroll, false)) {
              setHideOnContentScrollEnabled(true);
          }
          int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.ActionBar_elevation, 0);
          if (dimensionPixelSize != 0) {
              setElevation((float) dimensionPixelSize);
          }
          obtainStyledAttributes.recycle();
      }
  
      private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) {
          this.mHasEmbeddedTabs = hasEmbeddedTabs;
          if (!hasEmbeddedTabs) {
              this.mDecorToolbar.setEmbeddedTabView((ScrollingTabContainerView) null);
              this.mContainerView.setTabContainer(this.mTabScrollView);
          } else {
              this.mContainerView.setTabContainer((ScrollingTabContainerView) null);
              this.mDecorToolbar.setEmbeddedTabView(this.mTabScrollView);
          }
          boolean z = true;
          boolean z2 = getNavigationMode() == 2;
          ScrollingTabContainerView scrollingTabContainerView = this.mTabScrollView;
          if (scrollingTabContainerView != null) {
              if (z2) {
                  scrollingTabContainerView.setVisibility(0);
                  ActionBarOverlayLayout actionBarOverlayLayout = this.mOverlayLayout;
                  if (actionBarOverlayLayout != null) {
                      ViewCompat.requestApplyInsets(actionBarOverlayLayout);
                  }
              } else {
                  scrollingTabContainerView.setVisibility(8);
              }
          }
          this.mDecorToolbar.setCollapsible(!this.mHasEmbeddedTabs && z2);
          ActionBarOverlayLayout actionBarOverlayLayout2 = this.mOverlayLayout;
          if (this.mHasEmbeddedTabs || !z2) {
              z = false;
          }
          actionBarOverlayLayout2.setHasNonEmbeddedTabs(z);
      }
  
      private boolean shouldAnimateContextView() {
          return ViewCompat.isLaidOut(this.mContainerView);
      }
  
      private void showForActionMode() {
          if (!this.mShowingForMode) {
              this.mShowingForMode = true;
              ActionBarOverlayLayout actionBarOverlayLayout = this.mOverlayLayout;
              if (actionBarOverlayLayout != null) {
                  actionBarOverlayLayout.setShowingForActionMode(true);
              }
              updateVisibility(false);
          }
      }
  
      private void updateVisibility(boolean fromSystem) {
          if (checkShowingFlags(this.mHiddenByApp, this.mHiddenBySystem, this.mShowingForMode)) {
              if (!this.mNowShowing) {
                  this.mNowShowing = true;
                  doShow(fromSystem);
              }
          } else if (this.mNowShowing) {
              this.mNowShowing = false;
              doHide(fromSystem);
          }
      }
  
      public void addOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener) {
          this.mMenuVisibilityListeners.add(listener);
      }
  
      public void addTab(ActionBar.Tab tab) {
          addTab(tab, this.mTabs.isEmpty());
      }
  
      public void addTab(ActionBar.Tab tab, int position) {
          addTab(tab, position, this.mTabs.isEmpty());
      }
  
      public void addTab(ActionBar.Tab tab, int position, boolean setSelected) {
          ensureTabsExist();
          this.mTabScrollView.addTab(tab, position, setSelected);
          configureTab(tab, position);
          if (setSelected) {
              selectTab(tab);
          }
      }
  
      public void addTab(ActionBar.Tab tab, boolean setSelected) {
          ensureTabsExist();
          this.mTabScrollView.addTab(tab, setSelected);
          configureTab(tab, this.mTabs.size());
          if (setSelected) {
              selectTab(tab);
          }
      }
  
      public void animateToMode(boolean toActionMode) {
          ViewPropertyAnimatorCompat viewPropertyAnimatorCompat;
          ViewPropertyAnimatorCompat viewPropertyAnimatorCompat2;
          if (toActionMode) {
              showForActionMode();
          } else {
              hideForActionMode();
          }
          if (shouldAnimateContextView()) {
              if (toActionMode) {
                  viewPropertyAnimatorCompat2 = this.mDecorToolbar.setupAnimatorToVisibility(4, FADE_OUT_DURATION_MS);
                  viewPropertyAnimatorCompat = this.mContextView.setupAnimatorToVisibility(0, FADE_IN_DURATION_MS);
              } else {
                  viewPropertyAnimatorCompat = this.mDecorToolbar.setupAnimatorToVisibility(0, FADE_IN_DURATION_MS);
                  viewPropertyAnimatorCompat2 = this.mContextView.setupAnimatorToVisibility(8, FADE_OUT_DURATION_MS);
              }
              ViewPropertyAnimatorCompatSet viewPropertyAnimatorCompatSet = new ViewPropertyAnimatorCompatSet();
              viewPropertyAnimatorCompatSet.playSequentially(viewPropertyAnimatorCompat2, viewPropertyAnimatorCompat);
              viewPropertyAnimatorCompatSet.start();
          } else if (toActionMode) {
              this.mDecorToolbar.setVisibility(4);
              this.mContextView.setVisibility(0);
          } else {
              this.mDecorToolbar.setVisibility(0);
              this.mContextView.setVisibility(8);
          }
      }
  
      public boolean collapseActionView() {
          DecorToolbar decorToolbar = this.mDecorToolbar;
          if (decorToolbar == null || !decorToolbar.hasExpandedActionView()) {
              return false;
          }
          this.mDecorToolbar.collapseActionView();
          return true;
      }
  
      /* access modifiers changed from: package-private */
      public void completeDeferredDestroyActionMode() {
          ActionMode.Callback callback = this.mDeferredModeDestroyCallback;
          if (callback != null) {
              callback.onDestroyActionMode(this.mDeferredDestroyActionMode);
              this.mDeferredDestroyActionMode = null;
              this.mDeferredModeDestroyCallback = null;
          }
      }
  
      public void dispatchMenuVisibilityChanged(boolean isVisible) {
          if (isVisible != this.mLastMenuVisibility) {
              this.mLastMenuVisibility = isVisible;
              int size = this.mMenuVisibilityListeners.size();
              for (int i = 0; i < size; i++) {
                  this.mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible);
              }
          }
      }
  
      public void doHide(boolean fromSystem) {
          View view;
          ViewPropertyAnimatorCompatSet viewPropertyAnimatorCompatSet = this.mCurrentShowAnim;
          if (viewPropertyAnimatorCompatSet != null) {
              viewPropertyAnimatorCompatSet.cancel();
          }
          if (this.mCurWindowVisibility != 0 || (!this.mShowHideAnimationEnabled && !fromSystem)) {
              this.mHideListener.onAnimationEnd((View) null);
              return;
          }
          this.mContainerView.setAlpha(1.0f);
          this.mContainerView.setTransitioning(true);
          ViewPropertyAnimatorCompatSet viewPropertyAnimatorCompatSet2 = new ViewPropertyAnimatorCompatSet();
          float f = (float) (-this.mContainerView.getHeight());
          if (fromSystem) {
              int[] iArr = {0, 0};
              this.mContainerView.getLocationInWindow(iArr);
              f -= (float) iArr[1];
          }
          ViewPropertyAnimatorCompat translationY = ViewCompat.animate(this.mContainerView).translationY(f);
          translationY.setUpdateListener(this.mUpdateListener);
          viewPropertyAnimatorCompatSet2.play(translationY);
          if (this.mContentAnimations && (view = this.mContentView) != null) {
              viewPropertyAnimatorCompatSet2.play(ViewCompat.animate(view).translationY(f));
          }
          viewPropertyAnimatorCompatSet2.setInterpolator(sHideInterpolator);
          viewPropertyAnimatorCompatSet2.setDuration(250);
          viewPropertyAnimatorCompatSet2.setListener(this.mHideListener);
          this.mCurrentShowAnim = viewPropertyAnimatorCompatSet2;
          viewPropertyAnimatorCompatSet2.start();
      }
  
      public void doShow(boolean fromSystem) {
          View view;
          View view2;
          ViewPropertyAnimatorCompatSet viewPropertyAnimatorCompatSet = this.mCurrentShowAnim;
          if (viewPropertyAnimatorCompatSet != null) {
              viewPropertyAnimatorCompatSet.cancel();
          }
          this.mContainerView.setVisibility(0);
          if (this.mCurWindowVisibility != 0 || (!this.mShowHideAnimationEnabled && !fromSystem)) {
              this.mContainerView.setAlpha(1.0f);
              this.mContainerView.setTranslationY(0.0f);
              if (this.mContentAnimations && (view = this.mContentView) != null) {
                  view.setTranslationY(0.0f);
              }
              this.mShowListener.onAnimationEnd((View) null);
          } else {
              this.mContainerView.setTranslationY(0.0f);
              float f = (float) (-this.mContainerView.getHeight());
              if (fromSystem) {
                  int[] iArr = {0, 0};
                  this.mContainerView.getLocationInWindow(iArr);
                  f -= (float) iArr[1];
              }
              this.mContainerView.setTranslationY(f);
              ViewPropertyAnimatorCompatSet viewPropertyAnimatorCompatSet2 = new ViewPropertyAnimatorCompatSet();
              ViewPropertyAnimatorCompat translationY = ViewCompat.animate(this.mContainerView).translationY(0.0f);
              translationY.setUpdateListener(this.mUpdateListener);
              viewPropertyAnimatorCompatSet2.play(translationY);
              if (this.mContentAnimations && (view2 = this.mContentView) != null) {
                  view2.setTranslationY(f);
                  viewPropertyAnimatorCompatSet2.play(ViewCompat.animate(this.mContentView).translationY(0.0f));
              }
              viewPropertyAnimatorCompatSet2.setInterpolator(sShowInterpolator);
              viewPropertyAnimatorCompatSet2.setDuration(250);
              viewPropertyAnimatorCompatSet2.setListener(this.mShowListener);
              this.mCurrentShowAnim = viewPropertyAnimatorCompatSet2;
              viewPropertyAnimatorCompatSet2.start();
          }
          ActionBarOverlayLayout actionBarOverlayLayout = this.mOverlayLayout;
          if (actionBarOverlayLayout != null) {
              ViewCompat.requestApplyInsets(actionBarOverlayLayout);
          }
      }
  
      public void enableContentAnimations(boolean enabled) {
          this.mContentAnimations = enabled;
      }
  
      public View getCustomView() {
          return this.mDecorToolbar.getCustomView();
      }
  
      public int getDisplayOptions() {
          return this.mDecorToolbar.getDisplayOptions();
      }
  
      public float getElevation() {
          return ViewCompat.getElevation(this.mContainerView);
      }
  
      public int getHeight() {
          return this.mContainerView.getHeight();
      }
  
      public int getHideOffset() {
          return this.mOverlayLayout.getActionBarHideOffset();
      }
  
      public int getNavigationItemCount() {
          switch (this.mDecorToolbar.getNavigationMode()) {
              case 1:
                  return this.mDecorToolbar.getDropdownItemCount();
              case 2:
                  return this.mTabs.size();
              default:
                  return 0;
          }
      }
  
      public int getNavigationMode() {
          return this.mDecorToolbar.getNavigationMode();
      }
  
      public int getSelectedNavigationIndex() {
          switch (this.mDecorToolbar.getNavigationMode()) {
              case 1:
                  return this.mDecorToolbar.getDropdownSelectedPosition();
              case 2:
                  TabImpl tabImpl = this.mSelectedTab;
                  if (tabImpl != null) {
                      return tabImpl.getPosition();
                  }
                  return -1;
              default:
                  return -1;
          }
      }
  
      public ActionBar.Tab getSelectedTab() {
          return this.mSelectedTab;
      }
  
      public CharSequence getSubtitle() {
          return this.mDecorToolbar.getSubtitle();
      }
  
      public ActionBar.Tab getTabAt(int index) {
          return this.mTabs.get(index);
      }
  
      public int getTabCount() {
          return this.mTabs.size();
      }
  
      public Context getThemedContext() {
          if (this.mThemedContext == null) {
              TypedValue typedValue = new TypedValue();
              this.mContext.getTheme().resolveAttribute(R.attr.actionBarWidgetTheme, typedValue, true);
              int i = typedValue.resourceId;
              if (i != 0) {
                  this.mThemedContext = new ContextThemeWrapper(this.mContext, i);
              } else {
                  this.mThemedContext = this.mContext;
              }
          }
          return this.mThemedContext;
      }
  
      public CharSequence getTitle() {
          return this.mDecorToolbar.getTitle();
      }
  
      public boolean hasIcon() {
          return this.mDecorToolbar.hasIcon();
      }
  
      public boolean hasLogo() {
          return this.mDecorToolbar.hasLogo();
      }
  
      public void hide() {
          if (!this.mHiddenByApp) {
              this.mHiddenByApp = true;
              updateVisibility(false);
          }
      }
  
      public void hideForSystem() {
          if (!this.mHiddenBySystem) {
              this.mHiddenBySystem = true;
              updateVisibility(true);
          }
      }
  
      public boolean isHideOnContentScrollEnabled() {
          return this.mOverlayLayout.isHideOnContentScrollEnabled();
      }
  
      public boolean isShowing() {
          int height = getHeight();
          return this.mNowShowing && (height == 0 || getHideOffset() < height);
      }
  
      public boolean isTitleTruncated() {
          DecorToolbar decorToolbar = this.mDecorToolbar;
          return decorToolbar != null && decorToolbar.isTitleTruncated();
      }
  
      public ActionBar.Tab newTab() {
          return new TabImpl();
      }
  
      public void onConfigurationChanged(Configuration newConfig) {
          setHasEmbeddedTabs(ActionBarPolicy.get(this.mContext).hasEmbeddedTabs());
      }
  
      public void onContentScrollStarted() {
          ViewPropertyAnimatorCompatSet viewPropertyAnimatorCompatSet = this.mCurrentShowAnim;
          if (viewPropertyAnimatorCompatSet != null) {
              viewPropertyAnimatorCompatSet.cancel();
              this.mCurrentShowAnim = null;
          }
      }
  
      public void onContentScrollStopped() {
      }
  
      public boolean onKeyShortcut(int keyCode, KeyEvent event) {
          Menu menu;
          ActionModeImpl actionModeImpl = this.mActionMode;
          if (actionModeImpl == null || (menu = actionModeImpl.getMenu()) == null) {
              return false;
          }
          boolean z = true;
          if (KeyCharacterMap.load(event != null ? event.getDeviceId() : -1).getKeyboardType() == 1) {
              z = false;
          }
          menu.setQwertyMode(z);
          return menu.performShortcut(keyCode, event, 0);
      }
  
      public void onWindowVisibilityChanged(int visibility) {
          this.mCurWindowVisibility = visibility;
      }
  
      public void removeAllTabs() {
          cleanupTabs();
      }
  
      public void removeOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener) {
          this.mMenuVisibilityListeners.remove(listener);
      }
  
      public void removeTab(ActionBar.Tab tab) {
          removeTabAt(tab.getPosition());
      }
  
      public void removeTabAt(int position) {
          if (this.mTabScrollView != null) {
              TabImpl tabImpl = this.mSelectedTab;
              int position2 = tabImpl != null ? tabImpl.getPosition() : this.mSavedTabPosition;
              this.mTabScrollView.removeTabAt(position);
              TabImpl remove = this.mTabs.remove(position);
              if (remove != null) {
                  remove.setPosition(-1);
              }
              int size = this.mTabs.size();
              for (int i = position; i < size; i++) {
                  this.mTabs.get(i).setPosition(i);
              }
              if (position2 == position) {
                  selectTab(this.mTabs.isEmpty() ? null : this.mTabs.get(Math.max(0, position - 1)));
              }
          }
      }
  
      public boolean requestFocus() {
          ViewGroup viewGroup = this.mDecorToolbar.getViewGroup();
          if (viewGroup == null || viewGroup.hasFocus()) {
              return false;
          }
          viewGroup.requestFocus();
          return true;
      }
  
      public void selectTab(ActionBar.Tab tab) {
          int i = -1;
          if (getNavigationMode() != 2) {
              if (tab != null) {
                  i = tab.getPosition();
              }
              this.mSavedTabPosition = i;
              return;
          }
          FragmentTransaction disallowAddToBackStack = (!(this.mActivity instanceof FragmentActivity) || this.mDecorToolbar.getViewGroup().isInEditMode()) ? null : ((FragmentActivity) this.mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
          TabImpl tabImpl = this.mSelectedTab;
          if (tabImpl != tab) {
              ScrollingTabContainerView scrollingTabContainerView = this.mTabScrollView;
              if (tab != null) {
                  i = tab.getPosition();
              }
              scrollingTabContainerView.setTabSelected(i);
              TabImpl tabImpl2 = this.mSelectedTab;
              if (tabImpl2 != null) {
                  tabImpl2.getCallback().onTabUnselected(this.mSelectedTab, disallowAddToBackStack);
              }
              TabImpl tabImpl3 = (TabImpl) tab;
              this.mSelectedTab = tabImpl3;
              if (tabImpl3 != null) {
                  tabImpl3.getCallback().onTabSelected(this.mSelectedTab, disallowAddToBackStack);
              }
          } else if (tabImpl != null) {
              tabImpl.getCallback().onTabReselected(this.mSelectedTab, disallowAddToBackStack);
              this.mTabScrollView.animateToTab(tab.getPosition());
          }
          if (disallowAddToBackStack != null && !disallowAddToBackStack.isEmpty()) {
              disallowAddToBackStack.commit();
          }
      }
  
      public void setBackgroundDrawable(Drawable d) {
          this.mContainerView.setPrimaryBackground(d);
      }
  
      public void setCustomView(int resId) {
          setCustomView(LayoutInflater.from(getThemedContext()).inflate(resId, this.mDecorToolbar.getViewGroup(), false));
      }
  
      public void setCustomView(View view) {
          this.mDecorToolbar.setCustomView(view);
      }
  
      public void setCustomView(View view, ActionBar.LayoutParams layoutParams) {
          view.setLayoutParams(layoutParams);
          this.mDecorToolbar.setCustomView(view);
      }
  
      public void setDefaultDisplayHomeAsUpEnabled(boolean enable) {
          if (!this.mDisplayHomeAsUpSet) {
              setDisplayHomeAsUpEnabled(enable);
          }
      }
  
      public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
          setDisplayOptions(showHomeAsUp ? 4 : 0, 4);
      }
  
      public void setDisplayOptions(int options) {
          if ((options & 4) != 0) {
              this.mDisplayHomeAsUpSet = true;
          }
          this.mDecorToolbar.setDisplayOptions(options);
      }
  
      public void setDisplayOptions(int options, int mask) {
          int displayOptions = this.mDecorToolbar.getDisplayOptions();
          if ((mask & 4) != 0) {
              this.mDisplayHomeAsUpSet = true;
          }
          this.mDecorToolbar.setDisplayOptions((options & mask) | ((~mask) & displayOptions));
      }
  
      public void setDisplayShowCustomEnabled(boolean showCustom) {
          setDisplayOptions(showCustom ? 16 : 0, 16);
      }
  
      public void setDisplayShowHomeEnabled(boolean showHome) {
          setDisplayOptions(showHome ? 2 : 0, 2);
      }
  
      public void setDisplayShowTitleEnabled(boolean showTitle) {
          setDisplayOptions(showTitle ? 8 : 0, 8);
      }
  
      public void setDisplayUseLogoEnabled(boolean useLogo) {
          setDisplayOptions(useLogo, 1);
      }
  
      public void setElevation(float elevation) {
          ViewCompat.setElevation(this.mContainerView, elevation);
      }
  
      public void setHideOffset(int offset) {
          if (offset == 0 || this.mOverlayLayout.isInOverlayMode()) {
              this.mOverlayLayout.setActionBarHideOffset(offset);
              return;
          }
          throw new IllegalStateException("Action bar must be in overlay mode (Window.FEATURE_OVERLAY_ACTION_BAR) to set a non-zero hide offset");
      }
  
      public void setHideOnContentScrollEnabled(boolean hideOnContentScroll) {
          if (!hideOnContentScroll || this.mOverlayLayout.isInOverlayMode()) {
              this.mHideOnContentScroll = hideOnContentScroll;
              this.mOverlayLayout.setHideOnContentScrollEnabled(hideOnContentScroll);
              return;
          }
          throw new IllegalStateException("Action bar must be in overlay mode (Window.FEATURE_OVERLAY_ACTION_BAR) to enable hide on content scroll");
      }
  
      public void setHomeActionContentDescription(int resId) {
          this.mDecorToolbar.setNavigationContentDescription(resId);
      }
  
      public void setHomeActionContentDescription(CharSequence description) {
          this.mDecorToolbar.setNavigationContentDescription(description);
      }
  
      public void setHomeAsUpIndicator(int resId) {
          this.mDecorToolbar.setNavigationIcon(resId);
      }
  
      public void setHomeAsUpIndicator(Drawable indicator) {
          this.mDecorToolbar.setNavigationIcon(indicator);
      }
  
      public void setHomeButtonEnabled(boolean enable) {
          this.mDecorToolbar.setHomeButtonEnabled(enable);
      }
  
      public void setIcon(int resId) {
          this.mDecorToolbar.setIcon(resId);
      }
  
      public void setIcon(Drawable icon) {
          this.mDecorToolbar.setIcon(icon);
      }
  
      public void setListNavigationCallbacks(SpinnerAdapter adapter, ActionBar.OnNavigationListener callback) {
          this.mDecorToolbar.setDropdownParams(adapter, new NavItemSelectedListener(callback));
      }
  
      public void setLogo(int resId) {
          this.mDecorToolbar.setLogo(resId);
      }
  
      public void setLogo(Drawable logo) {
          this.mDecorToolbar.setLogo(logo);
      }
  
      public void setNavigationMode(int mode) {
          ActionBarOverlayLayout actionBarOverlayLayout;
          int navigationMode = this.mDecorToolbar.getNavigationMode();
          switch (navigationMode) {
              case 2:
                  this.mSavedTabPosition = getSelectedNavigationIndex();
                  selectTab((ActionBar.Tab) null);
                  this.mTabScrollView.setVisibility(8);
                  break;
          }
          if (!(navigationMode == mode || this.mHasEmbeddedTabs || (actionBarOverlayLayout = this.mOverlayLayout) == null)) {
              ViewCompat.requestApplyInsets(actionBarOverlayLayout);
          }
          this.mDecorToolbar.setNavigationMode(mode);
          boolean z = false;
          switch (mode) {
              case 2:
                  ensureTabsExist();
                  this.mTabScrollView.setVisibility(0);
                  int i = this.mSavedTabPosition;
                  if (i != -1) {
                      setSelectedNavigationItem(i);
                      this.mSavedTabPosition = -1;
                      break;
                  }
                  break;
          }
          this.mDecorToolbar.setCollapsible(mode == 2 && !this.mHasEmbeddedTabs);
          ActionBarOverlayLayout actionBarOverlayLayout2 = this.mOverlayLayout;
          if (mode == 2 && !this.mHasEmbeddedTabs) {
              z = true;
          }
          actionBarOverlayLayout2.setHasNonEmbeddedTabs(z);
      }
  
      public void setSelectedNavigationItem(int position) {
          switch (this.mDecorToolbar.getNavigationMode()) {
              case 1:
                  this.mDecorToolbar.setDropdownSelectedPosition(position);
                  return;
              case 2:
                  selectTab(this.mTabs.get(position));
                  return;
              default:
                  throw new IllegalStateException("setSelectedNavigationIndex not valid for current navigation mode");
          }
      }
  
      public void setShowHideAnimationEnabled(boolean enabled) {
          ViewPropertyAnimatorCompatSet viewPropertyAnimatorCompatSet;
          this.mShowHideAnimationEnabled = enabled;
          if (!enabled && (viewPropertyAnimatorCompatSet = this.mCurrentShowAnim) != null) {
              viewPropertyAnimatorCompatSet.cancel();
          }
      }
  
      public void setSplitBackgroundDrawable(Drawable d) {
      }
  
      public void setStackedBackgroundDrawable(Drawable d) {
          this.mContainerView.setStackedBackground(d);
      }
  
      public void setSubtitle(int resId) {
          setSubtitle((CharSequence) this.mContext.getString(resId));
      }
  
      public void setSubtitle(CharSequence subtitle) {
          this.mDecorToolbar.setSubtitle(subtitle);
      }
  
      public void setTitle(int resId) {
          setTitle((CharSequence) this.mContext.getString(resId));
      }
  
      public void setTitle(CharSequence title) {
          this.mDecorToolbar.setTitle(title);
      }
  
      public void setWindowTitle(CharSequence title) {
          this.mDecorToolbar.setWindowTitle(title);
      }
  
      public void show() {
          if (this.mHiddenByApp) {
              this.mHiddenByApp = false;
              updateVisibility(false);
          }
      }
  
      public void showForSystem() {
          if (this.mHiddenBySystem) {
              this.mHiddenBySystem = false;
              updateVisibility(true);
          }
      }
  
      public ActionMode startActionMode(ActionMode.Callback callback) {
          ActionModeImpl actionModeImpl = this.mActionMode;
          if (actionModeImpl != null) {
              actionModeImpl.finish();
          }
          this.mOverlayLayout.setHideOnContentScrollEnabled(false);
          this.mContextView.killMode();
          ActionModeImpl actionModeImpl2 = new ActionModeImpl(this.mContextView.getContext(), callback);
          if (!actionModeImpl2.dispatchOnCreate()) {
              return null;
          }
          this.mActionMode = actionModeImpl2;
          actionModeImpl2.invalidate();
          this.mContextView.initForMode(actionModeImpl2);
          animateToMode(true);
          return actionModeImpl2;
      }
  }
  