content: package androidx.appcompat.view.menu;
  
  import android.content.Context;
  import android.content.res.Configuration;
  import android.content.res.Resources;
  import android.content.res.TypedArray;
  import android.graphics.drawable.Drawable;
  import android.os.Parcelable;
  import android.text.TextUtils;
  import android.util.AttributeSet;
  import android.view.MotionEvent;
  import android.view.View;
  import android.widget.Button;
  import androidx.appcompat.R;
  import androidx.appcompat.view.menu.MenuBuilder;
  import androidx.appcompat.view.menu.MenuView;
  import androidx.appcompat.widget.ActionMenuView;
  import androidx.appcompat.widget.AppCompatTextView;
  import androidx.appcompat.widget.ForwardingListener;
  import androidx.appcompat.widget.TooltipCompat;
  import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
  
  public class ActionMenuItemView extends AppCompatTextView implements MenuView.ItemView, View.OnClickListener, ActionMenuView.ActionMenuChildView {
      private static final int MAX_ICON_SIZE = 32;
      private static final String TAG = "ActionMenuItemView";
      private boolean mAllowTextWithIcon;
      private boolean mExpandedFormat;
      private ForwardingListener mForwardingListener;
      private Drawable mIcon;
      MenuItemImpl mItemData;
      MenuBuilder.ItemInvoker mItemInvoker;
      private int mMaxIconSize;
      private int mMinWidth;
      PopupCallback mPopupCallback;
      private int mSavedPaddingLeft;
      private CharSequence mTitle;
  
      private class ActionMenuItemForwardingListener extends ForwardingListener {
          public ActionMenuItemForwardingListener() {
              super(ActionMenuItemView.this);
          }
  
          public ShowableListMenu getPopup() {
              if (ActionMenuItemView.this.mPopupCallback != null) {
                  return ActionMenuItemView.this.mPopupCallback.getPopup();
              }
              return null;
          }
  
          /* access modifiers changed from: protected */
          /* JADX WARNING: Code restructure failed: missing block: B:4:0x0015, code lost:
              r0 = getPopup();
           */
          /* Code decompiled incorrectly, please refer to instructions dump. */
          public boolean onForwardingStarted() {
              /*
                  r3 = this;
                  androidx.appcompat.view.menu.ActionMenuItemView r0 = androidx.appcompat.view.menu.ActionMenuItemView.this
                  androidx.appcompat.view.menu.MenuBuilder$ItemInvoker r0 = r0.mItemInvoker
                  r1 = 0
                  if (r0 == 0) goto L_0x0023
                  androidx.appcompat.view.menu.ActionMenuItemView r0 = androidx.appcompat.view.menu.ActionMenuItemView.this
                  androidx.appcompat.view.menu.MenuBuilder$ItemInvoker r0 = r0.mItemInvoker
                  androidx.appcompat.view.menu.ActionMenuItemView r2 = androidx.appcompat.view.menu.ActionMenuItemView.this
                  androidx.appcompat.view.menu.MenuItemImpl r2 = r2.mItemData
                  boolean r0 = r0.invokeItem(r2)
                  if (r0 == 0) goto L_0x0023
                  androidx.appcompat.view.menu.ShowableListMenu r0 = r3.getPopup()
                  if (r0 == 0) goto L_0x0022
                  boolean r2 = r0.isShowing()
                  if (r2 == 0) goto L_0x0022
                  r1 = 1
              L_0x0022:
                  return r1
              L_0x0023:
                  return r1
              */
              throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.view.menu.ActionMenuItemView.ActionMenuItemForwardingListener.onForwardingStarted():boolean");
          }
      }
  
      public static abstract class PopupCallback {
          public abstract ShowableListMenu getPopup();
      }
  
      public ActionMenuItemView(Context context) {
          this(context, (AttributeSet) null);
      }
  
      public ActionMenuItemView(Context context, AttributeSet attrs) {
          this(context, attrs, 0);
      }
  
      public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
          Resources resources = context.getResources();
          this.mAllowTextWithIcon = shouldAllowTextWithIcon();
          TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attrs, R.styleable.ActionMenuItemView, defStyle, 0);
          this.mMinWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.ActionMenuItemView_android_minWidth, 0);
          obtainStyledAttributes.recycle();
          this.mMaxIconSize = (int) ((32.0f * resources.getDisplayMetrics().density) + 0.5f);
          setOnClickListener(this);
          this.mSavedPaddingLeft = -1;
          setSaveEnabled(false);
      }
  
      private boolean shouldAllowTextWithIcon() {
          Configuration configuration = getContext().getResources().getConfiguration();
          int i = configuration.screenWidthDp;
          return i >= 480 || (i >= 640 && configuration.screenHeightDp >= 480) || configuration.orientation == 2;
      }
  
      private void updateTextButtonVisibility() {
          boolean z = true;
          boolean z2 = !TextUtils.isEmpty(this.mTitle);
          if (this.mIcon != null && (!this.mItemData.showsTextAsAction() || (!this.mAllowTextWithIcon && !this.mExpandedFormat))) {
              z = false;
          }
          boolean z3 = z2 & z;
          CharSequence charSequence = null;
          setText(z3 ? this.mTitle : null);
          CharSequence contentDescription = this.mItemData.getContentDescription();
          if (TextUtils.isEmpty(contentDescription)) {
              setContentDescription(z3 ? null : this.mItemData.getTitle());
          } else {
              setContentDescription(contentDescription);
          }
          CharSequence tooltipText = this.mItemData.getTooltipText();
          if (TextUtils.isEmpty(tooltipText)) {
              if (!z3) {
                  charSequence = this.mItemData.getTitle();
              }
              TooltipCompat.setTooltipText(this, charSequence);
              return;
          }
          TooltipCompat.setTooltipText(this, tooltipText);
      }
  
      public CharSequence getAccessibilityClassName() {
          return Button.class.getName();
      }
  
      public MenuItemImpl getItemData() {
          return this.mItemData;
      }
  
      public boolean hasText() {
          return !TextUtils.isEmpty(getText());
      }
  
      public void initialize(MenuItemImpl itemData, int menuType) {
          this.mItemData = itemData;
          setIcon(itemData.getIcon());
          setTitle(itemData.getTitleForItemView(this));
          setId(itemData.getItemId());
          setVisibility(itemData.isVisible() ? 0 : 8);
          setEnabled(itemData.isEnabled());
          if (itemData.hasSubMenu() && this.mForwardingListener == null) {
              this.mForwardingListener = new ActionMenuItemForwardingListener();
          }
      }
  
      public boolean needsDividerAfter() {
          return hasText();
      }
  
      public boolean needsDividerBefore() {
          return hasText() && this.mItemData.getIcon() == null;
      }
  
      public void onClick(View v) {
          MenuBuilder.ItemInvoker itemInvoker = this.mItemInvoker;
          if (itemInvoker != null) {
              itemInvoker.invokeItem(this.mItemData);
          }
      }
  
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
          this.mAllowTextWithIcon = shouldAllowTextWithIcon();
          updateTextButtonVisibility();
      }
  
      /* access modifiers changed from: protected */
      public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          int i;
          boolean hasText = hasText();
          if (hasText && (i = this.mSavedPaddingLeft) >= 0) {
              super.setPadding(i, getPaddingTop(), getPaddingRight(), getPaddingBottom());
          }
          super.onMeasure(widthMeasureSpec, heightMeasureSpec);
          int mode = View.MeasureSpec.getMode(widthMeasureSpec);
          int size = View.MeasureSpec.getSize(widthMeasureSpec);
          int measuredWidth = getMeasuredWidth();
          int min = mode == Integer.MIN_VALUE ? Math.min(size, this.mMinWidth) : this.mMinWidth;
          if (mode != 1073741824 && this.mMinWidth > 0 && measuredWidth < min) {
              super.onMeasure(View.MeasureSpec.makeMeasureSpec(min, BasicMeasure.EXACTLY), heightMeasureSpec);
          }
          if (!hasText && this.mIcon != null) {
              super.setPadding((getMeasuredWidth() - this.mIcon.getBounds().width()) / 2, getPaddingTop(), getPaddingRight(), getPaddingBottom());
          }
      }
  
      public void onRestoreInstanceState(Parcelable state) {
          super.onRestoreInstanceState((Parcelable) null);
      }
  
      public boolean onTouchEvent(MotionEvent e) {
          ForwardingListener forwardingListener;
          if (!this.mItemData.hasSubMenu() || (forwardingListener = this.mForwardingListener) == null || !forwardingListener.onTouch(this, e)) {
              return super.onTouchEvent(e);
          }
          return true;
      }
  
      public boolean prefersCondensedTitle() {
          return true;
      }
  
      public void setCheckable(boolean checkable) {
      }
  
      public void setChecked(boolean checked) {
      }
  
      public void setExpandedFormat(boolean expandedFormat) {
          if (this.mExpandedFormat != expandedFormat) {
              this.mExpandedFormat = expandedFormat;
              MenuItemImpl menuItemImpl = this.mItemData;
              if (menuItemImpl != null) {
                  menuItemImpl.actionFormatChanged();
              }
          }
      }
  
      public void setIcon(Drawable icon) {
          this.mIcon = icon;
          if (icon != null) {
              int intrinsicWidth = icon.getIntrinsicWidth();
              int intrinsicHeight = icon.getIntrinsicHeight();
              int i = this.mMaxIconSize;
              if (intrinsicWidth > i) {
                  float f = ((float) i) / ((float) intrinsicWidth);
                  intrinsicWidth = this.mMaxIconSize;
                  intrinsicHeight = (int) (((float) intrinsicHeight) * f);
              }
              if (intrinsicHeight > i) {
                  float f2 = ((float) i) / ((float) intrinsicHeight);
                  intrinsicHeight = this.mMaxIconSize;
                  intrinsicWidth = (int) (((float) intrinsicWidth) * f2);
              }
              icon.setBounds(0, 0, intrinsicWidth, intrinsicHeight);
          }
          setCompoundDrawables(icon, (Drawable) null, (Drawable) null, (Drawable) null);
          updateTextButtonVisibility();
      }
  
      public void setItemInvoker(MenuBuilder.ItemInvoker invoker) {
          this.mItemInvoker = invoker;
      }
  
      public void setPadding(int l, int t, int r, int b) {
          this.mSavedPaddingLeft = l;
          super.setPadding(l, t, r, b);
      }
  
      public void setPopupCallback(PopupCallback popupCallback) {
          this.mPopupCallback = popupCallback;
      }
  
      public void setShortcut(boolean showShortcut, char shortcutKey) {
      }
  
      public void setTitle(CharSequence title) {
          this.mTitle = title;
          updateTextButtonVisibility();
      }
  
      public boolean showsIcon() {
          return true;
      }
  }
  