package androidx.appcompat.app;

import android.R;
import android.app.Activity;
import android.app.Dialog;
import android.app.UiModeManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.LocaleList;
import android.os.PowerManager;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ContextThemeWrapper;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.KeyboardShortcutGroup;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.appcompat.view.b;
import androidx.appcompat.view.f;
import androidx.appcompat.view.menu.g;
import androidx.appcompat.view.menu.m;
import androidx.appcompat.widget.ActionBarContextView;
import androidx.appcompat.widget.ContentFrameLayout;
import androidx.appcompat.widget.ViewStubCompat;
import androidx.appcompat.widget.a1;
import androidx.appcompat.widget.g0;
import androidx.appcompat.widget.i1;
import androidx.appcompat.widget.j1;
import androidx.appcompat.widget.k0;
import androidx.core.content.res.h;
import androidx.core.view.e0;
import androidx.core.view.f;
import androidx.core.view.j0;
import androidx.core.view.y;
import androidx.lifecycle.g;
import java.lang.Thread;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;

/* JADX INFO: compiled from: AppCompatDelegateImpl.java */
/* JADX INFO: loaded from: classes.dex */
class f extends androidx.appcompat.app.e implements g.a, LayoutInflater.Factory2 {

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    private static final j.g<String, Integer> f174f0 = new j.g<>();

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    private static final boolean f175g0;

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    private static final int[] f176h0;

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    private static final boolean f177i0;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    private static final boolean f178j0;

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    private static boolean f179k0;
    private TextView A;
    private View B;
    private boolean C;
    private boolean D;
    boolean E;
    boolean F;
    boolean G;
    boolean H;
    boolean I;
    private boolean J;
    private u[] K;
    private u L;
    private boolean M;
    private boolean N;
    private boolean O;
    boolean P;
    private Configuration Q;
    private int R;
    private int S;
    private boolean T;
    private boolean U;
    private q V;
    private q W;
    boolean X;
    int Y;
    private final Runnable Z;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    private boolean f180a0;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    private Rect f181b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    private Rect f182c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    private androidx.appcompat.app.i f183d0;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    private androidx.appcompat.app.j f184e0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    final Object f185h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    final Context f186i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    Window f187j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private o f188k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    final androidx.appcompat.app.d f189l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    androidx.appcompat.app.a f190m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    MenuInflater f191n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    private CharSequence f192o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    private g0 f193p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    private i f194q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    private v f195r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    androidx.appcompat.view.b f196s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    ActionBarContextView f197t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    PopupWindow f198u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    Runnable f199v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    e0 f200w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    private boolean f201x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    private boolean f202y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    ViewGroup f203z;

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class a implements Thread.UncaughtExceptionHandler {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ Thread.UncaughtExceptionHandler f204a;

        a(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
            this.f204a = uncaughtExceptionHandler;
        }

        private boolean a(Throwable th) {
            String message;
            if (!(th instanceof Resources.NotFoundException) || (message = th.getMessage()) == null) {
                return false;
            }
            return message.contains("drawable") || message.contains("Drawable");
        }

        @Override // java.lang.Thread.UncaughtExceptionHandler
        public void uncaughtException(Thread thread, Throwable th) {
            if (!a(th)) {
                this.f204a.uncaughtException(thread, th);
                return;
            }
            Resources.NotFoundException notFoundException = new Resources.NotFoundException(th.getMessage() + ". If the resource you are trying to use is a vector resource, you may be referencing it in an unsupported way. See AppCompatDelegate.setCompatVectorFromResourcesEnabled() for more info.");
            notFoundException.initCause(th.getCause());
            notFoundException.setStackTrace(th.getStackTrace());
            this.f204a.uncaughtException(thread, notFoundException);
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class b implements Runnable {
        b() {
        }

        @Override // java.lang.Runnable
        public void run() {
            f fVar = f.this;
            if ((fVar.Y & 1) != 0) {
                fVar.U(0);
            }
            f fVar2 = f.this;
            if ((fVar2.Y & 4096) != 0) {
                fVar2.U(108);
            }
            f fVar3 = f.this;
            fVar3.X = false;
            fVar3.Y = 0;
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class c implements androidx.core.view.s {
        c() {
        }

        @Override // androidx.core.view.s
        public j0 a(View view, j0 j0Var) {
            int iK = j0Var.k();
            int iL0 = f.this.L0(j0Var, null);
            if (iK != iL0) {
                j0Var = j0Var.o(j0Var.i(), iL0, j0Var.j(), j0Var.h());
            }
            return y.d0(view, j0Var);
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class d implements k0.a {
        d() {
        }

        @Override // androidx.appcompat.widget.k0.a
        public void a(Rect rect) {
            rect.top = f.this.L0(null, rect);
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class e implements ContentFrameLayout.a {
        e() {
        }

        @Override // androidx.appcompat.widget.ContentFrameLayout.a
        public void a() {
        }

        @Override // androidx.appcompat.widget.ContentFrameLayout.a
        public void onDetachedFromWindow() {
            f.this.S();
        }
    }

    /* JADX INFO: renamed from: androidx.appcompat.app.f$f, reason: collision with other inner class name */
    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class RunnableC0003f implements Runnable {

        /* JADX INFO: renamed from: androidx.appcompat.app.f$f$a */
        /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
        class a extends androidx.core.view.g0 {
            a() {
            }

            @Override // androidx.core.view.f0
            public void a(View view) {
                f.this.f197t.setAlpha(1.0f);
                f.this.f200w.h(null);
                f.this.f200w = null;
            }

            @Override // androidx.core.view.g0, androidx.core.view.f0
            public void b(View view) {
                f.this.f197t.setVisibility(0);
            }
        }

        RunnableC0003f() {
        }

        @Override // java.lang.Runnable
        public void run() {
            f fVar = f.this;
            fVar.f198u.showAtLocation(fVar.f197t, 55, 0, 0);
            f.this.V();
            if (!f.this.D0()) {
                f.this.f197t.setAlpha(1.0f);
                f.this.f197t.setVisibility(0);
            } else {
                f.this.f197t.setAlpha(0.0f);
                f fVar2 = f.this;
                fVar2.f200w = y.e(fVar2.f197t).b(1.0f);
                f.this.f200w.h(new a());
            }
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class g extends androidx.core.view.g0 {
        g() {
        }

        @Override // androidx.core.view.f0
        public void a(View view) {
            f.this.f197t.setAlpha(1.0f);
            f.this.f200w.h(null);
            f.this.f200w = null;
        }

        @Override // androidx.core.view.g0, androidx.core.view.f0
        public void b(View view) {
            f.this.f197t.setVisibility(0);
            if (f.this.f197t.getParent() instanceof View) {
                y.o0((View) f.this.f197t.getParent());
            }
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    interface h {
        boolean a(int i3);

        View onCreatePanelView(int i3);
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    private final class i implements m.a {
        i() {
        }

        @Override // androidx.appcompat.view.menu.m.a
        public void b(androidx.appcompat.view.menu.g gVar, boolean z2) {
            f.this.L(gVar);
        }

        @Override // androidx.appcompat.view.menu.m.a
        public boolean c(androidx.appcompat.view.menu.g gVar) {
            Window.Callback callbackF0 = f.this.f0();
            if (callbackF0 == null) {
                return true;
            }
            callbackF0.onMenuOpened(108, gVar);
            return true;
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class j implements b.a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private b.a f213a;

        /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
        class a extends androidx.core.view.g0 {
            a() {
            }

            @Override // androidx.core.view.f0
            public void a(View view) {
                f.this.f197t.setVisibility(8);
                f fVar = f.this;
                PopupWindow popupWindow = fVar.f198u;
                if (popupWindow != null) {
                    popupWindow.dismiss();
                } else if (fVar.f197t.getParent() instanceof View) {
                    y.o0((View) f.this.f197t.getParent());
                }
                f.this.f197t.k();
                f.this.f200w.h(null);
                f fVar2 = f.this;
                fVar2.f200w = null;
                y.o0(fVar2.f203z);
            }
        }

        public j(b.a aVar) {
            this.f213a = aVar;
        }

        @Override // androidx.appcompat.view.b.a
        public boolean a(androidx.appcompat.view.b bVar, Menu menu) {
            y.o0(f.this.f203z);
            return this.f213a.a(bVar, menu);
        }

        @Override // androidx.appcompat.view.b.a
        public boolean b(androidx.appcompat.view.b bVar, MenuItem menuItem) {
            return this.f213a.b(bVar, menuItem);
        }

        @Override // androidx.appcompat.view.b.a
        public boolean c(androidx.appcompat.view.b bVar, Menu menu) {
            return this.f213a.c(bVar, menu);
        }

        @Override // androidx.appcompat.view.b.a
        public void d(androidx.appcompat.view.b bVar) {
            this.f213a.d(bVar);
            f fVar = f.this;
            if (fVar.f198u != null) {
                fVar.f187j.getDecorView().removeCallbacks(f.this.f199v);
            }
            f fVar2 = f.this;
            if (fVar2.f197t != null) {
                fVar2.V();
                f fVar3 = f.this;
                fVar3.f200w = y.e(fVar3.f197t).b(0.0f);
                f.this.f200w.h(new a());
            }
            f fVar4 = f.this;
            androidx.appcompat.app.d dVar = fVar4.f189l;
            if (dVar != null) {
                dVar.j(fVar4.f196s);
            }
            f fVar5 = f.this;
            fVar5.f196s = null;
            y.o0(fVar5.f203z);
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    static class k {
        static Context a(Context context, Configuration configuration) {
            return context.createConfigurationContext(configuration);
        }

        static void b(Configuration configuration, Configuration configuration2, Configuration configuration3) {
            int i3 = configuration.densityDpi;
            int i4 = configuration2.densityDpi;
            if (i3 != i4) {
                configuration3.densityDpi = i4;
            }
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    static class l {
        static boolean a(PowerManager powerManager) {
            return powerManager.isPowerSaveMode();
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    static class m {
        static void a(Configuration configuration, Configuration configuration2, Configuration configuration3) {
            LocaleList locales = configuration.getLocales();
            LocaleList locales2 = configuration2.getLocales();
            if (locales.equals(locales2)) {
                return;
            }
            configuration3.setLocales(locales2);
            configuration3.locale = configuration2.locale;
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    static class n {
        static void a(Configuration configuration, Configuration configuration2, Configuration configuration3) {
            int i3 = configuration.colorMode & 3;
            int i4 = configuration2.colorMode;
            if (i3 != (i4 & 3)) {
                configuration3.colorMode |= i4 & 3;
            }
            int i5 = configuration.colorMode & 12;
            int i6 = configuration2.colorMode;
            if (i5 != (i6 & 12)) {
                configuration3.colorMode |= i6 & 12;
            }
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    private class p extends q {

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private final PowerManager f221c;

        p(Context context) {
            super();
            this.f221c = (PowerManager) context.getApplicationContext().getSystemService("power");
        }

        @Override // androidx.appcompat.app.f.q
        IntentFilter b() {
            if (Build.VERSION.SDK_INT < 21) {
                return null;
            }
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction("android.os.action.POWER_SAVE_MODE_CHANGED");
            return intentFilter;
        }

        @Override // androidx.appcompat.app.f.q
        public int c() {
            return (Build.VERSION.SDK_INT < 21 || !l.a(this.f221c)) ? 1 : 2;
        }

        @Override // androidx.appcompat.app.f.q
        public void d() {
            f.this.F();
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    abstract class q {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private BroadcastReceiver f223a;

        /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
        class a extends BroadcastReceiver {
            a() {
            }

            @Override // android.content.BroadcastReceiver
            public void onReceive(Context context, Intent intent) {
                q.this.d();
            }
        }

        q() {
        }

        void a() {
            BroadcastReceiver broadcastReceiver = this.f223a;
            if (broadcastReceiver != null) {
                try {
                    f.this.f186i.unregisterReceiver(broadcastReceiver);
                } catch (IllegalArgumentException unused) {
                }
                this.f223a = null;
            }
        }

        abstract IntentFilter b();

        abstract int c();

        abstract void d();

        void e() {
            a();
            IntentFilter intentFilterB = b();
            if (intentFilterB == null || intentFilterB.countActions() == 0) {
                return;
            }
            if (this.f223a == null) {
                this.f223a = new a();
            }
            f.this.f186i.registerReceiver(this.f223a, intentFilterB);
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    private class r extends q {

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private final androidx.appcompat.app.m f226c;

        r(androidx.appcompat.app.m mVar) {
            super();
            this.f226c = mVar;
        }

        @Override // androidx.appcompat.app.f.q
        IntentFilter b() {
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction("android.intent.action.TIME_SET");
            intentFilter.addAction("android.intent.action.TIMEZONE_CHANGED");
            intentFilter.addAction("android.intent.action.TIME_TICK");
            return intentFilter;
        }

        @Override // androidx.appcompat.app.f.q
        public int c() {
            return this.f226c.d() ? 2 : 1;
        }

        @Override // androidx.appcompat.app.f.q
        public void d() {
            f.this.F();
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    private static class s {
        static void a(ContextThemeWrapper contextThemeWrapper, Configuration configuration) {
            contextThemeWrapper.applyOverrideConfiguration(configuration);
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    private class t extends ContentFrameLayout {
        public t(Context context) {
            super(context);
        }

        private boolean c(int i3, int i4) {
            return i3 < -5 || i4 < -5 || i3 > getWidth() + 5 || i4 > getHeight() + 5;
        }

        @Override // android.view.ViewGroup, android.view.View
        public boolean dispatchKeyEvent(KeyEvent keyEvent) {
            return f.this.T(keyEvent) || super.dispatchKeyEvent(keyEvent);
        }

        @Override // android.view.ViewGroup
        public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
            if (motionEvent.getAction() != 0 || !c((int) motionEvent.getX(), (int) motionEvent.getY())) {
                return super.onInterceptTouchEvent(motionEvent);
            }
            f.this.N(0);
            return true;
        }

        @Override // android.view.View
        public void setBackgroundResource(int i3) {
            setBackgroundDrawable(d.a.b(getContext(), i3));
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    protected static final class u {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        int f229a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        int f230b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        int f231c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        int f232d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        int f233e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        int f234f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        ViewGroup f235g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        View f236h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        View f237i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        androidx.appcompat.view.menu.g f238j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        androidx.appcompat.view.menu.e f239k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        Context f240l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        boolean f241m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        boolean f242n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        boolean f243o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public boolean f244p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        boolean f245q = false;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        boolean f246r;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        Bundle f247s;

        u(int i3) {
            this.f229a = i3;
        }

        androidx.appcompat.view.menu.n a(m.a aVar) {
            if (this.f238j == null) {
                return null;
            }
            if (this.f239k == null) {
                androidx.appcompat.view.menu.e eVar = new androidx.appcompat.view.menu.e(this.f240l, c.g.f3261j);
                this.f239k = eVar;
                eVar.h(aVar);
                this.f238j.b(this.f239k);
            }
            return this.f239k.c(this.f235g);
        }

        public boolean b() {
            if (this.f236h == null) {
                return false;
            }
            return this.f237i != null || this.f239k.a().getCount() > 0;
        }

        void c(androidx.appcompat.view.menu.g gVar) {
            androidx.appcompat.view.menu.e eVar;
            androidx.appcompat.view.menu.g gVar2 = this.f238j;
            if (gVar == gVar2) {
                return;
            }
            if (gVar2 != null) {
                gVar2.O(this.f239k);
            }
            this.f238j = gVar;
            if (gVar == null || (eVar = this.f239k) == null) {
                return;
            }
            gVar.b(eVar);
        }

        void d(Context context) {
            TypedValue typedValue = new TypedValue();
            Resources.Theme themeNewTheme = context.getResources().newTheme();
            themeNewTheme.setTo(context.getTheme());
            themeNewTheme.resolveAttribute(c.a.f3150a, typedValue, true);
            int i3 = typedValue.resourceId;
            if (i3 != 0) {
                themeNewTheme.applyStyle(i3, true);
            }
            themeNewTheme.resolveAttribute(c.a.F, typedValue, true);
            int i4 = typedValue.resourceId;
            if (i4 != 0) {
                themeNewTheme.applyStyle(i4, true);
            } else {
                themeNewTheme.applyStyle(c.i.f3285b, true);
            }
            androidx.appcompat.view.d dVar = new androidx.appcompat.view.d(context, 0);
            dVar.getTheme().setTo(themeNewTheme);
            this.f240l = dVar;
            TypedArray typedArrayObtainStyledAttributes = dVar.obtainStyledAttributes(c.j.f3363v0);
            this.f230b = typedArrayObtainStyledAttributes.getResourceId(c.j.f3372y0, 0);
            this.f234f = typedArrayObtainStyledAttributes.getResourceId(c.j.f3369x0, 0);
            typedArrayObtainStyledAttributes.recycle();
        }
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    private final class v implements m.a {
        v() {
        }

        @Override // androidx.appcompat.view.menu.m.a
        public void b(androidx.appcompat.view.menu.g gVar, boolean z2) {
            androidx.appcompat.view.menu.g gVarD = gVar.D();
            boolean z3 = gVarD != gVar;
            f fVar = f.this;
            if (z3) {
                gVar = gVarD;
            }
            u uVarY = fVar.Y(gVar);
            if (uVarY != null) {
                if (!z3) {
                    f.this.O(uVarY, z2);
                } else {
                    f.this.K(uVarY.f229a, uVarY, gVarD);
                    f.this.O(uVarY, true);
                }
            }
        }

        @Override // androidx.appcompat.view.menu.m.a
        public boolean c(androidx.appcompat.view.menu.g gVar) {
            Window.Callback callbackF0;
            if (gVar != gVar.D()) {
                return true;
            }
            f fVar = f.this;
            if (!fVar.E || (callbackF0 = fVar.f0()) == null || f.this.P) {
                return true;
            }
            callbackF0.onMenuOpened(108, gVar);
            return true;
        }
    }

    static {
        int i3 = Build.VERSION.SDK_INT;
        boolean z2 = i3 < 21;
        f175g0 = z2;
        f176h0 = new int[]{R.attr.windowBackground};
        f177i0 = !"robolectric".equals(Build.FINGERPRINT);
        f178j0 = i3 >= 17;
        if (!z2 || f179k0) {
            return;
        }
        Thread.setDefaultUncaughtExceptionHandler(new a(Thread.getDefaultUncaughtExceptionHandler()));
        f179k0 = true;
    }

    f(Activity activity, androidx.appcompat.app.d dVar) {
        this(activity, null, dVar, activity);
    }

    private boolean A0(u uVar, KeyEvent keyEvent) {
        g0 g0Var;
        g0 g0Var2;
        g0 g0Var3;
        if (this.P) {
            return false;
        }
        if (uVar.f241m) {
            return true;
        }
        u uVar2 = this.L;
        if (uVar2 != null && uVar2 != uVar) {
            O(uVar2, false);
        }
        Window.Callback callbackF0 = f0();
        if (callbackF0 != null) {
            uVar.f237i = callbackF0.onCreatePanelView(uVar.f229a);
        }
        int i3 = uVar.f229a;
        boolean z2 = i3 == 0 || i3 == 108;
        if (z2 && (g0Var3 = this.f193p) != null) {
            g0Var3.g();
        }
        if (uVar.f237i == null) {
            if (z2) {
                y0();
            }
            androidx.appcompat.view.menu.g gVar = uVar.f238j;
            if (gVar == null || uVar.f246r) {
                if (gVar == null && (!j0(uVar) || uVar.f238j == null)) {
                    return false;
                }
                if (z2 && this.f193p != null) {
                    if (this.f194q == null) {
                        this.f194q = new i();
                    }
                    this.f193p.a(uVar.f238j, this.f194q);
                }
                uVar.f238j.d0();
                if (!callbackF0.onCreatePanelMenu(uVar.f229a, uVar.f238j)) {
                    uVar.c(null);
                    if (z2 && (g0Var = this.f193p) != null) {
                        g0Var.a(null, this.f194q);
                    }
                    return false;
                }
                uVar.f246r = false;
            }
            uVar.f238j.d0();
            Bundle bundle = uVar.f247s;
            if (bundle != null) {
                uVar.f238j.P(bundle);
                uVar.f247s = null;
            }
            if (!callbackF0.onPreparePanel(0, uVar.f237i, uVar.f238j)) {
                if (z2 && (g0Var2 = this.f193p) != null) {
                    g0Var2.a(null, this.f194q);
                }
                uVar.f238j.c0();
                return false;
            }
            boolean z3 = KeyCharacterMap.load(keyEvent != null ? keyEvent.getDeviceId() : -1).getKeyboardType() != 1;
            uVar.f244p = z3;
            uVar.f238j.setQwertyMode(z3);
            uVar.f238j.c0();
        }
        uVar.f241m = true;
        uVar.f242n = false;
        this.L = uVar;
        return true;
    }

    private void B0(boolean z2) {
        g0 g0Var = this.f193p;
        if (g0Var == null || !g0Var.h() || (ViewConfiguration.get(this.f186i).hasPermanentMenuKey() && !this.f193p.b())) {
            u uVarD0 = d0(0, true);
            uVarD0.f245q = true;
            O(uVarD0, false);
            x0(uVarD0, null);
            return;
        }
        Window.Callback callbackF0 = f0();
        if (this.f193p.c() && z2) {
            this.f193p.e();
            if (this.P) {
                return;
            }
            callbackF0.onPanelClosed(108, d0(0, true).f238j);
            return;
        }
        if (callbackF0 == null || this.P) {
            return;
        }
        if (this.X && (this.Y & 1) != 0) {
            this.f187j.getDecorView().removeCallbacks(this.Z);
            this.Z.run();
        }
        u uVarD02 = d0(0, true);
        androidx.appcompat.view.menu.g gVar = uVarD02.f238j;
        if (gVar == null || uVarD02.f246r || !callbackF0.onPreparePanel(0, uVarD02.f237i, gVar)) {
            return;
        }
        callbackF0.onMenuOpened(108, uVarD02.f238j);
        this.f193p.f();
    }

    private int C0(int i3) {
        if (i3 == 8) {
            Log.i("AppCompatDelegate", "You should now use the AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR id when requesting this feature.");
            return 108;
        }
        if (i3 != 9) {
            return i3;
        }
        Log.i("AppCompatDelegate", "You should now use the AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR_OVERLAY id when requesting this feature.");
        return 109;
    }

    private boolean E0(ViewParent viewParent) {
        if (viewParent == null) {
            return false;
        }
        View decorView = this.f187j.getDecorView();
        while (viewParent != null) {
            if (viewParent == decorView || !(viewParent instanceof View) || y.U((View) viewParent)) {
                return false;
            }
            viewParent = viewParent.getParent();
        }
        return true;
    }

    private boolean G(boolean z2) {
        if (this.P) {
            return false;
        }
        int iJ = J();
        boolean zJ0 = J0(n0(this.f186i, iJ), z2);
        if (iJ == 0) {
            c0(this.f186i).e();
        } else {
            q qVar = this.V;
            if (qVar != null) {
                qVar.a();
            }
        }
        if (iJ == 3) {
            b0(this.f186i).e();
        } else {
            q qVar2 = this.W;
            if (qVar2 != null) {
                qVar2.a();
            }
        }
        return zJ0;
    }

    private void H() {
        ContentFrameLayout contentFrameLayout = (ContentFrameLayout) this.f203z.findViewById(R.id.content);
        View decorView = this.f187j.getDecorView();
        contentFrameLayout.b(decorView.getPaddingLeft(), decorView.getPaddingTop(), decorView.getPaddingRight(), decorView.getPaddingBottom());
        TypedArray typedArrayObtainStyledAttributes = this.f186i.obtainStyledAttributes(c.j.f3363v0);
        typedArrayObtainStyledAttributes.getValue(c.j.H0, contentFrameLayout.getMinWidthMajor());
        typedArrayObtainStyledAttributes.getValue(c.j.I0, contentFrameLayout.getMinWidthMinor());
        int i3 = c.j.F0;
        if (typedArrayObtainStyledAttributes.hasValue(i3)) {
            typedArrayObtainStyledAttributes.getValue(i3, contentFrameLayout.getFixedWidthMajor());
        }
        int i4 = c.j.G0;
        if (typedArrayObtainStyledAttributes.hasValue(i4)) {
            typedArrayObtainStyledAttributes.getValue(i4, contentFrameLayout.getFixedWidthMinor());
        }
        int i5 = c.j.D0;
        if (typedArrayObtainStyledAttributes.hasValue(i5)) {
            typedArrayObtainStyledAttributes.getValue(i5, contentFrameLayout.getFixedHeightMajor());
        }
        int i6 = c.j.E0;
        if (typedArrayObtainStyledAttributes.hasValue(i6)) {
            typedArrayObtainStyledAttributes.getValue(i6, contentFrameLayout.getFixedHeightMinor());
        }
        typedArrayObtainStyledAttributes.recycle();
        contentFrameLayout.requestLayout();
    }

    private void H0() {
        if (this.f202y) {
            throw new AndroidRuntimeException("Window feature must be requested before adding content");
        }
    }

    private void I(Window window) {
        if (this.f187j != null) {
            throw new IllegalStateException("AppCompat has already installed itself into the Window");
        }
        Window.Callback callback = window.getCallback();
        if (callback instanceof o) {
            throw new IllegalStateException("AppCompat has already installed itself into the Window");
        }
        o oVar = new o(callback);
        this.f188k = oVar;
        window.setCallback(oVar);
        a1 a1VarU = a1.u(this.f186i, null, f176h0);
        Drawable drawableH = a1VarU.h(0);
        if (drawableH != null) {
            window.setBackgroundDrawable(drawableH);
        }
        a1VarU.w();
        this.f187j = window;
    }

    private androidx.appcompat.app.c I0() {
        for (Context baseContext = this.f186i; baseContext != null; baseContext = ((ContextWrapper) baseContext).getBaseContext()) {
            if (baseContext instanceof androidx.appcompat.app.c) {
                return (androidx.appcompat.app.c) baseContext;
            }
            if (!(baseContext instanceof ContextWrapper)) {
                break;
            }
        }
        return null;
    }

    private int J() {
        int i3 = this.R;
        return i3 != -100 ? i3 : androidx.appcompat.app.e.j();
    }

    private boolean J0(int i3, boolean z2) {
        boolean z3 = false;
        Configuration configurationP = P(this.f186i, i3, null, false);
        boolean zL0 = l0(this.f186i);
        Configuration configuration = this.Q;
        if (configuration == null) {
            configuration = this.f186i.getResources().getConfiguration();
        }
        int i4 = configuration.uiMode & 48;
        int i5 = configurationP.uiMode & 48;
        boolean z4 = true;
        if (i4 != i5 && z2 && !zL0 && this.N && (f177i0 || this.O)) {
            Object obj = this.f185h;
            if ((obj instanceof Activity) && !((Activity) obj).isChild()) {
                androidx.core.app.b.i((Activity) this.f185h);
                z3 = true;
            }
        }
        if (z3 || i4 == i5) {
            z4 = z3;
        } else {
            K0(i5, zL0, null);
        }
        if (z4) {
            Object obj2 = this.f185h;
            if (obj2 instanceof androidx.appcompat.app.c) {
                ((androidx.appcompat.app.c) obj2).I(i3);
            }
        }
        return z4;
    }

    /* JADX WARN: Multi-variable type inference failed */
    private void K0(int i3, boolean z2, Configuration configuration) {
        Resources resources = this.f186i.getResources();
        Configuration configuration2 = new Configuration(resources.getConfiguration());
        if (configuration != null) {
            configuration2.updateFrom(configuration);
        }
        configuration2.uiMode = i3 | (resources.getConfiguration().uiMode & (-49));
        resources.updateConfiguration(configuration2, null);
        int i4 = Build.VERSION.SDK_INT;
        if (i4 < 26) {
            androidx.appcompat.app.k.a(resources);
        }
        int i5 = this.S;
        if (i5 != 0) {
            this.f186i.setTheme(i5);
            if (i4 >= 23) {
                this.f186i.getTheme().applyStyle(this.S, true);
            }
        }
        if (z2) {
            Object obj = this.f185h;
            if (obj instanceof Activity) {
                Activity activity = (Activity) obj;
                if (activity instanceof androidx.lifecycle.k) {
                    if (((androidx.lifecycle.k) activity).a().b().isAtLeast(g.c.CREATED)) {
                        activity.onConfigurationChanged(configuration2);
                    }
                } else {
                    if (!this.O || this.P) {
                        return;
                    }
                    activity.onConfigurationChanged(configuration2);
                }
            }
        }
    }

    private void M() {
        q qVar = this.V;
        if (qVar != null) {
            qVar.a();
        }
        q qVar2 = this.W;
        if (qVar2 != null) {
            qVar2.a();
        }
    }

    private void M0(View view) {
        view.setBackgroundColor((y.N(view) & 8192) != 0 ? androidx.core.content.a.b(this.f186i, c.c.f3178b) : androidx.core.content.a.b(this.f186i, c.c.f3177a));
    }

    private Configuration P(Context context, int i3, Configuration configuration, boolean z2) {
        int i4 = i3 != 1 ? i3 != 2 ? z2 ? 0 : context.getApplicationContext().getResources().getConfiguration().uiMode & 48 : 32 : 16;
        Configuration configuration2 = new Configuration();
        configuration2.fontScale = 0.0f;
        if (configuration != null) {
            configuration2.setTo(configuration);
        }
        configuration2.uiMode = i4 | (configuration2.uiMode & (-49));
        return configuration2;
    }

    private ViewGroup Q() {
        ViewGroup viewGroup;
        TypedArray typedArrayObtainStyledAttributes = this.f186i.obtainStyledAttributes(c.j.f3363v0);
        int i3 = c.j.A0;
        if (!typedArrayObtainStyledAttributes.hasValue(i3)) {
            typedArrayObtainStyledAttributes.recycle();
            throw new IllegalStateException("You need to use a Theme.AppCompat theme (or descendant) with this activity.");
        }
        if (typedArrayObtainStyledAttributes.getBoolean(c.j.J0, false)) {
            z(1);
        } else if (typedArrayObtainStyledAttributes.getBoolean(i3, false)) {
            z(108);
        }
        if (typedArrayObtainStyledAttributes.getBoolean(c.j.B0, false)) {
            z(109);
        }
        if (typedArrayObtainStyledAttributes.getBoolean(c.j.C0, false)) {
            z(10);
        }
        this.H = typedArrayObtainStyledAttributes.getBoolean(c.j.f3366w0, false);
        typedArrayObtainStyledAttributes.recycle();
        X();
        this.f187j.getDecorView();
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(this.f186i);
        if (this.I) {
            viewGroup = this.G ? (ViewGroup) layoutInflaterFrom.inflate(c.g.f3266o, (ViewGroup) null) : (ViewGroup) layoutInflaterFrom.inflate(c.g.f3265n, (ViewGroup) null);
        } else if (this.H) {
            viewGroup = (ViewGroup) layoutInflaterFrom.inflate(c.g.f3257f, (ViewGroup) null);
            this.F = false;
            this.E = false;
        } else if (this.E) {
            TypedValue typedValue = new TypedValue();
            this.f186i.getTheme().resolveAttribute(c.a.f3155f, typedValue, true);
            viewGroup = (ViewGroup) LayoutInflater.from(typedValue.resourceId != 0 ? new androidx.appcompat.view.d(this.f186i, typedValue.resourceId) : this.f186i).inflate(c.g.f3267p, (ViewGroup) null);
            g0 g0Var = (g0) viewGroup.findViewById(c.f.f3241p);
            this.f193p = g0Var;
            g0Var.setWindowCallback(f0());
            if (this.F) {
                this.f193p.k(109);
            }
            if (this.C) {
                this.f193p.k(2);
            }
            if (this.D) {
                this.f193p.k(5);
            }
        } else {
            viewGroup = null;
        }
        if (viewGroup == null) {
            throw new IllegalArgumentException("AppCompat does not support the current theme features: { windowActionBar: " + this.E + ", windowActionBarOverlay: " + this.F + ", android:windowIsFloating: " + this.H + ", windowActionModeOverlay: " + this.G + ", windowNoTitle: " + this.I + " }");
        }
        if (Build.VERSION.SDK_INT >= 21) {
            y.D0(viewGroup, new c());
        } else if (viewGroup instanceof k0) {
            ((k0) viewGroup).setOnFitSystemWindowsListener(new d());
        }
        if (this.f193p == null) {
            this.A = (TextView) viewGroup.findViewById(c.f.M);
        }
        j1.c(viewGroup);
        ContentFrameLayout contentFrameLayout = (ContentFrameLayout) viewGroup.findViewById(c.f.f3227b);
        ViewGroup viewGroup2 = (ViewGroup) this.f187j.findViewById(R.id.content);
        if (viewGroup2 != null) {
            while (viewGroup2.getChildCount() > 0) {
                View childAt = viewGroup2.getChildAt(0);
                viewGroup2.removeViewAt(0);
                contentFrameLayout.addView(childAt);
            }
            viewGroup2.setId(-1);
            contentFrameLayout.setId(R.id.content);
            if (viewGroup2 instanceof FrameLayout) {
                ((FrameLayout) viewGroup2).setForeground(null);
            }
        }
        this.f187j.setContentView(viewGroup);
        contentFrameLayout.setAttachListener(new e());
        return viewGroup;
    }

    private void W() {
        if (this.f202y) {
            return;
        }
        this.f203z = Q();
        CharSequence charSequenceE0 = e0();
        if (!TextUtils.isEmpty(charSequenceE0)) {
            g0 g0Var = this.f193p;
            if (g0Var != null) {
                g0Var.setWindowTitle(charSequenceE0);
            } else if (y0() != null) {
                y0().t(charSequenceE0);
            } else {
                TextView textView = this.A;
                if (textView != null) {
                    textView.setText(charSequenceE0);
                }
            }
        }
        H();
        w0(this.f203z);
        this.f202y = true;
        u uVarD0 = d0(0, false);
        if (this.P) {
            return;
        }
        if (uVarD0 == null || uVarD0.f238j == null) {
            k0(108);
        }
    }

    private void X() {
        if (this.f187j == null) {
            Object obj = this.f185h;
            if (obj instanceof Activity) {
                I(((Activity) obj).getWindow());
            }
        }
        if (this.f187j == null) {
            throw new IllegalStateException("We have not been given a Window");
        }
    }

    private static Configuration Z(Configuration configuration, Configuration configuration2) {
        Configuration configuration3 = new Configuration();
        configuration3.fontScale = 0.0f;
        if (configuration2 != null && configuration.diff(configuration2) != 0) {
            float f3 = configuration.fontScale;
            float f4 = configuration2.fontScale;
            if (f3 != f4) {
                configuration3.fontScale = f4;
            }
            int i3 = configuration.mcc;
            int i4 = configuration2.mcc;
            if (i3 != i4) {
                configuration3.mcc = i4;
            }
            int i5 = configuration.mnc;
            int i6 = configuration2.mnc;
            if (i5 != i6) {
                configuration3.mnc = i6;
            }
            int i7 = Build.VERSION.SDK_INT;
            if (i7 >= 24) {
                m.a(configuration, configuration2, configuration3);
            } else if (!androidx.core.util.c.a(configuration.locale, configuration2.locale)) {
                configuration3.locale = configuration2.locale;
            }
            int i8 = configuration.touchscreen;
            int i9 = configuration2.touchscreen;
            if (i8 != i9) {
                configuration3.touchscreen = i9;
            }
            int i10 = configuration.keyboard;
            int i11 = configuration2.keyboard;
            if (i10 != i11) {
                configuration3.keyboard = i11;
            }
            int i12 = configuration.keyboardHidden;
            int i13 = configuration2.keyboardHidden;
            if (i12 != i13) {
                configuration3.keyboardHidden = i13;
            }
            int i14 = configuration.navigation;
            int i15 = configuration2.navigation;
            if (i14 != i15) {
                configuration3.navigation = i15;
            }
            int i16 = configuration.navigationHidden;
            int i17 = configuration2.navigationHidden;
            if (i16 != i17) {
                configuration3.navigationHidden = i17;
            }
            int i18 = configuration.orientation;
            int i19 = configuration2.orientation;
            if (i18 != i19) {
                configuration3.orientation = i19;
            }
            int i20 = configuration.screenLayout & 15;
            int i21 = configuration2.screenLayout;
            if (i20 != (i21 & 15)) {
                configuration3.screenLayout |= i21 & 15;
            }
            int i22 = configuration.screenLayout & 192;
            int i23 = configuration2.screenLayout;
            if (i22 != (i23 & 192)) {
                configuration3.screenLayout |= i23 & 192;
            }
            int i24 = configuration.screenLayout & 48;
            int i25 = configuration2.screenLayout;
            if (i24 != (i25 & 48)) {
                configuration3.screenLayout |= i25 & 48;
            }
            int i26 = configuration.screenLayout & 768;
            int i27 = configuration2.screenLayout;
            if (i26 != (i27 & 768)) {
                configuration3.screenLayout |= i27 & 768;
            }
            if (i7 >= 26) {
                n.a(configuration, configuration2, configuration3);
            }
            int i28 = configuration.uiMode & 15;
            int i29 = configuration2.uiMode;
            if (i28 != (i29 & 15)) {
                configuration3.uiMode |= i29 & 15;
            }
            int i30 = configuration.uiMode & 48;
            int i31 = configuration2.uiMode;
            if (i30 != (i31 & 48)) {
                configuration3.uiMode |= i31 & 48;
            }
            int i32 = configuration.screenWidthDp;
            int i33 = configuration2.screenWidthDp;
            if (i32 != i33) {
                configuration3.screenWidthDp = i33;
            }
            int i34 = configuration.screenHeightDp;
            int i35 = configuration2.screenHeightDp;
            if (i34 != i35) {
                configuration3.screenHeightDp = i35;
            }
            int i36 = configuration.smallestScreenWidthDp;
            int i37 = configuration2.smallestScreenWidthDp;
            if (i36 != i37) {
                configuration3.smallestScreenWidthDp = i37;
            }
            if (i7 >= 17) {
                k.b(configuration, configuration2, configuration3);
            }
        }
        return configuration3;
    }

    private q b0(Context context) {
        if (this.W == null) {
            this.W = new p(context);
        }
        return this.W;
    }

    private q c0(Context context) {
        if (this.V == null) {
            this.V = new r(androidx.appcompat.app.m.a(context));
        }
        return this.V;
    }

    private void g0() {
        W();
        if (this.E && this.f190m == null) {
            Object obj = this.f185h;
            if (obj instanceof Activity) {
                this.f190m = new androidx.appcompat.app.n((Activity) this.f185h, this.F);
            } else if (obj instanceof Dialog) {
                this.f190m = new androidx.appcompat.app.n((Dialog) this.f185h);
            }
            androidx.appcompat.app.a aVar = this.f190m;
            if (aVar != null) {
                aVar.r(this.f180a0);
            }
        }
    }

    private boolean h0(u uVar) {
        View view = uVar.f237i;
        if (view != null) {
            uVar.f236h = view;
            return true;
        }
        if (uVar.f238j == null) {
            return false;
        }
        if (this.f195r == null) {
            this.f195r = new v();
        }
        View view2 = (View) uVar.a(this.f195r);
        uVar.f236h = view2;
        return view2 != null;
    }

    private boolean i0(u uVar) {
        uVar.d(a0());
        uVar.f235g = new t(uVar.f240l);
        uVar.f231c = 81;
        return true;
    }

    private boolean j0(u uVar) {
        Context context = this.f186i;
        int i3 = uVar.f229a;
        if ((i3 == 0 || i3 == 108) && this.f193p != null) {
            TypedValue typedValue = new TypedValue();
            Resources.Theme theme = context.getTheme();
            theme.resolveAttribute(c.a.f3155f, typedValue, true);
            Resources.Theme themeNewTheme = null;
            if (typedValue.resourceId != 0) {
                themeNewTheme = context.getResources().newTheme();
                themeNewTheme.setTo(theme);
                themeNewTheme.applyStyle(typedValue.resourceId, true);
                themeNewTheme.resolveAttribute(c.a.f3156g, typedValue, true);
            } else {
                theme.resolveAttribute(c.a.f3156g, typedValue, true);
            }
            if (typedValue.resourceId != 0) {
                if (themeNewTheme == null) {
                    themeNewTheme = context.getResources().newTheme();
                    themeNewTheme.setTo(theme);
                }
                themeNewTheme.applyStyle(typedValue.resourceId, true);
            }
            if (themeNewTheme != null) {
                androidx.appcompat.view.d dVar = new androidx.appcompat.view.d(context, 0);
                dVar.getTheme().setTo(themeNewTheme);
                context = dVar;
            }
        }
        androidx.appcompat.view.menu.g gVar = new androidx.appcompat.view.menu.g(context);
        gVar.R(this);
        uVar.c(gVar);
        return true;
    }

    private void k0(int i3) {
        this.Y = (1 << i3) | this.Y;
        if (this.X) {
            return;
        }
        y.j0(this.f187j.getDecorView(), this.Z);
        this.X = true;
    }

    private boolean l0(Context context) {
        if (!this.U && (this.f185h instanceof Activity)) {
            PackageManager packageManager = context.getPackageManager();
            if (packageManager == null) {
                return false;
            }
            try {
                int i3 = Build.VERSION.SDK_INT;
                ActivityInfo activityInfo = packageManager.getActivityInfo(new ComponentName(context, this.f185h.getClass()), i3 >= 29 ? 269221888 : i3 >= 24 ? 786432 : 0);
                this.T = (activityInfo == null || (activityInfo.configChanges & 512) == 0) ? false : true;
            } catch (PackageManager.NameNotFoundException e3) {
                Log.d("AppCompatDelegate", "Exception while getting ActivityInfo", e3);
                this.T = false;
            }
        }
        this.U = true;
        return this.T;
    }

    private boolean q0(int i3, KeyEvent keyEvent) {
        if (keyEvent.getRepeatCount() != 0) {
            return false;
        }
        u uVarD0 = d0(i3, true);
        if (uVarD0.f243o) {
            return false;
        }
        return A0(uVarD0, keyEvent);
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x0062  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private boolean t0(int r5, android.view.KeyEvent r6) {
        /*
            r4 = this;
            androidx.appcompat.view.b r0 = r4.f196s
            r1 = 0
            if (r0 == 0) goto L6
            return r1
        L6:
            r0 = 1
            androidx.appcompat.app.f$u r2 = r4.d0(r5, r0)
            if (r5 != 0) goto L43
            androidx.appcompat.widget.g0 r5 = r4.f193p
            if (r5 == 0) goto L43
            boolean r5 = r5.h()
            if (r5 == 0) goto L43
            android.content.Context r5 = r4.f186i
            android.view.ViewConfiguration r5 = android.view.ViewConfiguration.get(r5)
            boolean r5 = r5.hasPermanentMenuKey()
            if (r5 != 0) goto L43
            androidx.appcompat.widget.g0 r5 = r4.f193p
            boolean r5 = r5.c()
            if (r5 != 0) goto L3c
            boolean r5 = r4.P
            if (r5 != 0) goto L62
            boolean r5 = r4.A0(r2, r6)
            if (r5 == 0) goto L62
            androidx.appcompat.widget.g0 r5 = r4.f193p
            boolean r0 = r5.f()
            goto L68
        L3c:
            androidx.appcompat.widget.g0 r5 = r4.f193p
            boolean r0 = r5.e()
            goto L68
        L43:
            boolean r5 = r2.f243o
            if (r5 != 0) goto L64
            boolean r3 = r2.f242n
            if (r3 == 0) goto L4c
            goto L64
        L4c:
            boolean r5 = r2.f241m
            if (r5 == 0) goto L62
            boolean r5 = r2.f246r
            if (r5 == 0) goto L5b
            r2.f241m = r1
            boolean r5 = r4.A0(r2, r6)
            goto L5c
        L5b:
            r5 = r0
        L5c:
            if (r5 == 0) goto L62
            r4.x0(r2, r6)
            goto L68
        L62:
            r0 = r1
            goto L68
        L64:
            r4.O(r2, r0)
            r0 = r5
        L68:
            if (r0 == 0) goto L85
            android.content.Context r4 = r4.f186i
            android.content.Context r4 = r4.getApplicationContext()
            java.lang.String r5 = "audio"
            java.lang.Object r4 = r4.getSystemService(r5)
            android.media.AudioManager r4 = (android.media.AudioManager) r4
            if (r4 == 0) goto L7e
            r4.playSoundEffect(r1)
            goto L85
        L7e:
            java.lang.String r4 = "AppCompatDelegate"
            java.lang.String r5 = "Couldn't get audio manager"
            android.util.Log.w(r4, r5)
        L85:
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.app.f.t0(int, android.view.KeyEvent):boolean");
    }

    private void x0(u uVar, KeyEvent keyEvent) {
        int i3;
        ViewGroup.LayoutParams layoutParams;
        if (uVar.f243o || this.P) {
            return;
        }
        if (uVar.f229a == 0) {
            if ((this.f186i.getResources().getConfiguration().screenLayout & 15) == 4) {
                return;
            }
        }
        Window.Callback callbackF0 = f0();
        if (callbackF0 != null && !callbackF0.onMenuOpened(uVar.f229a, uVar.f238j)) {
            O(uVar, true);
            return;
        }
        WindowManager windowManager = (WindowManager) this.f186i.getSystemService("window");
        if (windowManager != null && A0(uVar, keyEvent)) {
            ViewGroup viewGroup = uVar.f235g;
            if (viewGroup != null && !uVar.f245q) {
                View view = uVar.f237i;
                if (view != null && (layoutParams = view.getLayoutParams()) != null && layoutParams.width == -1) {
                    i3 = -1;
                }
                uVar.f242n = false;
                WindowManager.LayoutParams layoutParams2 = new WindowManager.LayoutParams(i3, -2, uVar.f232d, uVar.f233e, 1002, 8519680, -3);
                layoutParams2.gravity = uVar.f231c;
                layoutParams2.windowAnimations = uVar.f234f;
                windowManager.addView(uVar.f235g, layoutParams2);
                uVar.f243o = true;
            }
            if (viewGroup == null) {
                if (!i0(uVar) || uVar.f235g == null) {
                    return;
                }
            } else if (uVar.f245q && viewGroup.getChildCount() > 0) {
                uVar.f235g.removeAllViews();
            }
            if (!h0(uVar) || !uVar.b()) {
                uVar.f245q = true;
                return;
            }
            ViewGroup.LayoutParams layoutParams3 = uVar.f236h.getLayoutParams();
            if (layoutParams3 == null) {
                layoutParams3 = new ViewGroup.LayoutParams(-2, -2);
            }
            uVar.f235g.setBackgroundResource(uVar.f230b);
            ViewParent parent = uVar.f236h.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(uVar.f236h);
            }
            uVar.f235g.addView(uVar.f236h, layoutParams3);
            if (!uVar.f236h.hasFocus()) {
                uVar.f236h.requestFocus();
            }
            i3 = -2;
            uVar.f242n = false;
            WindowManager.LayoutParams layoutParams22 = new WindowManager.LayoutParams(i3, -2, uVar.f232d, uVar.f233e, 1002, 8519680, -3);
            layoutParams22.gravity = uVar.f231c;
            layoutParams22.windowAnimations = uVar.f234f;
            windowManager.addView(uVar.f235g, layoutParams22);
            uVar.f243o = true;
        }
    }

    private boolean z0(u uVar, int i3, KeyEvent keyEvent, int i4) {
        androidx.appcompat.view.menu.g gVar;
        boolean zPerformShortcut = false;
        if (keyEvent.isSystem()) {
            return false;
        }
        if ((uVar.f241m || A0(uVar, keyEvent)) && (gVar = uVar.f238j) != null) {
            zPerformShortcut = gVar.performShortcut(i3, keyEvent, i4);
        }
        if (zPerformShortcut && (i4 & 1) == 0 && this.f193p == null) {
            O(uVar, true);
        }
        return zPerformShortcut;
    }

    @Override // androidx.appcompat.app.e
    public void A(int i3) {
        W();
        ViewGroup viewGroup = (ViewGroup) this.f203z.findViewById(R.id.content);
        viewGroup.removeAllViews();
        LayoutInflater.from(this.f186i).inflate(i3, viewGroup);
        this.f188k.c(this.f187j.getCallback());
    }

    @Override // androidx.appcompat.app.e
    public void B(View view) {
        W();
        ViewGroup viewGroup = (ViewGroup) this.f203z.findViewById(R.id.content);
        viewGroup.removeAllViews();
        viewGroup.addView(view);
        this.f188k.c(this.f187j.getCallback());
    }

    @Override // androidx.appcompat.app.e
    public void C(View view, ViewGroup.LayoutParams layoutParams) {
        W();
        ViewGroup viewGroup = (ViewGroup) this.f203z.findViewById(R.id.content);
        viewGroup.removeAllViews();
        viewGroup.addView(view, layoutParams);
        this.f188k.c(this.f187j.getCallback());
    }

    @Override // androidx.appcompat.app.e
    public void D(int i3) {
        this.S = i3;
    }

    final boolean D0() {
        ViewGroup viewGroup;
        return this.f202y && (viewGroup = this.f203z) != null && y.V(viewGroup);
    }

    @Override // androidx.appcompat.app.e
    public final void E(CharSequence charSequence) {
        this.f192o = charSequence;
        g0 g0Var = this.f193p;
        if (g0Var != null) {
            g0Var.setWindowTitle(charSequence);
            return;
        }
        if (y0() != null) {
            y0().t(charSequence);
            return;
        }
        TextView textView = this.A;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }

    public boolean F() {
        return G(true);
    }

    public androidx.appcompat.view.b F0(b.a aVar) {
        androidx.appcompat.app.d dVar;
        if (aVar == null) {
            throw new IllegalArgumentException("ActionMode callback can not be null.");
        }
        androidx.appcompat.view.b bVar = this.f196s;
        if (bVar != null) {
            bVar.c();
        }
        j jVar = new j(aVar);
        androidx.appcompat.app.a aVarM = m();
        if (aVarM != null) {
            androidx.appcompat.view.b bVarU = aVarM.u(jVar);
            this.f196s = bVarU;
            if (bVarU != null && (dVar = this.f189l) != null) {
                dVar.h(bVarU);
            }
        }
        if (this.f196s == null) {
            this.f196s = G0(jVar);
        }
        return this.f196s;
    }

    androidx.appcompat.view.b G0(b.a aVar) {
        androidx.appcompat.view.b bVarK;
        Context dVar;
        androidx.appcompat.app.d dVar2;
        V();
        androidx.appcompat.view.b bVar = this.f196s;
        if (bVar != null) {
            bVar.c();
        }
        if (!(aVar instanceof j)) {
            aVar = new j(aVar);
        }
        androidx.appcompat.app.d dVar3 = this.f189l;
        if (dVar3 == null || this.P) {
            bVarK = null;
        } else {
            try {
                bVarK = dVar3.k(aVar);
            } catch (AbstractMethodError unused) {
                bVarK = null;
            }
        }
        if (bVarK != null) {
            this.f196s = bVarK;
        } else {
            if (this.f197t == null) {
                if (this.H) {
                    TypedValue typedValue = new TypedValue();
                    Resources.Theme theme = this.f186i.getTheme();
                    theme.resolveAttribute(c.a.f3155f, typedValue, true);
                    if (typedValue.resourceId != 0) {
                        Resources.Theme themeNewTheme = this.f186i.getResources().newTheme();
                        themeNewTheme.setTo(theme);
                        themeNewTheme.applyStyle(typedValue.resourceId, true);
                        dVar = new androidx.appcompat.view.d(this.f186i, 0);
                        dVar.getTheme().setTo(themeNewTheme);
                    } else {
                        dVar = this.f186i;
                    }
                    this.f197t = new ActionBarContextView(dVar);
                    PopupWindow popupWindow = new PopupWindow(dVar, (AttributeSet) null, c.a.f3158i);
                    this.f198u = popupWindow;
                    androidx.core.widget.i.b(popupWindow, 2);
                    this.f198u.setContentView(this.f197t);
                    this.f198u.setWidth(-1);
                    dVar.getTheme().resolveAttribute(c.a.f3151b, typedValue, true);
                    this.f197t.setContentHeight(TypedValue.complexToDimensionPixelSize(typedValue.data, dVar.getResources().getDisplayMetrics()));
                    this.f198u.setHeight(-2);
                    this.f199v = new RunnableC0003f();
                } else {
                    ViewStubCompat viewStubCompat = (ViewStubCompat) this.f203z.findViewById(c.f.f3233h);
                    if (viewStubCompat != null) {
                        viewStubCompat.setLayoutInflater(LayoutInflater.from(a0()));
                        this.f197t = (ActionBarContextView) viewStubCompat.a();
                    }
                }
            }
            if (this.f197t != null) {
                V();
                this.f197t.k();
                androidx.appcompat.view.e eVar = new androidx.appcompat.view.e(this.f197t.getContext(), this.f197t, aVar, this.f198u == null);
                if (aVar.c(eVar, eVar.e())) {
                    eVar.k();
                    this.f197t.h(eVar);
                    this.f196s = eVar;
                    if (D0()) {
                        this.f197t.setAlpha(0.0f);
                        e0 e0VarB = y.e(this.f197t).b(1.0f);
                        this.f200w = e0VarB;
                        e0VarB.h(new g());
                    } else {
                        this.f197t.setAlpha(1.0f);
                        this.f197t.setVisibility(0);
                        if (this.f197t.getParent() instanceof View) {
                            y.o0((View) this.f197t.getParent());
                        }
                    }
                    if (this.f198u != null) {
                        this.f187j.getDecorView().post(this.f199v);
                    }
                } else {
                    this.f196s = null;
                }
            }
        }
        androidx.appcompat.view.b bVar2 = this.f196s;
        if (bVar2 != null && (dVar2 = this.f189l) != null) {
            dVar2.h(bVar2);
        }
        return this.f196s;
    }

    void K(int i3, u uVar, Menu menu) {
        if (menu == null) {
            if (uVar == null && i3 >= 0) {
                u[] uVarArr = this.K;
                if (i3 < uVarArr.length) {
                    uVar = uVarArr[i3];
                }
            }
            if (uVar != null) {
                menu = uVar.f238j;
            }
        }
        if ((uVar == null || uVar.f243o) && !this.P) {
            this.f188k.d(this.f187j.getCallback(), i3, menu);
        }
    }

    void L(androidx.appcompat.view.menu.g gVar) {
        if (this.J) {
            return;
        }
        this.J = true;
        this.f193p.l();
        Window.Callback callbackF0 = f0();
        if (callbackF0 != null && !this.P) {
            callbackF0.onPanelClosed(108, gVar);
        }
        this.J = false;
    }

    final int L0(j0 j0Var, Rect rect) {
        boolean z2;
        boolean z3;
        int iK = j0Var != null ? j0Var.k() : rect != null ? rect.top : 0;
        ActionBarContextView actionBarContextView = this.f197t;
        if (actionBarContextView == null || !(actionBarContextView.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) {
            z2 = false;
        } else {
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.f197t.getLayoutParams();
            if (this.f197t.isShown()) {
                if (this.f181b0 == null) {
                    this.f181b0 = new Rect();
                    this.f182c0 = new Rect();
                }
                Rect rect2 = this.f181b0;
                Rect rect3 = this.f182c0;
                if (j0Var == null) {
                    rect2.set(rect);
                } else {
                    rect2.set(j0Var.i(), j0Var.k(), j0Var.j(), j0Var.h());
                }
                j1.a(this.f203z, rect2, rect3);
                int i3 = rect2.top;
                int i4 = rect2.left;
                int i5 = rect2.right;
                j0 j0VarK = y.K(this.f203z);
                int i6 = j0VarK == null ? 0 : j0VarK.i();
                int iJ = j0VarK == null ? 0 : j0VarK.j();
                if (marginLayoutParams.topMargin == i3 && marginLayoutParams.leftMargin == i4 && marginLayoutParams.rightMargin == i5) {
                    z3 = false;
                } else {
                    marginLayoutParams.topMargin = i3;
                    marginLayoutParams.leftMargin = i4;
                    marginLayoutParams.rightMargin = i5;
                    z3 = true;
                }
                if (i3 <= 0 || this.B != null) {
                    View view = this.B;
                    if (view != null) {
                        ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
                        int i7 = marginLayoutParams2.height;
                        int i8 = marginLayoutParams.topMargin;
                        if (i7 != i8 || marginLayoutParams2.leftMargin != i6 || marginLayoutParams2.rightMargin != iJ) {
                            marginLayoutParams2.height = i8;
                            marginLayoutParams2.leftMargin = i6;
                            marginLayoutParams2.rightMargin = iJ;
                            this.B.setLayoutParams(marginLayoutParams2);
                        }
                    }
                } else {
                    View view2 = new View(this.f186i);
                    this.B = view2;
                    view2.setVisibility(8);
                    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, marginLayoutParams.topMargin, 51);
                    layoutParams.leftMargin = i6;
                    layoutParams.rightMargin = iJ;
                    this.f203z.addView(this.B, -1, layoutParams);
                }
                View view3 = this.B;
                z = view3 != null;
                if (z && view3.getVisibility() != 0) {
                    M0(this.B);
                }
                if (!this.G && z) {
                    iK = 0;
                }
                z2 = z;
                z = z3;
            } else if (marginLayoutParams.topMargin != 0) {
                marginLayoutParams.topMargin = 0;
                z2 = false;
            } else {
                z2 = false;
                z = false;
            }
            if (z) {
                this.f197t.setLayoutParams(marginLayoutParams);
            }
        }
        View view4 = this.B;
        if (view4 != null) {
            view4.setVisibility(z2 ? 0 : 8);
        }
        return iK;
    }

    void N(int i3) {
        O(d0(i3, true), true);
    }

    void O(u uVar, boolean z2) {
        ViewGroup viewGroup;
        g0 g0Var;
        if (z2 && uVar.f229a == 0 && (g0Var = this.f193p) != null && g0Var.c()) {
            L(uVar.f238j);
            return;
        }
        WindowManager windowManager = (WindowManager) this.f186i.getSystemService("window");
        if (windowManager != null && uVar.f243o && (viewGroup = uVar.f235g) != null) {
            windowManager.removeView(viewGroup);
            if (z2) {
                K(uVar.f229a, uVar, null);
            }
        }
        uVar.f241m = false;
        uVar.f242n = false;
        uVar.f243o = false;
        uVar.f236h = null;
        uVar.f245q = true;
        if (this.L == uVar) {
            this.L = null;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public View R(View view, String str, Context context, AttributeSet attributeSet) {
        boolean z2;
        boolean z3 = false;
        if (this.f183d0 == null) {
            String string = this.f186i.obtainStyledAttributes(c.j.f3363v0).getString(c.j.f3375z0);
            if (string == null) {
                this.f183d0 = new androidx.appcompat.app.i();
            } else {
                try {
                    this.f183d0 = (androidx.appcompat.app.i) this.f186i.getClassLoader().loadClass(string).getDeclaredConstructor(new Class[0]).newInstance(new Object[0]);
                } catch (Throwable th) {
                    Log.i("AppCompatDelegate", "Failed to instantiate custom view inflater " + string + ". Falling back to default.", th);
                    this.f183d0 = new androidx.appcompat.app.i();
                }
            }
        }
        boolean z4 = f175g0;
        boolean zE0 = true;
        if (z4) {
            if (this.f184e0 == null) {
                this.f184e0 = new androidx.appcompat.app.j();
            }
            if (this.f184e0.a(attributeSet)) {
                z2 = true;
            } else {
                if (attributeSet instanceof XmlPullParser) {
                    if (((XmlPullParser) attributeSet).getDepth() > 1) {
                    }
                    z2 = z3;
                } else {
                    zE0 = E0((ViewParent) view);
                }
                z3 = zE0;
                z2 = z3;
            }
        } else {
            z2 = z3;
        }
        return this.f183d0.r(view, str, context, attributeSet, z2, z4, true, i1.c());
    }

    void S() {
        androidx.appcompat.view.menu.g gVar;
        g0 g0Var = this.f193p;
        if (g0Var != null) {
            g0Var.l();
        }
        if (this.f198u != null) {
            this.f187j.getDecorView().removeCallbacks(this.f199v);
            if (this.f198u.isShowing()) {
                try {
                    this.f198u.dismiss();
                } catch (IllegalArgumentException unused) {
                }
            }
            this.f198u = null;
        }
        V();
        u uVarD0 = d0(0, false);
        if (uVarD0 == null || (gVar = uVarD0.f238j) == null) {
            return;
        }
        gVar.close();
    }

    boolean T(KeyEvent keyEvent) {
        View decorView;
        Object obj = this.f185h;
        if (((obj instanceof f.a) || (obj instanceof androidx.appcompat.app.h)) && (decorView = this.f187j.getDecorView()) != null && androidx.core.view.f.d(decorView, keyEvent)) {
            return true;
        }
        if (keyEvent.getKeyCode() == 82 && this.f188k.b(this.f187j.getCallback(), keyEvent)) {
            return true;
        }
        int keyCode = keyEvent.getKeyCode();
        return keyEvent.getAction() == 0 ? p0(keyCode, keyEvent) : s0(keyCode, keyEvent);
    }

    void U(int i3) {
        u uVarD0;
        u uVarD02 = d0(i3, true);
        if (uVarD02.f238j != null) {
            Bundle bundle = new Bundle();
            uVarD02.f238j.Q(bundle);
            if (bundle.size() > 0) {
                uVarD02.f247s = bundle;
            }
            uVarD02.f238j.d0();
            uVarD02.f238j.clear();
        }
        uVarD02.f246r = true;
        uVarD02.f245q = true;
        if ((i3 != 108 && i3 != 0) || this.f193p == null || (uVarD0 = d0(0, false)) == null) {
            return;
        }
        uVarD0.f241m = false;
        A0(uVarD0, null);
    }

    void V() {
        e0 e0Var = this.f200w;
        if (e0Var != null) {
            e0Var.c();
        }
    }

    u Y(Menu menu) {
        u[] uVarArr = this.K;
        int length = uVarArr != null ? uVarArr.length : 0;
        for (int i3 = 0; i3 < length; i3++) {
            u uVar = uVarArr[i3];
            if (uVar != null && uVar.f238j == menu) {
                return uVar;
            }
        }
        return null;
    }

    @Override // androidx.appcompat.view.menu.g.a
    public boolean a(androidx.appcompat.view.menu.g gVar, MenuItem menuItem) {
        u uVarY;
        Window.Callback callbackF0 = f0();
        if (callbackF0 == null || this.P || (uVarY = Y(gVar.D())) == null) {
            return false;
        }
        return callbackF0.onMenuItemSelected(uVarY.f229a, menuItem);
    }

    final Context a0() {
        androidx.appcompat.app.a aVarM = m();
        Context contextK = aVarM != null ? aVarM.k() : null;
        return contextK == null ? this.f186i : contextK;
    }

    @Override // androidx.appcompat.view.menu.g.a
    public void b(androidx.appcompat.view.menu.g gVar) {
        B0(true);
    }

    @Override // androidx.appcompat.app.e
    public void d(View view, ViewGroup.LayoutParams layoutParams) {
        W();
        ((ViewGroup) this.f203z.findViewById(R.id.content)).addView(view, layoutParams);
        this.f188k.c(this.f187j.getCallback());
    }

    protected u d0(int i3, boolean z2) {
        u[] uVarArr = this.K;
        if (uVarArr == null || uVarArr.length <= i3) {
            u[] uVarArr2 = new u[i3 + 1];
            if (uVarArr != null) {
                System.arraycopy(uVarArr, 0, uVarArr2, 0, uVarArr.length);
            }
            this.K = uVarArr2;
            uVarArr = uVarArr2;
        }
        u uVar = uVarArr[i3];
        if (uVar != null) {
            return uVar;
        }
        u uVar2 = new u(i3);
        uVarArr[i3] = uVar2;
        return uVar2;
    }

    final CharSequence e0() {
        Object obj = this.f185h;
        return obj instanceof Activity ? ((Activity) obj).getTitle() : this.f192o;
    }

    @Override // androidx.appcompat.app.e
    public Context f(Context context) {
        this.N = true;
        int iN0 = n0(context, J());
        Configuration configurationZ = null;
        boolean z2 = false;
        if (f178j0 && (context instanceof ContextThemeWrapper)) {
            try {
                s.a((ContextThemeWrapper) context, P(context, iN0, null, false));
                return context;
            } catch (IllegalStateException unused) {
            }
        }
        if (context instanceof androidx.appcompat.view.d) {
            try {
                ((androidx.appcompat.view.d) context).a(P(context, iN0, null, false));
                return context;
            } catch (IllegalStateException unused2) {
            }
        }
        if (!f177i0) {
            return super.f(context);
        }
        if (Build.VERSION.SDK_INT >= 17) {
            Configuration configuration = new Configuration();
            configuration.uiMode = -1;
            configuration.fontScale = 0.0f;
            Configuration configuration2 = k.a(context, configuration).getResources().getConfiguration();
            Configuration configuration3 = context.getResources().getConfiguration();
            configuration2.uiMode = configuration3.uiMode;
            if (!configuration2.equals(configuration3)) {
                configurationZ = Z(configuration2, configuration3);
            }
        }
        Configuration configurationP = P(context, iN0, configurationZ, true);
        androidx.appcompat.view.d dVar = new androidx.appcompat.view.d(context, c.i.f3286c);
        dVar.a(configurationP);
        try {
            z2 = context.getTheme() != null;
        } catch (NullPointerException unused3) {
        }
        if (z2) {
            h.g.a(dVar.getTheme());
        }
        return super.f(dVar);
    }

    final Window.Callback f0() {
        return this.f187j.getCallback();
    }

    @Override // androidx.appcompat.app.e
    public <T extends View> T i(int i3) {
        W();
        return (T) this.f187j.findViewById(i3);
    }

    @Override // androidx.appcompat.app.e
    public int k() {
        return this.R;
    }

    @Override // androidx.appcompat.app.e
    public MenuInflater l() {
        if (this.f191n == null) {
            g0();
            androidx.appcompat.app.a aVar = this.f190m;
            this.f191n = new androidx.appcompat.view.g(aVar != null ? aVar.k() : this.f186i);
        }
        return this.f191n;
    }

    @Override // androidx.appcompat.app.e
    public androidx.appcompat.app.a m() {
        g0();
        return this.f190m;
    }

    public boolean m0() {
        return this.f201x;
    }

    @Override // androidx.appcompat.app.e
    public void n() {
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(this.f186i);
        if (layoutInflaterFrom.getFactory() == null) {
            androidx.core.view.g.b(layoutInflaterFrom, this);
        } else {
            if (layoutInflaterFrom.getFactory2() instanceof f) {
                return;
            }
            Log.i("AppCompatDelegate", "The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's");
        }
    }

    int n0(Context context, int i3) {
        if (i3 == -100) {
            return -1;
        }
        if (i3 != -1) {
            if (i3 == 0) {
                if (Build.VERSION.SDK_INT < 23 || ((UiModeManager) context.getApplicationContext().getSystemService("uimode")).getNightMode() != 0) {
                    return c0(context).c();
                }
                return -1;
            }
            if (i3 != 1 && i3 != 2) {
                if (i3 == 3) {
                    return b0(context).c();
                }
                throw new IllegalStateException("Unknown value set for night mode. Please use one of the MODE_NIGHT values from AppCompatDelegate.");
            }
        }
        return i3;
    }

    @Override // androidx.appcompat.app.e
    public void o() {
        if (y0() == null || m().l()) {
            return;
        }
        k0(0);
    }

    boolean o0() {
        androidx.appcompat.view.b bVar = this.f196s;
        if (bVar != null) {
            bVar.c();
            return true;
        }
        androidx.appcompat.app.a aVarM = m();
        return aVarM != null && aVarM.h();
    }

    @Override // android.view.LayoutInflater.Factory2
    public final View onCreateView(View view, String str, Context context, AttributeSet attributeSet) {
        return R(view, str, context, attributeSet);
    }

    @Override // androidx.appcompat.app.e
    public void p(Configuration configuration) {
        androidx.appcompat.app.a aVarM;
        if (this.E && this.f202y && (aVarM = m()) != null) {
            aVarM.m(configuration);
        }
        androidx.appcompat.widget.k.b().g(this.f186i);
        this.Q = new Configuration(this.f186i.getResources().getConfiguration());
        G(false);
        configuration.updateFrom(this.f186i.getResources().getConfiguration());
    }

    boolean p0(int i3, KeyEvent keyEvent) {
        if (i3 == 4) {
            this.M = (keyEvent.getFlags() & 128) != 0;
        } else if (i3 == 82) {
            q0(0, keyEvent);
            return true;
        }
        return false;
    }

    @Override // androidx.appcompat.app.e
    public void q(Bundle bundle) {
        this.N = true;
        G(false);
        X();
        Object obj = this.f185h;
        if (obj instanceof Activity) {
            String strC = null;
            try {
                strC = androidx.core.app.g.c((Activity) obj);
            } catch (IllegalArgumentException unused) {
            }
            if (strC != null) {
                androidx.appcompat.app.a aVarY0 = y0();
                if (aVarY0 == null) {
                    this.f180a0 = true;
                } else {
                    aVarY0.r(true);
                }
            }
            androidx.appcompat.app.e.c(this);
        }
        this.Q = new Configuration(this.f186i.getResources().getConfiguration());
        this.O = true;
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0045  */
    @Override // androidx.appcompat.app.e
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void r() {
        /*
            r3 = this;
            java.lang.Object r0 = r3.f185h
            boolean r0 = r0 instanceof android.app.Activity
            if (r0 == 0) goto L9
            androidx.appcompat.app.e.x(r3)
        L9:
            boolean r0 = r3.X
            if (r0 == 0) goto L18
            android.view.Window r0 = r3.f187j
            android.view.View r0 = r0.getDecorView()
            java.lang.Runnable r1 = r3.Z
            r0.removeCallbacks(r1)
        L18:
            r0 = 1
            r3.P = r0
            int r0 = r3.R
            r1 = -100
            if (r0 == r1) goto L45
            java.lang.Object r0 = r3.f185h
            boolean r1 = r0 instanceof android.app.Activity
            if (r1 == 0) goto L45
            android.app.Activity r0 = (android.app.Activity) r0
            boolean r0 = r0.isChangingConfigurations()
            if (r0 == 0) goto L45
            j.g<java.lang.String, java.lang.Integer> r0 = androidx.appcompat.app.f.f174f0
            java.lang.Object r1 = r3.f185h
            java.lang.Class r1 = r1.getClass()
            java.lang.String r1 = r1.getName()
            int r2 = r3.R
            java.lang.Integer r2 = java.lang.Integer.valueOf(r2)
            r0.put(r1, r2)
            goto L54
        L45:
            j.g<java.lang.String, java.lang.Integer> r0 = androidx.appcompat.app.f.f174f0
            java.lang.Object r1 = r3.f185h
            java.lang.Class r1 = r1.getClass()
            java.lang.String r1 = r1.getName()
            r0.remove(r1)
        L54:
            androidx.appcompat.app.a r0 = r3.f190m
            if (r0 == 0) goto L5b
            r0.n()
        L5b:
            r3.M()
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.app.f.r():void");
    }

    boolean r0(int i3, KeyEvent keyEvent) {
        androidx.appcompat.app.a aVarM = m();
        if (aVarM != null && aVarM.o(i3, keyEvent)) {
            return true;
        }
        u uVar = this.L;
        if (uVar != null && z0(uVar, keyEvent.getKeyCode(), keyEvent, 1)) {
            u uVar2 = this.L;
            if (uVar2 != null) {
                uVar2.f242n = true;
            }
            return true;
        }
        if (this.L == null) {
            u uVarD0 = d0(0, true);
            A0(uVarD0, keyEvent);
            boolean zZ0 = z0(uVarD0, keyEvent.getKeyCode(), keyEvent, 1);
            uVarD0.f241m = false;
            if (zZ0) {
                return true;
            }
        }
        return false;
    }

    @Override // androidx.appcompat.app.e
    public void s(Bundle bundle) {
        W();
    }

    boolean s0(int i3, KeyEvent keyEvent) {
        if (i3 == 4) {
            boolean z2 = this.M;
            this.M = false;
            u uVarD0 = d0(0, false);
            if (uVarD0 != null && uVarD0.f243o) {
                if (!z2) {
                    O(uVarD0, true);
                }
                return true;
            }
            if (o0()) {
                return true;
            }
        } else if (i3 == 82) {
            t0(0, keyEvent);
            return true;
        }
        return false;
    }

    @Override // androidx.appcompat.app.e
    public void t() {
        androidx.appcompat.app.a aVarM = m();
        if (aVarM != null) {
            aVarM.s(true);
        }
    }

    @Override // androidx.appcompat.app.e
    public void u(Bundle bundle) {
    }

    void u0(int i3) {
        androidx.appcompat.app.a aVarM;
        if (i3 != 108 || (aVarM = m()) == null) {
            return;
        }
        aVarM.i(true);
    }

    @Override // androidx.appcompat.app.e
    public void v() {
        F();
    }

    void v0(int i3) {
        if (i3 == 108) {
            androidx.appcompat.app.a aVarM = m();
            if (aVarM != null) {
                aVarM.i(false);
                return;
            }
            return;
        }
        if (i3 == 0) {
            u uVarD0 = d0(i3, true);
            if (uVarD0.f243o) {
                O(uVarD0, false);
            }
        }
    }

    @Override // androidx.appcompat.app.e
    public void w() {
        androidx.appcompat.app.a aVarM = m();
        if (aVarM != null) {
            aVarM.s(false);
        }
    }

    void w0(ViewGroup viewGroup) {
    }

    final androidx.appcompat.app.a y0() {
        return this.f190m;
    }

    @Override // androidx.appcompat.app.e
    public boolean z(int i3) {
        int iC0 = C0(i3);
        if (this.I && iC0 == 108) {
            return false;
        }
        if (this.E && iC0 == 1) {
            this.E = false;
        }
        if (iC0 == 1) {
            H0();
            this.I = true;
            return true;
        }
        if (iC0 == 2) {
            H0();
            this.C = true;
            return true;
        }
        if (iC0 == 5) {
            H0();
            this.D = true;
            return true;
        }
        if (iC0 == 10) {
            H0();
            this.G = true;
            return true;
        }
        if (iC0 == 108) {
            H0();
            this.E = true;
            return true;
        }
        if (iC0 != 109) {
            return this.f187j.requestFeature(iC0);
        }
        H0();
        this.F = true;
        return true;
    }

    f(Dialog dialog, androidx.appcompat.app.d dVar) {
        this(dialog.getContext(), dialog.getWindow(), dVar, dialog);
    }

    @Override // android.view.LayoutInflater.Factory
    public View onCreateView(String str, Context context, AttributeSet attributeSet) {
        return onCreateView(null, str, context, attributeSet);
    }

    private f(Context context, Window window, androidx.appcompat.app.d dVar, Object obj) {
        j.g<String, Integer> gVar;
        Integer num;
        androidx.appcompat.app.c cVarI0;
        this.f200w = null;
        this.f201x = true;
        this.R = -100;
        this.Z = new b();
        this.f186i = context;
        this.f189l = dVar;
        this.f185h = obj;
        if (this.R == -100 && (obj instanceof Dialog) && (cVarI0 = I0()) != null) {
            this.R = cVarI0.E().k();
        }
        if (this.R == -100 && (num = (gVar = f174f0).get(obj.getClass().getName())) != null) {
            this.R = num.intValue();
            gVar.remove(obj.getClass().getName());
        }
        if (window != null) {
            I(window);
        }
        androidx.appcompat.widget.k.h();
    }

    /* JADX INFO: compiled from: AppCompatDelegateImpl.java */
    class o extends androidx.appcompat.view.i {

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private h f216f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private boolean f217g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        private boolean f218h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        private boolean f219i;

        o(Window.Callback callback) {
            super(callback);
        }

        public boolean b(Window.Callback callback, KeyEvent keyEvent) {
            try {
                this.f218h = true;
                return callback.dispatchKeyEvent(keyEvent);
            } finally {
                this.f218h = false;
            }
        }

        public void c(Window.Callback callback) {
            try {
                this.f217g = true;
                callback.onContentChanged();
            } finally {
                this.f217g = false;
            }
        }

        public void d(Window.Callback callback, int i3, Menu menu) {
            try {
                this.f219i = true;
                callback.onPanelClosed(i3, menu);
            } finally {
                this.f219i = false;
            }
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public boolean dispatchKeyEvent(KeyEvent keyEvent) {
            return this.f218h ? a().dispatchKeyEvent(keyEvent) : f.this.T(keyEvent) || super.dispatchKeyEvent(keyEvent);
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public boolean dispatchKeyShortcutEvent(KeyEvent keyEvent) {
            return super.dispatchKeyShortcutEvent(keyEvent) || f.this.r0(keyEvent.getKeyCode(), keyEvent);
        }

        final ActionMode e(ActionMode.Callback callback) {
            f.a aVar = new f.a(f.this.f186i, callback);
            androidx.appcompat.view.b bVarF0 = f.this.F0(aVar);
            if (bVarF0 != null) {
                return aVar.e(bVarF0);
            }
            return null;
        }

        @Override // android.view.Window.Callback
        public void onContentChanged() {
            if (this.f217g) {
                a().onContentChanged();
            }
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public boolean onCreatePanelMenu(int i3, Menu menu) {
            if (i3 != 0 || (menu instanceof androidx.appcompat.view.menu.g)) {
                return super.onCreatePanelMenu(i3, menu);
            }
            return false;
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public View onCreatePanelView(int i3) {
            View viewOnCreatePanelView;
            h hVar = this.f216f;
            return (hVar == null || (viewOnCreatePanelView = hVar.onCreatePanelView(i3)) == null) ? super.onCreatePanelView(i3) : viewOnCreatePanelView;
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public boolean onMenuOpened(int i3, Menu menu) {
            super.onMenuOpened(i3, menu);
            f.this.u0(i3);
            return true;
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public void onPanelClosed(int i3, Menu menu) {
            if (this.f219i) {
                a().onPanelClosed(i3, menu);
            } else {
                super.onPanelClosed(i3, menu);
                f.this.v0(i3);
            }
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public boolean onPreparePanel(int i3, View view, Menu menu) {
            androidx.appcompat.view.menu.g gVar = menu instanceof androidx.appcompat.view.menu.g ? (androidx.appcompat.view.menu.g) menu : null;
            if (i3 == 0 && gVar == null) {
                return false;
            }
            if (gVar != null) {
                gVar.a0(true);
            }
            h hVar = this.f216f;
            boolean zOnPreparePanel = hVar != null && hVar.a(i3);
            if (!zOnPreparePanel) {
                zOnPreparePanel = super.onPreparePanel(i3, view, menu);
            }
            if (gVar != null) {
                gVar.a0(false);
            }
            return zOnPreparePanel;
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> list, Menu menu, int i3) {
            androidx.appcompat.view.menu.g gVar;
            u uVarD0 = f.this.d0(0, true);
            if (uVarD0 == null || (gVar = uVarD0.f238j) == null) {
                super.onProvideKeyboardShortcuts(list, menu, i3);
            } else {
                super.onProvideKeyboardShortcuts(list, gVar, i3);
            }
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
            if (Build.VERSION.SDK_INT >= 23) {
                return null;
            }
            return f.this.m0() ? e(callback) : super.onWindowStartingActionMode(callback);
        }

        @Override // androidx.appcompat.view.i, android.view.Window.Callback
        public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int i3) {
            if (f.this.m0() && i3 == 0) {
                return e(callback);
            }
            return super.onWindowStartingActionMode(callback, i3);
        }
    }
}
