From e05442915d11f388a2dafe8b79f9f70bccc7a607 Mon Sep 17 00:00:00 2001 From: Zafar Date: Sun, 15 Dec 2024 23:30:28 +0100 Subject: [PATCH 01/14] feat(event-creation): add text clear button to first two fields Added a trailing icon button for the event title field and the short description field to match with the figma design. --- .../android/unio/ui/event/EventCreation.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/src/main/java/com/android/unio/ui/event/EventCreation.kt b/app/src/main/java/com/android/unio/ui/event/EventCreation.kt index a6f1c2ba7..43b8d114f 100644 --- a/app/src/main/java/com/android/unio/ui/event/EventCreation.kt +++ b/app/src/main/java/com/android/unio/ui/event/EventCreation.kt @@ -14,6 +14,8 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.outlined.Clear +import androidx.compose.material.icons.rounded.Clear import androidx.compose.material3.Button import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -139,6 +141,19 @@ fun EventCreationScreen( Modifier.testTag(EventCreationTestTags.TITLE_CHARACTER_COUNTER)) } } + }, + trailingIcon = { + if (name.isNotEmpty()) { + IconButton( + onClick = { name = "" }, + modifier = Modifier.testTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON) + ) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = context.getString(R.string.event_creation_content_description_clear_title) + ) + } + } }) OutlinedTextField( @@ -165,6 +180,19 @@ fun EventCreationScreen( EventCreationTestTags.SHORT_DESCRIPTION_CHARACTER_COUNTER)) } } + }, + trailingIcon = { + if (shortDescription.isNotEmpty()) { + IconButton( + onClick = { shortDescription = "" }, + modifier = Modifier.testTag(EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON) + ) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = context.getString(R.string.event_creation_content_description_clear_short_description) + ) + } + } }) BannerImagePicker( From 4f1baeb31e0d322d21ee138802f14f69f44f08b9 Mon Sep 17 00:00:00 2001 From: Zafar Date: Sun, 15 Dec 2024 23:31:08 +0100 Subject: [PATCH 02/14] chore(event-edition-components): add trailing icon to location input field --- .../android/unio/ui/components/EventEditComponents.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt b/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt index d16f74fc3..6e2effaf9 100644 --- a/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt +++ b/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt @@ -23,6 +23,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AccessTime import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.DateRange +import androidx.compose.material.icons.outlined.LocationOn import androidx.compose.material3.AlertDialog import androidx.compose.material3.DatePicker import androidx.compose.material3.DatePickerDialog @@ -108,7 +109,13 @@ fun NominatimLocationPicker( }, label = { Text(context.getString(R.string.event_creation_location_label)) }, placeholder = { Text(context.getString(R.string.event_creation_location_input_label)) }, - modifier = Modifier.fillMaxWidth().testTag(textFieldTestTag)) + modifier = Modifier.fillMaxWidth().testTag(textFieldTestTag), + trailingIcon = { + Icon( + imageVector = Icons.Outlined.LocationOn, + contentDescription = context.getString(R.string.event_creation_location_icon) + ) + }) DropdownMenu( expanded = showDropdown && locationSuggestions.isNotEmpty(), From 409dc96bec5098c23a0eaad3d37b28b831b57db9 Mon Sep 17 00:00:00 2001 From: Zafar Date: Sun, 15 Dec 2024 23:31:47 +0100 Subject: [PATCH 03/14] chore(strings): add content descriptions for clear buttons and location icon --- app/src/main/res/values-fr/strings.xml | 3 +++ app/src/main/res/values/strings.xml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 6a0402651..672fc480e 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -210,6 +210,9 @@ Entrez une addresse Plus… + Effacer titre + Effacer description courte + Icône de localisation Modifier diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 49148ba87..99310403d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -214,6 +214,9 @@ Enter an address More… + Clear title + Clear short description + Location icon Edit From 6a4c135d4a16d3bda78d2efb01a58fd171de629b Mon Sep 17 00:00:00 2001 From: Zafar Date: Sun, 15 Dec 2024 23:32:10 +0100 Subject: [PATCH 04/14] chore(test-tags): add test tags for clear buttons in Event creation --- .../android/unio/model/strings/test_tags/event/EventTestTags.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt b/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt index 0d720c9fc..65d8023ed 100644 --- a/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt +++ b/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt @@ -17,7 +17,9 @@ object EventCreationTestTags { const val SCREEN = "eventCreationScreen" const val TITLE = "eventCreationTitle" const val EVENT_TITLE = "eventCreationEventTitle" + const val EVENT_TITLE_CLEAR_BUTTON = "eventCreationEventTitleClearButton" const val SHORT_DESCRIPTION = "eventCreationShortDescription" + const val EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON = "eventCreationShortDescriptionClearButton" const val COAUTHORS = "eventCreationCoauthors" const val TAGGED_ASSOCIATIONS = "eventCreationTaggedAssociations" const val DESCRIPTION = "eventCreationDescription" From 5d4151f709568693fe163bac7cd1dc6e584b019d Mon Sep 17 00:00:00 2001 From: Zafar Date: Sun, 15 Dec 2024 23:32:36 +0100 Subject: [PATCH 05/14] style: format files using ktfmtFormat --- .../unio/ui/components/EventEditComponents.kt | 7 ++- .../android/unio/ui/event/EventCreation.kt | 47 ++++++++++--------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt b/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt index 6e2effaf9..19470f25f 100644 --- a/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt +++ b/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt @@ -111,10 +111,9 @@ fun NominatimLocationPicker( placeholder = { Text(context.getString(R.string.event_creation_location_input_label)) }, modifier = Modifier.fillMaxWidth().testTag(textFieldTestTag), trailingIcon = { - Icon( - imageVector = Icons.Outlined.LocationOn, - contentDescription = context.getString(R.string.event_creation_location_icon) - ) + Icon( + imageVector = Icons.Outlined.LocationOn, + contentDescription = context.getString(R.string.event_creation_location_icon)) }) DropdownMenu( diff --git a/app/src/main/java/com/android/unio/ui/event/EventCreation.kt b/app/src/main/java/com/android/unio/ui/event/EventCreation.kt index 43b8d114f..4793c8998 100644 --- a/app/src/main/java/com/android/unio/ui/event/EventCreation.kt +++ b/app/src/main/java/com/android/unio/ui/event/EventCreation.kt @@ -142,18 +142,18 @@ fun EventCreationScreen( } } }, - trailingIcon = { - if (name.isNotEmpty()) { - IconButton( - onClick = { name = "" }, - modifier = Modifier.testTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON) - ) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = context.getString(R.string.event_creation_content_description_clear_title) - ) + trailingIcon = { + if (name.isNotEmpty()) { + IconButton( + onClick = { name = "" }, + modifier = Modifier.testTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.event_creation_content_description_clear_title)) } - } + } }) OutlinedTextField( @@ -181,18 +181,21 @@ fun EventCreationScreen( } } }, - trailingIcon = { - if (shortDescription.isNotEmpty()) { - IconButton( - onClick = { shortDescription = "" }, - modifier = Modifier.testTag(EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON) - ) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = context.getString(R.string.event_creation_content_description_clear_short_description) - ) + trailingIcon = { + if (shortDescription.isNotEmpty()) { + IconButton( + onClick = { shortDescription = "" }, + modifier = + Modifier.testTag( + EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string + .event_creation_content_description_clear_short_description)) } - } + } }) BannerImagePicker( From 84c4186eabac6c43bbbd5793aeccef217cae5141 Mon Sep 17 00:00:00 2001 From: Zafar Date: Mon, 16 Dec 2024 13:18:51 +0100 Subject: [PATCH 06/14] fix(e2e): add substring recognition to date node text in EventCreationE2ETest --- .../java/com/android/unio/end2end/EventCreationE2ETest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/androidTest/java/com/android/unio/end2end/EventCreationE2ETest.kt b/app/src/androidTest/java/com/android/unio/end2end/EventCreationE2ETest.kt index 98723ab8d..7ffbcf48a 100644 --- a/app/src/androidTest/java/com/android/unio/end2end/EventCreationE2ETest.kt +++ b/app/src/androidTest/java/com/android/unio/end2end/EventCreationE2ETest.kt @@ -121,7 +121,7 @@ class EventCreationE2ETest : EndToEndTest() { val dateToSelect = LocalDate.of(currentDate.year, currentDate.month, day) val dateString = dateToSelect.format(dateFormatter) - composeTestRule.onNodeWithText(dateString).performClick() + composeTestRule.onNodeWithText(text = dateString, substring = true).performClick() composeTestRule .onNodeWithText(context.getString(R.string.event_creation_dialog_ok)) From 9c5f77af473b59d728ca06339549c09e6d581544 Mon Sep 17 00:00:00 2001 From: Zafar Date: Mon, 16 Dec 2024 16:50:36 +0100 Subject: [PATCH 07/14] chore(event-edit): add clear buttons to title and short description inputs --- .../strings/test_tags/event/EventTestTags.kt | 2 ++ .../com/android/unio/ui/event/EventEdit.kt | 33 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt b/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt index 65d8023ed..0749fe4d6 100644 --- a/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt +++ b/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt @@ -58,7 +58,9 @@ object EventEditTestTags { const val SCREEN = "eventEditScreen" const val TITLE = "eventEditTitle" const val EVENT_TITLE = "eventEditEventTitle" + const val EVENT_TITLE_CLEAR_BUTTON = "eventEditEventTitleClearButton" const val SHORT_DESCRIPTION = "eventEditShortDescription" + const val SHORT_DESCRIPTION_CLEAR_BUTTON = "eventEditShortDescriptionClearButton" const val COAUTHORS = "eventEditCoauthors" const val TAGGED_ASSOCIATIONS = "eventEditTaggedAssociations" const val DESCRIPTION = "eventEditDescription" diff --git a/app/src/main/java/com/android/unio/ui/event/EventEdit.kt b/app/src/main/java/com/android/unio/ui/event/EventEdit.kt index 7f26a2afb..86cfbfe7d 100644 --- a/app/src/main/java/com/android/unio/ui/event/EventEdit.kt +++ b/app/src/main/java/com/android/unio/ui/event/EventEdit.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.outlined.Clear import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Icon @@ -140,13 +141,41 @@ fun EventEditScreen( modifier = Modifier.fillMaxWidth().testTag(EventEditTestTags.EVENT_TITLE), value = name, onValueChange = { name = it }, - label = { Text(context.getString(R.string.event_creation_name_label)) }) + label = { Text(context.getString(R.string.event_creation_name_label)) }, + trailingIcon = { + if (name.isNotEmpty()) { + IconButton( + onClick = { name = "" }, + modifier = Modifier.testTag(EventEditTestTags.EVENT_TITLE_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.event_creation_content_description_clear_title)) + } + } + }) OutlinedTextField( modifier = Modifier.fillMaxWidth().testTag(EventEditTestTags.SHORT_DESCRIPTION), value = shortDescription, onValueChange = { shortDescription = it }, - label = { Text(context.getString(R.string.event_creation_short_description_label)) }) + label = { Text(context.getString(R.string.event_creation_short_description_label)) }, + trailingIcon = { + if (shortDescription.isNotEmpty()) { + IconButton( + onClick = { shortDescription = "" }, + modifier = + Modifier.testTag(EventEditTestTags.SHORT_DESCRIPTION_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string + .event_creation_content_description_clear_short_description)) + } + } + }) BannerImagePicker( eventBannerUri, modifier = Modifier.testTag(EventEditTestTags.EVENT_IMAGE)) From 537cc9f77846f83dc8002b93e266376a133c9974 Mon Sep 17 00:00:00 2001 From: Zafar Date: Mon, 16 Dec 2024 19:00:27 +0100 Subject: [PATCH 08/14] feat(account-details): add clear button to first and last name input fields --- .../authentication/AuthenticationTestTags.kt | 2 ++ .../unio/ui/authentication/AccountDetails.kt | 32 +++++++++++++++++-- app/src/main/res/values-fr/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/android/unio/model/strings/test_tags/authentication/AuthenticationTestTags.kt b/app/src/main/java/com/android/unio/model/strings/test_tags/authentication/AuthenticationTestTags.kt index 0536ab5af..bf8ab87dd 100644 --- a/app/src/main/java/com/android/unio/model/strings/test_tags/authentication/AuthenticationTestTags.kt +++ b/app/src/main/java/com/android/unio/model/strings/test_tags/authentication/AuthenticationTestTags.kt @@ -10,12 +10,14 @@ object AccountDetailsTestTags { const val FIRST_NAME_TEXT = "accountDetailsFirstNameText" const val FIRST_NAME_ERROR_TEXT = "accountDetailsFirstNameErrorText" const val FIRST_NAME_CHARACTER_COUNTER = "accountDetailsFirstNameCharacterCounter" + const val FIRST_NAME_CLEAR_BUTTON = "accountDetailsFirstNameClearButton" // LAST NAME TEXT FIELD const val LAST_NAME_TEXT_FIELD = "accountDetailsLastNameTextField" const val LAST_NAME_TEXT = "accountDetailsLastNameText" const val LAST_NAME_ERROR_TEXT = "accountDetailsLastNameErrorText" const val LAST_NAME_CHARACTER_COUNTER = "accountDetailsLastNameCharacterCounter" + const val LAST_NAME_CLEAR_BUTTON = "accountDetailsLastNameClearButton" // BIOGRAPHY TEXT FIELD const val BIOGRAPHY_TEXT_FIELD = "accountDetailsBioTextField" diff --git a/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt b/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt index 8ff2c93b3..30eef104d 100644 --- a/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt +++ b/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt @@ -15,8 +15,10 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.outlined.Clear import androidx.compose.material3.Button import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold @@ -306,7 +308,20 @@ private fun UserTextFields( onFirstNameChange(it) } }, - value = firstName) + value = firstName, + trailingIcon = { + if (firstName.isNotEmpty()) { + IconButton( + onClick = { onFirstNameChange("") }, + modifier = Modifier.testTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.account_details_content_description_clear_first_name)) + } + } + }) OutlinedTextField( modifier = @@ -340,7 +355,20 @@ private fun UserTextFields( onLastNameChange(it) } }, - value = lastName) + value = lastName, + trailingIcon = { + if (lastName.isNotEmpty()) { + IconButton( + onClick = { onLastNameChange("") }, + modifier = Modifier.testTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.account_details_content_description_clear_last_name)) + } + } + }) OutlinedTextField( modifier = diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 672fc480e..c0f783b12 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -103,6 +103,8 @@ Icône de liens Photo de profile Supprimer la photo de profil + Effacer prénom + Effacer nom Supprimer le compte diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 99310403d..6fb5dc1d9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -109,6 +109,8 @@ Links icon Profile Picture Remove Profile Picture + Clear first name + Clear last name Remove User Social From 68311639f2dea9e2eca0eda98fde4f5a8aade17e Mon Sep 17 00:00:00 2001 From: Zafar Date: Mon, 16 Dec 2024 20:19:41 +0100 Subject: [PATCH 09/14] feat(user-edition): add clear button to first and last name input fields --- .../test_tags/user/UserEditionTestTags.kt | 2 ++ .../unio/ui/user/UserProfileEdition.kt | 31 +++++++++++++++++-- app/src/main/res/values-fr/strings.xml | 4 +-- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/android/unio/model/strings/test_tags/user/UserEditionTestTags.kt b/app/src/main/java/com/android/unio/model/strings/test_tags/user/UserEditionTestTags.kt index 73ad53b61..988e47fcb 100644 --- a/app/src/main/java/com/android/unio/model/strings/test_tags/user/UserEditionTestTags.kt +++ b/app/src/main/java/com/android/unio/model/strings/test_tags/user/UserEditionTestTags.kt @@ -10,12 +10,14 @@ object UserEditionTestTags { const val FIRST_NAME_TEXT = "userSettingsFirstNameText" const val FIRST_NAME_ERROR_TEXT = "userSettingsFirstNameErrorText" const val FIRST_NAME_CHARACTER_COUNTER = "userSettingsFirstNameCharacterCounter" + const val FIRST_NAME_CLEAR_BUTTON = "userSettingsFirstNameClearButton" // LAST NAME TEXT FIELD const val LAST_NAME_TEXT_FIELD = "userSettingsLastNameTextField" const val LAST_NAME_TEXT = "userSettingsLastNameText" const val LAST_NAME_ERROR_TEXT = "userSettingsLastNameErrorText" const val LAST_NAME_CHARACTER_COUNTER = "userSettingsLastNameCharacterCounter" + const val LAST_NAME_CLEAR_BUTTON = "userSettingsLastNameClearButton" // BIOGRAPHY TEXT FIELD const val BIOGRAPHY_TEXT_FIELD = "userSettingsBioTextField" diff --git a/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt b/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt index 4a46c7994..f08af34b6 100644 --- a/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt +++ b/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt @@ -16,6 +16,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.outlined.Clear import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card @@ -406,7 +407,20 @@ private fun EditUserTextFields( onFirstNameChange(it) } }, - value = firstName) + value = firstName, + trailingIcon = { + if (firstName.isNotEmpty()) { + IconButton( + onClick = { onFirstNameChange("") }, + modifier = Modifier.testTag(UserEditionTestTags.FIRST_NAME_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.user_edition_content_description_clear_first_name)) + } + } + }) OutlinedTextField( modifier = Modifier.padding(4.dp).testTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD), @@ -439,7 +453,20 @@ private fun EditUserTextFields( onLastNameChange(it) } }, - value = lastName) + value = lastName, + trailingIcon = { + if (lastName.isNotEmpty()) { + IconButton( + onClick = { onLastNameChange("") }, + modifier = Modifier.testTag(UserEditionTestTags.LAST_NAME_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.user_edition_content_description_clear_last_name)) + } + } + }) OutlinedTextField( modifier = diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index c0f783b12..163c5f26f 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -123,8 +123,8 @@ Annuler vos modifications Sauvegarder vos modifications Changements correctement modifiés - - + Effacer prénom + Effacer nom Échec de l\'actualisation diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6fb5dc1d9..d05f35860 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -129,6 +129,8 @@ Failed to delete account, try again later Deleted user offline Please be connected to the internet to delete your Account + Clear first name + Clear last name From 2d35143f6c2f8f1d915c9c136f0c87acd3da931b Mon Sep 17 00:00:00 2001 From: Zafar Date: Wed, 18 Dec 2024 13:52:05 +0100 Subject: [PATCH 10/14] test(event-creation): add test for clear button functionality --- .../components/event/EventCreationTest.kt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/app/src/androidTest/java/com/android/unio/components/event/EventCreationTest.kt b/app/src/androidTest/java/com/android/unio/components/event/EventCreationTest.kt index f41768120..6a992bdc8 100644 --- a/app/src/androidTest/java/com/android/unio/components/event/EventCreationTest.kt +++ b/app/src/androidTest/java/com/android/unio/components/event/EventCreationTest.kt @@ -1,7 +1,9 @@ package com.android.unio.components.event +import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.isDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag @@ -285,6 +287,48 @@ class EventCreationTest : TearDown() { composeTestRule.onNodeWithTag(EventCreationTestTags.DESCRIPTION).performTextClearance() } + @Test + fun testClearButtonFunctionality() { + nominatimLocationSearchViewModel = + NominatimLocationSearchViewModel(nominatimLocationRepositoryWithoutFunctionality) + composeTestRule.setContent { + EventCreationScreen( + navigationAction, + searchViewModel, + associationViewModel, + eventViewModel, + nominatimLocationSearchViewModel) + } + + composeTestRule.waitForIdle() + + composeTestRule + .onNodeWithTag(EventCreationTestTags.EVENT_TITLE) + .performScrollTo() + .performTextClearance() + composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE).performTextInput("Test Title") + composeTestRule + .onNodeWithTag(EventCreationTestTags.EVENT_TITLE, useUnmergedTree = true) + .assertTextEquals("Test Title", includeEditableText = true) + composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE).assert(hasText("")) + + composeTestRule + .onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION) + .performScrollTo() + .performTextClearance() + composeTestRule + .onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION) + .performTextInput("Test Short Description") + composeTestRule + .onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION, useUnmergedTree = true) + .assertTextEquals("Test Short Description", includeEditableText = true) + composeTestRule + .onNodeWithTag(EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON) + .performClick() + composeTestRule.onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION).assert(hasText("")) + } + @Test fun testLocationInputFunctionality() { server = MockWebServer() From 3a46d1d387c0f05bbabef9b659894821262529d3 Mon Sep 17 00:00:00 2001 From: Zafar Date: Wed, 18 Dec 2024 13:57:09 +0100 Subject: [PATCH 11/14] test(account-details): add test for clear buttons --- .../authentication/AccountDetailsTest.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt b/app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt index 9fee81460..4cc9abe49 100644 --- a/app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt +++ b/app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt @@ -1,8 +1,11 @@ package com.android.unio.components.authentication +import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotDisplayed import androidx.compose.ui.test.assertTextContains +import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performClick @@ -125,6 +128,27 @@ class AccountDetailsTest : TearDown() { .assertTextContains("I am a student") } + @Test + fun testClearButtonFunctionality() { + composeTestRule + .onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD) + .performTextInput("John") + composeTestRule + .onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD, useUnmergedTree = true) + .assertTextEquals("John", includeEditableText = true) + composeTestRule.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD).assert(hasText("")) + + composeTestRule + .onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD) + .performTextInput("Doe") + composeTestRule + .onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD, useUnmergedTree = true) + .assertTextEquals("Doe", includeEditableText = true) + composeTestRule.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD).assert(hasText("")) + } + @Test fun testInterestsButtonWorksCorrectly() { composeTestRule From e7f6c9fea7de31569ebf05a04050c4b3f2b8a73f Mon Sep 17 00:00:00 2001 From: Zafar Date: Wed, 18 Dec 2024 14:04:42 +0100 Subject: [PATCH 12/14] test(user-profile-edition): add tests for clear buttons --- .../components/user/UserProfileEditionTest.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/src/androidTest/java/com/android/unio/components/user/UserProfileEditionTest.kt b/app/src/androidTest/java/com/android/unio/components/user/UserProfileEditionTest.kt index c37d5ad69..31f84a5a6 100644 --- a/app/src/androidTest/java/com/android/unio/components/user/UserProfileEditionTest.kt +++ b/app/src/androidTest/java/com/android/unio/components/user/UserProfileEditionTest.kt @@ -2,8 +2,11 @@ package com.android.unio.components.user import android.net.ConnectivityManager import android.net.Network +import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotDisplayed +import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performClick @@ -313,6 +316,29 @@ class UserProfileEditionTest : TearDown() { composeTestRule.onNodeWithTag(UserEditionTestTags.BIOGRAPHY_TEXT_FIELD).performTextClearance() } + @Test + fun testClearButtonFunctionality() { + composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD).performTextClearance() + composeTestRule + .onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD) + .performTextInput(UserUpdate.FIRST_NAME) + composeTestRule + .onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD, useUnmergedTree = true) + .assertTextEquals(UserUpdate.FIRST_NAME, includeEditableText = true) + composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD).assert(hasText("")) + + composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD).performTextClearance() + composeTestRule + .onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD) + .performTextInput(UserUpdate.LAST_NAME) + composeTestRule + .onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD, useUnmergedTree = true) + .assertTextEquals(UserUpdate.LAST_NAME, includeEditableText = true) + composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD).assert(hasText("")) + } + object UserUpdate { const val FIRST_NAME = "Johnny" const val LAST_NAME = "Däpp" From b416b35a6742790798dc4ee01c1445c72b62e681 Mon Sep 17 00:00:00 2001 From: Zafar Date: Wed, 18 Dec 2024 14:08:45 +0100 Subject: [PATCH 13/14] test(event-edit): add test for clear buttons --- .../unio/components/event/EventEditTests.kt | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/app/src/androidTest/java/com/android/unio/components/event/EventEditTests.kt b/app/src/androidTest/java/com/android/unio/components/event/EventEditTests.kt index 1fdc93883..7aea21ead 100644 --- a/app/src/androidTest/java/com/android/unio/components/event/EventEditTests.kt +++ b/app/src/androidTest/java/com/android/unio/components/event/EventEditTests.kt @@ -1,13 +1,17 @@ package com.android.unio.components.event +import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotEnabled +import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextClearance +import androidx.compose.ui.test.performTextInput import androidx.compose.ui.test.performTextReplacement import com.android.unio.TearDown import com.android.unio.assertDisplayComponentInScroll @@ -285,4 +289,42 @@ class EventEditTests : TearDown() { assert(result.title != mockEvent.title) assert(result.description == mockEvent.description) } + + @Test + fun testClearButtonFunctionality() { + nominatimLocationSearchViewModel = + NominatimLocationSearchViewModel(nominatimLocationRepositoryWithoutFunctionality) + composeTestRule.setContent { + EventEditScreen( + navigationAction, + searchViewModel, + associationViewModel, + eventViewModel, + nominatimLocationSearchViewModel) + } + + composeTestRule + .onNodeWithTag(EventEditTestTags.EVENT_TITLE) + .performScrollTo() + .performTextClearance() + composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE).performTextInput("New Event Title") + composeTestRule + .onNodeWithTag(EventEditTestTags.EVENT_TITLE, useUnmergedTree = true) + .assertTextEquals("New Event Title", includeEditableText = true) + composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE).assert(hasText("")) + + composeTestRule + .onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION) + .performScrollTo() + .performTextClearance() + composeTestRule + .onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION) + .performTextInput("New Short Description") + composeTestRule + .onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION, useUnmergedTree = true) + .assertTextEquals("New Short Description", includeEditableText = true) + composeTestRule.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION).assert(hasText("")) + } } From c8514d74fab26119e222f2627448400f6b5826be Mon Sep 17 00:00:00 2001 From: Zafar Date: Wed, 18 Dec 2024 18:43:17 +0100 Subject: [PATCH 14/14] refactor(clear-buttons): change behavior from hiding to enabling --- .../unio/ui/authentication/AccountDetails.kt | 42 ++++++++-------- .../android/unio/ui/event/EventCreation.kt | 48 +++++++++---------- .../com/android/unio/ui/event/EventEdit.kt | 45 ++++++++--------- .../unio/ui/user/UserProfileEdition.kt | 40 +++++++--------- 4 files changed, 82 insertions(+), 93 deletions(-) diff --git a/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt b/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt index 30eef104d..a85189536 100644 --- a/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt +++ b/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt @@ -310,17 +310,16 @@ private fun UserTextFields( }, value = firstName, trailingIcon = { - if (firstName.isNotEmpty()) { - IconButton( - onClick = { onFirstNameChange("") }, - modifier = Modifier.testTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON)) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = - context.getString( - R.string.account_details_content_description_clear_first_name)) - } - } + IconButton( + onClick = { onFirstNameChange("") }, + enabled = firstName.isNotEmpty(), + modifier = Modifier.testTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.account_details_content_description_clear_first_name)) + } }) OutlinedTextField( @@ -357,17 +356,16 @@ private fun UserTextFields( }, value = lastName, trailingIcon = { - if (lastName.isNotEmpty()) { - IconButton( - onClick = { onLastNameChange("") }, - modifier = Modifier.testTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON)) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = - context.getString( - R.string.account_details_content_description_clear_last_name)) - } - } + IconButton( + onClick = { onLastNameChange("") }, + enabled = lastName.isNotEmpty(), + modifier = Modifier.testTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.account_details_content_description_clear_last_name)) + } }) OutlinedTextField( diff --git a/app/src/main/java/com/android/unio/ui/event/EventCreation.kt b/app/src/main/java/com/android/unio/ui/event/EventCreation.kt index dc4ad1d72..f1721c76b 100644 --- a/app/src/main/java/com/android/unio/ui/event/EventCreation.kt +++ b/app/src/main/java/com/android/unio/ui/event/EventCreation.kt @@ -149,17 +149,16 @@ fun EventCreationScreen( } }, trailingIcon = { - if (name.isNotEmpty()) { - IconButton( - onClick = { name = "" }, - modifier = Modifier.testTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON)) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = - context.getString( - R.string.event_creation_content_description_clear_title)) - } - } + IconButton( + onClick = { name = "" }, + enabled = name.isNotEmpty(), + modifier = Modifier.testTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.event_creation_content_description_clear_title)) + } }) OutlinedTextField( @@ -194,20 +193,19 @@ fun EventCreationScreen( } }, trailingIcon = { - if (shortDescription.isNotEmpty()) { - IconButton( - onClick = { shortDescription = "" }, - modifier = - Modifier.testTag( - EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON)) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = - context.getString( - R.string - .event_creation_content_description_clear_short_description)) - } - } + IconButton( + onClick = { shortDescription = "" }, + enabled = shortDescription.isNotEmpty(), + modifier = + Modifier.testTag( + EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string + .event_creation_content_description_clear_short_description)) + } }) BannerImagePicker( diff --git a/app/src/main/java/com/android/unio/ui/event/EventEdit.kt b/app/src/main/java/com/android/unio/ui/event/EventEdit.kt index c19262714..9247721e7 100644 --- a/app/src/main/java/com/android/unio/ui/event/EventEdit.kt +++ b/app/src/main/java/com/android/unio/ui/event/EventEdit.kt @@ -149,17 +149,16 @@ fun EventEditScreen( onValueChange = { name = it }, label = { Text(context.getString(R.string.event_creation_name_label)) }, trailingIcon = { - if (name.isNotEmpty()) { - IconButton( - onClick = { name = "" }, - modifier = Modifier.testTag(EventEditTestTags.EVENT_TITLE_CLEAR_BUTTON)) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = - context.getString( - R.string.event_creation_content_description_clear_title)) - } - } + IconButton( + onClick = { name = "" }, + enabled = name.isNotEmpty(), + modifier = Modifier.testTag(EventEditTestTags.EVENT_TITLE_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string.event_creation_content_description_clear_title)) + } }) OutlinedTextField( @@ -174,19 +173,17 @@ fun EventEditScreen( onValueChange = { shortDescription = it }, label = { Text(context.getString(R.string.event_creation_short_description_label)) }, trailingIcon = { - if (shortDescription.isNotEmpty()) { - IconButton( - onClick = { shortDescription = "" }, - modifier = - Modifier.testTag(EventEditTestTags.SHORT_DESCRIPTION_CLEAR_BUTTON)) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = - context.getString( - R.string - .event_creation_content_description_clear_short_description)) - } - } + IconButton( + onClick = { shortDescription = "" }, + enabled = shortDescription.isNotEmpty(), + modifier = Modifier.testTag(EventEditTestTags.SHORT_DESCRIPTION_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString( + R.string + .event_creation_content_description_clear_short_description)) + } }) BannerImagePicker( diff --git a/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt b/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt index 49e016644..69a49d0ad 100644 --- a/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt +++ b/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt @@ -408,17 +408,15 @@ private fun EditUserTextFields( }, value = firstName, trailingIcon = { - if (firstName.isNotEmpty()) { - IconButton( - onClick = { onFirstNameChange("") }, - modifier = Modifier.testTag(UserEditionTestTags.FIRST_NAME_CLEAR_BUTTON)) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = - context.getString( - R.string.user_edition_content_description_clear_first_name)) - } - } + IconButton( + onClick = { onFirstNameChange("") }, + enabled = firstName.isNotEmpty(), + modifier = Modifier.testTag(UserEditionTestTags.FIRST_NAME_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString(R.string.user_edition_content_description_clear_first_name)) + } }) OutlinedTextField( @@ -454,17 +452,15 @@ private fun EditUserTextFields( }, value = lastName, trailingIcon = { - if (lastName.isNotEmpty()) { - IconButton( - onClick = { onLastNameChange("") }, - modifier = Modifier.testTag(UserEditionTestTags.LAST_NAME_CLEAR_BUTTON)) { - Icon( - imageVector = Icons.Outlined.Clear, - contentDescription = - context.getString( - R.string.user_edition_content_description_clear_last_name)) - } - } + IconButton( + onClick = { onLastNameChange("") }, + enabled = lastName.isNotEmpty(), + modifier = Modifier.testTag(UserEditionTestTags.LAST_NAME_CLEAR_BUTTON)) { + Icon( + imageVector = Icons.Outlined.Clear, + contentDescription = + context.getString(R.string.user_edition_content_description_clear_last_name)) + } }) OutlinedTextField(