package o;

import android.content.Context;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.Window;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import java.util.ArrayList;
import java.util.WeakHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Tf0 extends T0 {
    public final Vf0 a;
    public final Window.Callback b;
    public final Sf0 c;
    public boolean d;
    public boolean e;
    public boolean f;
    public final ArrayList g = new ArrayList();
    public final RunnableC2017o3 h = new RunnableC2017o3(20, this);

    public Tf0(Toolbar toolbar, CharSequence charSequence, N7 n7) {
        Sf0 sf0 = new Sf0(this);
        Vf0 vf0 = new Vf0(toolbar, false);
        this.a = vf0;
        n7.getClass();
        this.b = n7;
        vf0.k = n7;
        toolbar.setOnMenuItemClickListener(sf0);
        if (!vf0.g) {
            vf0.h = charSequence;
            if ((vf0.b & 8) != 0) {
                toolbar.setTitle(charSequence);
                if (vf0.g) {
                    Oj0.n(toolbar.getRootView(), charSequence);
                }
            }
        }
        this.c = new Sf0(this);
    }

    @Override // o.T0
    public final boolean a() {
        C1444i1 c1444i1;
        ActionMenuView actionMenuView = this.a.a.l;
        return (actionMenuView == null || (c1444i1 = actionMenuView.E) == null || !c1444i1.e()) ? false : true;
    }

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

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

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

    @Override // o.T0
    public final Context e() {
        return this.a.a.getContext();
    }

    @Override // o.T0
    public final boolean f() {
        Vf0 vf0 = this.a;
        Toolbar toolbar = vf0.a;
        RunnableC2017o3 runnableC2017o3 = this.h;
        toolbar.removeCallbacks(runnableC2017o3);
        Toolbar toolbar2 = vf0.a;
        WeakHashMap weakHashMap = Oj0.a;
        toolbar2.postOnAnimation(runnableC2017o3);
        return true;
    }

    @Override // o.T0
    public final void h() {
        this.a.a.removeCallbacks(this.h);
    }

    @Override // o.T0
    public final boolean i(int i, KeyEvent keyEvent) {
        Menu menuP = p();
        if (menuP == null) {
            return false;
        }
        menuP.setQwertyMode(KeyCharacterMap.load(keyEvent.getDeviceId()).getKeyboardType() != 1);
        return menuP.performShortcut(i, keyEvent, 0);
    }

    @Override // o.T0
    public final boolean j(KeyEvent keyEvent) {
        if (keyEvent.getAction() == 1) {
            k();
        }
        return true;
    }

    @Override // o.T0
    public final boolean k() {
        return this.a.a.v();
    }

    @Override // o.T0
    public final void n(CharSequence charSequence) {
        Vf0 vf0 = this.a;
        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);
            }
        }
    }

    public final Menu p() {
        boolean z = this.e;
        Vf0 vf0 = this.a;
        if (!z) {
            C2160pe c2160pe = new C2160pe(this, (byte) 0);
            Sf0 sf0 = new Sf0(this);
            Toolbar toolbar = vf0.a;
            toolbar.b0 = c2160pe;
            toolbar.c0 = sf0;
            ActionMenuView actionMenuView = toolbar.l;
            if (actionMenuView != null) {
                actionMenuView.F = c2160pe;
                actionMenuView.G = sf0;
            }
            this.e = true;
        }
        return vf0.a.getMenu();
    }

    @Override // o.T0
    public final void g() {
    }

    @Override // o.T0
    public final void l(boolean z) {
    }

    @Override // o.T0
    public final void m(boolean z) {
    }
}
