what-the-bank/sources/androidx/appcompat/widget/ActionMenuView.java

684 lines
24 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package androidx.appcompat.widget;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.LinearLayout;
import androidx.appcompat.view.menu.ActionMenuItemView;
import androidx.appcompat.view.menu.MenuItemImpl;
import androidx.appcompat.widget.ActionMenuPresenter;
import androidx.appcompat.widget.LinearLayoutCompat;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.lang.ref.WeakReference;
import o.InterfaceC15933jjG;
import o.NoP;
import o.Sya;
import o.mxt;
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
/* loaded from: classes.dex */
public class ActionMenuView extends LinearLayoutCompat implements NoP.LWm, Sya {
private boolean a;
public ActionMenuPresenter b;
private int c;
NoP d;
public boolean e;
private int f;
private int g;
private int i;
private Context j;
private InterfaceC15933jjG.Sts mActionMenuPresenterCallback;
NoP.Sts mMenuBuilderCallback;
OnMenuItemClickListener mOnMenuItemClickListener;
/* loaded from: classes.dex */
public interface HBt {
boolean c();
boolean d();
}
/* loaded from: classes.dex */
public interface OnMenuItemClickListener {
boolean onMenuItemClick(MenuItem menuItem);
}
@Override // android.view.View
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
return false;
}
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup
protected /* synthetic */ ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
return fm_(layoutParams);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.appcompat.widget.LinearLayoutCompat
/* renamed from: iq_ */
public /* synthetic */ LinearLayoutCompat.RVV generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
return fm_(layoutParams);
}
public ActionMenuView(Context context) {
this(context, null);
}
public ActionMenuView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
setBaselineAligned(false);
float f = context.getResources().getDisplayMetrics().density;
this.f = (int) (56.0f * f);
this.i = (int) (f * 4.0f);
this.j = context;
this.g = 0;
}
public void setPopupTheme(int i) {
if (this.g != i) {
this.g = i;
if (i == 0) {
this.j = getContext();
} else {
this.j = new ContextThemeWrapper(getContext(), i);
}
}
}
@Override // android.view.View
public void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
ActionMenuPresenter actionMenuPresenter = this.b;
if (actionMenuPresenter != null) {
actionMenuPresenter.a(false);
if (this.b.d()) {
this.b.c();
this.b.b();
}
}
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Type inference failed for: r6v17 */
/* JADX WARN: Type inference failed for: r6v18, types: [int, boolean] */
/* JADX WARN: Type inference failed for: r6v38 */
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.View
public void onMeasure(int i, int i2) {
int i3;
int i4;
int i5;
boolean z;
int i6;
?? r6;
int i7;
int i8;
int i9;
NoP noP;
boolean z2 = this.a;
boolean z3 = View.MeasureSpec.getMode(i) == 1073741824;
this.a = z3;
if (z2 != z3) {
this.c = 0;
}
int size = View.MeasureSpec.getSize(i);
if (this.a && (noP = this.d) != null && size != this.c) {
this.c = size;
noP.c(true);
}
int childCount = getChildCount();
if (!this.a || childCount <= 0) {
for (int i10 = 0; i10 < childCount; i10++) {
Sts sts = (Sts) getChildAt(i10).getLayoutParams();
((ViewGroup.MarginLayoutParams) sts).rightMargin = 0;
((ViewGroup.MarginLayoutParams) sts).leftMargin = 0;
}
super.onMeasure(i, i2);
return;
}
int mode = View.MeasureSpec.getMode(i2);
int size2 = View.MeasureSpec.getSize(i);
int size3 = View.MeasureSpec.getSize(i2);
int paddingLeft = getPaddingLeft();
int paddingRight = getPaddingRight();
int paddingTop = getPaddingTop() + getPaddingBottom();
int childMeasureSpec = getChildMeasureSpec(i2, paddingTop, -2);
int i11 = size2 - (paddingLeft + paddingRight);
int i12 = this.f;
int i13 = i11 / i12;
if (i13 == 0) {
setMeasuredDimension(i11, 0);
return;
}
int i14 = i12 + ((i11 % i12) / i13);
int childCount2 = getChildCount();
int i15 = 0;
int i16 = 0;
int i17 = 0;
boolean z4 = false;
int i18 = 0;
int i19 = 0;
long j = 0;
while (i17 < childCount2) {
View childAt = getChildAt(i17);
if (childAt.getVisibility() == 8) {
i8 = mode;
i7 = i11;
i6 = size3;
} else {
boolean z5 = childAt instanceof ActionMenuItemView;
int i20 = i15 + 1;
if (z5) {
int i21 = this.i;
i6 = size3;
r6 = 0;
childAt.setPadding(i21, 0, i21, 0);
} else {
i6 = size3;
r6 = 0;
}
Sts sts2 = (Sts) childAt.getLayoutParams();
sts2.a = r6;
sts2.c = r6;
sts2.e = r6;
sts2.b = r6;
((ViewGroup.MarginLayoutParams) sts2).leftMargin = r6;
((ViewGroup.MarginLayoutParams) sts2).rightMargin = r6;
sts2.g = z5 && (TextUtils.isEmpty(((ActionMenuItemView) childAt).getText()) ^ true);
int i22 = sts2.d ? 1 : i13;
Sts sts3 = (Sts) childAt.getLayoutParams();
i7 = i11;
i8 = mode;
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(childMeasureSpec) - paddingTop, View.MeasureSpec.getMode(childMeasureSpec));
ActionMenuItemView actionMenuItemView = z5 ? (ActionMenuItemView) childAt : null;
boolean z6 = actionMenuItemView != null && (TextUtils.isEmpty(actionMenuItemView.getText()) ^ true);
if (i22 <= 0 || (z6 && i22 < 2)) {
i9 = 0;
} else {
childAt.measure(View.MeasureSpec.makeMeasureSpec(i22 * i14, PKIFailureInfo.systemUnavail), makeMeasureSpec);
int measuredWidth = childAt.getMeasuredWidth();
i9 = measuredWidth / i14;
if (measuredWidth % i14 != 0) {
i9++;
}
if (z6 && i9 < 2) {
i9 = 2;
}
}
sts3.b = !sts3.d && z6;
sts3.e = i9;
childAt.measure(View.MeasureSpec.makeMeasureSpec(i14 * i9, 1073741824), makeMeasureSpec);
i19 = Math.max(i19, i9);
if (sts2.b) {
i16++;
}
if (sts2.d) {
z4 = true;
}
i13 -= i9;
i18 = Math.max(i18, childAt.getMeasuredHeight());
if (i9 == 1) {
j |= 1 << i17;
}
i15 = i20;
}
i17++;
size3 = i6;
i11 = i7;
mode = i8;
}
int i23 = mode;
int i24 = i11;
int i25 = size3;
int i26 = i18;
int i27 = i19;
boolean z7 = z4 && i15 == 2;
boolean z8 = false;
while (i16 > 0 && i13 > 0) {
int i28 = Integer.MAX_VALUE;
int i29 = 0;
int i30 = 0;
long j2 = 0;
while (i29 < childCount2) {
Sts sts4 = (Sts) getChildAt(i29).getLayoutParams();
int i31 = i26;
if (sts4.b) {
if (sts4.e < i28) {
j2 = 1 << i29;
i28 = sts4.e;
i30 = 1;
} else if (sts4.e == i28) {
j2 |= 1 << i29;
i30++;
}
}
i29++;
i26 = i31;
}
i3 = i26;
j |= j2;
if (i30 > i13) {
break;
}
int i32 = 0;
while (i32 < childCount2) {
View childAt2 = getChildAt(i32);
Sts sts5 = (Sts) childAt2.getLayoutParams();
int i33 = i16;
long j3 = 1 << i32;
if ((j2 & j3) == 0) {
if (sts5.e == i28 + 1) {
j |= j3;
}
z = z7;
} else {
if (z7 && sts5.g && i13 == 1) {
int i34 = this.i;
z = z7;
childAt2.setPadding(i34 + i14, 0, i34, 0);
} else {
z = z7;
}
sts5.e++;
sts5.a = true;
i13--;
}
i32++;
i16 = i33;
z7 = z;
}
i26 = i3;
z8 = true;
}
i3 = i26;
boolean z9 = !z4 && i15 == 1;
if (i13 > 0 && j != 0 && (i13 < i15 - 1 || z9 || i27 > 1)) {
float bitCount = Long.bitCount(j);
if (!z9) {
if ((j & 1) != 0 && !((Sts) getChildAt(0).getLayoutParams()).g) {
bitCount -= 0.5f;
}
int i35 = childCount2 - 1;
if ((j & (1 << i35)) != 0 && !((Sts) getChildAt(i35).getLayoutParams()).g) {
bitCount -= 0.5f;
}
}
int i36 = bitCount > BitmapDescriptorFactory.HUE_RED ? (int) ((i13 * i14) / bitCount) : 0;
for (int i37 = 0; i37 < childCount2; i37++) {
if ((j & (1 << i37)) != 0) {
View childAt3 = getChildAt(i37);
Sts sts6 = (Sts) childAt3.getLayoutParams();
if (childAt3 instanceof ActionMenuItemView) {
sts6.c = i36;
sts6.a = true;
if (i37 == 0 && !sts6.g) {
((ViewGroup.MarginLayoutParams) sts6).leftMargin = (-i36) / 2;
}
z8 = true;
} else if (sts6.d) {
sts6.c = i36;
sts6.a = true;
((ViewGroup.MarginLayoutParams) sts6).rightMargin = (-i36) / 2;
z8 = true;
} else {
if (i37 != 0) {
((ViewGroup.MarginLayoutParams) sts6).leftMargin = i36 / 2;
}
if (i37 != childCount2 - 1) {
((ViewGroup.MarginLayoutParams) sts6).rightMargin = i36 / 2;
}
}
}
}
}
if (z8) {
for (int i38 = 0; i38 < childCount2; i38++) {
View childAt4 = getChildAt(i38);
Sts sts7 = (Sts) childAt4.getLayoutParams();
if (sts7.a) {
childAt4.measure(View.MeasureSpec.makeMeasureSpec((sts7.e * i14) + sts7.c, 1073741824), childMeasureSpec);
}
}
}
if (i23 != 1073741824) {
i5 = i24;
i4 = i3;
} else {
i4 = i25;
i5 = i24;
}
setMeasuredDimension(i5, i4);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup, android.view.View
public void onLayout(boolean z, int i, int i2, int i3, int i4) {
int width;
int i5;
if (!this.a) {
super.onLayout(z, i, i2, i3, i4);
return;
}
int childCount = getChildCount();
int i6 = (i4 - i2) / 2;
int d = d();
int i7 = i3 - i;
int paddingRight = (i7 - getPaddingRight()) - getPaddingLeft();
boolean b = mxt.b(this);
int i8 = 0;
int i9 = 0;
for (int i10 = 0; i10 < childCount; i10++) {
View childAt = getChildAt(i10);
if (childAt.getVisibility() != 8) {
Sts sts = (Sts) childAt.getLayoutParams();
if (sts.d) {
int measuredWidth = childAt.getMeasuredWidth();
if (d(i10)) {
measuredWidth += d;
}
int measuredHeight = childAt.getMeasuredHeight();
if (b) {
i5 = getPaddingLeft() + ((ViewGroup.MarginLayoutParams) sts).leftMargin;
width = i5 + measuredWidth;
} else {
width = (getWidth() - getPaddingRight()) - ((ViewGroup.MarginLayoutParams) sts).rightMargin;
i5 = width - measuredWidth;
}
int i11 = i6 - (measuredHeight / 2);
childAt.layout(i5, i11, width, measuredHeight + i11);
paddingRight -= measuredWidth;
i8 = 1;
} else {
paddingRight -= (childAt.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) sts).leftMargin) + ((ViewGroup.MarginLayoutParams) sts).rightMargin;
d(i10);
i9++;
}
}
}
if (childCount == 1 && i8 == 0) {
View childAt2 = getChildAt(0);
int measuredWidth2 = childAt2.getMeasuredWidth();
int measuredHeight2 = childAt2.getMeasuredHeight();
int i12 = (i7 / 2) - (measuredWidth2 / 2);
int i13 = i6 - (measuredHeight2 / 2);
childAt2.layout(i12, i13, measuredWidth2 + i12, measuredHeight2 + i13);
return;
}
int i14 = i9 - (i8 ^ 1);
int max = Math.max(0, i14 > 0 ? paddingRight / i14 : 0);
if (b) {
int width2 = getWidth() - getPaddingRight();
for (int i15 = 0; i15 < childCount; i15++) {
View childAt3 = getChildAt(i15);
Sts sts2 = (Sts) childAt3.getLayoutParams();
if (childAt3.getVisibility() != 8 && !sts2.d) {
int i16 = width2 - ((ViewGroup.MarginLayoutParams) sts2).rightMargin;
int measuredWidth3 = childAt3.getMeasuredWidth();
int measuredHeight3 = childAt3.getMeasuredHeight();
int i17 = i6 - (measuredHeight3 / 2);
childAt3.layout(i16 - measuredWidth3, i17, i16, measuredHeight3 + i17);
width2 = i16 - ((measuredWidth3 + ((ViewGroup.MarginLayoutParams) sts2).leftMargin) + max);
}
}
return;
}
int paddingLeft = getPaddingLeft();
for (int i18 = 0; i18 < childCount; i18++) {
View childAt4 = getChildAt(i18);
Sts sts3 = (Sts) childAt4.getLayoutParams();
if (childAt4.getVisibility() != 8 && !sts3.d) {
int i19 = paddingLeft + ((ViewGroup.MarginLayoutParams) sts3).leftMargin;
int measuredWidth4 = childAt4.getMeasuredWidth();
int measuredHeight4 = childAt4.getMeasuredHeight();
int i20 = i6 - (measuredHeight4 / 2);
childAt4.layout(i19, i20, i19 + measuredWidth4, measuredHeight4 + i20);
paddingLeft = i19 + measuredWidth4 + ((ViewGroup.MarginLayoutParams) sts3).rightMargin + max;
}
}
}
@Override // android.view.ViewGroup, android.view.View
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
ActionMenuPresenter actionMenuPresenter = this.b;
if (actionMenuPresenter != null) {
actionMenuPresenter.c();
ActionMenuPresenter.HBt hBt = actionMenuPresenter.j;
if (hBt != null) {
hBt.a();
}
}
}
public void setOverflowIcon(Drawable drawable) {
fp_();
ActionMenuPresenter actionMenuPresenter = this.b;
ActionMenuPresenter.OverflowMenuButton overflowMenuButton = actionMenuPresenter.n;
if (overflowMenuButton != null) {
overflowMenuButton.setImageDrawable(drawable);
} else {
actionMenuPresenter.k = true;
actionMenuPresenter.m = drawable;
}
}
/* JADX INFO: Access modifiers changed from: protected */
public static Sts fm_(ViewGroup.LayoutParams layoutParams) {
Sts sts;
if (layoutParams != null) {
if (layoutParams instanceof Sts) {
sts = new Sts((Sts) layoutParams);
} else {
sts = new Sts(layoutParams);
}
if (((LinearLayout.LayoutParams) sts).gravity <= 0) {
((LinearLayout.LayoutParams) sts).gravity = 16;
}
return sts;
}
Sts sts2 = new Sts();
((LinearLayout.LayoutParams) sts2).gravity = 16;
return sts2;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup
public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
return layoutParams instanceof Sts;
}
public final Menu fp_() {
if (this.d == null) {
Context context = getContext();
NoP noP = new NoP(context);
this.d = noP;
noP.d(new RVV(this));
ActionMenuPresenter actionMenuPresenter = new ActionMenuPresenter(context);
this.b = actionMenuPresenter;
actionMenuPresenter.r = true;
actionMenuPresenter.p = true;
ActionMenuPresenter actionMenuPresenter2 = this.b;
InterfaceC15933jjG.Sts sts = this.mActionMenuPresenterCallback;
if (sts == null) {
sts = new IeS();
}
actionMenuPresenter2.a = sts;
NoP noP2 = this.d;
ActionMenuPresenter actionMenuPresenter3 = this.b;
Context context2 = this.j;
noP2.r.add(new WeakReference<>(actionMenuPresenter3));
actionMenuPresenter3.a(context2, noP2);
noP2.f = true;
ActionMenuPresenter actionMenuPresenter4 = this.b;
actionMenuPresenter4.b = this;
this.d = actionMenuPresenter4.d;
}
return this.d;
}
private boolean d(int i) {
boolean z = false;
if (i == 0) {
return false;
}
KeyEvent.Callback childAt = getChildAt(i - 1);
KeyEvent.Callback childAt2 = getChildAt(i);
if (i < getChildCount() && (childAt instanceof HBt)) {
z = ((HBt) childAt).d();
}
return (i <= 0 || !(childAt2 instanceof HBt)) ? z : z | ((HBt) childAt2).c();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public class RVV implements NoP.Sts {
final ActionMenuView b;
RVV(ActionMenuView actionMenuView) {
this.b = actionMenuView;
}
@Override // o.NoP.Sts
public final boolean Ko_(NoP noP, MenuItem menuItem) {
return this.b.mOnMenuItemClickListener != null && this.b.mOnMenuItemClickListener.onMenuItemClick(menuItem);
}
@Override // o.NoP.Sts
public final void b(NoP noP) {
if (this.b.mMenuBuilderCallback != null) {
this.b.mMenuBuilderCallback.b(noP);
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class IeS implements InterfaceC15933jjG.Sts {
@Override // o.InterfaceC15933jjG.Sts
public final boolean d(NoP noP) {
return false;
}
@Override // o.InterfaceC15933jjG.Sts
public final void e(NoP noP, boolean z) {
}
IeS() {
}
}
/* loaded from: classes.dex */
public static class Sts extends LinearLayoutCompat.RVV {
boolean a;
@ViewDebug.ExportedProperty
public boolean b;
@ViewDebug.ExportedProperty
public int c;
@ViewDebug.ExportedProperty
public boolean d;
@ViewDebug.ExportedProperty
public int e;
@ViewDebug.ExportedProperty
public boolean g;
public Sts(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
public Sts(ViewGroup.LayoutParams layoutParams) {
super(layoutParams);
}
public Sts(Sts sts) {
super(sts);
this.d = sts.d;
}
public Sts() {
super(-2, -2);
this.d = false;
}
}
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup
protected /* synthetic */ ViewGroup.LayoutParams generateDefaultLayoutParams() {
Sts sts = new Sts();
((LinearLayout.LayoutParams) sts).gravity = 16;
return sts;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.appcompat.widget.LinearLayoutCompat
/* renamed from: u_ */
public /* synthetic */ LinearLayoutCompat.RVV generateDefaultLayoutParams() {
Sts sts = new Sts();
((LinearLayout.LayoutParams) sts).gravity = 16;
return sts;
}
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup
public /* synthetic */ ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
return new Sts(getContext(), attributeSet);
}
@Override // androidx.appcompat.widget.LinearLayoutCompat
/* renamed from: ip_ */
public /* synthetic */ LinearLayoutCompat.RVV generateLayoutParams(AttributeSet attributeSet) {
return new Sts(getContext(), attributeSet);
}
public static Sts c() {
Sts sts = new Sts();
((LinearLayout.LayoutParams) sts).gravity = 16;
sts.d = true;
return sts;
}
@Override // o.NoP.LWm
public final boolean d(MenuItemImpl menuItemImpl) {
return this.d.eM_(menuItemImpl, null, 0);
}
public void setExpandedActionViewsExclusive(boolean z) {
this.b.f = z;
}
public void setPresenter(ActionMenuPresenter actionMenuPresenter) {
this.b = actionMenuPresenter;
actionMenuPresenter.b = this;
this.d = actionMenuPresenter.d;
}
public void setOverflowReserved(boolean z) {
this.e = z;
}
public void setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener) {
this.mOnMenuItemClickListener = onMenuItemClickListener;
}
public void setMenuCallbacks(InterfaceC15933jjG.Sts sts, NoP.Sts sts2) {
this.mActionMenuPresenterCallback = sts;
this.mMenuBuilderCallback = sts2;
}
@Override // o.Sya
public final void a(NoP noP) {
this.d = noP;
}
}