ADD week 5
This commit is contained in:
		| @@ -0,0 +1,413 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.graphics.PorterDuff; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.view.ContextMenu; | ||||
| import android.view.KeyEvent; | ||||
| import android.view.MenuItem; | ||||
| import android.view.SubMenu; | ||||
| import android.view.View; | ||||
| import androidx.core.content.ContextCompat; | ||||
| import androidx.core.graphics.drawable.DrawableCompat; | ||||
| import androidx.core.internal.view.SupportMenuItem; | ||||
| import androidx.core.view.ActionProvider; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class ActionMenuItem implements SupportMenuItem { | ||||
|     private static final int CHECKABLE = 1; | ||||
|     private static final int CHECKED = 2; | ||||
|     private static final int ENABLED = 16; | ||||
|     private static final int EXCLUSIVE = 4; | ||||
|     private static final int HIDDEN = 8; | ||||
|     private MenuItem.OnMenuItemClickListener mClickListener; | ||||
|     private CharSequence mContentDescription; | ||||
|     private Context mContext; | ||||
|     private final int mGroup; | ||||
|     private Drawable mIconDrawable; | ||||
|     private final int mId; | ||||
|     private Intent mIntent; | ||||
|     private final int mOrdering; | ||||
|     private char mShortcutAlphabeticChar; | ||||
|     private char mShortcutNumericChar; | ||||
|     private CharSequence mTitle; | ||||
|     private CharSequence mTitleCondensed; | ||||
|     private CharSequence mTooltipText; | ||||
|     private int mShortcutNumericModifiers = 4096; | ||||
|     private int mShortcutAlphabeticModifiers = 4096; | ||||
|     private ColorStateList mIconTintList = null; | ||||
|     private PorterDuff.Mode mIconTintMode = null; | ||||
|     private boolean mHasIconTint = false; | ||||
|     private boolean mHasIconTintMode = false; | ||||
|     private int mFlags = 16; | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public boolean collapseActionView() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public boolean expandActionView() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public View getActionView() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public int getAlphabeticModifiers() { | ||||
|         return this.mShortcutAlphabeticModifiers; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public char getAlphabeticShortcut() { | ||||
|         return this.mShortcutAlphabeticChar; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public CharSequence getContentDescription() { | ||||
|         return this.mContentDescription; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getGroupId() { | ||||
|         return this.mGroup; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public Drawable getIcon() { | ||||
|         return this.mIconDrawable; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public ColorStateList getIconTintList() { | ||||
|         return this.mIconTintList; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public PorterDuff.Mode getIconTintMode() { | ||||
|         return this.mIconTintMode; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public Intent getIntent() { | ||||
|         return this.mIntent; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getItemId() { | ||||
|         return this.mId; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public ContextMenu.ContextMenuInfo getMenuInfo() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public int getNumericModifiers() { | ||||
|         return this.mShortcutNumericModifiers; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public char getNumericShortcut() { | ||||
|         return this.mShortcutNumericChar; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getOrder() { | ||||
|         return this.mOrdering; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public SubMenu getSubMenu() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem | ||||
|     public ActionProvider getSupportActionProvider() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public CharSequence getTitle() { | ||||
|         return this.mTitle; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public CharSequence getTitleCondensed() { | ||||
|         CharSequence charSequence = this.mTitleCondensed; | ||||
|         return charSequence != null ? charSequence : this.mTitle; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public CharSequence getTooltipText() { | ||||
|         return this.mTooltipText; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean hasSubMenu() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public boolean isActionViewExpanded() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isCheckable() { | ||||
|         return (this.mFlags & 1) != 0; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isChecked() { | ||||
|         return (this.mFlags & 2) != 0; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isEnabled() { | ||||
|         return (this.mFlags & 16) != 0; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isVisible() { | ||||
|         return (this.mFlags & 8) == 0; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem | ||||
|     public boolean requiresActionButton() { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem | ||||
|     public boolean requiresOverflow() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setCheckable(boolean z) { | ||||
|         this.mFlags = (z ? 1 : 0) | (this.mFlags & (-2)); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setChecked(boolean z) { | ||||
|         this.mFlags = (z ? 2 : 0) | (this.mFlags & (-3)); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public SupportMenuItem setContentDescription(CharSequence charSequence) { | ||||
|         this.mContentDescription = charSequence; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setEnabled(boolean z) { | ||||
|         this.mFlags = (z ? 16 : 0) | (this.mFlags & (-17)); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public ActionMenuItem setExclusiveCheckable(boolean z) { | ||||
|         this.mFlags = (z ? 4 : 0) | (this.mFlags & (-5)); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIntent(Intent intent) { | ||||
|         this.mIntent = intent; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setNumericShortcut(char c) { | ||||
|         this.mShortcutNumericChar = c; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) { | ||||
|         this.mClickListener = onMenuItemClickListener; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public void setShowAsAction(int i) { | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitle(CharSequence charSequence) { | ||||
|         this.mTitle = charSequence; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitleCondensed(CharSequence charSequence) { | ||||
|         this.mTitleCondensed = charSequence; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public SupportMenuItem setTooltipText(CharSequence charSequence) { | ||||
|         this.mTooltipText = charSequence; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setVisible(boolean z) { | ||||
|         this.mFlags = (this.mFlags & 8) | (z ? 0 : 8); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public ActionMenuItem(Context context, int i, int i2, int i3, int i4, CharSequence charSequence) { | ||||
|         this.mContext = context; | ||||
|         this.mId = i2; | ||||
|         this.mGroup = i; | ||||
|         this.mOrdering = i4; | ||||
|         this.mTitle = charSequence; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setAlphabeticShortcut(char c) { | ||||
|         this.mShortcutAlphabeticChar = Character.toLowerCase(c); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setAlphabeticShortcut(char c, int i) { | ||||
|         this.mShortcutAlphabeticChar = Character.toLowerCase(c); | ||||
|         this.mShortcutAlphabeticModifiers = KeyEvent.normalizeMetaState(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIcon(Drawable drawable) { | ||||
|         this.mIconDrawable = drawable; | ||||
|         applyIconTint(); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIcon(int i) { | ||||
|         this.mIconDrawable = ContextCompat.getDrawable(this.mContext, i); | ||||
|         applyIconTint(); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setNumericShortcut(char c, int i) { | ||||
|         this.mShortcutNumericChar = c; | ||||
|         this.mShortcutNumericModifiers = KeyEvent.normalizeMetaState(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setShortcut(char c, char c2) { | ||||
|         this.mShortcutNumericChar = c; | ||||
|         this.mShortcutAlphabeticChar = Character.toLowerCase(c2); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setShortcut(char c, char c2, int i, int i2) { | ||||
|         this.mShortcutNumericChar = c; | ||||
|         this.mShortcutNumericModifiers = KeyEvent.normalizeMetaState(i); | ||||
|         this.mShortcutAlphabeticChar = Character.toLowerCase(c2); | ||||
|         this.mShortcutAlphabeticModifiers = KeyEvent.normalizeMetaState(i2); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitle(int i) { | ||||
|         this.mTitle = this.mContext.getResources().getString(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public boolean invoke() { | ||||
|         MenuItem.OnMenuItemClickListener onMenuItemClickListener = this.mClickListener; | ||||
|         if (onMenuItemClickListener != null && onMenuItemClickListener.onMenuItemClick(this)) { | ||||
|             return true; | ||||
|         } | ||||
|         Intent intent = this.mIntent; | ||||
|         if (intent == null) { | ||||
|             return false; | ||||
|         } | ||||
|         this.mContext.startActivity(intent); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public SupportMenuItem setActionView(View view) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setActionProvider(android.view.ActionProvider actionProvider) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public android.view.ActionProvider getActionProvider() { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public SupportMenuItem setActionView(int i) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem | ||||
|     public SupportMenuItem setSupportActionProvider(ActionProvider actionProvider) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public SupportMenuItem setShowAsActionFlags(int i) { | ||||
|         setShowAsAction(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setIconTintList(ColorStateList colorStateList) { | ||||
|         this.mIconTintList = colorStateList; | ||||
|         this.mHasIconTint = true; | ||||
|         applyIconTint(); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setIconTintMode(PorterDuff.Mode mode) { | ||||
|         this.mIconTintMode = mode; | ||||
|         this.mHasIconTintMode = true; | ||||
|         applyIconTint(); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     private void applyIconTint() { | ||||
|         Drawable drawable = this.mIconDrawable; | ||||
|         if (drawable != null) { | ||||
|             if (this.mHasIconTint || this.mHasIconTintMode) { | ||||
|                 Drawable wrap = DrawableCompat.wrap(drawable); | ||||
|                 this.mIconDrawable = wrap; | ||||
|                 Drawable mutate = wrap.mutate(); | ||||
|                 this.mIconDrawable = mutate; | ||||
|                 if (this.mHasIconTint) { | ||||
|                     DrawableCompat.setTintList(mutate, this.mIconTintList); | ||||
|                 } | ||||
|                 if (this.mHasIconTintMode) { | ||||
|                     DrawableCompat.setTintMode(this.mIconDrawable, this.mIconTintMode); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,272 @@ | ||||
| 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; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| 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; | ||||
|  | ||||
|     public static abstract class PopupCallback { | ||||
|         public abstract ShowableListMenu getPopup(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public MenuItemImpl getItemData() { | ||||
|         return this.mItemData; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public boolean prefersCondensedTitle() { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setCheckable(boolean z) { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setChecked(boolean z) { | ||||
|     } | ||||
|  | ||||
|     public void setItemInvoker(MenuBuilder.ItemInvoker itemInvoker) { | ||||
|         this.mItemInvoker = itemInvoker; | ||||
|     } | ||||
|  | ||||
|     public void setPopupCallback(PopupCallback popupCallback) { | ||||
|         this.mPopupCallback = popupCallback; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setShortcut(boolean z, char c) { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public boolean showsIcon() { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     public ActionMenuItemView(Context context) { | ||||
|         this(context, null); | ||||
|     } | ||||
|  | ||||
|     public ActionMenuItemView(Context context, AttributeSet attributeSet) { | ||||
|         this(context, attributeSet, 0); | ||||
|     } | ||||
|  | ||||
|     public ActionMenuItemView(Context context, AttributeSet attributeSet, int i) { | ||||
|         super(context, attributeSet, i); | ||||
|         Resources resources = context.getResources(); | ||||
|         this.mAllowTextWithIcon = shouldAllowTextWithIcon(); | ||||
|         TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ActionMenuItemView, i, 0); | ||||
|         this.mMinWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.ActionMenuItemView_android_minWidth, 0); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         this.mMaxIconSize = (int) ((resources.getDisplayMetrics().density * 32.0f) + 0.5f); | ||||
|         setOnClickListener(this); | ||||
|         this.mSavedPaddingLeft = -1; | ||||
|         setSaveEnabled(false); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.TextView, android.view.View | ||||
|     public void onConfigurationChanged(Configuration configuration) { | ||||
|         super.onConfigurationChanged(configuration); | ||||
|         this.mAllowTextWithIcon = shouldAllowTextWithIcon(); | ||||
|         updateTextButtonVisibility(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.TextView, android.view.View | ||||
|     public CharSequence getAccessibilityClassName() { | ||||
|         return Button.class.getName(); | ||||
|     } | ||||
|  | ||||
|     private boolean shouldAllowTextWithIcon() { | ||||
|         Configuration configuration = getContext().getResources().getConfiguration(); | ||||
|         int i = configuration.screenWidthDp; | ||||
|         return i >= 480 || (i >= 640 && configuration.screenHeightDp >= 480) || configuration.orientation == 2; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.TextView, android.view.View | ||||
|     public void setPadding(int i, int i2, int i3, int i4) { | ||||
|         this.mSavedPaddingLeft = i; | ||||
|         super.setPadding(i, i2, i3, i4); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void initialize(MenuItemImpl menuItemImpl, int i) { | ||||
|         this.mItemData = menuItemImpl; | ||||
|         setIcon(menuItemImpl.getIcon()); | ||||
|         setTitle(menuItemImpl.getTitleForItemView(this)); | ||||
|         setId(menuItemImpl.getItemId()); | ||||
|         setVisibility(menuItemImpl.isVisible() ? 0 : 8); | ||||
|         setEnabled(menuItemImpl.isEnabled()); | ||||
|         if (menuItemImpl.hasSubMenu() && this.mForwardingListener == null) { | ||||
|             this.mForwardingListener = new ActionMenuItemForwardingListener(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.TextView, android.view.View | ||||
|     public boolean onTouchEvent(MotionEvent motionEvent) { | ||||
|         ForwardingListener forwardingListener; | ||||
|         if (this.mItemData.hasSubMenu() && (forwardingListener = this.mForwardingListener) != null && forwardingListener.onTouch(this, motionEvent)) { | ||||
|             return true; | ||||
|         } | ||||
|         return super.onTouchEvent(motionEvent); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View.OnClickListener | ||||
|     public void onClick(View view) { | ||||
|         MenuBuilder.ItemInvoker itemInvoker = this.mItemInvoker; | ||||
|         if (itemInvoker != null) { | ||||
|             itemInvoker.invokeItem(this.mItemData); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void setExpandedFormat(boolean z) { | ||||
|         if (this.mExpandedFormat != z) { | ||||
|             this.mExpandedFormat = z; | ||||
|             MenuItemImpl menuItemImpl = this.mItemData; | ||||
|             if (menuItemImpl != null) { | ||||
|                 menuItemImpl.actionFormatChanged(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     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; | ||||
|         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)) { | ||||
|             TooltipCompat.setTooltipText(this, z3 ? null : this.mItemData.getTitle()); | ||||
|         } else { | ||||
|             TooltipCompat.setTooltipText(this, tooltipText); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setIcon(Drawable drawable) { | ||||
|         this.mIcon = drawable; | ||||
|         if (drawable != null) { | ||||
|             int intrinsicWidth = drawable.getIntrinsicWidth(); | ||||
|             int intrinsicHeight = drawable.getIntrinsicHeight(); | ||||
|             int i = this.mMaxIconSize; | ||||
|             if (intrinsicWidth > i) { | ||||
|                 intrinsicHeight = (int) (intrinsicHeight * (i / intrinsicWidth)); | ||||
|                 intrinsicWidth = i; | ||||
|             } | ||||
|             if (intrinsicHeight > i) { | ||||
|                 intrinsicWidth = (int) (intrinsicWidth * (i / intrinsicHeight)); | ||||
|             } else { | ||||
|                 i = intrinsicHeight; | ||||
|             } | ||||
|             drawable.setBounds(0, 0, intrinsicWidth, i); | ||||
|         } | ||||
|         setCompoundDrawables(drawable, null, null, null); | ||||
|         updateTextButtonVisibility(); | ||||
|     } | ||||
|  | ||||
|     public boolean hasText() { | ||||
|         return !TextUtils.isEmpty(getText()); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setTitle(CharSequence charSequence) { | ||||
|         this.mTitle = charSequence; | ||||
|         updateTextButtonVisibility(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.widget.ActionMenuView.ActionMenuChildView | ||||
|     public boolean needsDividerBefore() { | ||||
|         return hasText() && this.mItemData.getIcon() == null; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.widget.ActionMenuView.ActionMenuChildView | ||||
|     public boolean needsDividerAfter() { | ||||
|         return hasText(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.widget.AppCompatTextView, android.widget.TextView, android.view.View | ||||
|     protected void onMeasure(int i, int i2) { | ||||
|         int i3; | ||||
|         boolean hasText = hasText(); | ||||
|         if (hasText && (i3 = this.mSavedPaddingLeft) >= 0) { | ||||
|             super.setPadding(i3, getPaddingTop(), getPaddingRight(), getPaddingBottom()); | ||||
|         } | ||||
|         super.onMeasure(i, i2); | ||||
|         int mode = View.MeasureSpec.getMode(i); | ||||
|         int size = View.MeasureSpec.getSize(i); | ||||
|         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), i2); | ||||
|         } | ||||
|         if (hasText || this.mIcon == null) { | ||||
|             return; | ||||
|         } | ||||
|         super.setPadding((getMeasuredWidth() - this.mIcon.getBounds().width()) / 2, getPaddingTop(), getPaddingRight(), getPaddingBottom()); | ||||
|     } | ||||
|  | ||||
|     private class ActionMenuItemForwardingListener extends ForwardingListener { | ||||
|         public ActionMenuItemForwardingListener() { | ||||
|             super(ActionMenuItemView.this); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.appcompat.widget.ForwardingListener | ||||
|         public ShowableListMenu getPopup() { | ||||
|             if (ActionMenuItemView.this.mPopupCallback != null) { | ||||
|                 return ActionMenuItemView.this.mPopupCallback.getPopup(); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.appcompat.widget.ForwardingListener | ||||
|         protected boolean onForwardingStarted() { | ||||
|             ShowableListMenu popup; | ||||
|             return ActionMenuItemView.this.mItemInvoker != null && ActionMenuItemView.this.mItemInvoker.invokeItem(ActionMenuItemView.this.mItemData) && (popup = getPopup()) != null && popup.isShowing(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.TextView, android.view.View | ||||
|     public void onRestoreInstanceState(Parcelable parcelable) { | ||||
|         super.onRestoreInstanceState(null); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,178 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import androidx.appcompat.view.menu.MenuPresenter; | ||||
| import androidx.appcompat.view.menu.MenuView; | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public abstract class BaseMenuPresenter implements MenuPresenter { | ||||
|     private MenuPresenter.Callback mCallback; | ||||
|     protected Context mContext; | ||||
|     private int mId; | ||||
|     protected LayoutInflater mInflater; | ||||
|     private int mItemLayoutRes; | ||||
|     protected MenuBuilder mMenu; | ||||
|     private int mMenuLayoutRes; | ||||
|     protected MenuView mMenuView; | ||||
|     protected Context mSystemContext; | ||||
|     protected LayoutInflater mSystemInflater; | ||||
|  | ||||
|     public abstract void bindItemView(MenuItemImpl menuItemImpl, MenuView.ItemView itemView); | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean collapseItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean expandItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean flagActionItems() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public MenuPresenter.Callback getCallback() { | ||||
|         return this.mCallback; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public int getId() { | ||||
|         return this.mId; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void setCallback(MenuPresenter.Callback callback) { | ||||
|         this.mCallback = callback; | ||||
|     } | ||||
|  | ||||
|     public void setId(int i) { | ||||
|         this.mId = i; | ||||
|     } | ||||
|  | ||||
|     public boolean shouldIncludeItem(int i, MenuItemImpl menuItemImpl) { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     public BaseMenuPresenter(Context context, int i, int i2) { | ||||
|         this.mSystemContext = context; | ||||
|         this.mSystemInflater = LayoutInflater.from(context); | ||||
|         this.mMenuLayoutRes = i; | ||||
|         this.mItemLayoutRes = i2; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void initForMenu(Context context, MenuBuilder menuBuilder) { | ||||
|         this.mContext = context; | ||||
|         this.mInflater = LayoutInflater.from(context); | ||||
|         this.mMenu = menuBuilder; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public MenuView getMenuView(ViewGroup viewGroup) { | ||||
|         if (this.mMenuView == null) { | ||||
|             MenuView menuView = (MenuView) this.mSystemInflater.inflate(this.mMenuLayoutRes, viewGroup, false); | ||||
|             this.mMenuView = menuView; | ||||
|             menuView.initialize(this.mMenu); | ||||
|             updateMenuView(true); | ||||
|         } | ||||
|         return this.mMenuView; | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Multi-variable type inference failed */ | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void updateMenuView(boolean z) { | ||||
|         ViewGroup viewGroup = (ViewGroup) this.mMenuView; | ||||
|         if (viewGroup == null) { | ||||
|             return; | ||||
|         } | ||||
|         MenuBuilder menuBuilder = this.mMenu; | ||||
|         int i = 0; | ||||
|         if (menuBuilder != null) { | ||||
|             menuBuilder.flagActionItems(); | ||||
|             ArrayList<MenuItemImpl> visibleItems = this.mMenu.getVisibleItems(); | ||||
|             int size = visibleItems.size(); | ||||
|             int i2 = 0; | ||||
|             for (int i3 = 0; i3 < size; i3++) { | ||||
|                 MenuItemImpl menuItemImpl = visibleItems.get(i3); | ||||
|                 if (shouldIncludeItem(i2, menuItemImpl)) { | ||||
|                     View childAt = viewGroup.getChildAt(i2); | ||||
|                     MenuItemImpl itemData = childAt instanceof MenuView.ItemView ? ((MenuView.ItemView) childAt).getItemData() : null; | ||||
|                     View itemView = getItemView(menuItemImpl, childAt, viewGroup); | ||||
|                     if (menuItemImpl != itemData) { | ||||
|                         itemView.setPressed(false); | ||||
|                         itemView.jumpDrawablesToCurrentState(); | ||||
|                     } | ||||
|                     if (itemView != childAt) { | ||||
|                         addItemView(itemView, i2); | ||||
|                     } | ||||
|                     i2++; | ||||
|                 } | ||||
|             } | ||||
|             i = i2; | ||||
|         } | ||||
|         while (i < viewGroup.getChildCount()) { | ||||
|             if (!filterLeftoverView(viewGroup, i)) { | ||||
|                 i++; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected void addItemView(View view, int i) { | ||||
|         ViewGroup viewGroup = (ViewGroup) view.getParent(); | ||||
|         if (viewGroup != null) { | ||||
|             viewGroup.removeView(view); | ||||
|         } | ||||
|         ((ViewGroup) this.mMenuView).addView(view, i); | ||||
|     } | ||||
|  | ||||
|     protected boolean filterLeftoverView(ViewGroup viewGroup, int i) { | ||||
|         viewGroup.removeViewAt(i); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     public MenuView.ItemView createItemView(ViewGroup viewGroup) { | ||||
|         return (MenuView.ItemView) this.mSystemInflater.inflate(this.mItemLayoutRes, viewGroup, false); | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Multi-variable type inference failed */ | ||||
|     public View getItemView(MenuItemImpl menuItemImpl, View view, ViewGroup viewGroup) { | ||||
|         MenuView.ItemView itemView; | ||||
|         if (view instanceof MenuView.ItemView) { | ||||
|             itemView = (MenuView.ItemView) view; | ||||
|         } else { | ||||
|             itemView = createItemView(viewGroup); | ||||
|         } | ||||
|         bindItemView(menuItemImpl, itemView); | ||||
|         return (View) itemView; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void onCloseMenu(MenuBuilder menuBuilder, boolean z) { | ||||
|         MenuPresenter.Callback callback = this.mCallback; | ||||
|         if (callback != null) { | ||||
|             callback.onCloseMenu(menuBuilder, z); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Multi-variable type inference failed */ | ||||
|     /* JADX WARN: Type inference failed for: r2v4, types: [androidx.appcompat.view.menu.MenuBuilder] */ | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean onSubMenuSelected(SubMenuBuilder subMenuBuilder) { | ||||
|         MenuPresenter.Callback callback = this.mCallback; | ||||
|         SubMenuBuilder subMenuBuilder2 = subMenuBuilder; | ||||
|         if (callback == null) { | ||||
|             return false; | ||||
|         } | ||||
|         if (subMenuBuilder == null) { | ||||
|             subMenuBuilder2 = this.mMenu; | ||||
|         } | ||||
|         return callback.onOpenSubMenu(subMenuBuilder2); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,90 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.view.MenuItem; | ||||
| import android.view.SubMenu; | ||||
| import androidx.collection.SimpleArrayMap; | ||||
| import androidx.core.internal.view.SupportMenuItem; | ||||
| import androidx.core.internal.view.SupportSubMenu; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| abstract class BaseMenuWrapper { | ||||
|     final Context mContext; | ||||
|     private SimpleArrayMap<SupportMenuItem, MenuItem> mMenuItems; | ||||
|     private SimpleArrayMap<SupportSubMenu, SubMenu> mSubMenus; | ||||
|  | ||||
|     BaseMenuWrapper(Context context) { | ||||
|         this.mContext = context; | ||||
|     } | ||||
|  | ||||
|     final MenuItem getMenuItemWrapper(MenuItem menuItem) { | ||||
|         if (!(menuItem instanceof SupportMenuItem)) { | ||||
|             return menuItem; | ||||
|         } | ||||
|         SupportMenuItem supportMenuItem = (SupportMenuItem) menuItem; | ||||
|         if (this.mMenuItems == null) { | ||||
|             this.mMenuItems = new SimpleArrayMap<>(); | ||||
|         } | ||||
|         MenuItem menuItem2 = this.mMenuItems.get(supportMenuItem); | ||||
|         if (menuItem2 != null) { | ||||
|             return menuItem2; | ||||
|         } | ||||
|         MenuItemWrapperICS menuItemWrapperICS = new MenuItemWrapperICS(this.mContext, supportMenuItem); | ||||
|         this.mMenuItems.put(supportMenuItem, menuItemWrapperICS); | ||||
|         return menuItemWrapperICS; | ||||
|     } | ||||
|  | ||||
|     final SubMenu getSubMenuWrapper(SubMenu subMenu) { | ||||
|         if (!(subMenu instanceof SupportSubMenu)) { | ||||
|             return subMenu; | ||||
|         } | ||||
|         SupportSubMenu supportSubMenu = (SupportSubMenu) subMenu; | ||||
|         if (this.mSubMenus == null) { | ||||
|             this.mSubMenus = new SimpleArrayMap<>(); | ||||
|         } | ||||
|         SubMenu subMenu2 = this.mSubMenus.get(supportSubMenu); | ||||
|         if (subMenu2 != null) { | ||||
|             return subMenu2; | ||||
|         } | ||||
|         SubMenuWrapperICS subMenuWrapperICS = new SubMenuWrapperICS(this.mContext, supportSubMenu); | ||||
|         this.mSubMenus.put(supportSubMenu, subMenuWrapperICS); | ||||
|         return subMenuWrapperICS; | ||||
|     } | ||||
|  | ||||
|     final void internalClear() { | ||||
|         SimpleArrayMap<SupportMenuItem, MenuItem> simpleArrayMap = this.mMenuItems; | ||||
|         if (simpleArrayMap != null) { | ||||
|             simpleArrayMap.clear(); | ||||
|         } | ||||
|         SimpleArrayMap<SupportSubMenu, SubMenu> simpleArrayMap2 = this.mSubMenus; | ||||
|         if (simpleArrayMap2 != null) { | ||||
|             simpleArrayMap2.clear(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     final void internalRemoveGroup(int i) { | ||||
|         if (this.mMenuItems == null) { | ||||
|             return; | ||||
|         } | ||||
|         int i2 = 0; | ||||
|         while (i2 < this.mMenuItems.size()) { | ||||
|             if (this.mMenuItems.keyAt(i2).getGroupId() == i) { | ||||
|                 this.mMenuItems.removeAt(i2); | ||||
|                 i2--; | ||||
|             } | ||||
|             i2++; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     final void internalRemoveItem(int i) { | ||||
|         if (this.mMenuItems == null) { | ||||
|             return; | ||||
|         } | ||||
|         for (int i2 = 0; i2 < this.mMenuItems.size(); i2++) { | ||||
|             if (this.mMenuItems.keyAt(i2).getItemId() == i) { | ||||
|                 this.mMenuItems.removeAt(i2); | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,569 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.Resources; | ||||
| import android.graphics.Rect; | ||||
| import android.os.Build; | ||||
| import android.os.Handler; | ||||
| import android.os.Parcelable; | ||||
| import android.os.SystemClock; | ||||
| import android.view.KeyEvent; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.view.ViewTreeObserver; | ||||
| import android.widget.FrameLayout; | ||||
| import android.widget.HeaderViewListAdapter; | ||||
| import android.widget.ListAdapter; | ||||
| import android.widget.ListView; | ||||
| import android.widget.PopupWindow; | ||||
| import android.widget.TextView; | ||||
| import androidx.appcompat.R; | ||||
| import androidx.appcompat.view.menu.MenuPresenter; | ||||
| import androidx.appcompat.widget.MenuItemHoverListener; | ||||
| import androidx.appcompat.widget.MenuPopupWindow; | ||||
| import androidx.core.view.GravityCompat; | ||||
| import androidx.core.view.ViewCompat; | ||||
| import java.lang.annotation.Retention; | ||||
| import java.lang.annotation.RetentionPolicy; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, View.OnKeyListener, PopupWindow.OnDismissListener { | ||||
|     static final int HORIZ_POSITION_LEFT = 0; | ||||
|     static final int HORIZ_POSITION_RIGHT = 1; | ||||
|     private static final int ITEM_LAYOUT = R.layout.abc_cascading_menu_item_layout; | ||||
|     static final int SUBMENU_TIMEOUT_MS = 200; | ||||
|     private View mAnchorView; | ||||
|     private final Context mContext; | ||||
|     private boolean mHasXOffset; | ||||
|     private boolean mHasYOffset; | ||||
|     private final int mMenuMaxWidth; | ||||
|     private PopupWindow.OnDismissListener mOnDismissListener; | ||||
|     private final boolean mOverflowOnly; | ||||
|     private final int mPopupStyleAttr; | ||||
|     private final int mPopupStyleRes; | ||||
|     private MenuPresenter.Callback mPresenterCallback; | ||||
|     boolean mShouldCloseImmediately; | ||||
|     private boolean mShowTitle; | ||||
|     View mShownAnchorView; | ||||
|     final Handler mSubMenuHoverHandler; | ||||
|     ViewTreeObserver mTreeObserver; | ||||
|     private int mXOffset; | ||||
|     private int mYOffset; | ||||
|     private final List<MenuBuilder> mPendingMenus = new ArrayList(); | ||||
|     final List<CascadingMenuInfo> mShowingMenus = new ArrayList(); | ||||
|     final ViewTreeObserver.OnGlobalLayoutListener mGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { // from class: androidx.appcompat.view.menu.CascadingMenuPopup.1 | ||||
|         @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener | ||||
|         public void onGlobalLayout() { | ||||
|             if (!CascadingMenuPopup.this.isShowing() || CascadingMenuPopup.this.mShowingMenus.size() <= 0 || CascadingMenuPopup.this.mShowingMenus.get(0).window.isModal()) { | ||||
|                 return; | ||||
|             } | ||||
|             View view = CascadingMenuPopup.this.mShownAnchorView; | ||||
|             if (view == null || !view.isShown()) { | ||||
|                 CascadingMenuPopup.this.dismiss(); | ||||
|                 return; | ||||
|             } | ||||
|             Iterator<CascadingMenuInfo> it = CascadingMenuPopup.this.mShowingMenus.iterator(); | ||||
|             while (it.hasNext()) { | ||||
|                 it.next().window.show(); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|     private final View.OnAttachStateChangeListener mAttachStateChangeListener = new View.OnAttachStateChangeListener() { // from class: androidx.appcompat.view.menu.CascadingMenuPopup.2 | ||||
|         @Override // android.view.View.OnAttachStateChangeListener | ||||
|         public void onViewAttachedToWindow(View view) { | ||||
|         } | ||||
|  | ||||
|         @Override // android.view.View.OnAttachStateChangeListener | ||||
|         public void onViewDetachedFromWindow(View view) { | ||||
|             if (CascadingMenuPopup.this.mTreeObserver != null) { | ||||
|                 if (!CascadingMenuPopup.this.mTreeObserver.isAlive()) { | ||||
|                     CascadingMenuPopup.this.mTreeObserver = view.getViewTreeObserver(); | ||||
|                 } | ||||
|                 CascadingMenuPopup.this.mTreeObserver.removeGlobalOnLayoutListener(CascadingMenuPopup.this.mGlobalLayoutListener); | ||||
|             } | ||||
|             view.removeOnAttachStateChangeListener(this); | ||||
|         } | ||||
|     }; | ||||
|     private final MenuItemHoverListener mMenuItemHoverListener = new MenuItemHoverListener() { // from class: androidx.appcompat.view.menu.CascadingMenuPopup.3 | ||||
|         @Override // androidx.appcompat.widget.MenuItemHoverListener | ||||
|         public void onItemHoverExit(MenuBuilder menuBuilder, MenuItem menuItem) { | ||||
|             CascadingMenuPopup.this.mSubMenuHoverHandler.removeCallbacksAndMessages(menuBuilder); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.appcompat.widget.MenuItemHoverListener | ||||
|         public void onItemHoverEnter(final MenuBuilder menuBuilder, final MenuItem menuItem) { | ||||
|             CascadingMenuPopup.this.mSubMenuHoverHandler.removeCallbacksAndMessages(null); | ||||
|             int size = CascadingMenuPopup.this.mShowingMenus.size(); | ||||
|             int i = 0; | ||||
|             while (true) { | ||||
|                 if (i >= size) { | ||||
|                     i = -1; | ||||
|                     break; | ||||
|                 } else if (menuBuilder == CascadingMenuPopup.this.mShowingMenus.get(i).menu) { | ||||
|                     break; | ||||
|                 } else { | ||||
|                     i++; | ||||
|                 } | ||||
|             } | ||||
|             if (i == -1) { | ||||
|                 return; | ||||
|             } | ||||
|             int i2 = i + 1; | ||||
|             final CascadingMenuInfo cascadingMenuInfo = i2 < CascadingMenuPopup.this.mShowingMenus.size() ? CascadingMenuPopup.this.mShowingMenus.get(i2) : null; | ||||
|             CascadingMenuPopup.this.mSubMenuHoverHandler.postAtTime(new Runnable() { // from class: androidx.appcompat.view.menu.CascadingMenuPopup.3.1 | ||||
|                 @Override // java.lang.Runnable | ||||
|                 public void run() { | ||||
|                     if (cascadingMenuInfo != null) { | ||||
|                         CascadingMenuPopup.this.mShouldCloseImmediately = true; | ||||
|                         cascadingMenuInfo.menu.close(false); | ||||
|                         CascadingMenuPopup.this.mShouldCloseImmediately = false; | ||||
|                     } | ||||
|                     if (menuItem.isEnabled() && menuItem.hasSubMenu()) { | ||||
|                         menuBuilder.performItemAction(menuItem, 4); | ||||
|                     } | ||||
|                 } | ||||
|             }, menuBuilder, SystemClock.uptimeMillis() + 200); | ||||
|         } | ||||
|     }; | ||||
|     private int mRawDropDownGravity = 0; | ||||
|     private int mDropDownGravity = 0; | ||||
|     private boolean mForceShowIcon = false; | ||||
|     private int mLastPosition = getInitialMenuPosition(); | ||||
|  | ||||
|     @Retention(RetentionPolicy.SOURCE) | ||||
|     public @interface HorizPosition { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     protected boolean closeMenuOnSubMenuOpened() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean flagActionItems() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void onRestoreInstanceState(Parcelable parcelable) { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public Parcelable onSaveInstanceState() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void setCallback(MenuPresenter.Callback callback) { | ||||
|         this.mPresenterCallback = callback; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setForceShowIcon(boolean z) { | ||||
|         this.mForceShowIcon = z; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setHorizontalOffset(int i) { | ||||
|         this.mHasXOffset = true; | ||||
|         this.mXOffset = i; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setOnDismissListener(PopupWindow.OnDismissListener onDismissListener) { | ||||
|         this.mOnDismissListener = onDismissListener; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setShowTitle(boolean z) { | ||||
|         this.mShowTitle = z; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setVerticalOffset(int i) { | ||||
|         this.mHasYOffset = true; | ||||
|         this.mYOffset = i; | ||||
|     } | ||||
|  | ||||
|     public CascadingMenuPopup(Context context, View view, int i, int i2, boolean z) { | ||||
|         this.mContext = context; | ||||
|         this.mAnchorView = view; | ||||
|         this.mPopupStyleAttr = i; | ||||
|         this.mPopupStyleRes = i2; | ||||
|         this.mOverflowOnly = z; | ||||
|         Resources resources = context.getResources(); | ||||
|         this.mMenuMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth)); | ||||
|         this.mSubMenuHoverHandler = new Handler(); | ||||
|     } | ||||
|  | ||||
|     private MenuPopupWindow createPopupWindow() { | ||||
|         MenuPopupWindow menuPopupWindow = new MenuPopupWindow(this.mContext, null, this.mPopupStyleAttr, this.mPopupStyleRes); | ||||
|         menuPopupWindow.setHoverListener(this.mMenuItemHoverListener); | ||||
|         menuPopupWindow.setOnItemClickListener(this); | ||||
|         menuPopupWindow.setOnDismissListener(this); | ||||
|         menuPopupWindow.setAnchorView(this.mAnchorView); | ||||
|         menuPopupWindow.setDropDownGravity(this.mDropDownGravity); | ||||
|         menuPopupWindow.setModal(true); | ||||
|         menuPopupWindow.setInputMethodMode(2); | ||||
|         return menuPopupWindow; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.ShowableListMenu | ||||
|     public void show() { | ||||
|         if (isShowing()) { | ||||
|             return; | ||||
|         } | ||||
|         Iterator<MenuBuilder> it = this.mPendingMenus.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             showMenu(it.next()); | ||||
|         } | ||||
|         this.mPendingMenus.clear(); | ||||
|         View view = this.mAnchorView; | ||||
|         this.mShownAnchorView = view; | ||||
|         if (view != null) { | ||||
|             boolean z = this.mTreeObserver == null; | ||||
|             ViewTreeObserver viewTreeObserver = view.getViewTreeObserver(); | ||||
|             this.mTreeObserver = viewTreeObserver; | ||||
|             if (z) { | ||||
|                 viewTreeObserver.addOnGlobalLayoutListener(this.mGlobalLayoutListener); | ||||
|             } | ||||
|             this.mShownAnchorView.addOnAttachStateChangeListener(this.mAttachStateChangeListener); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.ShowableListMenu | ||||
|     public void dismiss() { | ||||
|         int size = this.mShowingMenus.size(); | ||||
|         if (size > 0) { | ||||
|             CascadingMenuInfo[] cascadingMenuInfoArr = (CascadingMenuInfo[]) this.mShowingMenus.toArray(new CascadingMenuInfo[size]); | ||||
|             for (int i = size - 1; i >= 0; i--) { | ||||
|                 CascadingMenuInfo cascadingMenuInfo = cascadingMenuInfoArr[i]; | ||||
|                 if (cascadingMenuInfo.window.isShowing()) { | ||||
|                     cascadingMenuInfo.window.dismiss(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View.OnKeyListener | ||||
|     public boolean onKey(View view, int i, KeyEvent keyEvent) { | ||||
|         if (keyEvent.getAction() != 1 || i != 82) { | ||||
|             return false; | ||||
|         } | ||||
|         dismiss(); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     private int getInitialMenuPosition() { | ||||
|         return ViewCompat.getLayoutDirection(this.mAnchorView) == 1 ? 0 : 1; | ||||
|     } | ||||
|  | ||||
|     private int getNextMenuPosition(int i) { | ||||
|         List<CascadingMenuInfo> list = this.mShowingMenus; | ||||
|         ListView listView = list.get(list.size() - 1).getListView(); | ||||
|         int[] iArr = new int[2]; | ||||
|         listView.getLocationOnScreen(iArr); | ||||
|         Rect rect = new Rect(); | ||||
|         this.mShownAnchorView.getWindowVisibleDisplayFrame(rect); | ||||
|         return this.mLastPosition == 1 ? (iArr[0] + listView.getWidth()) + i > rect.right ? 0 : 1 : iArr[0] - i < 0 ? 1 : 0; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void addMenu(MenuBuilder menuBuilder) { | ||||
|         menuBuilder.addMenuPresenter(this, this.mContext); | ||||
|         if (isShowing()) { | ||||
|             showMenu(menuBuilder); | ||||
|         } else { | ||||
|             this.mPendingMenus.add(menuBuilder); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void showMenu(MenuBuilder menuBuilder) { | ||||
|         CascadingMenuInfo cascadingMenuInfo; | ||||
|         View view; | ||||
|         int i; | ||||
|         int i2; | ||||
|         int i3; | ||||
|         LayoutInflater from = LayoutInflater.from(this.mContext); | ||||
|         MenuAdapter menuAdapter = new MenuAdapter(menuBuilder, from, this.mOverflowOnly, ITEM_LAYOUT); | ||||
|         if (!isShowing() && this.mForceShowIcon) { | ||||
|             menuAdapter.setForceShowIcon(true); | ||||
|         } else if (isShowing()) { | ||||
|             menuAdapter.setForceShowIcon(MenuPopup.shouldPreserveIconSpacing(menuBuilder)); | ||||
|         } | ||||
|         int measureIndividualMenuWidth = measureIndividualMenuWidth(menuAdapter, null, this.mContext, this.mMenuMaxWidth); | ||||
|         MenuPopupWindow createPopupWindow = createPopupWindow(); | ||||
|         createPopupWindow.setAdapter(menuAdapter); | ||||
|         createPopupWindow.setContentWidth(measureIndividualMenuWidth); | ||||
|         createPopupWindow.setDropDownGravity(this.mDropDownGravity); | ||||
|         if (this.mShowingMenus.size() > 0) { | ||||
|             List<CascadingMenuInfo> list = this.mShowingMenus; | ||||
|             cascadingMenuInfo = list.get(list.size() - 1); | ||||
|             view = findParentViewForSubmenu(cascadingMenuInfo, menuBuilder); | ||||
|         } else { | ||||
|             cascadingMenuInfo = null; | ||||
|             view = null; | ||||
|         } | ||||
|         if (view != null) { | ||||
|             createPopupWindow.setTouchModal(false); | ||||
|             createPopupWindow.setEnterTransition(null); | ||||
|             int nextMenuPosition = getNextMenuPosition(measureIndividualMenuWidth); | ||||
|             boolean z = nextMenuPosition == 1; | ||||
|             this.mLastPosition = nextMenuPosition; | ||||
|             if (Build.VERSION.SDK_INT >= 26) { | ||||
|                 createPopupWindow.setAnchorView(view); | ||||
|                 i2 = 0; | ||||
|                 i = 0; | ||||
|             } else { | ||||
|                 int[] iArr = new int[2]; | ||||
|                 this.mAnchorView.getLocationOnScreen(iArr); | ||||
|                 int[] iArr2 = new int[2]; | ||||
|                 view.getLocationOnScreen(iArr2); | ||||
|                 if ((this.mDropDownGravity & 7) == 5) { | ||||
|                     iArr[0] = iArr[0] + this.mAnchorView.getWidth(); | ||||
|                     iArr2[0] = iArr2[0] + view.getWidth(); | ||||
|                 } | ||||
|                 i = iArr2[0] - iArr[0]; | ||||
|                 i2 = iArr2[1] - iArr[1]; | ||||
|             } | ||||
|             if ((this.mDropDownGravity & 5) == 5) { | ||||
|                 if (!z) { | ||||
|                     measureIndividualMenuWidth = view.getWidth(); | ||||
|                     i3 = i - measureIndividualMenuWidth; | ||||
|                 } | ||||
|                 i3 = i + measureIndividualMenuWidth; | ||||
|             } else { | ||||
|                 if (z) { | ||||
|                     measureIndividualMenuWidth = view.getWidth(); | ||||
|                     i3 = i + measureIndividualMenuWidth; | ||||
|                 } | ||||
|                 i3 = i - measureIndividualMenuWidth; | ||||
|             } | ||||
|             createPopupWindow.setHorizontalOffset(i3); | ||||
|             createPopupWindow.setOverlapAnchor(true); | ||||
|             createPopupWindow.setVerticalOffset(i2); | ||||
|         } else { | ||||
|             if (this.mHasXOffset) { | ||||
|                 createPopupWindow.setHorizontalOffset(this.mXOffset); | ||||
|             } | ||||
|             if (this.mHasYOffset) { | ||||
|                 createPopupWindow.setVerticalOffset(this.mYOffset); | ||||
|             } | ||||
|             createPopupWindow.setEpicenterBounds(getEpicenterBounds()); | ||||
|         } | ||||
|         this.mShowingMenus.add(new CascadingMenuInfo(createPopupWindow, menuBuilder, this.mLastPosition)); | ||||
|         createPopupWindow.show(); | ||||
|         ListView listView = createPopupWindow.getListView(); | ||||
|         listView.setOnKeyListener(this); | ||||
|         if (cascadingMenuInfo == null && this.mShowTitle && menuBuilder.getHeaderTitle() != null) { | ||||
|             FrameLayout frameLayout = (FrameLayout) from.inflate(R.layout.abc_popup_menu_header_item_layout, (ViewGroup) listView, false); | ||||
|             TextView textView = (TextView) frameLayout.findViewById(android.R.id.title); | ||||
|             frameLayout.setEnabled(false); | ||||
|             textView.setText(menuBuilder.getHeaderTitle()); | ||||
|             listView.addHeaderView(frameLayout, null, false); | ||||
|             createPopupWindow.show(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private MenuItem findMenuItemForSubmenu(MenuBuilder menuBuilder, MenuBuilder menuBuilder2) { | ||||
|         int size = menuBuilder.size(); | ||||
|         for (int i = 0; i < size; i++) { | ||||
|             MenuItem item = menuBuilder.getItem(i); | ||||
|             if (item.hasSubMenu() && menuBuilder2 == item.getSubMenu()) { | ||||
|                 return item; | ||||
|             } | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     private View findParentViewForSubmenu(CascadingMenuInfo cascadingMenuInfo, MenuBuilder menuBuilder) { | ||||
|         MenuAdapter menuAdapter; | ||||
|         int i; | ||||
|         int firstVisiblePosition; | ||||
|         MenuItem findMenuItemForSubmenu = findMenuItemForSubmenu(cascadingMenuInfo.menu, menuBuilder); | ||||
|         if (findMenuItemForSubmenu == null) { | ||||
|             return null; | ||||
|         } | ||||
|         ListView listView = cascadingMenuInfo.getListView(); | ||||
|         ListAdapter adapter = listView.getAdapter(); | ||||
|         int i2 = 0; | ||||
|         if (adapter instanceof HeaderViewListAdapter) { | ||||
|             HeaderViewListAdapter headerViewListAdapter = (HeaderViewListAdapter) adapter; | ||||
|             i = headerViewListAdapter.getHeadersCount(); | ||||
|             menuAdapter = (MenuAdapter) headerViewListAdapter.getWrappedAdapter(); | ||||
|         } else { | ||||
|             menuAdapter = (MenuAdapter) adapter; | ||||
|             i = 0; | ||||
|         } | ||||
|         int count = menuAdapter.getCount(); | ||||
|         while (true) { | ||||
|             if (i2 >= count) { | ||||
|                 i2 = -1; | ||||
|                 break; | ||||
|             } | ||||
|             if (findMenuItemForSubmenu == menuAdapter.getItem(i2)) { | ||||
|                 break; | ||||
|             } | ||||
|             i2++; | ||||
|         } | ||||
|         if (i2 != -1 && (firstVisiblePosition = (i2 + i) - listView.getFirstVisiblePosition()) >= 0 && firstVisiblePosition < listView.getChildCount()) { | ||||
|             return listView.getChildAt(firstVisiblePosition); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.ShowableListMenu | ||||
|     public boolean isShowing() { | ||||
|         return this.mShowingMenus.size() > 0 && this.mShowingMenus.get(0).window.isShowing(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.PopupWindow.OnDismissListener | ||||
|     public void onDismiss() { | ||||
|         CascadingMenuInfo cascadingMenuInfo; | ||||
|         int size = this.mShowingMenus.size(); | ||||
|         int i = 0; | ||||
|         while (true) { | ||||
|             if (i >= size) { | ||||
|                 cascadingMenuInfo = null; | ||||
|                 break; | ||||
|             } | ||||
|             cascadingMenuInfo = this.mShowingMenus.get(i); | ||||
|             if (!cascadingMenuInfo.window.isShowing()) { | ||||
|                 break; | ||||
|             } else { | ||||
|                 i++; | ||||
|             } | ||||
|         } | ||||
|         if (cascadingMenuInfo != null) { | ||||
|             cascadingMenuInfo.menu.close(false); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void updateMenuView(boolean z) { | ||||
|         Iterator<CascadingMenuInfo> it = this.mShowingMenus.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             toMenuAdapter(it.next().getListView().getAdapter()).notifyDataSetChanged(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean onSubMenuSelected(SubMenuBuilder subMenuBuilder) { | ||||
|         for (CascadingMenuInfo cascadingMenuInfo : this.mShowingMenus) { | ||||
|             if (subMenuBuilder == cascadingMenuInfo.menu) { | ||||
|                 cascadingMenuInfo.getListView().requestFocus(); | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         if (!subMenuBuilder.hasVisibleItems()) { | ||||
|             return false; | ||||
|         } | ||||
|         addMenu(subMenuBuilder); | ||||
|         MenuPresenter.Callback callback = this.mPresenterCallback; | ||||
|         if (callback != null) { | ||||
|             callback.onOpenSubMenu(subMenuBuilder); | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     private int findIndexOfAddedMenu(MenuBuilder menuBuilder) { | ||||
|         int size = this.mShowingMenus.size(); | ||||
|         for (int i = 0; i < size; i++) { | ||||
|             if (menuBuilder == this.mShowingMenus.get(i).menu) { | ||||
|                 return i; | ||||
|             } | ||||
|         } | ||||
|         return -1; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void onCloseMenu(MenuBuilder menuBuilder, boolean z) { | ||||
|         int findIndexOfAddedMenu = findIndexOfAddedMenu(menuBuilder); | ||||
|         if (findIndexOfAddedMenu < 0) { | ||||
|             return; | ||||
|         } | ||||
|         int i = findIndexOfAddedMenu + 1; | ||||
|         if (i < this.mShowingMenus.size()) { | ||||
|             this.mShowingMenus.get(i).menu.close(false); | ||||
|         } | ||||
|         CascadingMenuInfo remove = this.mShowingMenus.remove(findIndexOfAddedMenu); | ||||
|         remove.menu.removeMenuPresenter(this); | ||||
|         if (this.mShouldCloseImmediately) { | ||||
|             remove.window.setExitTransition(null); | ||||
|             remove.window.setAnimationStyle(0); | ||||
|         } | ||||
|         remove.window.dismiss(); | ||||
|         int size = this.mShowingMenus.size(); | ||||
|         if (size > 0) { | ||||
|             this.mLastPosition = this.mShowingMenus.get(size - 1).position; | ||||
|         } else { | ||||
|             this.mLastPosition = getInitialMenuPosition(); | ||||
|         } | ||||
|         if (size != 0) { | ||||
|             if (z) { | ||||
|                 this.mShowingMenus.get(0).menu.close(false); | ||||
|                 return; | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         dismiss(); | ||||
|         MenuPresenter.Callback callback = this.mPresenterCallback; | ||||
|         if (callback != null) { | ||||
|             callback.onCloseMenu(menuBuilder, true); | ||||
|         } | ||||
|         ViewTreeObserver viewTreeObserver = this.mTreeObserver; | ||||
|         if (viewTreeObserver != null) { | ||||
|             if (viewTreeObserver.isAlive()) { | ||||
|                 this.mTreeObserver.removeGlobalOnLayoutListener(this.mGlobalLayoutListener); | ||||
|             } | ||||
|             this.mTreeObserver = null; | ||||
|         } | ||||
|         this.mShownAnchorView.removeOnAttachStateChangeListener(this.mAttachStateChangeListener); | ||||
|         this.mOnDismissListener.onDismiss(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setGravity(int i) { | ||||
|         if (this.mRawDropDownGravity != i) { | ||||
|             this.mRawDropDownGravity = i; | ||||
|             this.mDropDownGravity = GravityCompat.getAbsoluteGravity(i, ViewCompat.getLayoutDirection(this.mAnchorView)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setAnchorView(View view) { | ||||
|         if (this.mAnchorView != view) { | ||||
|             this.mAnchorView = view; | ||||
|             this.mDropDownGravity = GravityCompat.getAbsoluteGravity(this.mRawDropDownGravity, ViewCompat.getLayoutDirection(view)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.ShowableListMenu | ||||
|     public ListView getListView() { | ||||
|         if (this.mShowingMenus.isEmpty()) { | ||||
|             return null; | ||||
|         } | ||||
|         return this.mShowingMenus.get(r0.size() - 1).getListView(); | ||||
|     } | ||||
|  | ||||
|     private static class CascadingMenuInfo { | ||||
|         public final MenuBuilder menu; | ||||
|         public final int position; | ||||
|         public final MenuPopupWindow window; | ||||
|  | ||||
|         public CascadingMenuInfo(MenuPopupWindow menuPopupWindow, MenuBuilder menuBuilder, int i) { | ||||
|             this.window = menuPopupWindow; | ||||
|             this.menu = menuBuilder; | ||||
|             this.position = i; | ||||
|         } | ||||
|  | ||||
|         public ListView getListView() { | ||||
|             return this.window.getListView(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,60 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.R; | ||||
| import android.content.Context; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.View; | ||||
| import android.widget.AdapterView; | ||||
| import android.widget.ListView; | ||||
| import androidx.appcompat.view.menu.MenuBuilder; | ||||
| import androidx.appcompat.widget.TintTypedArray; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public final class ExpandedMenuView extends ListView implements MenuBuilder.ItemInvoker, MenuView, AdapterView.OnItemClickListener { | ||||
|     private static final int[] TINT_ATTRS = {R.attr.background, R.attr.divider}; | ||||
|     private int mAnimations; | ||||
|     private MenuBuilder mMenu; | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView | ||||
|     public int getWindowAnimations() { | ||||
|         return this.mAnimations; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView | ||||
|     public void initialize(MenuBuilder menuBuilder) { | ||||
|         this.mMenu = menuBuilder; | ||||
|     } | ||||
|  | ||||
|     public ExpandedMenuView(Context context, AttributeSet attributeSet) { | ||||
|         this(context, attributeSet, R.attr.listViewStyle); | ||||
|     } | ||||
|  | ||||
|     public ExpandedMenuView(Context context, AttributeSet attributeSet, int i) { | ||||
|         super(context, attributeSet); | ||||
|         setOnItemClickListener(this); | ||||
|         TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, attributeSet, TINT_ATTRS, i, 0); | ||||
|         if (obtainStyledAttributes.hasValue(0)) { | ||||
|             setBackgroundDrawable(obtainStyledAttributes.getDrawable(0)); | ||||
|         } | ||||
|         if (obtainStyledAttributes.hasValue(1)) { | ||||
|             setDivider(obtainStyledAttributes.getDrawable(1)); | ||||
|         } | ||||
|         obtainStyledAttributes.recycle(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.ListView, android.widget.AbsListView, android.widget.AdapterView, android.view.ViewGroup, android.view.View | ||||
|     protected void onDetachedFromWindow() { | ||||
|         super.onDetachedFromWindow(); | ||||
|         setChildrenDrawingCacheEnabled(false); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder.ItemInvoker | ||||
|     public boolean invokeItem(MenuItemImpl menuItemImpl) { | ||||
|         return this.mMenu.performItemAction(menuItemImpl, 0); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.AdapterView.OnItemClickListener | ||||
|     public void onItemClick(AdapterView adapterView, View view, int i, long j) { | ||||
|         invokeItem((MenuItemImpl) getAdapter().getItem(i)); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,299 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.TypedArray; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.AbsListView; | ||||
| import android.widget.CheckBox; | ||||
| import android.widget.CompoundButton; | ||||
| import android.widget.ImageView; | ||||
| import android.widget.LinearLayout; | ||||
| import android.widget.RadioButton; | ||||
| import android.widget.TextView; | ||||
| import androidx.appcompat.R; | ||||
| import androidx.appcompat.view.menu.MenuView; | ||||
| import androidx.appcompat.widget.TintTypedArray; | ||||
| import androidx.core.view.ViewCompat; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class ListMenuItemView extends LinearLayout implements MenuView.ItemView, AbsListView.SelectionBoundsAdjuster { | ||||
|     private static final String TAG = "ListMenuItemView"; | ||||
|     private Drawable mBackground; | ||||
|     private CheckBox mCheckBox; | ||||
|     private LinearLayout mContent; | ||||
|     private boolean mForceShowIcon; | ||||
|     private ImageView mGroupDivider; | ||||
|     private boolean mHasListDivider; | ||||
|     private ImageView mIconView; | ||||
|     private LayoutInflater mInflater; | ||||
|     private MenuItemImpl mItemData; | ||||
|     private boolean mPreserveIconSpacing; | ||||
|     private RadioButton mRadioButton; | ||||
|     private TextView mShortcutView; | ||||
|     private Drawable mSubMenuArrow; | ||||
|     private ImageView mSubMenuArrowView; | ||||
|     private int mTextAppearance; | ||||
|     private Context mTextAppearanceContext; | ||||
|     private TextView mTitleView; | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public MenuItemImpl getItemData() { | ||||
|         return this.mItemData; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public boolean prefersCondensedTitle() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public void setForceShowIcon(boolean z) { | ||||
|         this.mForceShowIcon = z; | ||||
|         this.mPreserveIconSpacing = z; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public boolean showsIcon() { | ||||
|         return this.mForceShowIcon; | ||||
|     } | ||||
|  | ||||
|     public ListMenuItemView(Context context, AttributeSet attributeSet) { | ||||
|         this(context, attributeSet, R.attr.listMenuViewStyle); | ||||
|     } | ||||
|  | ||||
|     public ListMenuItemView(Context context, AttributeSet attributeSet, int i) { | ||||
|         super(context, attributeSet); | ||||
|         TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(getContext(), attributeSet, R.styleable.MenuView, i, 0); | ||||
|         this.mBackground = obtainStyledAttributes.getDrawable(R.styleable.MenuView_android_itemBackground); | ||||
|         this.mTextAppearance = obtainStyledAttributes.getResourceId(R.styleable.MenuView_android_itemTextAppearance, -1); | ||||
|         this.mPreserveIconSpacing = obtainStyledAttributes.getBoolean(R.styleable.MenuView_preserveIconSpacing, false); | ||||
|         this.mTextAppearanceContext = context; | ||||
|         this.mSubMenuArrow = obtainStyledAttributes.getDrawable(R.styleable.MenuView_subMenuArrow); | ||||
|         TypedArray obtainStyledAttributes2 = context.getTheme().obtainStyledAttributes(null, new int[]{android.R.attr.divider}, R.attr.dropDownListViewStyle, 0); | ||||
|         this.mHasListDivider = obtainStyledAttributes2.hasValue(0); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         obtainStyledAttributes2.recycle(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     protected void onFinishInflate() { | ||||
|         super.onFinishInflate(); | ||||
|         ViewCompat.setBackground(this, this.mBackground); | ||||
|         TextView textView = (TextView) findViewById(R.id.title); | ||||
|         this.mTitleView = textView; | ||||
|         int i = this.mTextAppearance; | ||||
|         if (i != -1) { | ||||
|             textView.setTextAppearance(this.mTextAppearanceContext, i); | ||||
|         } | ||||
|         this.mShortcutView = (TextView) findViewById(R.id.shortcut); | ||||
|         ImageView imageView = (ImageView) findViewById(R.id.submenuarrow); | ||||
|         this.mSubMenuArrowView = imageView; | ||||
|         if (imageView != null) { | ||||
|             imageView.setImageDrawable(this.mSubMenuArrow); | ||||
|         } | ||||
|         this.mGroupDivider = (ImageView) findViewById(R.id.group_divider); | ||||
|         this.mContent = (LinearLayout) findViewById(R.id.content); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void initialize(MenuItemImpl menuItemImpl, int i) { | ||||
|         this.mItemData = menuItemImpl; | ||||
|         setVisibility(menuItemImpl.isVisible() ? 0 : 8); | ||||
|         setTitle(menuItemImpl.getTitleForItemView(this)); | ||||
|         setCheckable(menuItemImpl.isCheckable()); | ||||
|         setShortcut(menuItemImpl.shouldShowShortcut(), menuItemImpl.getShortcut()); | ||||
|         setIcon(menuItemImpl.getIcon()); | ||||
|         setEnabled(menuItemImpl.isEnabled()); | ||||
|         setSubMenuArrowVisible(menuItemImpl.hasSubMenu()); | ||||
|         setContentDescription(menuItemImpl.getContentDescription()); | ||||
|     } | ||||
|  | ||||
|     private void addContentView(View view) { | ||||
|         addContentView(view, -1); | ||||
|     } | ||||
|  | ||||
|     private void addContentView(View view, int i) { | ||||
|         LinearLayout linearLayout = this.mContent; | ||||
|         if (linearLayout != null) { | ||||
|             linearLayout.addView(view, i); | ||||
|         } else { | ||||
|             addView(view, i); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setTitle(CharSequence charSequence) { | ||||
|         if (charSequence != null) { | ||||
|             this.mTitleView.setText(charSequence); | ||||
|             if (this.mTitleView.getVisibility() != 0) { | ||||
|                 this.mTitleView.setVisibility(0); | ||||
|                 return; | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         if (this.mTitleView.getVisibility() != 8) { | ||||
|             this.mTitleView.setVisibility(8); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setCheckable(boolean z) { | ||||
|         CompoundButton compoundButton; | ||||
|         CompoundButton compoundButton2; | ||||
|         if (!z && this.mRadioButton == null && this.mCheckBox == null) { | ||||
|             return; | ||||
|         } | ||||
|         if (this.mItemData.isExclusiveCheckable()) { | ||||
|             if (this.mRadioButton == null) { | ||||
|                 insertRadioButton(); | ||||
|             } | ||||
|             compoundButton = this.mRadioButton; | ||||
|             compoundButton2 = this.mCheckBox; | ||||
|         } else { | ||||
|             if (this.mCheckBox == null) { | ||||
|                 insertCheckBox(); | ||||
|             } | ||||
|             compoundButton = this.mCheckBox; | ||||
|             compoundButton2 = this.mRadioButton; | ||||
|         } | ||||
|         if (z) { | ||||
|             compoundButton.setChecked(this.mItemData.isChecked()); | ||||
|             if (compoundButton.getVisibility() != 0) { | ||||
|                 compoundButton.setVisibility(0); | ||||
|             } | ||||
|             if (compoundButton2 == null || compoundButton2.getVisibility() == 8) { | ||||
|                 return; | ||||
|             } | ||||
|             compoundButton2.setVisibility(8); | ||||
|             return; | ||||
|         } | ||||
|         CheckBox checkBox = this.mCheckBox; | ||||
|         if (checkBox != null) { | ||||
|             checkBox.setVisibility(8); | ||||
|         } | ||||
|         RadioButton radioButton = this.mRadioButton; | ||||
|         if (radioButton != null) { | ||||
|             radioButton.setVisibility(8); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setChecked(boolean z) { | ||||
|         CompoundButton compoundButton; | ||||
|         if (this.mItemData.isExclusiveCheckable()) { | ||||
|             if (this.mRadioButton == null) { | ||||
|                 insertRadioButton(); | ||||
|             } | ||||
|             compoundButton = this.mRadioButton; | ||||
|         } else { | ||||
|             if (this.mCheckBox == null) { | ||||
|                 insertCheckBox(); | ||||
|             } | ||||
|             compoundButton = this.mCheckBox; | ||||
|         } | ||||
|         compoundButton.setChecked(z); | ||||
|     } | ||||
|  | ||||
|     private void setSubMenuArrowVisible(boolean z) { | ||||
|         ImageView imageView = this.mSubMenuArrowView; | ||||
|         if (imageView != null) { | ||||
|             imageView.setVisibility(z ? 0 : 8); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setShortcut(boolean z, char c) { | ||||
|         int i = (z && this.mItemData.shouldShowShortcut()) ? 0 : 8; | ||||
|         if (i == 0) { | ||||
|             this.mShortcutView.setText(this.mItemData.getShortcutLabel()); | ||||
|         } | ||||
|         if (this.mShortcutView.getVisibility() != i) { | ||||
|             this.mShortcutView.setVisibility(i); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuView.ItemView | ||||
|     public void setIcon(Drawable drawable) { | ||||
|         boolean z = this.mItemData.shouldShowIcon() || this.mForceShowIcon; | ||||
|         if (z || this.mPreserveIconSpacing) { | ||||
|             ImageView imageView = this.mIconView; | ||||
|             if (imageView == null && drawable == null && !this.mPreserveIconSpacing) { | ||||
|                 return; | ||||
|             } | ||||
|             if (imageView == null) { | ||||
|                 insertIconView(); | ||||
|             } | ||||
|             if (drawable != null || this.mPreserveIconSpacing) { | ||||
|                 ImageView imageView2 = this.mIconView; | ||||
|                 if (!z) { | ||||
|                     drawable = null; | ||||
|                 } | ||||
|                 imageView2.setImageDrawable(drawable); | ||||
|                 if (this.mIconView.getVisibility() != 0) { | ||||
|                     this.mIconView.setVisibility(0); | ||||
|                     return; | ||||
|                 } | ||||
|                 return; | ||||
|             } | ||||
|             this.mIconView.setVisibility(8); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.LinearLayout, android.view.View | ||||
|     protected void onMeasure(int i, int i2) { | ||||
|         if (this.mIconView != null && this.mPreserveIconSpacing) { | ||||
|             ViewGroup.LayoutParams layoutParams = getLayoutParams(); | ||||
|             LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.mIconView.getLayoutParams(); | ||||
|             if (layoutParams.height > 0 && layoutParams2.width <= 0) { | ||||
|                 layoutParams2.width = layoutParams.height; | ||||
|             } | ||||
|         } | ||||
|         super.onMeasure(i, i2); | ||||
|     } | ||||
|  | ||||
|     private void insertIconView() { | ||||
|         ImageView imageView = (ImageView) getInflater().inflate(R.layout.abc_list_menu_item_icon, (ViewGroup) this, false); | ||||
|         this.mIconView = imageView; | ||||
|         addContentView(imageView, 0); | ||||
|     } | ||||
|  | ||||
|     private void insertRadioButton() { | ||||
|         RadioButton radioButton = (RadioButton) getInflater().inflate(R.layout.abc_list_menu_item_radio, (ViewGroup) this, false); | ||||
|         this.mRadioButton = radioButton; | ||||
|         addContentView(radioButton); | ||||
|     } | ||||
|  | ||||
|     private void insertCheckBox() { | ||||
|         CheckBox checkBox = (CheckBox) getInflater().inflate(R.layout.abc_list_menu_item_checkbox, (ViewGroup) this, false); | ||||
|         this.mCheckBox = checkBox; | ||||
|         addContentView(checkBox); | ||||
|     } | ||||
|  | ||||
|     private LayoutInflater getInflater() { | ||||
|         if (this.mInflater == null) { | ||||
|             this.mInflater = LayoutInflater.from(getContext()); | ||||
|         } | ||||
|         return this.mInflater; | ||||
|     } | ||||
|  | ||||
|     public void setGroupDividerEnabled(boolean z) { | ||||
|         ImageView imageView = this.mGroupDivider; | ||||
|         if (imageView != null) { | ||||
|             imageView.setVisibility((this.mHasListDivider || !z) ? 8 : 0); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.AbsListView.SelectionBoundsAdjuster | ||||
|     public void adjustListItemSelectionBounds(Rect rect) { | ||||
|         ImageView imageView = this.mGroupDivider; | ||||
|         if (imageView == null || imageView.getVisibility() != 0) { | ||||
|             return; | ||||
|         } | ||||
|         LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.mGroupDivider.getLayoutParams(); | ||||
|         rect.top += this.mGroupDivider.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,249 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.os.Bundle; | ||||
| import android.os.Parcelable; | ||||
| import android.util.SparseArray; | ||||
| import android.view.ContextThemeWrapper; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.AdapterView; | ||||
| import android.widget.BaseAdapter; | ||||
| import android.widget.ListAdapter; | ||||
| import androidx.appcompat.R; | ||||
| import androidx.appcompat.view.menu.MenuPresenter; | ||||
| import androidx.appcompat.view.menu.MenuView; | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class ListMenuPresenter implements MenuPresenter, AdapterView.OnItemClickListener { | ||||
|     private static final String TAG = "ListMenuPresenter"; | ||||
|     public static final String VIEWS_TAG = "android:menu:list"; | ||||
|     MenuAdapter mAdapter; | ||||
|     private MenuPresenter.Callback mCallback; | ||||
|     Context mContext; | ||||
|     private int mId; | ||||
|     LayoutInflater mInflater; | ||||
|     int mItemIndexOffset; | ||||
|     int mItemLayoutRes; | ||||
|     MenuBuilder mMenu; | ||||
|     ExpandedMenuView mMenuView; | ||||
|     int mThemeRes; | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean collapseItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean expandItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean flagActionItems() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public int getId() { | ||||
|         return this.mId; | ||||
|     } | ||||
|  | ||||
|     int getItemIndexOffset() { | ||||
|         return this.mItemIndexOffset; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void setCallback(MenuPresenter.Callback callback) { | ||||
|         this.mCallback = callback; | ||||
|     } | ||||
|  | ||||
|     public void setId(int i) { | ||||
|         this.mId = i; | ||||
|     } | ||||
|  | ||||
|     public ListMenuPresenter(Context context, int i) { | ||||
|         this(i, 0); | ||||
|         this.mContext = context; | ||||
|         this.mInflater = LayoutInflater.from(context); | ||||
|     } | ||||
|  | ||||
|     public ListMenuPresenter(int i, int i2) { | ||||
|         this.mItemLayoutRes = i; | ||||
|         this.mThemeRes = i2; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void initForMenu(Context context, MenuBuilder menuBuilder) { | ||||
|         if (this.mThemeRes != 0) { | ||||
|             ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, this.mThemeRes); | ||||
|             this.mContext = contextThemeWrapper; | ||||
|             this.mInflater = LayoutInflater.from(contextThemeWrapper); | ||||
|         } else if (this.mContext != null) { | ||||
|             this.mContext = context; | ||||
|             if (this.mInflater == null) { | ||||
|                 this.mInflater = LayoutInflater.from(context); | ||||
|             } | ||||
|         } | ||||
|         this.mMenu = menuBuilder; | ||||
|         MenuAdapter menuAdapter = this.mAdapter; | ||||
|         if (menuAdapter != null) { | ||||
|             menuAdapter.notifyDataSetChanged(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public MenuView getMenuView(ViewGroup viewGroup) { | ||||
|         if (this.mMenuView == null) { | ||||
|             this.mMenuView = (ExpandedMenuView) this.mInflater.inflate(R.layout.abc_expanded_menu_layout, viewGroup, false); | ||||
|             if (this.mAdapter == null) { | ||||
|                 this.mAdapter = new MenuAdapter(); | ||||
|             } | ||||
|             this.mMenuView.setAdapter((ListAdapter) this.mAdapter); | ||||
|             this.mMenuView.setOnItemClickListener(this); | ||||
|         } | ||||
|         return this.mMenuView; | ||||
|     } | ||||
|  | ||||
|     public ListAdapter getAdapter() { | ||||
|         if (this.mAdapter == null) { | ||||
|             this.mAdapter = new MenuAdapter(); | ||||
|         } | ||||
|         return this.mAdapter; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void updateMenuView(boolean z) { | ||||
|         MenuAdapter menuAdapter = this.mAdapter; | ||||
|         if (menuAdapter != null) { | ||||
|             menuAdapter.notifyDataSetChanged(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean onSubMenuSelected(SubMenuBuilder subMenuBuilder) { | ||||
|         if (!subMenuBuilder.hasVisibleItems()) { | ||||
|             return false; | ||||
|         } | ||||
|         new MenuDialogHelper(subMenuBuilder).show(null); | ||||
|         MenuPresenter.Callback callback = this.mCallback; | ||||
|         if (callback == null) { | ||||
|             return true; | ||||
|         } | ||||
|         callback.onOpenSubMenu(subMenuBuilder); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void onCloseMenu(MenuBuilder menuBuilder, boolean z) { | ||||
|         MenuPresenter.Callback callback = this.mCallback; | ||||
|         if (callback != null) { | ||||
|             callback.onCloseMenu(menuBuilder, z); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void setItemIndexOffset(int i) { | ||||
|         this.mItemIndexOffset = i; | ||||
|         if (this.mMenuView != null) { | ||||
|             updateMenuView(false); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.AdapterView.OnItemClickListener | ||||
|     public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) { | ||||
|         this.mMenu.performItemAction(this.mAdapter.getItem(i), this, 0); | ||||
|     } | ||||
|  | ||||
|     public void saveHierarchyState(Bundle bundle) { | ||||
|         SparseArray<Parcelable> sparseArray = new SparseArray<>(); | ||||
|         ExpandedMenuView expandedMenuView = this.mMenuView; | ||||
|         if (expandedMenuView != null) { | ||||
|             expandedMenuView.saveHierarchyState(sparseArray); | ||||
|         } | ||||
|         bundle.putSparseParcelableArray(VIEWS_TAG, sparseArray); | ||||
|     } | ||||
|  | ||||
|     public void restoreHierarchyState(Bundle bundle) { | ||||
|         SparseArray<Parcelable> sparseParcelableArray = bundle.getSparseParcelableArray(VIEWS_TAG); | ||||
|         if (sparseParcelableArray != null) { | ||||
|             this.mMenuView.restoreHierarchyState(sparseParcelableArray); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public Parcelable onSaveInstanceState() { | ||||
|         if (this.mMenuView == null) { | ||||
|             return null; | ||||
|         } | ||||
|         Bundle bundle = new Bundle(); | ||||
|         saveHierarchyState(bundle); | ||||
|         return bundle; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void onRestoreInstanceState(Parcelable parcelable) { | ||||
|         restoreHierarchyState((Bundle) parcelable); | ||||
|     } | ||||
|  | ||||
|     private class MenuAdapter extends BaseAdapter { | ||||
|         private int mExpandedIndex = -1; | ||||
|  | ||||
|         @Override // android.widget.Adapter | ||||
|         public long getItemId(int i) { | ||||
|             return i; | ||||
|         } | ||||
|  | ||||
|         public MenuAdapter() { | ||||
|             findExpandedIndex(); | ||||
|         } | ||||
|  | ||||
|         @Override // android.widget.Adapter | ||||
|         public int getCount() { | ||||
|             int size = ListMenuPresenter.this.mMenu.getNonActionItems().size() - ListMenuPresenter.this.mItemIndexOffset; | ||||
|             return this.mExpandedIndex < 0 ? size : size - 1; | ||||
|         } | ||||
|  | ||||
|         @Override // android.widget.Adapter | ||||
|         public MenuItemImpl getItem(int i) { | ||||
|             ArrayList<MenuItemImpl> nonActionItems = ListMenuPresenter.this.mMenu.getNonActionItems(); | ||||
|             int i2 = i + ListMenuPresenter.this.mItemIndexOffset; | ||||
|             int i3 = this.mExpandedIndex; | ||||
|             if (i3 >= 0 && i2 >= i3) { | ||||
|                 i2++; | ||||
|             } | ||||
|             return nonActionItems.get(i2); | ||||
|         } | ||||
|  | ||||
|         @Override // android.widget.Adapter | ||||
|         public View getView(int i, View view, ViewGroup viewGroup) { | ||||
|             if (view == null) { | ||||
|                 view = ListMenuPresenter.this.mInflater.inflate(ListMenuPresenter.this.mItemLayoutRes, viewGroup, false); | ||||
|             } | ||||
|             ((MenuView.ItemView) view).initialize(getItem(i), 0); | ||||
|             return view; | ||||
|         } | ||||
|  | ||||
|         void findExpandedIndex() { | ||||
|             MenuItemImpl expandedItem = ListMenuPresenter.this.mMenu.getExpandedItem(); | ||||
|             if (expandedItem != null) { | ||||
|                 ArrayList<MenuItemImpl> nonActionItems = ListMenuPresenter.this.mMenu.getNonActionItems(); | ||||
|                 int size = nonActionItems.size(); | ||||
|                 for (int i = 0; i < size; i++) { | ||||
|                     if (nonActionItems.get(i) == expandedItem) { | ||||
|                         this.mExpandedIndex = i; | ||||
|                         return; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             this.mExpandedIndex = -1; | ||||
|         } | ||||
|  | ||||
|         @Override // android.widget.BaseAdapter | ||||
|         public void notifyDataSetChanged() { | ||||
|             findExpandedIndex(); | ||||
|             super.notifyDataSetChanged(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,100 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.BaseAdapter; | ||||
| import androidx.appcompat.view.menu.MenuView; | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MenuAdapter extends BaseAdapter { | ||||
|     MenuBuilder mAdapterMenu; | ||||
|     private int mExpandedIndex = -1; | ||||
|     private boolean mForceShowIcon; | ||||
|     private final LayoutInflater mInflater; | ||||
|     private final int mItemLayoutRes; | ||||
|     private final boolean mOverflowOnly; | ||||
|  | ||||
|     public MenuBuilder getAdapterMenu() { | ||||
|         return this.mAdapterMenu; | ||||
|     } | ||||
|  | ||||
|     public boolean getForceShowIcon() { | ||||
|         return this.mForceShowIcon; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public long getItemId(int i) { | ||||
|         return i; | ||||
|     } | ||||
|  | ||||
|     public void setForceShowIcon(boolean z) { | ||||
|         this.mForceShowIcon = z; | ||||
|     } | ||||
|  | ||||
|     public MenuAdapter(MenuBuilder menuBuilder, LayoutInflater layoutInflater, boolean z, int i) { | ||||
|         this.mOverflowOnly = z; | ||||
|         this.mInflater = layoutInflater; | ||||
|         this.mAdapterMenu = menuBuilder; | ||||
|         this.mItemLayoutRes = i; | ||||
|         findExpandedIndex(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public int getCount() { | ||||
|         ArrayList<MenuItemImpl> nonActionItems = this.mOverflowOnly ? this.mAdapterMenu.getNonActionItems() : this.mAdapterMenu.getVisibleItems(); | ||||
|         if (this.mExpandedIndex < 0) { | ||||
|             return nonActionItems.size(); | ||||
|         } | ||||
|         return nonActionItems.size() - 1; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public MenuItemImpl getItem(int i) { | ||||
|         ArrayList<MenuItemImpl> nonActionItems = this.mOverflowOnly ? this.mAdapterMenu.getNonActionItems() : this.mAdapterMenu.getVisibleItems(); | ||||
|         int i2 = this.mExpandedIndex; | ||||
|         if (i2 >= 0 && i >= i2) { | ||||
|             i++; | ||||
|         } | ||||
|         return nonActionItems.get(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public View getView(int i, View view, ViewGroup viewGroup) { | ||||
|         if (view == null) { | ||||
|             view = this.mInflater.inflate(this.mItemLayoutRes, viewGroup, false); | ||||
|         } | ||||
|         int groupId = getItem(i).getGroupId(); | ||||
|         int i2 = i - 1; | ||||
|         ListMenuItemView listMenuItemView = (ListMenuItemView) view; | ||||
|         listMenuItemView.setGroupDividerEnabled(this.mAdapterMenu.isGroupDividerEnabled() && groupId != (i2 >= 0 ? getItem(i2).getGroupId() : groupId)); | ||||
|         MenuView.ItemView itemView = (MenuView.ItemView) view; | ||||
|         if (this.mForceShowIcon) { | ||||
|             listMenuItemView.setForceShowIcon(true); | ||||
|         } | ||||
|         itemView.initialize(getItem(i), 0); | ||||
|         return view; | ||||
|     } | ||||
|  | ||||
|     void findExpandedIndex() { | ||||
|         MenuItemImpl expandedItem = this.mAdapterMenu.getExpandedItem(); | ||||
|         if (expandedItem != null) { | ||||
|             ArrayList<MenuItemImpl> nonActionItems = this.mAdapterMenu.getNonActionItems(); | ||||
|             int size = nonActionItems.size(); | ||||
|             for (int i = 0; i < size; i++) { | ||||
|                 if (nonActionItems.get(i) == expandedItem) { | ||||
|                     this.mExpandedIndex = i; | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         this.mExpandedIndex = -1; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.BaseAdapter | ||||
|     public void notifyDataSetChanged() { | ||||
|         findExpandedIndex(); | ||||
|         super.notifyDataSetChanged(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,982 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.ComponentName; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.pm.PackageManager; | ||||
| import android.content.pm.ResolveInfo; | ||||
| import android.content.res.Resources; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.os.Bundle; | ||||
| import android.os.Parcelable; | ||||
| import android.util.SparseArray; | ||||
| import android.view.ContextMenu; | ||||
| import android.view.KeyCharacterMap; | ||||
| import android.view.KeyEvent; | ||||
| import android.view.MenuItem; | ||||
| import android.view.SubMenu; | ||||
| import android.view.View; | ||||
| import androidx.core.content.ContextCompat; | ||||
| import androidx.core.internal.view.SupportMenu; | ||||
| import androidx.core.view.ActionProvider; | ||||
| import java.lang.ref.WeakReference; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.CopyOnWriteArrayList; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MenuBuilder implements SupportMenu { | ||||
|     private static final String ACTION_VIEW_STATES_KEY = "android:menu:actionviewstates"; | ||||
|     private static final String EXPANDED_ACTION_VIEW_ID = "android:menu:expandedactionview"; | ||||
|     private static final String PRESENTER_KEY = "android:menu:presenters"; | ||||
|     private static final String TAG = "MenuBuilder"; | ||||
|     private static final int[] sCategoryToOrder = {1, 4, 5, 3, 2, 0}; | ||||
|     private Callback mCallback; | ||||
|     private final Context mContext; | ||||
|     private ContextMenu.ContextMenuInfo mCurrentMenuInfo; | ||||
|     private MenuItemImpl mExpandedItem; | ||||
|     Drawable mHeaderIcon; | ||||
|     CharSequence mHeaderTitle; | ||||
|     View mHeaderView; | ||||
|     private boolean mOverrideVisibleItems; | ||||
|     private boolean mQwertyMode; | ||||
|     private final Resources mResources; | ||||
|     private boolean mShortcutsVisible; | ||||
|     private int mDefaultShowAsAction = 0; | ||||
|     private boolean mPreventDispatchingItemsChanged = false; | ||||
|     private boolean mItemsChangedWhileDispatchPrevented = false; | ||||
|     private boolean mStructureChangedWhileDispatchPrevented = false; | ||||
|     private boolean mOptionalIconsVisible = false; | ||||
|     private boolean mIsClosing = false; | ||||
|     private ArrayList<MenuItemImpl> mTempShortcutItemList = new ArrayList<>(); | ||||
|     private CopyOnWriteArrayList<WeakReference<MenuPresenter>> mPresenters = new CopyOnWriteArrayList<>(); | ||||
|     private boolean mGroupDividerEnabled = false; | ||||
|     private ArrayList<MenuItemImpl> mItems = new ArrayList<>(); | ||||
|     private ArrayList<MenuItemImpl> mVisibleItems = new ArrayList<>(); | ||||
|     private boolean mIsVisibleItemsStale = true; | ||||
|     private ArrayList<MenuItemImpl> mActionItems = new ArrayList<>(); | ||||
|     private ArrayList<MenuItemImpl> mNonActionItems = new ArrayList<>(); | ||||
|     private boolean mIsActionItemsStale = true; | ||||
|  | ||||
|     public interface Callback { | ||||
|         boolean onMenuItemSelected(MenuBuilder menuBuilder, MenuItem menuItem); | ||||
|  | ||||
|         void onMenuModeChange(MenuBuilder menuBuilder); | ||||
|     } | ||||
|  | ||||
|     public interface ItemInvoker { | ||||
|         boolean invokeItem(MenuItemImpl menuItemImpl); | ||||
|     } | ||||
|  | ||||
|     protected String getActionViewStatesKey() { | ||||
|         return ACTION_VIEW_STATES_KEY; | ||||
|     } | ||||
|  | ||||
|     public Context getContext() { | ||||
|         return this.mContext; | ||||
|     } | ||||
|  | ||||
|     public MenuItemImpl getExpandedItem() { | ||||
|         return this.mExpandedItem; | ||||
|     } | ||||
|  | ||||
|     public Drawable getHeaderIcon() { | ||||
|         return this.mHeaderIcon; | ||||
|     } | ||||
|  | ||||
|     public CharSequence getHeaderTitle() { | ||||
|         return this.mHeaderTitle; | ||||
|     } | ||||
|  | ||||
|     public View getHeaderView() { | ||||
|         return this.mHeaderView; | ||||
|     } | ||||
|  | ||||
|     boolean getOptionalIconsVisible() { | ||||
|         return this.mOptionalIconsVisible; | ||||
|     } | ||||
|  | ||||
|     Resources getResources() { | ||||
|         return this.mResources; | ||||
|     } | ||||
|  | ||||
|     public MenuBuilder getRootMenu() { | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public boolean isGroupDividerEnabled() { | ||||
|         return this.mGroupDividerEnabled; | ||||
|     } | ||||
|  | ||||
|     boolean isQwertyMode() { | ||||
|         return this.mQwertyMode; | ||||
|     } | ||||
|  | ||||
|     public boolean isShortcutsVisible() { | ||||
|         return this.mShortcutsVisible; | ||||
|     } | ||||
|  | ||||
|     public void setCallback(Callback callback) { | ||||
|         this.mCallback = callback; | ||||
|     } | ||||
|  | ||||
|     public void setCurrentMenuInfo(ContextMenu.ContextMenuInfo contextMenuInfo) { | ||||
|         this.mCurrentMenuInfo = contextMenuInfo; | ||||
|     } | ||||
|  | ||||
|     public MenuBuilder setDefaultShowAsAction(int i) { | ||||
|         this.mDefaultShowAsAction = i; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenu, android.view.Menu | ||||
|     public void setGroupDividerEnabled(boolean z) { | ||||
|         this.mGroupDividerEnabled = z; | ||||
|     } | ||||
|  | ||||
|     public void setOptionalIconsVisible(boolean z) { | ||||
|         this.mOptionalIconsVisible = z; | ||||
|     } | ||||
|  | ||||
|     public void setOverrideVisibleItems(boolean z) { | ||||
|         this.mOverrideVisibleItems = z; | ||||
|     } | ||||
|  | ||||
|     public void stopDispatchingItemsChanged() { | ||||
|         if (this.mPreventDispatchingItemsChanged) { | ||||
|             return; | ||||
|         } | ||||
|         this.mPreventDispatchingItemsChanged = true; | ||||
|         this.mItemsChangedWhileDispatchPrevented = false; | ||||
|         this.mStructureChangedWhileDispatchPrevented = false; | ||||
|     } | ||||
|  | ||||
|     public MenuBuilder(Context context) { | ||||
|         this.mContext = context; | ||||
|         this.mResources = context.getResources(); | ||||
|         setShortcutsVisibleInner(true); | ||||
|     } | ||||
|  | ||||
|     public void addMenuPresenter(MenuPresenter menuPresenter) { | ||||
|         addMenuPresenter(menuPresenter, this.mContext); | ||||
|     } | ||||
|  | ||||
|     public void addMenuPresenter(MenuPresenter menuPresenter, Context context) { | ||||
|         this.mPresenters.add(new WeakReference<>(menuPresenter)); | ||||
|         menuPresenter.initForMenu(context, this); | ||||
|         this.mIsActionItemsStale = true; | ||||
|     } | ||||
|  | ||||
|     public void removeMenuPresenter(MenuPresenter menuPresenter) { | ||||
|         Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             WeakReference<MenuPresenter> next = it.next(); | ||||
|             MenuPresenter menuPresenter2 = next.get(); | ||||
|             if (menuPresenter2 == null || menuPresenter2 == menuPresenter) { | ||||
|                 this.mPresenters.remove(next); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void dispatchPresenterUpdate(boolean z) { | ||||
|         if (this.mPresenters.isEmpty()) { | ||||
|             return; | ||||
|         } | ||||
|         stopDispatchingItemsChanged(); | ||||
|         Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             WeakReference<MenuPresenter> next = it.next(); | ||||
|             MenuPresenter menuPresenter = next.get(); | ||||
|             if (menuPresenter == null) { | ||||
|                 this.mPresenters.remove(next); | ||||
|             } else { | ||||
|                 menuPresenter.updateMenuView(z); | ||||
|             } | ||||
|         } | ||||
|         startDispatchingItemsChanged(); | ||||
|     } | ||||
|  | ||||
|     private boolean dispatchSubMenuSelected(SubMenuBuilder subMenuBuilder, MenuPresenter menuPresenter) { | ||||
|         if (this.mPresenters.isEmpty()) { | ||||
|             return false; | ||||
|         } | ||||
|         boolean onSubMenuSelected = menuPresenter != null ? menuPresenter.onSubMenuSelected(subMenuBuilder) : false; | ||||
|         Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             WeakReference<MenuPresenter> next = it.next(); | ||||
|             MenuPresenter menuPresenter2 = next.get(); | ||||
|             if (menuPresenter2 == null) { | ||||
|                 this.mPresenters.remove(next); | ||||
|             } else if (!onSubMenuSelected) { | ||||
|                 onSubMenuSelected = menuPresenter2.onSubMenuSelected(subMenuBuilder); | ||||
|             } | ||||
|         } | ||||
|         return onSubMenuSelected; | ||||
|     } | ||||
|  | ||||
|     private void dispatchSaveInstanceState(Bundle bundle) { | ||||
|         Parcelable onSaveInstanceState; | ||||
|         if (this.mPresenters.isEmpty()) { | ||||
|             return; | ||||
|         } | ||||
|         SparseArray<? extends Parcelable> sparseArray = new SparseArray<>(); | ||||
|         Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             WeakReference<MenuPresenter> next = it.next(); | ||||
|             MenuPresenter menuPresenter = next.get(); | ||||
|             if (menuPresenter == null) { | ||||
|                 this.mPresenters.remove(next); | ||||
|             } else { | ||||
|                 int id = menuPresenter.getId(); | ||||
|                 if (id > 0 && (onSaveInstanceState = menuPresenter.onSaveInstanceState()) != null) { | ||||
|                     sparseArray.put(id, onSaveInstanceState); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         bundle.putSparseParcelableArray(PRESENTER_KEY, sparseArray); | ||||
|     } | ||||
|  | ||||
|     private void dispatchRestoreInstanceState(Bundle bundle) { | ||||
|         Parcelable parcelable; | ||||
|         SparseArray sparseParcelableArray = bundle.getSparseParcelableArray(PRESENTER_KEY); | ||||
|         if (sparseParcelableArray == null || this.mPresenters.isEmpty()) { | ||||
|             return; | ||||
|         } | ||||
|         Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             WeakReference<MenuPresenter> next = it.next(); | ||||
|             MenuPresenter menuPresenter = next.get(); | ||||
|             if (menuPresenter == null) { | ||||
|                 this.mPresenters.remove(next); | ||||
|             } else { | ||||
|                 int id = menuPresenter.getId(); | ||||
|                 if (id > 0 && (parcelable = (Parcelable) sparseParcelableArray.get(id)) != null) { | ||||
|                     menuPresenter.onRestoreInstanceState(parcelable); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void savePresenterStates(Bundle bundle) { | ||||
|         dispatchSaveInstanceState(bundle); | ||||
|     } | ||||
|  | ||||
|     public void restorePresenterStates(Bundle bundle) { | ||||
|         dispatchRestoreInstanceState(bundle); | ||||
|     } | ||||
|  | ||||
|     public void saveActionViewStates(Bundle bundle) { | ||||
|         int size = size(); | ||||
|         SparseArray<? extends Parcelable> sparseArray = null; | ||||
|         for (int i = 0; i < size; i++) { | ||||
|             MenuItem item = getItem(i); | ||||
|             View actionView = item.getActionView(); | ||||
|             if (actionView != null && actionView.getId() != -1) { | ||||
|                 if (sparseArray == null) { | ||||
|                     sparseArray = new SparseArray<>(); | ||||
|                 } | ||||
|                 actionView.saveHierarchyState(sparseArray); | ||||
|                 if (item.isActionViewExpanded()) { | ||||
|                     bundle.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId()); | ||||
|                 } | ||||
|             } | ||||
|             if (item.hasSubMenu()) { | ||||
|                 ((SubMenuBuilder) item.getSubMenu()).saveActionViewStates(bundle); | ||||
|             } | ||||
|         } | ||||
|         if (sparseArray != null) { | ||||
|             bundle.putSparseParcelableArray(getActionViewStatesKey(), sparseArray); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void restoreActionViewStates(Bundle bundle) { | ||||
|         MenuItem findItem; | ||||
|         if (bundle == null) { | ||||
|             return; | ||||
|         } | ||||
|         SparseArray<Parcelable> sparseParcelableArray = bundle.getSparseParcelableArray(getActionViewStatesKey()); | ||||
|         int size = size(); | ||||
|         for (int i = 0; i < size; i++) { | ||||
|             MenuItem item = getItem(i); | ||||
|             View actionView = item.getActionView(); | ||||
|             if (actionView != null && actionView.getId() != -1) { | ||||
|                 actionView.restoreHierarchyState(sparseParcelableArray); | ||||
|             } | ||||
|             if (item.hasSubMenu()) { | ||||
|                 ((SubMenuBuilder) item.getSubMenu()).restoreActionViewStates(bundle); | ||||
|             } | ||||
|         } | ||||
|         int i2 = bundle.getInt(EXPANDED_ACTION_VIEW_ID); | ||||
|         if (i2 <= 0 || (findItem = findItem(i2)) == null) { | ||||
|             return; | ||||
|         } | ||||
|         findItem.expandActionView(); | ||||
|     } | ||||
|  | ||||
|     protected MenuItem addInternal(int i, int i2, int i3, CharSequence charSequence) { | ||||
|         int ordering = getOrdering(i3); | ||||
|         MenuItemImpl createNewMenuItem = createNewMenuItem(i, i2, i3, ordering, charSequence, this.mDefaultShowAsAction); | ||||
|         ContextMenu.ContextMenuInfo contextMenuInfo = this.mCurrentMenuInfo; | ||||
|         if (contextMenuInfo != null) { | ||||
|             createNewMenuItem.setMenuInfo(contextMenuInfo); | ||||
|         } | ||||
|         ArrayList<MenuItemImpl> arrayList = this.mItems; | ||||
|         arrayList.add(findInsertIndex(arrayList, ordering), createNewMenuItem); | ||||
|         onItemsChanged(true); | ||||
|         return createNewMenuItem; | ||||
|     } | ||||
|  | ||||
|     private MenuItemImpl createNewMenuItem(int i, int i2, int i3, int i4, CharSequence charSequence, int i5) { | ||||
|         return new MenuItemImpl(this, i, i2, i3, i4, charSequence, i5); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem add(CharSequence charSequence) { | ||||
|         return addInternal(0, 0, 0, charSequence); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem add(int i) { | ||||
|         return addInternal(0, 0, 0, this.mResources.getString(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem add(int i, int i2, int i3, CharSequence charSequence) { | ||||
|         return addInternal(i, i2, i3, charSequence); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem add(int i, int i2, int i3, int i4) { | ||||
|         return addInternal(i, i2, i3, this.mResources.getString(i4)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public SubMenu addSubMenu(CharSequence charSequence) { | ||||
|         return addSubMenu(0, 0, 0, charSequence); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public SubMenu addSubMenu(int i) { | ||||
|         return addSubMenu(0, 0, 0, this.mResources.getString(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public SubMenu addSubMenu(int i, int i2, int i3, CharSequence charSequence) { | ||||
|         MenuItemImpl menuItemImpl = (MenuItemImpl) addInternal(i, i2, i3, charSequence); | ||||
|         SubMenuBuilder subMenuBuilder = new SubMenuBuilder(this.mContext, this, menuItemImpl); | ||||
|         menuItemImpl.setSubMenu(subMenuBuilder); | ||||
|         return subMenuBuilder; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public SubMenu addSubMenu(int i, int i2, int i3, int i4) { | ||||
|         return addSubMenu(i, i2, i3, this.mResources.getString(i4)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public int addIntentOptions(int i, int i2, int i3, ComponentName componentName, Intent[] intentArr, Intent intent, int i4, MenuItem[] menuItemArr) { | ||||
|         PackageManager packageManager = this.mContext.getPackageManager(); | ||||
|         List<ResolveInfo> queryIntentActivityOptions = packageManager.queryIntentActivityOptions(componentName, intentArr, intent, 0); | ||||
|         int size = queryIntentActivityOptions != null ? queryIntentActivityOptions.size() : 0; | ||||
|         if ((i4 & 1) == 0) { | ||||
|             removeGroup(i); | ||||
|         } | ||||
|         for (int i5 = 0; i5 < size; i5++) { | ||||
|             ResolveInfo resolveInfo = queryIntentActivityOptions.get(i5); | ||||
|             Intent intent2 = new Intent(resolveInfo.specificIndex < 0 ? intent : intentArr[resolveInfo.specificIndex]); | ||||
|             intent2.setComponent(new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName, resolveInfo.activityInfo.name)); | ||||
|             MenuItem intent3 = add(i, i2, i3, resolveInfo.loadLabel(packageManager)).setIcon(resolveInfo.loadIcon(packageManager)).setIntent(intent2); | ||||
|             if (menuItemArr != null && resolveInfo.specificIndex >= 0) { | ||||
|                 menuItemArr[resolveInfo.specificIndex] = intent3; | ||||
|             } | ||||
|         } | ||||
|         return size; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void removeItem(int i) { | ||||
|         removeItemAtInt(findItemIndex(i), true); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void removeGroup(int i) { | ||||
|         int findGroupIndex = findGroupIndex(i); | ||||
|         if (findGroupIndex >= 0) { | ||||
|             int size = this.mItems.size() - findGroupIndex; | ||||
|             int i2 = 0; | ||||
|             while (true) { | ||||
|                 int i3 = i2 + 1; | ||||
|                 if (i2 >= size || this.mItems.get(findGroupIndex).getGroupId() != i) { | ||||
|                     break; | ||||
|                 } | ||||
|                 removeItemAtInt(findGroupIndex, false); | ||||
|                 i2 = i3; | ||||
|             } | ||||
|             onItemsChanged(true); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void removeItemAtInt(int i, boolean z) { | ||||
|         if (i < 0 || i >= this.mItems.size()) { | ||||
|             return; | ||||
|         } | ||||
|         this.mItems.remove(i); | ||||
|         if (z) { | ||||
|             onItemsChanged(true); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void removeItemAt(int i) { | ||||
|         removeItemAtInt(i, true); | ||||
|     } | ||||
|  | ||||
|     public void clearAll() { | ||||
|         this.mPreventDispatchingItemsChanged = true; | ||||
|         clear(); | ||||
|         clearHeader(); | ||||
|         this.mPresenters.clear(); | ||||
|         this.mPreventDispatchingItemsChanged = false; | ||||
|         this.mItemsChangedWhileDispatchPrevented = false; | ||||
|         this.mStructureChangedWhileDispatchPrevented = false; | ||||
|         onItemsChanged(true); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void clear() { | ||||
|         MenuItemImpl menuItemImpl = this.mExpandedItem; | ||||
|         if (menuItemImpl != null) { | ||||
|             collapseItemActionView(menuItemImpl); | ||||
|         } | ||||
|         this.mItems.clear(); | ||||
|         onItemsChanged(true); | ||||
|     } | ||||
|  | ||||
|     void setExclusiveItemChecked(MenuItem menuItem) { | ||||
|         int groupId = menuItem.getGroupId(); | ||||
|         int size = this.mItems.size(); | ||||
|         stopDispatchingItemsChanged(); | ||||
|         for (int i = 0; i < size; i++) { | ||||
|             MenuItemImpl menuItemImpl = this.mItems.get(i); | ||||
|             if (menuItemImpl.getGroupId() == groupId && menuItemImpl.isExclusiveCheckable() && menuItemImpl.isCheckable()) { | ||||
|                 menuItemImpl.setCheckedInt(menuItemImpl == menuItem); | ||||
|             } | ||||
|         } | ||||
|         startDispatchingItemsChanged(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void setGroupCheckable(int i, boolean z, boolean z2) { | ||||
|         int size = this.mItems.size(); | ||||
|         for (int i2 = 0; i2 < size; i2++) { | ||||
|             MenuItemImpl menuItemImpl = this.mItems.get(i2); | ||||
|             if (menuItemImpl.getGroupId() == i) { | ||||
|                 menuItemImpl.setExclusiveCheckable(z2); | ||||
|                 menuItemImpl.setCheckable(z); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void setGroupVisible(int i, boolean z) { | ||||
|         int size = this.mItems.size(); | ||||
|         boolean z2 = false; | ||||
|         for (int i2 = 0; i2 < size; i2++) { | ||||
|             MenuItemImpl menuItemImpl = this.mItems.get(i2); | ||||
|             if (menuItemImpl.getGroupId() == i && menuItemImpl.setVisibleInt(z)) { | ||||
|                 z2 = true; | ||||
|             } | ||||
|         } | ||||
|         if (z2) { | ||||
|             onItemsChanged(true); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void setGroupEnabled(int i, boolean z) { | ||||
|         int size = this.mItems.size(); | ||||
|         for (int i2 = 0; i2 < size; i2++) { | ||||
|             MenuItemImpl menuItemImpl = this.mItems.get(i2); | ||||
|             if (menuItemImpl.getGroupId() == i) { | ||||
|                 menuItemImpl.setEnabled(z); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public boolean hasVisibleItems() { | ||||
|         if (this.mOverrideVisibleItems) { | ||||
|             return true; | ||||
|         } | ||||
|         int size = size(); | ||||
|         for (int i = 0; i < size; i++) { | ||||
|             if (this.mItems.get(i).isVisible()) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem findItem(int i) { | ||||
|         MenuItem findItem; | ||||
|         int size = size(); | ||||
|         for (int i2 = 0; i2 < size; i2++) { | ||||
|             MenuItemImpl menuItemImpl = this.mItems.get(i2); | ||||
|             if (menuItemImpl.getItemId() == i) { | ||||
|                 return menuItemImpl; | ||||
|             } | ||||
|             if (menuItemImpl.hasSubMenu() && (findItem = menuItemImpl.getSubMenu().findItem(i)) != null) { | ||||
|                 return findItem; | ||||
|             } | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     public int findItemIndex(int i) { | ||||
|         int size = size(); | ||||
|         for (int i2 = 0; i2 < size; i2++) { | ||||
|             if (this.mItems.get(i2).getItemId() == i) { | ||||
|                 return i2; | ||||
|             } | ||||
|         } | ||||
|         return -1; | ||||
|     } | ||||
|  | ||||
|     public int findGroupIndex(int i) { | ||||
|         return findGroupIndex(i, 0); | ||||
|     } | ||||
|  | ||||
|     public int findGroupIndex(int i, int i2) { | ||||
|         int size = size(); | ||||
|         if (i2 < 0) { | ||||
|             i2 = 0; | ||||
|         } | ||||
|         while (i2 < size) { | ||||
|             if (this.mItems.get(i2).getGroupId() == i) { | ||||
|                 return i2; | ||||
|             } | ||||
|             i2++; | ||||
|         } | ||||
|         return -1; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public int size() { | ||||
|         return this.mItems.size(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem getItem(int i) { | ||||
|         return this.mItems.get(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public boolean isShortcutKey(int i, KeyEvent keyEvent) { | ||||
|         return findItemWithShortcutForKey(i, keyEvent) != null; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void setQwertyMode(boolean z) { | ||||
|         this.mQwertyMode = z; | ||||
|         onItemsChanged(false); | ||||
|     } | ||||
|  | ||||
|     private static int getOrdering(int i) { | ||||
|         int i2 = ((-65536) & i) >> 16; | ||||
|         if (i2 >= 0) { | ||||
|             int[] iArr = sCategoryToOrder; | ||||
|             if (i2 < iArr.length) { | ||||
|                 return (i & SupportMenu.USER_MASK) | (iArr[i2] << 16); | ||||
|             } | ||||
|         } | ||||
|         throw new IllegalArgumentException("order does not contain a valid category."); | ||||
|     } | ||||
|  | ||||
|     public void setShortcutsVisible(boolean z) { | ||||
|         if (this.mShortcutsVisible == z) { | ||||
|             return; | ||||
|         } | ||||
|         setShortcutsVisibleInner(z); | ||||
|         onItemsChanged(false); | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:5:0x0019, code lost: | ||||
|      | ||||
|         if (androidx.core.view.ViewConfigurationCompat.shouldShowMenuShortcutsWhenKeyboardPresent(android.view.ViewConfiguration.get(r2.mContext), r2.mContext) != false) goto L9; | ||||
|      */ | ||||
|     /* | ||||
|         Code decompiled incorrectly, please refer to instructions dump. | ||||
|         To view partially-correct add '--show-bad-code' argument | ||||
|     */ | ||||
|     private void setShortcutsVisibleInner(boolean r3) { | ||||
|         /* | ||||
|             r2 = this; | ||||
|             if (r3 == 0) goto L1c | ||||
|             android.content.res.Resources r3 = r2.mResources | ||||
|             android.content.res.Configuration r3 = r3.getConfiguration() | ||||
|             int r3 = r3.keyboard | ||||
|             r0 = 1 | ||||
|             if (r3 == r0) goto L1c | ||||
|             android.content.Context r3 = r2.mContext | ||||
|             android.view.ViewConfiguration r3 = android.view.ViewConfiguration.get(r3) | ||||
|             android.content.Context r1 = r2.mContext | ||||
|             boolean r3 = androidx.core.view.ViewConfigurationCompat.shouldShowMenuShortcutsWhenKeyboardPresent(r3, r1) | ||||
|             if (r3 == 0) goto L1c | ||||
|             goto L1d | ||||
|         L1c: | ||||
|             r0 = 0 | ||||
|         L1d: | ||||
|             r2.mShortcutsVisible = r0 | ||||
|             return | ||||
|         */ | ||||
|         throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.view.menu.MenuBuilder.setShortcutsVisibleInner(boolean):void"); | ||||
|     } | ||||
|  | ||||
|     boolean dispatchMenuItemSelected(MenuBuilder menuBuilder, MenuItem menuItem) { | ||||
|         Callback callback = this.mCallback; | ||||
|         return callback != null && callback.onMenuItemSelected(menuBuilder, menuItem); | ||||
|     } | ||||
|  | ||||
|     public void changeMenuMode() { | ||||
|         Callback callback = this.mCallback; | ||||
|         if (callback != null) { | ||||
|             callback.onMenuModeChange(this); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private static int findInsertIndex(ArrayList<MenuItemImpl> arrayList, int i) { | ||||
|         for (int size = arrayList.size() - 1; size >= 0; size--) { | ||||
|             if (arrayList.get(size).getOrdering() <= i) { | ||||
|                 return size + 1; | ||||
|             } | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public boolean performShortcut(int i, KeyEvent keyEvent, int i2) { | ||||
|         MenuItemImpl findItemWithShortcutForKey = findItemWithShortcutForKey(i, keyEvent); | ||||
|         boolean performItemAction = findItemWithShortcutForKey != null ? performItemAction(findItemWithShortcutForKey, i2) : false; | ||||
|         if ((i2 & 2) != 0) { | ||||
|             close(true); | ||||
|         } | ||||
|         return performItemAction; | ||||
|     } | ||||
|  | ||||
|     void findItemsWithShortcutForKey(List<MenuItemImpl> list, int i, KeyEvent keyEvent) { | ||||
|         boolean isQwertyMode = isQwertyMode(); | ||||
|         int modifiers = keyEvent.getModifiers(); | ||||
|         KeyCharacterMap.KeyData keyData = new KeyCharacterMap.KeyData(); | ||||
|         if (keyEvent.getKeyData(keyData) || i == 67) { | ||||
|             int size = this.mItems.size(); | ||||
|             for (int i2 = 0; i2 < size; i2++) { | ||||
|                 MenuItemImpl menuItemImpl = this.mItems.get(i2); | ||||
|                 if (menuItemImpl.hasSubMenu()) { | ||||
|                     ((MenuBuilder) menuItemImpl.getSubMenu()).findItemsWithShortcutForKey(list, i, keyEvent); | ||||
|                 } | ||||
|                 char alphabeticShortcut = isQwertyMode ? menuItemImpl.getAlphabeticShortcut() : menuItemImpl.getNumericShortcut(); | ||||
|                 if ((modifiers & SupportMenu.SUPPORTED_MODIFIERS_MASK) == ((isQwertyMode ? menuItemImpl.getAlphabeticModifiers() : menuItemImpl.getNumericModifiers()) & SupportMenu.SUPPORTED_MODIFIERS_MASK) && alphabeticShortcut != 0 && ((alphabeticShortcut == keyData.meta[0] || alphabeticShortcut == keyData.meta[2] || (isQwertyMode && alphabeticShortcut == '\b' && i == 67)) && menuItemImpl.isEnabled())) { | ||||
|                     list.add(menuItemImpl); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     MenuItemImpl findItemWithShortcutForKey(int i, KeyEvent keyEvent) { | ||||
|         char numericShortcut; | ||||
|         ArrayList<MenuItemImpl> arrayList = this.mTempShortcutItemList; | ||||
|         arrayList.clear(); | ||||
|         findItemsWithShortcutForKey(arrayList, i, keyEvent); | ||||
|         if (arrayList.isEmpty()) { | ||||
|             return null; | ||||
|         } | ||||
|         int metaState = keyEvent.getMetaState(); | ||||
|         KeyCharacterMap.KeyData keyData = new KeyCharacterMap.KeyData(); | ||||
|         keyEvent.getKeyData(keyData); | ||||
|         int size = arrayList.size(); | ||||
|         if (size == 1) { | ||||
|             return arrayList.get(0); | ||||
|         } | ||||
|         boolean isQwertyMode = isQwertyMode(); | ||||
|         for (int i2 = 0; i2 < size; i2++) { | ||||
|             MenuItemImpl menuItemImpl = arrayList.get(i2); | ||||
|             if (isQwertyMode) { | ||||
|                 numericShortcut = menuItemImpl.getAlphabeticShortcut(); | ||||
|             } else { | ||||
|                 numericShortcut = menuItemImpl.getNumericShortcut(); | ||||
|             } | ||||
|             if ((numericShortcut == keyData.meta[0] && (metaState & 2) == 0) || ((numericShortcut == keyData.meta[2] && (metaState & 2) != 0) || (isQwertyMode && numericShortcut == '\b' && i == 67))) { | ||||
|                 return menuItemImpl; | ||||
|             } | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public boolean performIdentifierAction(int i, int i2) { | ||||
|         return performItemAction(findItem(i), i2); | ||||
|     } | ||||
|  | ||||
|     public boolean performItemAction(MenuItem menuItem, int i) { | ||||
|         return performItemAction(menuItem, null, i); | ||||
|     } | ||||
|  | ||||
|     public boolean performItemAction(MenuItem menuItem, MenuPresenter menuPresenter, int i) { | ||||
|         MenuItemImpl menuItemImpl = (MenuItemImpl) menuItem; | ||||
|         if (menuItemImpl == null || !menuItemImpl.isEnabled()) { | ||||
|             return false; | ||||
|         } | ||||
|         boolean invoke = menuItemImpl.invoke(); | ||||
|         ActionProvider supportActionProvider = menuItemImpl.getSupportActionProvider(); | ||||
|         boolean z = supportActionProvider != null && supportActionProvider.hasSubMenu(); | ||||
|         if (menuItemImpl.hasCollapsibleActionView()) { | ||||
|             invoke |= menuItemImpl.expandActionView(); | ||||
|             if (invoke) { | ||||
|                 close(true); | ||||
|             } | ||||
|         } else if (menuItemImpl.hasSubMenu() || z) { | ||||
|             if ((i & 4) == 0) { | ||||
|                 close(false); | ||||
|             } | ||||
|             if (!menuItemImpl.hasSubMenu()) { | ||||
|                 menuItemImpl.setSubMenu(new SubMenuBuilder(getContext(), this, menuItemImpl)); | ||||
|             } | ||||
|             SubMenuBuilder subMenuBuilder = (SubMenuBuilder) menuItemImpl.getSubMenu(); | ||||
|             if (z) { | ||||
|                 supportActionProvider.onPrepareSubMenu(subMenuBuilder); | ||||
|             } | ||||
|             invoke |= dispatchSubMenuSelected(subMenuBuilder, menuPresenter); | ||||
|             if (!invoke) { | ||||
|                 close(true); | ||||
|             } | ||||
|         } else if ((i & 1) == 0) { | ||||
|             close(true); | ||||
|         } | ||||
|         return invoke; | ||||
|     } | ||||
|  | ||||
|     public final void close(boolean z) { | ||||
|         if (this.mIsClosing) { | ||||
|             return; | ||||
|         } | ||||
|         this.mIsClosing = true; | ||||
|         Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             WeakReference<MenuPresenter> next = it.next(); | ||||
|             MenuPresenter menuPresenter = next.get(); | ||||
|             if (menuPresenter == null) { | ||||
|                 this.mPresenters.remove(next); | ||||
|             } else { | ||||
|                 menuPresenter.onCloseMenu(this, z); | ||||
|             } | ||||
|         } | ||||
|         this.mIsClosing = false; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void close() { | ||||
|         close(true); | ||||
|     } | ||||
|  | ||||
|     public void onItemsChanged(boolean z) { | ||||
|         if (this.mPreventDispatchingItemsChanged) { | ||||
|             this.mItemsChangedWhileDispatchPrevented = true; | ||||
|             if (z) { | ||||
|                 this.mStructureChangedWhileDispatchPrevented = true; | ||||
|                 return; | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         if (z) { | ||||
|             this.mIsVisibleItemsStale = true; | ||||
|             this.mIsActionItemsStale = true; | ||||
|         } | ||||
|         dispatchPresenterUpdate(z); | ||||
|     } | ||||
|  | ||||
|     public void startDispatchingItemsChanged() { | ||||
|         this.mPreventDispatchingItemsChanged = false; | ||||
|         if (this.mItemsChangedWhileDispatchPrevented) { | ||||
|             this.mItemsChangedWhileDispatchPrevented = false; | ||||
|             onItemsChanged(this.mStructureChangedWhileDispatchPrevented); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void onItemVisibleChanged(MenuItemImpl menuItemImpl) { | ||||
|         this.mIsVisibleItemsStale = true; | ||||
|         onItemsChanged(true); | ||||
|     } | ||||
|  | ||||
|     void onItemActionRequestChanged(MenuItemImpl menuItemImpl) { | ||||
|         this.mIsActionItemsStale = true; | ||||
|         onItemsChanged(true); | ||||
|     } | ||||
|  | ||||
|     public ArrayList<MenuItemImpl> getVisibleItems() { | ||||
|         if (!this.mIsVisibleItemsStale) { | ||||
|             return this.mVisibleItems; | ||||
|         } | ||||
|         this.mVisibleItems.clear(); | ||||
|         int size = this.mItems.size(); | ||||
|         for (int i = 0; i < size; i++) { | ||||
|             MenuItemImpl menuItemImpl = this.mItems.get(i); | ||||
|             if (menuItemImpl.isVisible()) { | ||||
|                 this.mVisibleItems.add(menuItemImpl); | ||||
|             } | ||||
|         } | ||||
|         this.mIsVisibleItemsStale = false; | ||||
|         this.mIsActionItemsStale = true; | ||||
|         return this.mVisibleItems; | ||||
|     } | ||||
|  | ||||
|     public void flagActionItems() { | ||||
|         ArrayList<MenuItemImpl> visibleItems = getVisibleItems(); | ||||
|         if (this.mIsActionItemsStale) { | ||||
|             Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|             boolean z = false; | ||||
|             while (it.hasNext()) { | ||||
|                 WeakReference<MenuPresenter> next = it.next(); | ||||
|                 MenuPresenter menuPresenter = next.get(); | ||||
|                 if (menuPresenter == null) { | ||||
|                     this.mPresenters.remove(next); | ||||
|                 } else { | ||||
|                     z |= menuPresenter.flagActionItems(); | ||||
|                 } | ||||
|             } | ||||
|             if (z) { | ||||
|                 this.mActionItems.clear(); | ||||
|                 this.mNonActionItems.clear(); | ||||
|                 int size = visibleItems.size(); | ||||
|                 for (int i = 0; i < size; i++) { | ||||
|                     MenuItemImpl menuItemImpl = visibleItems.get(i); | ||||
|                     if (menuItemImpl.isActionButton()) { | ||||
|                         this.mActionItems.add(menuItemImpl); | ||||
|                     } else { | ||||
|                         this.mNonActionItems.add(menuItemImpl); | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|                 this.mActionItems.clear(); | ||||
|                 this.mNonActionItems.clear(); | ||||
|                 this.mNonActionItems.addAll(getVisibleItems()); | ||||
|             } | ||||
|             this.mIsActionItemsStale = false; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public ArrayList<MenuItemImpl> getActionItems() { | ||||
|         flagActionItems(); | ||||
|         return this.mActionItems; | ||||
|     } | ||||
|  | ||||
|     public ArrayList<MenuItemImpl> getNonActionItems() { | ||||
|         flagActionItems(); | ||||
|         return this.mNonActionItems; | ||||
|     } | ||||
|  | ||||
|     public void clearHeader() { | ||||
|         this.mHeaderIcon = null; | ||||
|         this.mHeaderTitle = null; | ||||
|         this.mHeaderView = null; | ||||
|         onItemsChanged(false); | ||||
|     } | ||||
|  | ||||
|     private void setHeaderInternal(int i, CharSequence charSequence, int i2, Drawable drawable, View view) { | ||||
|         Resources resources = getResources(); | ||||
|         if (view != null) { | ||||
|             this.mHeaderView = view; | ||||
|             this.mHeaderTitle = null; | ||||
|             this.mHeaderIcon = null; | ||||
|         } else { | ||||
|             if (i > 0) { | ||||
|                 this.mHeaderTitle = resources.getText(i); | ||||
|             } else if (charSequence != null) { | ||||
|                 this.mHeaderTitle = charSequence; | ||||
|             } | ||||
|             if (i2 > 0) { | ||||
|                 this.mHeaderIcon = ContextCompat.getDrawable(getContext(), i2); | ||||
|             } else if (drawable != null) { | ||||
|                 this.mHeaderIcon = drawable; | ||||
|             } | ||||
|             this.mHeaderView = null; | ||||
|         } | ||||
|         onItemsChanged(false); | ||||
|     } | ||||
|  | ||||
|     protected MenuBuilder setHeaderTitleInt(CharSequence charSequence) { | ||||
|         setHeaderInternal(0, charSequence, 0, null, null); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     protected MenuBuilder setHeaderTitleInt(int i) { | ||||
|         setHeaderInternal(i, null, 0, null, null); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     protected MenuBuilder setHeaderIconInt(Drawable drawable) { | ||||
|         setHeaderInternal(0, null, 0, drawable, null); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     protected MenuBuilder setHeaderIconInt(int i) { | ||||
|         setHeaderInternal(0, null, i, null, null); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     protected MenuBuilder setHeaderViewInt(View view) { | ||||
|         setHeaderInternal(0, null, 0, null, view); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public boolean expandItemActionView(MenuItemImpl menuItemImpl) { | ||||
|         boolean z = false; | ||||
|         if (this.mPresenters.isEmpty()) { | ||||
|             return false; | ||||
|         } | ||||
|         stopDispatchingItemsChanged(); | ||||
|         Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             WeakReference<MenuPresenter> next = it.next(); | ||||
|             MenuPresenter menuPresenter = next.get(); | ||||
|             if (menuPresenter == null) { | ||||
|                 this.mPresenters.remove(next); | ||||
|             } else { | ||||
|                 z = menuPresenter.expandItemActionView(this, menuItemImpl); | ||||
|                 if (z) { | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         startDispatchingItemsChanged(); | ||||
|         if (z) { | ||||
|             this.mExpandedItem = menuItemImpl; | ||||
|         } | ||||
|         return z; | ||||
|     } | ||||
|  | ||||
|     public boolean collapseItemActionView(MenuItemImpl menuItemImpl) { | ||||
|         boolean z = false; | ||||
|         if (!this.mPresenters.isEmpty() && this.mExpandedItem == menuItemImpl) { | ||||
|             stopDispatchingItemsChanged(); | ||||
|             Iterator<WeakReference<MenuPresenter>> it = this.mPresenters.iterator(); | ||||
|             while (it.hasNext()) { | ||||
|                 WeakReference<MenuPresenter> next = it.next(); | ||||
|                 MenuPresenter menuPresenter = next.get(); | ||||
|                 if (menuPresenter == null) { | ||||
|                     this.mPresenters.remove(next); | ||||
|                 } else { | ||||
|                     z = menuPresenter.collapseItemActionView(this, menuItemImpl); | ||||
|                     if (z) { | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             startDispatchingItemsChanged(); | ||||
|             if (z) { | ||||
|                 this.mExpandedItem = null; | ||||
|             } | ||||
|         } | ||||
|         return z; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,115 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.DialogInterface; | ||||
| import android.os.IBinder; | ||||
| import android.view.KeyEvent; | ||||
| import android.view.View; | ||||
| import android.view.Window; | ||||
| import android.view.WindowManager; | ||||
| import androidx.appcompat.R; | ||||
| import androidx.appcompat.app.AlertDialog; | ||||
| import androidx.appcompat.view.menu.MenuPresenter; | ||||
| import androidx.core.view.PointerIconCompat; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class MenuDialogHelper implements DialogInterface.OnKeyListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, MenuPresenter.Callback { | ||||
|     private AlertDialog mDialog; | ||||
|     private MenuBuilder mMenu; | ||||
|     ListMenuPresenter mPresenter; | ||||
|     private MenuPresenter.Callback mPresenterCallback; | ||||
|  | ||||
|     public void setPresenterCallback(MenuPresenter.Callback callback) { | ||||
|         this.mPresenterCallback = callback; | ||||
|     } | ||||
|  | ||||
|     public MenuDialogHelper(MenuBuilder menuBuilder) { | ||||
|         this.mMenu = menuBuilder; | ||||
|     } | ||||
|  | ||||
|     public void show(IBinder iBinder) { | ||||
|         MenuBuilder menuBuilder = this.mMenu; | ||||
|         AlertDialog.Builder builder = new AlertDialog.Builder(menuBuilder.getContext()); | ||||
|         ListMenuPresenter listMenuPresenter = new ListMenuPresenter(builder.getContext(), R.layout.abc_list_menu_item_layout); | ||||
|         this.mPresenter = listMenuPresenter; | ||||
|         listMenuPresenter.setCallback(this); | ||||
|         this.mMenu.addMenuPresenter(this.mPresenter); | ||||
|         builder.setAdapter(this.mPresenter.getAdapter(), this); | ||||
|         View headerView = menuBuilder.getHeaderView(); | ||||
|         if (headerView != null) { | ||||
|             builder.setCustomTitle(headerView); | ||||
|         } else { | ||||
|             builder.setIcon(menuBuilder.getHeaderIcon()).setTitle(menuBuilder.getHeaderTitle()); | ||||
|         } | ||||
|         builder.setOnKeyListener(this); | ||||
|         AlertDialog create = builder.create(); | ||||
|         this.mDialog = create; | ||||
|         create.setOnDismissListener(this); | ||||
|         WindowManager.LayoutParams attributes = this.mDialog.getWindow().getAttributes(); | ||||
|         attributes.type = PointerIconCompat.TYPE_HELP; | ||||
|         if (iBinder != null) { | ||||
|             attributes.token = iBinder; | ||||
|         } | ||||
|         attributes.flags |= 131072; | ||||
|         this.mDialog.show(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.content.DialogInterface.OnKeyListener | ||||
|     public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) { | ||||
|         Window window; | ||||
|         View decorView; | ||||
|         KeyEvent.DispatcherState keyDispatcherState; | ||||
|         View decorView2; | ||||
|         KeyEvent.DispatcherState keyDispatcherState2; | ||||
|         if (i == 82 || i == 4) { | ||||
|             if (keyEvent.getAction() == 0 && keyEvent.getRepeatCount() == 0) { | ||||
|                 Window window2 = this.mDialog.getWindow(); | ||||
|                 if (window2 != null && (decorView2 = window2.getDecorView()) != null && (keyDispatcherState2 = decorView2.getKeyDispatcherState()) != null) { | ||||
|                     keyDispatcherState2.startTracking(keyEvent, this); | ||||
|                     return true; | ||||
|                 } | ||||
|             } else if (keyEvent.getAction() == 1 && !keyEvent.isCanceled() && (window = this.mDialog.getWindow()) != null && (decorView = window.getDecorView()) != null && (keyDispatcherState = decorView.getKeyDispatcherState()) != null && keyDispatcherState.isTracking(keyEvent)) { | ||||
|                 this.mMenu.close(true); | ||||
|                 dialogInterface.dismiss(); | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return this.mMenu.performShortcut(i, keyEvent, 0); | ||||
|     } | ||||
|  | ||||
|     public void dismiss() { | ||||
|         AlertDialog alertDialog = this.mDialog; | ||||
|         if (alertDialog != null) { | ||||
|             alertDialog.dismiss(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.content.DialogInterface.OnDismissListener | ||||
|     public void onDismiss(DialogInterface dialogInterface) { | ||||
|         this.mPresenter.onCloseMenu(this.mMenu, true); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter.Callback | ||||
|     public void onCloseMenu(MenuBuilder menuBuilder, boolean z) { | ||||
|         if (z || menuBuilder == this.mMenu) { | ||||
|             dismiss(); | ||||
|         } | ||||
|         MenuPresenter.Callback callback = this.mPresenterCallback; | ||||
|         if (callback != null) { | ||||
|             callback.onCloseMenu(menuBuilder, z); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter.Callback | ||||
|     public boolean onOpenSubMenu(MenuBuilder menuBuilder) { | ||||
|         MenuPresenter.Callback callback = this.mPresenterCallback; | ||||
|         if (callback != null) { | ||||
|             return callback.onOpenSubMenu(menuBuilder); | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // android.content.DialogInterface.OnClickListener | ||||
|     public void onClick(DialogInterface dialogInterface, int i) { | ||||
|         this.mMenu.performItemAction((MenuItemImpl) this.mPresenter.getAdapter().getItem(i), 0); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,10 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import androidx.appcompat.view.menu.MenuPresenter; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| interface MenuHelper { | ||||
|     void dismiss(); | ||||
|  | ||||
|     void setPresenterCallback(MenuPresenter.Callback callback); | ||||
| } | ||||
| @@ -0,0 +1,711 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.ActivityNotFoundException; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.content.res.Resources; | ||||
| import android.graphics.PorterDuff; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.util.Log; | ||||
| import android.view.ContextMenu; | ||||
| import android.view.KeyEvent; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.MenuItem; | ||||
| import android.view.SubMenu; | ||||
| import android.view.View; | ||||
| import android.view.ViewConfiguration; | ||||
| import android.view.ViewDebug; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.LinearLayout; | ||||
| import androidx.appcompat.R; | ||||
| import androidx.appcompat.content.res.AppCompatResources; | ||||
| import androidx.appcompat.view.menu.MenuView; | ||||
| import androidx.core.graphics.drawable.DrawableCompat; | ||||
| import androidx.core.internal.view.SupportMenuItem; | ||||
| import androidx.core.view.ActionProvider; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public final class MenuItemImpl implements SupportMenuItem { | ||||
|     private static final int CHECKABLE = 1; | ||||
|     private static final int CHECKED = 2; | ||||
|     private static final int ENABLED = 16; | ||||
|     private static final int EXCLUSIVE = 4; | ||||
|     private static final int HIDDEN = 8; | ||||
|     private static final int IS_ACTION = 32; | ||||
|     static final int NO_ICON = 0; | ||||
|     private static final int SHOW_AS_ACTION_MASK = 3; | ||||
|     private static final String TAG = "MenuItemImpl"; | ||||
|     private ActionProvider mActionProvider; | ||||
|     private View mActionView; | ||||
|     private final int mCategoryOrder; | ||||
|     private MenuItem.OnMenuItemClickListener mClickListener; | ||||
|     private CharSequence mContentDescription; | ||||
|     private final int mGroup; | ||||
|     private Drawable mIconDrawable; | ||||
|     private final int mId; | ||||
|     private Intent mIntent; | ||||
|     private Runnable mItemCallback; | ||||
|     MenuBuilder mMenu; | ||||
|     private ContextMenu.ContextMenuInfo mMenuInfo; | ||||
|     private MenuItem.OnActionExpandListener mOnActionExpandListener; | ||||
|     private final int mOrdering; | ||||
|     private char mShortcutAlphabeticChar; | ||||
|     private char mShortcutNumericChar; | ||||
|     private int mShowAsAction; | ||||
|     private SubMenuBuilder mSubMenu; | ||||
|     private CharSequence mTitle; | ||||
|     private CharSequence mTitleCondensed; | ||||
|     private CharSequence mTooltipText; | ||||
|     private int mShortcutNumericModifiers = 4096; | ||||
|     private int mShortcutAlphabeticModifiers = 4096; | ||||
|     private int mIconResId = 0; | ||||
|     private ColorStateList mIconTintList = null; | ||||
|     private PorterDuff.Mode mIconTintMode = null; | ||||
|     private boolean mHasIconTint = false; | ||||
|     private boolean mHasIconTintMode = false; | ||||
|     private boolean mNeedToApplyIconTint = false; | ||||
|     private int mFlags = 16; | ||||
|     private boolean mIsActionViewExpanded = false; | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public int getAlphabeticModifiers() { | ||||
|         return this.mShortcutAlphabeticModifiers; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public char getAlphabeticShortcut() { | ||||
|         return this.mShortcutAlphabeticChar; | ||||
|     } | ||||
|  | ||||
|     Runnable getCallback() { | ||||
|         return this.mItemCallback; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public CharSequence getContentDescription() { | ||||
|         return this.mContentDescription; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getGroupId() { | ||||
|         return this.mGroup; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public ColorStateList getIconTintList() { | ||||
|         return this.mIconTintList; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public PorterDuff.Mode getIconTintMode() { | ||||
|         return this.mIconTintMode; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public Intent getIntent() { | ||||
|         return this.mIntent; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     @ViewDebug.CapturedViewProperty | ||||
|     public int getItemId() { | ||||
|         return this.mId; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public ContextMenu.ContextMenuInfo getMenuInfo() { | ||||
|         return this.mMenuInfo; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public int getNumericModifiers() { | ||||
|         return this.mShortcutNumericModifiers; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public char getNumericShortcut() { | ||||
|         return this.mShortcutNumericChar; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getOrder() { | ||||
|         return this.mCategoryOrder; | ||||
|     } | ||||
|  | ||||
|     public int getOrdering() { | ||||
|         return this.mOrdering; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public SubMenu getSubMenu() { | ||||
|         return this.mSubMenu; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem | ||||
|     public ActionProvider getSupportActionProvider() { | ||||
|         return this.mActionProvider; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     @ViewDebug.CapturedViewProperty | ||||
|     public CharSequence getTitle() { | ||||
|         return this.mTitle; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public CharSequence getTitleCondensed() { | ||||
|         CharSequence charSequence = this.mTitleCondensed; | ||||
|         return charSequence != null ? charSequence : this.mTitle; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public CharSequence getTooltipText() { | ||||
|         return this.mTooltipText; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean hasSubMenu() { | ||||
|         return this.mSubMenu != null; | ||||
|     } | ||||
|  | ||||
|     public boolean isActionButton() { | ||||
|         return (this.mFlags & 32) == 32; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public boolean isActionViewExpanded() { | ||||
|         return this.mIsActionViewExpanded; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isCheckable() { | ||||
|         return (this.mFlags & 1) == 1; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isChecked() { | ||||
|         return (this.mFlags & 2) == 2; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isEnabled() { | ||||
|         return (this.mFlags & 16) != 0; | ||||
|     } | ||||
|  | ||||
|     public boolean isExclusiveCheckable() { | ||||
|         return (this.mFlags & 4) != 0; | ||||
|     } | ||||
|  | ||||
|     public boolean requestsActionButton() { | ||||
|         return (this.mShowAsAction & 1) == 1; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem | ||||
|     public boolean requiresActionButton() { | ||||
|         return (this.mShowAsAction & 2) == 2; | ||||
|     } | ||||
|  | ||||
|     public MenuItem setCallback(Runnable runnable) { | ||||
|         this.mItemCallback = runnable; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public void setExclusiveCheckable(boolean z) { | ||||
|         this.mFlags = (z ? 4 : 0) | (this.mFlags & (-5)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIntent(Intent intent) { | ||||
|         this.mIntent = intent; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public void setIsActionButton(boolean z) { | ||||
|         if (z) { | ||||
|             this.mFlags |= 32; | ||||
|         } else { | ||||
|             this.mFlags &= -33; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void setMenuInfo(ContextMenu.ContextMenuInfo contextMenuInfo) { | ||||
|         this.mMenuInfo = contextMenuInfo; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) { | ||||
|         this.mOnActionExpandListener = onActionExpandListener; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) { | ||||
|         this.mClickListener = onMenuItemClickListener; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     boolean setVisibleInt(boolean z) { | ||||
|         int i = this.mFlags; | ||||
|         int i2 = (z ? 0 : 8) | (i & (-9)); | ||||
|         this.mFlags = i2; | ||||
|         return i != i2; | ||||
|     } | ||||
|  | ||||
|     public boolean showsTextAsAction() { | ||||
|         return (this.mShowAsAction & 4) == 4; | ||||
|     } | ||||
|  | ||||
|     MenuItemImpl(MenuBuilder menuBuilder, int i, int i2, int i3, int i4, CharSequence charSequence, int i5) { | ||||
|         this.mMenu = menuBuilder; | ||||
|         this.mId = i2; | ||||
|         this.mGroup = i; | ||||
|         this.mCategoryOrder = i3; | ||||
|         this.mOrdering = i4; | ||||
|         this.mTitle = charSequence; | ||||
|         this.mShowAsAction = i5; | ||||
|     } | ||||
|  | ||||
|     public boolean invoke() { | ||||
|         MenuItem.OnMenuItemClickListener onMenuItemClickListener = this.mClickListener; | ||||
|         if (onMenuItemClickListener != null && onMenuItemClickListener.onMenuItemClick(this)) { | ||||
|             return true; | ||||
|         } | ||||
|         MenuBuilder menuBuilder = this.mMenu; | ||||
|         if (menuBuilder.dispatchMenuItemSelected(menuBuilder, this)) { | ||||
|             return true; | ||||
|         } | ||||
|         Runnable runnable = this.mItemCallback; | ||||
|         if (runnable != null) { | ||||
|             runnable.run(); | ||||
|             return true; | ||||
|         } | ||||
|         if (this.mIntent != null) { | ||||
|             try { | ||||
|                 this.mMenu.getContext().startActivity(this.mIntent); | ||||
|                 return true; | ||||
|             } catch (ActivityNotFoundException e) { | ||||
|                 Log.e(TAG, "Can't find activity to handle intent; ignoring", e); | ||||
|             } | ||||
|         } | ||||
|         ActionProvider actionProvider = this.mActionProvider; | ||||
|         return actionProvider != null && actionProvider.onPerformDefaultAction(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setEnabled(boolean z) { | ||||
|         if (z) { | ||||
|             this.mFlags |= 16; | ||||
|         } else { | ||||
|             this.mFlags &= -17; | ||||
|         } | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setAlphabeticShortcut(char c) { | ||||
|         if (this.mShortcutAlphabeticChar == c) { | ||||
|             return this; | ||||
|         } | ||||
|         this.mShortcutAlphabeticChar = Character.toLowerCase(c); | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setAlphabeticShortcut(char c, int i) { | ||||
|         if (this.mShortcutAlphabeticChar == c && this.mShortcutAlphabeticModifiers == i) { | ||||
|             return this; | ||||
|         } | ||||
|         this.mShortcutAlphabeticChar = Character.toLowerCase(c); | ||||
|         this.mShortcutAlphabeticModifiers = KeyEvent.normalizeMetaState(i); | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setNumericShortcut(char c) { | ||||
|         if (this.mShortcutNumericChar == c) { | ||||
|             return this; | ||||
|         } | ||||
|         this.mShortcutNumericChar = c; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setNumericShortcut(char c, int i) { | ||||
|         if (this.mShortcutNumericChar == c && this.mShortcutNumericModifiers == i) { | ||||
|             return this; | ||||
|         } | ||||
|         this.mShortcutNumericChar = c; | ||||
|         this.mShortcutNumericModifiers = KeyEvent.normalizeMetaState(i); | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setShortcut(char c, char c2) { | ||||
|         this.mShortcutNumericChar = c; | ||||
|         this.mShortcutAlphabeticChar = Character.toLowerCase(c2); | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setShortcut(char c, char c2, int i, int i2) { | ||||
|         this.mShortcutNumericChar = c; | ||||
|         this.mShortcutNumericModifiers = KeyEvent.normalizeMetaState(i); | ||||
|         this.mShortcutAlphabeticChar = Character.toLowerCase(c2); | ||||
|         this.mShortcutAlphabeticModifiers = KeyEvent.normalizeMetaState(i2); | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     char getShortcut() { | ||||
|         return this.mMenu.isQwertyMode() ? this.mShortcutAlphabeticChar : this.mShortcutNumericChar; | ||||
|     } | ||||
|  | ||||
|     String getShortcutLabel() { | ||||
|         char shortcut = getShortcut(); | ||||
|         if (shortcut == 0) { | ||||
|             return ""; | ||||
|         } | ||||
|         Resources resources = this.mMenu.getContext().getResources(); | ||||
|         StringBuilder sb = new StringBuilder(); | ||||
|         if (ViewConfiguration.get(this.mMenu.getContext()).hasPermanentMenuKey()) { | ||||
|             sb.append(resources.getString(R.string.abc_prepend_shortcut_label)); | ||||
|         } | ||||
|         int i = this.mMenu.isQwertyMode() ? this.mShortcutAlphabeticModifiers : this.mShortcutNumericModifiers; | ||||
|         appendModifier(sb, i, 65536, resources.getString(R.string.abc_menu_meta_shortcut_label)); | ||||
|         appendModifier(sb, i, 4096, resources.getString(R.string.abc_menu_ctrl_shortcut_label)); | ||||
|         appendModifier(sb, i, 2, resources.getString(R.string.abc_menu_alt_shortcut_label)); | ||||
|         appendModifier(sb, i, 1, resources.getString(R.string.abc_menu_shift_shortcut_label)); | ||||
|         appendModifier(sb, i, 4, resources.getString(R.string.abc_menu_sym_shortcut_label)); | ||||
|         appendModifier(sb, i, 8, resources.getString(R.string.abc_menu_function_shortcut_label)); | ||||
|         if (shortcut == '\b') { | ||||
|             sb.append(resources.getString(R.string.abc_menu_delete_shortcut_label)); | ||||
|         } else if (shortcut == '\n') { | ||||
|             sb.append(resources.getString(R.string.abc_menu_enter_shortcut_label)); | ||||
|         } else if (shortcut == ' ') { | ||||
|             sb.append(resources.getString(R.string.abc_menu_space_shortcut_label)); | ||||
|         } else { | ||||
|             sb.append(shortcut); | ||||
|         } | ||||
|         return sb.toString(); | ||||
|     } | ||||
|  | ||||
|     private static void appendModifier(StringBuilder sb, int i, int i2, String str) { | ||||
|         if ((i & i2) == i2) { | ||||
|             sb.append(str); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     boolean shouldShowShortcut() { | ||||
|         return this.mMenu.isShortcutsVisible() && getShortcut() != 0; | ||||
|     } | ||||
|  | ||||
|     public void setSubMenu(SubMenuBuilder subMenuBuilder) { | ||||
|         this.mSubMenu = subMenuBuilder; | ||||
|         subMenuBuilder.setHeaderTitle(getTitle()); | ||||
|     } | ||||
|  | ||||
|     CharSequence getTitleForItemView(MenuView.ItemView itemView) { | ||||
|         if (itemView != null && itemView.prefersCondensedTitle()) { | ||||
|             return getTitleCondensed(); | ||||
|         } | ||||
|         return getTitle(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitle(CharSequence charSequence) { | ||||
|         this.mTitle = charSequence; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         SubMenuBuilder subMenuBuilder = this.mSubMenu; | ||||
|         if (subMenuBuilder != null) { | ||||
|             subMenuBuilder.setHeaderTitle(charSequence); | ||||
|         } | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitle(int i) { | ||||
|         return setTitle(this.mMenu.getContext().getString(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitleCondensed(CharSequence charSequence) { | ||||
|         this.mTitleCondensed = charSequence; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public Drawable getIcon() { | ||||
|         Drawable drawable = this.mIconDrawable; | ||||
|         if (drawable != null) { | ||||
|             return applyIconTintIfNecessary(drawable); | ||||
|         } | ||||
|         if (this.mIconResId == 0) { | ||||
|             return null; | ||||
|         } | ||||
|         Drawable drawable2 = AppCompatResources.getDrawable(this.mMenu.getContext(), this.mIconResId); | ||||
|         this.mIconResId = 0; | ||||
|         this.mIconDrawable = drawable2; | ||||
|         return applyIconTintIfNecessary(drawable2); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIcon(Drawable drawable) { | ||||
|         this.mIconResId = 0; | ||||
|         this.mIconDrawable = drawable; | ||||
|         this.mNeedToApplyIconTint = true; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIcon(int i) { | ||||
|         this.mIconDrawable = null; | ||||
|         this.mIconResId = i; | ||||
|         this.mNeedToApplyIconTint = true; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setIconTintList(ColorStateList colorStateList) { | ||||
|         this.mIconTintList = colorStateList; | ||||
|         this.mHasIconTint = true; | ||||
|         this.mNeedToApplyIconTint = true; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public MenuItem setIconTintMode(PorterDuff.Mode mode) { | ||||
|         this.mIconTintMode = mode; | ||||
|         this.mHasIconTintMode = true; | ||||
|         this.mNeedToApplyIconTint = true; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     private Drawable applyIconTintIfNecessary(Drawable drawable) { | ||||
|         if (drawable != null && this.mNeedToApplyIconTint && (this.mHasIconTint || this.mHasIconTintMode)) { | ||||
|             drawable = DrawableCompat.wrap(drawable).mutate(); | ||||
|             if (this.mHasIconTint) { | ||||
|                 DrawableCompat.setTintList(drawable, this.mIconTintList); | ||||
|             } | ||||
|             if (this.mHasIconTintMode) { | ||||
|                 DrawableCompat.setTintMode(drawable, this.mIconTintMode); | ||||
|             } | ||||
|             this.mNeedToApplyIconTint = false; | ||||
|         } | ||||
|         return drawable; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setCheckable(boolean z) { | ||||
|         int i = this.mFlags; | ||||
|         int i2 = (z ? 1 : 0) | (i & (-2)); | ||||
|         this.mFlags = i2; | ||||
|         if (i != i2) { | ||||
|             this.mMenu.onItemsChanged(false); | ||||
|         } | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setChecked(boolean z) { | ||||
|         if ((this.mFlags & 4) != 0) { | ||||
|             this.mMenu.setExclusiveItemChecked(this); | ||||
|         } else { | ||||
|             setCheckedInt(z); | ||||
|         } | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     void setCheckedInt(boolean z) { | ||||
|         int i = this.mFlags; | ||||
|         int i2 = (z ? 2 : 0) | (i & (-3)); | ||||
|         this.mFlags = i2; | ||||
|         if (i != i2) { | ||||
|             this.mMenu.onItemsChanged(false); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isVisible() { | ||||
|         ActionProvider actionProvider = this.mActionProvider; | ||||
|         return (actionProvider == null || !actionProvider.overridesItemVisibility()) ? (this.mFlags & 8) == 0 : (this.mFlags & 8) == 0 && this.mActionProvider.isVisible(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setVisible(boolean z) { | ||||
|         if (setVisibleInt(z)) { | ||||
|             this.mMenu.onItemVisibleChanged(this); | ||||
|         } | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public String toString() { | ||||
|         CharSequence charSequence = this.mTitle; | ||||
|         if (charSequence != null) { | ||||
|             return charSequence.toString(); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     public void actionFormatChanged() { | ||||
|         this.mMenu.onItemActionRequestChanged(this); | ||||
|     } | ||||
|  | ||||
|     public boolean shouldShowIcon() { | ||||
|         return this.mMenu.getOptionalIconsVisible(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem | ||||
|     public boolean requiresOverflow() { | ||||
|         return (requiresActionButton() || requestsActionButton()) ? false : true; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public void setShowAsAction(int i) { | ||||
|         int i2 = i & 3; | ||||
|         if (i2 != 0 && i2 != 1 && i2 != 2) { | ||||
|             throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM, and SHOW_AS_ACTION_NEVER are mutually exclusive."); | ||||
|         } | ||||
|         this.mShowAsAction = i; | ||||
|         this.mMenu.onItemActionRequestChanged(this); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public SupportMenuItem setActionView(View view) { | ||||
|         int i; | ||||
|         this.mActionView = view; | ||||
|         this.mActionProvider = null; | ||||
|         if (view != null && view.getId() == -1 && (i = this.mId) > 0) { | ||||
|             view.setId(i); | ||||
|         } | ||||
|         this.mMenu.onItemActionRequestChanged(this); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public SupportMenuItem setActionView(int i) { | ||||
|         Context context = this.mMenu.getContext(); | ||||
|         setActionView(LayoutInflater.from(context).inflate(i, (ViewGroup) new LinearLayout(context), false)); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public View getActionView() { | ||||
|         View view = this.mActionView; | ||||
|         if (view != null) { | ||||
|             return view; | ||||
|         } | ||||
|         ActionProvider actionProvider = this.mActionProvider; | ||||
|         if (actionProvider == null) { | ||||
|             return null; | ||||
|         } | ||||
|         View onCreateActionView = actionProvider.onCreateActionView(this); | ||||
|         this.mActionView = onCreateActionView; | ||||
|         return onCreateActionView; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setActionProvider(android.view.ActionProvider actionProvider) { | ||||
|         throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.setActionProvider()"); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public android.view.ActionProvider getActionProvider() { | ||||
|         throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.getActionProvider()"); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem | ||||
|     public SupportMenuItem setSupportActionProvider(ActionProvider actionProvider) { | ||||
|         ActionProvider actionProvider2 = this.mActionProvider; | ||||
|         if (actionProvider2 != null) { | ||||
|             actionProvider2.reset(); | ||||
|         } | ||||
|         this.mActionView = null; | ||||
|         this.mActionProvider = actionProvider; | ||||
|         this.mMenu.onItemsChanged(true); | ||||
|         ActionProvider actionProvider3 = this.mActionProvider; | ||||
|         if (actionProvider3 != null) { | ||||
|             actionProvider3.setVisibilityListener(new ActionProvider.VisibilityListener() { // from class: androidx.appcompat.view.menu.MenuItemImpl.1 | ||||
|                 @Override // androidx.core.view.ActionProvider.VisibilityListener | ||||
|                 public void onActionProviderVisibilityChanged(boolean z) { | ||||
|                     MenuItemImpl.this.mMenu.onItemVisibleChanged(MenuItemImpl.this); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public SupportMenuItem setShowAsActionFlags(int i) { | ||||
|         setShowAsAction(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public boolean expandActionView() { | ||||
|         if (!hasCollapsibleActionView()) { | ||||
|             return false; | ||||
|         } | ||||
|         MenuItem.OnActionExpandListener onActionExpandListener = this.mOnActionExpandListener; | ||||
|         if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionExpand(this)) { | ||||
|             return this.mMenu.expandItemActionView(this); | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem | ||||
|     public boolean collapseActionView() { | ||||
|         if ((this.mShowAsAction & 8) == 0) { | ||||
|             return false; | ||||
|         } | ||||
|         if (this.mActionView == null) { | ||||
|             return true; | ||||
|         } | ||||
|         MenuItem.OnActionExpandListener onActionExpandListener = this.mOnActionExpandListener; | ||||
|         if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionCollapse(this)) { | ||||
|             return this.mMenu.collapseItemActionView(this); | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public boolean hasCollapsibleActionView() { | ||||
|         ActionProvider actionProvider; | ||||
|         if ((this.mShowAsAction & 8) == 0) { | ||||
|             return false; | ||||
|         } | ||||
|         if (this.mActionView == null && (actionProvider = this.mActionProvider) != null) { | ||||
|             this.mActionView = actionProvider.onCreateActionView(this); | ||||
|         } | ||||
|         return this.mActionView != null; | ||||
|     } | ||||
|  | ||||
|     public void setActionViewExpanded(boolean z) { | ||||
|         this.mIsActionViewExpanded = z; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public SupportMenuItem setContentDescription(CharSequence charSequence) { | ||||
|         this.mContentDescription = charSequence; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public SupportMenuItem setTooltipText(CharSequence charSequence) { | ||||
|         this.mTooltipText = charSequence; | ||||
|         this.mMenu.onItemsChanged(false); | ||||
|         return this; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,483 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.graphics.PorterDuff; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.util.Log; | ||||
| import android.view.ActionProvider; | ||||
| import android.view.CollapsibleActionView; | ||||
| import android.view.ContextMenu; | ||||
| import android.view.MenuItem; | ||||
| import android.view.SubMenu; | ||||
| import android.view.View; | ||||
| import android.widget.FrameLayout; | ||||
| import androidx.core.internal.view.SupportMenuItem; | ||||
| import androidx.core.view.ActionProvider; | ||||
| import java.lang.reflect.Method; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MenuItemWrapperICS extends BaseMenuWrapper implements MenuItem { | ||||
|     static final String LOG_TAG = "MenuItemWrapper"; | ||||
|     private Method mSetExclusiveCheckableMethod; | ||||
|     private final SupportMenuItem mWrappedObject; | ||||
|  | ||||
|     public MenuItemWrapperICS(Context context, SupportMenuItem supportMenuItem) { | ||||
|         super(context); | ||||
|         if (supportMenuItem == null) { | ||||
|             throw new IllegalArgumentException("Wrapped Object can not be null."); | ||||
|         } | ||||
|         this.mWrappedObject = supportMenuItem; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getItemId() { | ||||
|         return this.mWrappedObject.getItemId(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getGroupId() { | ||||
|         return this.mWrappedObject.getGroupId(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getOrder() { | ||||
|         return this.mWrappedObject.getOrder(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitle(CharSequence charSequence) { | ||||
|         this.mWrappedObject.setTitle(charSequence); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitle(int i) { | ||||
|         this.mWrappedObject.setTitle(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public CharSequence getTitle() { | ||||
|         return this.mWrappedObject.getTitle(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTitleCondensed(CharSequence charSequence) { | ||||
|         this.mWrappedObject.setTitleCondensed(charSequence); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public CharSequence getTitleCondensed() { | ||||
|         return this.mWrappedObject.getTitleCondensed(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIcon(Drawable drawable) { | ||||
|         this.mWrappedObject.setIcon(drawable); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIcon(int i) { | ||||
|         this.mWrappedObject.setIcon(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public Drawable getIcon() { | ||||
|         return this.mWrappedObject.getIcon(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIntent(Intent intent) { | ||||
|         this.mWrappedObject.setIntent(intent); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public Intent getIntent() { | ||||
|         return this.mWrappedObject.getIntent(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setShortcut(char c, char c2) { | ||||
|         this.mWrappedObject.setShortcut(c, c2); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setShortcut(char c, char c2, int i, int i2) { | ||||
|         this.mWrappedObject.setShortcut(c, c2, i, i2); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setNumericShortcut(char c) { | ||||
|         this.mWrappedObject.setNumericShortcut(c); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setNumericShortcut(char c, int i) { | ||||
|         this.mWrappedObject.setNumericShortcut(c, i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public char getNumericShortcut() { | ||||
|         return this.mWrappedObject.getNumericShortcut(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getNumericModifiers() { | ||||
|         return this.mWrappedObject.getNumericModifiers(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setAlphabeticShortcut(char c) { | ||||
|         this.mWrappedObject.setAlphabeticShortcut(c); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setAlphabeticShortcut(char c, int i) { | ||||
|         this.mWrappedObject.setAlphabeticShortcut(c, i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public char getAlphabeticShortcut() { | ||||
|         return this.mWrappedObject.getAlphabeticShortcut(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public int getAlphabeticModifiers() { | ||||
|         return this.mWrappedObject.getAlphabeticModifiers(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setCheckable(boolean z) { | ||||
|         this.mWrappedObject.setCheckable(z); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isCheckable() { | ||||
|         return this.mWrappedObject.isCheckable(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setChecked(boolean z) { | ||||
|         this.mWrappedObject.setChecked(z); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isChecked() { | ||||
|         return this.mWrappedObject.isChecked(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setVisible(boolean z) { | ||||
|         return this.mWrappedObject.setVisible(z); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isVisible() { | ||||
|         return this.mWrappedObject.isVisible(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setEnabled(boolean z) { | ||||
|         this.mWrappedObject.setEnabled(z); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isEnabled() { | ||||
|         return this.mWrappedObject.isEnabled(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean hasSubMenu() { | ||||
|         return this.mWrappedObject.hasSubMenu(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public SubMenu getSubMenu() { | ||||
|         return getSubMenuWrapper(this.mWrappedObject.getSubMenu()); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) { | ||||
|         this.mWrappedObject.setOnMenuItemClickListener(onMenuItemClickListener != null ? new OnMenuItemClickListenerWrapper(onMenuItemClickListener) : null); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public ContextMenu.ContextMenuInfo getMenuInfo() { | ||||
|         return this.mWrappedObject.getMenuInfo(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public void setShowAsAction(int i) { | ||||
|         this.mWrappedObject.setShowAsAction(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setShowAsActionFlags(int i) { | ||||
|         this.mWrappedObject.setShowAsActionFlags(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setActionView(View view) { | ||||
|         if (view instanceof CollapsibleActionView) { | ||||
|             view = new CollapsibleActionViewWrapper(view); | ||||
|         } | ||||
|         this.mWrappedObject.setActionView(view); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setActionView(int i) { | ||||
|         this.mWrappedObject.setActionView(i); | ||||
|         View actionView = this.mWrappedObject.getActionView(); | ||||
|         if (actionView instanceof CollapsibleActionView) { | ||||
|             this.mWrappedObject.setActionView(new CollapsibleActionViewWrapper(actionView)); | ||||
|         } | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public View getActionView() { | ||||
|         View actionView = this.mWrappedObject.getActionView(); | ||||
|         return actionView instanceof CollapsibleActionViewWrapper ? ((CollapsibleActionViewWrapper) actionView).getWrappedView() : actionView; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setActionProvider(ActionProvider actionProvider) { | ||||
|         ActionProviderWrapperJB actionProviderWrapperJB = new ActionProviderWrapperJB(this.mContext, actionProvider); | ||||
|         SupportMenuItem supportMenuItem = this.mWrappedObject; | ||||
|         if (actionProvider == null) { | ||||
|             actionProviderWrapperJB = null; | ||||
|         } | ||||
|         supportMenuItem.setSupportActionProvider(actionProviderWrapperJB); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public ActionProvider getActionProvider() { | ||||
|         androidx.core.view.ActionProvider supportActionProvider = this.mWrappedObject.getSupportActionProvider(); | ||||
|         if (supportActionProvider instanceof ActionProviderWrapper) { | ||||
|             return ((ActionProviderWrapper) supportActionProvider).mInner; | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean expandActionView() { | ||||
|         return this.mWrappedObject.expandActionView(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean collapseActionView() { | ||||
|         return this.mWrappedObject.collapseActionView(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public boolean isActionViewExpanded() { | ||||
|         return this.mWrappedObject.isActionViewExpanded(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) { | ||||
|         this.mWrappedObject.setOnActionExpandListener(onActionExpandListener != null ? new OnActionExpandListenerWrapper(onActionExpandListener) : null); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setContentDescription(CharSequence charSequence) { | ||||
|         this.mWrappedObject.setContentDescription(charSequence); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public CharSequence getContentDescription() { | ||||
|         return this.mWrappedObject.getContentDescription(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setTooltipText(CharSequence charSequence) { | ||||
|         this.mWrappedObject.setTooltipText(charSequence); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public CharSequence getTooltipText() { | ||||
|         return this.mWrappedObject.getTooltipText(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIconTintList(ColorStateList colorStateList) { | ||||
|         this.mWrappedObject.setIconTintList(colorStateList); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public ColorStateList getIconTintList() { | ||||
|         return this.mWrappedObject.getIconTintList(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public MenuItem setIconTintMode(PorterDuff.Mode mode) { | ||||
|         this.mWrappedObject.setIconTintMode(mode); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuItem | ||||
|     public PorterDuff.Mode getIconTintMode() { | ||||
|         return this.mWrappedObject.getIconTintMode(); | ||||
|     } | ||||
|  | ||||
|     public void setExclusiveCheckable(boolean z) { | ||||
|         try { | ||||
|             if (this.mSetExclusiveCheckableMethod == null) { | ||||
|                 this.mSetExclusiveCheckableMethod = this.mWrappedObject.getClass().getDeclaredMethod("setExclusiveCheckable", Boolean.TYPE); | ||||
|             } | ||||
|             this.mSetExclusiveCheckableMethod.invoke(this.mWrappedObject, Boolean.valueOf(z)); | ||||
|         } catch (Exception e) { | ||||
|             Log.w(LOG_TAG, "Error while calling setExclusiveCheckable", e); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private class OnMenuItemClickListenerWrapper implements MenuItem.OnMenuItemClickListener { | ||||
|         private final MenuItem.OnMenuItemClickListener mObject; | ||||
|  | ||||
|         OnMenuItemClickListenerWrapper(MenuItem.OnMenuItemClickListener onMenuItemClickListener) { | ||||
|             this.mObject = onMenuItemClickListener; | ||||
|         } | ||||
|  | ||||
|         @Override // android.view.MenuItem.OnMenuItemClickListener | ||||
|         public boolean onMenuItemClick(MenuItem menuItem) { | ||||
|             return this.mObject.onMenuItemClick(MenuItemWrapperICS.this.getMenuItemWrapper(menuItem)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private class OnActionExpandListenerWrapper implements MenuItem.OnActionExpandListener { | ||||
|         private final MenuItem.OnActionExpandListener mObject; | ||||
|  | ||||
|         OnActionExpandListenerWrapper(MenuItem.OnActionExpandListener onActionExpandListener) { | ||||
|             this.mObject = onActionExpandListener; | ||||
|         } | ||||
|  | ||||
|         @Override // android.view.MenuItem.OnActionExpandListener | ||||
|         public boolean onMenuItemActionExpand(MenuItem menuItem) { | ||||
|             return this.mObject.onMenuItemActionExpand(MenuItemWrapperICS.this.getMenuItemWrapper(menuItem)); | ||||
|         } | ||||
|  | ||||
|         @Override // android.view.MenuItem.OnActionExpandListener | ||||
|         public boolean onMenuItemActionCollapse(MenuItem menuItem) { | ||||
|             return this.mObject.onMenuItemActionCollapse(MenuItemWrapperICS.this.getMenuItemWrapper(menuItem)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private class ActionProviderWrapper extends androidx.core.view.ActionProvider { | ||||
|         final ActionProvider mInner; | ||||
|  | ||||
|         ActionProviderWrapper(Context context, ActionProvider actionProvider) { | ||||
|             super(context); | ||||
|             this.mInner = actionProvider; | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public View onCreateActionView() { | ||||
|             return this.mInner.onCreateActionView(); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public boolean onPerformDefaultAction() { | ||||
|             return this.mInner.onPerformDefaultAction(); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public boolean hasSubMenu() { | ||||
|             return this.mInner.hasSubMenu(); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public void onPrepareSubMenu(SubMenu subMenu) { | ||||
|             this.mInner.onPrepareSubMenu(MenuItemWrapperICS.this.getSubMenuWrapper(subMenu)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private class ActionProviderWrapperJB extends ActionProviderWrapper implements ActionProvider.VisibilityListener { | ||||
|         private ActionProvider.VisibilityListener mListener; | ||||
|  | ||||
|         ActionProviderWrapperJB(Context context, android.view.ActionProvider actionProvider) { | ||||
|             super(context, actionProvider); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public View onCreateActionView(MenuItem menuItem) { | ||||
|             return this.mInner.onCreateActionView(menuItem); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public boolean overridesItemVisibility() { | ||||
|             return this.mInner.overridesItemVisibility(); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public boolean isVisible() { | ||||
|             return this.mInner.isVisible(); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public void refreshVisibility() { | ||||
|             this.mInner.refreshVisibility(); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.core.view.ActionProvider | ||||
|         public void setVisibilityListener(ActionProvider.VisibilityListener visibilityListener) { | ||||
|             this.mListener = visibilityListener; | ||||
|             this.mInner.setVisibilityListener(visibilityListener != null ? this : null); | ||||
|         } | ||||
|  | ||||
|         @Override // android.view.ActionProvider.VisibilityListener | ||||
|         public void onActionProviderVisibilityChanged(boolean z) { | ||||
|             ActionProvider.VisibilityListener visibilityListener = this.mListener; | ||||
|             if (visibilityListener != null) { | ||||
|                 visibilityListener.onActionProviderVisibilityChanged(z); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static class CollapsibleActionViewWrapper extends FrameLayout implements androidx.appcompat.view.CollapsibleActionView { | ||||
|         final CollapsibleActionView mWrappedView; | ||||
|  | ||||
|         /* JADX WARN: Multi-variable type inference failed */ | ||||
|         CollapsibleActionViewWrapper(View view) { | ||||
|             super(view.getContext()); | ||||
|             this.mWrappedView = (CollapsibleActionView) view; | ||||
|             addView(view); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.appcompat.view.CollapsibleActionView | ||||
|         public void onActionViewExpanded() { | ||||
|             this.mWrappedView.onActionViewExpanded(); | ||||
|         } | ||||
|  | ||||
|         @Override // androidx.appcompat.view.CollapsibleActionView | ||||
|         public void onActionViewCollapsed() { | ||||
|             this.mWrappedView.onActionViewCollapsed(); | ||||
|         } | ||||
|  | ||||
|         View getWrappedView() { | ||||
|             return (View) this.mWrappedView; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										126
									
								
								02-Easy5/E5/sources/androidx/appcompat/view/menu/MenuPopup.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								02-Easy5/E5/sources/androidx/appcompat/view/menu/MenuPopup.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,126 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.graphics.Rect; | ||||
| import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.AdapterView; | ||||
| import android.widget.FrameLayout; | ||||
| import android.widget.HeaderViewListAdapter; | ||||
| import android.widget.ListAdapter; | ||||
| import android.widget.PopupWindow; | ||||
|  | ||||
| /* JADX INFO: Access modifiers changed from: package-private */ | ||||
| /* loaded from: classes.dex */ | ||||
| public abstract class MenuPopup implements ShowableListMenu, MenuPresenter, AdapterView.OnItemClickListener { | ||||
|     private Rect mEpicenterBounds; | ||||
|  | ||||
|     public abstract void addMenu(MenuBuilder menuBuilder); | ||||
|  | ||||
|     protected boolean closeMenuOnSubMenuOpened() { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean collapseItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean expandItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public Rect getEpicenterBounds() { | ||||
|         return this.mEpicenterBounds; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public int getId() { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void initForMenu(Context context, MenuBuilder menuBuilder) { | ||||
|     } | ||||
|  | ||||
|     public abstract void setAnchorView(View view); | ||||
|  | ||||
|     public void setEpicenterBounds(Rect rect) { | ||||
|         this.mEpicenterBounds = rect; | ||||
|     } | ||||
|  | ||||
|     public abstract void setForceShowIcon(boolean z); | ||||
|  | ||||
|     public abstract void setGravity(int i); | ||||
|  | ||||
|     public abstract void setHorizontalOffset(int i); | ||||
|  | ||||
|     public abstract void setOnDismissListener(PopupWindow.OnDismissListener onDismissListener); | ||||
|  | ||||
|     public abstract void setShowTitle(boolean z); | ||||
|  | ||||
|     public abstract void setVerticalOffset(int i); | ||||
|  | ||||
|     MenuPopup() { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public MenuView getMenuView(ViewGroup viewGroup) { | ||||
|         throw new UnsupportedOperationException("MenuPopups manage their own views"); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.AdapterView.OnItemClickListener | ||||
|     public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) { | ||||
|         ListAdapter listAdapter = (ListAdapter) adapterView.getAdapter(); | ||||
|         toMenuAdapter(listAdapter).mAdapterMenu.performItemAction((MenuItem) listAdapter.getItem(i), this, closeMenuOnSubMenuOpened() ? 0 : 4); | ||||
|     } | ||||
|  | ||||
|     protected static int measureIndividualMenuWidth(ListAdapter listAdapter, ViewGroup viewGroup, Context context, int i) { | ||||
|         int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, 0); | ||||
|         int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(0, 0); | ||||
|         int count = listAdapter.getCount(); | ||||
|         View view = null; | ||||
|         int i2 = 0; | ||||
|         int i3 = 0; | ||||
|         for (int i4 = 0; i4 < count; i4++) { | ||||
|             int itemViewType = listAdapter.getItemViewType(i4); | ||||
|             if (itemViewType != i3) { | ||||
|                 view = null; | ||||
|                 i3 = itemViewType; | ||||
|             } | ||||
|             if (viewGroup == null) { | ||||
|                 viewGroup = new FrameLayout(context); | ||||
|             } | ||||
|             view = listAdapter.getView(i4, view, viewGroup); | ||||
|             view.measure(makeMeasureSpec, makeMeasureSpec2); | ||||
|             int measuredWidth = view.getMeasuredWidth(); | ||||
|             if (measuredWidth >= i) { | ||||
|                 return i; | ||||
|             } | ||||
|             if (measuredWidth > i2) { | ||||
|                 i2 = measuredWidth; | ||||
|             } | ||||
|         } | ||||
|         return i2; | ||||
|     } | ||||
|  | ||||
|     protected static MenuAdapter toMenuAdapter(ListAdapter listAdapter) { | ||||
|         if (listAdapter instanceof HeaderViewListAdapter) { | ||||
|             return (MenuAdapter) ((HeaderViewListAdapter) listAdapter).getWrappedAdapter(); | ||||
|         } | ||||
|         return (MenuAdapter) listAdapter; | ||||
|     } | ||||
|  | ||||
|     protected static boolean shouldPreserveIconSpacing(MenuBuilder menuBuilder) { | ||||
|         int size = menuBuilder.size(); | ||||
|         for (int i = 0; i < size; i++) { | ||||
|             MenuItem item = menuBuilder.getItem(i); | ||||
|             if (item.isVisible() && item.getIcon() != null) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,200 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.graphics.Point; | ||||
| import android.graphics.Rect; | ||||
| import android.view.Display; | ||||
| import android.view.View; | ||||
| import android.view.WindowManager; | ||||
| import android.widget.ListView; | ||||
| import android.widget.PopupWindow; | ||||
| import androidx.appcompat.R; | ||||
| import androidx.appcompat.view.menu.MenuPresenter; | ||||
| import androidx.core.view.GravityCompat; | ||||
| import androidx.core.view.ViewCompat; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MenuPopupHelper implements MenuHelper { | ||||
|     private static final int TOUCH_EPICENTER_SIZE_DP = 48; | ||||
|     private View mAnchorView; | ||||
|     private final Context mContext; | ||||
|     private int mDropDownGravity; | ||||
|     private boolean mForceShowIcon; | ||||
|     private final PopupWindow.OnDismissListener mInternalOnDismissListener; | ||||
|     private final MenuBuilder mMenu; | ||||
|     private PopupWindow.OnDismissListener mOnDismissListener; | ||||
|     private final boolean mOverflowOnly; | ||||
|     private MenuPopup mPopup; | ||||
|     private final int mPopupStyleAttr; | ||||
|     private final int mPopupStyleRes; | ||||
|     private MenuPresenter.Callback mPresenterCallback; | ||||
|  | ||||
|     public int getGravity() { | ||||
|         return this.mDropDownGravity; | ||||
|     } | ||||
|  | ||||
|     public void setAnchorView(View view) { | ||||
|         this.mAnchorView = view; | ||||
|     } | ||||
|  | ||||
|     public void setGravity(int i) { | ||||
|         this.mDropDownGravity = i; | ||||
|     } | ||||
|  | ||||
|     public void setOnDismissListener(PopupWindow.OnDismissListener onDismissListener) { | ||||
|         this.mOnDismissListener = onDismissListener; | ||||
|     } | ||||
|  | ||||
|     public MenuPopupHelper(Context context, MenuBuilder menuBuilder) { | ||||
|         this(context, menuBuilder, null, false, R.attr.popupMenuStyle, 0); | ||||
|     } | ||||
|  | ||||
|     public MenuPopupHelper(Context context, MenuBuilder menuBuilder, View view) { | ||||
|         this(context, menuBuilder, view, false, R.attr.popupMenuStyle, 0); | ||||
|     } | ||||
|  | ||||
|     public MenuPopupHelper(Context context, MenuBuilder menuBuilder, View view, boolean z, int i) { | ||||
|         this(context, menuBuilder, view, z, i, 0); | ||||
|     } | ||||
|  | ||||
|     public MenuPopupHelper(Context context, MenuBuilder menuBuilder, View view, boolean z, int i, int i2) { | ||||
|         this.mDropDownGravity = GravityCompat.START; | ||||
|         this.mInternalOnDismissListener = new PopupWindow.OnDismissListener() { // from class: androidx.appcompat.view.menu.MenuPopupHelper.1 | ||||
|             @Override // android.widget.PopupWindow.OnDismissListener | ||||
|             public void onDismiss() { | ||||
|                 MenuPopupHelper.this.onDismiss(); | ||||
|             } | ||||
|         }; | ||||
|         this.mContext = context; | ||||
|         this.mMenu = menuBuilder; | ||||
|         this.mAnchorView = view; | ||||
|         this.mOverflowOnly = z; | ||||
|         this.mPopupStyleAttr = i; | ||||
|         this.mPopupStyleRes = i2; | ||||
|     } | ||||
|  | ||||
|     public void setForceShowIcon(boolean z) { | ||||
|         this.mForceShowIcon = z; | ||||
|         MenuPopup menuPopup = this.mPopup; | ||||
|         if (menuPopup != null) { | ||||
|             menuPopup.setForceShowIcon(z); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void show() { | ||||
|         if (!tryShow()) { | ||||
|             throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void show(int i, int i2) { | ||||
|         if (!tryShow(i, i2)) { | ||||
|             throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public MenuPopup getPopup() { | ||||
|         if (this.mPopup == null) { | ||||
|             this.mPopup = createPopup(); | ||||
|         } | ||||
|         return this.mPopup; | ||||
|     } | ||||
|  | ||||
|     public boolean tryShow() { | ||||
|         if (isShowing()) { | ||||
|             return true; | ||||
|         } | ||||
|         if (this.mAnchorView == null) { | ||||
|             return false; | ||||
|         } | ||||
|         showPopup(0, 0, false, false); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     public boolean tryShow(int i, int i2) { | ||||
|         if (isShowing()) { | ||||
|             return true; | ||||
|         } | ||||
|         if (this.mAnchorView == null) { | ||||
|             return false; | ||||
|         } | ||||
|         showPopup(i, i2, true, true); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     private MenuPopup createPopup() { | ||||
|         MenuPopup standardMenuPopup; | ||||
|         Display defaultDisplay = ((WindowManager) this.mContext.getSystemService("window")).getDefaultDisplay(); | ||||
|         Point point = new Point(); | ||||
|         Api17Impl.getRealSize(defaultDisplay, point); | ||||
|         if (Math.min(point.x, point.y) >= this.mContext.getResources().getDimensionPixelSize(R.dimen.abc_cascading_menus_min_smallest_width)) { | ||||
|             standardMenuPopup = new CascadingMenuPopup(this.mContext, this.mAnchorView, this.mPopupStyleAttr, this.mPopupStyleRes, this.mOverflowOnly); | ||||
|         } else { | ||||
|             standardMenuPopup = new StandardMenuPopup(this.mContext, this.mMenu, this.mAnchorView, this.mPopupStyleAttr, this.mPopupStyleRes, this.mOverflowOnly); | ||||
|         } | ||||
|         standardMenuPopup.addMenu(this.mMenu); | ||||
|         standardMenuPopup.setOnDismissListener(this.mInternalOnDismissListener); | ||||
|         standardMenuPopup.setAnchorView(this.mAnchorView); | ||||
|         standardMenuPopup.setCallback(this.mPresenterCallback); | ||||
|         standardMenuPopup.setForceShowIcon(this.mForceShowIcon); | ||||
|         standardMenuPopup.setGravity(this.mDropDownGravity); | ||||
|         return standardMenuPopup; | ||||
|     } | ||||
|  | ||||
|     private void showPopup(int i, int i2, boolean z, boolean z2) { | ||||
|         MenuPopup popup = getPopup(); | ||||
|         popup.setShowTitle(z2); | ||||
|         if (z) { | ||||
|             if ((GravityCompat.getAbsoluteGravity(this.mDropDownGravity, ViewCompat.getLayoutDirection(this.mAnchorView)) & 7) == 5) { | ||||
|                 i -= this.mAnchorView.getWidth(); | ||||
|             } | ||||
|             popup.setHorizontalOffset(i); | ||||
|             popup.setVerticalOffset(i2); | ||||
|             int i3 = (int) ((this.mContext.getResources().getDisplayMetrics().density * 48.0f) / 2.0f); | ||||
|             popup.setEpicenterBounds(new Rect(i - i3, i2 - i3, i + i3, i2 + i3)); | ||||
|         } | ||||
|         popup.show(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuHelper | ||||
|     public void dismiss() { | ||||
|         if (isShowing()) { | ||||
|             this.mPopup.dismiss(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected void onDismiss() { | ||||
|         this.mPopup = null; | ||||
|         PopupWindow.OnDismissListener onDismissListener = this.mOnDismissListener; | ||||
|         if (onDismissListener != null) { | ||||
|             onDismissListener.onDismiss(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public boolean isShowing() { | ||||
|         MenuPopup menuPopup = this.mPopup; | ||||
|         return menuPopup != null && menuPopup.isShowing(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuHelper | ||||
|     public void setPresenterCallback(MenuPresenter.Callback callback) { | ||||
|         this.mPresenterCallback = callback; | ||||
|         MenuPopup menuPopup = this.mPopup; | ||||
|         if (menuPopup != null) { | ||||
|             menuPopup.setCallback(callback); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public ListView getListView() { | ||||
|         return getPopup().getListView(); | ||||
|     } | ||||
|  | ||||
|     static class Api17Impl { | ||||
|         private Api17Impl() { | ||||
|         } | ||||
|  | ||||
|         static void getRealSize(Display display, Point point) { | ||||
|             display.getRealSize(point); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,39 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.os.Parcelable; | ||||
| import android.view.ViewGroup; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public interface MenuPresenter { | ||||
|  | ||||
|     public interface Callback { | ||||
|         void onCloseMenu(MenuBuilder menuBuilder, boolean z); | ||||
|  | ||||
|         boolean onOpenSubMenu(MenuBuilder menuBuilder); | ||||
|     } | ||||
|  | ||||
|     boolean collapseItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl); | ||||
|  | ||||
|     boolean expandItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl); | ||||
|  | ||||
|     boolean flagActionItems(); | ||||
|  | ||||
|     int getId(); | ||||
|  | ||||
|     MenuView getMenuView(ViewGroup viewGroup); | ||||
|  | ||||
|     void initForMenu(Context context, MenuBuilder menuBuilder); | ||||
|  | ||||
|     void onCloseMenu(MenuBuilder menuBuilder, boolean z); | ||||
|  | ||||
|     void onRestoreInstanceState(Parcelable parcelable); | ||||
|  | ||||
|     Parcelable onSaveInstanceState(); | ||||
|  | ||||
|     boolean onSubMenuSelected(SubMenuBuilder subMenuBuilder); | ||||
|  | ||||
|     void setCallback(Callback callback); | ||||
|  | ||||
|     void updateMenuView(boolean z); | ||||
| } | ||||
| @@ -0,0 +1,33 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.graphics.drawable.Drawable; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public interface MenuView { | ||||
|  | ||||
|     public interface ItemView { | ||||
|         MenuItemImpl getItemData(); | ||||
|  | ||||
|         void initialize(MenuItemImpl menuItemImpl, int i); | ||||
|  | ||||
|         boolean prefersCondensedTitle(); | ||||
|  | ||||
|         void setCheckable(boolean z); | ||||
|  | ||||
|         void setChecked(boolean z); | ||||
|  | ||||
|         void setEnabled(boolean z); | ||||
|  | ||||
|         void setIcon(Drawable drawable); | ||||
|  | ||||
|         void setShortcut(boolean z, char c); | ||||
|  | ||||
|         void setTitle(CharSequence charSequence); | ||||
|  | ||||
|         boolean showsIcon(); | ||||
|     } | ||||
|  | ||||
|     int getWindowAnimations(); | ||||
|  | ||||
|     void initialize(MenuBuilder menuBuilder); | ||||
| } | ||||
| @@ -0,0 +1,154 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.ComponentName; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.view.KeyEvent; | ||||
| import android.view.Menu; | ||||
| import android.view.MenuItem; | ||||
| import android.view.SubMenu; | ||||
| import androidx.core.internal.view.SupportMenu; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MenuWrapperICS extends BaseMenuWrapper implements Menu { | ||||
|     private final SupportMenu mWrappedObject; | ||||
|  | ||||
|     public MenuWrapperICS(Context context, SupportMenu supportMenu) { | ||||
|         super(context); | ||||
|         if (supportMenu == null) { | ||||
|             throw new IllegalArgumentException("Wrapped Object can not be null."); | ||||
|         } | ||||
|         this.mWrappedObject = supportMenu; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem add(CharSequence charSequence) { | ||||
|         return getMenuItemWrapper(this.mWrappedObject.add(charSequence)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem add(int i) { | ||||
|         return getMenuItemWrapper(this.mWrappedObject.add(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem add(int i, int i2, int i3, CharSequence charSequence) { | ||||
|         return getMenuItemWrapper(this.mWrappedObject.add(i, i2, i3, charSequence)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem add(int i, int i2, int i3, int i4) { | ||||
|         return getMenuItemWrapper(this.mWrappedObject.add(i, i2, i3, i4)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public SubMenu addSubMenu(CharSequence charSequence) { | ||||
|         return getSubMenuWrapper(this.mWrappedObject.addSubMenu(charSequence)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public SubMenu addSubMenu(int i) { | ||||
|         return getSubMenuWrapper(this.mWrappedObject.addSubMenu(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public SubMenu addSubMenu(int i, int i2, int i3, CharSequence charSequence) { | ||||
|         return getSubMenuWrapper(this.mWrappedObject.addSubMenu(i, i2, i3, charSequence)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public SubMenu addSubMenu(int i, int i2, int i3, int i4) { | ||||
|         return getSubMenuWrapper(this.mWrappedObject.addSubMenu(i, i2, i3, i4)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public int addIntentOptions(int i, int i2, int i3, ComponentName componentName, Intent[] intentArr, Intent intent, int i4, MenuItem[] menuItemArr) { | ||||
|         MenuItem[] menuItemArr2 = menuItemArr != null ? new MenuItem[menuItemArr.length] : null; | ||||
|         int addIntentOptions = this.mWrappedObject.addIntentOptions(i, i2, i3, componentName, intentArr, intent, i4, menuItemArr2); | ||||
|         if (menuItemArr2 != null) { | ||||
|             int length = menuItemArr2.length; | ||||
|             for (int i5 = 0; i5 < length; i5++) { | ||||
|                 menuItemArr[i5] = getMenuItemWrapper(menuItemArr2[i5]); | ||||
|             } | ||||
|         } | ||||
|         return addIntentOptions; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void removeItem(int i) { | ||||
|         internalRemoveItem(i); | ||||
|         this.mWrappedObject.removeItem(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void removeGroup(int i) { | ||||
|         internalRemoveGroup(i); | ||||
|         this.mWrappedObject.removeGroup(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void clear() { | ||||
|         internalClear(); | ||||
|         this.mWrappedObject.clear(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void setGroupCheckable(int i, boolean z, boolean z2) { | ||||
|         this.mWrappedObject.setGroupCheckable(i, z, z2); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void setGroupVisible(int i, boolean z) { | ||||
|         this.mWrappedObject.setGroupVisible(i, z); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void setGroupEnabled(int i, boolean z) { | ||||
|         this.mWrappedObject.setGroupEnabled(i, z); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public boolean hasVisibleItems() { | ||||
|         return this.mWrappedObject.hasVisibleItems(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem findItem(int i) { | ||||
|         return getMenuItemWrapper(this.mWrappedObject.findItem(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public int size() { | ||||
|         return this.mWrappedObject.size(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public MenuItem getItem(int i) { | ||||
|         return getMenuItemWrapper(this.mWrappedObject.getItem(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void close() { | ||||
|         this.mWrappedObject.close(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public boolean performShortcut(int i, KeyEvent keyEvent, int i2) { | ||||
|         return this.mWrappedObject.performShortcut(i, keyEvent, i2); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public boolean isShortcutKey(int i, KeyEvent keyEvent) { | ||||
|         return this.mWrappedObject.isShortcutKey(i, keyEvent); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public boolean performIdentifierAction(int i, int i2) { | ||||
|         return this.mWrappedObject.performIdentifierAction(i, i2); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.Menu | ||||
|     public void setQwertyMode(boolean z) { | ||||
|         this.mWrappedObject.setQwertyMode(z); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,14 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.widget.ListView; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public interface ShowableListMenu { | ||||
|     void dismiss(); | ||||
|  | ||||
|     ListView getListView(); | ||||
|  | ||||
|     boolean isShowing(); | ||||
|  | ||||
|     void show(); | ||||
| } | ||||
| @@ -0,0 +1,290 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.Resources; | ||||
| import android.os.Parcelable; | ||||
| import android.view.Gravity; | ||||
| import android.view.KeyEvent; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.view.ViewTreeObserver; | ||||
| import android.widget.AdapterView; | ||||
| import android.widget.FrameLayout; | ||||
| import android.widget.ListView; | ||||
| import android.widget.PopupWindow; | ||||
| import android.widget.TextView; | ||||
| import androidx.appcompat.R; | ||||
| import androidx.appcompat.view.menu.MenuPresenter; | ||||
| import androidx.appcompat.widget.MenuPopupWindow; | ||||
| import androidx.core.view.ViewCompat; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| final class StandardMenuPopup extends MenuPopup implements PopupWindow.OnDismissListener, AdapterView.OnItemClickListener, MenuPresenter, View.OnKeyListener { | ||||
|     private static final int ITEM_LAYOUT = R.layout.abc_popup_menu_item_layout; | ||||
|     private final MenuAdapter mAdapter; | ||||
|     private View mAnchorView; | ||||
|     private int mContentWidth; | ||||
|     private final Context mContext; | ||||
|     private boolean mHasContentWidth; | ||||
|     private final MenuBuilder mMenu; | ||||
|     private PopupWindow.OnDismissListener mOnDismissListener; | ||||
|     private final boolean mOverflowOnly; | ||||
|     final MenuPopupWindow mPopup; | ||||
|     private final int mPopupMaxWidth; | ||||
|     private final int mPopupStyleAttr; | ||||
|     private final int mPopupStyleRes; | ||||
|     private MenuPresenter.Callback mPresenterCallback; | ||||
|     private boolean mShowTitle; | ||||
|     View mShownAnchorView; | ||||
|     ViewTreeObserver mTreeObserver; | ||||
|     private boolean mWasDismissed; | ||||
|     final ViewTreeObserver.OnGlobalLayoutListener mGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { // from class: androidx.appcompat.view.menu.StandardMenuPopup.1 | ||||
|         @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener | ||||
|         public void onGlobalLayout() { | ||||
|             if (!StandardMenuPopup.this.isShowing() || StandardMenuPopup.this.mPopup.isModal()) { | ||||
|                 return; | ||||
|             } | ||||
|             View view = StandardMenuPopup.this.mShownAnchorView; | ||||
|             if (view == null || !view.isShown()) { | ||||
|                 StandardMenuPopup.this.dismiss(); | ||||
|             } else { | ||||
|                 StandardMenuPopup.this.mPopup.show(); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|     private final View.OnAttachStateChangeListener mAttachStateChangeListener = new View.OnAttachStateChangeListener() { // from class: androidx.appcompat.view.menu.StandardMenuPopup.2 | ||||
|         @Override // android.view.View.OnAttachStateChangeListener | ||||
|         public void onViewAttachedToWindow(View view) { | ||||
|         } | ||||
|  | ||||
|         @Override // android.view.View.OnAttachStateChangeListener | ||||
|         public void onViewDetachedFromWindow(View view) { | ||||
|             if (StandardMenuPopup.this.mTreeObserver != null) { | ||||
|                 if (!StandardMenuPopup.this.mTreeObserver.isAlive()) { | ||||
|                     StandardMenuPopup.this.mTreeObserver = view.getViewTreeObserver(); | ||||
|                 } | ||||
|                 StandardMenuPopup.this.mTreeObserver.removeGlobalOnLayoutListener(StandardMenuPopup.this.mGlobalLayoutListener); | ||||
|             } | ||||
|             view.removeOnAttachStateChangeListener(this); | ||||
|         } | ||||
|     }; | ||||
|     private int mDropDownGravity = 0; | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void addMenu(MenuBuilder menuBuilder) { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean flagActionItems() { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void onRestoreInstanceState(Parcelable parcelable) { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public Parcelable onSaveInstanceState() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setAnchorView(View view) { | ||||
|         this.mAnchorView = view; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void setCallback(MenuPresenter.Callback callback) { | ||||
|         this.mPresenterCallback = callback; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setGravity(int i) { | ||||
|         this.mDropDownGravity = i; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setOnDismissListener(PopupWindow.OnDismissListener onDismissListener) { | ||||
|         this.mOnDismissListener = onDismissListener; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setShowTitle(boolean z) { | ||||
|         this.mShowTitle = z; | ||||
|     } | ||||
|  | ||||
|     public StandardMenuPopup(Context context, MenuBuilder menuBuilder, View view, int i, int i2, boolean z) { | ||||
|         this.mContext = context; | ||||
|         this.mMenu = menuBuilder; | ||||
|         this.mOverflowOnly = z; | ||||
|         this.mAdapter = new MenuAdapter(menuBuilder, LayoutInflater.from(context), z, ITEM_LAYOUT); | ||||
|         this.mPopupStyleAttr = i; | ||||
|         this.mPopupStyleRes = i2; | ||||
|         Resources resources = context.getResources(); | ||||
|         this.mPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth)); | ||||
|         this.mAnchorView = view; | ||||
|         this.mPopup = new MenuPopupWindow(context, null, i, i2); | ||||
|         menuBuilder.addMenuPresenter(this, context); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setForceShowIcon(boolean z) { | ||||
|         this.mAdapter.setForceShowIcon(z); | ||||
|     } | ||||
|  | ||||
|     private boolean tryShow() { | ||||
|         View view; | ||||
|         if (isShowing()) { | ||||
|             return true; | ||||
|         } | ||||
|         if (this.mWasDismissed || (view = this.mAnchorView) == null) { | ||||
|             return false; | ||||
|         } | ||||
|         this.mShownAnchorView = view; | ||||
|         this.mPopup.setOnDismissListener(this); | ||||
|         this.mPopup.setOnItemClickListener(this); | ||||
|         this.mPopup.setModal(true); | ||||
|         View view2 = this.mShownAnchorView; | ||||
|         boolean z = this.mTreeObserver == null; | ||||
|         ViewTreeObserver viewTreeObserver = view2.getViewTreeObserver(); | ||||
|         this.mTreeObserver = viewTreeObserver; | ||||
|         if (z) { | ||||
|             viewTreeObserver.addOnGlobalLayoutListener(this.mGlobalLayoutListener); | ||||
|         } | ||||
|         view2.addOnAttachStateChangeListener(this.mAttachStateChangeListener); | ||||
|         this.mPopup.setAnchorView(view2); | ||||
|         this.mPopup.setDropDownGravity(this.mDropDownGravity); | ||||
|         if (!this.mHasContentWidth) { | ||||
|             this.mContentWidth = measureIndividualMenuWidth(this.mAdapter, null, this.mContext, this.mPopupMaxWidth); | ||||
|             this.mHasContentWidth = true; | ||||
|         } | ||||
|         this.mPopup.setContentWidth(this.mContentWidth); | ||||
|         this.mPopup.setInputMethodMode(2); | ||||
|         this.mPopup.setEpicenterBounds(getEpicenterBounds()); | ||||
|         this.mPopup.show(); | ||||
|         ListView listView = this.mPopup.getListView(); | ||||
|         listView.setOnKeyListener(this); | ||||
|         if (this.mShowTitle && this.mMenu.getHeaderTitle() != null) { | ||||
|             FrameLayout frameLayout = (FrameLayout) LayoutInflater.from(this.mContext).inflate(R.layout.abc_popup_menu_header_item_layout, (ViewGroup) listView, false); | ||||
|             TextView textView = (TextView) frameLayout.findViewById(android.R.id.title); | ||||
|             if (textView != null) { | ||||
|                 textView.setText(this.mMenu.getHeaderTitle()); | ||||
|             } | ||||
|             frameLayout.setEnabled(false); | ||||
|             listView.addHeaderView(frameLayout, null, false); | ||||
|         } | ||||
|         this.mPopup.setAdapter(this.mAdapter); | ||||
|         this.mPopup.show(); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.ShowableListMenu | ||||
|     public void show() { | ||||
|         if (!tryShow()) { | ||||
|             throw new IllegalStateException("StandardMenuPopup cannot be used without an anchor"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.ShowableListMenu | ||||
|     public void dismiss() { | ||||
|         if (isShowing()) { | ||||
|             this.mPopup.dismiss(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.ShowableListMenu | ||||
|     public boolean isShowing() { | ||||
|         return !this.mWasDismissed && this.mPopup.isShowing(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.PopupWindow.OnDismissListener | ||||
|     public void onDismiss() { | ||||
|         this.mWasDismissed = true; | ||||
|         this.mMenu.close(); | ||||
|         ViewTreeObserver viewTreeObserver = this.mTreeObserver; | ||||
|         if (viewTreeObserver != null) { | ||||
|             if (!viewTreeObserver.isAlive()) { | ||||
|                 this.mTreeObserver = this.mShownAnchorView.getViewTreeObserver(); | ||||
|             } | ||||
|             this.mTreeObserver.removeGlobalOnLayoutListener(this.mGlobalLayoutListener); | ||||
|             this.mTreeObserver = null; | ||||
|         } | ||||
|         this.mShownAnchorView.removeOnAttachStateChangeListener(this.mAttachStateChangeListener); | ||||
|         PopupWindow.OnDismissListener onDismissListener = this.mOnDismissListener; | ||||
|         if (onDismissListener != null) { | ||||
|             onDismissListener.onDismiss(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void updateMenuView(boolean z) { | ||||
|         this.mHasContentWidth = false; | ||||
|         MenuAdapter menuAdapter = this.mAdapter; | ||||
|         if (menuAdapter != null) { | ||||
|             menuAdapter.notifyDataSetChanged(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public boolean onSubMenuSelected(SubMenuBuilder subMenuBuilder) { | ||||
|         if (subMenuBuilder.hasVisibleItems()) { | ||||
|             MenuPopupHelper menuPopupHelper = new MenuPopupHelper(this.mContext, subMenuBuilder, this.mShownAnchorView, this.mOverflowOnly, this.mPopupStyleAttr, this.mPopupStyleRes); | ||||
|             menuPopupHelper.setPresenterCallback(this.mPresenterCallback); | ||||
|             menuPopupHelper.setForceShowIcon(MenuPopup.shouldPreserveIconSpacing(subMenuBuilder)); | ||||
|             menuPopupHelper.setOnDismissListener(this.mOnDismissListener); | ||||
|             this.mOnDismissListener = null; | ||||
|             this.mMenu.close(false); | ||||
|             int horizontalOffset = this.mPopup.getHorizontalOffset(); | ||||
|             int verticalOffset = this.mPopup.getVerticalOffset(); | ||||
|             if ((Gravity.getAbsoluteGravity(this.mDropDownGravity, ViewCompat.getLayoutDirection(this.mAnchorView)) & 7) == 5) { | ||||
|                 horizontalOffset += this.mAnchorView.getWidth(); | ||||
|             } | ||||
|             if (menuPopupHelper.tryShow(horizontalOffset, verticalOffset)) { | ||||
|                 MenuPresenter.Callback callback = this.mPresenterCallback; | ||||
|                 if (callback == null) { | ||||
|                     return true; | ||||
|                 } | ||||
|                 callback.onOpenSubMenu(subMenuBuilder); | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPresenter | ||||
|     public void onCloseMenu(MenuBuilder menuBuilder, boolean z) { | ||||
|         if (menuBuilder != this.mMenu) { | ||||
|             return; | ||||
|         } | ||||
|         dismiss(); | ||||
|         MenuPresenter.Callback callback = this.mPresenterCallback; | ||||
|         if (callback != null) { | ||||
|             callback.onCloseMenu(menuBuilder, z); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View.OnKeyListener | ||||
|     public boolean onKey(View view, int i, KeyEvent keyEvent) { | ||||
|         if (keyEvent.getAction() != 1 || i != 82) { | ||||
|             return false; | ||||
|         } | ||||
|         dismiss(); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.ShowableListMenu | ||||
|     public ListView getListView() { | ||||
|         return this.mPopup.getListView(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setHorizontalOffset(int i) { | ||||
|         this.mPopup.setHorizontalOffset(i); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuPopup | ||||
|     public void setVerticalOffset(int i) { | ||||
|         this.mPopup.setVerticalOffset(i); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,132 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.view.Menu; | ||||
| import android.view.MenuItem; | ||||
| import android.view.SubMenu; | ||||
| import android.view.View; | ||||
| import androidx.appcompat.view.menu.MenuBuilder; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class SubMenuBuilder extends MenuBuilder implements SubMenu { | ||||
|     private MenuItemImpl mItem; | ||||
|     private MenuBuilder mParentMenu; | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public MenuItem getItem() { | ||||
|         return this.mItem; | ||||
|     } | ||||
|  | ||||
|     public Menu getParentMenu() { | ||||
|         return this.mParentMenu; | ||||
|     } | ||||
|  | ||||
|     public SubMenuBuilder(Context context, MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { | ||||
|         super(context); | ||||
|         this.mParentMenu = menuBuilder; | ||||
|         this.mItem = menuItemImpl; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder, android.view.Menu | ||||
|     public void setQwertyMode(boolean z) { | ||||
|         this.mParentMenu.setQwertyMode(z); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public boolean isQwertyMode() { | ||||
|         return this.mParentMenu.isQwertyMode(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public void setShortcutsVisible(boolean z) { | ||||
|         this.mParentMenu.setShortcutsVisible(z); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public boolean isShortcutsVisible() { | ||||
|         return this.mParentMenu.isShortcutsVisible(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public void setCallback(MenuBuilder.Callback callback) { | ||||
|         this.mParentMenu.setCallback(callback); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public MenuBuilder getRootMenu() { | ||||
|         return this.mParentMenu.getRootMenu(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     boolean dispatchMenuItemSelected(MenuBuilder menuBuilder, MenuItem menuItem) { | ||||
|         return super.dispatchMenuItemSelected(menuBuilder, menuItem) || this.mParentMenu.dispatchMenuItemSelected(menuBuilder, menuItem); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setIcon(Drawable drawable) { | ||||
|         this.mItem.setIcon(drawable); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setIcon(int i) { | ||||
|         this.mItem.setIcon(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderIcon(Drawable drawable) { | ||||
|         return (SubMenu) super.setHeaderIconInt(drawable); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderIcon(int i) { | ||||
|         return (SubMenu) super.setHeaderIconInt(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderTitle(CharSequence charSequence) { | ||||
|         return (SubMenu) super.setHeaderTitleInt(charSequence); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderTitle(int i) { | ||||
|         return (SubMenu) super.setHeaderTitleInt(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderView(View view) { | ||||
|         return (SubMenu) super.setHeaderViewInt(view); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public boolean expandItemActionView(MenuItemImpl menuItemImpl) { | ||||
|         return this.mParentMenu.expandItemActionView(menuItemImpl); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public boolean collapseItemActionView(MenuItemImpl menuItemImpl) { | ||||
|         return this.mParentMenu.collapseItemActionView(menuItemImpl); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public String getActionViewStatesKey() { | ||||
|         MenuItemImpl menuItemImpl = this.mItem; | ||||
|         int itemId = menuItemImpl != null ? menuItemImpl.getItemId() : 0; | ||||
|         if (itemId == 0) { | ||||
|             return null; | ||||
|         } | ||||
|         return super.getActionViewStatesKey() + ":" + itemId; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder, androidx.core.internal.view.SupportMenu, android.view.Menu | ||||
|     public void setGroupDividerEnabled(boolean z) { | ||||
|         this.mParentMenu.setGroupDividerEnabled(z); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.view.menu.MenuBuilder | ||||
|     public boolean isGroupDividerEnabled() { | ||||
|         return this.mParentMenu.isGroupDividerEnabled(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,70 @@ | ||||
| package androidx.appcompat.view.menu; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.view.MenuItem; | ||||
| import android.view.SubMenu; | ||||
| import android.view.View; | ||||
| import androidx.core.internal.view.SupportSubMenu; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class SubMenuWrapperICS extends MenuWrapperICS implements SubMenu { | ||||
|     private final SupportSubMenu mSubMenu; | ||||
|  | ||||
|     SubMenuWrapperICS(Context context, SupportSubMenu supportSubMenu) { | ||||
|         super(context, supportSubMenu); | ||||
|         this.mSubMenu = supportSubMenu; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderTitle(int i) { | ||||
|         this.mSubMenu.setHeaderTitle(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderTitle(CharSequence charSequence) { | ||||
|         this.mSubMenu.setHeaderTitle(charSequence); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderIcon(int i) { | ||||
|         this.mSubMenu.setHeaderIcon(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderIcon(Drawable drawable) { | ||||
|         this.mSubMenu.setHeaderIcon(drawable); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setHeaderView(View view) { | ||||
|         this.mSubMenu.setHeaderView(view); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public void clearHeader() { | ||||
|         this.mSubMenu.clearHeader(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setIcon(int i) { | ||||
|         this.mSubMenu.setIcon(i); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public SubMenu setIcon(Drawable drawable) { | ||||
|         this.mSubMenu.setIcon(drawable); | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.SubMenu | ||||
|     public MenuItem getItem() { | ||||
|         return getMenuItemWrapper(this.mSubMenu.getItem()); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user