mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Add accessibility label on buttons.
This commit is contained in:
@@ -26,7 +26,8 @@ import org.thoughtcrime.securesms.util.NameUtil
|
||||
fun AvatarImage(
|
||||
recipient: Recipient,
|
||||
modifier: Modifier = Modifier,
|
||||
useProfile: Boolean = true
|
||||
useProfile: Boolean = true,
|
||||
contentDescription: String? = null
|
||||
) {
|
||||
if (LocalInspectionMode.current) {
|
||||
Spacer(
|
||||
@@ -38,7 +39,11 @@ fun AvatarImage(
|
||||
val state = recipient.live().liveData.map { AvatarImageState(NameUtil.getAbbreviation(it.getDisplayName(context)), it, AvatarHelper.getAvatarFileDetails(context, it.id)) }.observeAsState().value ?: return
|
||||
|
||||
AndroidView(
|
||||
factory = ::AvatarImageView,
|
||||
factory = {
|
||||
AvatarImageView(context).apply {
|
||||
this.contentDescription = contentDescription
|
||||
}
|
||||
},
|
||||
modifier = modifier.background(color = Color.Transparent, shape = CircleShape)
|
||||
) {
|
||||
if (useProfile) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import org.signal.core.ui.compose.Previews
|
||||
@@ -158,6 +159,7 @@ private fun TopAppBar(
|
||||
title = pluralStringResource(R.plurals.GroupsInCommon__n_groups_in_common_title, groupCount, NumberFormat.getInstance().format(groupCount)),
|
||||
titleContent = { _, title -> Text(text = title, style = MaterialTheme.typography.titleLarge) },
|
||||
navigationIconPainter = painterResource(R.drawable.symbol_arrow_start_24),
|
||||
navigationContentDescription = stringResource(R.string.DefaultTopAppBar__navigate_up_content_description),
|
||||
onNavigationClick = onBackPress,
|
||||
scrollBehavior = scrollBehavior
|
||||
)
|
||||
|
||||
@@ -32,6 +32,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -182,15 +183,15 @@ private fun PrimaryActionButton(
|
||||
shadowElevation = elevation,
|
||||
icon = {
|
||||
AnimatedContent(destination) { targetState ->
|
||||
val icon = when (targetState) {
|
||||
MainNavigationListLocation.CHATS -> R.drawable.symbol_edit_24
|
||||
MainNavigationListLocation.CALLS -> R.drawable.symbol_phone_plus_24
|
||||
MainNavigationListLocation.STORIES -> R.drawable.symbol_camera_24
|
||||
val (icon, contentDescriptionId) = when (targetState) {
|
||||
MainNavigationListLocation.CHATS -> R.drawable.symbol_edit_24 to R.string.conversation_list_fragment__fab_content_description
|
||||
MainNavigationListLocation.CALLS -> R.drawable.symbol_phone_plus_24 to R.string.CallLogFragment__start_a_new_call
|
||||
MainNavigationListLocation.STORIES -> R.drawable.symbol_camera_24 to R.string.conversation_list_fragment__open_camera_description
|
||||
}
|
||||
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(icon),
|
||||
contentDescription = ""
|
||||
contentDescription = stringResource(contentDescriptionId)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -209,7 +210,7 @@ private fun CameraButton(
|
||||
icon = {
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(R.drawable.symbol_camera_24),
|
||||
contentDescription = ""
|
||||
contentDescription = stringResource(R.string.conversation_list_fragment__open_camera_description)
|
||||
)
|
||||
},
|
||||
colors = colors,
|
||||
|
||||
@@ -63,6 +63,8 @@ import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.signal.core.ui.compose.DropdownMenus
|
||||
@@ -317,6 +319,7 @@ private fun PrimaryToolbar(
|
||||
containerColor = state.toolbarColor ?: MaterialTheme.colorScheme.surface
|
||||
),
|
||||
navigationIcon = {
|
||||
val contentDescription = stringResource(R.string.conversation_list_settings_shortcut)
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
@@ -327,7 +330,8 @@ private fun PrimaryToolbar(
|
||||
recipient = state.self,
|
||||
modifier = Modifier
|
||||
.clip(CircleShape)
|
||||
.size(28.dp)
|
||||
.size(28.dp),
|
||||
contentDescription = contentDescription
|
||||
)
|
||||
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
@@ -336,10 +340,12 @@ private fun PrimaryToolbar(
|
||||
.fillMaxSize()
|
||||
.clickable(
|
||||
onClick = callback::onSettingsClick,
|
||||
onClickLabel = stringResource(R.string.conversation_list_settings_shortcut),
|
||||
interactionSource = interactionSource,
|
||||
indication = ripple(radius = 14.dp)
|
||||
)
|
||||
.semantics {
|
||||
this.contentDescription = contentDescription
|
||||
}
|
||||
)
|
||||
|
||||
BadgeImageSmall(
|
||||
|
||||
@@ -78,7 +78,8 @@ fun CountryCodeSelectScreen(
|
||||
Text(text = title, style = MaterialTheme.typography.titleLarge)
|
||||
},
|
||||
onNavigationClick = onDismissed,
|
||||
navigationIconPainter = rememberVectorPainter(ImageVector.vectorResource(R.drawable.symbol_x_24))
|
||||
navigationIconPainter = rememberVectorPainter(ImageVector.vectorResource(R.drawable.symbol_x_24)),
|
||||
navigationContentDescription = stringResource(R.string.Material3SearchToolbar__close)
|
||||
)
|
||||
}
|
||||
) { padding ->
|
||||
|
||||
@@ -243,6 +243,7 @@ private fun TopAppBar(
|
||||
title = stringResource(R.string.StickerManagementActivity_stickers),
|
||||
titleContent = { _, title -> Text(text = title, style = MaterialTheme.typography.titleLarge) },
|
||||
navigationIconPainter = painterResource(R.drawable.symbol_arrow_start_24),
|
||||
navigationContentDescription = stringResource(R.string.DefaultTopAppBar__navigate_up_content_description),
|
||||
onNavigationClick = onBackPress
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8463,5 +8463,8 @@
|
||||
<!-- Accessibility label for more options button in MainToolbar -->
|
||||
<string name="MainToolbar__proxy_content_description">Proxy</string>
|
||||
|
||||
<!-- Accessibility label for a button displayed in the toolbar to return to the previous screen. -->
|
||||
<string name="DefaultTopAppBar__navigate_up_content_description">Navigate up</string>
|
||||
|
||||
<!-- EOF -->
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user