package e;

import android.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewParent;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import androidx.appcompat.widget.ActionBarContainer;
import androidx.appcompat.widget.ActionBarContextView;
import androidx.appcompat.widget.ActionBarOverlayLayout;
import androidx.appcompat.widget.ScrollingTabContainerView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.g1;
import androidx.core.view.i1;
import androidx.core.view.s1;
import androidx.core.view.z1;
import com.google.android.gms.measurement.internal.u1;
import java.util.ArrayList;
import java.util.WeakHashMap;
import l.m1;
import l.s3;
import l.w3;

/* JADX INFO: loaded from: classes.dex */
public final class y0 extends c implements l.g {
    public static final AccelerateInterpolator A = new AccelerateInterpolator();
    public static final DecelerateInterpolator B = new DecelerateInterpolator();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Context f25366a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Context f25367b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Activity f25368c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public ActionBarOverlayLayout f25369d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public ActionBarContainer f25370e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public m1 f25371f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public ActionBarContextView f25372g;

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public x0 f25375j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public x0 f25376k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public j.b f25377l;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final ArrayList f25379n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f25380o;

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

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

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

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

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

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public j.m f25386u;

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

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

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final w0 f25389x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final w0 f25390y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final xyz.stream.utils.f0 f25391z;

    public y0(boolean z10, Activity activity) {
        new ArrayList();
        this.f25379n = new ArrayList();
        this.f25380o = 0;
        this.f25381p = true;
        this.f25385t = true;
        this.f25389x = new w0(this, 0);
        this.f25390y = new w0(this, 1);
        this.f25391z = new xyz.stream.utils.f0(this, 2);
        this.f25368c = activity;
        View decorView = activity.getWindow().getDecorView();
        v(decorView);
        if (z10) {
            return;
        }
        this.f25373h = decorView.findViewById(R.id.content);
    }

    @Override // e.c
    public final boolean b() {
        s3 s3Var;
        m1 m1Var = this.f25371f;
        if (m1Var == null || (s3Var = ((w3) m1Var).f29883a.f829s0) == null || s3Var.f29840b == null) {
            return false;
        }
        s3 s3Var2 = ((w3) m1Var).f29883a.f829s0;
        k.r rVar = s3Var2 == null ? null : s3Var2.f29840b;
        if (rVar == null) {
            return true;
        }
        rVar.collapseActionView();
        return true;
    }

    @Override // e.c
    public final void c(boolean z10) {
        if (z10 == this.f25378m) {
            return;
        }
        this.f25378m = z10;
        ArrayList arrayList = this.f25379n;
        if (arrayList.size() <= 0) {
            return;
        }
        u1.x(arrayList.get(0));
        throw null;
    }

    @Override // e.c
    public final int d() {
        return ((w3) this.f25371f).f29884b;
    }

    @Override // e.c
    public final Context e() {
        if (this.f25367b == null) {
            TypedValue typedValue = new TypedValue();
            this.f25366a.getTheme().resolveAttribute(d.a.actionBarWidgetTheme, typedValue, true);
            int i10 = typedValue.resourceId;
            if (i10 != 0) {
                this.f25367b = new ContextThemeWrapper(this.f25366a, i10);
            } else {
                this.f25367b = this.f25366a;
            }
        }
        return this.f25367b;
    }

    @Override // e.c
    public final void f() {
        if (this.f25382q) {
            return;
        }
        this.f25382q = true;
        x(false);
    }

    @Override // e.c
    public final b getSelectedTab() {
        return null;
    }

    @Override // e.c
    public final CharSequence getSubtitle() {
        return ((w3) this.f25371f).f29883a.getSubtitle();
    }

    @Override // e.c
    public final CharSequence getTitle() {
        return ((w3) this.f25371f).f29883a.getTitle();
    }

    @Override // e.c
    public final boolean h() {
        int height = this.f25370e.getHeight();
        return this.f25385t && (height == 0 || this.f25369d.getActionBarHideOffset() < height);
    }

    @Override // e.c
    public final void i() {
        w(j.a.a(this.f25366a).f28433a.getResources().getBoolean(d.b.abc_action_bar_embed_tabs));
    }

    @Override // e.c
    public final boolean k(int i10, KeyEvent keyEvent) {
        k.p pVar;
        x0 x0Var = this.f25375j;
        if (x0Var == null || (pVar = x0Var.f25361d) == null) {
            return false;
        }
        pVar.setQwertyMode(KeyCharacterMap.load(keyEvent != null ? keyEvent.getDeviceId() : -1).getKeyboardType() != 1);
        return pVar.performShortcut(i10, keyEvent, 0);
    }

    @Override // e.c
    public final void n(boolean z10) {
        if (this.f25374i) {
            return;
        }
        int i10 = z10 ? 4 : 0;
        w3 w3Var = (w3) this.f25371f;
        int i11 = w3Var.f29884b;
        this.f25374i = true;
        w3Var.a((i10 & 4) | (i11 & (-5)));
    }

    @Override // e.c
    public final void o(boolean z10) {
        int i10 = z10 ? 8 : 0;
        w3 w3Var = (w3) this.f25371f;
        w3Var.a((i10 & 8) | (w3Var.f29884b & (-9)));
    }

    @Override // e.c
    public final void p(boolean z10) {
        j.m mVar;
        this.f25387v = z10;
        if (z10 || (mVar = this.f25386u) == null) {
            return;
        }
        mVar.a();
    }

    @Override // e.c
    public final void q(CharSequence charSequence) {
        w3 w3Var = (w3) this.f25371f;
        w3Var.f29890h = true;
        w3Var.f29891i = charSequence;
        if ((w3Var.f29884b & 8) != 0) {
            Toolbar toolbar = w3Var.f29883a;
            toolbar.setTitle(charSequence);
            if (w3Var.f29890h) {
                s1.setAccessibilityPaneTitle(toolbar.getRootView(), charSequence);
            }
        }
    }

    @Override // e.c
    public final void r(CharSequence charSequence) {
        w3 w3Var = (w3) this.f25371f;
        if (w3Var.f29890h) {
            return;
        }
        w3Var.f29891i = charSequence;
        if ((w3Var.f29884b & 8) != 0) {
            Toolbar toolbar = w3Var.f29883a;
            toolbar.setTitle(charSequence);
            if (w3Var.f29890h) {
                s1.setAccessibilityPaneTitle(toolbar.getRootView(), charSequence);
            }
        }
    }

    @Override // e.c
    public final void s() {
        if (this.f25382q) {
            this.f25382q = false;
            x(false);
        }
    }

    @Override // e.c
    public final void setBackgroundDrawable(Drawable drawable) {
        this.f25370e.setPrimaryBackground(drawable);
    }

    @Override // e.c
    public final void setHomeActionContentDescription(CharSequence charSequence) {
        w3 w3Var = (w3) this.f25371f;
        w3Var.f29893k = charSequence;
        w3Var.b();
    }

    @Override // e.c
    public final void setHomeAsUpIndicator(Drawable drawable) {
        w3 w3Var = (w3) this.f25371f;
        w3Var.f29889g = drawable;
        int i10 = w3Var.f29884b & 4;
        Toolbar toolbar = w3Var.f29883a;
        if (i10 == 0) {
            toolbar.setNavigationIcon((Drawable) null);
            return;
        }
        if (drawable == null) {
            drawable = w3Var.f29898p;
        }
        toolbar.setNavigationIcon(drawable);
    }

    @Override // e.c
    public final j.c t(b0 b0Var) {
        x0 x0Var = this.f25375j;
        if (x0Var != null) {
            x0Var.a();
        }
        this.f25369d.setHideOnContentScrollEnabled(false);
        this.f25372g.h();
        x0 x0Var2 = new x0(this, this.f25372g.getContext(), b0Var);
        k.p pVar = x0Var2.f25361d;
        pVar.y();
        try {
            if (!x0Var2.f25362e.c(x0Var2, pVar)) {
                return null;
            }
            this.f25375j = x0Var2;
            x0Var2.h();
            this.f25372g.f(x0Var2);
            u(true);
            return x0Var2;
        } finally {
            pVar.x();
        }
    }

    public final void u(boolean z10) {
        z1 listener;
        z1 z1VarE;
        if (z10) {
            if (!this.f25384s) {
                this.f25384s = true;
                ActionBarOverlayLayout actionBarOverlayLayout = this.f25369d;
                if (actionBarOverlayLayout != null) {
                    actionBarOverlayLayout.setShowingForActionMode(true);
                }
                x(false);
            }
        } else if (this.f25384s) {
            this.f25384s = false;
            ActionBarOverlayLayout actionBarOverlayLayout2 = this.f25369d;
            if (actionBarOverlayLayout2 != null) {
                actionBarOverlayLayout2.setShowingForActionMode(false);
            }
            x(false);
        }
        if (!this.f25370e.isLaidOut()) {
            if (z10) {
                ((w3) this.f25371f).f29883a.setVisibility(4);
                this.f25372g.setVisibility(0);
                return;
            } else {
                ((w3) this.f25371f).f29883a.setVisibility(0);
                this.f25372g.setVisibility(8);
                return;
            }
        }
        if (z10) {
            w3 w3Var = (w3) this.f25371f;
            z1 z1VarA = s1.a(w3Var.f29883a);
            z1VarA.a(0.0f);
            z1VarA.c(100L);
            z1VarE = z1VarA.setListener(new j.l(w3Var, 4));
            listener = this.f25372g.e(0, 200L);
        } else {
            w3 w3Var2 = (w3) this.f25371f;
            z1 z1VarA2 = s1.a(w3Var2.f29883a);
            z1VarA2.a(1.0f);
            z1VarA2.c(200L);
            listener = z1VarA2.setListener(new j.l(w3Var2, 0));
            z1VarE = this.f25372g.e(8, 100L);
        }
        j.m mVar = new j.m();
        ArrayList arrayList = mVar.f28493a;
        arrayList.add(z1VarE);
        View view = (View) z1VarE.f1872a.get();
        long duration = view != null ? view.animate().getDuration() : 0L;
        View view2 = (View) listener.f1872a.get();
        if (view2 != null) {
            view2.animate().setStartDelay(duration);
        }
        arrayList.add(listener);
        mVar.b();
    }

    public final void v(View view) {
        m1 wrapper;
        ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) view.findViewById(d.f.decor_content_parent);
        this.f25369d = actionBarOverlayLayout;
        if (actionBarOverlayLayout != null) {
            actionBarOverlayLayout.setActionBarVisibilityCallback(this);
        }
        KeyEvent.Callback callbackFindViewById = view.findViewById(d.f.action_bar);
        if (callbackFindViewById instanceof m1) {
            wrapper = (m1) callbackFindViewById;
        } else {
            if (!(callbackFindViewById instanceof Toolbar)) {
                throw new IllegalStateException("Can't make a decor toolbar out of ".concat(callbackFindViewById != null ? callbackFindViewById.getClass().getSimpleName() : "null"));
            }
            wrapper = ((Toolbar) callbackFindViewById).getWrapper();
        }
        this.f25371f = wrapper;
        this.f25372g = (ActionBarContextView) view.findViewById(d.f.action_context_bar);
        ActionBarContainer actionBarContainer = (ActionBarContainer) view.findViewById(d.f.action_bar_container);
        this.f25370e = actionBarContainer;
        m1 m1Var = this.f25371f;
        if (m1Var == null || this.f25372g == null || actionBarContainer == null) {
            throw new IllegalStateException(y0.class.getSimpleName().concat(" can only be used with a compatible window decor layout"));
        }
        Context context = ((w3) m1Var).f29883a.getContext();
        this.f25366a = context;
        if ((((w3) this.f25371f).f29884b & 4) != 0) {
            this.f25374i = true;
        }
        j.a aVarA = j.a.a(context);
        int i10 = aVarA.f28433a.getApplicationInfo().targetSdkVersion;
        this.f25371f.getClass();
        w(aVarA.f28433a.getResources().getBoolean(d.b.abc_action_bar_embed_tabs));
        TypedArray typedArrayObtainStyledAttributes = this.f25366a.obtainStyledAttributes(null, d.j.ActionBar, d.a.actionBarStyle, 0);
        if (typedArrayObtainStyledAttributes.getBoolean(d.j.ActionBar_hideOnContentScroll, false)) {
            ActionBarOverlayLayout actionBarOverlayLayout2 = this.f25369d;
            if (!actionBarOverlayLayout2.f617g) {
                throw new IllegalStateException("Action bar must be in overlay mode (Window.FEATURE_OVERLAY_ACTION_BAR) to enable hide on content scroll");
            }
            this.f25388w = true;
            actionBarOverlayLayout2.setHideOnContentScrollEnabled(true);
        }
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(d.j.ActionBar_elevation, 0);
        if (dimensionPixelSize != 0) {
            ActionBarContainer actionBarContainer2 = this.f25370e;
            WeakHashMap weakHashMap = s1.f1815a;
            i1.m(actionBarContainer2, dimensionPixelSize);
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public final void w(boolean z10) {
        if (z10) {
            this.f25370e.setTabContainer(null);
            w3 w3Var = (w3) this.f25371f;
            ScrollingTabContainerView scrollingTabContainerView = w3Var.f29885c;
            if (scrollingTabContainerView != null) {
                ViewParent parent = scrollingTabContainerView.getParent();
                Toolbar toolbar = w3Var.f29883a;
                if (parent == toolbar) {
                    toolbar.removeView(w3Var.f29885c);
                }
            }
            w3Var.f29885c = null;
        } else {
            w3 w3Var2 = (w3) this.f25371f;
            ScrollingTabContainerView scrollingTabContainerView2 = w3Var2.f29885c;
            if (scrollingTabContainerView2 != null) {
                ViewParent parent2 = scrollingTabContainerView2.getParent();
                Toolbar toolbar2 = w3Var2.f29883a;
                if (parent2 == toolbar2) {
                    toolbar2.removeView(w3Var2.f29885c);
                }
            }
            w3Var2.f29885c = null;
            this.f25370e.setTabContainer(null);
        }
        this.f25371f.getClass();
        ((w3) this.f25371f).f29883a.setCollapsible(false);
        this.f25369d.setHasNonEmbeddedTabs(false);
    }

    public final void x(boolean z10) {
        boolean z11 = this.f25384s || !(this.f25382q || this.f25383r);
        View view = this.f25373h;
        xyz.stream.utils.f0 f0Var = this.f25391z;
        if (!z11) {
            if (this.f25385t) {
                this.f25385t = false;
                j.m mVar = this.f25386u;
                if (mVar != null) {
                    mVar.a();
                }
                int i10 = this.f25380o;
                w0 w0Var = this.f25389x;
                if (i10 != 0 || (!this.f25387v && !z10)) {
                    w0Var.b();
                    return;
                }
                this.f25370e.setAlpha(1.0f);
                this.f25370e.setTransitioning(true);
                j.m mVar2 = new j.m();
                float f10 = -this.f25370e.getHeight();
                if (z10) {
                    this.f25370e.getLocationInWindow(new int[]{0, 0});
                    f10 -= r11[1];
                }
                z1 z1VarA = s1.a(this.f25370e);
                z1VarA.d(f10);
                z1VarA.setUpdateListener(f0Var);
                boolean z12 = mVar2.f28497e;
                ArrayList arrayList = mVar2.f28493a;
                if (!z12) {
                    arrayList.add(z1VarA);
                }
                if (this.f25381p && view != null) {
                    z1 z1VarA2 = s1.a(view);
                    z1VarA2.d(f10);
                    if (!mVar2.f28497e) {
                        arrayList.add(z1VarA2);
                    }
                }
                AccelerateInterpolator accelerateInterpolator = A;
                boolean z13 = mVar2.f28497e;
                if (!z13) {
                    mVar2.f28495c = accelerateInterpolator;
                }
                if (!z13) {
                    mVar2.f28494b = 250L;
                }
                if (!z13) {
                    mVar2.f28496d = w0Var;
                }
                this.f25386u = mVar2;
                mVar2.b();
                return;
            }
            return;
        }
        if (this.f25385t) {
            return;
        }
        this.f25385t = true;
        j.m mVar3 = this.f25386u;
        if (mVar3 != null) {
            mVar3.a();
        }
        this.f25370e.setVisibility(0);
        int i11 = this.f25380o;
        w0 w0Var2 = this.f25390y;
        if (i11 == 0 && (this.f25387v || z10)) {
            this.f25370e.setTranslationY(0.0f);
            float f11 = -this.f25370e.getHeight();
            if (z10) {
                this.f25370e.getLocationInWindow(new int[]{0, 0});
                f11 -= r11[1];
            }
            this.f25370e.setTranslationY(f11);
            j.m mVar4 = new j.m();
            z1 z1VarA3 = s1.a(this.f25370e);
            z1VarA3.d(0.0f);
            z1VarA3.setUpdateListener(f0Var);
            boolean z14 = mVar4.f28497e;
            ArrayList arrayList2 = mVar4.f28493a;
            if (!z14) {
                arrayList2.add(z1VarA3);
            }
            if (this.f25381p && view != null) {
                view.setTranslationY(f11);
                z1 z1VarA4 = s1.a(view);
                z1VarA4.d(0.0f);
                if (!mVar4.f28497e) {
                    arrayList2.add(z1VarA4);
                }
            }
            DecelerateInterpolator decelerateInterpolator = B;
            boolean z15 = mVar4.f28497e;
            if (!z15) {
                mVar4.f28495c = decelerateInterpolator;
            }
            if (!z15) {
                mVar4.f28494b = 250L;
            }
            if (!z15) {
                mVar4.f28496d = w0Var2;
            }
            this.f25386u = mVar4;
            mVar4.b();
        } else {
            this.f25370e.setAlpha(1.0f);
            this.f25370e.setTranslationY(0.0f);
            if (this.f25381p && view != null) {
                view.setTranslationY(0.0f);
            }
            w0Var2.b();
        }
        ActionBarOverlayLayout actionBarOverlayLayout = this.f25369d;
        if (actionBarOverlayLayout != null) {
            WeakHashMap weakHashMap = s1.f1815a;
            g1.c(actionBarOverlayLayout);
        }
    }

    public y0(Dialog dialog) {
        new ArrayList();
        this.f25379n = new ArrayList();
        this.f25380o = 0;
        this.f25381p = true;
        this.f25385t = true;
        this.f25389x = new w0(this, 0);
        this.f25390y = new w0(this, 1);
        this.f25391z = new xyz.stream.utils.f0(this, 2);
        v(dialog.getWindow().getDecorView());
    }
}
