Skip to content

Commit 62b2bba

Browse files
committed
[a11y] Group device information and spell out the deviceId
1 parent 58cdd9b commit 62b2bba

File tree

2 files changed

+21
-1
lines changed
  • features/verifysession/impl/src/main/kotlin/io/element/android/features/verifysession/impl/incoming/ui
  • libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/molecules

2 files changed

+21
-1
lines changed

features/verifysession/impl/src/main/kotlin/io/element/android/features/verifysession/impl/incoming/ui/SessionDetailsView.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.compose.runtime.Composable
1818
import androidx.compose.ui.Alignment
1919
import androidx.compose.ui.Modifier
2020
import androidx.compose.ui.res.stringResource
21+
import androidx.compose.ui.semantics.semantics
2122
import androidx.compose.ui.unit.dp
2223
import io.element.android.compound.theme.ElementTheme
2324
import io.element.android.features.verifysession.impl.R
@@ -46,7 +47,8 @@ fun SessionDetailsView(
4647
color = ElementTheme.colors.borderDisabled,
4748
shape = RoundedCornerShape(8.dp)
4849
)
49-
.padding(24.dp),
50+
.padding(24.dp)
51+
.semantics(mergeDescendants = true) {},
5052
verticalArrangement = Arrangement.spacedBy(12.dp),
5153
) {
5254
Row(
@@ -76,6 +78,7 @@ fun SessionDetailsView(
7678
label = stringResource(CommonStrings.common_device_id),
7779
text = deviceId.value,
7880
modifier = Modifier.weight(5f),
81+
spellText = true,
7982
)
8083
}
8184
}

libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/molecules/TextWithLabelMolecule.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,26 @@ package io.element.android.libraries.designsystem.atomic.molecules
1010
import androidx.compose.foundation.layout.Column
1111
import androidx.compose.runtime.Composable
1212
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.semantics.contentDescription
14+
import androidx.compose.ui.semantics.semantics
1315
import io.element.android.compound.theme.ElementTheme
1416
import io.element.android.libraries.designsystem.theme.components.Text
1517

18+
/**
19+
* Display a label and a text in a column.
20+
* @param label the label to display
21+
* @param text the text to display
22+
* @param modifier the modifier to apply to this layout
23+
* @param spellText if true, the text will be spelled out in the content description for accessibility.
24+
* Useful for deviceId for instance, that the screen reader will read as a list of letters instead of trying to read a
25+
* word of random characters.
26+
*/
1627
@Composable
1728
fun TextWithLabelMolecule(
1829
label: String,
1930
text: String,
2031
modifier: Modifier = Modifier,
32+
spellText: Boolean = false,
2133
) {
2234
Column(modifier = modifier) {
2335
Text(
@@ -26,6 +38,11 @@ fun TextWithLabelMolecule(
2638
color = ElementTheme.colors.textSecondary,
2739
)
2840
Text(
41+
modifier = Modifier.semantics {
42+
if (spellText) {
43+
contentDescription = text.toList().joinToString()
44+
}
45+
},
2946
text = text,
3047
style = ElementTheme.typography.fontBodyMdRegular,
3148
color = ElementTheme.colors.textPrimary,

0 commit comments

Comments
 (0)