Initial commit
This commit is contained in:
406
sources/androidx/appcompat/view/menu/ActionMenuItem.java
Normal file
406
sources/androidx/appcompat/view/menu/ActionMenuItem.java
Normal file
@@ -0,0 +1,406 @@
|
||||
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;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionMenuItem implements SupportMenuItem {
|
||||
private final int a;
|
||||
private final int b;
|
||||
private final int c;
|
||||
private CharSequence d;
|
||||
private CharSequence e;
|
||||
private Intent f;
|
||||
private char g;
|
||||
private char i;
|
||||
private Drawable k;
|
||||
private Context l;
|
||||
private CharSequence m;
|
||||
private CharSequence n;
|
||||
private int h = FileUtil.ZIP_BUFFER_SIZE;
|
||||
private int j = FileUtil.ZIP_BUFFER_SIZE;
|
||||
private ColorStateList o = null;
|
||||
private PorterDuff.Mode p = null;
|
||||
private boolean q = false;
|
||||
private boolean r = false;
|
||||
private int s = 16;
|
||||
|
||||
public ActionMenuItem(Context context, int i, int i2, int i3, int i4, CharSequence charSequence) {
|
||||
this.l = context;
|
||||
this.a = i2;
|
||||
this.b = i;
|
||||
this.c = i4;
|
||||
this.d = charSequence;
|
||||
}
|
||||
|
||||
private void b() {
|
||||
if (this.k != null) {
|
||||
if (this.q || this.r) {
|
||||
this.k = DrawableCompat.h(this.k);
|
||||
this.k = this.k.mutate();
|
||||
if (this.q) {
|
||||
DrawableCompat.a(this.k, this.o);
|
||||
}
|
||||
if (this.r) {
|
||||
DrawableCompat.a(this.k, this.p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem
|
||||
public SupportMenuItem a(ActionProvider actionProvider) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem
|
||||
public ActionProvider a() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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 // android.view.MenuItem
|
||||
public android.view.ActionProvider getActionProvider() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@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.j;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public char getAlphabeticShortcut() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public CharSequence getContentDescription() {
|
||||
return this.m;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getGroupId() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public Drawable getIcon() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public ColorStateList getIconTintList() {
|
||||
return this.o;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public PorterDuff.Mode getIconTintMode() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public Intent getIntent() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getItemId() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public ContextMenu.ContextMenuInfo getMenuInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public int getNumericModifiers() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public char getNumericShortcut() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getOrder() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public SubMenu getSubMenu() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public CharSequence getTitle() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public CharSequence getTitleCondensed() {
|
||||
CharSequence charSequence = this.e;
|
||||
return charSequence != null ? charSequence : this.d;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public CharSequence getTooltipText() {
|
||||
return this.n;
|
||||
}
|
||||
|
||||
@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.s & 1) != 0;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isChecked() {
|
||||
return (this.s & 2) != 0;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isEnabled() {
|
||||
return (this.s & 16) != 0;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isVisible() {
|
||||
return (this.s & 8) == 0;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setActionProvider(android.view.ActionProvider actionProvider) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setActionView(int i) {
|
||||
setActionView(i);
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setAlphabeticShortcut(char c) {
|
||||
this.i = Character.toLowerCase(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setCheckable(boolean z) {
|
||||
this.s = (z ? 1 : 0) | (this.s & (-2));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setChecked(boolean z) {
|
||||
this.s = (z ? 2 : 0) | (this.s & (-3));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setContentDescription(CharSequence charSequence) {
|
||||
setContentDescription(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setEnabled(boolean z) {
|
||||
this.s = (z ? 16 : 0) | (this.s & (-17));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIcon(Drawable drawable) {
|
||||
this.k = drawable;
|
||||
b();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setIconTintList(ColorStateList colorStateList) {
|
||||
this.o = colorStateList;
|
||||
this.q = true;
|
||||
b();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setIconTintMode(PorterDuff.Mode mode) {
|
||||
this.p = mode;
|
||||
this.r = true;
|
||||
b();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIntent(Intent intent) {
|
||||
this.f = intent;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setNumericShortcut(char c) {
|
||||
this.g = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setShortcut(char c, char c2) {
|
||||
this.g = c;
|
||||
this.i = Character.toLowerCase(c2);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public void setShowAsAction(int i) {
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setShowAsActionFlags(int i) {
|
||||
setShowAsActionFlags(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitle(CharSequence charSequence) {
|
||||
this.d = charSequence;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitleCondensed(CharSequence charSequence) {
|
||||
this.e = charSequence;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setTooltipText(CharSequence charSequence) {
|
||||
setTooltipText(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setVisible(boolean z) {
|
||||
this.s = (this.s & 8) | (z ? 0 : 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setActionView(View view) {
|
||||
setActionView(view);
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setAlphabeticShortcut(char c, int i) {
|
||||
this.i = Character.toLowerCase(c);
|
||||
this.j = KeyEvent.normalizeMetaState(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public SupportMenuItem setContentDescription(CharSequence charSequence) {
|
||||
this.m = charSequence;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setNumericShortcut(char c, int i) {
|
||||
this.g = c;
|
||||
this.h = KeyEvent.normalizeMetaState(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public SupportMenuItem setShowAsActionFlags(int i) {
|
||||
setShowAsAction(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitle(int i) {
|
||||
this.d = this.l.getResources().getString(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public SupportMenuItem setTooltipText(CharSequence charSequence) {
|
||||
this.n = charSequence;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public SupportMenuItem setActionView(View view) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIcon(int i) {
|
||||
this.k = ContextCompat.c(this.l, i);
|
||||
b();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setShortcut(char c, char c2, int i, int i2) {
|
||||
this.g = c;
|
||||
this.h = KeyEvent.normalizeMetaState(i);
|
||||
this.i = Character.toLowerCase(c2);
|
||||
this.j = KeyEvent.normalizeMetaState(i2);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public SupportMenuItem setActionView(int i) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
253
sources/androidx/appcompat/view/menu/ActionMenuItemView.java
Normal file
253
sources/androidx/appcompat/view/menu/ActionMenuItemView.java
Normal file
@@ -0,0 +1,253 @@
|
||||
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 androidx.appcompat.R$styleable;
|
||||
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;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionMenuItemView extends AppCompatTextView implements MenuView.ItemView, View.OnClickListener, ActionMenuView.ActionMenuChildView {
|
||||
MenuItemImpl d;
|
||||
private CharSequence e;
|
||||
private Drawable f;
|
||||
MenuBuilder.ItemInvoker g;
|
||||
private ForwardingListener h;
|
||||
PopupCallback i;
|
||||
private boolean j;
|
||||
private boolean k;
|
||||
private int l;
|
||||
private int m;
|
||||
private int n;
|
||||
|
||||
private class ActionMenuItemForwardingListener extends ForwardingListener {
|
||||
public ActionMenuItemForwardingListener() {
|
||||
super(ActionMenuItemView.this);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.ForwardingListener
|
||||
public ShowableListMenu a() {
|
||||
PopupCallback popupCallback = ActionMenuItemView.this.i;
|
||||
if (popupCallback != null) {
|
||||
return popupCallback.a();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.ForwardingListener
|
||||
protected boolean b() {
|
||||
ShowableListMenu a;
|
||||
ActionMenuItemView actionMenuItemView = ActionMenuItemView.this;
|
||||
MenuBuilder.ItemInvoker itemInvoker = actionMenuItemView.g;
|
||||
return itemInvoker != null && itemInvoker.a(actionMenuItemView.d) && (a = a()) != null && a.c();
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class PopupCallback {
|
||||
public abstract ShowableListMenu a();
|
||||
}
|
||||
|
||||
public ActionMenuItemView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private boolean e() {
|
||||
Configuration configuration = getContext().getResources().getConfiguration();
|
||||
int i = configuration.screenWidthDp;
|
||||
return i >= 480 || (i >= 640 && configuration.screenHeightDp >= 480) || configuration.orientation == 2;
|
||||
}
|
||||
|
||||
private void f() {
|
||||
boolean z = true;
|
||||
boolean z2 = !TextUtils.isEmpty(this.e);
|
||||
if (this.f != null && (!this.d.n() || (!this.j && !this.k))) {
|
||||
z = false;
|
||||
}
|
||||
boolean z3 = z2 & z;
|
||||
setText(z3 ? this.e : null);
|
||||
CharSequence contentDescription = this.d.getContentDescription();
|
||||
if (TextUtils.isEmpty(contentDescription)) {
|
||||
setContentDescription(z3 ? null : this.d.getTitle());
|
||||
} else {
|
||||
setContentDescription(contentDescription);
|
||||
}
|
||||
CharSequence tooltipText = this.d.getTooltipText();
|
||||
if (TextUtils.isEmpty(tooltipText)) {
|
||||
TooltipCompat.a(this, z3 ? null : this.d.getTitle());
|
||||
} else {
|
||||
TooltipCompat.a(this, tooltipText);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuView.ItemView
|
||||
public void a(MenuItemImpl menuItemImpl, int i) {
|
||||
this.d = menuItemImpl;
|
||||
setIcon(menuItemImpl.getIcon());
|
||||
setTitle(menuItemImpl.a(this));
|
||||
setId(menuItemImpl.getItemId());
|
||||
setVisibility(menuItemImpl.isVisible() ? 0 : 8);
|
||||
setEnabled(menuItemImpl.isEnabled());
|
||||
if (menuItemImpl.hasSubMenu() && this.h == null) {
|
||||
this.h = new ActionMenuItemForwardingListener();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuView.ItemView
|
||||
public boolean a() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.ActionMenuView.ActionMenuChildView
|
||||
public boolean b() {
|
||||
return d();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.ActionMenuView.ActionMenuChildView
|
||||
public boolean c() {
|
||||
return d() && this.d.getIcon() == null;
|
||||
}
|
||||
|
||||
public boolean d() {
|
||||
return !TextUtils.isEmpty(getText());
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuView.ItemView
|
||||
public MenuItemImpl getItemData() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
MenuBuilder.ItemInvoker itemInvoker = this.g;
|
||||
if (itemInvoker != null) {
|
||||
itemInvoker.a(this.d);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
public void onConfigurationChanged(Configuration configuration) {
|
||||
super.onConfigurationChanged(configuration);
|
||||
this.j = e();
|
||||
f();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatTextView, android.widget.TextView, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
int i3;
|
||||
boolean d = d();
|
||||
if (d && (i3 = this.m) >= 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.l) : this.l;
|
||||
if (mode != 1073741824 && this.l > 0 && measuredWidth < min) {
|
||||
super.onMeasure(View.MeasureSpec.makeMeasureSpec(min, 1073741824), i2);
|
||||
}
|
||||
if (d || this.f == null) {
|
||||
return;
|
||||
}
|
||||
super.setPadding((getMeasuredWidth() - this.f.getBounds().width()) / 2, getPaddingTop(), getPaddingRight(), getPaddingBottom());
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
public void onRestoreInstanceState(Parcelable parcelable) {
|
||||
super.onRestoreInstanceState(null);
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
ForwardingListener forwardingListener;
|
||||
if (this.d.hasSubMenu() && (forwardingListener = this.h) != null && forwardingListener.onTouch(this, motionEvent)) {
|
||||
return true;
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
public void setCheckable(boolean z) {
|
||||
}
|
||||
|
||||
public void setChecked(boolean z) {
|
||||
}
|
||||
|
||||
public void setExpandedFormat(boolean z) {
|
||||
if (this.k != z) {
|
||||
this.k = z;
|
||||
MenuItemImpl menuItemImpl = this.d;
|
||||
if (menuItemImpl != null) {
|
||||
menuItemImpl.b();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIcon(Drawable drawable) {
|
||||
this.f = drawable;
|
||||
if (drawable != null) {
|
||||
int intrinsicWidth = drawable.getIntrinsicWidth();
|
||||
int intrinsicHeight = drawable.getIntrinsicHeight();
|
||||
int i = this.n;
|
||||
if (intrinsicWidth > i) {
|
||||
intrinsicHeight = (int) (intrinsicHeight * (i / intrinsicWidth));
|
||||
intrinsicWidth = i;
|
||||
}
|
||||
int i2 = this.n;
|
||||
if (intrinsicHeight > i2) {
|
||||
intrinsicWidth = (int) (intrinsicWidth * (i2 / intrinsicHeight));
|
||||
intrinsicHeight = i2;
|
||||
}
|
||||
drawable.setBounds(0, 0, intrinsicWidth, intrinsicHeight);
|
||||
}
|
||||
setCompoundDrawables(drawable, null, null, null);
|
||||
f();
|
||||
}
|
||||
|
||||
public void setItemInvoker(MenuBuilder.ItemInvoker itemInvoker) {
|
||||
this.g = itemInvoker;
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
public void setPadding(int i, int i2, int i3, int i4) {
|
||||
this.m = i;
|
||||
super.setPadding(i, i2, i3, i4);
|
||||
}
|
||||
|
||||
public void setPopupCallback(PopupCallback popupCallback) {
|
||||
this.i = popupCallback;
|
||||
}
|
||||
|
||||
public void setTitle(CharSequence charSequence) {
|
||||
this.e = charSequence;
|
||||
f();
|
||||
}
|
||||
|
||||
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.j = e();
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.ActionMenuItemView, i, 0);
|
||||
this.l = obtainStyledAttributes.getDimensionPixelSize(R$styleable.ActionMenuItemView_android_minWidth, 0);
|
||||
obtainStyledAttributes.recycle();
|
||||
this.n = (int) ((resources.getDisplayMetrics().density * 32.0f) + 0.5f);
|
||||
setOnClickListener(this);
|
||||
this.m = -1;
|
||||
setSaveEnabled(false);
|
||||
}
|
||||
}
|
155
sources/androidx/appcompat/view/menu/BaseMenuPresenter.java
Normal file
155
sources/androidx/appcompat/view/menu/BaseMenuPresenter.java
Normal file
@@ -0,0 +1,155 @@
|
||||
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 {
|
||||
protected Context a;
|
||||
protected Context b;
|
||||
protected MenuBuilder c;
|
||||
protected LayoutInflater d;
|
||||
private MenuPresenter.Callback e;
|
||||
private int f;
|
||||
private int g;
|
||||
protected MenuView h;
|
||||
|
||||
public BaseMenuPresenter(Context context, int i, int i2) {
|
||||
this.a = context;
|
||||
this.d = LayoutInflater.from(context);
|
||||
this.f = i;
|
||||
this.g = i2;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(Context context, MenuBuilder menuBuilder) {
|
||||
this.b = context;
|
||||
LayoutInflater.from(this.b);
|
||||
this.c = menuBuilder;
|
||||
}
|
||||
|
||||
public abstract void a(MenuItemImpl menuItemImpl, MenuView.ItemView itemView);
|
||||
|
||||
public abstract boolean a(int i, MenuItemImpl menuItemImpl);
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean a(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public MenuView b(ViewGroup viewGroup) {
|
||||
if (this.h == null) {
|
||||
this.h = (MenuView) this.d.inflate(this.f, viewGroup, false);
|
||||
this.h.a(this.c);
|
||||
a(true);
|
||||
}
|
||||
return this.h;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean b(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(boolean z) {
|
||||
ViewGroup viewGroup = (ViewGroup) this.h;
|
||||
if (viewGroup == null) {
|
||||
return;
|
||||
}
|
||||
MenuBuilder menuBuilder = this.c;
|
||||
int i = 0;
|
||||
if (menuBuilder != null) {
|
||||
menuBuilder.b();
|
||||
ArrayList<MenuItemImpl> n = this.c.n();
|
||||
int size = n.size();
|
||||
int i2 = 0;
|
||||
for (int i3 = 0; i3 < size; i3++) {
|
||||
MenuItemImpl menuItemImpl = n.get(i3);
|
||||
if (a(i2, menuItemImpl)) {
|
||||
View childAt = viewGroup.getChildAt(i2);
|
||||
MenuItemImpl itemData = childAt instanceof MenuView.ItemView ? ((MenuView.ItemView) childAt).getItemData() : null;
|
||||
View a = a(menuItemImpl, childAt, viewGroup);
|
||||
if (menuItemImpl != itemData) {
|
||||
a.setPressed(false);
|
||||
a.jumpDrawablesToCurrentState();
|
||||
}
|
||||
if (a != childAt) {
|
||||
a(a, i2);
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
i = i2;
|
||||
}
|
||||
while (i < viewGroup.getChildCount()) {
|
||||
if (!a(viewGroup, i)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(View view, int i) {
|
||||
ViewGroup viewGroup = (ViewGroup) view.getParent();
|
||||
if (viewGroup != null) {
|
||||
viewGroup.removeView(view);
|
||||
}
|
||||
((ViewGroup) this.h).addView(view, i);
|
||||
}
|
||||
|
||||
protected boolean a(ViewGroup viewGroup, int i) {
|
||||
viewGroup.removeViewAt(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(MenuPresenter.Callback callback) {
|
||||
this.e = callback;
|
||||
}
|
||||
|
||||
public MenuPresenter.Callback a() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public MenuView.ItemView a(ViewGroup viewGroup) {
|
||||
return (MenuView.ItemView) this.d.inflate(this.g, viewGroup, false);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public View a(MenuItemImpl menuItemImpl, View view, ViewGroup viewGroup) {
|
||||
MenuView.ItemView itemView;
|
||||
if (view instanceof MenuView.ItemView) {
|
||||
itemView = (MenuView.ItemView) view;
|
||||
} else {
|
||||
itemView = a(viewGroup);
|
||||
}
|
||||
a(menuItemImpl, itemView);
|
||||
return (View) itemView;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(MenuBuilder menuBuilder, boolean z) {
|
||||
MenuPresenter.Callback callback = this.e;
|
||||
if (callback != null) {
|
||||
callback.a(menuBuilder, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean a(SubMenuBuilder subMenuBuilder) {
|
||||
MenuPresenter.Callback callback = this.e;
|
||||
if (callback != null) {
|
||||
return callback.a(subMenuBuilder);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
94
sources/androidx/appcompat/view/menu/BaseMenuWrapper.java
Normal file
94
sources/androidx/appcompat/view/menu/BaseMenuWrapper.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import androidx.collection.ArrayMap;
|
||||
import androidx.core.internal.view.SupportMenuItem;
|
||||
import androidx.core.internal.view.SupportSubMenu;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class BaseMenuWrapper<T> extends BaseWrapper<T> {
|
||||
final Context b;
|
||||
private Map<SupportMenuItem, MenuItem> c;
|
||||
private Map<SupportSubMenu, SubMenu> d;
|
||||
|
||||
BaseMenuWrapper(Context context, T t) {
|
||||
super(t);
|
||||
this.b = context;
|
||||
}
|
||||
|
||||
final MenuItem a(MenuItem menuItem) {
|
||||
if (!(menuItem instanceof SupportMenuItem)) {
|
||||
return menuItem;
|
||||
}
|
||||
SupportMenuItem supportMenuItem = (SupportMenuItem) menuItem;
|
||||
if (this.c == null) {
|
||||
this.c = new ArrayMap();
|
||||
}
|
||||
MenuItem menuItem2 = this.c.get(menuItem);
|
||||
if (menuItem2 != null) {
|
||||
return menuItem2;
|
||||
}
|
||||
MenuItem a = MenuWrapperFactory.a(this.b, supportMenuItem);
|
||||
this.c.put(supportMenuItem, a);
|
||||
return a;
|
||||
}
|
||||
|
||||
final void b() {
|
||||
Map<SupportMenuItem, MenuItem> map = this.c;
|
||||
if (map != null) {
|
||||
map.clear();
|
||||
}
|
||||
Map<SupportSubMenu, SubMenu> map2 = this.d;
|
||||
if (map2 != null) {
|
||||
map2.clear();
|
||||
}
|
||||
}
|
||||
|
||||
final void b(int i) {
|
||||
Map<SupportMenuItem, MenuItem> map = this.c;
|
||||
if (map == null) {
|
||||
return;
|
||||
}
|
||||
Iterator<SupportMenuItem> it = map.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (i == it.next().getItemId()) {
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final SubMenu a(SubMenu subMenu) {
|
||||
if (!(subMenu instanceof SupportSubMenu)) {
|
||||
return subMenu;
|
||||
}
|
||||
SupportSubMenu supportSubMenu = (SupportSubMenu) subMenu;
|
||||
if (this.d == null) {
|
||||
this.d = new ArrayMap();
|
||||
}
|
||||
SubMenu subMenu2 = this.d.get(supportSubMenu);
|
||||
if (subMenu2 != null) {
|
||||
return subMenu2;
|
||||
}
|
||||
SubMenu a = MenuWrapperFactory.a(this.b, supportSubMenu);
|
||||
this.d.put(supportSubMenu, a);
|
||||
return a;
|
||||
}
|
||||
|
||||
final void a(int i) {
|
||||
Map<SupportMenuItem, MenuItem> map = this.c;
|
||||
if (map == null) {
|
||||
return;
|
||||
}
|
||||
Iterator<SupportMenuItem> it = map.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (i == it.next().getGroupId()) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
sources/androidx/appcompat/view/menu/BaseWrapper.java
Normal file
13
sources/androidx/appcompat/view/menu/BaseWrapper.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class BaseWrapper<T> {
|
||||
final T a;
|
||||
|
||||
BaseWrapper(T t) {
|
||||
if (t == null) {
|
||||
throw new IllegalArgumentException("Wrapped Object can not be null.");
|
||||
}
|
||||
this.a = t;
|
||||
}
|
||||
}
|
554
sources/androidx/appcompat/view/menu/CascadingMenuPopup.java
Normal file
554
sources/androidx/appcompat/view/menu/CascadingMenuPopup.java
Normal file
@@ -0,0 +1,554 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
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.AdapterView;
|
||||
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$dimen;
|
||||
import androidx.appcompat.R$layout;
|
||||
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.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 {
|
||||
private static final int C = R$layout.abc_cascading_menu_item_layout;
|
||||
private PopupWindow.OnDismissListener A;
|
||||
boolean B;
|
||||
private final Context b;
|
||||
private final int c;
|
||||
private final int d;
|
||||
private final int e;
|
||||
private final boolean f;
|
||||
final Handler g;
|
||||
private View o;
|
||||
View p;
|
||||
private boolean r;
|
||||
private boolean s;
|
||||
private int t;
|
||||
private int u;
|
||||
private boolean x;
|
||||
private MenuPresenter.Callback y;
|
||||
ViewTreeObserver z;
|
||||
private final List<MenuBuilder> h = new ArrayList();
|
||||
final List<CascadingMenuInfo> i = new ArrayList();
|
||||
final ViewTreeObserver.OnGlobalLayoutListener j = new ViewTreeObserver.OnGlobalLayoutListener() { // from class: androidx.appcompat.view.menu.CascadingMenuPopup.1
|
||||
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
|
||||
public void onGlobalLayout() {
|
||||
if (!CascadingMenuPopup.this.c() || CascadingMenuPopup.this.i.size() <= 0 || CascadingMenuPopup.this.i.get(0).a.k()) {
|
||||
return;
|
||||
}
|
||||
View view = CascadingMenuPopup.this.p;
|
||||
if (view == null || !view.isShown()) {
|
||||
CascadingMenuPopup.this.dismiss();
|
||||
return;
|
||||
}
|
||||
Iterator<CascadingMenuInfo> it = CascadingMenuPopup.this.i.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a.a();
|
||||
}
|
||||
}
|
||||
};
|
||||
private final View.OnAttachStateChangeListener k = 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) {
|
||||
ViewTreeObserver viewTreeObserver = CascadingMenuPopup.this.z;
|
||||
if (viewTreeObserver != null) {
|
||||
if (!viewTreeObserver.isAlive()) {
|
||||
CascadingMenuPopup.this.z = view.getViewTreeObserver();
|
||||
}
|
||||
CascadingMenuPopup cascadingMenuPopup = CascadingMenuPopup.this;
|
||||
cascadingMenuPopup.z.removeGlobalOnLayoutListener(cascadingMenuPopup.j);
|
||||
}
|
||||
view.removeOnAttachStateChangeListener(this);
|
||||
}
|
||||
};
|
||||
private final MenuItemHoverListener l = new MenuItemHoverListener() { // from class: androidx.appcompat.view.menu.CascadingMenuPopup.3
|
||||
@Override // androidx.appcompat.widget.MenuItemHoverListener
|
||||
public void a(final MenuBuilder menuBuilder, final MenuItem menuItem) {
|
||||
CascadingMenuPopup.this.g.removeCallbacksAndMessages(null);
|
||||
int size = CascadingMenuPopup.this.i.size();
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= size) {
|
||||
i = -1;
|
||||
break;
|
||||
} else if (menuBuilder == CascadingMenuPopup.this.i.get(i).b) {
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i == -1) {
|
||||
return;
|
||||
}
|
||||
int i2 = i + 1;
|
||||
final CascadingMenuInfo cascadingMenuInfo = i2 < CascadingMenuPopup.this.i.size() ? CascadingMenuPopup.this.i.get(i2) : null;
|
||||
CascadingMenuPopup.this.g.postAtTime(new Runnable() { // from class: androidx.appcompat.view.menu.CascadingMenuPopup.3.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
CascadingMenuInfo cascadingMenuInfo2 = cascadingMenuInfo;
|
||||
if (cascadingMenuInfo2 != null) {
|
||||
CascadingMenuPopup.this.B = true;
|
||||
cascadingMenuInfo2.b.a(false);
|
||||
CascadingMenuPopup.this.B = false;
|
||||
}
|
||||
if (menuItem.isEnabled() && menuItem.hasSubMenu()) {
|
||||
menuBuilder.a(menuItem, 4);
|
||||
}
|
||||
}
|
||||
}, menuBuilder, SystemClock.uptimeMillis() + 200);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.MenuItemHoverListener
|
||||
public void b(MenuBuilder menuBuilder, MenuItem menuItem) {
|
||||
CascadingMenuPopup.this.g.removeCallbacksAndMessages(menuBuilder);
|
||||
}
|
||||
};
|
||||
private int m = 0;
|
||||
private int n = 0;
|
||||
private boolean v = false;
|
||||
private int q = h();
|
||||
|
||||
private static class CascadingMenuInfo {
|
||||
public final MenuPopupWindow a;
|
||||
public final MenuBuilder b;
|
||||
public final int c;
|
||||
|
||||
public CascadingMenuInfo(MenuPopupWindow menuPopupWindow, MenuBuilder menuBuilder, int i) {
|
||||
this.a = menuPopupWindow;
|
||||
this.b = menuBuilder;
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
public ListView a() {
|
||||
return this.a.d();
|
||||
}
|
||||
}
|
||||
|
||||
public CascadingMenuPopup(Context context, View view, int i, int i2, boolean z) {
|
||||
this.b = context;
|
||||
this.o = view;
|
||||
this.d = i;
|
||||
this.e = i2;
|
||||
this.f = z;
|
||||
Resources resources = context.getResources();
|
||||
this.c = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R$dimen.abc_config_prefDialogWidth));
|
||||
this.g = new Handler();
|
||||
}
|
||||
|
||||
private int d(int i) {
|
||||
List<CascadingMenuInfo> list = this.i;
|
||||
ListView a = list.get(list.size() - 1).a();
|
||||
int[] iArr = new int[2];
|
||||
a.getLocationOnScreen(iArr);
|
||||
Rect rect = new Rect();
|
||||
this.p.getWindowVisibleDisplayFrame(rect);
|
||||
return this.q == 1 ? (iArr[0] + a.getWidth()) + i > rect.right ? 0 : 1 : iArr[0] - i < 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
private MenuPopupWindow g() {
|
||||
MenuPopupWindow menuPopupWindow = new MenuPopupWindow(this.b, null, this.d, this.e);
|
||||
menuPopupWindow.a(this.l);
|
||||
menuPopupWindow.a((AdapterView.OnItemClickListener) this);
|
||||
menuPopupWindow.a((PopupWindow.OnDismissListener) this);
|
||||
menuPopupWindow.a(this.o);
|
||||
menuPopupWindow.c(this.n);
|
||||
menuPopupWindow.a(true);
|
||||
menuPopupWindow.e(2);
|
||||
return menuPopupWindow;
|
||||
}
|
||||
|
||||
private int h() {
|
||||
return ViewCompat.k(this.o) == 1 ? 0 : 1;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
||||
public void a() {
|
||||
if (c()) {
|
||||
return;
|
||||
}
|
||||
Iterator<MenuBuilder> it = this.h.iterator();
|
||||
while (it.hasNext()) {
|
||||
d(it.next());
|
||||
}
|
||||
this.h.clear();
|
||||
this.p = this.o;
|
||||
if (this.p != null) {
|
||||
boolean z = this.z == null;
|
||||
this.z = this.p.getViewTreeObserver();
|
||||
if (z) {
|
||||
this.z.addOnGlobalLayoutListener(this.j);
|
||||
}
|
||||
this.p.addOnAttachStateChangeListener(this.k);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void b(boolean z) {
|
||||
this.v = z;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean b() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
||||
public boolean c() {
|
||||
return this.i.size() > 0 && this.i.get(0).a.c();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
||||
public void dismiss() {
|
||||
int size = this.i.size();
|
||||
if (size > 0) {
|
||||
CascadingMenuInfo[] cascadingMenuInfoArr = (CascadingMenuInfo[]) this.i.toArray(new CascadingMenuInfo[size]);
|
||||
for (int i = size - 1; i >= 0; i--) {
|
||||
CascadingMenuInfo cascadingMenuInfo = cascadingMenuInfoArr[i];
|
||||
if (cascadingMenuInfo.a.c()) {
|
||||
cascadingMenuInfo.a.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
protected boolean e() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.widget.PopupWindow.OnDismissListener
|
||||
public void onDismiss() {
|
||||
CascadingMenuInfo cascadingMenuInfo;
|
||||
int size = this.i.size();
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= size) {
|
||||
cascadingMenuInfo = null;
|
||||
break;
|
||||
}
|
||||
cascadingMenuInfo = this.i.get(i);
|
||||
if (!cascadingMenuInfo.a.c()) {
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (cascadingMenuInfo != null) {
|
||||
cascadingMenuInfo.b.a(false);
|
||||
}
|
||||
}
|
||||
|
||||
@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 c(MenuBuilder menuBuilder) {
|
||||
int size = this.i.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (menuBuilder == this.i.get(i).b) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void b(int i) {
|
||||
this.r = true;
|
||||
this.t = i;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void c(int i) {
|
||||
this.s = true;
|
||||
this.u = i;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void c(boolean z) {
|
||||
this.x = z;
|
||||
}
|
||||
|
||||
private void d(MenuBuilder menuBuilder) {
|
||||
CascadingMenuInfo cascadingMenuInfo;
|
||||
View view;
|
||||
int i;
|
||||
int i2;
|
||||
int i3;
|
||||
LayoutInflater from = LayoutInflater.from(this.b);
|
||||
MenuAdapter menuAdapter = new MenuAdapter(menuBuilder, from, this.f, C);
|
||||
if (!c() && this.v) {
|
||||
menuAdapter.a(true);
|
||||
} else if (c()) {
|
||||
menuAdapter.a(MenuPopup.b(menuBuilder));
|
||||
}
|
||||
int a = MenuPopup.a(menuAdapter, null, this.b, this.c);
|
||||
MenuPopupWindow g = g();
|
||||
g.a((ListAdapter) menuAdapter);
|
||||
g.b(a);
|
||||
g.c(this.n);
|
||||
if (this.i.size() > 0) {
|
||||
List<CascadingMenuInfo> list = this.i;
|
||||
cascadingMenuInfo = list.get(list.size() - 1);
|
||||
view = a(cascadingMenuInfo, menuBuilder);
|
||||
} else {
|
||||
cascadingMenuInfo = null;
|
||||
view = null;
|
||||
}
|
||||
if (view != null) {
|
||||
g.c(false);
|
||||
g.a((Object) null);
|
||||
int d = d(a);
|
||||
boolean z = d == 1;
|
||||
this.q = d;
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
g.a(view);
|
||||
i2 = 0;
|
||||
i = 0;
|
||||
} else {
|
||||
int[] iArr = new int[2];
|
||||
this.o.getLocationOnScreen(iArr);
|
||||
int[] iArr2 = new int[2];
|
||||
view.getLocationOnScreen(iArr2);
|
||||
if ((this.n & 7) == 5) {
|
||||
iArr[0] = iArr[0] + this.o.getWidth();
|
||||
iArr2[0] = iArr2[0] + view.getWidth();
|
||||
}
|
||||
i = iArr2[0] - iArr[0];
|
||||
i2 = iArr2[1] - iArr[1];
|
||||
}
|
||||
if ((this.n & 5) == 5) {
|
||||
if (!z) {
|
||||
a = view.getWidth();
|
||||
i3 = i - a;
|
||||
}
|
||||
i3 = i + a;
|
||||
} else {
|
||||
if (z) {
|
||||
a = view.getWidth();
|
||||
i3 = i + a;
|
||||
}
|
||||
i3 = i - a;
|
||||
}
|
||||
g.d(i3);
|
||||
g.b(true);
|
||||
g.h(i2);
|
||||
} else {
|
||||
if (this.r) {
|
||||
g.d(this.t);
|
||||
}
|
||||
if (this.s) {
|
||||
g.h(this.u);
|
||||
}
|
||||
g.a(f());
|
||||
}
|
||||
this.i.add(new CascadingMenuInfo(g, menuBuilder, this.q));
|
||||
g.a();
|
||||
ListView d2 = g.d();
|
||||
d2.setOnKeyListener(this);
|
||||
if (cascadingMenuInfo == null && this.x && menuBuilder.h() != null) {
|
||||
FrameLayout frameLayout = (FrameLayout) from.inflate(R$layout.abc_popup_menu_header_item_layout, (ViewGroup) d2, false);
|
||||
TextView textView = (TextView) frameLayout.findViewById(R.id.title);
|
||||
frameLayout.setEnabled(false);
|
||||
textView.setText(menuBuilder.h());
|
||||
d2.addHeaderView(frameLayout, null, false);
|
||||
g.a();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void a(MenuBuilder menuBuilder) {
|
||||
menuBuilder.a(this, this.b);
|
||||
if (c()) {
|
||||
d(menuBuilder);
|
||||
} else {
|
||||
this.h.add(menuBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItem a(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 a(CascadingMenuInfo cascadingMenuInfo, MenuBuilder menuBuilder) {
|
||||
MenuAdapter menuAdapter;
|
||||
int i;
|
||||
int firstVisiblePosition;
|
||||
MenuItem a = a(cascadingMenuInfo.b, menuBuilder);
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
ListView a2 = cascadingMenuInfo.a();
|
||||
ListAdapter adapter = a2.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 (a == menuAdapter.getItem(i2)) {
|
||||
break;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
if (i2 != -1 && (firstVisiblePosition = (i2 + i) - a2.getFirstVisiblePosition()) >= 0 && firstVisiblePosition < a2.getChildCount()) {
|
||||
return a2.getChildAt(firstVisiblePosition);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(boolean z) {
|
||||
Iterator<CascadingMenuInfo> it = this.i.iterator();
|
||||
while (it.hasNext()) {
|
||||
MenuPopup.a(it.next().a().getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(MenuPresenter.Callback callback) {
|
||||
this.y = callback;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean a(SubMenuBuilder subMenuBuilder) {
|
||||
for (CascadingMenuInfo cascadingMenuInfo : this.i) {
|
||||
if (subMenuBuilder == cascadingMenuInfo.b) {
|
||||
cascadingMenuInfo.a().requestFocus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!subMenuBuilder.hasVisibleItems()) {
|
||||
return false;
|
||||
}
|
||||
a((MenuBuilder) subMenuBuilder);
|
||||
MenuPresenter.Callback callback = this.y;
|
||||
if (callback != null) {
|
||||
callback.a(subMenuBuilder);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(MenuBuilder menuBuilder, boolean z) {
|
||||
int c = c(menuBuilder);
|
||||
if (c < 0) {
|
||||
return;
|
||||
}
|
||||
int i = c + 1;
|
||||
if (i < this.i.size()) {
|
||||
this.i.get(i).b.a(false);
|
||||
}
|
||||
CascadingMenuInfo remove = this.i.remove(c);
|
||||
remove.b.b(this);
|
||||
if (this.B) {
|
||||
remove.a.b((Object) null);
|
||||
remove.a.a(0);
|
||||
}
|
||||
remove.a.dismiss();
|
||||
int size = this.i.size();
|
||||
if (size > 0) {
|
||||
this.q = this.i.get(size - 1).c;
|
||||
} else {
|
||||
this.q = h();
|
||||
}
|
||||
if (size != 0) {
|
||||
if (z) {
|
||||
this.i.get(0).b.a(false);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
dismiss();
|
||||
MenuPresenter.Callback callback = this.y;
|
||||
if (callback != null) {
|
||||
callback.a(menuBuilder, true);
|
||||
}
|
||||
ViewTreeObserver viewTreeObserver = this.z;
|
||||
if (viewTreeObserver != null) {
|
||||
if (viewTreeObserver.isAlive()) {
|
||||
this.z.removeGlobalOnLayoutListener(this.j);
|
||||
}
|
||||
this.z = null;
|
||||
}
|
||||
this.p.removeOnAttachStateChangeListener(this.k);
|
||||
this.A.onDismiss();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
||||
public ListView d() {
|
||||
if (this.i.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return this.i.get(r0.size() - 1).a();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void a(int i) {
|
||||
if (this.m != i) {
|
||||
this.m = i;
|
||||
this.n = GravityCompat.a(i, ViewCompat.k(this.o));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void a(View view) {
|
||||
if (this.o != view) {
|
||||
this.o = view;
|
||||
this.n = GravityCompat.a(this.m, ViewCompat.k(this.o));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void a(PopupWindow.OnDismissListener onDismissListener) {
|
||||
this.A = onDismissListener;
|
||||
}
|
||||
}
|
59
sources/androidx/appcompat/view/menu/ExpandedMenuView.java
Normal file
59
sources/androidx/appcompat/view/menu/ExpandedMenuView.java
Normal file
@@ -0,0 +1,59 @@
|
||||
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[] c = {R.attr.background, R.attr.divider};
|
||||
private MenuBuilder a;
|
||||
private int b;
|
||||
|
||||
public ExpandedMenuView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.listViewStyle);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuView
|
||||
public void a(MenuBuilder menuBuilder) {
|
||||
this.a = menuBuilder;
|
||||
}
|
||||
|
||||
public int getWindowAnimations() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override // android.widget.ListView, android.widget.AbsListView, android.widget.AdapterView, android.view.ViewGroup, android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
setChildrenDrawingCacheEnabled(false);
|
||||
}
|
||||
|
||||
@Override // android.widget.AdapterView.OnItemClickListener
|
||||
public void onItemClick(AdapterView adapterView, View view, int i, long j) {
|
||||
a((MenuItemImpl) getAdapter().getItem(i));
|
||||
}
|
||||
|
||||
public ExpandedMenuView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet);
|
||||
setOnItemClickListener(this);
|
||||
TintTypedArray a = TintTypedArray.a(context, attributeSet, c, i, 0);
|
||||
if (a.g(0)) {
|
||||
setBackgroundDrawable(a.b(0));
|
||||
}
|
||||
if (a.g(1)) {
|
||||
setDivider(a.b(1));
|
||||
}
|
||||
a.a();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder.ItemInvoker
|
||||
public boolean a(MenuItemImpl menuItemImpl) {
|
||||
return this.a.a(menuItemImpl, 0);
|
||||
}
|
||||
}
|
285
sources/androidx/appcompat/view/menu/ListMenuItemView.java
Normal file
285
sources/androidx/appcompat/view/menu/ListMenuItemView.java
Normal file
@@ -0,0 +1,285 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.R;
|
||||
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$attr;
|
||||
import androidx.appcompat.R$id;
|
||||
import androidx.appcompat.R$layout;
|
||||
import androidx.appcompat.R$styleable;
|
||||
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 MenuItemImpl a;
|
||||
private ImageView b;
|
||||
private RadioButton c;
|
||||
private TextView d;
|
||||
private CheckBox e;
|
||||
private TextView f;
|
||||
private ImageView g;
|
||||
private ImageView h;
|
||||
private LinearLayout i;
|
||||
private Drawable j;
|
||||
private int k;
|
||||
private Context l;
|
||||
private boolean m;
|
||||
private Drawable n;
|
||||
private boolean o;
|
||||
private LayoutInflater p;
|
||||
private boolean q;
|
||||
|
||||
public ListMenuItemView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R$attr.listMenuViewStyle);
|
||||
}
|
||||
|
||||
private void b() {
|
||||
this.e = (CheckBox) getInflater().inflate(R$layout.abc_list_menu_item_checkbox, (ViewGroup) this, false);
|
||||
a(this.e);
|
||||
}
|
||||
|
||||
private void c() {
|
||||
this.b = (ImageView) getInflater().inflate(R$layout.abc_list_menu_item_icon, (ViewGroup) this, false);
|
||||
a(this.b, 0);
|
||||
}
|
||||
|
||||
private void d() {
|
||||
this.c = (RadioButton) getInflater().inflate(R$layout.abc_list_menu_item_radio, (ViewGroup) this, false);
|
||||
a(this.c);
|
||||
}
|
||||
|
||||
private LayoutInflater getInflater() {
|
||||
if (this.p == null) {
|
||||
this.p = LayoutInflater.from(getContext());
|
||||
}
|
||||
return this.p;
|
||||
}
|
||||
|
||||
private void setSubMenuArrowVisible(boolean z) {
|
||||
ImageView imageView = this.g;
|
||||
if (imageView != null) {
|
||||
imageView.setVisibility(z ? 0 : 8);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuView.ItemView
|
||||
public void a(MenuItemImpl menuItemImpl, int i) {
|
||||
this.a = menuItemImpl;
|
||||
setVisibility(menuItemImpl.isVisible() ? 0 : 8);
|
||||
setTitle(menuItemImpl.a(this));
|
||||
setCheckable(menuItemImpl.isCheckable());
|
||||
a(menuItemImpl.m(), menuItemImpl.d());
|
||||
setIcon(menuItemImpl.getIcon());
|
||||
setEnabled(menuItemImpl.isEnabled());
|
||||
setSubMenuArrowVisible(menuItemImpl.hasSubMenu());
|
||||
setContentDescription(menuItemImpl.getContentDescription());
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuView.ItemView
|
||||
public boolean a() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.widget.AbsListView.SelectionBoundsAdjuster
|
||||
public void adjustListItemSelectionBounds(Rect rect) {
|
||||
ImageView imageView = this.h;
|
||||
if (imageView == null || imageView.getVisibility() != 0) {
|
||||
return;
|
||||
}
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.h.getLayoutParams();
|
||||
rect.top += this.h.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuView.ItemView
|
||||
public MenuItemImpl getItemData() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
ViewCompat.a(this, this.j);
|
||||
this.d = (TextView) findViewById(R$id.title);
|
||||
int i = this.k;
|
||||
if (i != -1) {
|
||||
this.d.setTextAppearance(this.l, i);
|
||||
}
|
||||
this.f = (TextView) findViewById(R$id.shortcut);
|
||||
this.g = (ImageView) findViewById(R$id.submenuarrow);
|
||||
ImageView imageView = this.g;
|
||||
if (imageView != null) {
|
||||
imageView.setImageDrawable(this.n);
|
||||
}
|
||||
this.h = (ImageView) findViewById(R$id.group_divider);
|
||||
this.i = (LinearLayout) findViewById(R$id.content);
|
||||
}
|
||||
|
||||
@Override // android.widget.LinearLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
if (this.b != null && this.m) {
|
||||
ViewGroup.LayoutParams layoutParams = getLayoutParams();
|
||||
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.b.getLayoutParams();
|
||||
if (layoutParams.height > 0 && layoutParams2.width <= 0) {
|
||||
layoutParams2.width = layoutParams.height;
|
||||
}
|
||||
}
|
||||
super.onMeasure(i, i2);
|
||||
}
|
||||
|
||||
public void setCheckable(boolean z) {
|
||||
CompoundButton compoundButton;
|
||||
CompoundButton compoundButton2;
|
||||
if (!z && this.c == null && this.e == null) {
|
||||
return;
|
||||
}
|
||||
if (this.a.i()) {
|
||||
if (this.c == null) {
|
||||
d();
|
||||
}
|
||||
compoundButton = this.c;
|
||||
compoundButton2 = this.e;
|
||||
} else {
|
||||
if (this.e == null) {
|
||||
b();
|
||||
}
|
||||
compoundButton = this.e;
|
||||
compoundButton2 = this.c;
|
||||
}
|
||||
if (z) {
|
||||
compoundButton.setChecked(this.a.isChecked());
|
||||
if (compoundButton.getVisibility() != 0) {
|
||||
compoundButton.setVisibility(0);
|
||||
}
|
||||
if (compoundButton2 == null || compoundButton2.getVisibility() == 8) {
|
||||
return;
|
||||
}
|
||||
compoundButton2.setVisibility(8);
|
||||
return;
|
||||
}
|
||||
CheckBox checkBox = this.e;
|
||||
if (checkBox != null) {
|
||||
checkBox.setVisibility(8);
|
||||
}
|
||||
RadioButton radioButton = this.c;
|
||||
if (radioButton != null) {
|
||||
radioButton.setVisibility(8);
|
||||
}
|
||||
}
|
||||
|
||||
public void setChecked(boolean z) {
|
||||
CompoundButton compoundButton;
|
||||
if (this.a.i()) {
|
||||
if (this.c == null) {
|
||||
d();
|
||||
}
|
||||
compoundButton = this.c;
|
||||
} else {
|
||||
if (this.e == null) {
|
||||
b();
|
||||
}
|
||||
compoundButton = this.e;
|
||||
}
|
||||
compoundButton.setChecked(z);
|
||||
}
|
||||
|
||||
public void setForceShowIcon(boolean z) {
|
||||
this.q = z;
|
||||
this.m = z;
|
||||
}
|
||||
|
||||
public void setGroupDividerEnabled(boolean z) {
|
||||
ImageView imageView = this.h;
|
||||
if (imageView != null) {
|
||||
imageView.setVisibility((this.o || !z) ? 8 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIcon(Drawable drawable) {
|
||||
boolean z = this.a.l() || this.q;
|
||||
if (z || this.m) {
|
||||
if (this.b == null && drawable == null && !this.m) {
|
||||
return;
|
||||
}
|
||||
if (this.b == null) {
|
||||
c();
|
||||
}
|
||||
if (drawable == null && !this.m) {
|
||||
this.b.setVisibility(8);
|
||||
return;
|
||||
}
|
||||
ImageView imageView = this.b;
|
||||
if (!z) {
|
||||
drawable = null;
|
||||
}
|
||||
imageView.setImageDrawable(drawable);
|
||||
if (this.b.getVisibility() != 0) {
|
||||
this.b.setVisibility(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitle(CharSequence charSequence) {
|
||||
if (charSequence == null) {
|
||||
if (this.d.getVisibility() != 8) {
|
||||
this.d.setVisibility(8);
|
||||
}
|
||||
} else {
|
||||
this.d.setText(charSequence);
|
||||
if (this.d.getVisibility() != 0) {
|
||||
this.d.setVisibility(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ListMenuItemView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet);
|
||||
TintTypedArray a = TintTypedArray.a(getContext(), attributeSet, R$styleable.MenuView, i, 0);
|
||||
this.j = a.b(R$styleable.MenuView_android_itemBackground);
|
||||
this.k = a.g(R$styleable.MenuView_android_itemTextAppearance, -1);
|
||||
this.m = a.a(R$styleable.MenuView_preserveIconSpacing, false);
|
||||
this.l = context;
|
||||
this.n = a.b(R$styleable.MenuView_subMenuArrow);
|
||||
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(null, new int[]{R.attr.divider}, R$attr.dropDownListViewStyle, 0);
|
||||
this.o = obtainStyledAttributes.hasValue(0);
|
||||
a.a();
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
private void a(View view) {
|
||||
a(view, -1);
|
||||
}
|
||||
|
||||
private void a(View view, int i) {
|
||||
LinearLayout linearLayout = this.i;
|
||||
if (linearLayout != null) {
|
||||
linearLayout.addView(view, i);
|
||||
} else {
|
||||
addView(view, i);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(boolean z, char c) {
|
||||
int i = (z && this.a.m()) ? 0 : 8;
|
||||
if (i == 0) {
|
||||
this.f.setText(this.a.e());
|
||||
}
|
||||
if (this.f.getVisibility() != i) {
|
||||
this.f.setVisibility(i);
|
||||
}
|
||||
}
|
||||
}
|
193
sources/androidx/appcompat/view/menu/ListMenuPresenter.java
Normal file
193
sources/androidx/appcompat/view/menu/ListMenuPresenter.java
Normal file
@@ -0,0 +1,193 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.IBinder;
|
||||
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$layout;
|
||||
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 {
|
||||
Context a;
|
||||
LayoutInflater b;
|
||||
MenuBuilder c;
|
||||
ExpandedMenuView d;
|
||||
int e;
|
||||
int f;
|
||||
int g;
|
||||
private MenuPresenter.Callback h;
|
||||
MenuAdapter i;
|
||||
|
||||
private class MenuAdapter extends BaseAdapter {
|
||||
private int a = -1;
|
||||
|
||||
public MenuAdapter() {
|
||||
a();
|
||||
}
|
||||
|
||||
void a() {
|
||||
MenuItemImpl f = ListMenuPresenter.this.c.f();
|
||||
if (f != null) {
|
||||
ArrayList<MenuItemImpl> j = ListMenuPresenter.this.c.j();
|
||||
int size = j.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (j.get(i) == f) {
|
||||
this.a = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.a = -1;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public int getCount() {
|
||||
int size = ListMenuPresenter.this.c.j().size() - ListMenuPresenter.this.e;
|
||||
return this.a < 0 ? size : size - 1;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
if (view == null) {
|
||||
ListMenuPresenter listMenuPresenter = ListMenuPresenter.this;
|
||||
view = listMenuPresenter.b.inflate(listMenuPresenter.g, viewGroup, false);
|
||||
}
|
||||
((MenuView.ItemView) view).a(getItem(i), 0);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override // android.widget.BaseAdapter
|
||||
public void notifyDataSetChanged() {
|
||||
a();
|
||||
super.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public MenuItemImpl getItem(int i) {
|
||||
ArrayList<MenuItemImpl> j = ListMenuPresenter.this.c.j();
|
||||
int i2 = i + ListMenuPresenter.this.e;
|
||||
int i3 = this.a;
|
||||
if (i3 >= 0 && i2 >= i3) {
|
||||
i2++;
|
||||
}
|
||||
return j.get(i2);
|
||||
}
|
||||
}
|
||||
|
||||
public ListMenuPresenter(Context context, int i) {
|
||||
this(i, 0);
|
||||
this.a = context;
|
||||
this.b = LayoutInflater.from(this.a);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(Context context, MenuBuilder menuBuilder) {
|
||||
int i = this.f;
|
||||
if (i != 0) {
|
||||
this.a = new ContextThemeWrapper(context, i);
|
||||
this.b = LayoutInflater.from(this.a);
|
||||
} else if (this.a != null) {
|
||||
this.a = context;
|
||||
if (this.b == null) {
|
||||
this.b = LayoutInflater.from(this.a);
|
||||
}
|
||||
}
|
||||
this.c = menuBuilder;
|
||||
MenuAdapter menuAdapter = this.i;
|
||||
if (menuAdapter != null) {
|
||||
menuAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean a(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean b() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean b(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.widget.AdapterView.OnItemClickListener
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
|
||||
this.c.a(this.i.getItem(i), this, 0);
|
||||
}
|
||||
|
||||
public ListMenuPresenter(int i, int i2) {
|
||||
this.g = i;
|
||||
this.f = i2;
|
||||
}
|
||||
|
||||
public MenuView a(ViewGroup viewGroup) {
|
||||
if (this.d == null) {
|
||||
this.d = (ExpandedMenuView) this.b.inflate(R$layout.abc_expanded_menu_layout, viewGroup, false);
|
||||
if (this.i == null) {
|
||||
this.i = new MenuAdapter();
|
||||
}
|
||||
this.d.setAdapter((ListAdapter) this.i);
|
||||
this.d.setOnItemClickListener(this);
|
||||
}
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public ListAdapter a() {
|
||||
if (this.i == null) {
|
||||
this.i = new MenuAdapter();
|
||||
}
|
||||
return this.i;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(boolean z) {
|
||||
MenuAdapter menuAdapter = this.i;
|
||||
if (menuAdapter != null) {
|
||||
menuAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(MenuPresenter.Callback callback) {
|
||||
this.h = callback;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean a(SubMenuBuilder subMenuBuilder) {
|
||||
if (!subMenuBuilder.hasVisibleItems()) {
|
||||
return false;
|
||||
}
|
||||
new MenuDialogHelper(subMenuBuilder).a((IBinder) null);
|
||||
MenuPresenter.Callback callback = this.h;
|
||||
if (callback == null) {
|
||||
return true;
|
||||
}
|
||||
callback.a(subMenuBuilder);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(MenuBuilder menuBuilder, boolean z) {
|
||||
MenuPresenter.Callback callback = this.h;
|
||||
if (callback != null) {
|
||||
callback.a(menuBuilder, z);
|
||||
}
|
||||
}
|
||||
}
|
92
sources/androidx/appcompat/view/menu/MenuAdapter.java
Normal file
92
sources/androidx/appcompat/view/menu/MenuAdapter.java
Normal file
@@ -0,0 +1,92 @@
|
||||
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 a;
|
||||
private int b = -1;
|
||||
private boolean c;
|
||||
private final boolean d;
|
||||
private final LayoutInflater e;
|
||||
private final int f;
|
||||
|
||||
public MenuAdapter(MenuBuilder menuBuilder, LayoutInflater layoutInflater, boolean z, int i) {
|
||||
this.d = z;
|
||||
this.e = layoutInflater;
|
||||
this.a = menuBuilder;
|
||||
this.f = i;
|
||||
a();
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.c = z;
|
||||
}
|
||||
|
||||
public MenuBuilder b() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public int getCount() {
|
||||
return this.b < 0 ? (this.d ? this.a.j() : this.a.n()).size() : r0.size() - 1;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
if (view == null) {
|
||||
view = this.e.inflate(this.f, viewGroup, false);
|
||||
}
|
||||
int groupId = getItem(i).getGroupId();
|
||||
int i2 = i - 1;
|
||||
ListMenuItemView listMenuItemView = (ListMenuItemView) view;
|
||||
listMenuItemView.setGroupDividerEnabled(this.a.o() && groupId != (i2 >= 0 ? getItem(i2).getGroupId() : groupId));
|
||||
MenuView.ItemView itemView = (MenuView.ItemView) view;
|
||||
if (this.c) {
|
||||
listMenuItemView.setForceShowIcon(true);
|
||||
}
|
||||
itemView.a(getItem(i), 0);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override // android.widget.BaseAdapter
|
||||
public void notifyDataSetChanged() {
|
||||
a();
|
||||
super.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
void a() {
|
||||
MenuItemImpl f = this.a.f();
|
||||
if (f != null) {
|
||||
ArrayList<MenuItemImpl> j = this.a.j();
|
||||
int size = j.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (j.get(i) == f) {
|
||||
this.b = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.b = -1;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public MenuItemImpl getItem(int i) {
|
||||
ArrayList<MenuItemImpl> j = this.d ? this.a.j() : this.a.n();
|
||||
int i2 = this.b;
|
||||
if (i2 >= 0 && i >= i2) {
|
||||
i++;
|
||||
}
|
||||
return j.get(i);
|
||||
}
|
||||
}
|
874
sources/androidx/appcompat/view/menu/MenuBuilder.java
Normal file
874
sources/androidx/appcompat/view/menu/MenuBuilder.java
Normal file
@@ -0,0 +1,874 @@
|
||||
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 android.view.ViewConfiguration;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.internal.view.SupportMenu;
|
||||
import androidx.core.view.ActionProvider;
|
||||
import androidx.core.view.ViewConfigurationCompat;
|
||||
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 int[] A = {1, 4, 5, 3, 2, 0};
|
||||
private final Context a;
|
||||
private final Resources b;
|
||||
private boolean c;
|
||||
private boolean d;
|
||||
private Callback e;
|
||||
private ContextMenu.ContextMenuInfo m;
|
||||
CharSequence n;
|
||||
Drawable o;
|
||||
View p;
|
||||
private MenuItemImpl x;
|
||||
private boolean z;
|
||||
private int l = 0;
|
||||
private boolean q = false;
|
||||
private boolean r = false;
|
||||
private boolean s = false;
|
||||
private boolean t = false;
|
||||
private boolean u = false;
|
||||
private ArrayList<MenuItemImpl> v = new ArrayList<>();
|
||||
private CopyOnWriteArrayList<WeakReference<MenuPresenter>> w = new CopyOnWriteArrayList<>();
|
||||
private boolean y = false;
|
||||
private ArrayList<MenuItemImpl> f = new ArrayList<>();
|
||||
private ArrayList<MenuItemImpl> g = new ArrayList<>();
|
||||
private boolean h = true;
|
||||
private ArrayList<MenuItemImpl> i = new ArrayList<>();
|
||||
private ArrayList<MenuItemImpl> j = new ArrayList<>();
|
||||
private boolean k = true;
|
||||
|
||||
public interface Callback {
|
||||
void a(MenuBuilder menuBuilder);
|
||||
|
||||
boolean a(MenuBuilder menuBuilder, MenuItem menuItem);
|
||||
}
|
||||
|
||||
public interface ItemInvoker {
|
||||
boolean a(MenuItemImpl menuItemImpl);
|
||||
}
|
||||
|
||||
public MenuBuilder(Context context) {
|
||||
this.a = context;
|
||||
this.b = context.getResources();
|
||||
e(true);
|
||||
}
|
||||
|
||||
private void d(boolean z) {
|
||||
if (this.w.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
s();
|
||||
Iterator<WeakReference<MenuPresenter>> it = this.w.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<MenuPresenter> next = it.next();
|
||||
MenuPresenter menuPresenter = next.get();
|
||||
if (menuPresenter == null) {
|
||||
this.w.remove(next);
|
||||
} else {
|
||||
menuPresenter.a(z);
|
||||
}
|
||||
}
|
||||
r();
|
||||
}
|
||||
|
||||
private void e(boolean z) {
|
||||
this.d = z && this.b.getConfiguration().keyboard != 1 && ViewConfigurationCompat.d(ViewConfiguration.get(this.a), this.a);
|
||||
}
|
||||
|
||||
private static int f(int i) {
|
||||
int i2 = ((-65536) & i) >> 16;
|
||||
if (i2 >= 0) {
|
||||
int[] iArr = A;
|
||||
if (i2 < iArr.length) {
|
||||
return (i & 65535) | (iArr[i2] << 16);
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("order does not contain a valid category.");
|
||||
}
|
||||
|
||||
public void a(MenuPresenter menuPresenter) {
|
||||
a(menuPresenter, this.a);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem add(CharSequence charSequence) {
|
||||
return a(0, 0, 0, charSequence);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public int addIntentOptions(int i, int i2, int i3, ComponentName componentName, Intent[] intentArr, Intent intent, int i4, MenuItem[] menuItemArr) {
|
||||
int i5;
|
||||
PackageManager packageManager = this.a.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 i6 = 0; i6 < size; i6++) {
|
||||
ResolveInfo resolveInfo = queryIntentActivityOptions.get(i6);
|
||||
int i7 = resolveInfo.specificIndex;
|
||||
Intent intent2 = new Intent(i7 < 0 ? intent : intentArr[i7]);
|
||||
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 && (i5 = resolveInfo.specificIndex) >= 0) {
|
||||
menuItemArr[i5] = intent3;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public SubMenu addSubMenu(CharSequence charSequence) {
|
||||
return addSubMenu(0, 0, 0, charSequence);
|
||||
}
|
||||
|
||||
public void b(MenuPresenter menuPresenter) {
|
||||
Iterator<WeakReference<MenuPresenter>> it = this.w.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<MenuPresenter> next = it.next();
|
||||
MenuPresenter menuPresenter2 = next.get();
|
||||
if (menuPresenter2 == null || menuPresenter2 == menuPresenter) {
|
||||
this.w.remove(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MenuBuilder c(int i) {
|
||||
this.l = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void clear() {
|
||||
MenuItemImpl menuItemImpl = this.x;
|
||||
if (menuItemImpl != null) {
|
||||
a(menuItemImpl);
|
||||
}
|
||||
this.f.clear();
|
||||
b(true);
|
||||
}
|
||||
|
||||
public void clearHeader() {
|
||||
this.o = null;
|
||||
this.n = null;
|
||||
this.p = null;
|
||||
b(false);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void close() {
|
||||
a(true);
|
||||
}
|
||||
|
||||
protected String d() {
|
||||
return "android:menu:actionviewstates";
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem findItem(int i) {
|
||||
MenuItem findItem;
|
||||
int size = size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
MenuItemImpl menuItemImpl = this.f.get(i2);
|
||||
if (menuItemImpl.getItemId() == i) {
|
||||
return menuItemImpl;
|
||||
}
|
||||
if (menuItemImpl.hasSubMenu() && (findItem = menuItemImpl.getSubMenu().findItem(i)) != null) {
|
||||
return findItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Drawable g() {
|
||||
return this.o;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem getItem(int i) {
|
||||
return this.f.get(i);
|
||||
}
|
||||
|
||||
public CharSequence h() {
|
||||
return this.n;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public boolean hasVisibleItems() {
|
||||
if (this.z) {
|
||||
return true;
|
||||
}
|
||||
int size = size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (this.f.get(i).isVisible()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public View i() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public boolean isShortcutKey(int i, KeyEvent keyEvent) {
|
||||
return a(i, keyEvent) != null;
|
||||
}
|
||||
|
||||
public ArrayList<MenuItemImpl> j() {
|
||||
b();
|
||||
return this.j;
|
||||
}
|
||||
|
||||
boolean k() {
|
||||
return this.t;
|
||||
}
|
||||
|
||||
Resources l() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public MenuBuilder m() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ArrayList<MenuItemImpl> n() {
|
||||
if (!this.h) {
|
||||
return this.g;
|
||||
}
|
||||
this.g.clear();
|
||||
int size = this.f.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
MenuItemImpl menuItemImpl = this.f.get(i);
|
||||
if (menuItemImpl.isVisible()) {
|
||||
this.g.add(menuItemImpl);
|
||||
}
|
||||
}
|
||||
this.h = false;
|
||||
this.k = true;
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public boolean o() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
boolean p() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public boolean performIdentifierAction(int i, int i2) {
|
||||
return a(findItem(i), i2);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public boolean performShortcut(int i, KeyEvent keyEvent, int i2) {
|
||||
MenuItemImpl a = a(i, keyEvent);
|
||||
boolean a2 = a != null ? a(a, i2) : false;
|
||||
if ((i2 & 2) != 0) {
|
||||
a(true);
|
||||
}
|
||||
return a2;
|
||||
}
|
||||
|
||||
public boolean q() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public void r() {
|
||||
this.q = false;
|
||||
if (this.r) {
|
||||
this.r = false;
|
||||
b(this.s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void removeGroup(int i) {
|
||||
int a = a(i);
|
||||
if (a >= 0) {
|
||||
int size = this.f.size() - a;
|
||||
int i2 = 0;
|
||||
while (true) {
|
||||
int i3 = i2 + 1;
|
||||
if (i2 >= size || this.f.get(a).getGroupId() != i) {
|
||||
break;
|
||||
}
|
||||
a(a, false);
|
||||
i2 = i3;
|
||||
}
|
||||
b(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void removeItem(int i) {
|
||||
a(b(i), true);
|
||||
}
|
||||
|
||||
public void s() {
|
||||
if (this.q) {
|
||||
return;
|
||||
}
|
||||
this.q = true;
|
||||
this.r = false;
|
||||
this.s = false;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setGroupCheckable(int i, boolean z, boolean z2) {
|
||||
int size = this.f.size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
MenuItemImpl menuItemImpl = this.f.get(i2);
|
||||
if (menuItemImpl.getGroupId() == i) {
|
||||
menuItemImpl.c(z2);
|
||||
menuItemImpl.setCheckable(z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setGroupDividerEnabled(boolean z) {
|
||||
this.y = z;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setGroupEnabled(int i, boolean z) {
|
||||
int size = this.f.size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
MenuItemImpl menuItemImpl = this.f.get(i2);
|
||||
if (menuItemImpl.getGroupId() == i) {
|
||||
menuItemImpl.setEnabled(z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setGroupVisible(int i, boolean z) {
|
||||
int size = this.f.size();
|
||||
boolean z2 = false;
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
MenuItemImpl menuItemImpl = this.f.get(i2);
|
||||
if (menuItemImpl.getGroupId() == i && menuItemImpl.e(z)) {
|
||||
z2 = true;
|
||||
}
|
||||
}
|
||||
if (z2) {
|
||||
b(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setQwertyMode(boolean z) {
|
||||
this.c = z;
|
||||
b(false);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public int size() {
|
||||
return this.f.size();
|
||||
}
|
||||
|
||||
public void a(MenuPresenter menuPresenter, Context context) {
|
||||
this.w.add(new WeakReference<>(menuPresenter));
|
||||
menuPresenter.a(context, this);
|
||||
this.k = true;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem add(int i) {
|
||||
return a(0, 0, 0, this.b.getString(i));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public SubMenu addSubMenu(int i) {
|
||||
return addSubMenu(0, 0, 0, this.b.getString(i));
|
||||
}
|
||||
|
||||
void c(MenuItemImpl menuItemImpl) {
|
||||
this.k = true;
|
||||
b(true);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem add(int i, int i2, int i3, CharSequence charSequence) {
|
||||
return a(i, i2, i3, charSequence);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public SubMenu addSubMenu(int i, int i2, int i3, CharSequence charSequence) {
|
||||
MenuItemImpl menuItemImpl = (MenuItemImpl) a(i, i2, i3, charSequence);
|
||||
SubMenuBuilder subMenuBuilder = new SubMenuBuilder(this.a, this, menuItemImpl);
|
||||
menuItemImpl.a(subMenuBuilder);
|
||||
return subMenuBuilder;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem add(int i, int i2, int i3, int i4) {
|
||||
return a(i, i2, i3, this.b.getString(i4));
|
||||
}
|
||||
|
||||
public void b(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("android:menu:expandedactionview", item.getItemId());
|
||||
}
|
||||
}
|
||||
if (item.hasSubMenu()) {
|
||||
((SubMenuBuilder) item.getSubMenu()).b(bundle);
|
||||
}
|
||||
}
|
||||
if (sparseArray != null) {
|
||||
bundle.putSparseParcelableArray(d(), sparseArray);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<MenuItemImpl> c() {
|
||||
b();
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public MenuItemImpl f() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
private boolean a(SubMenuBuilder subMenuBuilder, MenuPresenter menuPresenter) {
|
||||
if (this.w.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
boolean a = menuPresenter != null ? menuPresenter.a(subMenuBuilder) : false;
|
||||
Iterator<WeakReference<MenuPresenter>> it = this.w.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<MenuPresenter> next = it.next();
|
||||
MenuPresenter menuPresenter2 = next.get();
|
||||
if (menuPresenter2 == null) {
|
||||
this.w.remove(next);
|
||||
} else if (!a) {
|
||||
a = menuPresenter2.a(subMenuBuilder);
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public Context e() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public SubMenu addSubMenu(int i, int i2, int i3, int i4) {
|
||||
return addSubMenu(i, i2, i3, this.b.getString(i4));
|
||||
}
|
||||
|
||||
public void c(boolean z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
protected MenuBuilder e(int i) {
|
||||
a(i, null, 0, null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
void d(MenuItemImpl menuItemImpl) {
|
||||
this.h = true;
|
||||
b(true);
|
||||
}
|
||||
|
||||
protected MenuBuilder d(int i) {
|
||||
a(0, null, i, null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void a(Bundle bundle) {
|
||||
MenuItem findItem;
|
||||
if (bundle == null) {
|
||||
return;
|
||||
}
|
||||
SparseArray<Parcelable> sparseParcelableArray = bundle.getSparseParcelableArray(d());
|
||||
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()).a(bundle);
|
||||
}
|
||||
}
|
||||
int i2 = bundle.getInt("android:menu:expandedactionview");
|
||||
if (i2 <= 0 || (findItem = findItem(i2)) == null) {
|
||||
return;
|
||||
}
|
||||
findItem.expandActionView();
|
||||
}
|
||||
|
||||
public int b(int i) {
|
||||
int size = size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
if (this.f.get(i2).getItemId() == i) {
|
||||
return i2;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void b(boolean z) {
|
||||
if (!this.q) {
|
||||
if (z) {
|
||||
this.h = true;
|
||||
this.k = true;
|
||||
}
|
||||
d(z);
|
||||
return;
|
||||
}
|
||||
this.r = true;
|
||||
if (z) {
|
||||
this.s = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Callback callback) {
|
||||
this.e = callback;
|
||||
}
|
||||
|
||||
protected MenuItem a(int i, int i2, int i3, CharSequence charSequence) {
|
||||
int f = f(i3);
|
||||
MenuItemImpl a = a(i, i2, i3, f, charSequence, this.l);
|
||||
ContextMenu.ContextMenuInfo contextMenuInfo = this.m;
|
||||
if (contextMenuInfo != null) {
|
||||
a.a(contextMenuInfo);
|
||||
}
|
||||
ArrayList<MenuItemImpl> arrayList = this.f;
|
||||
arrayList.add(a(arrayList, f), a);
|
||||
b(true);
|
||||
return a;
|
||||
}
|
||||
|
||||
public void b() {
|
||||
ArrayList<MenuItemImpl> n = n();
|
||||
if (this.k) {
|
||||
Iterator<WeakReference<MenuPresenter>> it = this.w.iterator();
|
||||
boolean z = false;
|
||||
while (it.hasNext()) {
|
||||
WeakReference<MenuPresenter> next = it.next();
|
||||
MenuPresenter menuPresenter = next.get();
|
||||
if (menuPresenter == null) {
|
||||
this.w.remove(next);
|
||||
} else {
|
||||
z |= menuPresenter.b();
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
this.i.clear();
|
||||
this.j.clear();
|
||||
int size = n.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
MenuItemImpl menuItemImpl = n.get(i);
|
||||
if (menuItemImpl.h()) {
|
||||
this.i.add(menuItemImpl);
|
||||
} else {
|
||||
this.j.add(menuItemImpl);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.i.clear();
|
||||
this.j.clear();
|
||||
this.j.addAll(n());
|
||||
}
|
||||
this.k = false;
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItemImpl a(int i, int i2, int i3, int i4, CharSequence charSequence, int i5) {
|
||||
return new MenuItemImpl(this, i, i2, i3, i4, charSequence, i5);
|
||||
}
|
||||
|
||||
private void a(int i, boolean z) {
|
||||
if (i < 0 || i >= this.f.size()) {
|
||||
return;
|
||||
}
|
||||
this.f.remove(i);
|
||||
if (z) {
|
||||
b(true);
|
||||
}
|
||||
}
|
||||
|
||||
void a(MenuItem menuItem) {
|
||||
int groupId = menuItem.getGroupId();
|
||||
int size = this.f.size();
|
||||
s();
|
||||
for (int i = 0; i < size; i++) {
|
||||
MenuItemImpl menuItemImpl = this.f.get(i);
|
||||
if (menuItemImpl.getGroupId() == groupId && menuItemImpl.i() && menuItemImpl.isCheckable()) {
|
||||
menuItemImpl.b(menuItemImpl == menuItem);
|
||||
}
|
||||
}
|
||||
r();
|
||||
}
|
||||
|
||||
public boolean b(MenuItemImpl menuItemImpl) {
|
||||
boolean z = false;
|
||||
if (this.w.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
s();
|
||||
Iterator<WeakReference<MenuPresenter>> it = this.w.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<MenuPresenter> next = it.next();
|
||||
MenuPresenter menuPresenter = next.get();
|
||||
if (menuPresenter == null) {
|
||||
this.w.remove(next);
|
||||
} else {
|
||||
z = menuPresenter.b(this, menuItemImpl);
|
||||
if (z) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
r();
|
||||
if (z) {
|
||||
this.x = menuItemImpl;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public int a(int i) {
|
||||
return a(i, 0);
|
||||
}
|
||||
|
||||
public int a(int i, int i2) {
|
||||
int size = size();
|
||||
if (i2 < 0) {
|
||||
i2 = 0;
|
||||
}
|
||||
while (i2 < size) {
|
||||
if (this.f.get(i2).getGroupId() == i) {
|
||||
return i2;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
boolean a(MenuBuilder menuBuilder, MenuItem menuItem) {
|
||||
Callback callback = this.e;
|
||||
return callback != null && callback.a(menuBuilder, menuItem);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
Callback callback = this.e;
|
||||
if (callback != null) {
|
||||
callback.a(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static int a(ArrayList<MenuItemImpl> arrayList, int i) {
|
||||
for (int size = arrayList.size() - 1; size >= 0; size--) {
|
||||
if (arrayList.get(size).c() <= i) {
|
||||
return size + 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void a(List<MenuItemImpl> list, int i, KeyEvent keyEvent) {
|
||||
boolean p = p();
|
||||
int modifiers = keyEvent.getModifiers();
|
||||
KeyCharacterMap.KeyData keyData = new KeyCharacterMap.KeyData();
|
||||
if (keyEvent.getKeyData(keyData) || i == 67) {
|
||||
int size = this.f.size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
MenuItemImpl menuItemImpl = this.f.get(i2);
|
||||
if (menuItemImpl.hasSubMenu()) {
|
||||
((MenuBuilder) menuItemImpl.getSubMenu()).a(list, i, keyEvent);
|
||||
}
|
||||
char alphabeticShortcut = p ? menuItemImpl.getAlphabeticShortcut() : menuItemImpl.getNumericShortcut();
|
||||
if (((modifiers & 69647) == ((p ? menuItemImpl.getAlphabeticModifiers() : menuItemImpl.getNumericModifiers()) & 69647)) && alphabeticShortcut != 0) {
|
||||
char[] cArr = keyData.meta;
|
||||
if ((alphabeticShortcut == cArr[0] || alphabeticShortcut == cArr[2] || (p && alphabeticShortcut == '\b' && i == 67)) && menuItemImpl.isEnabled()) {
|
||||
list.add(menuItemImpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuItemImpl a(int i, KeyEvent keyEvent) {
|
||||
char numericShortcut;
|
||||
ArrayList<MenuItemImpl> arrayList = this.v;
|
||||
arrayList.clear();
|
||||
a(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 p = p();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
MenuItemImpl menuItemImpl = arrayList.get(i2);
|
||||
if (p) {
|
||||
numericShortcut = menuItemImpl.getAlphabeticShortcut();
|
||||
} else {
|
||||
numericShortcut = menuItemImpl.getNumericShortcut();
|
||||
}
|
||||
if ((numericShortcut == keyData.meta[0] && (metaState & 2) == 0) || ((numericShortcut == keyData.meta[2] && (metaState & 2) != 0) || (p && numericShortcut == '\b' && i == 67))) {
|
||||
return menuItemImpl;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean a(MenuItem menuItem, int i) {
|
||||
return a(menuItem, (MenuPresenter) null, i);
|
||||
}
|
||||
|
||||
public boolean a(MenuItem menuItem, MenuPresenter menuPresenter, int i) {
|
||||
MenuItemImpl menuItemImpl = (MenuItemImpl) menuItem;
|
||||
if (menuItemImpl == null || !menuItemImpl.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
boolean g = menuItemImpl.g();
|
||||
ActionProvider a = menuItemImpl.a();
|
||||
boolean z = a != null && a.a();
|
||||
if (menuItemImpl.f()) {
|
||||
g |= menuItemImpl.expandActionView();
|
||||
if (g) {
|
||||
a(true);
|
||||
}
|
||||
} else if (menuItemImpl.hasSubMenu() || z) {
|
||||
if ((i & 4) == 0) {
|
||||
a(false);
|
||||
}
|
||||
if (!menuItemImpl.hasSubMenu()) {
|
||||
menuItemImpl.a(new SubMenuBuilder(e(), this, menuItemImpl));
|
||||
}
|
||||
SubMenuBuilder subMenuBuilder = (SubMenuBuilder) menuItemImpl.getSubMenu();
|
||||
if (z) {
|
||||
a.a(subMenuBuilder);
|
||||
}
|
||||
g |= a(subMenuBuilder, menuPresenter);
|
||||
if (!g) {
|
||||
a(true);
|
||||
}
|
||||
} else if ((i & 1) == 0) {
|
||||
a(true);
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
public final void a(boolean z) {
|
||||
if (this.u) {
|
||||
return;
|
||||
}
|
||||
this.u = true;
|
||||
Iterator<WeakReference<MenuPresenter>> it = this.w.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<MenuPresenter> next = it.next();
|
||||
MenuPresenter menuPresenter = next.get();
|
||||
if (menuPresenter == null) {
|
||||
this.w.remove(next);
|
||||
} else {
|
||||
menuPresenter.a(this, z);
|
||||
}
|
||||
}
|
||||
this.u = false;
|
||||
}
|
||||
|
||||
private void a(int i, CharSequence charSequence, int i2, Drawable drawable, View view) {
|
||||
Resources l = l();
|
||||
if (view != null) {
|
||||
this.p = view;
|
||||
this.n = null;
|
||||
this.o = null;
|
||||
} else {
|
||||
if (i > 0) {
|
||||
this.n = l.getText(i);
|
||||
} else if (charSequence != null) {
|
||||
this.n = charSequence;
|
||||
}
|
||||
if (i2 > 0) {
|
||||
this.o = ContextCompat.c(e(), i2);
|
||||
} else if (drawable != null) {
|
||||
this.o = drawable;
|
||||
}
|
||||
this.p = null;
|
||||
}
|
||||
b(false);
|
||||
}
|
||||
|
||||
protected MenuBuilder a(CharSequence charSequence) {
|
||||
a(0, charSequence, 0, null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected MenuBuilder a(Drawable drawable) {
|
||||
a(0, null, 0, drawable, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected MenuBuilder a(View view) {
|
||||
a(0, null, 0, null, view);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean a(MenuItemImpl menuItemImpl) {
|
||||
boolean z = false;
|
||||
if (!this.w.isEmpty() && this.x == menuItemImpl) {
|
||||
s();
|
||||
Iterator<WeakReference<MenuPresenter>> it = this.w.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<MenuPresenter> next = it.next();
|
||||
MenuPresenter menuPresenter = next.get();
|
||||
if (menuPresenter == null) {
|
||||
this.w.remove(next);
|
||||
} else {
|
||||
z = menuPresenter.a(this, menuItemImpl);
|
||||
if (z) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
r();
|
||||
if (z) {
|
||||
this.x = null;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
}
|
109
sources/androidx/appcompat/view/menu/MenuDialogHelper.java
Normal file
109
sources/androidx/appcompat/view/menu/MenuDialogHelper.java
Normal file
@@ -0,0 +1,109 @@
|
||||
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$layout;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.view.menu.MenuPresenter;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class MenuDialogHelper implements DialogInterface.OnKeyListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, MenuPresenter.Callback {
|
||||
private MenuBuilder a;
|
||||
private AlertDialog b;
|
||||
ListMenuPresenter c;
|
||||
private MenuPresenter.Callback d;
|
||||
|
||||
public MenuDialogHelper(MenuBuilder menuBuilder) {
|
||||
this.a = menuBuilder;
|
||||
}
|
||||
|
||||
public void a(IBinder iBinder) {
|
||||
MenuBuilder menuBuilder = this.a;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(menuBuilder.e());
|
||||
this.c = new ListMenuPresenter(builder.b(), R$layout.abc_list_menu_item_layout);
|
||||
this.c.a(this);
|
||||
this.a.a(this.c);
|
||||
builder.a(this.c.a(), this);
|
||||
View i = menuBuilder.i();
|
||||
if (i != null) {
|
||||
builder.a(i);
|
||||
} else {
|
||||
builder.a(menuBuilder.g());
|
||||
builder.a(menuBuilder.h());
|
||||
}
|
||||
builder.a(this);
|
||||
this.b = builder.a();
|
||||
this.b.setOnDismissListener(this);
|
||||
WindowManager.LayoutParams attributes = this.b.getWindow().getAttributes();
|
||||
attributes.type = 1003;
|
||||
if (iBinder != null) {
|
||||
attributes.token = iBinder;
|
||||
}
|
||||
attributes.flags |= 131072;
|
||||
this.b.show();
|
||||
}
|
||||
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
this.a.a((MenuItemImpl) this.c.a().getItem(i), 0);
|
||||
}
|
||||
|
||||
@Override // android.content.DialogInterface.OnDismissListener
|
||||
public void onDismiss(DialogInterface dialogInterface) {
|
||||
this.c.a(this.a, true);
|
||||
}
|
||||
|
||||
@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.b.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.b.getWindow()) != null && (decorView = window.getDecorView()) != null && (keyDispatcherState = decorView.getKeyDispatcherState()) != null && keyDispatcherState.isTracking(keyEvent)) {
|
||||
this.a.a(true);
|
||||
dialogInterface.dismiss();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this.a.performShortcut(i, keyEvent, 0);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
AlertDialog alertDialog = this.b;
|
||||
if (alertDialog != null) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter.Callback
|
||||
public void a(MenuBuilder menuBuilder, boolean z) {
|
||||
if (z || menuBuilder == this.a) {
|
||||
a();
|
||||
}
|
||||
MenuPresenter.Callback callback = this.d;
|
||||
if (callback != null) {
|
||||
callback.a(menuBuilder, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter.Callback
|
||||
public boolean a(MenuBuilder menuBuilder) {
|
||||
MenuPresenter.Callback callback = this.d;
|
||||
if (callback != null) {
|
||||
return callback.a(menuBuilder);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
5
sources/androidx/appcompat/view/menu/MenuHelper.java
Normal file
5
sources/androidx/appcompat/view/menu/MenuHelper.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface MenuHelper {
|
||||
}
|
721
sources/androidx/appcompat/view/menu/MenuItemImpl.java
Normal file
721
sources/androidx/appcompat/view/menu/MenuItemImpl.java
Normal file
@@ -0,0 +1,721 @@
|
||||
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.os.Build;
|
||||
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$string;
|
||||
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;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MenuItemImpl implements SupportMenuItem {
|
||||
private View A;
|
||||
private ActionProvider B;
|
||||
private MenuItem.OnActionExpandListener C;
|
||||
private ContextMenu.ContextMenuInfo E;
|
||||
private final int a;
|
||||
private final int b;
|
||||
private final int c;
|
||||
private final int d;
|
||||
private CharSequence e;
|
||||
private CharSequence f;
|
||||
private Intent g;
|
||||
private char h;
|
||||
private char j;
|
||||
private Drawable l;
|
||||
MenuBuilder n;
|
||||
private SubMenuBuilder o;
|
||||
private Runnable p;
|
||||
private MenuItem.OnMenuItemClickListener q;
|
||||
private CharSequence r;
|
||||
private CharSequence s;
|
||||
private int z;
|
||||
private int i = FileUtil.ZIP_BUFFER_SIZE;
|
||||
private int k = FileUtil.ZIP_BUFFER_SIZE;
|
||||
private int m = 0;
|
||||
private ColorStateList t = null;
|
||||
private PorterDuff.Mode u = null;
|
||||
private boolean v = false;
|
||||
private boolean w = false;
|
||||
private boolean x = false;
|
||||
private int y = 16;
|
||||
private boolean D = false;
|
||||
|
||||
MenuItemImpl(MenuBuilder menuBuilder, int i, int i2, int i3, int i4, CharSequence charSequence, int i5) {
|
||||
this.z = 0;
|
||||
this.n = menuBuilder;
|
||||
this.a = i2;
|
||||
this.b = i;
|
||||
this.c = i3;
|
||||
this.d = i4;
|
||||
this.e = charSequence;
|
||||
this.z = i5;
|
||||
}
|
||||
|
||||
private static void a(StringBuilder sb, int i, int i2, String str) {
|
||||
if ((i & i2) == i2) {
|
||||
sb.append(str);
|
||||
}
|
||||
}
|
||||
|
||||
void b(boolean z) {
|
||||
int i = this.y;
|
||||
this.y = (z ? 2 : 0) | (i & (-3));
|
||||
if (i != this.y) {
|
||||
this.n.b(false);
|
||||
}
|
||||
}
|
||||
|
||||
public int c() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public boolean collapseActionView() {
|
||||
if ((this.z & 8) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (this.A == null) {
|
||||
return true;
|
||||
}
|
||||
MenuItem.OnActionExpandListener onActionExpandListener = this.C;
|
||||
if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionCollapse(this)) {
|
||||
return this.n.a(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
char d() {
|
||||
return this.n.p() ? this.j : this.h;
|
||||
}
|
||||
|
||||
String e() {
|
||||
char d = d();
|
||||
if (d == 0) {
|
||||
return "";
|
||||
}
|
||||
Resources resources = this.n.e().getResources();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (ViewConfiguration.get(this.n.e()).hasPermanentMenuKey()) {
|
||||
sb.append(resources.getString(R$string.abc_prepend_shortcut_label));
|
||||
}
|
||||
int i = this.n.p() ? this.k : this.i;
|
||||
a(sb, i, 65536, resources.getString(R$string.abc_menu_meta_shortcut_label));
|
||||
a(sb, i, FileUtil.ZIP_BUFFER_SIZE, resources.getString(R$string.abc_menu_ctrl_shortcut_label));
|
||||
a(sb, i, 2, resources.getString(R$string.abc_menu_alt_shortcut_label));
|
||||
a(sb, i, 1, resources.getString(R$string.abc_menu_shift_shortcut_label));
|
||||
a(sb, i, 4, resources.getString(R$string.abc_menu_sym_shortcut_label));
|
||||
a(sb, i, 8, resources.getString(R$string.abc_menu_function_shortcut_label));
|
||||
if (d == '\b') {
|
||||
sb.append(resources.getString(R$string.abc_menu_delete_shortcut_label));
|
||||
} else if (d == '\n') {
|
||||
sb.append(resources.getString(R$string.abc_menu_enter_shortcut_label));
|
||||
} else if (d != ' ') {
|
||||
sb.append(d);
|
||||
} else {
|
||||
sb.append(resources.getString(R$string.abc_menu_space_shortcut_label));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public boolean expandActionView() {
|
||||
if (!f()) {
|
||||
return false;
|
||||
}
|
||||
MenuItem.OnActionExpandListener onActionExpandListener = this.C;
|
||||
if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionExpand(this)) {
|
||||
return this.n.b(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean f() {
|
||||
ActionProvider actionProvider;
|
||||
if ((this.z & 8) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (this.A == null && (actionProvider = this.B) != null) {
|
||||
this.A = actionProvider.a(this);
|
||||
}
|
||||
return this.A != null;
|
||||
}
|
||||
|
||||
public boolean g() {
|
||||
MenuItem.OnMenuItemClickListener onMenuItemClickListener = this.q;
|
||||
if (onMenuItemClickListener != null && onMenuItemClickListener.onMenuItemClick(this)) {
|
||||
return true;
|
||||
}
|
||||
MenuBuilder menuBuilder = this.n;
|
||||
if (menuBuilder.a(menuBuilder, this)) {
|
||||
return true;
|
||||
}
|
||||
Runnable runnable = this.p;
|
||||
if (runnable != null) {
|
||||
runnable.run();
|
||||
return true;
|
||||
}
|
||||
if (this.g != null) {
|
||||
try {
|
||||
this.n.e().startActivity(this.g);
|
||||
return true;
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e("MenuItemImpl", "Can't find activity to handle intent; ignoring", e);
|
||||
}
|
||||
}
|
||||
ActionProvider actionProvider = this.B;
|
||||
return actionProvider != null && actionProvider.d();
|
||||
}
|
||||
|
||||
@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, android.view.MenuItem
|
||||
public View getActionView() {
|
||||
View view = this.A;
|
||||
if (view != null) {
|
||||
return view;
|
||||
}
|
||||
ActionProvider actionProvider = this.B;
|
||||
if (actionProvider == null) {
|
||||
return null;
|
||||
}
|
||||
this.A = actionProvider.a(this);
|
||||
return this.A;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public int getAlphabeticModifiers() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public char getAlphabeticShortcut() {
|
||||
return this.j;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public CharSequence getContentDescription() {
|
||||
return this.r;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getGroupId() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public Drawable getIcon() {
|
||||
Drawable drawable = this.l;
|
||||
if (drawable != null) {
|
||||
return a(drawable);
|
||||
}
|
||||
if (this.m == 0) {
|
||||
return null;
|
||||
}
|
||||
Drawable c = AppCompatResources.c(this.n.e(), this.m);
|
||||
this.m = 0;
|
||||
this.l = c;
|
||||
return a(c);
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public ColorStateList getIconTintList() {
|
||||
return this.t;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public PorterDuff.Mode getIconTintMode() {
|
||||
return this.u;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public Intent getIntent() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
@ViewDebug.CapturedViewProperty
|
||||
public int getItemId() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public ContextMenu.ContextMenuInfo getMenuInfo() {
|
||||
return this.E;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public int getNumericModifiers() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public char getNumericShortcut() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getOrder() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public SubMenu getSubMenu() {
|
||||
return this.o;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
@ViewDebug.CapturedViewProperty
|
||||
public CharSequence getTitle() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public CharSequence getTitleCondensed() {
|
||||
CharSequence charSequence = this.f;
|
||||
if (charSequence == null) {
|
||||
charSequence = this.e;
|
||||
}
|
||||
return (Build.VERSION.SDK_INT >= 18 || charSequence == null || (charSequence instanceof String)) ? charSequence : charSequence.toString();
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public CharSequence getTooltipText() {
|
||||
return this.s;
|
||||
}
|
||||
|
||||
public boolean h() {
|
||||
return (this.y & 32) == 32;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean hasSubMenu() {
|
||||
return this.o != null;
|
||||
}
|
||||
|
||||
public boolean i() {
|
||||
return (this.y & 4) != 0;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public boolean isActionViewExpanded() {
|
||||
return this.D;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isCheckable() {
|
||||
return (this.y & 1) == 1;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isChecked() {
|
||||
return (this.y & 2) == 2;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isEnabled() {
|
||||
return (this.y & 16) != 0;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isVisible() {
|
||||
ActionProvider actionProvider = this.B;
|
||||
return (actionProvider == null || !actionProvider.e()) ? (this.y & 8) == 0 : (this.y & 8) == 0 && this.B.b();
|
||||
}
|
||||
|
||||
public boolean j() {
|
||||
return (this.z & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean k() {
|
||||
return (this.z & 2) == 2;
|
||||
}
|
||||
|
||||
public boolean l() {
|
||||
return this.n.k();
|
||||
}
|
||||
|
||||
boolean m() {
|
||||
return this.n.q() && d() != 0;
|
||||
}
|
||||
|
||||
public boolean n() {
|
||||
return (this.z & 4) == 4;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setActionProvider(android.view.ActionProvider actionProvider) {
|
||||
throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.setActionProvider()");
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setActionView(int i) {
|
||||
setActionView(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setAlphabeticShortcut(char c) {
|
||||
if (this.j == c) {
|
||||
return this;
|
||||
}
|
||||
this.j = Character.toLowerCase(c);
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setCheckable(boolean z) {
|
||||
int i = this.y;
|
||||
this.y = (z ? 1 : 0) | (i & (-2));
|
||||
if (i != this.y) {
|
||||
this.n.b(false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setChecked(boolean z) {
|
||||
if ((this.y & 4) != 0) {
|
||||
this.n.a((MenuItem) this);
|
||||
} else {
|
||||
b(z);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setContentDescription(CharSequence charSequence) {
|
||||
setContentDescription(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setEnabled(boolean z) {
|
||||
if (z) {
|
||||
this.y |= 16;
|
||||
} else {
|
||||
this.y &= -17;
|
||||
}
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIcon(Drawable drawable) {
|
||||
this.m = 0;
|
||||
this.l = drawable;
|
||||
this.x = true;
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setIconTintList(ColorStateList colorStateList) {
|
||||
this.t = colorStateList;
|
||||
this.v = true;
|
||||
this.x = true;
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setIconTintMode(PorterDuff.Mode mode) {
|
||||
this.u = mode;
|
||||
this.w = true;
|
||||
this.x = true;
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIntent(Intent intent) {
|
||||
this.g = intent;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setNumericShortcut(char c) {
|
||||
if (this.h == c) {
|
||||
return this;
|
||||
}
|
||||
this.h = c;
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) {
|
||||
this.C = onActionExpandListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) {
|
||||
this.q = onMenuItemClickListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setShortcut(char c, char c2) {
|
||||
this.h = c;
|
||||
this.j = Character.toLowerCase(c2);
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@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.z = i;
|
||||
this.n.c(this);
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setShowAsActionFlags(int i) {
|
||||
setShowAsActionFlags(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitle(CharSequence charSequence) {
|
||||
this.e = charSequence;
|
||||
this.n.b(false);
|
||||
SubMenuBuilder subMenuBuilder = this.o;
|
||||
if (subMenuBuilder != null) {
|
||||
subMenuBuilder.setHeaderTitle(charSequence);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitleCondensed(CharSequence charSequence) {
|
||||
this.f = charSequence;
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setTooltipText(CharSequence charSequence) {
|
||||
setTooltipText(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setVisible(boolean z) {
|
||||
if (e(z)) {
|
||||
this.n.d(this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
CharSequence charSequence = this.e;
|
||||
if (charSequence != null) {
|
||||
return charSequence.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void a(SubMenuBuilder subMenuBuilder) {
|
||||
this.o = subMenuBuilder;
|
||||
subMenuBuilder.setHeaderTitle(getTitle());
|
||||
}
|
||||
|
||||
public void c(boolean z) {
|
||||
this.y = (z ? 4 : 0) | (this.y & (-5));
|
||||
}
|
||||
|
||||
public void d(boolean z) {
|
||||
if (z) {
|
||||
this.y |= 32;
|
||||
} else {
|
||||
this.y &= -33;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public /* bridge */ /* synthetic */ MenuItem setActionView(View view) {
|
||||
setActionView(view);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public SupportMenuItem setContentDescription(CharSequence charSequence) {
|
||||
this.r = charSequence;
|
||||
this.n.b(false);
|
||||
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 SupportMenuItem setTooltipText(CharSequence charSequence) {
|
||||
this.s = charSequence;
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public SupportMenuItem setActionView(View view) {
|
||||
int i;
|
||||
this.A = view;
|
||||
this.B = null;
|
||||
if (view != null && view.getId() == -1 && (i = this.a) > 0) {
|
||||
view.setId(i);
|
||||
}
|
||||
this.n.c(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
CharSequence a(MenuView.ItemView itemView) {
|
||||
if (itemView != null && itemView.a()) {
|
||||
return getTitleCondensed();
|
||||
}
|
||||
return getTitle();
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setAlphabeticShortcut(char c, int i) {
|
||||
if (this.j == c && this.k == i) {
|
||||
return this;
|
||||
}
|
||||
this.j = Character.toLowerCase(c);
|
||||
this.k = KeyEvent.normalizeMetaState(i);
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setNumericShortcut(char c, int i) {
|
||||
if (this.h == c && this.i == i) {
|
||||
return this;
|
||||
}
|
||||
this.h = c;
|
||||
this.i = KeyEvent.normalizeMetaState(i);
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public MenuItem setShortcut(char c, char c2, int i, int i2) {
|
||||
this.h = c;
|
||||
this.i = KeyEvent.normalizeMetaState(i);
|
||||
this.j = Character.toLowerCase(c2);
|
||||
this.k = KeyEvent.normalizeMetaState(i2);
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.n.c(this);
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIcon(int i) {
|
||||
this.l = null;
|
||||
this.m = i;
|
||||
this.x = true;
|
||||
this.n.b(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitle(int i) {
|
||||
setTitle(this.n.e().getString(i));
|
||||
return this;
|
||||
}
|
||||
|
||||
private Drawable a(Drawable drawable) {
|
||||
if (drawable != null && this.x && (this.v || this.w)) {
|
||||
drawable = DrawableCompat.h(drawable).mutate();
|
||||
if (this.v) {
|
||||
DrawableCompat.a(drawable, this.t);
|
||||
}
|
||||
if (this.w) {
|
||||
DrawableCompat.a(drawable, this.u);
|
||||
}
|
||||
this.x = false;
|
||||
}
|
||||
return drawable;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem
|
||||
public SupportMenuItem setActionView(int i) {
|
||||
Context e = this.n.e();
|
||||
setActionView(LayoutInflater.from(e).inflate(i, (ViewGroup) new LinearLayout(e), false));
|
||||
return this;
|
||||
}
|
||||
|
||||
void a(ContextMenu.ContextMenuInfo contextMenuInfo) {
|
||||
this.E = contextMenuInfo;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem
|
||||
public ActionProvider a() {
|
||||
return this.B;
|
||||
}
|
||||
|
||||
@Override // androidx.core.internal.view.SupportMenuItem
|
||||
public SupportMenuItem a(ActionProvider actionProvider) {
|
||||
ActionProvider actionProvider2 = this.B;
|
||||
if (actionProvider2 != null) {
|
||||
actionProvider2.f();
|
||||
}
|
||||
this.A = null;
|
||||
this.B = actionProvider;
|
||||
this.n.b(true);
|
||||
ActionProvider actionProvider3 = this.B;
|
||||
if (actionProvider3 != null) {
|
||||
actionProvider3.a(new ActionProvider.VisibilityListener() { // from class: androidx.appcompat.view.menu.MenuItemImpl.1
|
||||
@Override // androidx.core.view.ActionProvider.VisibilityListener
|
||||
public void onActionProviderVisibilityChanged(boolean z) {
|
||||
MenuItemImpl menuItemImpl = MenuItemImpl.this;
|
||||
menuItemImpl.n.d(menuItemImpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.D = z;
|
||||
this.n.b(false);
|
||||
}
|
||||
|
||||
boolean e(boolean z) {
|
||||
int i = this.y;
|
||||
this.y = (z ? 0 : 8) | (i & (-9));
|
||||
return i != this.y;
|
||||
}
|
||||
}
|
429
sources/androidx/appcompat/view/menu/MenuItemWrapperICS.java
Normal file
429
sources/androidx/appcompat/view/menu/MenuItemWrapperICS.java
Normal file
@@ -0,0 +1,429 @@
|
||||
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.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.view.CollapsibleActionView;
|
||||
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<SupportMenuItem> implements MenuItem {
|
||||
private Method e;
|
||||
|
||||
class ActionProviderWrapper extends ActionProvider {
|
||||
final android.view.ActionProvider b;
|
||||
|
||||
public ActionProviderWrapper(Context context, android.view.ActionProvider actionProvider) {
|
||||
super(context);
|
||||
this.b = actionProvider;
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.ActionProvider
|
||||
public boolean a() {
|
||||
return this.b.hasSubMenu();
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.ActionProvider
|
||||
public View c() {
|
||||
return this.b.onCreateActionView();
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.ActionProvider
|
||||
public boolean d() {
|
||||
return this.b.onPerformDefaultAction();
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.ActionProvider
|
||||
public void a(SubMenu subMenu) {
|
||||
this.b.onPrepareSubMenu(MenuItemWrapperICS.this.a(subMenu));
|
||||
}
|
||||
}
|
||||
|
||||
static class CollapsibleActionViewWrapper extends FrameLayout implements CollapsibleActionView {
|
||||
final android.view.CollapsibleActionView a;
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
CollapsibleActionViewWrapper(View view) {
|
||||
super(view.getContext());
|
||||
this.a = (android.view.CollapsibleActionView) view;
|
||||
addView(view);
|
||||
}
|
||||
|
||||
View a() {
|
||||
return (View) this.a;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.CollapsibleActionView
|
||||
public void b() {
|
||||
this.a.onActionViewExpanded();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.CollapsibleActionView
|
||||
public void c() {
|
||||
this.a.onActionViewCollapsed();
|
||||
}
|
||||
}
|
||||
|
||||
private class OnActionExpandListenerWrapper extends BaseWrapper<MenuItem.OnActionExpandListener> implements MenuItem.OnActionExpandListener {
|
||||
OnActionExpandListenerWrapper(MenuItem.OnActionExpandListener onActionExpandListener) {
|
||||
super(onActionExpandListener);
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem.OnActionExpandListener
|
||||
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
|
||||
return ((MenuItem.OnActionExpandListener) this.a).onMenuItemActionCollapse(MenuItemWrapperICS.this.a(menuItem));
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem.OnActionExpandListener
|
||||
public boolean onMenuItemActionExpand(MenuItem menuItem) {
|
||||
return ((MenuItem.OnActionExpandListener) this.a).onMenuItemActionExpand(MenuItemWrapperICS.this.a(menuItem));
|
||||
}
|
||||
}
|
||||
|
||||
private class OnMenuItemClickListenerWrapper extends BaseWrapper<MenuItem.OnMenuItemClickListener> implements MenuItem.OnMenuItemClickListener {
|
||||
OnMenuItemClickListenerWrapper(MenuItem.OnMenuItemClickListener onMenuItemClickListener) {
|
||||
super(onMenuItemClickListener);
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem.OnMenuItemClickListener
|
||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||
return ((MenuItem.OnMenuItemClickListener) this.a).onMenuItemClick(MenuItemWrapperICS.this.a(menuItem));
|
||||
}
|
||||
}
|
||||
|
||||
MenuItemWrapperICS(Context context, SupportMenuItem supportMenuItem) {
|
||||
super(context, supportMenuItem);
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
try {
|
||||
if (this.e == null) {
|
||||
this.e = ((SupportMenuItem) this.a).getClass().getDeclaredMethod("setExclusiveCheckable", Boolean.TYPE);
|
||||
}
|
||||
this.e.invoke(this.a, Boolean.valueOf(z));
|
||||
} catch (Exception e) {
|
||||
Log.w("MenuItemWrapper", "Error while calling setExclusiveCheckable", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean collapseActionView() {
|
||||
return ((SupportMenuItem) this.a).collapseActionView();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean expandActionView() {
|
||||
return ((SupportMenuItem) this.a).expandActionView();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public android.view.ActionProvider getActionProvider() {
|
||||
ActionProvider a = ((SupportMenuItem) this.a).a();
|
||||
if (a instanceof ActionProviderWrapper) {
|
||||
return ((ActionProviderWrapper) a).b;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public View getActionView() {
|
||||
View actionView = ((SupportMenuItem) this.a).getActionView();
|
||||
return actionView instanceof CollapsibleActionViewWrapper ? ((CollapsibleActionViewWrapper) actionView).a() : actionView;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getAlphabeticModifiers() {
|
||||
return ((SupportMenuItem) this.a).getAlphabeticModifiers();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public char getAlphabeticShortcut() {
|
||||
return ((SupportMenuItem) this.a).getAlphabeticShortcut();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public CharSequence getContentDescription() {
|
||||
return ((SupportMenuItem) this.a).getContentDescription();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getGroupId() {
|
||||
return ((SupportMenuItem) this.a).getGroupId();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public Drawable getIcon() {
|
||||
return ((SupportMenuItem) this.a).getIcon();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public ColorStateList getIconTintList() {
|
||||
return ((SupportMenuItem) this.a).getIconTintList();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public PorterDuff.Mode getIconTintMode() {
|
||||
return ((SupportMenuItem) this.a).getIconTintMode();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public Intent getIntent() {
|
||||
return ((SupportMenuItem) this.a).getIntent();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getItemId() {
|
||||
return ((SupportMenuItem) this.a).getItemId();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public ContextMenu.ContextMenuInfo getMenuInfo() {
|
||||
return ((SupportMenuItem) this.a).getMenuInfo();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getNumericModifiers() {
|
||||
return ((SupportMenuItem) this.a).getNumericModifiers();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public char getNumericShortcut() {
|
||||
return ((SupportMenuItem) this.a).getNumericShortcut();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public int getOrder() {
|
||||
return ((SupportMenuItem) this.a).getOrder();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public SubMenu getSubMenu() {
|
||||
return a(((SupportMenuItem) this.a).getSubMenu());
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public CharSequence getTitle() {
|
||||
return ((SupportMenuItem) this.a).getTitle();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public CharSequence getTitleCondensed() {
|
||||
return ((SupportMenuItem) this.a).getTitleCondensed();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public CharSequence getTooltipText() {
|
||||
return ((SupportMenuItem) this.a).getTooltipText();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean hasSubMenu() {
|
||||
return ((SupportMenuItem) this.a).hasSubMenu();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isActionViewExpanded() {
|
||||
return ((SupportMenuItem) this.a).isActionViewExpanded();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isCheckable() {
|
||||
return ((SupportMenuItem) this.a).isCheckable();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isChecked() {
|
||||
return ((SupportMenuItem) this.a).isChecked();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isEnabled() {
|
||||
return ((SupportMenuItem) this.a).isEnabled();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public boolean isVisible() {
|
||||
return ((SupportMenuItem) this.a).isVisible();
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setActionProvider(android.view.ActionProvider actionProvider) {
|
||||
((SupportMenuItem) this.a).a(actionProvider != null ? a(actionProvider) : null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setActionView(View view) {
|
||||
if (view instanceof android.view.CollapsibleActionView) {
|
||||
view = new CollapsibleActionViewWrapper(view);
|
||||
}
|
||||
((SupportMenuItem) this.a).setActionView(view);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setAlphabeticShortcut(char c) {
|
||||
((SupportMenuItem) this.a).setAlphabeticShortcut(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setCheckable(boolean z) {
|
||||
((SupportMenuItem) this.a).setCheckable(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setChecked(boolean z) {
|
||||
((SupportMenuItem) this.a).setChecked(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setContentDescription(CharSequence charSequence) {
|
||||
((SupportMenuItem) this.a).setContentDescription(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setEnabled(boolean z) {
|
||||
((SupportMenuItem) this.a).setEnabled(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIcon(Drawable drawable) {
|
||||
((SupportMenuItem) this.a).setIcon(drawable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIconTintList(ColorStateList colorStateList) {
|
||||
((SupportMenuItem) this.a).setIconTintList(colorStateList);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIconTintMode(PorterDuff.Mode mode) {
|
||||
((SupportMenuItem) this.a).setIconTintMode(mode);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIntent(Intent intent) {
|
||||
((SupportMenuItem) this.a).setIntent(intent);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setNumericShortcut(char c) {
|
||||
((SupportMenuItem) this.a).setNumericShortcut(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) {
|
||||
((SupportMenuItem) this.a).setOnActionExpandListener(onActionExpandListener != null ? new OnActionExpandListenerWrapper(onActionExpandListener) : null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) {
|
||||
((SupportMenuItem) this.a).setOnMenuItemClickListener(onMenuItemClickListener != null ? new OnMenuItemClickListenerWrapper(onMenuItemClickListener) : null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setShortcut(char c, char c2) {
|
||||
((SupportMenuItem) this.a).setShortcut(c, c2);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public void setShowAsAction(int i) {
|
||||
((SupportMenuItem) this.a).setShowAsAction(i);
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setShowAsActionFlags(int i) {
|
||||
((SupportMenuItem) this.a).setShowAsActionFlags(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitle(CharSequence charSequence) {
|
||||
((SupportMenuItem) this.a).setTitle(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitleCondensed(CharSequence charSequence) {
|
||||
((SupportMenuItem) this.a).setTitleCondensed(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTooltipText(CharSequence charSequence) {
|
||||
((SupportMenuItem) this.a).setTooltipText(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setVisible(boolean z) {
|
||||
return ((SupportMenuItem) this.a).setVisible(z);
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setAlphabeticShortcut(char c, int i) {
|
||||
((SupportMenuItem) this.a).setAlphabeticShortcut(c, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setIcon(int i) {
|
||||
((SupportMenuItem) this.a).setIcon(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setNumericShortcut(char c, int i) {
|
||||
((SupportMenuItem) this.a).setNumericShortcut(c, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setShortcut(char c, char c2, int i, int i2) {
|
||||
((SupportMenuItem) this.a).setShortcut(c, c2, i, i2);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setTitle(int i) {
|
||||
((SupportMenuItem) this.a).setTitle(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.MenuItem
|
||||
public MenuItem setActionView(int i) {
|
||||
((SupportMenuItem) this.a).setActionView(i);
|
||||
View actionView = ((SupportMenuItem) this.a).getActionView();
|
||||
if (actionView instanceof android.view.CollapsibleActionView) {
|
||||
((SupportMenuItem) this.a).setActionView(new CollapsibleActionViewWrapper(actionView));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
ActionProviderWrapper a(android.view.ActionProvider actionProvider) {
|
||||
return new ActionProviderWrapper(this.b, actionProvider);
|
||||
}
|
||||
}
|
59
sources/androidx/appcompat/view/menu/MenuItemWrapperJB.java
Normal file
59
sources/androidx/appcompat/view/menu/MenuItemWrapperJB.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ActionProvider;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.view.menu.MenuItemWrapperICS;
|
||||
import androidx.core.internal.view.SupportMenuItem;
|
||||
import androidx.core.view.ActionProvider;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class MenuItemWrapperJB extends MenuItemWrapperICS {
|
||||
|
||||
class ActionProviderWrapperJB extends MenuItemWrapperICS.ActionProviderWrapper implements ActionProvider.VisibilityListener {
|
||||
ActionProvider.VisibilityListener d;
|
||||
|
||||
public ActionProviderWrapperJB(MenuItemWrapperJB menuItemWrapperJB, Context context, android.view.ActionProvider actionProvider) {
|
||||
super(context, actionProvider);
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.ActionProvider
|
||||
public View a(MenuItem menuItem) {
|
||||
return this.b.onCreateActionView(menuItem);
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.ActionProvider
|
||||
public boolean b() {
|
||||
return this.b.isVisible();
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.ActionProvider
|
||||
public boolean e() {
|
||||
return this.b.overridesItemVisibility();
|
||||
}
|
||||
|
||||
@Override // android.view.ActionProvider.VisibilityListener
|
||||
public void onActionProviderVisibilityChanged(boolean z) {
|
||||
ActionProvider.VisibilityListener visibilityListener = this.d;
|
||||
if (visibilityListener != null) {
|
||||
visibilityListener.onActionProviderVisibilityChanged(z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.ActionProvider
|
||||
public void a(ActionProvider.VisibilityListener visibilityListener) {
|
||||
this.d = visibilityListener;
|
||||
this.b.setVisibilityListener(visibilityListener != null ? this : null);
|
||||
}
|
||||
}
|
||||
|
||||
MenuItemWrapperJB(Context context, SupportMenuItem supportMenuItem) {
|
||||
super(context, supportMenuItem);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuItemWrapperICS
|
||||
MenuItemWrapperICS.ActionProviderWrapper a(android.view.ActionProvider actionProvider) {
|
||||
return new ActionProviderWrapperJB(this, this.b, actionProvider);
|
||||
}
|
||||
}
|
117
sources/androidx/appcompat/view/menu/MenuPopup.java
Normal file
117
sources/androidx/appcompat/view/menu/MenuPopup.java
Normal file
@@ -0,0 +1,117 @@
|
||||
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 a;
|
||||
|
||||
MenuPopup() {
|
||||
}
|
||||
|
||||
protected static boolean b(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;
|
||||
}
|
||||
|
||||
public abstract void a(int i);
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(Context context, MenuBuilder menuBuilder) {
|
||||
}
|
||||
|
||||
public void a(Rect rect) {
|
||||
this.a = rect;
|
||||
}
|
||||
|
||||
public abstract void a(View view);
|
||||
|
||||
public abstract void a(PopupWindow.OnDismissListener onDismissListener);
|
||||
|
||||
public abstract void a(MenuBuilder menuBuilder);
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean a(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract void b(int i);
|
||||
|
||||
public abstract void b(boolean z);
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean b(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract void c(int i);
|
||||
|
||||
public abstract void c(boolean z);
|
||||
|
||||
protected boolean e() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Rect f() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override // android.widget.AdapterView.OnItemClickListener
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
|
||||
ListAdapter listAdapter = (ListAdapter) adapterView.getAdapter();
|
||||
a(listAdapter).a.a((MenuItem) listAdapter.getItem(i), this, e() ? 0 : 4);
|
||||
}
|
||||
|
||||
protected static int a(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();
|
||||
ViewGroup viewGroup2 = viewGroup;
|
||||
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 (viewGroup2 == null) {
|
||||
viewGroup2 = new FrameLayout(context);
|
||||
}
|
||||
view = listAdapter.getView(i4, view, viewGroup2);
|
||||
view.measure(makeMeasureSpec, makeMeasureSpec2);
|
||||
int measuredWidth = view.getMeasuredWidth();
|
||||
if (measuredWidth >= i) {
|
||||
return i;
|
||||
}
|
||||
if (measuredWidth > i2) {
|
||||
i2 = measuredWidth;
|
||||
}
|
||||
}
|
||||
return i2;
|
||||
}
|
||||
|
||||
protected static MenuAdapter a(ListAdapter listAdapter) {
|
||||
if (listAdapter instanceof HeaderViewListAdapter) {
|
||||
return (MenuAdapter) ((HeaderViewListAdapter) listAdapter).getWrappedAdapter();
|
||||
}
|
||||
return (MenuAdapter) listAdapter;
|
||||
}
|
||||
}
|
165
sources/androidx/appcompat/view/menu/MenuPopupHelper.java
Normal file
165
sources/androidx/appcompat/view/menu/MenuPopupHelper.java
Normal file
@@ -0,0 +1,165 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.PopupWindow;
|
||||
import androidx.appcompat.R$dimen;
|
||||
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 final Context a;
|
||||
private final MenuBuilder b;
|
||||
private final boolean c;
|
||||
private final int d;
|
||||
private final int e;
|
||||
private View f;
|
||||
private int g;
|
||||
private boolean h;
|
||||
private MenuPresenter.Callback i;
|
||||
private MenuPopup j;
|
||||
private PopupWindow.OnDismissListener k;
|
||||
private final PopupWindow.OnDismissListener l;
|
||||
|
||||
public MenuPopupHelper(Context context, MenuBuilder menuBuilder, View view, boolean z, int i) {
|
||||
this(context, menuBuilder, view, z, i, 0);
|
||||
}
|
||||
|
||||
private MenuPopup g() {
|
||||
Display defaultDisplay = ((WindowManager) this.a.getSystemService("window")).getDefaultDisplay();
|
||||
Point point = new Point();
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
defaultDisplay.getRealSize(point);
|
||||
} else {
|
||||
defaultDisplay.getSize(point);
|
||||
}
|
||||
MenuPopup cascadingMenuPopup = Math.min(point.x, point.y) >= this.a.getResources().getDimensionPixelSize(R$dimen.abc_cascading_menus_min_smallest_width) ? new CascadingMenuPopup(this.a, this.f, this.d, this.e, this.c) : new StandardMenuPopup(this.a, this.b, this.f, this.d, this.e, this.c);
|
||||
cascadingMenuPopup.a(this.b);
|
||||
cascadingMenuPopup.a(this.l);
|
||||
cascadingMenuPopup.a(this.f);
|
||||
cascadingMenuPopup.a(this.i);
|
||||
cascadingMenuPopup.b(this.h);
|
||||
cascadingMenuPopup.a(this.g);
|
||||
return cascadingMenuPopup;
|
||||
}
|
||||
|
||||
public void a(PopupWindow.OnDismissListener onDismissListener) {
|
||||
this.k = onDismissListener;
|
||||
}
|
||||
|
||||
public MenuPopup b() {
|
||||
if (this.j == null) {
|
||||
this.j = g();
|
||||
}
|
||||
return this.j;
|
||||
}
|
||||
|
||||
public boolean c() {
|
||||
MenuPopup menuPopup = this.j;
|
||||
return menuPopup != null && menuPopup.c();
|
||||
}
|
||||
|
||||
protected void d() {
|
||||
this.j = null;
|
||||
PopupWindow.OnDismissListener onDismissListener = this.k;
|
||||
if (onDismissListener != null) {
|
||||
onDismissListener.onDismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public void e() {
|
||||
if (!f()) {
|
||||
throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean f() {
|
||||
if (c()) {
|
||||
return true;
|
||||
}
|
||||
if (this.f == null) {
|
||||
return false;
|
||||
}
|
||||
a(0, 0, false, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public MenuPopupHelper(Context context, MenuBuilder menuBuilder, View view, boolean z, int i, int i2) {
|
||||
this.g = 8388611;
|
||||
this.l = new PopupWindow.OnDismissListener() { // from class: androidx.appcompat.view.menu.MenuPopupHelper.1
|
||||
@Override // android.widget.PopupWindow.OnDismissListener
|
||||
public void onDismiss() {
|
||||
MenuPopupHelper.this.d();
|
||||
}
|
||||
};
|
||||
this.a = context;
|
||||
this.b = menuBuilder;
|
||||
this.f = view;
|
||||
this.c = z;
|
||||
this.d = i;
|
||||
this.e = i2;
|
||||
}
|
||||
|
||||
public void a(View view) {
|
||||
this.f = view;
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.h = z;
|
||||
MenuPopup menuPopup = this.j;
|
||||
if (menuPopup != null) {
|
||||
menuPopup.b(z);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.g = i;
|
||||
}
|
||||
|
||||
public boolean a(int i, int i2) {
|
||||
if (c()) {
|
||||
return true;
|
||||
}
|
||||
if (this.f == null) {
|
||||
return false;
|
||||
}
|
||||
a(i, i2, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void a(int i, int i2, boolean z, boolean z2) {
|
||||
MenuPopup b = b();
|
||||
b.c(z2);
|
||||
if (z) {
|
||||
if ((GravityCompat.a(this.g, ViewCompat.k(this.f)) & 7) == 5) {
|
||||
i -= this.f.getWidth();
|
||||
}
|
||||
b.b(i);
|
||||
b.c(i2);
|
||||
int i3 = (int) ((this.a.getResources().getDisplayMetrics().density * 48.0f) / 2.0f);
|
||||
b.a(new Rect(i - i3, i2 - i3, i + i3, i2 + i3));
|
||||
}
|
||||
b.a();
|
||||
}
|
||||
|
||||
public void a() {
|
||||
if (c()) {
|
||||
this.j.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public void a(MenuPresenter.Callback callback) {
|
||||
this.i = callback;
|
||||
MenuPopup menuPopup = this.j;
|
||||
if (menuPopup != null) {
|
||||
menuPopup.a(callback);
|
||||
}
|
||||
}
|
||||
}
|
29
sources/androidx/appcompat/view/menu/MenuPresenter.java
Normal file
29
sources/androidx/appcompat/view/menu/MenuPresenter.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface MenuPresenter {
|
||||
|
||||
public interface Callback {
|
||||
void a(MenuBuilder menuBuilder, boolean z);
|
||||
|
||||
boolean a(MenuBuilder menuBuilder);
|
||||
}
|
||||
|
||||
void a(Context context, MenuBuilder menuBuilder);
|
||||
|
||||
void a(MenuBuilder menuBuilder, boolean z);
|
||||
|
||||
void a(Callback callback);
|
||||
|
||||
void a(boolean z);
|
||||
|
||||
boolean a(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl);
|
||||
|
||||
boolean a(SubMenuBuilder subMenuBuilder);
|
||||
|
||||
boolean b();
|
||||
|
||||
boolean b(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl);
|
||||
}
|
15
sources/androidx/appcompat/view/menu/MenuView.java
Normal file
15
sources/androidx/appcompat/view/menu/MenuView.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface MenuView {
|
||||
|
||||
public interface ItemView {
|
||||
void a(MenuItemImpl menuItemImpl, int i);
|
||||
|
||||
boolean a();
|
||||
|
||||
MenuItemImpl getItemData();
|
||||
}
|
||||
|
||||
void a(MenuBuilder menuBuilder);
|
||||
}
|
25
sources/androidx/appcompat/view/menu/MenuWrapperFactory.java
Normal file
25
sources/androidx/appcompat/view/menu/MenuWrapperFactory.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import androidx.core.internal.view.SupportMenu;
|
||||
import androidx.core.internal.view.SupportMenuItem;
|
||||
import androidx.core.internal.view.SupportSubMenu;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MenuWrapperFactory {
|
||||
public static Menu a(Context context, SupportMenu supportMenu) {
|
||||
return new MenuWrapperICS(context, supportMenu);
|
||||
}
|
||||
|
||||
public static MenuItem a(Context context, SupportMenuItem supportMenuItem) {
|
||||
return Build.VERSION.SDK_INT >= 16 ? new MenuItemWrapperJB(context, supportMenuItem) : new MenuItemWrapperICS(context, supportMenuItem);
|
||||
}
|
||||
|
||||
public static SubMenu a(Context context, SupportSubMenu supportSubMenu) {
|
||||
return new SubMenuWrapperICS(context, supportSubMenu);
|
||||
}
|
||||
}
|
148
sources/androidx/appcompat/view/menu/MenuWrapperICS.java
Normal file
148
sources/androidx/appcompat/view/menu/MenuWrapperICS.java
Normal file
@@ -0,0 +1,148 @@
|
||||
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 */
|
||||
class MenuWrapperICS extends BaseMenuWrapper<SupportMenu> implements Menu {
|
||||
MenuWrapperICS(Context context, SupportMenu supportMenu) {
|
||||
super(context, supportMenu);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem add(CharSequence charSequence) {
|
||||
return a(((SupportMenu) this.a).add(charSequence));
|
||||
}
|
||||
|
||||
@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 = ((SupportMenu) this.a).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] = a(menuItemArr2[i5]);
|
||||
}
|
||||
}
|
||||
return addIntentOptions;
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public SubMenu addSubMenu(CharSequence charSequence) {
|
||||
return a(((SupportMenu) this.a).addSubMenu(charSequence));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void clear() {
|
||||
b();
|
||||
((SupportMenu) this.a).clear();
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void close() {
|
||||
((SupportMenu) this.a).close();
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem findItem(int i) {
|
||||
return a(((SupportMenu) this.a).findItem(i));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem getItem(int i) {
|
||||
return a(((SupportMenu) this.a).getItem(i));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public boolean hasVisibleItems() {
|
||||
return ((SupportMenu) this.a).hasVisibleItems();
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public boolean isShortcutKey(int i, KeyEvent keyEvent) {
|
||||
return ((SupportMenu) this.a).isShortcutKey(i, keyEvent);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public boolean performIdentifierAction(int i, int i2) {
|
||||
return ((SupportMenu) this.a).performIdentifierAction(i, i2);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public boolean performShortcut(int i, KeyEvent keyEvent, int i2) {
|
||||
return ((SupportMenu) this.a).performShortcut(i, keyEvent, i2);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void removeGroup(int i) {
|
||||
a(i);
|
||||
((SupportMenu) this.a).removeGroup(i);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void removeItem(int i) {
|
||||
b(i);
|
||||
((SupportMenu) this.a).removeItem(i);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setGroupCheckable(int i, boolean z, boolean z2) {
|
||||
((SupportMenu) this.a).setGroupCheckable(i, z, z2);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setGroupEnabled(int i, boolean z) {
|
||||
((SupportMenu) this.a).setGroupEnabled(i, z);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setGroupVisible(int i, boolean z) {
|
||||
((SupportMenu) this.a).setGroupVisible(i, z);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public void setQwertyMode(boolean z) {
|
||||
((SupportMenu) this.a).setQwertyMode(z);
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public int size() {
|
||||
return ((SupportMenu) this.a).size();
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem add(int i) {
|
||||
return a(((SupportMenu) this.a).add(i));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public SubMenu addSubMenu(int i) {
|
||||
return a(((SupportMenu) this.a).addSubMenu(i));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem add(int i, int i2, int i3, CharSequence charSequence) {
|
||||
return a(((SupportMenu) this.a).add(i, i2, i3, charSequence));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public SubMenu addSubMenu(int i, int i2, int i3, CharSequence charSequence) {
|
||||
return a(((SupportMenu) this.a).addSubMenu(i, i2, i3, charSequence));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public MenuItem add(int i, int i2, int i3, int i4) {
|
||||
return a(((SupportMenu) this.a).add(i, i2, i3, i4));
|
||||
}
|
||||
|
||||
@Override // android.view.Menu
|
||||
public SubMenu addSubMenu(int i, int i2, int i3, int i4) {
|
||||
return a(((SupportMenu) this.a).addSubMenu(i, i2, i3, i4));
|
||||
}
|
||||
}
|
14
sources/androidx/appcompat/view/menu/ShowableListMenu.java
Normal file
14
sources/androidx/appcompat/view/menu/ShowableListMenu.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.widget.ListView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ShowableListMenu {
|
||||
void a();
|
||||
|
||||
boolean c();
|
||||
|
||||
ListView d();
|
||||
|
||||
void dismiss();
|
||||
}
|
284
sources/androidx/appcompat/view/menu/StandardMenuPopup.java
Normal file
284
sources/androidx/appcompat/view/menu/StandardMenuPopup.java
Normal file
@@ -0,0 +1,284 @@
|
||||
package androidx.appcompat.view.menu;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
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.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.R$dimen;
|
||||
import androidx.appcompat.R$layout;
|
||||
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 v = R$layout.abc_popup_menu_item_layout;
|
||||
private final Context b;
|
||||
private final MenuBuilder c;
|
||||
private final MenuAdapter d;
|
||||
private final boolean e;
|
||||
private final int f;
|
||||
private final int g;
|
||||
private final int h;
|
||||
final MenuPopupWindow i;
|
||||
private PopupWindow.OnDismissListener l;
|
||||
private View m;
|
||||
View n;
|
||||
private MenuPresenter.Callback o;
|
||||
ViewTreeObserver p;
|
||||
private boolean q;
|
||||
private boolean r;
|
||||
private int s;
|
||||
private boolean u;
|
||||
final ViewTreeObserver.OnGlobalLayoutListener j = new ViewTreeObserver.OnGlobalLayoutListener() { // from class: androidx.appcompat.view.menu.StandardMenuPopup.1
|
||||
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
|
||||
public void onGlobalLayout() {
|
||||
if (!StandardMenuPopup.this.c() || StandardMenuPopup.this.i.k()) {
|
||||
return;
|
||||
}
|
||||
View view = StandardMenuPopup.this.n;
|
||||
if (view == null || !view.isShown()) {
|
||||
StandardMenuPopup.this.dismiss();
|
||||
} else {
|
||||
StandardMenuPopup.this.i.a();
|
||||
}
|
||||
}
|
||||
};
|
||||
private final View.OnAttachStateChangeListener k = 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) {
|
||||
ViewTreeObserver viewTreeObserver = StandardMenuPopup.this.p;
|
||||
if (viewTreeObserver != null) {
|
||||
if (!viewTreeObserver.isAlive()) {
|
||||
StandardMenuPopup.this.p = view.getViewTreeObserver();
|
||||
}
|
||||
StandardMenuPopup standardMenuPopup = StandardMenuPopup.this;
|
||||
standardMenuPopup.p.removeGlobalOnLayoutListener(standardMenuPopup.j);
|
||||
}
|
||||
view.removeOnAttachStateChangeListener(this);
|
||||
}
|
||||
};
|
||||
private int t = 0;
|
||||
|
||||
public StandardMenuPopup(Context context, MenuBuilder menuBuilder, View view, int i, int i2, boolean z) {
|
||||
this.b = context;
|
||||
this.c = menuBuilder;
|
||||
this.e = z;
|
||||
this.d = new MenuAdapter(menuBuilder, LayoutInflater.from(context), this.e, v);
|
||||
this.g = i;
|
||||
this.h = i2;
|
||||
Resources resources = context.getResources();
|
||||
this.f = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R$dimen.abc_config_prefDialogWidth));
|
||||
this.m = view;
|
||||
this.i = new MenuPopupWindow(this.b, null, this.g, this.h);
|
||||
menuBuilder.a(this, context);
|
||||
}
|
||||
|
||||
private boolean g() {
|
||||
View view;
|
||||
if (c()) {
|
||||
return true;
|
||||
}
|
||||
if (this.q || (view = this.m) == null) {
|
||||
return false;
|
||||
}
|
||||
this.n = view;
|
||||
this.i.a((PopupWindow.OnDismissListener) this);
|
||||
this.i.a((AdapterView.OnItemClickListener) this);
|
||||
this.i.a(true);
|
||||
View view2 = this.n;
|
||||
boolean z = this.p == null;
|
||||
this.p = view2.getViewTreeObserver();
|
||||
if (z) {
|
||||
this.p.addOnGlobalLayoutListener(this.j);
|
||||
}
|
||||
view2.addOnAttachStateChangeListener(this.k);
|
||||
this.i.a(view2);
|
||||
this.i.c(this.t);
|
||||
if (!this.r) {
|
||||
this.s = MenuPopup.a(this.d, null, this.b, this.f);
|
||||
this.r = true;
|
||||
}
|
||||
this.i.b(this.s);
|
||||
this.i.e(2);
|
||||
this.i.a(f());
|
||||
this.i.a();
|
||||
ListView d = this.i.d();
|
||||
d.setOnKeyListener(this);
|
||||
if (this.u && this.c.h() != null) {
|
||||
FrameLayout frameLayout = (FrameLayout) LayoutInflater.from(this.b).inflate(R$layout.abc_popup_menu_header_item_layout, (ViewGroup) d, false);
|
||||
TextView textView = (TextView) frameLayout.findViewById(R.id.title);
|
||||
if (textView != null) {
|
||||
textView.setText(this.c.h());
|
||||
}
|
||||
frameLayout.setEnabled(false);
|
||||
d.addHeaderView(frameLayout, null, false);
|
||||
}
|
||||
this.i.a((ListAdapter) this.d);
|
||||
this.i.a();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void a(int i) {
|
||||
this.t = i;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void a(MenuBuilder menuBuilder) {
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void b(boolean z) {
|
||||
this.d.a(z);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean b() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
||||
public boolean c() {
|
||||
return !this.q && this.i.c();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
||||
public ListView d() {
|
||||
return this.i.d();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
||||
public void dismiss() {
|
||||
if (c()) {
|
||||
this.i.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.PopupWindow.OnDismissListener
|
||||
public void onDismiss() {
|
||||
this.q = true;
|
||||
this.c.close();
|
||||
ViewTreeObserver viewTreeObserver = this.p;
|
||||
if (viewTreeObserver != null) {
|
||||
if (!viewTreeObserver.isAlive()) {
|
||||
this.p = this.n.getViewTreeObserver();
|
||||
}
|
||||
this.p.removeGlobalOnLayoutListener(this.j);
|
||||
this.p = null;
|
||||
}
|
||||
this.n.removeOnAttachStateChangeListener(this.k);
|
||||
PopupWindow.OnDismissListener onDismissListener = this.l;
|
||||
if (onDismissListener != null) {
|
||||
onDismissListener.onDismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@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 void a() {
|
||||
if (!g()) {
|
||||
throw new IllegalStateException("StandardMenuPopup cannot be used without an anchor");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void b(int i) {
|
||||
this.i.d(i);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void c(int i) {
|
||||
this.i.h(i);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void c(boolean z) {
|
||||
this.u = z;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(boolean z) {
|
||||
this.r = false;
|
||||
MenuAdapter menuAdapter = this.d;
|
||||
if (menuAdapter != null) {
|
||||
menuAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(MenuPresenter.Callback callback) {
|
||||
this.o = callback;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public boolean a(SubMenuBuilder subMenuBuilder) {
|
||||
if (subMenuBuilder.hasVisibleItems()) {
|
||||
MenuPopupHelper menuPopupHelper = new MenuPopupHelper(this.b, subMenuBuilder, this.n, this.e, this.g, this.h);
|
||||
menuPopupHelper.a(this.o);
|
||||
menuPopupHelper.a(MenuPopup.b(subMenuBuilder));
|
||||
menuPopupHelper.a(this.l);
|
||||
this.l = null;
|
||||
this.c.a(false);
|
||||
int g = this.i.g();
|
||||
int h = this.i.h();
|
||||
if ((Gravity.getAbsoluteGravity(this.t, ViewCompat.k(this.m)) & 7) == 5) {
|
||||
g += this.m.getWidth();
|
||||
}
|
||||
if (menuPopupHelper.a(g, h)) {
|
||||
MenuPresenter.Callback callback = this.o;
|
||||
if (callback == null) {
|
||||
return true;
|
||||
}
|
||||
callback.a(subMenuBuilder);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPresenter
|
||||
public void a(MenuBuilder menuBuilder, boolean z) {
|
||||
if (menuBuilder != this.c) {
|
||||
return;
|
||||
}
|
||||
dismiss();
|
||||
MenuPresenter.Callback callback = this.o;
|
||||
if (callback != null) {
|
||||
callback.a(menuBuilder, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void a(View view) {
|
||||
this.m = view;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuPopup
|
||||
public void a(PopupWindow.OnDismissListener onDismissListener) {
|
||||
this.l = onDismissListener;
|
||||
}
|
||||
}
|
132
sources/androidx/appcompat/view/menu/SubMenuBuilder.java
Normal file
132
sources/androidx/appcompat/view/menu/SubMenuBuilder.java
Normal file
@@ -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 MenuBuilder B;
|
||||
private MenuItemImpl C;
|
||||
|
||||
public SubMenuBuilder(Context context, MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
||||
super(context);
|
||||
this.B = menuBuilder;
|
||||
this.C = menuItemImpl;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
public void a(MenuBuilder.Callback callback) {
|
||||
this.B.a(callback);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
public boolean b(MenuItemImpl menuItemImpl) {
|
||||
return this.B.b(menuItemImpl);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
public String d() {
|
||||
MenuItemImpl menuItemImpl = this.C;
|
||||
int itemId = menuItemImpl != null ? menuItemImpl.getItemId() : 0;
|
||||
if (itemId == 0) {
|
||||
return null;
|
||||
}
|
||||
return super.d() + ":" + itemId;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public MenuItem getItem() {
|
||||
return this.C;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
public MenuBuilder m() {
|
||||
return this.B.m();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
public boolean o() {
|
||||
return this.B.o();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
public boolean p() {
|
||||
return this.B.p();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
public boolean q() {
|
||||
return this.B.q();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder, android.view.Menu
|
||||
public void setGroupDividerEnabled(boolean z) {
|
||||
this.B.setGroupDividerEnabled(z);
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderIcon(Drawable drawable) {
|
||||
super.a(drawable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderTitle(CharSequence charSequence) {
|
||||
super.a(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderView(View view) {
|
||||
super.a(view);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setIcon(Drawable drawable) {
|
||||
this.C.setIcon(drawable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder, android.view.Menu
|
||||
public void setQwertyMode(boolean z) {
|
||||
this.B.setQwertyMode(z);
|
||||
}
|
||||
|
||||
public Menu t() {
|
||||
return this.B;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
boolean a(MenuBuilder menuBuilder, MenuItem menuItem) {
|
||||
return super.a(menuBuilder, menuItem) || this.B.a(menuBuilder, menuItem);
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderIcon(int i) {
|
||||
super.d(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderTitle(int i) {
|
||||
super.e(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setIcon(int i) {
|
||||
this.C.setIcon(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.view.menu.MenuBuilder
|
||||
public boolean a(MenuItemImpl menuItemImpl) {
|
||||
return this.B.a(menuItemImpl);
|
||||
}
|
||||
}
|
71
sources/androidx/appcompat/view/menu/SubMenuWrapperICS.java
Normal file
71
sources/androidx/appcompat/view/menu/SubMenuWrapperICS.java
Normal file
@@ -0,0 +1,71 @@
|
||||
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 {
|
||||
SubMenuWrapperICS(Context context, SupportSubMenu supportSubMenu) {
|
||||
super(context, supportSubMenu);
|
||||
}
|
||||
|
||||
public SupportSubMenu c() {
|
||||
return (SupportSubMenu) this.a;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public void clearHeader() {
|
||||
c().clearHeader();
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public MenuItem getItem() {
|
||||
return a(c().getItem());
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderIcon(int i) {
|
||||
c().setHeaderIcon(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderTitle(int i) {
|
||||
c().setHeaderTitle(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderView(View view) {
|
||||
c().setHeaderView(view);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setIcon(int i) {
|
||||
c().setIcon(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderIcon(Drawable drawable) {
|
||||
c().setHeaderIcon(drawable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setHeaderTitle(CharSequence charSequence) {
|
||||
c().setHeaderTitle(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.view.SubMenu
|
||||
public SubMenu setIcon(Drawable drawable) {
|
||||
c().setIcon(drawable);
|
||||
return this;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user