Expose formatting toggle state to accessibility services
FormattingOption used clearAndSetSemantics with only a contentDescription, so the Bold/Italic/Underline toggle buttons never exposed whether they were currently active to TalkBack. Add a stateDescription reflecting the selected/unselected state alongside the existing contentDescription. New a11y_active / a11y_inactive strings added to temporary.xml for Localazy import.
This commit is contained in:
+12
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user