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

feat: Add accessibility strings to conversation details [WPB-9784] #3495

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 @@ -146,7 +146,7 @@ private fun RegisterDeviceContent(
WireCenterAlignedTopAppBar(
elevation = dimensions().spacing0x,
title = stringResource(id = R.string.register_device_title),
navigationIconType = NavigationIconType.Close,
navigationIconType = NavigationIconType.Close(),
onNavigationPressed = onBackButtonClicked
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun RemoveDeviceTopBar(elevation: Dp, onBackButtonClicked: () -> Unit) {
WireCenterAlignedTopAppBar(
elevation = elevation,
title = stringResource(R.string.remove_device_title),
navigationIconType = NavigationIconType.Close,
navigationIconType = NavigationIconType.Close(),
onNavigationPressed = onBackButtonClicked
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private fun WelcomeContent(
WireCenterAlignedTopAppBar(
elevation = dimensions().spacing0x,
title = "",
navigationIconType = NavigationIconType.Close,
navigationIconType = NavigationIconType.Close(),
onNavigationPressed = navigateBack
)
} else {
Expand Down
24 changes: 18 additions & 6 deletions app/src/main/kotlin/com/wire/android/ui/common/AppExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package com.wire.android.ui.common

import androidx.compose.foundation.selection.selectable
import android.annotation.SuppressLint
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
Expand All @@ -29,13 +29,17 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.flowWithLifecycle
import com.google.accompanist.placeholder.PlaceholderHighlight
import com.google.accompanist.placeholder.placeholder
import com.google.accompanist.placeholder.shimmer
import com.wire.android.R
import com.wire.android.model.Clickable
import com.wire.android.ui.home.conversations.model.messagetypes.asset.UIAssetMessage
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireDimensions
Expand All @@ -53,13 +57,21 @@ import kotlin.coroutines.EmptyCoroutineContext

// todo try to move as much as we can to common

@SuppressLint("ComposeComposableModifier")
@Composable
fun Modifier.selectableBackground(isSelected: Boolean, onClick: () -> Unit): Modifier =
this.selectable(
selected = isSelected,
fun Modifier.selectableBackground(isSelected: Boolean, onClick: () -> Unit): Modifier {
val onItemClick = Clickable(
enabled = !isSelected,
onClick = onClick,
role = Role.Tab
onClickDescription = stringResource(id = R.string.content_description_select_label)
)
val selectedDescription = stringResource(id = R.string.content_description_selected_label)

return this
.clickable(onItemClick)
.clickableDescriptions(onItemClick)
.semantics { stateDescription = if (isSelected) selectedDescription else "" }
}

@Composable
fun Modifier.shimmerPlaceholder(
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/kotlin/com/wire/android/ui/common/ArrowIcon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import com.wire.android.ui.theme.wireDimensions

@Composable
fun ArrowRightIcon(
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
@StringRes contentDescription: Int = R.string.content_description_right_arrow,
) {
ArrowIcon(
arrowIcon = R.drawable.ic_arrow_right,
contentDescription = R.string.content_description_right_arrow,
contentDescription = contentDescription,
modifier = modifier
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.wire.android.ui.common

import androidx.annotation.StringRes
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.wire.android.R
Expand All @@ -27,13 +28,14 @@ import com.wire.android.ui.common.button.WireSecondaryIconButton
@Composable
fun MoreOptionIcon(
onButtonClicked: () -> Unit,
modifier: Modifier = Modifier,
state: WireButtonState = WireButtonState.Default,
modifier: Modifier = Modifier
@StringRes contentDescription: Int = R.string.content_description_show_more_options
) {
WireSecondaryIconButton(
onButtonClicked = onButtonClicked,
iconResource = R.drawable.ic_more,
contentDescription = R.string.content_description_show_more_options,
contentDescription = contentDescription,
state = state,
modifier = modifier
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ fun UserProfileAvatar(
clickable: Clickable? = null,
showPlaceholderIfNoAsset: Boolean = true,
withCrossfadeAnimation: Boolean = false,
contentDescription: String? = null,
type: UserProfileAvatarType = UserProfileAvatarType.WithIndicators.RegularUser(legalHoldIndicatorVisible = false),
) {
Box(
Expand All @@ -142,6 +143,7 @@ fun UserProfileAvatar(
.wrapContentSize()
.clip(CircleShape)
.clickable(clickable)
.clickableDescriptions(clickable)
) {
var userStatusIndicatorParams by remember { mutableStateOf(Size.Zero to Offset.Zero) }
Box(
Expand All @@ -167,6 +169,7 @@ fun UserProfileAvatar(
withCrossfadeAnimation = withCrossfadeAnimation,
type = type,
size = size,
contentDescription = contentDescription,
modifier = Modifier
.padding(padding)
.clip(CircleShape)
Expand Down Expand Up @@ -224,14 +227,15 @@ private fun UserAvatar(
type: UserProfileAvatarType,
size: Dp,
modifier: Modifier = Modifier,
contentDescription: String? = stringResource(R.string.content_description_user_avatar)
) {
if (avatarData.shouldPreferNameBasedAvatar()) {
DefaultInitialsAvatar(nameBasedAvatar = avatarData.nameBasedAvatar!!, type = type, size = size, modifier = modifier)
} else {
val painter = painter(avatarData, showPlaceholderIfNoAsset, withCrossfadeAnimation)
Image(
painter = painter,
contentDescription = stringResource(R.string.content_description_user_avatar),
contentDescription = contentDescription,
contentScale = ContentScale.Crop,
modifier = modifier,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.wire.android.ui.common

import androidx.annotation.StringRes
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand All @@ -30,10 +31,10 @@ import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireDimensions

@Composable
fun WireCheckIcon() {
fun WireCheckIcon(@StringRes contentDescription: Int = R.string.content_description_check) {
Icon(
painter = painterResource(id = R.drawable.ic_check_circle),
contentDescription = stringResource(R.string.content_description_check),
contentDescription = stringResource(contentDescription),
modifier = Modifier.size(MaterialTheme.wireDimensions.wireIconButtonSize),
tint = MaterialTheme.wireColorScheme.positive
)
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/kotlin/com/wire/android/ui/common/WireSwitch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wire.android.ui.theme.wireColorScheme
Expand All @@ -43,9 +45,18 @@ fun WireSwitch(
thumbContent: @Composable () -> Unit = { },
enabled: Boolean = true,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
colors: SwitchColors = wireSwitchColors()
colors: SwitchColors = wireSwitchColors(),
toggleActionDescription: String? = null
) {
Switch(checked, onCheckedChange, modifier, thumbContent, enabled, colors, interactionSource)
Switch(
checked,
onCheckedChange,
modifier.semantics { toggleActionDescription?.let { onClick(it) { false } } },
thumbContent,
enabled,
colors,
interactionSource
)
}

@Composable
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/kotlin/com/wire/android/ui/common/WireTabRow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireTypography
Expand Down Expand Up @@ -70,8 +73,10 @@ fun WireTabRow(
val text = tabItem.title.asString().let {
if (upperCaseTitles) it.uppercase() else it
}
val selectText = stringResource(id = com.wire.android.R.string.content_description_select_label)

Tab(
modifier = Modifier.semantics { onClick(selectText) { false } },
enabled = true,
text = {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import com.wire.android.R
import com.wire.android.model.Clickable
import com.wire.android.ui.common.WireCheckIcon
import com.wire.android.ui.common.clickable
import com.wire.android.ui.common.clickableDescriptions
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.DEFAULT_WEIGHT
import com.wire.android.ui.theme.wireColorScheme
Expand All @@ -63,6 +65,7 @@ fun SelectableMenuBottomSheetItem(
.defaultMinSize(minHeight = dimensions().spacing48x)
.let { if (isSelectedItem(state)) it.background(MaterialTheme.wireColorScheme.secondaryButtonSelected) else it }
.clickable(onItemClick)
.clickableDescriptions(onItemClick)
.padding(vertical = dimensions().spacing12x, horizontal = dimensions().spacing16x)
) {
icon()
Expand Down Expand Up @@ -91,7 +94,7 @@ fun SelectableMenuBottomSheetItem(
.padding(start = dimensions().spacing8x)
.align(Alignment.CenterVertically)
) {
WireCheckIcon()
WireCheckIcon(R.string.label_selected)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ internal fun ConversationMainSheetContent(
icon = {
MenuItemIcon(
id = R.drawable.ic_mute,
contentDescription = stringResource(R.string.content_description_muted_conversation),
contentDescription = null,
)
},
action = { NotificationsOptionsItemAction(conversationSheetContent.mutingConversationState) },
onItemClick = navigateToNotification
onItemClick = navigateToNotification,
onItemClickDescription = stringResource(id = R.string.content_description_open_notification_settings_label)
)
}
}
Expand Down Expand Up @@ -139,10 +140,7 @@ internal fun ConversationMainSheetContent(
icon = {
MenuItemIcon(
id = R.drawable.ic_archive,
contentDescription = stringResource(
if (conversationSheetContent.isArchived) R.string.content_description_unarchive
else R.string.content_description_move_to_archive
),
contentDescription = null,
)
},
title = stringResource(
Expand All @@ -161,14 +159,15 @@ internal fun ConversationMainSheetContent(
)
)
}
})
}
)
}
add {
MenuBottomSheetItem(
icon = {
MenuItemIcon(
id = R.drawable.ic_erase,
contentDescription = stringResource(R.string.content_description_clear_content),
contentDescription = null,
)
},
title = stringResource(R.string.label_clear_content),
Expand All @@ -191,7 +190,7 @@ internal fun ConversationMainSheetContent(
icon = {
MenuItemIcon(
id = R.drawable.ic_block,
contentDescription = stringResource(R.string.content_description_block_the_user),
contentDescription = null,
)
},
itemProvidedColor = MaterialTheme.colorScheme.error,
Expand All @@ -214,7 +213,7 @@ internal fun ConversationMainSheetContent(
icon = {
MenuItemIcon(
id = R.drawable.ic_block,
contentDescription = stringResource(R.string.content_description_unblock_the_user)
contentDescription = null
)
},
itemProvidedColor = MaterialTheme.colorScheme.onBackground,
Expand All @@ -236,7 +235,7 @@ internal fun ConversationMainSheetContent(
icon = {
MenuItemIcon(
id = R.drawable.ic_leave,
contentDescription = stringResource(R.string.content_description_leave_the_group),
contentDescription = null,
)
},
itemProvidedColor = MaterialTheme.colorScheme.error,
Expand All @@ -258,7 +257,7 @@ internal fun ConversationMainSheetContent(
icon = {
MenuItemIcon(
id = R.drawable.ic_remove,
contentDescription = stringResource(R.string.content_description_delete_the_group),
contentDescription = null,
)
},
title = stringResource(R.string.label_delete_group),
Expand Down Expand Up @@ -293,6 +292,6 @@ fun NotificationsOptionsItemAction(
modifier = Modifier.weight(weight = 1f, fill = false)
)
Spacer(modifier = Modifier.size(dimensions().spacing16x))
ArrowRightIcon()
ArrowRightIcon(contentDescription = R.string.content_description_empty)
}
}
Loading
Loading