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

343 lines
13 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package androidx.appcompat.widget;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.widget.ActionMenuPresenter;
import androidx.core.view.ViewCompat;
import androidx.core.view.ViewPropertyAnimatorCompat;
import java.lang.ref.WeakReference;
import o.C0683McA;
import o.NoP;
import o.SYO;
import o.mxt;
import o.vsf;
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
/* loaded from: classes.dex */
public class ActionBarContextView extends AbsActionBarView {
public CharSequence f;
public boolean g;
public CharSequence i;
public View j;
private int k;
private View l;
private int m;
private View n;
/* renamed from: o, reason: collision with root package name */
private TextView f6371o;
private LinearLayout q;
private int r;
private TextView s;
@Override // android.view.ViewGroup
public boolean shouldDelayChildPressedState() {
return false;
}
@Override // androidx.appcompat.widget.AbsActionBarView
public final /* bridge */ /* synthetic */ ViewPropertyAnimatorCompat c(int i, long j) {
return super.c(i, j);
}
@Override // androidx.appcompat.widget.AbsActionBarView, android.view.View
public /* bridge */ /* synthetic */ boolean onHoverEvent(MotionEvent motionEvent) {
return super.onHoverEvent(motionEvent);
}
@Override // androidx.appcompat.widget.AbsActionBarView, android.view.View
public /* bridge */ /* synthetic */ boolean onTouchEvent(MotionEvent motionEvent) {
return super.onTouchEvent(motionEvent);
}
@Override // androidx.appcompat.widget.AbsActionBarView, android.view.View
public /* bridge */ /* synthetic */ void setVisibility(int i) {
super.setVisibility(i);
}
public ActionBarContextView(Context context) {
this(context, null);
}
public ActionBarContextView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, SYO.IeS.actionModeStyle);
}
public ActionBarContextView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
C0683McA c0683McA = new C0683McA(context, context.obtainStyledAttributes(attributeSet, SYO.ZqN.ActionMode, i, 0));
ViewCompat.sn_(this, c0683McA.jL_(SYO.ZqN.ActionMode_background));
this.r = c0683McA.d.getResourceId(SYO.ZqN.ActionMode_titleTextStyle, 0);
this.m = c0683McA.d.getResourceId(SYO.ZqN.ActionMode_subtitleTextStyle, 0);
this.b = c0683McA.d.getLayoutDimension(SYO.ZqN.ActionMode_height, 0);
this.k = c0683McA.d.getResourceId(SYO.ZqN.ActionMode_closeItemLayout, SYO.ojQ.abc_action_mode_close_item_material);
c0683McA.d.recycle();
}
@Override // android.view.ViewGroup, android.view.View
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (this.c != null) {
this.c.c();
ActionMenuPresenter.HBt hBt = this.c.j;
if (hBt != null) {
hBt.a();
}
}
}
@Override // androidx.appcompat.widget.AbsActionBarView
public void setContentHeight(int i) {
this.b = i;
}
public void setCustomView(View view) {
LinearLayout linearLayout;
View view2 = this.l;
if (view2 != null) {
removeView(view2);
}
this.l = view;
if (view != null && (linearLayout = this.q) != null) {
removeView(linearLayout);
this.q = null;
}
if (view != null) {
addView(view);
}
requestLayout();
}
public void setTitle(CharSequence charSequence) {
this.i = charSequence;
a();
ViewCompat.d(this, charSequence);
}
public void setSubtitle(CharSequence charSequence) {
this.f = charSequence;
a();
}
private void a() {
if (this.q == null) {
LayoutInflater.from(getContext()).inflate(SYO.ojQ.abc_action_bar_title_item, this);
LinearLayout linearLayout = (LinearLayout) getChildAt(getChildCount() - 1);
this.q = linearLayout;
this.s = (TextView) linearLayout.findViewById(SYO.saX.action_bar_title);
this.f6371o = (TextView) this.q.findViewById(SYO.saX.action_bar_subtitle);
if (this.r != 0) {
this.s.setTextAppearance(getContext(), this.r);
}
if (this.m != 0) {
this.f6371o.setTextAppearance(getContext(), this.m);
}
}
this.s.setText(this.i);
this.f6371o.setText(this.f);
boolean isEmpty = TextUtils.isEmpty(this.i);
boolean z = !TextUtils.isEmpty(this.f);
this.f6371o.setVisibility(z ? 0 : 8);
this.q.setVisibility(((isEmpty ^ true) || z) ? 0 : 8);
if (this.q.getParent() == null) {
addView(this.q);
}
}
public final void c(vsf vsfVar) {
View view = this.j;
if (view == null) {
View inflate = LayoutInflater.from(getContext()).inflate(this.k, (ViewGroup) this, false);
this.j = inflate;
addView(inflate);
} else if (view.getParent() == null) {
addView(this.j);
}
View findViewById = this.j.findViewById(SYO.saX.action_mode_close_button);
this.n = findViewById;
findViewById.setOnClickListener(new View.OnClickListener(this, vsfVar) { // from class: androidx.appcompat.widget.ActionBarContextView.1
final vsf c;
final ActionBarContextView d;
{
this.d = this;
this.c = vsfVar;
}
@Override // android.view.View.OnClickListener
public final void onClick(View view2) {
this.c.e();
}
});
NoP noP = (NoP) vsfVar.ed_();
if (this.c != null) {
ActionMenuPresenter actionMenuPresenter = this.c;
actionMenuPresenter.c();
ActionMenuPresenter.HBt hBt = actionMenuPresenter.j;
if (hBt != null) {
hBt.a();
}
}
this.c = new ActionMenuPresenter(getContext());
ActionMenuPresenter actionMenuPresenter2 = this.c;
actionMenuPresenter2.r = true;
actionMenuPresenter2.p = true;
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-2, -1);
ActionMenuPresenter actionMenuPresenter3 = this.c;
Context context = this.e;
noP.r.add(new WeakReference<>(actionMenuPresenter3));
actionMenuPresenter3.a(context, noP);
noP.f = true;
this.d = (ActionMenuView) this.c.fj_(this);
ViewCompat.sn_(this.d, null);
addView(this.d, layoutParams);
}
public final void c() {
removeAllViews();
this.l = null;
this.d = null;
this.c = null;
View view = this.n;
if (view != null) {
view.setOnClickListener(null);
}
}
@Override // androidx.appcompat.widget.AbsActionBarView
public final boolean d() {
if (this.c != null) {
return this.c.b();
}
return false;
}
@Override // android.view.ViewGroup
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
return new ViewGroup.MarginLayoutParams(-1, -2);
}
@Override // android.view.ViewGroup
public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
return new ViewGroup.MarginLayoutParams(getContext(), attributeSet);
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
if (View.MeasureSpec.getMode(i) != 1073741824) {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" can only be used with android:layout_width=\"match_parent\" (or fill_parent)");
throw new IllegalStateException(sb.toString());
}
if (View.MeasureSpec.getMode(i2) == 0) {
StringBuilder sb2 = new StringBuilder();
sb2.append(getClass().getSimpleName());
sb2.append(" can only be used with android:layout_height=\"wrap_content\"");
throw new IllegalStateException(sb2.toString());
}
int size = View.MeasureSpec.getSize(i);
int size2 = this.b > 0 ? this.b : View.MeasureSpec.getSize(i2);
int paddingTop = getPaddingTop() + getPaddingBottom();
int paddingLeft = (size - getPaddingLeft()) - getPaddingRight();
int i3 = size2 - paddingTop;
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i3, PKIFailureInfo.systemUnavail);
View view = this.j;
if (view != null) {
view.measure(View.MeasureSpec.makeMeasureSpec(paddingLeft, PKIFailureInfo.systemUnavail), makeMeasureSpec);
int max = Math.max(0, paddingLeft - view.getMeasuredWidth());
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.j.getLayoutParams();
paddingLeft = max - (marginLayoutParams.leftMargin + marginLayoutParams.rightMargin);
}
if (this.d != null && this.d.getParent() == this) {
ActionMenuView actionMenuView = this.d;
actionMenuView.measure(View.MeasureSpec.makeMeasureSpec(paddingLeft, PKIFailureInfo.systemUnavail), makeMeasureSpec);
paddingLeft = Math.max(0, paddingLeft - actionMenuView.getMeasuredWidth());
}
LinearLayout linearLayout = this.q;
if (linearLayout != null && this.l == null) {
if (this.g) {
this.q.measure(View.MeasureSpec.makeMeasureSpec(0, 0), makeMeasureSpec);
int measuredWidth = this.q.getMeasuredWidth();
boolean z = measuredWidth <= paddingLeft;
if (z) {
paddingLeft -= measuredWidth;
}
this.q.setVisibility(z ? 0 : 8);
} else {
linearLayout.measure(View.MeasureSpec.makeMeasureSpec(paddingLeft, PKIFailureInfo.systemUnavail), makeMeasureSpec);
paddingLeft = Math.max(0, paddingLeft - linearLayout.getMeasuredWidth());
}
}
View view2 = this.l;
if (view2 != null) {
ViewGroup.LayoutParams layoutParams = view2.getLayoutParams();
int i4 = layoutParams.width != -2 ? 1073741824 : Integer.MIN_VALUE;
if (layoutParams.width >= 0) {
paddingLeft = Math.min(layoutParams.width, paddingLeft);
}
int i5 = layoutParams.height == -2 ? Integer.MIN_VALUE : 1073741824;
if (layoutParams.height >= 0) {
i3 = Math.min(layoutParams.height, i3);
}
this.l.measure(View.MeasureSpec.makeMeasureSpec(paddingLeft, i4), View.MeasureSpec.makeMeasureSpec(i3, i5));
}
if (this.b <= 0) {
int childCount = getChildCount();
int i6 = 0;
for (int i7 = 0; i7 < childCount; i7++) {
int measuredHeight = getChildAt(i7).getMeasuredHeight() + paddingTop;
if (measuredHeight > i6) {
i6 = measuredHeight;
}
}
setMeasuredDimension(size, i6);
return;
}
setMeasuredDimension(size, size2);
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
boolean b = mxt.b(this);
int paddingRight = b ? (i3 - i) - getPaddingRight() : getPaddingLeft();
int paddingTop = getPaddingTop();
int paddingTop2 = ((i4 - i2) - getPaddingTop()) - getPaddingBottom();
View view = this.j;
if (view != null && view.getVisibility() != 8) {
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.j.getLayoutParams();
int i5 = b ? marginLayoutParams.rightMargin : marginLayoutParams.leftMargin;
int i6 = b ? marginLayoutParams.leftMargin : marginLayoutParams.rightMargin;
int i7 = b ? paddingRight - i5 : paddingRight + i5;
int e = i7 + e(this.j, i7, paddingTop, paddingTop2, b);
paddingRight = b ? e - i6 : e + i6;
}
LinearLayout linearLayout = this.q;
if (linearLayout != null && this.l == null && linearLayout.getVisibility() != 8) {
paddingRight += e(this.q, paddingRight, paddingTop, paddingTop2, b);
}
View view2 = this.l;
if (view2 != null) {
e(view2, paddingRight, paddingTop, paddingTop2, b);
}
int paddingLeft = b ? getPaddingLeft() : (i3 - i) - getPaddingRight();
if (this.d != null) {
e(this.d, paddingLeft, paddingTop, paddingTop2, !b);
}
}
public void setTitleOptional(boolean z) {
if (z != this.g) {
requestLayout();
}
this.g = z;
}
}