Prevent usage of hard-coded string for contentDescription, and fix existing issues.

This commit is contained in:
Benoit Marty
2023-11-21 15:36:20 +01:00
parent ef7315d6c6
commit 5f8e85edc6
12 changed files with 20 additions and 16 deletions

View File

@@ -58,7 +58,7 @@ fun RoomPrivacyOption(
Icon(
modifier = Modifier.padding(horizontal = 8.dp),
resourceId = roomPrivacyItem.icon,
contentDescription = "",
contentDescription = null,
tint = MaterialTheme.colorScheme.secondary,
)

View File

@@ -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))

View File

@@ -70,7 +70,7 @@ fun RoundedIconAtom(
tint = tint,
resourceId = resourceId,
imageVector = imageVector,
contentDescription = "",
contentDescription = null,
)
}
}

View File

@@ -51,7 +51,7 @@ fun PreferenceIcon(
Icon(
imageVector = icon,
resourceId = iconResourceId,
contentDescription = "",
contentDescription = null,
tint = tintColor ?: enabled.toSecondaryEnabledColor(),
modifier = Modifier
.padding(end = 16.dp)

View File

@@ -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)
}
}
}

View File

@@ -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)
}

View File

@@ -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)
}
}
}

View File

@@ -87,7 +87,7 @@ fun EditableAvatarView(
Icon(
modifier = Modifier.size(16.dp),
resourceId = CommonDrawables.ic_edit,
contentDescription = "",
contentDescription = null,
tint = MaterialTheme.colorScheme.onPrimary,
)
}

View File

@@ -79,7 +79,7 @@ fun UnresolvedUserRow(
) {
Icon(
resourceId = CommonDrawables.ic_compound_error,
contentDescription = "",
contentDescription = null,
modifier = Modifier
.size(18.dp)
.align(Alignment.Top)

View File

@@ -72,7 +72,7 @@ fun UnsavedAvatar(
Box(modifier = commonModifier.background(ElementTheme.colors.temporaryColorBgSpecial)) {
Icon(
imageVector = Icons.Outlined.AddAPhoto,
contentDescription = "",
contentDescription = null,
modifier = Modifier
.align(Alignment.Center)
.size(40.dp),

View File

@@ -98,19 +98,19 @@ internal fun FormattingButtonPreview() = ElementPreview {
state = FormattingOptionState.Default,
onClick = { },
imageVector = ImageVector.vectorResource(CommonDrawables.ic_bold),
contentDescription = "",
contentDescription = null,
)
FormattingOption(
state = FormattingOptionState.Selected,
onClick = { },
imageVector = ImageVector.vectorResource(CommonDrawables.ic_italic),
contentDescription = "",
contentDescription = null,
)
FormattingOption(
state = FormattingOptionState.Disabled,
onClick = { },
imageVector = ImageVector.vectorResource(CommonDrawables.ic_underline),
contentDescription = "",
contentDescription = null,
)
}
}

View File

@@ -132,3 +132,7 @@ System\.currentTimeMillis\(\)===1
### Use `import io.element.android.libraries.ui.strings.CommonStrings` then `CommonStrings.<stringKey>` instead
import io\.element\.android\.libraries\.ui\.strings\.R
# Accessibility
### Use string resource for `contentDescription`, or null instead of empty string
contentDescription = "