package d.b.c;

import android.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import androidx.appcompat.widget.ActionBarContainer;
import androidx.appcompat.widget.ActionBarContextView;
import androidx.appcompat.widget.ActionBarOverlayLayout;
import androidx.appcompat.widget.Toolbar;
import d.b.c.a;
import d.b.f.a;
import d.b.f.i.g;
import d.b.g.f0;
import d.h.j.d0;
import d.h.j.e0;
import d.h.j.g0;
import d.h.j.y;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;

/* JADX INFO: loaded from: classes.dex */
public class s extends d.b.c.a implements ActionBarOverlayLayout.d {
    public static final Interpolator a = new AccelerateInterpolator();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Interpolator f1636b = new DecelerateInterpolator();
    public final g0 A;

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public d.b.f.a f1646l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public a.InterfaceC0019a f1647m;

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public ArrayList<a.b> f1649o;

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

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

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

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

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

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

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public d.b.f.g f1656v;

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

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

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

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final e0 f1660z;

    public class a extends d.h.j.f0 {
        public a() {
        }

        @Override // d.h.j.e0
        public void b(View view) {
            View view2;
            s sVar = s.this;
            if (sVar.f1652r && (view2 = sVar.f1643i) != null) {
                view2.setTranslationY(0.0f);
                s.this.f1640f.setTranslationY(0.0f);
            }
            s.this.f1640f.setVisibility(8);
            s.this.f1640f.setTransitioning(false);
            s sVar2 = s.this;
            sVar2.f1656v = null;
            a.InterfaceC0019a interfaceC0019a = sVar2.f1647m;
            if (interfaceC0019a != null) {
                interfaceC0019a.a(sVar2.f1646l);
                sVar2.f1646l = null;
                sVar2.f1647m = null;
            }
            ActionBarOverlayLayout actionBarOverlayLayout = s.this.f1639e;
            if (actionBarOverlayLayout != null) {
                AtomicInteger atomicInteger = y.a;
                y.g.c(actionBarOverlayLayout);
            }
        }
    }

    public class b extends d.h.j.f0 {
        public b() {
        }

        @Override // d.h.j.e0
        public void b(View view) {
            s sVar = s.this;
            sVar.f1656v = null;
            sVar.f1640f.requestLayout();
        }
    }

    public class c implements g0 {
        public c() {
        }
    }

    public class d extends d.b.f.a implements g.a {

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

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        public final d.b.f.i.g f1662o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public a.InterfaceC0019a f1663p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        public WeakReference<View> f1664q;

        public d(Context context, a.InterfaceC0019a interfaceC0019a) {
            this.f1661n = context;
            this.f1663p = interfaceC0019a;
            d.b.f.i.g gVar = new d.b.f.i.g(context);
            gVar.f1798m = 1;
            this.f1662o = gVar;
            gVar.f1791f = this;
        }

        @Override // d.b.f.i.g.a
        public boolean a(d.b.f.i.g gVar, MenuItem menuItem) {
            a.InterfaceC0019a interfaceC0019a = this.f1663p;
            if (interfaceC0019a != null) {
                return interfaceC0019a.d(this, menuItem);
            }
            return false;
        }

        @Override // d.b.f.i.g.a
        public void b(d.b.f.i.g gVar) {
            if (this.f1663p == null) {
                return;
            }
            i();
            d.b.g.c cVar = s.this.f1642h.f1882o;
            if (cVar != null) {
                cVar.n();
            }
        }

        @Override // d.b.f.a
        public void c() {
            s sVar = s.this;
            if (sVar.f1645k != this) {
                return;
            }
            if (!sVar.f1653s) {
                this.f1663p.a(this);
            } else {
                sVar.f1646l = this;
                sVar.f1647m = this.f1663p;
            }
            this.f1663p = null;
            s.this.p(false);
            ActionBarContextView actionBarContextView = s.this.f1642h;
            if (actionBarContextView.f472v == null) {
                actionBarContextView.h();
            }
            s.this.f1641g.r().sendAccessibilityEvent(32);
            s sVar2 = s.this;
            sVar2.f1639e.setHideOnContentScrollEnabled(sVar2.f1658x);
            s.this.f1645k = null;
        }

        @Override // d.b.f.a
        public View d() {
            WeakReference<View> weakReference = this.f1664q;
            if (weakReference != null) {
                return weakReference.get();
            }
            return null;
        }

        @Override // d.b.f.a
        public Menu e() {
            return this.f1662o;
        }

        @Override // d.b.f.a
        public MenuInflater f() {
            return new d.b.f.f(this.f1661n);
        }

        @Override // d.b.f.a
        public CharSequence g() {
            return s.this.f1642h.getSubtitle();
        }

        @Override // d.b.f.a
        public CharSequence h() {
            return s.this.f1642h.getTitle();
        }

        @Override // d.b.f.a
        public void i() {
            if (s.this.f1645k != this) {
                return;
            }
            this.f1662o.z();
            try {
                this.f1663p.c(this, this.f1662o);
            } finally {
                this.f1662o.y();
            }
        }

        @Override // d.b.f.a
        public boolean j() {
            return s.this.f1642h.D;
        }

        @Override // d.b.f.a
        public void k(View view) {
            s.this.f1642h.setCustomView(view);
            this.f1664q = new WeakReference<>(view);
        }

        @Override // d.b.f.a
        public void l(int i2) {
            s.this.f1642h.setSubtitle(s.this.f1637c.getResources().getString(i2));
        }

        @Override // d.b.f.a
        public void m(CharSequence charSequence) {
            s.this.f1642h.setSubtitle(charSequence);
        }

        @Override // d.b.f.a
        public void n(int i2) {
            s.this.f1642h.setTitle(s.this.f1637c.getResources().getString(i2));
        }

        @Override // d.b.f.a
        public void o(CharSequence charSequence) {
            s.this.f1642h.setTitle(charSequence);
        }

        @Override // d.b.f.a
        public void p(boolean z2) {
            this.f1670m = z2;
            s.this.f1642h.setTitleOptional(z2);
        }
    }

    public s(Activity activity, boolean z2) {
        new ArrayList();
        this.f1649o = new ArrayList<>();
        this.f1651q = 0;
        this.f1652r = true;
        this.f1655u = true;
        this.f1659y = new a();
        this.f1660z = new b();
        this.A = new c();
        View decorView = activity.getWindow().getDecorView();
        q(decorView);
        if (z2) {
            return;
        }
        this.f1643i = decorView.findViewById(R.id.content);
    }

    public s(Dialog dialog) {
        new ArrayList();
        this.f1649o = new ArrayList<>();
        this.f1651q = 0;
        this.f1652r = true;
        this.f1655u = true;
        this.f1659y = new a();
        this.f1660z = new b();
        this.A = new c();
        q(dialog.getWindow().getDecorView());
    }

    @Override // d.b.c.a
    public boolean b() {
        f0 f0Var = this.f1641g;
        if (f0Var == null || !f0Var.j()) {
            return false;
        }
        this.f1641g.collapseActionView();
        return true;
    }

    @Override // d.b.c.a
    public void c(boolean z2) {
        if (z2 == this.f1648n) {
            return;
        }
        this.f1648n = z2;
        int size = this.f1649o.size();
        for (int i2 = 0; i2 < size; i2++) {
            this.f1649o.get(i2).a(z2);
        }
    }

    @Override // d.b.c.a
    public int d() {
        return this.f1641g.t();
    }

    @Override // d.b.c.a
    public Context e() {
        if (this.f1638d == null) {
            TypedValue typedValue = new TypedValue();
            this.f1637c.getTheme().resolveAttribute(com.ifpdos.udi.service.core.pc.R.attr.actionBarWidgetTheme, typedValue, true);
            int i2 = typedValue.resourceId;
            if (i2 != 0) {
                this.f1638d = new ContextThemeWrapper(this.f1637c, i2);
            } else {
                this.f1638d = this.f1637c;
            }
        }
        return this.f1638d;
    }

    @Override // d.b.c.a
    public void g(Configuration configuration) {
        r(this.f1637c.getResources().getBoolean(com.ifpdos.udi.service.core.pc.R.bool.abc_action_bar_embed_tabs));
    }

    @Override // d.b.c.a
    public boolean i(int i2, KeyEvent keyEvent) {
        d.b.f.i.g gVar;
        d dVar = this.f1645k;
        if (dVar == null || (gVar = dVar.f1662o) == null) {
            return false;
        }
        gVar.setQwertyMode(KeyCharacterMap.load(keyEvent != null ? keyEvent.getDeviceId() : -1).getKeyboardType() != 1);
        return gVar.performShortcut(i2, keyEvent, 0);
    }

    @Override // d.b.c.a
    public void l(boolean z2) {
        if (this.f1644j) {
            return;
        }
        int i2 = z2 ? 4 : 0;
        int iT = this.f1641g.t();
        this.f1644j = true;
        this.f1641g.k((i2 & 4) | (iT & (-5)));
    }

    @Override // d.b.c.a
    public void m(boolean z2) {
        d.b.f.g gVar;
        this.f1657w = z2;
        if (z2 || (gVar = this.f1656v) == null) {
            return;
        }
        gVar.a();
    }

    @Override // d.b.c.a
    public void n(CharSequence charSequence) {
        this.f1641g.setWindowTitle(charSequence);
    }

    @Override // d.b.c.a
    public d.b.f.a o(a.InterfaceC0019a interfaceC0019a) {
        d dVar = this.f1645k;
        if (dVar != null) {
            dVar.c();
        }
        this.f1639e.setHideOnContentScrollEnabled(false);
        this.f1642h.h();
        d dVar2 = new d(this.f1642h.getContext(), interfaceC0019a);
        dVar2.f1662o.z();
        try {
            if (!dVar2.f1663p.b(dVar2, dVar2.f1662o)) {
                return null;
            }
            this.f1645k = dVar2;
            dVar2.i();
            this.f1642h.f(dVar2);
            p(true);
            this.f1642h.sendAccessibilityEvent(32);
            return dVar2;
        } finally {
            dVar2.f1662o.y();
        }
    }

    public void p(boolean z2) {
        d0 d0VarO;
        d0 d0VarE;
        if (z2) {
            if (!this.f1654t) {
                this.f1654t = true;
                ActionBarOverlayLayout actionBarOverlayLayout = this.f1639e;
                if (actionBarOverlayLayout != null) {
                    actionBarOverlayLayout.setShowingForActionMode(true);
                }
                s(false);
            }
        } else if (this.f1654t) {
            this.f1654t = false;
            ActionBarOverlayLayout actionBarOverlayLayout2 = this.f1639e;
            if (actionBarOverlayLayout2 != null) {
                actionBarOverlayLayout2.setShowingForActionMode(false);
            }
            s(false);
        }
        ActionBarContainer actionBarContainer = this.f1640f;
        AtomicInteger atomicInteger = y.a;
        if (!y.f.c(actionBarContainer)) {
            if (z2) {
                this.f1641g.q(4);
                this.f1642h.setVisibility(0);
                return;
            } else {
                this.f1641g.q(0);
                this.f1642h.setVisibility(8);
                return;
            }
        }
        if (z2) {
            d0VarE = this.f1641g.o(4, 100L);
            d0VarO = this.f1642h.e(0, 200L);
        } else {
            d0VarO = this.f1641g.o(0, 200L);
            d0VarE = this.f1642h.e(8, 100L);
        }
        d.b.f.g gVar = new d.b.f.g();
        gVar.a.add(d0VarE);
        View view = d0VarE.a.get();
        long duration = view != null ? view.animate().getDuration() : 0L;
        View view2 = d0VarO.a.get();
        if (view2 != null) {
            view2.animate().setStartDelay(duration);
        }
        gVar.a.add(d0VarO);
        gVar.b();
    }

    public final void q(View view) {
        f0 wrapper;
        ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) view.findViewById(com.ifpdos.udi.service.core.pc.R.id.decor_content_parent);
        this.f1639e = actionBarOverlayLayout;
        if (actionBarOverlayLayout != null) {
            actionBarOverlayLayout.setActionBarVisibilityCallback(this);
        }
        KeyEvent.Callback callbackFindViewById = view.findViewById(com.ifpdos.udi.service.core.pc.R.id.action_bar);
        if (callbackFindViewById instanceof f0) {
            wrapper = (f0) callbackFindViewById;
        } else {
            if (!(callbackFindViewById instanceof Toolbar)) {
                StringBuilder sbF = g.a.a.a.a.F("Can't make a decor toolbar out of ");
                sbF.append(callbackFindViewById != null ? callbackFindViewById.getClass().getSimpleName() : AbstractJsonLexerKt.NULL);
                throw new IllegalStateException(sbF.toString());
            }
            wrapper = ((Toolbar) callbackFindViewById).getWrapper();
        }
        this.f1641g = wrapper;
        this.f1642h = (ActionBarContextView) view.findViewById(com.ifpdos.udi.service.core.pc.R.id.action_context_bar);
        ActionBarContainer actionBarContainer = (ActionBarContainer) view.findViewById(com.ifpdos.udi.service.core.pc.R.id.action_bar_container);
        this.f1640f = actionBarContainer;
        f0 f0Var = this.f1641g;
        if (f0Var == null || this.f1642h == null || actionBarContainer == null) {
            throw new IllegalStateException(s.class.getSimpleName() + " can only be used with a compatible window decor layout");
        }
        this.f1637c = f0Var.getContext();
        boolean z2 = (this.f1641g.t() & 4) != 0;
        if (z2) {
            this.f1644j = true;
        }
        Context context = this.f1637c;
        this.f1641g.s((context.getApplicationInfo().targetSdkVersion < 14) || z2);
        r(context.getResources().getBoolean(com.ifpdos.udi.service.core.pc.R.bool.abc_action_bar_embed_tabs));
        TypedArray typedArrayObtainStyledAttributes = this.f1637c.obtainStyledAttributes(null, d.b.b.a, com.ifpdos.udi.service.core.pc.R.attr.actionBarStyle, 0);
        if (typedArrayObtainStyledAttributes.getBoolean(14, false)) {
            ActionBarOverlayLayout actionBarOverlayLayout2 = this.f1639e;
            if (!actionBarOverlayLayout2.f486t) {
                throw new IllegalStateException("Action bar must be in overlay mode (Window.FEATURE_OVERLAY_ACTION_BAR) to enable hide on content scroll");
            }
            this.f1658x = true;
            actionBarOverlayLayout2.setHideOnContentScrollEnabled(true);
        }
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(12, 0);
        if (dimensionPixelSize != 0) {
            ActionBarContainer actionBarContainer2 = this.f1640f;
            AtomicInteger atomicInteger = y.a;
            y.h.s(actionBarContainer2, dimensionPixelSize);
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public final void r(boolean z2) {
        this.f1650p = z2;
        if (z2) {
            this.f1640f.setTabContainer(null);
            this.f1641g.i(null);
        } else {
            this.f1641g.i(null);
            this.f1640f.setTabContainer(null);
        }
        boolean z3 = this.f1641g.n() == 2;
        this.f1641g.w(!this.f1650p && z3);
        this.f1639e.setHasNonEmbeddedTabs(!this.f1650p && z3);
    }

    public final void s(boolean z2) {
        View view;
        View view2;
        View view3;
        if (!(this.f1654t || !this.f1653s)) {
            if (this.f1655u) {
                this.f1655u = false;
                d.b.f.g gVar = this.f1656v;
                if (gVar != null) {
                    gVar.a();
                }
                if (this.f1651q != 0 || (!this.f1657w && !z2)) {
                    this.f1659y.b(null);
                    return;
                }
                this.f1640f.setAlpha(1.0f);
                this.f1640f.setTransitioning(true);
                d.b.f.g gVar2 = new d.b.f.g();
                float f2 = -this.f1640f.getHeight();
                if (z2) {
                    this.f1640f.getLocationInWindow(new int[]{0, 0});
                    f2 -= r9[1];
                }
                d0 d0VarB = y.b(this.f1640f);
                d0VarB.g(f2);
                d0VarB.f(this.A);
                if (!gVar2.f1720e) {
                    gVar2.a.add(d0VarB);
                }
                if (this.f1652r && (view = this.f1643i) != null) {
                    d0 d0VarB2 = y.b(view);
                    d0VarB2.g(f2);
                    if (!gVar2.f1720e) {
                        gVar2.a.add(d0VarB2);
                    }
                }
                Interpolator interpolator = a;
                boolean z3 = gVar2.f1720e;
                if (!z3) {
                    gVar2.f1718c = interpolator;
                }
                if (!z3) {
                    gVar2.f1717b = 250L;
                }
                e0 e0Var = this.f1659y;
                if (!z3) {
                    gVar2.f1719d = e0Var;
                }
                this.f1656v = gVar2;
                gVar2.b();
                return;
            }
            return;
        }
        if (this.f1655u) {
            return;
        }
        this.f1655u = true;
        d.b.f.g gVar3 = this.f1656v;
        if (gVar3 != null) {
            gVar3.a();
        }
        this.f1640f.setVisibility(0);
        if (this.f1651q == 0 && (this.f1657w || z2)) {
            this.f1640f.setTranslationY(0.0f);
            float f3 = -this.f1640f.getHeight();
            if (z2) {
                this.f1640f.getLocationInWindow(new int[]{0, 0});
                f3 -= r9[1];
            }
            this.f1640f.setTranslationY(f3);
            d.b.f.g gVar4 = new d.b.f.g();
            d0 d0VarB3 = y.b(this.f1640f);
            d0VarB3.g(0.0f);
            d0VarB3.f(this.A);
            if (!gVar4.f1720e) {
                gVar4.a.add(d0VarB3);
            }
            if (this.f1652r && (view3 = this.f1643i) != null) {
                view3.setTranslationY(f3);
                d0 d0VarB4 = y.b(this.f1643i);
                d0VarB4.g(0.0f);
                if (!gVar4.f1720e) {
                    gVar4.a.add(d0VarB4);
                }
            }
            Interpolator interpolator2 = f1636b;
            boolean z4 = gVar4.f1720e;
            if (!z4) {
                gVar4.f1718c = interpolator2;
            }
            if (!z4) {
                gVar4.f1717b = 250L;
            }
            e0 e0Var2 = this.f1660z;
            if (!z4) {
                gVar4.f1719d = e0Var2;
            }
            this.f1656v = gVar4;
            gVar4.b();
        } else {
            this.f1640f.setAlpha(1.0f);
            this.f1640f.setTranslationY(0.0f);
            if (this.f1652r && (view2 = this.f1643i) != null) {
                view2.setTranslationY(0.0f);
            }
            this.f1660z.b(null);
        }
        ActionBarOverlayLayout actionBarOverlayLayout = this.f1639e;
        if (actionBarOverlayLayout != null) {
            AtomicInteger atomicInteger = y.a;
            y.g.c(actionBarOverlayLayout);
        }
    }
}
