Skip to content

Commit

Permalink
Merge branch 'develop' into left-align-policy-text-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TanishMoral11 authored Nov 22, 2024
2 parents 220580f + 2f68639 commit 64fca2b
Show file tree
Hide file tree
Showing 26 changed files with 345 additions and 160 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
# Utilities that are primarily used for frontend/UI purposes.
/utility/src/*/java/org/oppia/android/util/accessibility/ @oppia/android-frontend-reviewers
/utility/src/*/java/org/oppia/android/util/statusbar/ @oppia/android-frontend-reviewers
/utility/src/main/java/org/oppia/android/util/enumfilter/ @oppia/android-frontend-reviewers
/utility/src/*/java/org/oppia/android/util/extensions/ @oppia/android-frontend-reviewers
/utility/src/*/java/org/oppia/android/util/parser/html @oppia/android-frontend-reviewers
/utility/src/*/res/**/*.xml @oppia/android-frontend-reviewers
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/comment_coverage_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
check_code_coverage_completed:
name: Check code coverage completed
runs-on: ubuntu-latest
outputs:
conclusion: ${{ steps.wait-for-coverage.outputs.run-conclusion }}
steps:
- name: Wait for code coverage to complete
id: wait-for-coverage
Expand All @@ -27,6 +29,13 @@ jobs:
allowed-conclusions: |
success
failure
action_required
- name: Conclusion Analysis
if: steps.wait-for-coverage.outputs.run-conclusion == 'action_required'
run: |
echo "::error::First-time contributor workflows require manual approval. After approval, please re-run the comment coverage workflows to post the coverage report."
exit 1
comment_coverage_report:
name: Comment Code Coverage Report
Expand Down Expand Up @@ -60,7 +69,7 @@ jobs:
const run = runs[0];
if(!run) {
core.setFailed('Could not find a succesful workflow run for the PR');
core.setFailed('Could not find a successful workflow run for the PR');
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class ExitProfileDialogFragment : InjectableDialogFragment() {
dialog.dismiss()
}
.setPositiveButton(R.string.home_activity_back_dialog_exit) { _, _ ->
// TODO(#3641): Investigate on using finish instead of intent.
val intent = ProfileChooserActivity.createProfileChooserActivity(activity!!)
if (!restoreLastCheckedItem) {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ class AddProfileActivity : InjectableAutoLocalizedAppCompatActivity() {
}

override fun onSupportNavigateUp(): Boolean {
// TODO(#3641): Investigate on using finish instead of intent.
val intent = Intent(this, ProfileChooserActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(intent)
finish()
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.oppia.android.app.survey.PreviousAnswerHandler
import org.oppia.android.app.survey.SelectedAnswerAvailabilityReceiver
import org.oppia.android.app.survey.SelectedAnswerHandler
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.util.enumfilter.filterByEnumCondition
import javax.inject.Inject

/** [SurveyAnswerItemViewModel] for the market fit question options. */
Expand Down Expand Up @@ -98,8 +99,12 @@ class MarketFitItemsViewModel @Inject constructor(
private fun getMarketFitOptions(): ObservableList<MultipleChoiceOptionContentViewModel> {
val appName = resourceHandler.getStringInLocale(R.string.app_name)
val observableList = ObservableArrayList<MultipleChoiceOptionContentViewModel>()
observableList += MarketFitAnswer.values()
.filter { it.isValid() }
val filteredmarketFitAnswer = filterByEnumCondition(
MarketFitAnswer.values().toList(),
{ marketFitAnswer -> marketFitAnswer },
{ marketFitAnswer -> marketFitAnswer.isValid() }
)
observableList += filteredmarketFitAnswer
.mapIndexed { index, marketFitAnswer ->
when (marketFitAnswer) {
MarketFitAnswer.VERY_DISAPPOINTED -> MultipleChoiceOptionContentViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.oppia.android.app.survey.SelectedAnswerAvailabilityReceiver
import org.oppia.android.app.survey.SelectedAnswerHandler
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.viewmodel.ObservableArrayList
import org.oppia.android.util.enumfilter.filterByEnumCondition
import javax.inject.Inject

/** [SurveyAnswerItemViewModel] for providing the type of user question options. */
Expand Down Expand Up @@ -97,46 +98,36 @@ class UserTypeItemsViewModel @Inject constructor(

private fun getUserTypeOptions(): ObservableArrayList<MultipleChoiceOptionContentViewModel> {
val observableList = ObservableArrayList<MultipleChoiceOptionContentViewModel>()
observableList += UserTypeAnswer.values()
.filter { it.isValid() }
.mapIndexed { index, userTypeOption ->
when (userTypeOption) {
UserTypeAnswer.LEARNER ->
MultipleChoiceOptionContentViewModel(
resourceHandler.getStringInLocale(
R.string.user_type_answer_learner
),
index,
this
)
UserTypeAnswer.TEACHER -> MultipleChoiceOptionContentViewModel(
resourceHandler.getStringInLocale(
R.string.user_type_answer_teacher
),
index,
this
)

UserTypeAnswer.PARENT ->
MultipleChoiceOptionContentViewModel(
resourceHandler.getStringInLocale(
R.string.user_type_answer_parent
),
index,
this
)

UserTypeAnswer.OTHER ->
MultipleChoiceOptionContentViewModel(
resourceHandler.getStringInLocale(
R.string.user_type_answer_other
),
index,
this
)
else -> throw IllegalStateException("Invalid UserTypeAnswer")
}
val filteredUserTypes = filterByEnumCondition(
UserTypeAnswer.values().toList(),
{ userTypeAnswer -> userTypeAnswer },
{ userTypeAnswer -> userTypeAnswer.isValid() }
)
observableList += filteredUserTypes.mapIndexed { index, userTypeOption ->
when (userTypeOption) {
UserTypeAnswer.LEARNER -> MultipleChoiceOptionContentViewModel(
resourceHandler.getStringInLocale(R.string.user_type_answer_learner),
index,
this
)
UserTypeAnswer.TEACHER -> MultipleChoiceOptionContentViewModel(
resourceHandler.getStringInLocale(R.string.user_type_answer_teacher),
index,
this
)
UserTypeAnswer.PARENT -> MultipleChoiceOptionContentViewModel(
resourceHandler.getStringInLocale(R.string.user_type_answer_parent),
index,
this
)
UserTypeAnswer.OTHER -> MultipleChoiceOptionContentViewModel(
resourceHandler.getStringInLocale(R.string.user_type_answer_other),
index,
this
)
else -> throw IllegalStateException("Invalid UserTypeAnswer")
}
}
return observableList
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.oppia.android.domain.oppialogger.OppiaLogger
import org.oppia.android.util.accessibility.AccessibilityService
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import org.oppia.android.util.enumfilter.filterByEnumCondition
import javax.inject.Inject

/** The presenter for [TopicLessonsFragment]. */
Expand Down Expand Up @@ -161,18 +162,18 @@ class TopicLessonsFragmentPresenter @Inject constructor(

val chapterSummaries = storySummaryViewModel
.storySummary.chapterList
val completedChapterCount =
chapterSummaries.map(ChapterSummary::getChapterPlayState)
.filter {
it == ChapterPlayState.COMPLETED
}
.size
val completedChapterCount = filterByEnumCondition(
chapterSummaries.map(ChapterSummary::getChapterPlayState),
{ it },
{ it == ChapterPlayState.COMPLETED }
).size

val inProgressChapterCount =
chapterSummaries.map(ChapterSummary::getChapterPlayState)
.filter {
it == ChapterPlayState.IN_PROGRESS_SAVED
}
.size
filterByEnumCondition(
chapterSummaries.map(ChapterSummary::getChapterPlayState),
{ it },
{ it == ChapterPlayState.IN_PROGRESS_SAVED }
).size

val storyPercentage: Int =
(completedChapterCount * 100) / storySummaryViewModel.storySummary.chapterCount
Expand Down
Loading

0 comments on commit 64fca2b

Please sign in to comment.