Skip to content

Commit

Permalink
Fix #5612 Talk back is not reading Arabic language in Preferred Audio…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
7 people authored Jan 22, 2025
1 parent 8ce374b commit f98c410
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ VIEW_MODELS_WITH_RESOURCE_IMPORTS = [
"src/main/java/org/oppia/android/app/onboarding/OnboadingSlideViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/OnboardingViewModel.kt",
"src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicItemViewModel.kt",
"src/main/java/org/oppia/android/app/options/AudioLanguageItemViewModel.kt",
"src/main/java/org/oppia/android/app/options/OptionsReadingTextSizeViewModel.kt",
"src/main/java/org/oppia/android/app/options/TextSizeItemViewModel.kt",
"src/main/java/org/oppia/android/app/parser/FractionParsingUiError.kt",
Expand Down Expand Up @@ -310,7 +311,6 @@ VIEW_MODELS = [
"src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListViewModel.kt",
"src/main/java/org/oppia/android/app/options/AppLanguageItemViewModel.kt",
"src/main/java/org/oppia/android/app/options/AppLanguageSelectionViewModel.kt",
"src/main/java/org/oppia/android/app/options/AudioLanguageItemViewModel.kt",
"src/main/java/org/oppia/android/app/options/AudioLanguageSelectionViewModel.kt",
"src/main/java/org/oppia/android/app/options/OptionControlsViewModel.kt",
"src/main/java/org/oppia/android/app/options/OptionsAppLanguageViewModel.kt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package org.oppia.android.app.options

import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
import org.oppia.android.R
import org.oppia.android.app.model.AudioLanguage
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.viewmodel.ObservableViewModel

/**
Expand All @@ -20,7 +22,8 @@ class AudioLanguageItemViewModel(
val language: AudioLanguage,
val languageDisplayName: String,
private val currentSelectedLanguage: LiveData<AudioLanguage>,
val audioLanguageRadioButtonListener: AudioLanguageRadioButtonListener
val audioLanguageRadioButtonListener: AudioLanguageRadioButtonListener,
private val appLanguageResourceHandler: AppLanguageResourceHandler
) : ObservableViewModel() {
/**
* Indicates whether the language corresponding to this view model is _currently_ selected in the
Expand All @@ -29,4 +32,16 @@ class AudioLanguageItemViewModel(
val isLanguageSelected: LiveData<Boolean> by lazy {
Transformations.map(currentSelectedLanguage) { it == language }
}
/**
* Returns the content description for the current language. This is used for accessibility
* purposes to provide a readable description of the language in the UI.
*/
fun languageContentDescription(): String {
return when (language) {
AudioLanguage.ARABIC_LANGUAGE -> appLanguageResourceHandler.getStringInLocaleWithWrapping(
R.string.arabic_language_display_name_content_description
)
else -> languageDisplayName
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ class AudioLanguageSelectionViewModel @Inject constructor(
language,
appLanguageResourceHandler.computeLocalizedDisplayName(language),
selectedLanguage,
fragment as AudioLanguageRadioButtonListener
fragment as AudioLanguageRadioButtonListener,
appLanguageResourceHandler
)
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/audio_language_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:fontFamily="sans-serif"
android:contentDescription="@{viewModel.languageContentDescription()}"
android:text="@{viewModel.languageDisplayName}"
android:textColor="@color/component_color_shared_primary_text_color"
android:textSize="16sp" />
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -686,4 +686,8 @@
<string name="audio_language_fragment_text">In %s, you can listen to lessons!</string>
<string name="audio_language_fragment_subtitle">Select the audio language to listen to lessons</string>
<string name="onboarding_step_count_five">STEP 5 OF 5</string>

<!-- AudioLanguageFragment -->
<string name="arabic_language_display_name_content_description">Arabic</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.test.espresso.matcher.RootMatchers.withDecorView
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.isChecked
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
Expand Down Expand Up @@ -499,6 +500,32 @@ class AudioLanguageFragmentTest {
}
}

@Test
fun testFragment_withEnglish_verifyContentDescriptionReadsArabicLanguage() {
initializeTestApplicationComponent(enableOnboardingFlowV2 = false)
launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use {
verifyEnglishIsSelected()

onView(
atPositionOnView(
R.id.audio_language_recycler_view,
3,
R.id.language_text_view
)
).check(matches(withText(R.string.arabic_localized_language_name)))

onView(
atPositionOnView(
R.id.audio_language_recycler_view,
3,
R.id.language_text_view
)
).check(
matches(withContentDescription(R.string.arabic_language_display_name_content_description))
)
}
}

private fun launchActivityWithLanguage(
audioLanguage: AudioLanguage
): ActivityScenario<AppLanguageActivity> {
Expand Down

0 comments on commit f98c410

Please sign in to comment.