Merge pull request #7227 from unclejay80/a11y/formatting-option-state-description

Expose formatting toggle state to TalkBack
This commit is contained in:
Benoit Marty
2026-07-17 10:00:31 +02:00
committed by GitHub
2 changed files with 14 additions and 0 deletions
@@ -23,14 +23,17 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.ui.strings.CommonStrings
@Composable
internal fun FormattingOption(
@@ -52,6 +55,8 @@ internal fun FormattingOption(
FormattingOptionState.Default -> ElementTheme.colors.iconSecondary
FormattingOptionState.Disabled -> ElementTheme.colors.iconDisabled
}
val activeStateDescription = stringResource(CommonStrings.a11y_active)
val inactiveStateDescription = stringResource(CommonStrings.a11y_inactive)
Box(
modifier = modifier
.clickable(
@@ -77,6 +82,13 @@ internal fun FormattingOption(
)
.clearAndSetSemantics {
this.contentDescription = contentDescription
if (toggleable) {
this.stateDescription = if (state == FormattingOptionState.Selected) {
activeStateDescription
} else {
inactiveStateDescription
}
}
}
) {
Box(
@@ -10,4 +10,6 @@
<string name="a11y_jump_to_unread_messages">"Jump to first unread message"</string>
<string name="screen_local_network_opt_in_title">Allow access to local network</string>
<string name="screen_local_network_opt_in_subtitle">Your homeserver is on your local network. To connect, Element needs permission to reach other devices on this network.</string>
<string name="a11y_active">Active</string>
<string name="a11y_inactive">Inactive</string>
</resources>