Skip to content

Commit

Permalink
Merge pull request #1845 from vector-im/feature/bma/sendingStateA11y
Browse files Browse the repository at this point in the history
Content description: add for sending state and fix other issues.
  • Loading branch information
bmarty authored Nov 22, 2023
2 parents bc5c02c + 0114d97 commit 68c4f1e
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun RoomPrivacyOption(
Icon(
modifier = Modifier.padding(horizontal = 8.dp),
resourceId = roomPrivacyItem.icon,
contentDescription = "",
contentDescription = null,
tint = MaterialTheme.colorScheme.secondary,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ private fun PinUnlockHeader(
.size(32.dp),
tint = ElementTheme.colors.iconPrimary,
imageVector = Icons.Filled.Lock,
contentDescription = "",
contentDescription = null,
)
}
Spacer(modifier = Modifier.height(16.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.PreviewParameter
Expand Down Expand Up @@ -382,7 +384,7 @@ private fun EmojiReactionsRow(
) {
Icon(
resourceId = CommonDrawables.ic_add_reaction,
contentDescription = "Emojis",
contentDescription = stringResource(id = CommonStrings.a11y_react_with_other_emojis),
tint = MaterialTheme.colorScheme.secondary,
modifier = Modifier
.size(24.dp)
Expand All @@ -409,11 +411,18 @@ private fun EmojiButton(
} else {
Color.Transparent
}
val description = if (isHighlighted) {
stringResource(id = CommonStrings.a11y_remove_reaction_with, emoji)
} else {
stringResource(id = CommonStrings.a11y_react_with, emoji)
}
Box(
modifier = modifier
.size(48.dp)
.background(backgroundColor, CircleShape),

.background(backgroundColor, CircleShape)
.clearAndSetSemantics {
contentDescription = description
},
contentAlignment = Alignment.Center
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
Expand All @@ -69,6 +70,7 @@ import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.libraries.designsystem.utils.KeepScreenOn
import io.element.android.libraries.designsystem.utils.OnLifecycleEvent
import io.element.android.libraries.theme.ElementTheme
import io.element.android.libraries.ui.strings.CommonStrings
import me.saket.telephoto.zoomable.ZoomSpec
import me.saket.telephoto.zoomable.ZoomableState
import me.saket.telephoto.zoomable.coil.ZoomableAsyncImage
Expand Down Expand Up @@ -135,7 +137,7 @@ private fun MediaImageView(
modifier = modifier.fillMaxSize(),
state = zoomableImageState,
model = localMedia?.uri,
contentDescription = "Image",
contentDescription = stringResource(id = CommonStrings.common_image),
contentScale = ContentScale.Fit,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.text.roundToPx
import io.element.android.libraries.designsystem.text.toDp
import io.element.android.libraries.ui.strings.CommonStrings
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import me.saket.telephoto.zoomable.zoomable
Expand Down Expand Up @@ -98,7 +100,7 @@ private fun PdfPageView(
is PdfPage.State.Loaded -> {
Image(
bitmap = state.bitmap.asImageBitmap(),
contentDescription = "Page ${pdfPage.pageIndex}",
contentDescription = stringResource(id = CommonStrings.a11y_page_n, pdfPage.pageIndex),
contentScale = ContentScale.FillWidth,
modifier = modifier.fillMaxWidth()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import io.element.android.features.messages.impl.R
Expand All @@ -78,6 +79,7 @@ import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.libraries.matrix.api.core.EventId
import io.element.android.libraries.matrix.api.core.UserId
import io.element.android.libraries.theme.ElementTheme
import io.element.android.libraries.ui.strings.CommonStrings
import kotlinx.coroutines.launch

@Composable
Expand Down Expand Up @@ -350,7 +352,7 @@ private fun JumpToBottomButton(
.size(24.dp)
.rotate(90f),
resourceId = CommonDrawables.ic_compound_arrow_right,
contentDescription = "",
contentDescription = stringResource(id = CommonStrings.a11y_jump_to_bottom)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import androidx.compose.ui.unit.dp
import io.element.android.features.messages.impl.timeline.model.TimelineItem
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemTextBasedContent
import io.element.android.libraries.core.bool.orFalse
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
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.designsystem.theme.components.Text
import io.element.android.libraries.designsystem.utils.CommonDrawables
Expand Down Expand Up @@ -91,7 +91,7 @@ fun TimelineEventTimestampView(
Spacer(modifier = Modifier.width(2.dp))
Icon(
resourceId = CommonDrawables.ic_compound_error,
contentDescription = "Error sending message",
contentDescription = stringResource(id = CommonStrings.common_sending_failed),
tint = tint,
modifier = Modifier.size(15.dp, 18.dp),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.unit.dp
import io.element.android.emojibasebindings.Emoji
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.theme.ElementTheme
import io.element.android.libraries.ui.strings.CommonStrings

@Composable
fun EmojiItem(
Expand All @@ -49,7 +53,11 @@ fun EmojiItem(
} else {
Color.Transparent
}

val description = if (isSelected) {
stringResource(id = CommonStrings.a11y_remove_reaction_with, item.unicode)
} else {
stringResource(id = CommonStrings.a11y_react_with, item.unicode)
}
Box(
modifier = modifier
.size(40.dp)
Expand All @@ -59,7 +67,10 @@ fun EmojiItem(
onClick = { onEmojiSelected(item) },
indication = rememberRipple(bounded = false, radius = 20.dp),
interactionSource = remember { MutableInteractionSource() }
),
)
.clearAndSetSemantics {
contentDescription = description
},
contentAlignment = Alignment.Center
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fun TimelineItemFileView(
) {
Icon(
resourceId = CommonDrawables.ic_attachment,
contentDescription = "OpenFile",
contentDescription = null,
tint = ElementTheme.materialColors.primary,
modifier = Modifier
.size(16.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewParameter
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemVideoContent
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemVideoContentProvider
Expand All @@ -34,6 +35,7 @@ import io.element.android.libraries.designsystem.modifiers.roundedBackground
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.matrix.ui.media.MediaRequestData
import io.element.android.libraries.ui.strings.CommonStrings

@Composable
fun TimelineItemVideoView(
Expand All @@ -56,7 +58,7 @@ fun TimelineItemVideoView(
) {
Image(
Icons.Default.PlayArrow,
contentDescription = "Play",
contentDescription = stringResource(id = CommonStrings.a11y_play),
colorFilter = ColorFilter.tint(Color.White),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
Expand Down Expand Up @@ -69,7 +69,9 @@ fun TimelineItemReadReceiptView(
receipts = state.receipts,
modifier = Modifier
.clip(RoundedCornerShape(4.dp))
.clickable { onReadReceiptsClicked() }
.clickable {
onReadReceiptsClicked()
}
.padding(2.dp)
)
}
Expand All @@ -80,7 +82,7 @@ fun TimelineItemReadReceiptView(
Icon(
modifier = Modifier.padding(2.dp),
resourceId = CommonDrawables.ic_sending,
contentDescription = null,
contentDescription = stringResource(id = CommonStrings.common_sending),
tint = ElementTheme.colors.iconSecondary
)
}
Expand All @@ -96,7 +98,7 @@ fun TimelineItemReadReceiptView(
Icon(
modifier = Modifier.padding(2.dp),
resourceId = CommonDrawables.ic_sent,
contentDescription = null,
contentDescription = stringResource(id = CommonStrings.common_sent),
tint = ElementTheme.colors.iconSecondary
)
}
Expand Down Expand Up @@ -139,7 +141,7 @@ private fun ReadReceiptsAvatars(
Row(
modifier = modifier
.clearAndSetSemantics {
stateDescription = receiptDescription
contentDescription = receiptDescription
},
horizontalArrangement = Arrangement.spacedBy(4.dp - avatarStrokeSize),
verticalAlignment = Alignment.CenterVertically,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fun TimelineEncryptedHistoryBannerView(
Icon(
modifier = Modifier.size(20.dp),
resourceId = CommonDrawables.ic_compound_info_solid,
contentDescription = "Info",
contentDescription = null,
tint = ElementTheme.colors.iconInfoPrimary
)
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fun RoundedIconAtom(
tint = tint,
resourceId = resourceId,
imageVector = imageVector,
contentDescription = "",
contentDescription = null,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun BackButton(
@Composable
internal fun BackButtonPreview() = ElementThemedPreview {
Column {
BackButton(onClick = { }, enabled = true, contentDescription = "Back")
BackButton(onClick = { }, enabled = false, contentDescription = "Back")
BackButton(onClick = { }, enabled = true)
BackButton(onClick = { }, enabled = false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun PreferenceIcon(
Icon(
imageVector = icon,
resourceId = iconResourceId,
contentDescription = "",
contentDescription = null,
tint = tintColor ?: enabled.toSecondaryEnabledColor(),
modifier = Modifier
.padding(end = 16.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal fun FloatingActionButtonPreview() =
private fun ContentToPreview() {
Box(modifier = Modifier.padding(8.dp)) {
FloatingActionButton(onClick = {}) {
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = "")
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = null)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ internal fun IconImageVectorPreview() =

@Composable
private fun ContentToPreview() {
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = "")
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = null)
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ private fun ContentToPreview() {
CompositionLocalProvider(LocalContentColor provides ElementTheme.colors.iconPrimary) {
Row {
IconButton(onClick = {}) {
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = "")
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = null)
}
IconButton(enabled = false, onClick = {}) {
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = "")
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = null)
}
}
}
CompositionLocalProvider(LocalContentColor provides ElementTheme.colors.iconSecondary) {
Row {
IconButton(onClick = {}) {
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = "")
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = null)
}
IconButton(enabled = false, onClick = {}) {
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = "")
Icon(resourceId = CommonDrawables.ic_compound_close, contentDescription = null)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private fun ContentToPreview() {
val icon: @Composable () -> Unit = {
Icon(
imageVector = if (checked) Icons.Default.CheckCircle else Icons.Default.RadioButtonUnchecked,
contentDescription = "IconToggleButton"
contentDescription = null
)
}
IconToggleButton(checked = checked, enabled = true, onCheckedChange = { checked = !checked }, content = icon)
Expand All @@ -79,7 +79,7 @@ private fun ContentToPreview() {
val icon: @Composable () -> Unit = {
Icon(
imageVector = if (!checked) Icons.Default.CheckCircle else Icons.Default.RadioButtonUnchecked,
contentDescription = "IconToggleButton"
contentDescription = null
)
}
IconToggleButton(checked = !checked, enabled = true, onCheckedChange = { checked = !checked }, content = icon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ internal fun MenuPreview() {
for (i in 0..5) {
val leadingIcon: @Composable (() -> Unit)? = if (i in 2..3) {
@Composable {
Icon(Icons.Filled.Favorite, contentDescription = "Favorite")
Icon(
imageVector = Icons.Filled.Favorite,
contentDescription = null
)
}
} else {
null
Expand All @@ -53,7 +56,7 @@ internal fun MenuPreview() {
@Composable {
Icon(
resourceId = CommonDrawables.ic_compound_chevron_right,
contentDescription = "Favorite",
contentDescription = null,
)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fun EditableAvatarView(
Icon(
modifier = Modifier.size(16.dp),
resourceId = CommonDrawables.ic_edit,
contentDescription = "",
contentDescription = null,
tint = MaterialTheme.colorScheme.onPrimary,
)
}
Expand Down
Loading

0 comments on commit 68c4f1e

Please sign in to comment.