mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Merge pull request #7227 from unclejay80/a11y/formatting-option-state-description
Expose formatting toggle state to TalkBack
This commit is contained in:
+12
@@ -23,14 +23,17 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
import androidx.compose.ui.semantics.stateDescription
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||||
|
import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun FormattingOption(
|
internal fun FormattingOption(
|
||||||
@@ -52,6 +55,8 @@ internal fun FormattingOption(
|
|||||||
FormattingOptionState.Default -> ElementTheme.colors.iconSecondary
|
FormattingOptionState.Default -> ElementTheme.colors.iconSecondary
|
||||||
FormattingOptionState.Disabled -> ElementTheme.colors.iconDisabled
|
FormattingOptionState.Disabled -> ElementTheme.colors.iconDisabled
|
||||||
}
|
}
|
||||||
|
val activeStateDescription = stringResource(CommonStrings.a11y_active)
|
||||||
|
val inactiveStateDescription = stringResource(CommonStrings.a11y_inactive)
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.clickable(
|
.clickable(
|
||||||
@@ -77,6 +82,13 @@ internal fun FormattingOption(
|
|||||||
)
|
)
|
||||||
.clearAndSetSemantics {
|
.clearAndSetSemantics {
|
||||||
this.contentDescription = contentDescription
|
this.contentDescription = contentDescription
|
||||||
|
if (toggleable) {
|
||||||
|
this.stateDescription = if (state == FormattingOptionState.Selected) {
|
||||||
|
activeStateDescription
|
||||||
|
} else {
|
||||||
|
inactiveStateDescription
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
|
|||||||
@@ -10,4 +10,6 @@
|
|||||||
<string name="a11y_jump_to_unread_messages">"Jump to first unread message"</string>
|
<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_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="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>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user