package d.b.c;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
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 androidx.appcompat.widget.Toolbar;
import com.ifpdos.udi.service.core.pc.R;
import d.b.f.a;
import d.b.g.c1;
import d.h.b.b;
import d.h.b.s;
import d.h.c.a;
import d.q.a;
import java.lang.ref.WeakReference;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class f extends d.k.b.n implements g, s.a {
    private static final String DELEGATE_TAG = "androidx:appcompat";
    private h mDelegate;
    private Resources mResources;

    public class a implements a.b {
        public a() {
        }

        @Override // d.q.a.b
        public Bundle a() {
            Bundle bundle = new Bundle();
            f.this.getDelegate().q(bundle);
            return bundle;
        }
    }

    public class b implements d.a.d.b {
        public b() {
        }

        @Override // d.a.d.b
        public void a(Context context) {
            h delegate = f.this.getDelegate();
            delegate.j();
            delegate.m(f.this.getSavedStateRegistry().a(f.DELEGATE_TAG));
        }
    }

    public f() {
        initDelegate();
    }

    public f(int i2) {
        super(i2);
        initDelegate();
    }

    private void initDelegate() {
        getSavedStateRegistry().b(DELEGATE_TAG, new a());
        addOnContextAvailableListener(new b());
    }

    private void initViewTreeOwners() {
        getWindow().getDecorView().setTag(R.id.view_tree_lifecycle_owner, this);
        getWindow().getDecorView().setTag(R.id.view_tree_view_model_store_owner, this);
        getWindow().getDecorView().setTag(R.id.view_tree_saved_state_registry_owner, this);
    }

    private boolean performMenuItemShortcut(KeyEvent keyEvent) {
        return false;
    }

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

    @Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper
    public void attachBaseContext(Context context) {
        super.attachBaseContext(getDelegate().d(context));
    }

    @Override // android.app.Activity
    public void closeOptionsMenu() {
        d.b.c.a supportActionBar = getSupportActionBar();
        if (getWindow().hasFeature(0)) {
            if (supportActionBar == null || !supportActionBar.a()) {
                super.closeOptionsMenu();
            }
        }
    }

    @Override // d.h.b.i, android.app.Activity, android.view.Window.Callback
    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        int keyCode = keyEvent.getKeyCode();
        d.b.c.a supportActionBar = getSupportActionBar();
        if (keyCode == 82 && supportActionBar != null && supportActionBar.j(keyEvent)) {
            return true;
        }
        return super.dispatchKeyEvent(keyEvent);
    }

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

    public h getDelegate() {
        if (this.mDelegate == null) {
            d.e.c<WeakReference<h>> cVar = h.f1559f;
            this.mDelegate = new i(this, null, this, this);
        }
        return this.mDelegate;
    }

    public d.b.c.b getDrawerToggleDelegate() {
        return getDelegate().f();
    }

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

    @Override // android.view.ContextThemeWrapper, android.content.ContextWrapper, android.content.Context
    public Resources getResources() {
        Resources resources = this.mResources;
        if (resources == null) {
            int i2 = c1.a;
        }
        return resources == null ? super.getResources() : resources;
    }

    public d.b.c.a getSupportActionBar() {
        return getDelegate().i();
    }

    @Override // d.h.b.s.a
    public Intent getSupportParentActivityIntent() {
        return d.h.b.h.n(this);
    }

    @Override // android.app.Activity
    public void invalidateOptionsMenu() {
        getDelegate().k();
    }

    @Override // d.k.b.n, android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (this.mResources != null) {
            this.mResources.updateConfiguration(configuration, super.getResources().getDisplayMetrics());
        }
        getDelegate().l(configuration);
    }

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

    public void onCreateSupportNavigateUpTaskStack(d.h.b.s sVar) {
        Objects.requireNonNull(sVar);
        Intent supportParentActivityIntent = getSupportParentActivityIntent();
        if (supportParentActivityIntent == null) {
            supportParentActivityIntent = d.h.b.h.n(this);
        }
        if (supportParentActivityIntent == null) {
            return;
        }
        ComponentName component = supportParentActivityIntent.getComponent();
        if (component == null) {
            component = supportParentActivityIntent.resolveActivity(sVar.f2631m.getPackageManager());
        }
        int size = sVar.f2630f.size();
        try {
            Context context = sVar.f2631m;
            while (true) {
                Intent intentO = d.h.b.h.o(context, component);
                if (intentO == null) {
                    sVar.f2630f.add(supportParentActivityIntent);
                    return;
                } else {
                    sVar.f2630f.add(size, intentO);
                    context = sVar.f2631m;
                    component = intentO.getComponent();
                }
            }
        } catch (PackageManager.NameNotFoundException e2) {
            Log.e("TaskStackBuilder", "Bad ComponentName while traversing activity parent metadata");
            throw new IllegalArgumentException(e2);
        }
    }

    @Override // d.k.b.n, android.app.Activity
    public void onDestroy() {
        super.onDestroy();
        getDelegate().n();
    }

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

    @Override // d.k.b.n, android.app.Activity, android.view.Window.Callback
    public final boolean onMenuItemSelected(int i2, MenuItem menuItem) {
        if (super.onMenuItemSelected(i2, menuItem)) {
            return true;
        }
        d.b.c.a supportActionBar = getSupportActionBar();
        if (menuItem.getItemId() != 16908332 || supportActionBar == null || (supportActionBar.d() & 4) == 0) {
            return false;
        }
        return onSupportNavigateUp();
    }

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

    public void onNightModeChanged(int i2) {
    }

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

    @Override // android.app.Activity
    public void onPostCreate(Bundle bundle) {
        super.onPostCreate(bundle);
        getDelegate().o(bundle);
    }

    @Override // d.k.b.n, android.app.Activity
    public void onPostResume() {
        super.onPostResume();
        getDelegate().p();
    }

    public void onPrepareSupportNavigateUpTaskStack(d.h.b.s sVar) {
    }

    @Override // d.k.b.n, android.app.Activity
    public void onStart() {
        super.onStart();
        getDelegate().r();
    }

    @Override // d.k.b.n, android.app.Activity
    public void onStop() {
        super.onStop();
        getDelegate().s();
    }

    @Override // d.b.c.g
    public void onSupportActionModeFinished(d.b.f.a aVar) {
    }

    @Override // d.b.c.g
    public void onSupportActionModeStarted(d.b.f.a aVar) {
    }

    @Deprecated
    public void onSupportContentChanged() {
    }

    public boolean onSupportNavigateUp() {
        Intent supportParentActivityIntent = getSupportParentActivityIntent();
        if (supportParentActivityIntent == null) {
            return false;
        }
        if (!supportShouldUpRecreateTask(supportParentActivityIntent)) {
            supportNavigateUpTo(supportParentActivityIntent);
            return true;
        }
        d.h.b.s sVar = new d.h.b.s(this);
        onCreateSupportNavigateUpTaskStack(sVar);
        onPrepareSupportNavigateUpTaskStack(sVar);
        if (sVar.f2630f.isEmpty()) {
            throw new IllegalStateException("No intents added to TaskStackBuilder; cannot startActivities");
        }
        Intent[] intentArr = (Intent[]) sVar.f2630f.toArray(new Intent[0]);
        intentArr[0] = new Intent(intentArr[0]).addFlags(268484608);
        Context context = sVar.f2631m;
        Object obj = d.h.c.a.a;
        a.C0030a.a(context, intentArr, null);
        try {
            int i2 = d.h.b.b.f2569b;
            b.a.a(this);
            return true;
        } catch (IllegalStateException unused) {
            finish();
            return true;
        }
    }

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

    @Override // d.b.c.g
    public d.b.f.a onWindowStartingSupportActionMode(a.InterfaceC0019a interfaceC0019a) {
        return null;
    }

    @Override // android.app.Activity
    public void openOptionsMenu() {
        d.b.c.a supportActionBar = getSupportActionBar();
        if (getWindow().hasFeature(0)) {
            if (supportActionBar == null || !supportActionBar.k()) {
                super.openOptionsMenu();
            }
        }
    }

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

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

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

    public void setSupportActionBar(Toolbar toolbar) {
        getDelegate().y(toolbar);
    }

    @Deprecated
    public void setSupportProgress(int i2) {
    }

    @Deprecated
    public void setSupportProgressBarIndeterminate(boolean z2) {
    }

    @Deprecated
    public void setSupportProgressBarIndeterminateVisibility(boolean z2) {
    }

    @Deprecated
    public void setSupportProgressBarVisibility(boolean z2) {
    }

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

    public d.b.f.a startSupportActionMode(a.InterfaceC0019a interfaceC0019a) {
        return getDelegate().B(interfaceC0019a);
    }

    @Override // d.k.b.n
    public void supportInvalidateOptionsMenu() {
        getDelegate().k();
    }

    public void supportNavigateUpTo(Intent intent) {
        d.h.b.j.b(this, intent);
    }

    public boolean supportRequestWindowFeature(int i2) {
        return getDelegate().u(i2);
    }

    public boolean supportShouldUpRecreateTask(Intent intent) {
        return d.h.b.j.c(this, intent);
    }
}
