Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve accessibility #38

Merged
merged 2 commits into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions chip-navigation-bar/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<attr name="android:title" />
<attr name="android:icon" />
<attr name="android:enabled" />
<attr name="android:contentDescription" />
<attr name="cnb_iconColor" format="color" />
<attr name="cnb_iconTintMode">
<enum name="src_over" value="3" />
Expand Down