package androidx.appcompat.app;

import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import androidx.appcompat.widget.y0;
import androidx.core.app.g;
import c.a.m.b;

/* JADX INFO: compiled from: AppCompatActivity.java */
/* JADX INFO: loaded from: classes.dex */
public class c extends androidx.fragment.app.d implements d, g.a {
    private e s;
    private int t = 0;
    private Resources u;

    private boolean G(int i2, KeyEvent keyEvent) {
        Window window;
        return (Build.VERSION.SDK_INT >= 26 || keyEvent.isCtrlPressed() || KeyEvent.metaStateHasNoModifiers(keyEvent.getMetaState()) || keyEvent.getRepeatCount() != 0 || KeyEvent.isModifierKey(keyEvent.getKeyCode()) || (window = getWindow()) == null || window.getDecorView() == null || !window.getDecorView().dispatchKeyShortcutEvent(keyEvent)) ? false : true;
    }

    public e A() {
        if (this.s == null) {
            this.s = e.e(this, this);
        }
        return this.s;
    }

    public a B() {
        return A().j();
    }

    public void C(androidx.core.app.g gVar) {
        gVar.b(this);
    }

    public void D(androidx.core.app.g gVar) {
    }

    @Deprecated
    public void E() {
    }

    public boolean F() {
        Intent intentI = i();
        if (intentI == null) {
            return false;
        }
        if (!I(intentI)) {
            H(intentI);
            return true;
        }
        androidx.core.app.g gVarD = androidx.core.app.g.d(this);
        C(gVarD);
        D(gVarD);
        gVarD.e();
        try {
            androidx.core.app.a.g(this);
            return true;
        } catch (IllegalStateException unused) {
            finish();
            return true;
        }
    }

    public void H(Intent intent) {
        androidx.core.app.e.e(this, intent);
    }

    public boolean I(Intent intent) {
        return androidx.core.app.e.f(this, intent);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void addContentView(View view, ViewGroup.LayoutParams layoutParams) {
        A().c(view, layoutParams);
    }

    @Override // android.app.Activity
    public void closeOptionsMenu() {
        a aVarB = B();
        if (getWindow().hasFeature(0)) {
            if (aVarB == null || !aVarB.g()) {
                super.closeOptionsMenu();
            }
        }
    }

    @Override // androidx.core.app.d, android.app.Activity, android.view.Window.Callback
    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        int keyCode = keyEvent.getKeyCode();
        a aVarB = B();
        if (keyCode == 82 && aVarB != null && aVarB.p(keyEvent)) {
            return true;
        }
        return super.dispatchKeyEvent(keyEvent);
    }

    @Override // androidx.appcompat.app.d
    public void f(c.a.m.b bVar) {
    }

    @Override // android.app.Activity
    public <T extends View> T findViewById(int i2) {
        return (T) A().g(i2);
    }

    @Override // androidx.appcompat.app.d
    public void g(c.a.m.b bVar) {
    }

    @Override // android.app.Activity
    public MenuInflater getMenuInflater() {
        return A().i();
    }

    @Override // android.view.ContextThemeWrapper, android.content.ContextWrapper, android.content.Context
    public Resources getResources() {
        if (this.u == null && y0.b()) {
            this.u = new y0(this, super.getResources());
        }
        Resources resources = this.u;
        return resources == null ? super.getResources() : resources;
    }

    @Override // androidx.core.app.g.a
    public Intent i() {
        return androidx.core.app.e.a(this);
    }

    @Override // android.app.Activity
    public void invalidateOptionsMenu() {
        A().l();
    }

    @Override // androidx.appcompat.app.d
    public c.a.m.b k(b.a aVar) {
        return null;
    }

    @Override // androidx.fragment.app.d, android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        A().m(configuration);
        if (this.u != null) {
            this.u.updateConfiguration(configuration, super.getResources().getDisplayMetrics());
        }
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public void onContentChanged() {
        E();
    }

    @Override // androidx.fragment.app.d, androidx.activity.ComponentActivity, androidx.core.app.d, android.app.Activity
    protected void onCreate(Bundle bundle) {
        int i2;
        e eVarA = A();
        eVarA.k();
        eVarA.n(bundle);
        if (eVarA.d() && (i2 = this.t) != 0) {
            if (Build.VERSION.SDK_INT >= 23) {
                onApplyThemeResource(getTheme(), this.t, false);
            } else {
                setTheme(i2);
            }
        }
        super.onCreate(bundle);
    }

    @Override // androidx.fragment.app.d, android.app.Activity
    protected void onDestroy() {
        super.onDestroy();
        A().o();
    }

    @Override // android.app.Activity, android.view.KeyEvent.Callback
    public boolean onKeyDown(int i2, KeyEvent keyEvent) {
        if (G(i2, keyEvent)) {
            return true;
        }
        return super.onKeyDown(i2, keyEvent);
    }

    @Override // androidx.fragment.app.d, android.app.Activity, android.view.Window.Callback
    public final boolean onMenuItemSelected(int i2, MenuItem menuItem) {
        if (super.onMenuItemSelected(i2, menuItem)) {
            return true;
        }
        a aVarB = B();
        if (menuItem.getItemId() != 16908332 || aVarB == null || (aVarB.j() & 4) == 0) {
            return false;
        }
        return F();
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean onMenuOpened(int i2, Menu menu) {
        return super.onMenuOpened(i2, menu);
    }

    @Override // androidx.fragment.app.d, android.app.Activity, android.view.Window.Callback
    public void onPanelClosed(int i2, Menu menu) {
        super.onPanelClosed(i2, menu);
    }

    @Override // android.app.Activity
    protected void onPostCreate(Bundle bundle) {
        super.onPostCreate(bundle);
        A().p(bundle);
    }

    @Override // androidx.fragment.app.d, android.app.Activity
    protected void onPostResume() {
        super.onPostResume();
        A().q();
    }

    @Override // androidx.activity.ComponentActivity, androidx.core.app.d, android.app.Activity
    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        A().r(bundle);
    }

    @Override // androidx.fragment.app.d, android.app.Activity
    protected void onStart() {
        super.onStart();
        A().s();
    }

    @Override // androidx.fragment.app.d, android.app.Activity
    protected void onStop() {
        super.onStop();
        A().t();
    }

    @Override // android.app.Activity
    protected void onTitleChanged(CharSequence charSequence, int i2) {
        super.onTitleChanged(charSequence, i2);
        A().y(charSequence);
    }

    @Override // android.app.Activity
    public void openOptionsMenu() {
        a aVarB = B();
        if (getWindow().hasFeature(0)) {
            if (aVarB == null || !aVarB.q()) {
                super.openOptionsMenu();
            }
        }
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void setContentView(int i2) {
        A().v(i2);
    }

    @Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper, android.content.Context
    public void setTheme(int i2) {
        super.setTheme(i2);
        this.t = i2;
    }

    @Override // androidx.fragment.app.d
    public void z() {
        A().l();
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void setContentView(View view) {
        A().w(view);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
        A().x(view, layoutParams);
    }
}
