diff --git a/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/model/MenuItem.kt b/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/model/MenuItem.kt index e801dc2..dea077d 100644 --- a/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/model/MenuItem.kt +++ b/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/model/MenuItem.kt @@ -8,6 +8,7 @@ import androidx.annotation.DrawableRes internal class MenuItem( val id: Int, val title: CharSequence, + val contentDescription: CharSequence?, @DrawableRes val icon: Int, val enabled: Boolean, val tintMode: PorterDuff.Mode?, diff --git a/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/model/MenuParser.kt b/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/model/MenuParser.kt index d15128a..5dee915 100644 --- a/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/model/MenuParser.kt +++ b/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/model/MenuParser.kt @@ -74,6 +74,7 @@ internal class MenuParser(private val context: Context) { val item = MenuItem( id = sAttr.getResourceId(R.styleable.ChipMenuItem_android_id, 0), title = sAttr.getText(R.styleable.ChipMenuItem_android_title), + contentDescription = sAttr.getText(R.styleable.ChipMenuItem_android_contentDescription), icon = sAttr.getResourceId(R.styleable.ChipMenuItem_android_icon, 0), enabled = sAttr.getBoolean(R.styleable.ChipMenuItem_android_enabled, true), iconColor = readIconActiveColor(sAttr), diff --git a/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/view/HorizontalMenuItemView.kt b/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/view/HorizontalMenuItemView.kt index 1b4f0e3..04ad30a 100644 --- a/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/view/HorizontalMenuItemView.kt +++ b/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/view/HorizontalMenuItemView.kt @@ -36,6 +36,10 @@ internal class HorizontalMenuItemView @JvmOverloads constructor( override fun bind(item: MenuItem) { id = item.id + + importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_YES + contentDescription = item.contentDescription ?: item.title + isEnabled = item.enabled item.menuStyle.textAppearance?.let(title::setTextAppearance) title.text = item.title diff --git a/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/view/VerticalMenuItemView.kt b/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/view/VerticalMenuItemView.kt index 7569b73..42465cd 100644 --- a/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/view/VerticalMenuItemView.kt +++ b/chip-navigation-bar/src/main/java/com/ismaeldivita/chipnavigation/view/VerticalMenuItemView.kt @@ -49,6 +49,9 @@ internal class VerticalMenuItemView @JvmOverloads constructor( isEnabled = item.enabled radius = item.menuStyle.radius + importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_YES + contentDescription = item.contentDescription ?: item.title + item.menuStyle.textAppearance?.let(title::setTextAppearance) title.text = item.title title.setColorStateListAnimator( diff --git a/chip-navigation-bar/src/main/res/values/attrs.xml b/chip-navigation-bar/src/main/res/values/attrs.xml index a39ebab..a95231f 100644 --- a/chip-navigation-bar/src/main/res/values/attrs.xml +++ b/chip-navigation-bar/src/main/res/values/attrs.xml @@ -25,6 +25,7 @@ +