Skip to content

Commit

Permalink
Merge branch 'onboarding-language-domain-config' into onboarding-prof…
Browse files Browse the repository at this point in the history
…ile-domain-config
  • Loading branch information
adhiamboperes committed Sep 10, 2024
2 parents 73105a0 + fac0a95 commit 1a4d82d
Show file tree
Hide file tree
Showing 45 changed files with 771 additions and 128 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ jobs:
evaluate_code_coverage_reports:
name: Evaluate Code Coverage Reports
runs-on: ubuntu-20.04
needs: code_coverage_run
needs: [ check_unit_tests_completed, code_coverage_run ]
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
if: ${{ !cancelled() && needs.check_unit_tests_completed.result == 'success'}}
env:
CACHE_DIRECTORY: ~/.bazel_cache
steps:
Expand Down Expand Up @@ -311,12 +311,16 @@ jobs:
# Reference: https://github.community/t/127354/7.
check_coverage_results:
name: Check Code Coverage Results
needs: [ compute_changed_files, code_coverage_run, evaluate_code_coverage_reports ]
needs: [ check_unit_tests_completed, compute_changed_files, code_coverage_run, evaluate_code_coverage_reports ]
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
runs-on: ubuntu-20.04
steps:
- name: Check unit tests passed
if: ${{ needs.check_unit_tests_completed.result != 'success' }}
run: exit 1

- name: Check coverages passed
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && needs.code_coverage_run.result != 'success' }}
run: exit 1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/comment_coverage_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
name: Comment Coverage Report

# Controls when the action will run. Triggers the workflow on pull request events
# (assigned, opened, synchronize, reopened)
# (opened, synchronize, reopened)

on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ jobs:
CACHE_DIRECTORY: ~/.bazel_cache
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
Expand Down Expand Up @@ -205,6 +207,15 @@ jobs:
run: |
bazel run //scripts:string_resource_validation_check -- $(pwd)
- name: Binary files check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bash /home/runner/work/oppia-android/oppia-android/scripts/pre-commit.sh
echo "No binary files found in commit"
echo "BINARY FILES CHECK PASSED"
# Note that caching is intentionally not enabled for this check since licenses should always be
# verified without any potential influence from earlier builds (i.e. always from a clean build to
# ensure the results exactly match the current state of the repository).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.oppia.android.app.model.HintsAndSolutionDialogFragmentStateBundle
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.State
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.topic.conceptcard.ConceptCardFragment
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.extensions.putProto
import javax.inject.Inject
Expand Down Expand Up @@ -192,4 +193,12 @@ class HintsAndSolutionDialogFragment :
isSolutionRevealed
)
}

/**
* Delegates the removal of all [ConceptCardFragment] instances
* to the [hintsAndSolutionDialogFragmentPresenter].
*/
fun dismissConceptCard() {
hintsAndSolutionDialogFragmentPresenter.dismissConceptCard()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,9 @@ class HintsAndSolutionDialogFragmentPresenter @Inject constructor(
override fun onConceptCardLinkClicked(view: View, skillId: String) {
ConceptCardFragment.bringToFrontOrCreateIfNew(skillId, profileId, fragment.childFragmentManager)
}

/** Removes all [ConceptCardFragment] in the given FragmentManager. */
fun dismissConceptCard() {
ConceptCardFragment.dismissAll(fragment.childFragmentManager)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class OnboardingAppLanguageViewModel @Inject constructor() : ObservableViewModel
private val _languageSelectionLiveData = MutableLiveData<OppiaLanguage>()

/** Get the list of app supported languages to be displayed in the language dropdown. */
val supportedAppLanguagesList: LiveData<List<String>> get() = _supportedAppLanguagesList
private val _supportedAppLanguagesList = MutableLiveData<List<String>>()
val supportedAppLanguagesList: LiveData<List<OppiaLanguage>> get() = _supportedAppLanguagesList
private val _supportedAppLanguagesList = MutableLiveData<List<OppiaLanguage>>()

/** Sets the app language selection. */
fun setSystemLanguageLivedata(language: OppiaLanguage) {
_languageSelectionLiveData.value = language
}

/** Sets the list of app supported languages to be displayed in the language dropdown. */
fun setSupportedAppLanguages(languageList: List<String>) {
fun setSupportedAppLanguages(languageList: List<OppiaLanguage>) {
_supportedAppLanguagesList.value = languageList
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class OnboardingFragmentPresenter @Inject constructor(
fragment.requireContext(),
R.layout.onboarding_language_dropdown_item,
R.id.onboarding_language_text_view,
languagesList
languagesList.map { appLanguageResourceHandler.computeLocalizedDisplayName(it) }
)
onboardingLanguageDropdown.setAdapter(adapter)
}
Expand Down Expand Up @@ -205,9 +205,7 @@ class OnboardingFragmentPresenter @Inject constructor(
{ result ->
when (result) {
is AsyncResult.Success -> {
onboardingAppLanguageViewModel.setSupportedAppLanguages(
result.value.map { appLanguageResourceHandler.computeLocalizedDisplayName(it) }
)
onboardingAppLanguageViewModel.setSupportedAppLanguages(result.value)
}
is AsyncResult.Failure -> {
oppiaLogger.e(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class AppLanguageFragment : InjectableFragment(), AppLanguageRadioButtonListener
}
}

private fun Bundle.retrieveLanguageFromArguments(): OppiaLanguage {
/** Returns the [OppiaLanguage] stored in the fragment's arguments. */
fun Bundle.retrieveLanguageFromArguments(): OppiaLanguage {
return getProto(
FRAGMENT_ARGUMENTS_KEY, AppLanguageFragmentArguments.getDefaultInstance()
).oppiaLanguage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class AudioLanguageFragment : InjectableFragment(), AudioLanguageRadioButtonList
}
}

private fun Bundle.retrieveLanguageFromArguments(): AudioLanguage {
/** Returns the [AudioLanguage] stored in the fragment's arguments. */
fun Bundle.retrieveLanguageFromArguments(): AudioLanguage {
return getProto(
FRAGMENT_ARGUMENTS_KEY, AudioLanguageFragmentArguments.getDefaultInstance()
).audioLanguage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ class ExplorationActivity :
this.writtenTranslationContext = writtenTranslationContext
}

override fun dismissConceptCard() = explorationActivityPresenter.dismissConceptCard()
override fun dismissConceptCard() {
getHintsAndSolution()?.dismissConceptCard()
}

override fun requestVoiceOverIconSpotlight(numberOfLogins: Int) {
explorationActivityPresenter.requestVoiceOverIconSpotlight(numberOfLogins)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,6 @@ class ExplorationActivityPresenter @Inject constructor(
showDialogFragmentBasedOnCurrentCheckpointState()
}

fun dismissConceptCard() {
getExplorationFragment()?.dismissConceptCard()
}

private fun updateToolbarTitle(explorationId: String) {
subscribeToExploration(
explorationDataController.getExplorationById(profileId, explorationId).toLiveData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,5 @@ class ExplorationFragment : InjectableFragment() {
explorationFragmentPresenter.viewSolution()
}

fun dismissConceptCard() = explorationFragmentPresenter.dismissConceptCard()

fun getExplorationCheckpointState() = explorationFragmentPresenter.getExplorationCheckpointState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ class ExplorationFragmentPresenter @Inject constructor(
getStateFragment()?.viewSolution()
}

fun dismissConceptCard() = getStateFragment()?.dismissConceptCard()

fun getExplorationCheckpointState() = getStateFragment()?.getExplorationCheckpointState()

private fun getStateFragment(): StateFragment? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ class StateFragment :
stateFragmentPresenter.viewSolution()
}

fun dismissConceptCard() = stateFragmentPresenter.dismissConceptCard()

fun getExplorationCheckpointState() = stateFragmentPresenter.getExplorationCheckpointState()

override fun onSaveInstanceState(outState: Bundle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import org.oppia.android.app.player.state.listener.RouteToHintsAndSolutionListen
import org.oppia.android.app.player.stopplaying.StopStatePlayingSessionWithSavedProgressListener
import org.oppia.android.app.survey.SurveyWelcomeDialogFragment
import org.oppia.android.app.survey.TAG_SURVEY_WELCOME_DIALOG
import org.oppia.android.app.topic.conceptcard.ConceptCardFragment
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.utility.SplitScreenManager
import org.oppia.android.app.utility.lifecycle.LifecycleSafeTimerFactory
Expand Down Expand Up @@ -428,10 +427,6 @@ class StateFragmentPresenter @Inject constructor(
subscribeToAnswerOutcome(explorationProgressController.submitAnswer(answer).toLiveData())
}

fun dismissConceptCard() {
ConceptCardFragment.dismissAll(fragment.childFragmentManager)
}

private fun moveToNextState() {
stateViewModel.setCanSubmitAnswer(canSubmitAnswer = false)
explorationProgressController.moveToNextState().toLiveData().observe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ConceptCardFragmentTestActivity :
}

override fun dismissConceptCard() {
getConceptCardFragment()?.dismiss()
ConceptCardFragment.dismissAll(supportFragmentManager)
}

private fun getConceptCardFragment(): ConceptCardFragment? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ class QuestionPlayerActivityPresenter @Inject constructor(
getHintsAndSolutionDialogFragment()?.dismiss()
}

fun dismissConceptCard() = getQuestionPlayerFragment()?.dismissConceptCard()
fun dismissConceptCard() {
getHintsAndSolutionDialogFragment()?.dismissConceptCard()
}

private fun getHintsAndSolutionDialogFragment(): HintsAndSolutionDialogFragment? {
return activity.supportFragmentManager.findFragmentByTag(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ class QuestionPlayerFragment :
questionPlayerFragmentPresenter.revealSolution()
}

fun dismissConceptCard() = questionPlayerFragmentPresenter.dismissConceptCard()

companion object {

/** Arguments key for [QuestionPlayerFragment]. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.oppia.android.app.player.state.StatePlayerRecyclerViewAssembler
import org.oppia.android.app.player.state.listener.RouteToHintsAndSolutionListener
import org.oppia.android.app.player.stopplaying.RestartPlayingSessionListener
import org.oppia.android.app.player.stopplaying.StopStatePlayingSessionListener
import org.oppia.android.app.topic.conceptcard.ConceptCardFragment
import org.oppia.android.app.utility.FontScaleConfigurationUtil
import org.oppia.android.app.utility.SplitScreenManager
import org.oppia.android.databinding.QuestionPlayerFragmentBinding
Expand Down Expand Up @@ -124,10 +123,6 @@ class QuestionPlayerFragmentPresenter @Inject constructor(
subscribeToHintSolution(questionAssessmentProgressController.submitSolutionIsRevealed())
}

fun dismissConceptCard() {
ConceptCardFragment.dismissAll(fragment.childFragmentManager)
}

private fun retrieveArguments(): QuestionPlayerFragmentArguments {
return fragment.requireArguments().getProto(
QuestionPlayerFragment.ARGUMENTS_KEY, QuestionPlayerFragmentArguments.getDefaultInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,33 +186,11 @@ class AppLanguageResourceHandler @Inject constructor(
}
}

/**
* Returns an [OppiaLanguage] from its human-readable, localized representation.
* It is expected that each input string is localized to the user's current locale, as per
* [computeLocalizedDisplayName].
*/
fun getOppiaLanguageFromDisplayName(displayName: String): OppiaLanguage {
val localizedNameMap = OppiaLanguage.values()
.filter { it !in IGNORED_OPPIA_LANGUAGES }
.associateBy { computeLocalizedDisplayName(it) }
return localizedNameMap[displayName] ?: OppiaLanguage.ENGLISH
}

private fun getLocalizedDisplayName(languageCode: String, regionCode: String = ""): String {
// TODO(#3791): Remove this dependency.
val locale = Locale(languageCode, regionCode)
return locale.getDisplayLanguage(locale).replaceFirstChar {
if (it.isLowerCase()) it.titlecase(locale) else it.toString()
}
}

private companion object {
private val IGNORED_AUDIO_LANGUAGES =
listOf(
AudioLanguage.NO_AUDIO, AudioLanguage.AUDIO_LANGUAGE_UNSPECIFIED, AudioLanguage.UNRECOGNIZED
)

private val IGNORED_OPPIA_LANGUAGES =
listOf(OppiaLanguage.LANGUAGE_UNSPECIFIED, OppiaLanguage.UNRECOGNIZED)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ class TextInputLayoutBindingAdaptersTest {
}
}

@Test
fun testBindingAdapters_setSelection_arabicLanguage_setsSelectionCorrectly() {
launchActivity().use { scenario ->
scenario?.onActivity { activity ->
val testView: AutoCompleteTextView = activity.findViewById(R.id.test_autocomplete_view)
TextInputLayoutBindingAdapters.setLanguageSelection(testView, OppiaLanguage.ARABIC, true)
assertThat(testView.text.toString()).isEqualTo(
context.getString(R.string.arabic_localized_language_name)
)
}
}
}

private fun launchActivity():
ActivityScenario<TextInputLayoutBindingAdaptersTestActivity>? {
val scenario = ActivityScenario.launch<TextInputLayoutBindingAdaptersTestActivity>(
Expand Down
Loading

0 comments on commit 1a4d82d

Please sign in to comment.