Skip to content

Commit f98c410

Browse files
subhajitxyzdattasnehaadhiamboperestheMr17Rd4dev
authored
Fix #5612 Talk back is not reading Arabic language in Preferred Audio Language (#5613)
<!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Checklist! --> ## Explanation Fix #5612 This PR includes adding a function languageContentDescription(), which return content description for audioLangueDisplayname Finally, it is set into the content description of the TextView. ## Essential Checklist <!-- Please tick the relevant boxes by putting an "x" in them. --> - [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: ...".) - [ ] 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 <!-- Delete these section if this PR does not include UI-related changes. --> 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: Sneha Datta <[email protected]> Co-authored-by: Adhiambo Peres <[email protected]> Co-authored-by: Mr. 17 <[email protected]> Co-authored-by: RD Rama Devi <[email protected]> Co-authored-by: Ben Henning <[email protected]> Co-authored-by: Tobiloba Oyelekan <[email protected]>
1 parent 8ce374b commit f98c410

File tree

6 files changed

+51
-3
lines changed

6 files changed

+51
-3
lines changed

app/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ VIEW_MODELS_WITH_RESOURCE_IMPORTS = [
215215
"src/main/java/org/oppia/android/app/onboarding/OnboadingSlideViewModel.kt",
216216
"src/main/java/org/oppia/android/app/onboarding/OnboardingViewModel.kt",
217217
"src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicItemViewModel.kt",
218+
"src/main/java/org/oppia/android/app/options/AudioLanguageItemViewModel.kt",
218219
"src/main/java/org/oppia/android/app/options/OptionsReadingTextSizeViewModel.kt",
219220
"src/main/java/org/oppia/android/app/options/TextSizeItemViewModel.kt",
220221
"src/main/java/org/oppia/android/app/parser/FractionParsingUiError.kt",
@@ -310,7 +311,6 @@ VIEW_MODELS = [
310311
"src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListViewModel.kt",
311312
"src/main/java/org/oppia/android/app/options/AppLanguageItemViewModel.kt",
312313
"src/main/java/org/oppia/android/app/options/AppLanguageSelectionViewModel.kt",
313-
"src/main/java/org/oppia/android/app/options/AudioLanguageItemViewModel.kt",
314314
"src/main/java/org/oppia/android/app/options/AudioLanguageSelectionViewModel.kt",
315315
"src/main/java/org/oppia/android/app/options/OptionControlsViewModel.kt",
316316
"src/main/java/org/oppia/android/app/options/OptionsAppLanguageViewModel.kt",

app/src/main/java/org/oppia/android/app/options/AudioLanguageItemViewModel.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package org.oppia.android.app.options
22

33
import androidx.lifecycle.LiveData
44
import androidx.lifecycle.Transformations
5+
import org.oppia.android.R
56
import org.oppia.android.app.model.AudioLanguage
7+
import org.oppia.android.app.translation.AppLanguageResourceHandler
68
import org.oppia.android.app.viewmodel.ObservableViewModel
79

810
/**
@@ -20,7 +22,8 @@ class AudioLanguageItemViewModel(
2022
val language: AudioLanguage,
2123
val languageDisplayName: String,
2224
private val currentSelectedLanguage: LiveData<AudioLanguage>,
23-
val audioLanguageRadioButtonListener: AudioLanguageRadioButtonListener
25+
val audioLanguageRadioButtonListener: AudioLanguageRadioButtonListener,
26+
private val appLanguageResourceHandler: AppLanguageResourceHandler
2427
) : ObservableViewModel() {
2528
/**
2629
* Indicates whether the language corresponding to this view model is _currently_ selected in the
@@ -29,4 +32,16 @@ class AudioLanguageItemViewModel(
2932
val isLanguageSelected: LiveData<Boolean> by lazy {
3033
Transformations.map(currentSelectedLanguage) { it == language }
3134
}
35+
/**
36+
* Returns the content description for the current language. This is used for accessibility
37+
* purposes to provide a readable description of the language in the UI.
38+
*/
39+
fun languageContentDescription(): String {
40+
return when (language) {
41+
AudioLanguage.ARABIC_LANGUAGE -> appLanguageResourceHandler.getStringInLocaleWithWrapping(
42+
R.string.arabic_language_display_name_content_description
43+
)
44+
else -> languageDisplayName
45+
}
46+
}
3247
}

app/src/main/java/org/oppia/android/app/options/AudioLanguageSelectionViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ class AudioLanguageSelectionViewModel @Inject constructor(
128128
language,
129129
appLanguageResourceHandler.computeLocalizedDisplayName(language),
130130
selectedLanguage,
131-
fragment as AudioLanguageRadioButtonListener
131+
fragment as AudioLanguageRadioButtonListener,
132+
appLanguageResourceHandler
132133
)
133134
}
134135

app/src/main/res/layout/audio_language_item.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
android:layout_height="wrap_content"
3939
android:layout_marginEnd="24dp"
4040
android:fontFamily="sans-serif"
41+
android:contentDescription="@{viewModel.languageContentDescription()}"
4142
android:text="@{viewModel.languageDisplayName}"
4243
android:textColor="@color/component_color_shared_primary_text_color"
4344
android:textSize="16sp" />

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,4 +686,8 @@
686686
<string name="audio_language_fragment_text">In %s, you can listen to lessons!</string>
687687
<string name="audio_language_fragment_subtitle">Select the audio language to listen to lessons</string>
688688
<string name="onboarding_step_count_five">STEP 5 OF 5</string>
689+
690+
<!-- AudioLanguageFragment -->
691+
<string name="arabic_language_display_name_content_description">Arabic</string>
692+
689693
</resources>

app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import androidx.test.espresso.matcher.RootMatchers.withDecorView
1717
import androidx.test.espresso.matcher.ViewMatchers.Visibility
1818
import androidx.test.espresso.matcher.ViewMatchers.isChecked
1919
import androidx.test.espresso.matcher.ViewMatchers.isRoot
20+
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
2021
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
2122
import androidx.test.espresso.matcher.ViewMatchers.withId
2223
import androidx.test.espresso.matcher.ViewMatchers.withText
@@ -499,6 +500,32 @@ class AudioLanguageFragmentTest {
499500
}
500501
}
501502

503+
@Test
504+
fun testFragment_withEnglish_verifyContentDescriptionReadsArabicLanguage() {
505+
initializeTestApplicationComponent(enableOnboardingFlowV2 = false)
506+
launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use {
507+
verifyEnglishIsSelected()
508+
509+
onView(
510+
atPositionOnView(
511+
R.id.audio_language_recycler_view,
512+
3,
513+
R.id.language_text_view
514+
)
515+
).check(matches(withText(R.string.arabic_localized_language_name)))
516+
517+
onView(
518+
atPositionOnView(
519+
R.id.audio_language_recycler_view,
520+
3,
521+
R.id.language_text_view
522+
)
523+
).check(
524+
matches(withContentDescription(R.string.arabic_language_display_name_content_description))
525+
)
526+
}
527+
}
528+
502529
private fun launchActivityWithLanguage(
503530
audioLanguage: AudioLanguage
504531
): ActivityScenario<AppLanguageActivity> {

0 commit comments

Comments
 (0)