package androidx.appcompat.view.menu;

import android.R;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import p037.p041.C1468;
import p037.p041.C1473;
import p037.p041.C1474;
import p037.p041.C1475;
import p037.p041.C1477;
import p037.p041.p049.p050.C1576;
import p037.p041.p049.p050.InterfaceC1589;
import p037.p041.p051.C1689;
import p037.p065.p078.C1920;

/* JADX INFO: loaded from: classes.dex */
public class ListMenuItemView extends LinearLayout implements InterfaceC1589.InterfaceC1590, AbsListView.SelectionBoundsAdjuster {

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public C1576 f210;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public ImageView f211;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public RadioButton f212;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public TextView f213;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public CheckBox f214;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public TextView f215;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public ImageView f216;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public ImageView f217;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public LinearLayout f218;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public Drawable f219;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public int f220;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public Context f221;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public boolean f222;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public Drawable f223;

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public boolean f224;

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public LayoutInflater f225;

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public boolean f226;

    public ListMenuItemView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, C1468.listMenuViewStyle);
    }

    public ListMenuItemView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet);
        C1689 c1689M3294 = C1689.m3294(getContext(), attributeSet, C1477.MenuView, i, 0);
        this.f219 = c1689M3294.m3300(C1477.MenuView_android_itemBackground);
        this.f220 = c1689M3294.m3305(C1477.MenuView_android_itemTextAppearance, -1);
        this.f222 = c1689M3294.m3298(C1477.MenuView_preserveIconSpacing, false);
        this.f221 = context;
        this.f223 = c1689M3294.m3300(C1477.MenuView_subMenuArrow);
        TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(null, new int[]{R.attr.divider}, C1468.dropDownListViewStyle, 0);
        this.f224 = typedArrayObtainStyledAttributes.hasValue(0);
        c1689M3294.f5496.recycle();
        typedArrayObtainStyledAttributes.recycle();
    }

    private LayoutInflater getInflater() {
        if (this.f225 == null) {
            this.f225 = LayoutInflater.from(getContext());
        }
        return this.f225;
    }

    private void setSubMenuArrowVisible(boolean z) {
        ImageView imageView = this.f216;
        if (imageView != null) {
            imageView.setVisibility(z ? 0 : 8);
        }
    }

    @Override // android.widget.AbsListView.SelectionBoundsAdjuster
    public void adjustListItemSelectionBounds(Rect rect) {
        ImageView imageView = this.f217;
        if (imageView == null || imageView.getVisibility() != 0) {
            return;
        }
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.f217.getLayoutParams();
        rect.top = this.f217.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin + rect.top;
    }

    @Override // p037.p041.p049.p050.InterfaceC1589.InterfaceC1590
    public C1576 getItemData() {
        return this.f210;
    }

    @Override // android.view.View
    public void onFinishInflate() {
        super.onFinishInflate();
        C1920.m3744(this, this.f219);
        TextView textView = (TextView) findViewById(C1473.title);
        this.f213 = textView;
        int i = this.f220;
        if (i != -1) {
            textView.setTextAppearance(this.f221, i);
        }
        this.f215 = (TextView) findViewById(C1473.shortcut);
        ImageView imageView = (ImageView) findViewById(C1473.submenuarrow);
        this.f216 = imageView;
        if (imageView != null) {
            imageView.setImageDrawable(this.f223);
        }
        this.f217 = (ImageView) findViewById(C1473.group_divider);
        this.f218 = (LinearLayout) findViewById(C1473.content);
    }

    @Override // android.widget.LinearLayout, android.view.View
    public void onMeasure(int i, int i2) {
        if (this.f211 != null && this.f222) {
            ViewGroup.LayoutParams layoutParams = getLayoutParams();
            LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.f211.getLayoutParams();
            int i3 = layoutParams.height;
            if (i3 > 0 && layoutParams2.width <= 0) {
                layoutParams2.width = i3;
            }
        }
        super.onMeasure(i, i2);
    }

    public void setCheckable(boolean z) {
        CompoundButton compoundButton;
        CompoundButton compoundButton2;
        if (!z && this.f212 == null && this.f214 == null) {
            return;
        }
        if (this.f210.m3118()) {
            if (this.f212 == null) {
                m115();
            }
            compoundButton = this.f212;
            compoundButton2 = this.f214;
        } else {
            if (this.f214 == null) {
                m114();
            }
            compoundButton = this.f214;
            compoundButton2 = this.f212;
        }
        if (z) {
            compoundButton.setChecked(this.f210.isChecked());
            if (compoundButton.getVisibility() != 0) {
                compoundButton.setVisibility(0);
            }
            if (compoundButton2 == null || compoundButton2.getVisibility() == 8) {
                return;
            }
            compoundButton2.setVisibility(8);
            return;
        }
        CheckBox checkBox = this.f214;
        if (checkBox != null) {
            checkBox.setVisibility(8);
        }
        RadioButton radioButton = this.f212;
        if (radioButton != null) {
            radioButton.setVisibility(8);
        }
    }

    public void setChecked(boolean z) {
        CompoundButton compoundButton;
        if (this.f210.m3118()) {
            if (this.f212 == null) {
                m115();
            }
            compoundButton = this.f212;
        } else {
            if (this.f214 == null) {
                m114();
            }
            compoundButton = this.f214;
        }
        compoundButton.setChecked(z);
    }

    public void setForceShowIcon(boolean z) {
        this.f226 = z;
        this.f222 = z;
    }

    public void setGroupDividerEnabled(boolean z) {
        ImageView imageView = this.f217;
        if (imageView != null) {
            imageView.setVisibility((this.f224 || !z) ? 8 : 0);
        }
    }

    public void setIcon(Drawable drawable) {
        boolean z = this.f210.f5118.f5095 || this.f226;
        if (z || this.f222) {
            if (this.f211 == null && drawable == null && !this.f222) {
                return;
            }
            if (this.f211 == null) {
                ImageView imageView = (ImageView) getInflater().inflate(C1474.abc_list_menu_item_icon, (ViewGroup) this, false);
                this.f211 = imageView;
                LinearLayout linearLayout = this.f218;
                if (linearLayout != null) {
                    linearLayout.addView(imageView, 0);
                } else {
                    addView(imageView, 0);
                }
            }
            if (drawable == null && !this.f222) {
                this.f211.setVisibility(8);
                return;
            }
            ImageView imageView2 = this.f211;
            if (!z) {
                drawable = null;
            }
            imageView2.setImageDrawable(drawable);
            if (this.f211.getVisibility() != 0) {
                this.f211.setVisibility(0);
            }
        }
    }

    public void setTitle(CharSequence charSequence) {
        if (charSequence == null) {
            if (this.f213.getVisibility() != 8) {
                this.f213.setVisibility(8);
            }
        } else {
            this.f213.setText(charSequence);
            if (this.f213.getVisibility() != 0) {
                this.f213.setVisibility(0);
            }
        }
    }

    @Override // p037.p041.p049.p050.InterfaceC1589.InterfaceC1590
    /* JADX INFO: renamed from: ֏ */
    public void mo103(C1576 c1576, int i) {
        String string;
        this.f210 = c1576;
        setVisibility(c1576.isVisible() ? 0 : 8);
        setTitle(mo104() ? c1576.getTitleCondensed() : c1576.f5109);
        setCheckable(c1576.isCheckable());
        boolean zM3119 = c1576.m3119();
        c1576.m3113();
        int i2 = (zM3119 && this.f210.m3119()) ? 0 : 8;
        if (i2 == 0) {
            TextView textView = this.f215;
            C1576 c15762 = this.f210;
            char cM3113 = c15762.m3113();
            if (cM3113 == 0) {
                string = "";
            } else {
                Resources resources = c15762.f5118.f5077.getResources();
                StringBuilder sb = new StringBuilder();
                if (ViewConfiguration.get(c15762.f5118.f5077).hasPermanentMenuKey()) {
                    sb.append(resources.getString(C1475.abc_prepend_shortcut_label));
                }
                int i3 = c15762.f5118.mo3105() ? c15762.f5115 : c15762.f5113;
                C1576.m3110(sb, i3, 65536, resources.getString(C1475.abc_menu_meta_shortcut_label));
                C1576.m3110(sb, i3, 4096, resources.getString(C1475.abc_menu_ctrl_shortcut_label));
                C1576.m3110(sb, i3, 2, resources.getString(C1475.abc_menu_alt_shortcut_label));
                C1576.m3110(sb, i3, 1, resources.getString(C1475.abc_menu_shift_shortcut_label));
                C1576.m3110(sb, i3, 4, resources.getString(C1475.abc_menu_sym_shortcut_label));
                C1576.m3110(sb, i3, 8, resources.getString(C1475.abc_menu_function_shortcut_label));
                if (cM3113 == '\b') {
                    sb.append(resources.getString(C1475.abc_menu_delete_shortcut_label));
                } else if (cM3113 == '\n') {
                    sb.append(resources.getString(C1475.abc_menu_enter_shortcut_label));
                } else if (cM3113 != ' ') {
                    sb.append(cM3113);
                } else {
                    sb.append(resources.getString(C1475.abc_menu_space_shortcut_label));
                }
                string = sb.toString();
            }
            textView.setText(string);
        }
        if (this.f215.getVisibility() != i2) {
            this.f215.setVisibility(i2);
        }
        setIcon(c1576.getIcon());
        setEnabled(c1576.isEnabled());
        setSubMenuArrowVisible(c1576.hasSubMenu());
        setContentDescription(c1576.f5121);
    }

    @Override // p037.p041.p049.p050.InterfaceC1589.InterfaceC1590
    /* JADX INFO: renamed from: ֏ */
    public boolean mo104() {
        return false;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m114() {
        CheckBox checkBox = (CheckBox) getInflater().inflate(C1474.abc_list_menu_item_checkbox, (ViewGroup) this, false);
        this.f214 = checkBox;
        LinearLayout linearLayout = this.f218;
        if (linearLayout != null) {
            linearLayout.addView(checkBox, -1);
        } else {
            addView(checkBox, -1);
        }
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final void m115() {
        RadioButton radioButton = (RadioButton) getInflater().inflate(C1474.abc_list_menu_item_radio, (ViewGroup) this, false);
        this.f212 = radioButton;
        LinearLayout linearLayout = this.f218;
        if (linearLayout != null) {
            linearLayout.addView(radioButton, -1);
        } else {
            addView(radioButton, -1);
        }
    }
}
