Skip to content

Commit

Permalink
HMA-7136 ViewExt (#168)
Browse files Browse the repository at this point in the history
* HMA-7136 role description

* changelog

* HMA-7136 default parameter

* HMA-7136 example

* HMA-7136 button accessibility updated

* HMA-7136 unused string
  • Loading branch information
emmaatkins authored May 20, 2024
1 parent add5b68 commit 0131a73
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Allowed headings:

## [Unreleased]

### Added

* Added role description option in `ViewExt`

## [4.11.1] - 2024-04-26Z

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import androidx.core.view.ViewCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import uk.gov.hmrc.components.R

fun View.setAccessibilityMessage(message: CharSequence) {
fun View.setAccessibilityMessage(message: CharSequence, className: String? = null) {
ViewCompat.setAccessibilityDelegate(
this,
object : AccessibilityDelegateCompat() {
Expand All @@ -34,6 +34,9 @@ fun View.setAccessibilityMessage(message: CharSequence) {
message
)
info.addAction(customClick)
if (!className.isNullOrEmpty()) {
info.roleDescription = className
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.text.TextUtils
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.RelativeLayout
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
Expand Down Expand Up @@ -157,8 +158,8 @@ class SummaryRowView @JvmOverloads constructor(
}

fun setButtonAccessibilityMessage(buttonText: String, action: String) {
contentDescription = context.getString(R.string.button_content_description, buttonText)
setAccessibilityMessage(action)
contentDescription = buttonText
setAccessibilityMessage(action, Button::class.java.simpleName)
}

// This method can be used as an accessibility aid for informing talkback users of the result of tapping the view.
Expand Down
1 change: 0 additions & 1 deletion components/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<string name="text_input_example_hint">Message</string>
<string name="text_input_example_text">I need some help with my help to save account. For some reason my account is blocked and I am not sure why. Please help.</string>

<string name="button_content_description">%s, button</string>
<string name="menu_panel_button_no_notification_content_description">%s, %s. %s</string>
<string name="menu_panel_button_new_notification_content_description">%s. New. %s. %s</string>
<string name="menu_panel_button_circle_notification_content_description">%s, new item, %s. %s</string>
Expand Down

0 comments on commit 0131a73

Please sign in to comment.