Skip to content

Commit

Permalink
Merge pull request #21445 from wordpress-mobile/issue/21444-personali…
Browse files Browse the repository at this point in the history
…zation-accessibility

Personalization accessibility
  • Loading branch information
nbradbury authored Nov 13, 2024
2 parents 700baba + e5d90e9 commit bf81edf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -45,6 +46,7 @@ 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 androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -247,15 +249,27 @@ fun DashboardCardStateRow(
onCardToggled: (cardType: CardType, enabled: Boolean) -> Unit,
modifier: Modifier = Modifier
) {
Column(modifier = modifier.fillMaxWidth()) {
val title = stringResource(id = cardState.title)
val label = stringResource(id = R.string.personalization_screen_card_accessibility_label, title)

Column(
modifier = modifier
.fillMaxWidth()
.clickable(onClickLabel = label) {
onCardToggled(cardState.cardType, !cardState.enabled)
}
.semantics(
mergeDescendants = true,
) { },
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(
start = 16.dp,
end = 16.dp
),
verticalAlignment = Alignment.CenterVertically
verticalAlignment = Alignment.CenterVertically,
) {
Column(
modifier = Modifier
Expand All @@ -279,7 +293,10 @@ fun DashboardCardStateRow(
onCardToggled(cardState.cardType, it)
},
modifier = Modifier
.weight(.1f),
.clickable(onClickLabel = label) {
onCardToggled(cardState.cardType, !cardState.enabled)
}
.weight(.1f)
)
}
HorizontalDivider(
Expand Down Expand Up @@ -318,7 +335,7 @@ fun ShortcutStateRow(
) {
Image(
painter = painterResource(id = state.icon),
contentDescription = null, // Add appropriate content description
contentDescription = uiStringText(state.label),
contentScale = ContentScale.Fit,
modifier = Modifier
.size(24.dp)
Expand Down Expand Up @@ -347,7 +364,8 @@ fun ShortcutStateRow(
painter = painterResource(id = actionIcon),
tint = actionIconTint,
contentDescription = stringResource(
R.string.personalization_screen_shortcuts_add_or_remove_shortcut_button
R.string.personalization_screen_shortcuts_accessibility_label,
uiStringText(state.label)
),
)
}
Expand Down
3 changes: 2 additions & 1 deletion WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4846,7 +4846,8 @@ translators: %s: Select control option value e.g: "Auto, 25%". -->
<string name="personalization_screen_activity_log_card_description">Recent actions taken on your site.</string>
<string name="personalization_screen_next_steps_card_title" translatable="false">@string/quick_start_sites</string>
<string name="personalization_screen_next_steps_card_description">Learn how to make the most of your site with the app.</string>
<string name="personalization_screen_shortcuts_add_or_remove_shortcut_button">Add or Remove shortcuts</string>
<string name="personalization_screen_card_accessibility_label">Toggle %s card</string>
<string name="personalization_screen_shortcuts_accessibility_label">Toggle %s shortcut</string>

<string name="my_site_dashboard_no_cards_message_title">All cards are hidden</string>
<string name="my_site_dashboard_no_cards_message_description">Tap the personalise button to show more cards.</string>
Expand Down

0 comments on commit bf81edf

Please sign in to comment.