Skip to content

Commit cc3d04a

Browse files
[a11y] Add content descriptions to room list item indicators (#5236)
* [a11y] Add content descriptions to room list item indicators. These can now be read aloud as 'ongoing call', 'new messages', 'new mentions'. * Add `contentDescription` to `UnreadIndicatorAtom` as an optional value * Make the 'ongoing call', 'new messages', etc. indicators be read aloud before the latest event of the room summary --------- Co-authored-by: ElementBot <[email protected]>
1 parent da03a50 commit cc3d04a

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

features/home/impl/src/main/kotlin/io/element/android/features/home/impl/components/RoomSummaryRow.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import androidx.compose.ui.text.font.FontStyle
3535
import androidx.compose.ui.text.style.TextOverflow
3636
import androidx.compose.ui.tooling.preview.PreviewParameter
3737
import androidx.compose.ui.unit.dp
38+
import androidx.compose.ui.zIndex
3839
import io.element.android.compound.theme.ElementTheme
3940
import io.element.android.compound.tokens.generated.CompoundIcons
4041
import io.element.android.features.home.impl.R
@@ -285,9 +286,13 @@ private fun MessagePreviewAndIndicatorRow(
285286
maxLines = 2,
286287
overflow = TextOverflow.Ellipsis
287288
)
289+
288290
// Call and unread
289291
Row(
290-
modifier = Modifier.height(16.dp),
292+
modifier = Modifier
293+
.height(16.dp)
294+
// Used to force this line to be read aloud earlier than the latest event when using Talkback
295+
.zIndex(-1f),
291296
horizontalArrangement = Arrangement.spacedBy(8.dp),
292297
verticalAlignment = Alignment.CenterVertically,
293298
) {
@@ -303,8 +308,10 @@ private fun MessagePreviewAndIndicatorRow(
303308
MentionIndicatorAtom()
304309
}
305310
if (room.hasNewContent) {
311+
val contentDescription = stringResource(CommonStrings.a11y_notifications_new_messages)
306312
UnreadIndicatorAtom(
307-
color = tint
313+
color = tint,
314+
contentDescription = contentDescription,
308315
)
309316
}
310317
}
@@ -371,7 +378,7 @@ private fun OnGoingCallIcon(
371378
Icon(
372379
modifier = Modifier.size(16.dp),
373380
imageVector = CompoundIcons.VideoCallSolid(),
374-
contentDescription = null,
381+
contentDescription = stringResource(CommonStrings.a11y_notifications_ongoing_call),
375382
tint = color,
376383
)
377384
}
@@ -380,7 +387,7 @@ private fun OnGoingCallIcon(
380387
private fun NotificationOffIndicatorAtom() {
381388
Icon(
382389
modifier = Modifier.size(16.dp),
383-
contentDescription = null,
390+
contentDescription = stringResource(CommonStrings.a11y_notifications_muted),
384391
imageVector = CompoundIcons.NotificationsOffSolid(),
385392
tint = ElementTheme.colors.iconQuaternary,
386393
)
@@ -390,7 +397,7 @@ private fun NotificationOffIndicatorAtom() {
390397
private fun MentionIndicatorAtom() {
391398
Icon(
392399
modifier = Modifier.size(16.dp),
393-
contentDescription = null,
400+
contentDescription = stringResource(CommonStrings.a11y_notifications_new_mentions),
394401
imageVector = CompoundIcons.Mention(),
395402
tint = ElementTheme.colors.unreadIndicator,
396403
)

libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/atoms/UnreadIndicatorAtom.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import androidx.compose.runtime.Composable
1515
import androidx.compose.ui.Modifier
1616
import androidx.compose.ui.draw.clip
1717
import androidx.compose.ui.graphics.Color
18+
import androidx.compose.ui.semantics.contentDescription
19+
import androidx.compose.ui.semantics.semantics
1820
import androidx.compose.ui.unit.Dp
1921
import androidx.compose.ui.unit.dp
2022
import io.element.android.compound.theme.ElementTheme
@@ -28,9 +30,13 @@ fun UnreadIndicatorAtom(
2830
size: Dp = 12.dp,
2931
color: Color = ElementTheme.colors.unreadIndicator,
3032
isVisible: Boolean = true,
33+
contentDescription: String? = null,
3134
) {
3235
Box(
3336
modifier = modifier
37+
.semantics {
38+
contentDescription?.let { this.contentDescription = it }
39+
}
3440
.size(size)
3541
.clip(CircleShape)
3642
.background(if (isVisible) color else Color.Transparent)
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)