what-the-bank/sources/com/google/android/material/internal/NavigationMenuItemView.java

217 lines
7.4 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.material.internal;
import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.CheckedTextView;
import android.widget.FrameLayout;
import androidx.appcompat.view.menu.MenuItemImpl;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import o.C17052tZT;
import o.C6286cOZ;
import o.SYO;
import o.Sya;
import o.URz;
import o.kVs;
import o.yZt;
/* loaded from: classes2.dex */
public class NavigationMenuItemView extends ForegroundLinearLayout implements Sya.HBt {
private static final int[] e = {R.attr.state_checked};
private final yZt a;
private Drawable b;
private FrameLayout c;
boolean d;
private boolean f;
private MenuItemImpl g;
private int h;
private final CheckedTextView i;
private boolean j;
@Override // o.Sya.HBt
public final boolean b() {
return false;
}
public void setShortcut(boolean z, char c) {
}
public NavigationMenuItemView(Context context) {
this(context, null);
}
public NavigationMenuItemView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public NavigationMenuItemView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
yZt yzt = new yZt(this) { // from class: com.google.android.material.internal.NavigationMenuItemView.1
private NavigationMenuItemView e;
{
this.e = this;
}
@Override // o.yZt
public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.c(this.e.d);
}
};
this.a = yzt;
setOrientation(0);
LayoutInflater.from(context).inflate(C17052tZT.tOB.design_navigation_menu_item, (ViewGroup) this, true);
setIconSize(context.getResources().getDimensionPixelSize(C17052tZT.HBt.design_navigation_icon_size));
CheckedTextView checkedTextView = (CheckedTextView) findViewById(C17052tZT.ZqN.design_menu_item_text);
this.i = checkedTextView;
checkedTextView.setDuplicateParentStateEnabled(true);
ViewCompat.e(checkedTextView, yzt);
}
@Override // o.Sya.HBt
public final void c(MenuItemImpl menuItemImpl) {
StateListDrawable stateListDrawable;
this.g = menuItemImpl;
if (menuItemImpl.getItemId() > 0) {
setId(menuItemImpl.getItemId());
}
setVisibility(menuItemImpl.isVisible() ? 0 : 8);
if (getBackground() == null) {
TypedValue typedValue = new TypedValue();
if (getContext().getTheme().resolveAttribute(SYO.IeS.colorControlHighlight, typedValue, true)) {
stateListDrawable = new StateListDrawable();
stateListDrawable.addState(e, new ColorDrawable(typedValue.data));
stateListDrawable.addState(EMPTY_STATE_SET, new ColorDrawable(0));
} else {
stateListDrawable = null;
}
ViewCompat.sn_(this, stateListDrawable);
}
setCheckable(menuItemImpl.isCheckable());
setChecked(menuItemImpl.isChecked());
setEnabled(menuItemImpl.isEnabled());
setTitle(menuItemImpl.getTitle());
setIcon(menuItemImpl.getIcon());
View actionView = menuItemImpl.getActionView();
if (actionView != null) {
if (this.c == null) {
this.c = (FrameLayout) ((ViewStub) findViewById(C17052tZT.ZqN.design_menu_item_action_area_stub)).inflate();
}
this.c.removeAllViews();
this.c.addView(actionView);
}
setContentDescription(menuItemImpl.getContentDescription());
C6286cOZ.e(this, menuItemImpl.getTooltipText());
if (this.g.getTitle() == null && this.g.getIcon() == null && this.g.getActionView() != null) {
this.i.setVisibility(8);
FrameLayout frameLayout = this.c;
if (frameLayout != null) {
LinearLayoutCompat.RVV rvv = (LinearLayoutCompat.RVV) frameLayout.getLayoutParams();
((ViewGroup.LayoutParams) rvv).width = -1;
this.c.setLayoutParams(rvv);
return;
}
return;
}
this.i.setVisibility(0);
FrameLayout frameLayout2 = this.c;
if (frameLayout2 != null) {
LinearLayoutCompat.RVV rvv2 = (LinearLayoutCompat.RVV) frameLayout2.getLayoutParams();
((ViewGroup.LayoutParams) rvv2).width = -2;
this.c.setLayoutParams(rvv2);
}
}
public void setTitle(CharSequence charSequence) {
this.i.setText(charSequence);
}
public void setCheckable(boolean z) {
refreshDrawableState();
if (this.d != z) {
this.d = z;
this.a.sendAccessibilityEvent(this.i, 2048);
}
}
public void setChecked(boolean z) {
refreshDrawableState();
this.i.setChecked(z);
CheckedTextView checkedTextView = this.i;
checkedTextView.setTypeface(checkedTextView.getTypeface(), z ? 1 : 0);
}
public void setIcon(Drawable drawable) {
if (drawable != null) {
int i = this.h;
drawable.setBounds(0, 0, i, i);
} else if (this.j) {
if (this.b == null) {
Drawable nZ_ = kVs.nZ_(getResources(), C17052tZT.LWm.navigation_empty_icon, getContext().getTheme());
this.b = nZ_;
if (nZ_ != null) {
int i2 = this.h;
nZ_.setBounds(0, 0, i2, i2);
}
}
drawable = this.b;
}
URz.vZ_(this.i, drawable, null, null, null);
}
@Override // android.view.ViewGroup, android.view.View
protected int[] onCreateDrawableState(int i) {
int[] onCreateDrawableState = super.onCreateDrawableState(i + 1);
MenuItemImpl menuItemImpl = this.g;
if (menuItemImpl != null && menuItemImpl.isCheckable() && this.g.isChecked()) {
mergeDrawableStates(onCreateDrawableState, e);
}
return onCreateDrawableState;
}
public void setTextAppearance(int i) {
URz.we_(this.i, i);
}
public void setTextColor(ColorStateList colorStateList) {
this.i.setTextColor(colorStateList);
}
public void setHorizontalPadding(int i) {
setPadding(i, getPaddingTop(), i, getPaddingBottom());
}
public void setIconPadding(int i) {
this.i.setCompoundDrawablePadding(i);
}
public void setMaxLines(int i) {
this.i.setMaxLines(i);
}
public void setNeedsEmptyIcon(boolean z) {
this.j = z;
}
public void setIconSize(int i) {
this.h = i;
}
@Override // o.Sya.HBt
public final MenuItemImpl a() {
return this.g;
}
}