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 WhatsNew #WPB-9835 🍒 #3579

Merged
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
15 changes: 10 additions & 5 deletions app/src/main/kotlin/com/wire/android/ui/common/AppExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.flowWithLifecycle
Expand Down Expand Up @@ -59,17 +59,22 @@ import kotlin.coroutines.EmptyCoroutineContext

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

return this
.clickable(onItemClick)
.semantics { stateDescription = if (isSelected) selectedDescription else "" }
.semantics {
if (isSelected) selected = true // So TalkBack ignores selection when it's not selected
}
}

@Composable
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/kotlin/com/wire/android/ui/common/Logo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.wire.android.R

@Composable
fun Logo(modifier: Modifier = Modifier) {
Image(
painter = painterResource(id = R.drawable.ic_wire_logo),
contentDescription = stringResource(id = R.string.content_description_app_logo),
contentDescription = null,
contentScale = ContentScale.Fit,
modifier = modifier,
colorFilter = ColorFilter.tint(colorsScheme().onSurface)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ private fun UserAvatar(
nameBasedAvatar = avatarData.nameBasedAvatar!!,
type = type,
size = size,
modifier = modifier
modifier = modifier,
contentDescription = contentDescription
)
} else {
val painter = painter(avatarData, showPlaceholderIfNoAsset, withCrossfadeAnimation)
Expand All @@ -290,12 +291,12 @@ private fun DefaultInitialsAvatar(
type: UserProfileAvatarType,
size: Dp,
modifier: Modifier = Modifier,
contentDescription: String? = stringResource(R.string.content_description_user_avatar),
) {
val contentDescription = stringResource(R.string.content_description_user_avatar)
Box(
contentAlignment = Alignment.Center,
modifier = modifier
.semantics { this.contentDescription = contentDescription }
.semantics { this.contentDescription = contentDescription ?: "" }
.size(size)
.clip(CircleShape)
.background(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
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 @@ -63,7 +61,6 @@ fun InternalContactSearchResultItem(
actionType: ItemActionType,
modifier: Modifier = Modifier
) {
val selectedDescription = stringResource(id = R.string.content_description_selected_label)
RowItemTemplate(
leadingIcon = { UserProfileAvatar(avatarData) },
titleStartPadding = dimensions().spacing0x,
Expand Down Expand Up @@ -112,7 +109,7 @@ fun InternalContactSearchResultItem(
modifier = modifier
.padding(start = dimensions().spacing8x)
.semantics {
if (actionType.checkable && isSelected) stateDescription = selectedDescription
if (actionType.checkable && isSelected) selected = true
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.wire.android.R
import com.wire.android.navigation.HomeDestination
import com.wire.android.ui.common.Logo
import com.wire.android.ui.common.dimensions
Expand Down Expand Up @@ -122,11 +123,11 @@ fun DrawerItem(destination: HomeDestination, selected: Boolean, unreadCount: Int
.fillMaxWidth()
.height(40.dp)
.background(backgroundColor)
.selectableBackground(selected) { onItemClick() },
.selectableBackground(selected, stringResource(R.string.content_description_open_label), onItemClick),
) {
Image(
painter = painterResource(id = destination.icon),
contentDescription = stringResource(destination.title),
contentDescription = null,
colorFilter = ColorFilter.tint(contentColor),
contentScale = ContentScale.Fit,
modifier = Modifier.padding(start = dimensions().spacing16x, end = dimensions().spacing16x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import com.ramcosta.composedestinations.spec.Direction
import com.wire.android.R
import com.wire.android.model.Clickable
Expand All @@ -51,6 +53,7 @@ fun WhatsNewItem(
title: String? = null,
boldTitle: Boolean = false,
text: String? = null,
contentDescription: String = "${title ?: ""} ${text ?: ""}",
@DrawableRes trailingIcon: Int? = null,
onRowPressed: Clickable = Clickable(false),
isLoading: Boolean = false,
Expand Down Expand Up @@ -84,7 +87,7 @@ fun WhatsNewItem(
trailingIcon?.let {
Icon(
painter = painterResource(id = trailingIcon),
contentDescription = "",
contentDescription = null,
tint = MaterialTheme.wireColorScheme.onSecondaryButtonEnabled,
modifier = Modifier
.defaultMinSize(dimensions().wireIconButtonSize)
Expand All @@ -94,7 +97,9 @@ fun WhatsNewItem(
} ?: Icons.Filled.ChevronRight
},
clickable = onRowPressed,
modifier = modifier.padding(vertical = dimensions().spacing4x)
modifier = modifier
.padding(vertical = dimensions().spacing4x)
.clearAndSetSemantics { this.contentDescription = contentDescription }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.navigation.compose.hiltViewModel
import com.wire.android.BuildConfig
Expand Down Expand Up @@ -70,6 +71,7 @@ fun WhatsNewScreenContent(
lazyListState: LazyListState = rememberLazyListState()
) {
val context = LocalContext.current
val openLinkLabel = stringResource(R.string.content_description_open_link_label)
LazyColumn(
state = lazyListState,
modifier = modifier.fillMaxSize()
Expand All @@ -80,6 +82,7 @@ fun WhatsNewScreenContent(
add(WhatsNewItem.WelcomeToNewAndroidApp)
},
onItemClicked = onItemClicked,
onItemClickedDescription = openLinkLabel,
isLoading = false,
)
}
Expand Down Expand Up @@ -119,6 +122,7 @@ fun WhatsNewScreenContent(
}
},
onItemClicked = onItemClicked,
onItemClickedDescription = openLinkLabel,
isLoading = state.isLoading,
)
}
Expand All @@ -128,17 +132,30 @@ private fun LazyListScope.folderWithElements(
header: String? = null,
items: List<WhatsNewItem>,
onItemClicked: (WhatsNewItem) -> Unit,
onItemClickedDescription: String,
isLoading: Boolean,
) {
folderWithElements(
header = header?.uppercase(),
items = items.associateBy { it.id }
) { item ->
val contentDescription = when (item) {
WhatsNewItem.WelcomeToNewAndroidApp -> stringResource(R.string.content_description_whats_new_welcome_item)
is WhatsNewItem.AllAndroidReleaseNotes -> stringResource(R.string.content_description_whats_new_all_releases_item)
is WhatsNewItem.AndroidReleaseNotes ->
stringResource(R.string.content_description_whats_new_release_item, item.title.asString(), item.text?.asString() ?: "")
}
WhatsNewItem(
title = item.title.asString(),
boldTitle = item.boldTitle,
text = item.text?.asString(),
onRowPressed = remember(isLoading) { Clickable(enabled = !isLoading) { onItemClicked(item) } },
onRowPressed = remember(isLoading) {
Clickable(
enabled = !isLoading,
onClickDescription = onItemClickedDescription
) { onItemClicked(item) }
},
contentDescription = contentDescription,
trailingIcon = R.drawable.ic_arrow_right,
isLoading = isLoading,
)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<string name="label_and">y</string>
<string name="label_retry">Reintentar</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Logo de la aplicación</string>
<string name="content_description_reveal_password">Mostrar contraseña</string>
<string name="content_description_hide_password">Ocultar contraseña</string>
<string name="content_description_search_back">Icono de búsqueda atrás</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<string name="label_and">ja</string>
<string name="label_retry">Proovi uuesti</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Rakenduse logo</string>
<string name="content_description_reveal_password">Kuva parool</string>
<string name="content_description_hide_password">Peida parool</string>
<string name="content_description_search_back">Otsi tagasi ikoon</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<string name="label_retry">Réessayer</string>
<string name="label_draft">Brouillons</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Logo de l\'application</string>
<string name="content_description_reveal_password">Afficher le mot de passe</string>
<string name="content_description_hide_password">Cacher le mot de passe</string>
<string name="content_description_search_back">Icône de retour de recherche</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
<string name="label_and">i</string>
<string name="label_retry">Pokušaj ponovo</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Logotip aplikacije</string>
<string name="content_description_reveal_password">Prikaži lozinku</string>
<string name="content_description_hide_password">Sakrij lozinku</string>
<string name="content_description_search_back">Ikona za povratak</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<string name="label_retry">Újra</string>
<string name="label_draft">*Piszkozat*</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">App logó</string>
<string name="content_description_reveal_password">Jelszó megjelenítése</string>
<string name="content_description_hide_password">Jelszó elrejtése</string>
<string name="content_description_search_back">Keresés vissza ikon</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
<string name="label_and">e</string>
<string name="label_retry">Riprova</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Logo dell\'app</string>
<string name="content_description_reveal_password">Mostra la password</string>
<string name="content_description_hide_password">Nascondi la password</string>
<string name="content_description_search_back">Icona di ricerca all\'indietro</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<string name="label_and">と</string>
<string name="label_retry">再試行</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">アプリのロゴ</string>
<string name="content_description_reveal_password">パスワードを表示</string>
<string name="content_description_hide_password">パスワードを非表示</string>
<string name="content_description_search_back">検索に戻るアイコン</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<string name="label_and">i</string>
<string name="label_retry">Pon&#243;w pr&#243;b&#281;</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Logo aplikacji</string>
<string name="content_description_reveal_password">Poka&#380; has&#322;o</string>
<string name="content_description_hide_password">Ukryj has&#322;o</string>
<string name="content_description_search_back">Ikona wyszukiwania wstecz</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<string name="label_retry">Tentar novamente</string>
<string name="label_draft">*Rascunho*</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Logo do aplicativo</string>
<string name="content_description_reveal_password">Mostrar senha</string>
<string name="content_description_hide_password">Ocultar senha</string>
<string name="content_description_search_back">Ícone de busca</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<string name="label_retry">Повторить</string>
<string name="label_draft">*Черновик*</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Логотип приложения</string>
<string name="content_description_reveal_password">Показать пароль</string>
<string name="content_description_hide_password">Скрыть пароль</string>
<string name="content_description_search_back">Значок возврата поиска</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-si/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
<string name="label_retry">නැවත</string>
<string name="label_draft">*කටුපිටපත*</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">යෙදුමේ ලාංඡනය</string>
<string name="content_description_reveal_password">මුරපදය පෙන්වන්න</string>
<string name="content_description_hide_password">මුරපදය සඟවන්න</string>
<string name="content_description_search_back">ආපසු සොයන්න නිරූපකය</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
<string name="label_retry">Försök igen</string>
<string name="label_draft">*Utkast*</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Appens logga</string>
<string name="content_description_reveal_password">Visa lösenord</string>
<string name="content_description_hide_password">Dölj lösenord</string>
<string name="content_description_clear_content">Rensa bort innehåll</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
<string name="label_retry">Yeniden Dene</string>
<string name="label_draft">Taslaklar</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Uygulama Simgesi</string>
<string name="content_description_reveal_password">Şifreyi göster</string>
<string name="content_description_hide_password">Parolayı gizle</string>
<string name="content_description_search_back">Geri arama simgesi</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
<string name="label_and">і</string>
<string name="label_retry">Повторити</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">Логотип додатка</string>
<string name="content_description_reveal_password">Показати пароль</string>
<string name="content_description_hide_password">Приховати пароль</string>
<string name="content_description_clear_content">Видалити вміст</string>
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
<string name="label_retry">Retry</string>
<string name="label_draft">*Draft*</string>
<!-- Content descriptions https://wearezeta.atlassian.net/wiki/spaces/AR/pages/122520039/Code+Style+Guideline#Content-description-strings -->
<string name="content_description_app_logo">App Logo</string>
<string name="content_description_reveal_password">Show password</string>
<string name="content_description_hide_password">Hide password</string>
<string name="content_description_search_back">Search back icon</string>
Expand Down Expand Up @@ -238,6 +237,9 @@
<string name="content_description_login_email_field">enter your email or username</string>
<string name="content_description_login_password_field">enter your password</string>
<string name="content_description_login_sso_code_field">enter your SSO code or Wire email</string>
<string name="content_description_whats_new_welcome_item">Welcome to Wire\'s New Android App, link to support page</string>
<string name="content_description_whats_new_all_releases_item">All Android release notes, link to release note overview</string>
<string name="content_description_whats_new_release_item">%1$s, %2$s, link to release details</string>
<string name="content_description_empty"> </string>
<!-- Non translatable strings-->
<string name="url_android_release_notes" translatable="false">https://medium.com/wire-news/android-updates/home</string>
Expand Down
Loading