-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
## Explanation Fixes #3821 This PR introduces the following end-user visible changes: - It adds Brazilian Portuguese as an option when selecting a default audio language. - It removes the 'No Audio' option from the list since it's confusing and presently defaults to 'English' when playing audio voiceovers, anyway. - It changes the display names of the default audio languages to be localized to their own locale to make the languages easier to read by native speakers. - It fixes a bug in the tablet version of OptionsActivity wherein switching between audio & reading text would result in fragment stacking (i.e. you could see the bottom of the longer fragment when on the shorter one). This entailed changing fragment 'adds' to 'replaces' for the options fragment transactions. Technical details: - This PR migrates the audio language pattern from using a string over to using the AudioLanguage proto enum, similar to the recent change for ReadingTextSize. This was preferred since changing everywhere to support a localized name of each language seemed non-ideal. - A few models & listeners needed to be split between app & audio languages due to the previous approaching having a lot of codesharing between the two that's no longer applicable with strong types. Exemptions: - AppLanguageResourceHandler is now allowed to use ``Locale`` directly so that it can produce localized display names for each audio language. In the future, this could be moved to MachineLocale maybe. - AppLanguageResourceHandlerTest is now allowed to use parameterized tests. The new parameterized tests that were added are technically violating the principle of now parameterizing the expected output of the test, but these are medium-term tests that will go away when the new language selector is added. - The test file exemptions aren't technically "new" in the sense that they're just preserving the existing exemptions except that the exemptions are now split in the same way as the new app/audio versions of the classes. ## 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 This section will be filled in post-merge (#4567 is tracking ensuring that the description is finished later). Commits: * Add pt-Br as option for default voiceover audio. This also makes some infrastructural improvements, a small UX improvement (removing the 'No Audio' option), and fixed a tablet bug in the options menu. * Update app/src/main/java/org/oppia/android/app/translation/AppLanguageResourceHandler.kt
- Loading branch information
1 parent
52f7a2c
commit 7ff4874
Showing
43 changed files
with
653 additions
and
488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/oppia/android/app/options/AppLanguageItemViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.oppia.android.app.options | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.Transformations | ||
import org.oppia.android.app.viewmodel.ObservableViewModel | ||
|
||
/** | ||
* Language item view model for the recycler view in [AppLanguageFragment] and. | ||
* | ||
* @property language the app language corresponding to this language item to be displayed | ||
* @property currentSelectedLanguage the [LiveData] tracking the currently selected language | ||
* @property appLanguageRadioButtonListener the listener which will be called if this language is | ||
* selected by the user | ||
*/ | ||
class AppLanguageItemViewModel( | ||
val language: String, | ||
private val currentSelectedLanguage: LiveData<String>, | ||
val appLanguageRadioButtonListener: AppLanguageRadioButtonListener | ||
) : ObservableViewModel() { | ||
/** | ||
* Indicates whether the language corresponding to this view model is _currently_ selected in the | ||
* radio button list. | ||
*/ | ||
val isLanguageSelected: LiveData<Boolean> by lazy { | ||
Transformations.map(currentSelectedLanguage) { it == language } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/org/oppia/android/app/options/AppLanguageRadioButtonListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.oppia.android.app.options | ||
|
||
/** Listener for when a language is selected for the [AppLanguageFragment]. */ | ||
interface AppLanguageRadioButtonListener { | ||
/** Called when the user selected a new app language to use as their default preference. */ | ||
fun onLanguageSelected(appLanguage: String) | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/oppia/android/app/options/AppLanguageSelectionViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.oppia.android.app.options | ||
|
||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.MutableLiveData | ||
import org.oppia.android.app.fragment.FragmentScope | ||
import org.oppia.android.app.viewmodel.ObservableViewModel | ||
import javax.inject.Inject | ||
|
||
/** Language list view model for the recycler view in [AppLanguageFragment]. */ | ||
@FragmentScope | ||
class AppLanguageSelectionViewModel @Inject constructor( | ||
val fragment: Fragment | ||
) : ObservableViewModel() { | ||
/** The name of the app language currently selected in the radio button list. */ | ||
val selectedLanguage = MutableLiveData<String>() | ||
private val appLanguageRadioButtonListener = fragment as AppLanguageRadioButtonListener | ||
|
||
private val appLanguagesList = listOf( | ||
AppLanguageItemViewModel("English", selectedLanguage, appLanguageRadioButtonListener), | ||
AppLanguageItemViewModel("French", selectedLanguage, appLanguageRadioButtonListener), | ||
AppLanguageItemViewModel("Hindi", selectedLanguage, appLanguageRadioButtonListener), | ||
AppLanguageItemViewModel("Chinese", selectedLanguage, appLanguageRadioButtonListener) | ||
) | ||
|
||
/** The list of [AppLanguageItemViewModel]s which can be bound to a recycler view. */ | ||
val recyclerViewAppLanguageList: List<AppLanguageItemViewModel> by lazy { appLanguagesList } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.