From 83f535648118870b728e5de7d2994c8dfcec9839 Mon Sep 17 00:00:00 2001 From: "Mr. 17" Date: Thu, 8 Aug 2024 23:43:02 +0530 Subject: [PATCH] Fix part of #5344: Fix Localization Issues of Classroom List Screen (#5479) ## Explanation Fixes part of #5344 This PR fixes the localization issues of the promoted stories' header and the classroom carousel. ## Screenshots |Portrait|Landscape| |--|--| |![image](https://github.com/user-attachments/assets/9cc3dbec-f5f7-4ae6-bb42-4bb4c9d5126b)|![image](https://github.com/user-attachments/assets/51947734-a6c7-4a36-80a9-21849e4dfa90)| |![image](https://github.com/user-attachments/assets/6774a2a8-2487-410b-8a97-60260d459b97)|![image](https://github.com/user-attachments/assets/2371f5a4-cfa7-429d-bc1b-47387825decc)| ## Essential Checklist - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only If your PR includes UI-related changes, then: - Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes - For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see [RTL guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing --------- Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com> --- .../classroom/classroomlist/ClassroomList.kt | 4 +- .../promotedlist/PromotedStoryList.kt | 63 ++++++++++--------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/classroom/classroomlist/ClassroomList.kt b/app/src/main/java/org/oppia/android/app/classroom/classroomlist/ClassroomList.kt index 23554bad74d..5a5db784fec 100644 --- a/app/src/main/java/org/oppia/android/app/classroom/classroomlist/ClassroomList.kt +++ b/app/src/main/java/org/oppia/android/app/classroom/classroomlist/ClassroomList.kt @@ -8,7 +8,6 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width @@ -52,8 +51,7 @@ fun ClassroomList( .testTag(CLASSROOM_LIST_TEST_TAG) .background( color = colorResource(id = R.color.component_color_shared_screen_primary_background_color) - ) - .fillMaxWidth(), + ), contentPadding = PaddingValues( start = dimensionResource(id = R.dimen.classrooms_text_margin_start), top = dimensionResource(id = R.dimen.classrooms_text_margin_bottom), diff --git a/app/src/main/java/org/oppia/android/app/classroom/promotedlist/PromotedStoryList.kt b/app/src/main/java/org/oppia/android/app/classroom/promotedlist/PromotedStoryList.kt index 55e59672d18..ba9fcc32e13 100644 --- a/app/src/main/java/org/oppia/android/app/classroom/promotedlist/PromotedStoryList.kt +++ b/app/src/main/java/org/oppia/android/app/classroom/promotedlist/PromotedStoryList.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.background 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 import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row @@ -52,40 +53,46 @@ fun PromotedStoryList( promotedStoryListViewModel: PromotedStoryListViewModel, machineLocale: OppiaLocale.MachineLocale, ) { - Row( - modifier = Modifier - .testTag(PROMOTED_STORY_LIST_HEADER_TEST_TAG) - .fillMaxWidth() - .padding( - start = dimensionResource(id = R.dimen.promoted_story_list_layout_margin_start), - top = dimensionResource(id = R.dimen.promoted_story_list_layout_margin_top), - end = dimensionResource(id = R.dimen.promoted_story_list_layout_margin_end), - ), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, + Box( + contentAlignment = Alignment.Center, ) { - Text( - text = promotedStoryListViewModel.getHeader(), - color = colorResource(id = R.color.component_color_classroom_shared_header_text_color), - fontFamily = FontFamily.SansSerif, - fontWeight = FontWeight.Normal, - fontSize = dimensionResource(id = R.dimen.promoted_story_list_header_text_size).value.sp, + Row( modifier = Modifier - .weight(weight = 1f, fill = false), - ) - if (promotedStoryListViewModel.getViewAllButtonVisibility() == View.VISIBLE) { + .testTag(PROMOTED_STORY_LIST_HEADER_TEST_TAG) + .fillMaxWidth() + .padding( + start = dimensionResource(id = R.dimen.promoted_story_list_layout_margin_start), + top = dimensionResource(id = R.dimen.promoted_story_list_layout_margin_top), + end = dimensionResource(id = R.dimen.promoted_story_list_layout_margin_end), + ), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { Text( - text = machineLocale.run { stringResource(id = R.string.view_all).toMachineUpperCase() }, - color = colorResource(id = R.color.component_color_home_activity_view_all_text_color), + text = promotedStoryListViewModel.getHeader(), + color = colorResource(id = R.color.component_color_classroom_shared_header_text_color), fontFamily = FontFamily.SansSerif, - fontWeight = FontWeight.Medium, - fontSize = dimensionResource(id = R.dimen.promoted_story_list_view_all_text_size).value.sp, + fontWeight = FontWeight.Normal, + fontSize = dimensionResource(id = R.dimen.promoted_story_list_header_text_size).value.sp, modifier = Modifier - .padding( - start = dimensionResource(id = R.dimen.promoted_story_list_view_all_padding_start) - ) - .clickable { promotedStoryListViewModel.clickOnViewAll() }, + .weight(weight = 1f, fill = false), ) + if (promotedStoryListViewModel.getViewAllButtonVisibility() == View.VISIBLE) { + Text( + text = machineLocale.run { stringResource(id = R.string.view_all).toMachineUpperCase() }, + color = colorResource(id = R.color.component_color_home_activity_view_all_text_color), + fontFamily = FontFamily.SansSerif, + fontWeight = FontWeight.Medium, + fontSize = dimensionResource( + id = R.dimen.promoted_story_list_view_all_text_size + ).value.sp, + modifier = Modifier + .padding( + start = dimensionResource(id = R.dimen.promoted_story_list_view_all_padding_start) + ) + .clickable { promotedStoryListViewModel.clickOnViewAll() }, + ) + } } } LazyRow(