Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Accessibility strings issues #WPB-9827 #3614

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.DpOffset
Expand Down Expand Up @@ -274,12 +275,15 @@ private fun DropdownItem(
leadingIcon = leadingCompose,
trailingIcon = {
if (isSelected) {
WireCheckIcon(R.string.content_description_selected_label)
WireCheckIcon(R.string.content_description_empty)
}
},
onClick = onClick,
modifier = Modifier
.semantics { onClick(selectLabel) { false } }
.semantics {
onClick(selectLabel) { false }
if (isSelected) selected = true
}
.background(
color = if (isSelected) MaterialTheme.wireColorScheme.secondaryButtonSelected
else MaterialTheme.wireColorScheme.tertiaryButtonEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import com.wire.android.R
Expand All @@ -48,6 +50,7 @@ import io.github.esentsov.PackagePrivate
@Composable
fun SelectableMenuBottomSheetItem(
title: String,
modifier: Modifier = Modifier,
titleColor: Color? = null,
titleStyleUnselected: TextStyle = MaterialTheme.wireTypography.body02,
titleStyleSelected: TextStyle = MaterialTheme.wireTypography.body02,
Expand All @@ -58,12 +61,13 @@ fun SelectableMenuBottomSheetItem(
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
modifier = modifier
.wrapContentHeight()
.wrapContentWidth()
.defaultMinSize(minHeight = dimensions().spacing48x)
.let { if (isSelectedItem(state)) it.background(MaterialTheme.wireColorScheme.secondaryButtonSelected) else it }
.clickable(onItemClick)
.semantics { if (isSelectedItem(state)) selected = true }
.padding(vertical = dimensions().spacing12x, horizontal = dimensions().spacing16x)
) {
icon()
Expand Down Expand Up @@ -92,7 +96,7 @@ fun SelectableMenuBottomSheetItem(
.padding(start = dimensions().spacing8x)
.align(Alignment.CenterVertically)
) {
WireCheckIcon(R.string.label_selected)
WireCheckIcon(contentDescription = R.string.content_description_empty)
}
}
}
Expand All @@ -102,11 +106,11 @@ fun SelectableMenuBottomSheetItem(
@Composable
fun MenuItemHeading(
title: String,
modifier: Modifier = Modifier,
titleStyleUnselected: TextStyle = MaterialTheme.wireTypography.body02,
titleStyleSelected: TextStyle = MaterialTheme.wireTypography.body02,
state: RichMenuItemState = RichMenuItemState.DEFAULT,
color: Color? = null,
modifier: Modifier = Modifier
color: Color? = null
) {
Text(
style = if (isSelectedItem(state)) titleStyleSelected else titleStyleUnselected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,48 @@ internal fun MutingOptionsSheetContent(
),
menuItems = listOf(
{
val state = if (mutingConversationState == MutedConversationStatus.AllAllowed) RichMenuItemState.SELECTED
else RichMenuItemState.DEFAULT
SelectableMenuBottomSheetItem(
title = stringResource(id = R.string.muting_option_all_allowed_title),
subLine = stringResource(id = R.string.muting_option_all_allowed_text),
onItemClick = Clickable(onClickDescription = stringResource(id = R.string.content_description_select_label)) {
onItemClick = Clickable(
enabled = state == RichMenuItemState.DEFAULT,
onClickDescription = stringResource(id = R.string.content_description_select_label)
) {
onMuteConversation(MutedConversationStatus.AllAllowed)
},
state = if (mutingConversationState == MutedConversationStatus.AllAllowed) RichMenuItemState.SELECTED
else RichMenuItemState.DEFAULT
state = state
)
},
{
val state = if (mutingConversationState == MutedConversationStatus.OnlyMentionsAndRepliesAllowed) RichMenuItemState.SELECTED
else RichMenuItemState.DEFAULT
SelectableMenuBottomSheetItem(
title = stringResource(id = R.string.muting_option_only_mentions_title),
subLine = stringResource(id = R.string.muting_option_only_mentions_text),
onItemClick = Clickable(onClickDescription = stringResource(id = R.string.content_description_select_label)) {
onItemClick = Clickable(
enabled = state == RichMenuItemState.DEFAULT,
onClickDescription = stringResource(id = R.string.content_description_select_label)
) {
onMuteConversation(MutedConversationStatus.OnlyMentionsAndRepliesAllowed)
},
state = if (mutingConversationState == MutedConversationStatus.OnlyMentionsAndRepliesAllowed)
RichMenuItemState.SELECTED else RichMenuItemState.DEFAULT
state = state
)
},
{
val state = if (mutingConversationState == MutedConversationStatus.AllMuted) RichMenuItemState.SELECTED
else RichMenuItemState.DEFAULT
SelectableMenuBottomSheetItem(
title = stringResource(id = R.string.muting_option_all_muted_title),
subLine = stringResource(id = R.string.muting_option_all_muted_text),
onItemClick = Clickable(onClickDescription = stringResource(id = R.string.content_description_select_label)) {
onItemClick = Clickable(
enabled = state == RichMenuItemState.DEFAULT,
onClickDescription = stringResource(id = R.string.content_description_select_label)
) {
onMuteConversation(MutedConversationStatus.AllMuted)
},
state = if (mutingConversationState == MutedConversationStatus.AllMuted) RichMenuItemState.SELECTED
else RichMenuItemState.DEFAULT
state = state
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ private fun ConversationScreenTopAppBarContent(
// spacing between navigation icon button and avatar according to the designs
.offset(x = -dimensions().spacing4x)
.clip(RoundedCornerShape(MaterialTheme.wireDimensions.buttonCornerSize))
.clickable(onClick = onDropDownClick, enabled = isDropDownEnabled && isInteractionEnabled)

.clickable(
onClick = onDropDownClick,
enabled = isDropDownEnabled && isInteractionEnabled,
onClickLabel = stringResource(R.string.content_description_conversation_open_details_label)
)
) {
val conversationAvatar: ConversationAvatar = conversationInfoViewState.conversationAvatar
Avatar(conversationAvatar, conversationInfoViewState)
Expand All @@ -148,7 +151,7 @@ private fun ConversationScreenTopAppBarContent(
if (isDropDownEnabled && isInteractionEnabled) {
Icon(
painter = painterResource(id = R.drawable.ic_dropdown_icon),
contentDescription = stringResource(R.string.content_description_drop_down_icon)
contentDescription = null
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import com.wire.android.R
import com.wire.android.appLogger
import com.wire.android.model.Clickable
import com.wire.android.model.ItemActionType
Expand Down Expand Up @@ -91,7 +92,7 @@ fun InternalContactSearchResultItem(
.wrapContentWidth()
.padding(end = dimensions().spacing4x)
) {
ArrowRightIcon(Modifier.align(Alignment.TopEnd))
ArrowRightIcon(Modifier.align(Alignment.TopEnd), R.string.content_description_empty)
}
} else if (actionType.checkable) {
WireCheckbox(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ fun UserProfileInfo(
label = "UserProfileInfoAvatar"
) { (userAvatarData, showPlaceholderIfNoAsset) ->
val onAvatarClickDescription = stringResource(R.string.content_description_change_it_label)
val contentDescription = if (editableState is EditableState.IsEditable) {
stringResource(R.string.content_description_self_profile_avatar)
} else {
null
}
UserProfileAvatar(
size = dimensions().avatarDefaultBigSize,
temporaryUserBorderWidth = dimensions().avatarBigTemporaryUserBorderWidth,
Expand All @@ -162,7 +167,7 @@ fun UserProfileInfo(
withCrossfadeAnimation = true,
type = expiresAt?.let { UserProfileAvatarType.WithIndicators.TemporaryUser(expiresAt) }
?: UserProfileAvatarType.WithoutIndicators,
contentDescription = stringResource(R.string.content_description_self_profile_avatar)
contentDescription = contentDescription
)
}
[email protected](visible = isLoading) {
Expand Down Expand Up @@ -237,7 +242,11 @@ fun UserProfileInfo(
color = MaterialTheme.wireColorScheme.labelText,
modifier = Modifier.semantics(mergeDescendants = true) { contentDescription = usernameDescription }
)
UserBadge(membership, connection, topPadding = dimensions().spacing8x)
UserBadge(
membership = membership,
connectionState = connection,
topPadding = dimensions().spacing8x
)
}

Column(
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<string name="content_description_conversation_send_gif">Send GIF button</string>
<string name="content_description_conversation_mention_someone">Mention someone</string>
<string name="content_description_conversation_back_btn">Go back to conversation list</string>
<string name="content_description_conversation_open_details_label">open conversation details</string>
<string name="content_description_new_conversation">Search for people or create a new group</string>
<string name="content_description_back_button">Back button</string>
<string name="content_description_send_button">Send</string>
Expand Down
Loading