Skip to content

Commit c3a4d64

Browse files
authored
Merge pull request #6827 from element-hq/feature/bma/a11y/roomNameHeading
[a11y] Improve accessibility of screen headers.
2 parents 0c3c9f4 + df9a3fe commit c3a4d64

7 files changed

Lines changed: 55 additions & 25 deletions

File tree

features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ private fun JoinRoomTopBar(
609609
val roundedCornerShape = RoundedCornerShape(8.dp)
610610
val titleModifier = Modifier
611611
.clip(roundedCornerShape)
612+
.semantics { heading() }
612613
if (contentState.name != null) {
613614
Row(
614615
modifier = titleModifier,
@@ -621,10 +622,7 @@ private fun JoinRoomTopBar(
621622
)
622623
Text(
623624
modifier = Modifier
624-
.padding(horizontal = 8.dp)
625-
.semantics {
626-
heading()
627-
},
625+
.padding(horizontal = 8.dp),
628626
text = contentState.name,
629627
style = ElementTheme.typography.fontBodyLgMedium,
630628
maxLines = 1,

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/threads/list/ThreadsListView.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ import androidx.compose.runtime.remember
3131
import androidx.compose.ui.Alignment
3232
import androidx.compose.ui.Modifier
3333
import androidx.compose.ui.res.stringResource
34+
import androidx.compose.ui.semantics.clearAndSetSemantics
35+
import androidx.compose.ui.semantics.contentDescription
36+
import androidx.compose.ui.semantics.heading
3437
import androidx.compose.ui.text.style.TextOverflow
3538
import androidx.compose.ui.unit.dp
3639
import io.element.android.compound.theme.ElementTheme
@@ -79,7 +82,18 @@ fun ThreadsListView(
7982
topBar = {
8083
TopAppBar(
8184
title = {
82-
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
85+
val description = stringResource(
86+
CommonStrings.a11y_threads_in_room,
87+
state.roomName,
88+
)
89+
Row(
90+
horizontalArrangement = Arrangement.spacedBy(8.dp),
91+
verticalAlignment = Alignment.CenterVertically,
92+
modifier = Modifier.clearAndSetSemantics {
93+
heading()
94+
contentDescription = description
95+
},
96+
) {
8397
Avatar(
8498
avatarData = AvatarData(
8599
id = state.roomId.value,

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/topbars/MessagesViewTopBar.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ internal fun MessagesViewTopBar(
8080
Row(
8181
modifier = Modifier
8282
.clip(roundedCornerShape)
83-
.clickable { onRoomDetailsClick() },
83+
.clickable { onRoomDetailsClick() }
84+
.semantics { heading() },
8485
horizontalArrangement = Arrangement.spacedBy(4.dp),
8586
verticalAlignment = Alignment.CenterVertically,
8687
) {
@@ -158,10 +159,7 @@ private fun RoomAvatarAndNameRow(
158159
)
159160
Text(
160161
modifier = Modifier
161-
.padding(start = 8.dp)
162-
.semantics {
163-
heading()
164-
},
162+
.padding(start = 8.dp),
165163
text = roomName ?: stringResource(CommonStrings.common_no_room_name),
166164
style = ElementTheme.typography.fontBodyLgMedium,
167165
fontStyle = FontStyle.Italic.takeIf { roomName == null },

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/topbars/ThreadTopBar.kt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import androidx.compose.runtime.Composable
1717
import androidx.compose.ui.Alignment
1818
import androidx.compose.ui.Modifier
1919
import androidx.compose.ui.res.stringResource
20+
import androidx.compose.ui.semantics.clearAndSetSemantics
21+
import androidx.compose.ui.semantics.contentDescription
2022
import androidx.compose.ui.semantics.heading
21-
import androidx.compose.ui.semantics.semantics
2223
import androidx.compose.ui.text.font.FontStyle
2324
import androidx.compose.ui.text.style.TextOverflow
2425
import androidx.compose.ui.unit.dp
@@ -58,7 +59,18 @@ internal fun ThreadTopBar(
5859
BackButton(onClick = onBackClick)
5960
},
6061
title = {
61-
Row(verticalAlignment = Alignment.CenterVertically) {
62+
val name = roomName ?: stringResource(CommonStrings.common_no_room_name)
63+
val description = stringResource(
64+
CommonStrings.a11y_thread_in_room,
65+
name,
66+
)
67+
Row(
68+
verticalAlignment = Alignment.CenterVertically,
69+
modifier = Modifier.clearAndSetSemantics {
70+
heading()
71+
contentDescription = description
72+
},
73+
) {
6274
Avatar(
6375
avatarData = roomAvatarData,
6476
avatarType = AvatarType.Room(
@@ -69,17 +81,14 @@ internal fun ThreadTopBar(
6981
Column(
7082
modifier = Modifier
7183
.fillMaxWidth()
72-
.padding(horizontal = 8.dp)
73-
.semantics {
74-
heading()
75-
},
84+
.padding(horizontal = 8.dp),
7685
) {
7786
Text(
7887
text = stringResource(CommonStrings.common_thread),
7988
style = ElementTheme.typography.fontBodyLgMedium,
8089
)
8190
Text(
82-
text = roomName ?: stringResource(CommonStrings.common_no_room_name),
91+
text = name,
8392
style = ElementTheme.typography.fontBodySmRegular,
8493
fontStyle = FontStyle.Italic.takeIf { roomName == null },
8594
color = ElementTheme.colors.textSecondary,

features/space/impl/src/main/kotlin/io/element/android/features/space/impl/root/SpaceView.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ private fun EmptySpaceView(
354354
title = stringResource(R.string.screen_space_empty_state_title),
355355
subTitle = null,
356356
iconStyle = BigIcon.Style.Default(vectorIcon = CompoundIcons.Room(), usePrimaryTint = true),
357-
modifier = Modifier.fillMaxWidth()
357+
modifier = Modifier
358+
.fillMaxWidth()
358359
.padding(top = 40.dp, start = 24.dp, end = 24.dp, bottom = 24.dp),
359360
)
360361
ButtonColumnMolecule(
@@ -425,6 +426,7 @@ private fun SpaceViewTopBar(
425426
modifier = Modifier
426427
.clip(roundedCornerShape)
427428
.clickable(enabled = canAccessSpaceSettings, onClick = onSettingsClick)
429+
.semantics { heading() }
428430
)
429431
},
430432
actions = {
@@ -532,6 +534,7 @@ private fun ManageModeTopBar(
532534
Text(
533535
text = pluralStringResource(CommonPlurals.common_selected_count, selectedCount, selectedCount),
534536
style = ElementTheme.typography.fontBodyLgMedium,
537+
modifier = Modifier.semantics { heading() },
535538
)
536539
},
537540
actions = {
@@ -585,10 +588,7 @@ private fun SpaceAvatarAndNameRow(
585588
)
586589
Text(
587590
modifier = Modifier
588-
.padding(horizontal = 8.dp)
589-
.semantics {
590-
heading()
591-
},
591+
.padding(horizontal = 8.dp),
592592
text = name ?: stringResource(CommonStrings.common_no_space_name),
593593
style = ElementTheme.typography.fontBodyLgMedium,
594594
fontStyle = FontStyle.Italic.takeIf { name == null },

libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/viewer/MediaViewerView.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ import androidx.compose.ui.layout.onVisibilityChanged
5555
import androidx.compose.ui.platform.LocalDensity
5656
import androidx.compose.ui.platform.LocalInspectionMode
5757
import androidx.compose.ui.res.stringResource
58+
import androidx.compose.ui.semantics.clearAndSetSemantics
59+
import androidx.compose.ui.semantics.contentDescription
5860
import androidx.compose.ui.semantics.heading
5961
import androidx.compose.ui.semantics.semantics
6062
import androidx.compose.ui.text.style.TextOverflow
@@ -495,14 +497,20 @@ private fun MediaViewerTopBar(
495497
TopAppBar(
496498
title = {
497499
if (senderName != null && dateSent != null) {
500+
val description = stringResource(
501+
CommonStrings.a11y_sent_by_sender_at_date,
502+
senderName,
503+
dateSent,
504+
)
498505
Column(
499506
modifier = Modifier
500507
.fillMaxWidth()
501-
) {
502-
Text(
503-
modifier = Modifier.semantics {
508+
.clearAndSetSemantics {
504509
heading()
510+
contentDescription = description
505511
},
512+
) {
513+
Text(
506514
text = senderName,
507515
style = ElementTheme.typography.fontBodyMdMedium,
508516
color = ElementTheme.colors.textPrimary,

libraries/ui-strings/src/main/res/values/localazy.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@
5050
<string name="a11y_room_avatar">"Room avatar"</string>
5151
<string name="a11y_send_files">"Send files"</string>
5252
<string name="a11y_sender_location">"Sender location"</string>
53+
<string name="a11y_sent_by_sender_at_date">"Sent by %1$s at %2$s"</string>
5354
<string name="a11y_session_verification_time_limited_action_required">"Time limited action required, you have one minute to verify"</string>
5455
<string name="a11y_settings_with_required_action">"Settings, action required"</string>
5556
<string name="a11y_show_password">"Show password"</string>
5657
<string name="a11y_start_call">"Start a call"</string>
5758
<string name="a11y_start_video_call">"Start a video call"</string>
5859
<string name="a11y_start_voice_call">"Start a voice call"</string>
60+
<string name="a11y_thread_in_room">"Thread in %1$s"</string>
61+
<string name="a11y_threads_in_room">"Threads in %1$s"</string>
5962
<string name="a11y_tombstoned_room">"Tombstoned room"</string>
6063
<string name="a11y_user_avatar">"User avatar"</string>
6164
<string name="a11y_user_menu">"User menu"</string>

0 commit comments

Comments
 (0)