From bf6219923c606f0a3af0e352d9c687f290b15be2 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 11 Nov 2024 11:52:43 -0500 Subject: [PATCH 1/7] Group personalize card rows --- .../personalization/PersonalizationActivity.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt index 11dd6689cf87..8dd3729e9555 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt @@ -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 @@ -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 @@ -254,8 +256,12 @@ fun DashboardCardStateRow( .padding( start = 16.dp, end = 16.dp - ), - verticalAlignment = Alignment.CenterVertically + ) + .clickable { + onCardToggled(cardState.cardType, !cardState.enabled) + } + .semantics(mergeDescendants = true) { }, + verticalAlignment = Alignment.CenterVertically, ) { Column( modifier = Modifier @@ -276,7 +282,7 @@ fun DashboardCardStateRow( Switch( checked = cardState.enabled, onCheckedChange = { - onCardToggled(cardState.cardType, it) + // TODO onCardToggled(cardState.cardType, it) }, modifier = Modifier .weight(.1f), From 320f2e38f809578d40dc2e8d6bb0b6a7ebf16b3a Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 11 Nov 2024 12:06:55 -0500 Subject: [PATCH 2/7] Make entire column clickable --- .../PersonalizationActivity.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt index 8dd3729e9555..640874dd0489 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt @@ -46,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.clearAndSetSemantics import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview @@ -249,18 +250,24 @@ fun DashboardCardStateRow( onCardToggled: (cardType: CardType, enabled: Boolean) -> Unit, modifier: Modifier = Modifier ) { - Column(modifier = modifier.fillMaxWidth()) { + Column( + modifier = modifier + .fillMaxWidth() + .clickable { + onCardToggled(cardState.cardType, !cardState.enabled) + } + .clearAndSetSemantics { } + .semantics( + mergeDescendants = true, + ) { }, + ) { Row( modifier = Modifier .fillMaxWidth() .padding( start = 16.dp, end = 16.dp - ) - .clickable { - onCardToggled(cardState.cardType, !cardState.enabled) - } - .semantics(mergeDescendants = true) { }, + ), verticalAlignment = Alignment.CenterVertically, ) { Column( From 28eb1cbaf7abcd4566de47be9371447149d86b09 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 11 Nov 2024 12:42:57 -0500 Subject: [PATCH 3/7] Added label --- .../ui/mysite/personalization/PersonalizationActivity.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt index 640874dd0489..423a71e2f3a5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt @@ -46,7 +46,6 @@ 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.clearAndSetSemantics import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview @@ -250,13 +249,15 @@ fun DashboardCardStateRow( onCardToggled: (cardType: CardType, enabled: Boolean) -> Unit, modifier: Modifier = Modifier ) { + val title = stringResource(id = cardState.title) + val label = stringResource(id = R.string.personalization_card_accessibility_label, title) + Column( modifier = modifier .fillMaxWidth() - .clickable { + .clickable( onClickLabel = label) { onCardToggled(cardState.cardType, !cardState.enabled) } - .clearAndSetSemantics { } .semantics( mergeDescendants = true, ) { }, @@ -292,7 +293,7 @@ fun DashboardCardStateRow( // TODO onCardToggled(cardState.cardType, it) }, modifier = Modifier - .weight(.1f), + .weight(.1f) ) } HorizontalDivider( From 00e40b0d27bd49f4be27bb7e1cacd798ad998f5c Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 11 Nov 2024 12:47:09 -0500 Subject: [PATCH 4/7] Added label to switch --- .../ui/mysite/personalization/PersonalizationActivity.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt index 423a71e2f3a5..8638ce1f93aa 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt @@ -255,7 +255,7 @@ fun DashboardCardStateRow( Column( modifier = modifier .fillMaxWidth() - .clickable( onClickLabel = label) { + .clickable(onClickLabel = label) { onCardToggled(cardState.cardType, !cardState.enabled) } .semantics( @@ -290,9 +290,10 @@ fun DashboardCardStateRow( Switch( checked = cardState.enabled, onCheckedChange = { - // TODO onCardToggled(cardState.cardType, it) + onCardToggled(cardState.cardType, it) }, modifier = Modifier + .clickable(onClickLabel = label) { } .weight(.1f) ) } From 3c99c21ad395ba5fae8b73ce8ae7b03dd8dd68ba Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 11 Nov 2024 13:01:12 -0500 Subject: [PATCH 5/7] Fixed switch when TalkBack is off --- .../mysite/personalization/PersonalizationActivity.kt | 11 ++++++++++- WordPress/src/main/res/values/strings.xml | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt index 8638ce1f93aa..50d9b2a336b1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt @@ -293,7 +293,9 @@ fun DashboardCardStateRow( onCardToggled(cardState.cardType, it) }, modifier = Modifier - .clickable(onClickLabel = label) { } + .clickable(onClickLabel = label) { + onCardToggled(cardState.cardType, !cardState.enabled) + } .weight(.1f) ) } @@ -313,10 +315,17 @@ fun ShortcutStateRow( actionButtonClick: () -> Unit, modifier: Modifier = Modifier ) { + val label = stringResource(id = R.string.personalization_card_accessibility_label, state.label) Box( modifier = modifier .fillMaxWidth() .padding(start = 16.dp, end = 16.dp, top = 6.dp, bottom = 6.dp) + .clickable(onClickLabel = label) { + actionButtonClick() + } + .semantics( + mergeDescendants = true, + ) { }, ) { Row( diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 3a5204be5ac1..092dc97aed3d 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -4847,6 +4847,7 @@ translators: %s: Select control option value e.g: "Auto, 25%". --> @string/quick_start_sites Learn how to make the most of your site with the app. Add or Remove shortcuts + Toggle %s All cards are hidden Tap the personalise button to show more cards. From 9ab84a17475fd2d366321db6485c0fdbc91333aa Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 11 Nov 2024 13:06:04 -0500 Subject: [PATCH 6/7] Added missing content description --- .../ui/mysite/personalization/PersonalizationActivity.kt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt index 50d9b2a336b1..aefbaf5a26cb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt @@ -315,17 +315,10 @@ fun ShortcutStateRow( actionButtonClick: () -> Unit, modifier: Modifier = Modifier ) { - val label = stringResource(id = R.string.personalization_card_accessibility_label, state.label) Box( modifier = modifier .fillMaxWidth() .padding(start = 16.dp, end = 16.dp, top = 6.dp, bottom = 6.dp) - .clickable(onClickLabel = label) { - actionButtonClick() - } - .semantics( - mergeDescendants = true, - ) { }, ) { Row( @@ -342,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) From 82295317475221b6ea1123b42d53e1598fdf4a3a Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 11 Nov 2024 13:12:06 -0500 Subject: [PATCH 7/7] Changed content description for shortcuts --- .../ui/mysite/personalization/PersonalizationActivity.kt | 5 +++-- WordPress/src/main/res/values/strings.xml | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt index aefbaf5a26cb..207f4e13e400 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt @@ -250,7 +250,7 @@ fun DashboardCardStateRow( modifier: Modifier = Modifier ) { val title = stringResource(id = cardState.title) - val label = stringResource(id = R.string.personalization_card_accessibility_label, title) + val label = stringResource(id = R.string.personalization_screen_card_accessibility_label, title) Column( modifier = modifier @@ -364,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) ), ) } diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 092dc97aed3d..1299e8daa405 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -4846,8 +4846,8 @@ translators: %s: Select control option value e.g: "Auto, 25%". --> Recent actions taken on your site. @string/quick_start_sites Learn how to make the most of your site with the app. - Add or Remove shortcuts - Toggle %s + Toggle %s card + Toggle %s shortcut All cards are hidden Tap the personalise button to show more cards.