package androidx.appcompat.view;

import android.content.Context;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.view.b;
import androidx.appcompat.view.menu.g;
import androidx.appcompat.widget.ActionBarContextView;
import java.lang.ref.WeakReference;

/* JADX INFO: compiled from: StandaloneActionMode.java */
/* JADX INFO: loaded from: classes.dex */
public class e extends b implements g.a {

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private Context f326g;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private b.a f328i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private WeakReference<View> f329j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private boolean f330k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private androidx.appcompat.view.menu.g f331l;

    public e(Context context, ActionBarContextView actionBarContextView, b.a aVar, boolean z2) {
        this.f326g = context;
        this.f327h = actionBarContextView;
        this.f328i = aVar;
        androidx.appcompat.view.menu.g gVarS = new androidx.appcompat.view.menu.g(actionBarContextView.getContext()).S(1);
        this.f331l = gVarS;
        gVarS.R(this);
    }

    @Override // androidx.appcompat.view.menu.g.a
    public boolean a(androidx.appcompat.view.menu.g gVar, MenuItem menuItem) {
        return this.f328i.b(this, menuItem);
    }

    @Override // androidx.appcompat.view.menu.g.a
    public void b(androidx.appcompat.view.menu.g gVar) {
        k();
        this.f327h.l();
    }

    @Override // androidx.appcompat.view.b
    public void c() {
        if (this.f330k) {
            return;
        }
        this.f330k = true;
        this.f328i.d(this);
    }

    @Override // androidx.appcompat.view.b
    public View d() {
        WeakReference<View> weakReference = this.f329j;
        if (weakReference != null) {
            return weakReference.get();
        }
        return null;
    }

    @Override // androidx.appcompat.view.b
    public Menu e() {
        return this.f331l;
    }

    @Override // androidx.appcompat.view.b
    public MenuInflater f() {
        return new g(this.f327h.getContext());
    }

    @Override // androidx.appcompat.view.b
    public CharSequence g() {
        return this.f327h.getSubtitle();
    }

    @Override // androidx.appcompat.view.b
    public CharSequence i() {
        return this.f327h.getTitle();
    }

    @Override // androidx.appcompat.view.b
    public void k() {
        this.f328i.a(this, this.f331l);
    }

    @Override // androidx.appcompat.view.b
    public boolean l() {
        return this.f327h.j();
    }

    @Override // androidx.appcompat.view.b
    public void m(View view) {
        this.f327h.setCustomView(view);
        this.f329j = view != null ? new WeakReference<>(view) : null;
    }

    @Override // androidx.appcompat.view.b
    public void n(int i3) {
        o(this.f326g.getString(i3));
    }

    @Override // androidx.appcompat.view.b
    public void o(CharSequence charSequence) {
        this.f327h.setSubtitle(charSequence);
    }

    @Override // androidx.appcompat.view.b
    public void q(int i3) {
        r(this.f326g.getString(i3));
    }

    @Override // androidx.appcompat.view.b
    public void r(CharSequence charSequence) {
        this.f327h.setTitle(charSequence);
    }

    @Override // androidx.appcompat.view.b
    public void s(boolean z2) {
        super.s(z2);
        this.f327h.setTitleOptional(z2);
    }
}
