content: package androidx.appcompat.app;
  
  import android.content.Context;
  import android.content.res.Configuration;
  import android.graphics.drawable.Drawable;
  import android.view.KeyCharacterMap;
  import android.view.KeyEvent;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.Window;
  import android.widget.SpinnerAdapter;
  import androidx.appcompat.app.ActionBar;
  import androidx.appcompat.app.AppCompatDelegateImpl;
  import androidx.appcompat.view.menu.MenuBuilder;
  import androidx.appcompat.view.menu.MenuPresenter;
  import androidx.appcompat.widget.DecorToolbar;
  import androidx.appcompat.widget.Toolbar;
  import androidx.appcompat.widget.ToolbarWidgetWrapper;
  import androidx.core.util.Preconditions;
  import androidx.core.view.ViewCompat;
  import java.util.ArrayList;
  
  class ToolbarActionBar extends ActionBar {
      final DecorToolbar mDecorToolbar;
      private boolean mLastMenuVisibility;
      final AppCompatDelegateImpl.ActionBarMenuCallback mMenuCallback;
      private boolean mMenuCallbackSet;
      private final Toolbar.OnMenuItemClickListener mMenuClicker;
      private final Runnable mMenuInvalidator = new Runnable() {
          public void run() {
              ToolbarActionBar.this.populateOptionsMenu();
          }
      };
      private ArrayList<ActionBar.OnMenuVisibilityListener> mMenuVisibilityListeners = new ArrayList<>();
      boolean mToolbarMenuPrepared;
      final Window.Callback mWindowCallback;
  
      private final class ActionMenuPresenterCallback implements MenuPresenter.Callback {
          private boolean mClosingActionMenu;
  
          ActionMenuPresenterCallback() {
          }
  
          public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
              if (!this.mClosingActionMenu) {
                  this.mClosingActionMenu = true;
                  ToolbarActionBar.this.mDecorToolbar.dismissPopupMenus();
                  ToolbarActionBar.this.mWindowCallback.onPanelClosed(AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR, menu);
                  this.mClosingActionMenu = false;
              }
          }
  
          public boolean onOpenSubMenu(MenuBuilder subMenu) {
              ToolbarActionBar.this.mWindowCallback.onMenuOpened(AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR, subMenu);
              return true;
          }
      }
  
      private final class MenuBuilderCallback implements MenuBuilder.Callback {
          MenuBuilderCallback() {
          }
  
          public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
              return false;
          }
  
          public void onMenuModeChange(MenuBuilder menu) {
              if (ToolbarActionBar.this.mDecorToolbar.isOverflowMenuShowing()) {
                  ToolbarActionBar.this.mWindowCallback.onPanelClosed(AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR, menu);
              } else if (ToolbarActionBar.this.mWindowCallback.onPreparePanel(0, (View) null, menu)) {
                  ToolbarActionBar.this.mWindowCallback.onMenuOpened(AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR, menu);
              }
          }
      }
  
      private class ToolbarMenuCallback implements AppCompatDelegateImpl.ActionBarMenuCallback {
          ToolbarMenuCallback() {
          }
  
          public View onCreatePanelView(int featureId) {
              if (featureId == 0) {
                  return new View(ToolbarActionBar.this.mDecorToolbar.getContext());
              }
              return null;
          }
  
          public boolean onPreparePanel(int featureId) {
              if (featureId != 0 || ToolbarActionBar.this.mToolbarMenuPrepared) {
                  return false;
              }
              ToolbarActionBar.this.mDecorToolbar.setMenuPrepared();
              ToolbarActionBar.this.mToolbarMenuPrepared = true;
              return false;
          }
      }
  
      ToolbarActionBar(Toolbar toolbar, CharSequence title, Window.Callback windowCallback) {
          AnonymousClass2 r0 = new Toolbar.OnMenuItemClickListener() {
              public boolean onMenuItemClick(MenuItem item) {
                  return ToolbarActionBar.this.mWindowCallback.onMenuItemSelected(0, item);
              }
          };
          this.mMenuClicker = r0;
          Preconditions.checkNotNull(toolbar);
          ToolbarWidgetWrapper toolbarWidgetWrapper = new ToolbarWidgetWrapper(toolbar, false);
          this.mDecorToolbar = toolbarWidgetWrapper;
          this.mWindowCallback = (Window.Callback) Preconditions.checkNotNull(windowCallback);
          toolbarWidgetWrapper.setWindowCallback(windowCallback);
          toolbar.setOnMenuItemClickListener(r0);
          toolbarWidgetWrapper.setWindowTitle(title);
          this.mMenuCallback = new ToolbarMenuCallback();
      }
  
      private Menu getMenu() {
          if (!this.mMenuCallbackSet) {
              this.mDecorToolbar.setMenuCallbacks(new ActionMenuPresenterCallback(), new MenuBuilderCallback());
              this.mMenuCallbackSet = true;
          }
          return this.mDecorToolbar.getMenu();
      }
  
      public void addOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener) {
          this.mMenuVisibilityListeners.add(listener);
      }
  
      public void addTab(ActionBar.Tab tab) {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public void addTab(ActionBar.Tab tab, int position) {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public void addTab(ActionBar.Tab tab, int position, boolean setSelected) {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public void addTab(ActionBar.Tab tab, boolean setSelected) {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public boolean closeOptionsMenu() {
          return this.mDecorToolbar.hideOverflowMenu();
      }
  
      public boolean collapseActionView() {
          if (!this.mDecorToolbar.hasExpandedActionView()) {
              return false;
          }
          this.mDecorToolbar.collapseActionView();
          return true;
      }
  
      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 View getCustomView() {
          return this.mDecorToolbar.getCustomView();
      }
  
      public int getDisplayOptions() {
          return this.mDecorToolbar.getDisplayOptions();
      }
  
      public float getElevation() {
          return ViewCompat.getElevation(this.mDecorToolbar.getViewGroup());
      }
  
      public int getHeight() {
          return this.mDecorToolbar.getHeight();
      }
  
      public int getNavigationItemCount() {
          return 0;
      }
  
      public int getNavigationMode() {
          return 0;
      }
  
      public int getSelectedNavigationIndex() {
          return -1;
      }
  
      public ActionBar.Tab getSelectedTab() {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public CharSequence getSubtitle() {
          return this.mDecorToolbar.getSubtitle();
      }
  
      public ActionBar.Tab getTabAt(int index) {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public int getTabCount() {
          return 0;
      }
  
      public Context getThemedContext() {
          return this.mDecorToolbar.getContext();
      }
  
      public CharSequence getTitle() {
          return this.mDecorToolbar.getTitle();
      }
  
      public void hide() {
          this.mDecorToolbar.setVisibility(8);
      }
  
      public boolean invalidateOptionsMenu() {
          this.mDecorToolbar.getViewGroup().removeCallbacks(this.mMenuInvalidator);
          ViewCompat.postOnAnimation(this.mDecorToolbar.getViewGroup(), this.mMenuInvalidator);
          return true;
      }
  
      public boolean isShowing() {
          return this.mDecorToolbar.getVisibility() == 0;
      }
  
      public boolean isTitleTruncated() {
          return super.isTitleTruncated();
      }
  
      public ActionBar.Tab newTab() {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public void onConfigurationChanged(Configuration config) {
          super.onConfigurationChanged(config);
      }
  
      /* access modifiers changed from: package-private */
      public void onDestroy() {
          this.mDecorToolbar.getViewGroup().removeCallbacks(this.mMenuInvalidator);
      }
  
      public boolean onKeyShortcut(int keyCode, KeyEvent ev) {
          Menu menu = getMenu();
          if (menu == null) {
              return false;
          }
          boolean z = true;
          if (KeyCharacterMap.load(ev != null ? ev.getDeviceId() : -1).getKeyboardType() == 1) {
              z = false;
          }
          menu.setQwertyMode(z);
          return menu.performShortcut(keyCode, ev, 0);
      }
  
      public boolean onMenuKeyEvent(KeyEvent event) {
          if (event.getAction() == 1) {
              openOptionsMenu();
          }
          return true;
      }
  
      public boolean openOptionsMenu() {
          return this.mDecorToolbar.showOverflowMenu();
      }
  
      /* access modifiers changed from: package-private */
      public void populateOptionsMenu() {
          Menu menu = getMenu();
          MenuBuilder menuBuilder = menu instanceof MenuBuilder ? (MenuBuilder) menu : null;
          if (menuBuilder != null) {
              menuBuilder.stopDispatchingItemsChanged();
          }
          try {
              menu.clear();
              if (!this.mWindowCallback.onCreatePanelMenu(0, menu) || !this.mWindowCallback.onPreparePanel(0, (View) null, menu)) {
                  menu.clear();
              }
          } finally {
              if (menuBuilder != null) {
                  menuBuilder.startDispatchingItemsChanged();
              }
          }
      }
  
      public void removeAllTabs() {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public void removeOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener) {
          this.mMenuVisibilityListeners.remove(listener);
      }
  
      public void removeTab(ActionBar.Tab tab) {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public void removeTabAt(int position) {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      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) {
          throw new UnsupportedOperationException("Tabs are not supported in toolbar action bars");
      }
  
      public void setBackgroundDrawable(Drawable d) {
          this.mDecorToolbar.setBackgroundDrawable(d);
      }
  
      public void setCustomView(int resId) {
          setCustomView(LayoutInflater.from(this.mDecorToolbar.getContext()).inflate(resId, this.mDecorToolbar.getViewGroup(), false));
      }
  
      public void setCustomView(View view) {
          setCustomView(view, new ActionBar.LayoutParams(-2, -2));
      }
  
      public void setCustomView(View view, ActionBar.LayoutParams layoutParams) {
          if (view != null) {
              view.setLayoutParams(layoutParams);
          }
          this.mDecorToolbar.setCustomView(view);
      }
  
      public void setDefaultDisplayHomeAsUpEnabled(boolean enabled) {
      }
  
      public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
          setDisplayOptions(showHomeAsUp ? 4 : 0, 4);
      }
  
      public void setDisplayOptions(int options) {
          setDisplayOptions(options, -1);
      }
  
      public void setDisplayOptions(int options, int mask) {
          this.mDecorToolbar.setDisplayOptions((options & mask) | ((~mask) & this.mDecorToolbar.getDisplayOptions()));
      }
  
      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.mDecorToolbar.getViewGroup(), elevation);
      }
  
      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 enabled) {
      }
  
      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) {
          if (mode != 2) {
              this.mDecorToolbar.setNavigationMode(mode);
              return;
          }
          throw new IllegalArgumentException("Tabs not supported in this configuration");
      }
  
      public void setSelectedNavigationItem(int position) {
          switch (this.mDecorToolbar.getNavigationMode()) {
              case 1:
                  this.mDecorToolbar.setDropdownSelectedPosition(position);
                  return;
              default:
                  throw new IllegalStateException("setSelectedNavigationIndex not valid for current navigation mode");
          }
      }
  
      public void setShowHideAnimationEnabled(boolean enabled) {
      }
  
      public void setSplitBackgroundDrawable(Drawable d) {
      }
  
      public void setStackedBackgroundDrawable(Drawable d) {
      }
  
      public void setSubtitle(int resId) {
          DecorToolbar decorToolbar = this.mDecorToolbar;
          decorToolbar.setSubtitle(resId != 0 ? decorToolbar.getContext().getText(resId) : null);
      }
  
      public void setSubtitle(CharSequence subtitle) {
          this.mDecorToolbar.setSubtitle(subtitle);
      }
  
      public void setTitle(int resId) {
          DecorToolbar decorToolbar = this.mDecorToolbar;
          decorToolbar.setTitle(resId != 0 ? decorToolbar.getContext().getText(resId) : null);
      }
  
      public void setTitle(CharSequence title) {
          this.mDecorToolbar.setTitle(title);
      }
  
      public void setWindowTitle(CharSequence title) {
          this.mDecorToolbar.setWindowTitle(title);
      }
  
      public void show() {
          this.mDecorToolbar.setVisibility(0);
      }
  }
  