From 0131a73c5d9f530abdc09c17c550a007cc870ba9 Mon Sep 17 00:00:00 2001
From: Emma Atkins <68222696+emmaatkins@users.noreply.github.com>
Date: Mon, 20 May 2024 11:09:18 +0100
Subject: [PATCH] HMA-7136 ViewExt (#168)
* HMA-7136 role description
* changelog
* HMA-7136 default parameter
* HMA-7136 example
* HMA-7136 button accessibility updated
* HMA-7136 unused string
---
components/CHANGELOG.md | 4 ++++
.../main/java/uk/gov/hmrc/components/extensions/ViewExt.kt | 5 ++++-
.../gov/hmrc/components/organism/summary/SummaryRowView.kt | 5 +++--
components/src/main/res/values/strings.xml | 1 -
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/components/CHANGELOG.md b/components/CHANGELOG.md
index f3943216..e214ceed 100644
--- a/components/CHANGELOG.md
+++ b/components/CHANGELOG.md
@@ -16,6 +16,10 @@ Allowed headings:
## [Unreleased]
+### Added
+
+* Added role description option in `ViewExt`
+
## [4.11.1] - 2024-04-26Z
### Fixed
diff --git a/components/src/main/java/uk/gov/hmrc/components/extensions/ViewExt.kt b/components/src/main/java/uk/gov/hmrc/components/extensions/ViewExt.kt
index 26aa6e3e..833d1003 100644
--- a/components/src/main/java/uk/gov/hmrc/components/extensions/ViewExt.kt
+++ b/components/src/main/java/uk/gov/hmrc/components/extensions/ViewExt.kt
@@ -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() {
@@ -34,6 +34,9 @@ fun View.setAccessibilityMessage(message: CharSequence) {
message
)
info.addAction(customClick)
+ if (!className.isNullOrEmpty()) {
+ info.roleDescription = className
+ }
}
}
)
diff --git a/components/src/main/java/uk/gov/hmrc/components/organism/summary/SummaryRowView.kt b/components/src/main/java/uk/gov/hmrc/components/organism/summary/SummaryRowView.kt
index 682851fe..b127a336 100644
--- a/components/src/main/java/uk/gov/hmrc/components/organism/summary/SummaryRowView.kt
+++ b/components/src/main/java/uk/gov/hmrc/components/organism/summary/SummaryRowView.kt
@@ -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
@@ -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.
diff --git a/components/src/main/res/values/strings.xml b/components/src/main/res/values/strings.xml
index d61bd16d..d2a294a8 100644
--- a/components/src/main/res/values/strings.xml
+++ b/components/src/main/res/values/strings.xml
@@ -19,7 +19,6 @@
Message
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.
- %s, button
%s, %s. %s
%s. New. %s. %s
%s, new item, %s. %s