package o;

import android.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
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.Toolbar;
import java.util.ArrayList;
import java.util.WeakHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.il0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1510il0 extends T0 implements Z0 {
    public static final AccelerateInterpolator y = new AccelerateInterpolator();
    public static final DecelerateInterpolator z = new DecelerateInterpolator();
    public Context a;
    public Context b;
    public ActionBarOverlayLayout c;
    public ActionBarContainer d;
    public InterfaceC0378Op e;
    public ActionBarContextView f;
    public final View g;
    public boolean h;
    public C1415hl0 i;
    public C1415hl0 j;
    public Gm0 k;
    public boolean l;
    public final ArrayList m;
    public int n;

    /* renamed from: o, reason: collision with root package name */
    public boolean f585o;
    public boolean p;
    public boolean q;
    public boolean r;
    public C1793lk0 s;
    public boolean t;
    public boolean u;
    public final C1319gl0 v;
    public final C1319gl0 w;
    public final C1696kj0 x;

    public C1510il0(Activity activity, boolean z2) {
        new ArrayList();
        this.m = new ArrayList();
        this.n = 0;
        this.f585o = true;
        this.r = true;
        this.v = new C1319gl0(this, 0);
        this.w = new C1319gl0(this, 1);
        this.x = new C1696kj0(2, this);
        View decorView = activity.getWindow().getDecorView();
        q(decorView);
        if (z2) {
            return;
        }
        this.g = decorView.findViewById(R.id.content);
    }

    @Override // o.T0
    public final boolean b() {
        Of0 of0;
        InterfaceC0378Op interfaceC0378Op = this.e;
        if (interfaceC0378Op == null || (of0 = ((Vf0) interfaceC0378Op).a.a0) == null || of0.m == null) {
            return false;
        }
        Of0 of02 = ((Vf0) interfaceC0378Op).a.a0;
        LO lo = of02 == null ? null : of02.m;
        if (lo == null) {
            return true;
        }
        lo.collapseActionView();
        return true;
    }

    @Override // o.T0
    public final void c(boolean z2) {
        if (z2 == this.l) {
            return;
        }
        this.l = z2;
        ArrayList arrayList = this.m;
        if (arrayList.size() <= 0) {
            return;
        }
        arrayList.get(0).getClass();
        throw new ClassCastException();
    }

    @Override // o.T0
    public final int d() {
        return ((Vf0) this.e).b;
    }

    @Override // o.T0
    public final Context e() {
        if (this.b == null) {
            TypedValue typedValue = new TypedValue();
            this.a.getTheme().resolveAttribute(com.google.android.gms.common.R.attr.actionBarWidgetTheme, typedValue, true);
            int i = typedValue.resourceId;
            if (i != 0) {
                this.b = new ContextThemeWrapper(this.a, i);
            } else {
                this.b = this.a;
            }
        }
        return this.b;
    }

    @Override // o.T0
    public final void g() {
        r(this.a.getResources().getBoolean(com.google.android.gms.common.R.bool.abc_action_bar_embed_tabs));
    }

    @Override // o.T0
    public final boolean i(int i, KeyEvent keyEvent) {
        CO co;
        C1415hl0 c1415hl0 = this.i;
        if (c1415hl0 == null || (co = c1415hl0.f568o) == null) {
            return false;
        }
        co.setQwertyMode(KeyCharacterMap.load(keyEvent.getDeviceId()).getKeyboardType() != 1);
        return co.performShortcut(i, keyEvent, 0);
    }

    @Override // o.T0
    public final void l(boolean z2) {
        if (this.h) {
            return;
        }
        int i = z2 ? 4 : 0;
        Vf0 vf0 = (Vf0) this.e;
        int i2 = vf0.b;
        this.h = true;
        vf0.a((i & 4) | (i2 & (-5)));
    }

    @Override // o.T0
    public final void m(boolean z2) {
        C1793lk0 c1793lk0;
        this.t = z2;
        if (z2 || (c1793lk0 = this.s) == null) {
            return;
        }
        c1793lk0.a();
    }

    @Override // o.T0
    public final void n(CharSequence charSequence) {
        Vf0 vf0 = (Vf0) this.e;
        if (vf0.g) {
            return;
        }
        Toolbar toolbar = vf0.a;
        vf0.h = charSequence;
        if ((vf0.b & 8) != 0) {
            toolbar.setTitle(charSequence);
            if (vf0.g) {
                Oj0.n(toolbar.getRootView(), charSequence);
            }
        }
    }

    @Override // o.T0
    public final AbstractC1918n1 o(Gm0 gm0) {
        C1415hl0 c1415hl0 = this.i;
        if (c1415hl0 != null) {
            c1415hl0.a();
        }
        this.c.setHideOnContentScrollEnabled(false);
        this.f.e();
        C1415hl0 c1415hl02 = new C1415hl0(this, this.f.getContext(), gm0);
        CO co = c1415hl02.f568o;
        co.w();
        try {
            if (!((InterfaceC1823m1) c1415hl02.p.m).c(c1415hl02, co)) {
                return null;
            }
            this.i = c1415hl02;
            c1415hl02.g();
            this.f.c(c1415hl02);
            p(true);
            return c1415hl02;
        } finally {
            co.v();
        }
    }

    public final void p(boolean z2) {
        C1698kk0 c1698kk0I;
        C1698kk0 c1698kk0I2;
        if (z2) {
            if (!this.q) {
                this.q = true;
                ActionBarOverlayLayout actionBarOverlayLayout = this.c;
                if (actionBarOverlayLayout != null) {
                    actionBarOverlayLayout.setShowingForActionMode(true);
                }
                s(false);
            }
        } else if (this.q) {
            this.q = false;
            ActionBarOverlayLayout actionBarOverlayLayout2 = this.c;
            if (actionBarOverlayLayout2 != null) {
                actionBarOverlayLayout2.setShowingForActionMode(false);
            }
            s(false);
        }
        if (!this.d.isLaidOut()) {
            if (z2) {
                ((Vf0) this.e).a.setVisibility(4);
                this.f.setVisibility(0);
                return;
            } else {
                ((Vf0) this.e).a.setVisibility(0);
                this.f.setVisibility(8);
                return;
            }
        }
        if (z2) {
            Vf0 vf0 = (Vf0) this.e;
            c1698kk0I = Oj0.a(vf0.a);
            c1698kk0I.a(0.0f);
            c1698kk0I.c(100L);
            c1698kk0I.d(new Uf0(vf0, 4));
            c1698kk0I2 = this.f.i(0, 200L);
        } else {
            Vf0 vf02 = (Vf0) this.e;
            C1698kk0 c1698kk0A = Oj0.a(vf02.a);
            c1698kk0A.a(1.0f);
            c1698kk0A.c(200L);
            c1698kk0A.d(new Uf0(vf02, 0));
            c1698kk0I = this.f.i(8, 100L);
            c1698kk0I2 = c1698kk0A;
        }
        C1793lk0 c1793lk0 = new C1793lk0();
        ArrayList arrayList = c1793lk0.a;
        arrayList.add(c1698kk0I);
        View view = (View) c1698kk0I.a.get();
        long duration = view != null ? view.animate().getDuration() : 0L;
        View view2 = (View) c1698kk0I2.a.get();
        if (view2 != null) {
            view2.animate().setStartDelay(duration);
        }
        arrayList.add(c1698kk0I2);
        c1793lk0.b();
    }

    public final void q(View view) {
        InterfaceC0378Op wrapper;
        ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) view.findViewById(com.google.android.gms.common.R.id.decor_content_parent);
        this.c = actionBarOverlayLayout;
        if (actionBarOverlayLayout != null) {
            actionBarOverlayLayout.setActionBarVisibilityCallback(this);
        }
        KeyEvent.Callback callbackFindViewById = view.findViewById(com.google.android.gms.common.R.id.action_bar);
        if (callbackFindViewById instanceof InterfaceC0378Op) {
            wrapper = (InterfaceC0378Op) 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.e = wrapper;
        this.f = (ActionBarContextView) view.findViewById(com.google.android.gms.common.R.id.action_context_bar);
        ActionBarContainer actionBarContainer = (ActionBarContainer) view.findViewById(com.google.android.gms.common.R.id.action_bar_container);
        this.d = actionBarContainer;
        InterfaceC0378Op interfaceC0378Op = this.e;
        if (interfaceC0378Op == null || this.f == null || actionBarContainer == null) {
            throw new IllegalStateException(C1510il0.class.getSimpleName().concat(" can only be used with a compatible window decor layout"));
        }
        Context context = ((Vf0) interfaceC0378Op).a.getContext();
        this.a = context;
        if ((((Vf0) this.e).b & 4) != 0) {
            this.h = true;
        }
        int i = context.getApplicationInfo().targetSdkVersion;
        this.e.getClass();
        r(context.getResources().getBoolean(com.google.android.gms.common.R.bool.abc_action_bar_embed_tabs));
        TypedArray typedArrayObtainStyledAttributes = this.a.obtainStyledAttributes(null, YZ.a, com.google.android.gms.common.R.attr.actionBarStyle, 0);
        if (typedArrayObtainStyledAttributes.getBoolean(14, false)) {
            ActionBarOverlayLayout actionBarOverlayLayout2 = this.c;
            if (!actionBarOverlayLayout2.r) {
                throw new IllegalStateException("Action bar must be in overlay mode (Window.FEATURE_OVERLAY_ACTION_BAR) to enable hide on content scroll");
            }
            this.u = true;
            actionBarOverlayLayout2.setHideOnContentScrollEnabled(true);
        }
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(12, 0);
        if (dimensionPixelSize != 0) {
            ActionBarContainer actionBarContainer2 = this.d;
            WeakHashMap weakHashMap = Oj0.a;
            Gj0.k(actionBarContainer2, dimensionPixelSize);
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public final void r(boolean z2) {
        if (z2) {
            this.d.setTabContainer(null);
            ((Vf0) this.e).getClass();
        } else {
            ((Vf0) this.e).getClass();
            this.d.setTabContainer(null);
        }
        this.e.getClass();
        ((Vf0) this.e).a.setCollapsible(false);
        this.c.setHasNonEmbeddedTabs(false);
    }

    public final void s(boolean z2) {
        boolean z3 = this.p;
        boolean z4 = this.q;
        C1696kj0 c1696kj0 = this.x;
        View view = this.g;
        if (!z4 && z3) {
            if (this.r) {
                this.r = false;
                C1793lk0 c1793lk0 = this.s;
                if (c1793lk0 != null) {
                    c1793lk0.a();
                }
                int i = this.n;
                C1319gl0 c1319gl0 = this.v;
                if (i != 0 || (!this.t && !z2)) {
                    c1319gl0.a();
                    return;
                }
                this.d.setAlpha(1.0f);
                this.d.setTransitioning(true);
                C1793lk0 c1793lk02 = new C1793lk0();
                float f = -this.d.getHeight();
                if (z2) {
                    this.d.getLocationInWindow(new int[]{0, 0});
                    f -= r12[1];
                }
                C1698kk0 c1698kk0A = Oj0.a(this.d);
                c1698kk0A.e(f);
                View view2 = (View) c1698kk0A.a.get();
                if (view2 != null) {
                    view2.animate().setUpdateListener(c1696kj0 != null ? new C0175Gt(c1696kj0, view2) : null);
                }
                boolean z5 = c1793lk02.e;
                ArrayList arrayList = c1793lk02.a;
                if (!z5) {
                    arrayList.add(c1698kk0A);
                }
                if (this.f585o && view != null) {
                    C1698kk0 c1698kk0A2 = Oj0.a(view);
                    c1698kk0A2.e(f);
                    if (!c1793lk02.e) {
                        arrayList.add(c1698kk0A2);
                    }
                }
                boolean z6 = c1793lk02.e;
                if (!z6) {
                    c1793lk02.c = y;
                }
                if (!z6) {
                    c1793lk02.b = 250L;
                }
                if (!z6) {
                    c1793lk02.d = c1319gl0;
                }
                this.s = c1793lk02;
                c1793lk02.b();
                return;
            }
            return;
        }
        if (this.r) {
            return;
        }
        this.r = true;
        C1793lk0 c1793lk03 = this.s;
        if (c1793lk03 != null) {
            c1793lk03.a();
        }
        this.d.setVisibility(0);
        int i2 = this.n;
        C1319gl0 c1319gl02 = this.w;
        if (i2 == 0 && (this.t || z2)) {
            this.d.setTranslationY(0.0f);
            float f2 = -this.d.getHeight();
            if (z2) {
                this.d.getLocationInWindow(new int[]{0, 0});
                f2 -= r12[1];
            }
            this.d.setTranslationY(f2);
            C1793lk0 c1793lk04 = new C1793lk0();
            C1698kk0 c1698kk0A3 = Oj0.a(this.d);
            c1698kk0A3.e(0.0f);
            View view3 = (View) c1698kk0A3.a.get();
            if (view3 != null) {
                view3.animate().setUpdateListener(c1696kj0 != null ? new C0175Gt(c1696kj0, view3) : null);
            }
            boolean z7 = c1793lk04.e;
            ArrayList arrayList2 = c1793lk04.a;
            if (!z7) {
                arrayList2.add(c1698kk0A3);
            }
            if (this.f585o && view != null) {
                view.setTranslationY(f2);
                C1698kk0 c1698kk0A4 = Oj0.a(view);
                c1698kk0A4.e(0.0f);
                if (!c1793lk04.e) {
                    arrayList2.add(c1698kk0A4);
                }
            }
            boolean z8 = c1793lk04.e;
            if (!z8) {
                c1793lk04.c = z;
            }
            if (!z8) {
                c1793lk04.b = 250L;
            }
            if (!z8) {
                c1793lk04.d = c1319gl02;
            }
            this.s = c1793lk04;
            c1793lk04.b();
        } else {
            this.d.setAlpha(1.0f);
            this.d.setTranslationY(0.0f);
            if (this.f585o && view != null) {
                view.setTranslationY(0.0f);
            }
            c1319gl02.a();
        }
        ActionBarOverlayLayout actionBarOverlayLayout = this.c;
        if (actionBarOverlayLayout != null) {
            WeakHashMap weakHashMap = Oj0.a;
            Ej0.c(actionBarOverlayLayout);
        }
    }

    public C1510il0(Dialog dialog) {
        new ArrayList();
        this.m = new ArrayList();
        this.n = 0;
        this.f585o = true;
        this.r = true;
        this.v = new C1319gl0(this, 0);
        this.w = new C1319gl0(this, 1);
        this.x = new C1696kj0(2, this);
        q(dialog.getWindow().getDecorView());
    }
}
