discord-jadx/app/src/main/java/j/g.java
2022-04-15 08:15:37 +00:00

455 lines
16 KiB
Java

package j;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import android.view.InflateException;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import androidx.appcompat.widget.e0;
import androidx.appcompat.widget.x0;
import androidx.core.view.i;
import e.j;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import k.c;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/* compiled from: SupportMenuInflater.java */
/* loaded from: classes.dex */
public class g extends MenuInflater {
/* renamed from: e reason: collision with root package name */
static final Class<?>[] f14484e;
/* renamed from: f reason: collision with root package name */
static final Class<?>[] f14485f;
/* renamed from: a reason: collision with root package name */
final Object[] f14486a;
/* renamed from: b reason: collision with root package name */
final Object[] f14487b;
/* renamed from: c reason: collision with root package name */
Context f14488c;
/* renamed from: d reason: collision with root package name */
private Object f14489d;
/* compiled from: SupportMenuInflater.java */
/* loaded from: classes.dex */
private static class a implements MenuItem.OnMenuItemClickListener {
/* renamed from: c reason: collision with root package name */
private static final Class<?>[] f14490c = {MenuItem.class};
/* renamed from: a reason: collision with root package name */
private Object f14491a;
/* renamed from: b reason: collision with root package name */
private Method f14492b;
public a(Object obj, String str) {
this.f14491a = obj;
Class<?> cls = obj.getClass();
try {
this.f14492b = cls.getMethod(str, f14490c);
} catch (Exception e10) {
InflateException inflateException = new InflateException("Couldn't resolve menu item onClick handler " + str + " in class " + cls.getName());
inflateException.initCause(e10);
throw inflateException;
}
}
@Override // android.view.MenuItem.OnMenuItemClickListener
public boolean onMenuItemClick(MenuItem menuItem) {
try {
if (this.f14492b.getReturnType() == Boolean.TYPE) {
return ((Boolean) this.f14492b.invoke(this.f14491a, menuItem)).booleanValue();
}
this.f14492b.invoke(this.f14491a, menuItem);
return true;
} catch (Exception e10) {
throw new RuntimeException(e10);
}
}
}
/* compiled from: SupportMenuInflater.java */
/* loaded from: classes.dex */
private class b {
androidx.core.view.b A;
private CharSequence B;
private CharSequence C;
private ColorStateList D = null;
private PorterDuff.Mode E = null;
/* renamed from: a reason: collision with root package name */
private Menu f14493a;
/* renamed from: b reason: collision with root package name */
private int f14494b;
/* renamed from: c reason: collision with root package name */
private int f14495c;
/* renamed from: d reason: collision with root package name */
private int f14496d;
/* renamed from: e reason: collision with root package name */
private int f14497e;
/* renamed from: f reason: collision with root package name */
private boolean f14498f;
/* renamed from: g reason: collision with root package name */
private boolean f14499g;
/* renamed from: h reason: collision with root package name */
private boolean f14500h;
/* renamed from: i reason: collision with root package name */
private int f14501i;
/* renamed from: j reason: collision with root package name */
private int f14502j;
/* renamed from: k reason: collision with root package name */
private CharSequence f14503k;
/* renamed from: l reason: collision with root package name */
private CharSequence f14504l;
/* renamed from: m reason: collision with root package name */
private int f14505m;
/* renamed from: n reason: collision with root package name */
private char f14506n;
/* renamed from: o reason: collision with root package name */
private int f14507o;
/* renamed from: p reason: collision with root package name */
private char f14508p;
/* renamed from: q reason: collision with root package name */
private int f14509q;
/* renamed from: r reason: collision with root package name */
private int f14510r;
/* renamed from: s reason: collision with root package name */
private boolean f14511s;
/* renamed from: t reason: collision with root package name */
private boolean f14512t;
/* renamed from: u reason: collision with root package name */
private boolean f14513u;
/* renamed from: v reason: collision with root package name */
private int f14514v;
/* renamed from: w reason: collision with root package name */
private int f14515w;
/* renamed from: x reason: collision with root package name */
private String f14516x;
/* renamed from: y reason: collision with root package name */
private String f14517y;
/* renamed from: z reason: collision with root package name */
private String f14518z;
public b(Menu menu) {
this.f14493a = menu;
h();
}
private char c(String str) {
if (str == null) {
return (char) 0;
}
return str.charAt(0);
}
private <T> T e(String str, Class<?>[] clsArr, Object[] objArr) {
try {
Constructor<?> constructor = Class.forName(str, false, g.this.f14488c.getClassLoader()).getConstructor(clsArr);
constructor.setAccessible(true);
return (T) constructor.newInstance(objArr);
} catch (Exception e10) {
Log.w("SupportMenuInflater", "Cannot instantiate class: " + str, e10);
return null;
}
}
private void i(MenuItem menuItem) {
boolean z10 = false;
menuItem.setChecked(this.f14511s).setVisible(this.f14512t).setEnabled(this.f14513u).setCheckable(this.f14510r >= 1).setTitleCondensed(this.f14504l).setIcon(this.f14505m);
int i10 = this.f14514v;
if (i10 >= 0) {
menuItem.setShowAsAction(i10);
}
if (this.f14518z != null) {
if (!g.this.f14488c.isRestricted()) {
menuItem.setOnMenuItemClickListener(new a(g.this.b(), this.f14518z));
} else {
throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
}
}
if (this.f14510r >= 2) {
if (menuItem instanceof androidx.appcompat.view.menu.g) {
((androidx.appcompat.view.menu.g) menuItem).t(true);
} else if (menuItem instanceof c) {
((c) menuItem).h(true);
}
}
String str = this.f14516x;
if (str != null) {
menuItem.setActionView((View) e(str, g.f14484e, g.this.f14486a));
z10 = true;
}
int i11 = this.f14515w;
if (i11 > 0) {
if (!z10) {
menuItem.setActionView(i11);
} else {
Log.w("SupportMenuInflater", "Ignoring attribute 'itemActionViewLayout'. Action view already specified.");
}
}
androidx.core.view.b bVar = this.A;
if (bVar != null) {
i.a(menuItem, bVar);
}
i.c(menuItem, this.B);
i.g(menuItem, this.C);
i.b(menuItem, this.f14506n, this.f14507o);
i.f(menuItem, this.f14508p, this.f14509q);
PorterDuff.Mode mode = this.E;
if (mode != null) {
i.e(menuItem, mode);
}
ColorStateList colorStateList = this.D;
if (colorStateList != null) {
i.d(menuItem, colorStateList);
}
}
public void a() {
this.f14500h = true;
i(this.f14493a.add(this.f14494b, this.f14501i, this.f14502j, this.f14503k));
}
public SubMenu b() {
this.f14500h = true;
SubMenu addSubMenu = this.f14493a.addSubMenu(this.f14494b, this.f14501i, this.f14502j, this.f14503k);
i(addSubMenu.getItem());
return addSubMenu;
}
public boolean d() {
return this.f14500h;
}
public void f(AttributeSet attributeSet) {
TypedArray obtainStyledAttributes = g.this.f14488c.obtainStyledAttributes(attributeSet, j.f10420r1);
this.f14494b = obtainStyledAttributes.getResourceId(j.f10430t1, 0);
this.f14495c = obtainStyledAttributes.getInt(j.f10440v1, 0);
this.f14496d = obtainStyledAttributes.getInt(j.f10445w1, 0);
this.f14497e = obtainStyledAttributes.getInt(j.f10450x1, 0);
this.f14498f = obtainStyledAttributes.getBoolean(j.f10435u1, true);
this.f14499g = obtainStyledAttributes.getBoolean(j.f10425s1, true);
obtainStyledAttributes.recycle();
}
public void g(AttributeSet attributeSet) {
x0 u10 = x0.u(g.this.f14488c, attributeSet, j.f10455y1);
this.f14501i = u10.n(j.B1, 0);
this.f14502j = (u10.k(j.E1, this.f14495c) & (-65536)) | (u10.k(j.F1, this.f14496d) & 65535);
this.f14503k = u10.p(j.G1);
this.f14504l = u10.p(j.H1);
this.f14505m = u10.n(j.f10460z1, 0);
this.f14506n = c(u10.o(j.I1));
this.f14507o = u10.k(j.P1, 4096);
this.f14508p = c(u10.o(j.J1));
this.f14509q = u10.k(j.T1, 4096);
int i10 = j.K1;
if (u10.s(i10)) {
this.f14510r = u10.a(i10, false) ? 1 : 0;
} else {
this.f14510r = this.f14497e;
}
this.f14511s = u10.a(j.C1, false);
this.f14512t = u10.a(j.D1, this.f14498f);
this.f14513u = u10.a(j.A1, this.f14499g);
this.f14514v = u10.k(j.U1, -1);
this.f14518z = u10.o(j.L1);
this.f14515w = u10.n(j.M1, 0);
this.f14516x = u10.o(j.O1);
String o2 = u10.o(j.N1);
this.f14517y = o2;
boolean z10 = o2 != null;
if (z10 && this.f14515w == 0 && this.f14516x == null) {
this.A = (androidx.core.view.b) e(o2, g.f14485f, g.this.f14487b);
} else {
if (z10) {
Log.w("SupportMenuInflater", "Ignoring attribute 'actionProviderClass'. Action view already specified.");
}
this.A = null;
}
this.B = u10.p(j.Q1);
this.C = u10.p(j.V1);
int i11 = j.S1;
if (u10.s(i11)) {
this.E = e0.e(u10.k(i11, -1), this.E);
} else {
this.E = null;
}
int i12 = j.R1;
if (u10.s(i12)) {
this.D = u10.c(i12);
} else {
this.D = null;
}
u10.w();
this.f14500h = false;
}
public void h() {
this.f14494b = 0;
this.f14495c = 0;
this.f14496d = 0;
this.f14497e = 0;
this.f14498f = true;
this.f14499g = true;
}
}
static {
Class<?>[] clsArr = {Context.class};
f14484e = clsArr;
f14485f = clsArr;
}
public g(Context context) {
super(context);
this.f14488c = context;
Object[] objArr = {context};
this.f14486a = objArr;
this.f14487b = objArr;
}
private Object a(Object obj) {
return (!(obj instanceof Activity) && (obj instanceof ContextWrapper)) ? a(((ContextWrapper) obj).getBaseContext()) : obj;
}
private void c(XmlPullParser xmlPullParser, AttributeSet attributeSet, Menu menu) {
b bVar = new b(menu);
int eventType = xmlPullParser.getEventType();
while (true) {
if (eventType != 2) {
eventType = xmlPullParser.next();
if (eventType == 1) {
break;
}
} else {
String name = xmlPullParser.getName();
if (name.equals("menu")) {
eventType = xmlPullParser.next();
} else {
throw new RuntimeException("Expecting menu, got " + name);
}
}
}
String str = null;
boolean z10 = false;
boolean z11 = false;
while (!z10) {
if (eventType != 1) {
if (eventType != 2) {
if (eventType == 3) {
String name2 = xmlPullParser.getName();
if (z11 && name2.equals(str)) {
str = null;
z11 = false;
} else if (name2.equals("group")) {
bVar.h();
} else if (name2.equals("item")) {
if (!bVar.d()) {
androidx.core.view.b bVar2 = bVar.A;
if (bVar2 == null || !bVar2.a()) {
bVar.a();
} else {
bVar.b();
}
}
} else if (name2.equals("menu")) {
z10 = true;
}
}
} else if (!z11) {
String name3 = xmlPullParser.getName();
if (name3.equals("group")) {
bVar.f(attributeSet);
} else if (name3.equals("item")) {
bVar.g(attributeSet);
} else if (name3.equals("menu")) {
c(xmlPullParser, attributeSet, bVar.b());
} else {
str = name3;
z11 = true;
}
}
eventType = xmlPullParser.next();
} else {
throw new RuntimeException("Unexpected end of document");
}
}
}
Object b() {
if (this.f14489d == null) {
this.f14489d = a(this.f14488c);
}
return this.f14489d;
}
@Override // android.view.MenuInflater
public void inflate(int i10, Menu menu) {
if (!(menu instanceof d0.a)) {
super.inflate(i10, menu);
return;
}
XmlResourceParser xmlResourceParser = null;
try {
try {
try {
xmlResourceParser = this.f14488c.getResources().getLayout(i10);
c(xmlResourceParser, Xml.asAttributeSet(xmlResourceParser), menu);
} catch (XmlPullParserException e10) {
throw new InflateException("Error inflating menu XML", e10);
}
} catch (IOException e11) {
throw new InflateException("Error inflating menu XML", e11);
}
} finally {
if (xmlResourceParser != null) {
xmlResourceParser.close();
}
}
}
}