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 g.a.m.b;

/* JADX INFO: compiled from: AppCompatActivity.java */
/* JADX INFO: loaded from: classes.dex */
public class c extends g.h.a.d implements d, g.a {
    private e o;
    private int p = 0;
    private Resources q;

    private boolean y(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 boolean B(Intent intent) {
        return androidx.core.app.e.f(this, intent);
    }

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

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

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

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

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

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

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

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

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

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

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

    @Override // g.h.a.d, android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        s().m(configuration);
        if (this.q != null) {
            this.q.updateConfiguration(configuration, super.getResources().getDisplayMetrics());
        }
    }

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

    @Override // g.h.a.d, androidx.core.app.d, android.app.Activity
    protected void onCreate(Bundle bundle) {
        int i2;
        e eVarS = s();
        eVarS.k();
        eVarS.n(bundle);
        if (eVarS.d() && (i2 = this.p) != 0) {
            if (Build.VERSION.SDK_INT >= 23) {
                onApplyThemeResource(getTheme(), this.p, false);
            } else {
                setTheme(i2);
            }
        }
        super.onCreate(bundle);
    }

    @Override // g.h.a.d, android.app.Activity
    protected void onDestroy() {
        super.onDestroy();
        s().o();
    }

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

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

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

    @Override // g.h.a.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);
        s().p(bundle);
    }

    @Override // g.h.a.d, android.app.Activity
    protected void onPostResume() {
        super.onPostResume();
        s().q();
    }

    @Override // g.h.a.d, androidx.core.app.d, android.app.Activity
    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        s().r(bundle);
    }

    @Override // g.h.a.d, android.app.Activity
    protected void onStart() {
        super.onStart();
        s().s();
    }

    @Override // g.h.a.d, android.app.Activity
    protected void onStop() {
        super.onStop();
        s().t();
    }

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

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

    @Override // g.h.a.d
    public void r() {
        s().l();
    }

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

    @Override // android.app.Activity
    public void setContentView(int i2) {
        s().v(i2);
    }

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

    public a t() {
        return s().j();
    }

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

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

    @Deprecated
    public void w() {
    }

    public boolean x() {
        Intent intentE = e();
        if (intentE == null) {
            return false;
        }
        if (!B(intentE)) {
            z(intentE);
            return true;
        }
        androidx.core.app.g gVarD = androidx.core.app.g.d(this);
        u(gVarD);
        v(gVarD);
        gVarD.e();
        try {
            androidx.core.app.a.e(this);
            return true;
        } catch (IllegalStateException unused) {
            finish();
            return true;
        }
    }

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

    @Override // android.app.Activity
    public void setContentView(View view) {
        s().w(view);
    }

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