package ῲ.ῲ.K;

import android.content.Context;
import android.content.res.Configuration;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import androidx.appcompat.widget.Toolbar;
import java.util.ArrayList;
import ῲ.ᨨ.ᨨ.C1729;
import ῲ.ῲ.ඓ.Window$CallbackC1889;
import ῲ.ῲ.ඓ.㳳.AbstractC1897;
import ῲ.ῲ.ඓ.㳳.C1912;
import ῲ.ῲ.K.AbstractC1963;
import ῲ.ῲ.㴹.AbstractC2002;
import ῲ.ῲ.㴹.C2040;

/* renamed from: ῲ.ῲ.K.㶋  reason: contains not printable characters */
/* compiled from: ToolbarActionBar */
public class C1974 extends AbstractC1963 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public Window.Callback f6710;

    /* renamed from: ඓ  reason: contains not printable characters */
    public boolean f6711;

    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean f6712;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public final Runnable f6713 = new RunnableC1978();

    /* renamed from: K  reason: contains not printable characters */
    public AbstractC2002 f6714;

    /* renamed from: 㴹  reason: contains not printable characters */
    public ArrayList<AbstractC1963.AbstractC1965> f6715 = new ArrayList<>();

    /* renamed from: 㸾  reason: contains not printable characters */
    public boolean f6716;

    /* renamed from: 㿎  reason: contains not printable characters */
    public final Toolbar.AbstractC0119 f6717 = new C1977();

    /* renamed from: ῲ.ῲ.K.㶋$ʬ  reason: contains not printable characters */
    /* compiled from: ToolbarActionBar */
    public final class C1975 implements AbstractC1897.AbstractC1898 {

        /* renamed from: ῲ  reason: contains not printable characters */
        public boolean f6719;

        public C1975() {
        }

        @Override // ῲ.ῲ.ඓ.㳳.AbstractC1897.AbstractC1898
        public void onCloseMenu(C1912 r2, boolean z) {
            if (!this.f6719) {
                this.f6719 = true;
                ((C2040) C1974.this.f6714).f6933.dismissPopupMenus();
                Window.Callback callback = C1974.this.f6710;
                if (callback != null) {
                    callback.onPanelClosed(108, r2);
                }
                this.f6719 = false;
            }
        }

        @Override // ῲ.ῲ.ඓ.㳳.AbstractC1897.AbstractC1898
        /* renamed from: K  reason: contains not printable characters */
        public boolean m5119(C1912 r3) {
            Window.Callback callback = C1974.this.f6710;
            if (callback == null) {
                return false;
            }
            callback.onMenuOpened(108, r3);
            return true;
        }
    }

    /* renamed from: ῲ.ῲ.K.㶋$ඓ  reason: contains not printable characters */
    /* compiled from: ToolbarActionBar */
    public class C1976 extends Window$CallbackC1889 {
        public C1976(Window.Callback callback) {
            super(callback);
        }

        @Override // ῲ.ῲ.ඓ.Window$CallbackC1889
        public View onCreatePanelView(int i) {
            if (i == 0) {
                return new View(((C2040) C1974.this.f6714).m5294());
            }
            return this.f6391.onCreatePanelView(i);
        }

        public boolean onPreparePanel(int i, View view, Menu menu) {
            boolean onPreparePanel = this.f6391.onPreparePanel(i, view, menu);
            if (onPreparePanel) {
                C1974 r3 = C1974.this;
                if (!r3.f6712) {
                    ((C2040) r3.f6714).f6940 = true;
                    r3.f6712 = true;
                }
            }
            return onPreparePanel;
        }
    }

    /* renamed from: ῲ.ῲ.K.㶋$ῲ  reason: contains not printable characters */
    /* compiled from: ToolbarActionBar */
    public class C1977 implements Toolbar.AbstractC0119 {
        public C1977() {
        }
    }

    /* renamed from: ῲ.ῲ.K.㶋$K  reason: contains not printable characters */
    /* compiled from: ToolbarActionBar */
    public class RunnableC1978 implements Runnable {
        public RunnableC1978() {
        }

        public void run() {
            C1974.this.m5100();
        }
    }

    /* renamed from: ῲ.ῲ.K.㶋$㸾  reason: contains not printable characters */
    /* compiled from: ToolbarActionBar */
    public final class C1979 implements C1912.AbstractC1914 {
        public C1979() {
        }

        @Override // ῲ.ῲ.ඓ.㳳.C1912.AbstractC1914
        public boolean onMenuItemSelected(C1912 r1, MenuItem menuItem) {
            return false;
        }

        @Override // ῲ.ῲ.ඓ.㳳.C1912.AbstractC1914
        public void onMenuModeChange(C1912 r5) {
            C1974 r0 = C1974.this;
            if (r0.f6710 == null) {
                return;
            }
            if (((C2040) r0.f6714).f6933.isOverflowMenuShowing()) {
                C1974.this.f6710.onPanelClosed(108, r5);
            } else if (C1974.this.f6710.onPreparePanel(0, null, r5)) {
                C1974.this.f6710.onMenuOpened(108, r5);
            }
        }
    }

    public C1974(Toolbar toolbar, CharSequence charSequence, Window.Callback callback) {
        this.f6714 = new C2040(toolbar, false);
        this.f6710 = new C1976(callback);
        ((C2040) this.f6714).f6934 = this.f6710;
        toolbar.setOnMenuItemClickListener(this.f6717);
        C2040 r3 = (C2040) this.f6714;
        if (!r3.f6939) {
            r3.f6930 = charSequence;
            if ((r3.f6931 & 8) != 0) {
                r3.f6933.setTitle(charSequence);
            }
        }
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    public void addOnMenuVisibilityListener(AbstractC1963.AbstractC1965 r2) {
        this.f6715.add(r2);
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    public void removeOnMenuVisibilityListener(AbstractC1963.AbstractC1965 r2) {
        this.f6715.remove(r2);
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: ʬ  reason: contains not printable characters */
    public void m5099(boolean z) {
    }

    /* renamed from: Ԕ  reason: contains not printable characters */
    public void m5100() {
        Menu r0 = m5112();
        C1912 r1 = r0 instanceof C1912 ? (C1912) r0 : null;
        if (r1 != null) {
            r1.stopDispatchingItemsChanged();
        }
        try {
            r0.clear();
            if (!this.f6710.onCreatePanelMenu(0, r0) || !this.f6710.onPreparePanel(0, null, r0)) {
                r0.clear();
            }
        } finally {
            if (r1 != null) {
                r1.startDispatchingItemsChanged();
            }
        }
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: ඓ  reason: contains not printable characters */
    public void m5101(boolean z) {
        m5107(z ? 8 : 0, 8);
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: ᕣ  reason: contains not printable characters */
    public boolean m5103() {
        return ((C2040) this.f6714).f6933.showOverflowMenu();
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: ᨨ  reason: contains not printable characters */
    public boolean m5104() {
        ((C2040) this.f6714).f6933.removeCallbacks(this.f6713);
        C1729.m4479(((C2040) this.f6714).f6933, this.f6713);
        return true;
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: ῲ  reason: contains not printable characters */
    public void m5105(boolean z) {
        if (z != this.f6711) {
            this.f6711 = z;
            int size = this.f6715.size();
            for (int i = 0; i < size; i++) {
                this.f6715.get(i).m5095(z);
            }
        }
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: ⁱ  reason: contains not printable characters */
    public int m5106() {
        return ((C2040) this.f6714).f6931;
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: K  reason: contains not printable characters */
    public void m5108(Configuration configuration) {
        super.m5081(configuration);
    }

    /* renamed from: 㑃  reason: contains not printable characters */
    public final Menu m5112() {
        if (!this.f6716) {
            AbstractC2002 r0 = this.f6714;
            ((C2040) r0).f6933.setMenuCallbacks(new C1975(), new C1979());
            this.f6716 = true;
        }
        return ((C2040) this.f6714).f6933.getMenu();
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: 㳳  reason: contains not printable characters */
    public void m5113() {
        ((C2040) this.f6714).f6933.removeCallbacks(this.f6713);
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: 㴹  reason: contains not printable characters */
    public void m5114(boolean z) {
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: 㴹  reason: contains not printable characters */
    public boolean m5115() {
        if (!((C2040) this.f6714).f6933.hasExpandedActionView()) {
            return false;
        }
        ((C2040) this.f6714).f6933.collapseActionView();
        return true;
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: 㸾  reason: contains not printable characters */
    public void m5116(boolean z) {
        m5107(z ? 4 : 0, 4);
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: 㿎  reason: contains not printable characters */
    public Context m5117() {
        return ((C2040) this.f6714).m5294();
    }

    /* renamed from: 䁗  reason: contains not printable characters */
    public Window.Callback m5118() {
        return this.f6710;
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: ඓ  reason: contains not printable characters */
    public boolean m5102() {
        return ((C2040) this.f6714).f6933.hideOverflowMenu();
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: K  reason: contains not printable characters */
    public void m5109(CharSequence charSequence) {
        C2040 r0 = (C2040) this.f6714;
        if (!r0.f6939) {
            r0.m5299(charSequence);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5107(int i, int i2) {
        AbstractC2002 r0 = this.f6714;
        int i3 = ((C2040) r0).f6931;
        ((C2040) r0).m5296((i & i2) | ((~i2) & i3));
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: K  reason: contains not printable characters */
    public boolean m5111(KeyEvent keyEvent) {
        if (keyEvent.getAction() == 1) {
            m5103();
        }
        return true;
    }

    @Override // ῲ.ῲ.K.AbstractC1963
    /* renamed from: K  reason: contains not printable characters */
    public boolean m5110(int i, KeyEvent keyEvent) {
        Menu r0 = m5112();
        if (r0 == null) {
            return false;
        }
        boolean z = true;
        if (KeyCharacterMap.load(keyEvent != null ? keyEvent.getDeviceId() : -1).getKeyboardType() == 1) {
            z = false;
        }
        r0.setQwertyMode(z);
        return r0.performShortcut(i, keyEvent, 0);
    }
}
