Skip to content

Commit

Permalink
Fix #4648: Fix topic lesson differentiation between locked, completed…
Browse files Browse the repository at this point in the history
… and in-progress lessons (#4958)

<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->
Fix #4648: When this PR is merged, it will fix the issue of locked,
completed and in progress lessons not being differentiated by Talkback.

## 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: ...".)
- [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
<!-- 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))
- Add a screenshot demonstrating that you ran affected Espresso tests
locally & that they're passing
  • Loading branch information
kkmurerwa authored May 9, 2023
1 parent 6778805 commit c5eac6d
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ChapterSummaryViewModel(
val chapterPlayState: ChapterPlayState,
val explorationId: String,
val chapterTitle: String,
val previousChapterTitle: String?,
val storyId: String,
private val index: Int,
private val chapterSummarySelector: ChapterSummarySelector,
Expand All @@ -23,14 +24,28 @@ class ChapterSummaryViewModel(
}

fun computeChapterPlayStateIconContentDescription(): String {
return if (chapterPlayState == ChapterPlayState.COMPLETED) {
resourceHandler.getStringInLocaleWithWrapping(
R.string.chapter_completed, (index + 1).toString(), chapterTitle
)
} else {
resourceHandler.getStringInLocaleWithWrapping(
R.string.chapter_in_progress, (index + 1).toString(), chapterTitle
)
return when (chapterPlayState) {
ChapterPlayState.COMPLETED -> {
resourceHandler.getStringInLocaleWithWrapping(
R.string.chapter_completed, (index + 1).toString(), chapterTitle
)
}
ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES -> {
if (previousChapterTitle != null) {
resourceHandler.getStringInLocaleWithWrapping(
R.string.chapter_prerequisite_title_label, index.toString(), previousChapterTitle
)
} else {
resourceHandler.getStringInLocaleWithWrapping(
R.string.chapter_prerequisite_title_label_without_chapter_title
)
}
}
else -> {
resourceHandler.getStringInLocaleWithWrapping(
R.string.chapter_in_progress, (index + 1).toString(), chapterTitle
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ class StorySummaryViewModel(
ephemeralChapterSummary.chapterSummary.title,
ephemeralChapterSummary.writtenTranslationContext
),
previousChapterTitle = if (index > 0) {
translationController.extractString(
ephemeralStorySummary.chaptersList[index - 1].chapterSummary.title,
ephemeralStorySummary.chaptersList[index - 1].writtenTranslationContext
)
} else null,
storyId = storySummary.storyId,
index = index,
chapterSummarySelector = chapterSummarySelector,
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/lessons_completed_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
android:text="@{viewModel.computePlayChapterIndexText()}"
android:textColor="@color/component_color_shared_secondary_4_text_color"
android:textSize="20sp"
android:contentDescription="@{viewModel.computeChapterPlayStateIconContentDescription()}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand All @@ -48,7 +49,7 @@
android:background="@color/component_color_lessons_tab_activity_lessons_completed_chapter_name_background_color"
android:fontFamily="sans-serif"
android:gravity="center|start"
android:importantForAccessibility="yes"
android:importantForAccessibility="no"
android:minHeight="48dp"
android:paddingStart="12dp"
android:paddingEnd="12dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<string name="chapter_completed">Chapter %s with title %s is completed</string>
<string name="chapter_in_progress">Chapter %s with title %s is in progress</string>
<string name="chapter_prerequisite_title_label">Complete Chapter %s: %s to unlock this chapter.</string>
<string name="chapter_prerequisite_title_label_without_chapter_title">Complete the previous chapter to unlock this chapter.</string>
<string name="text_input_default_content_description">Enter text.</string>
<string name="fractions_default_hint_text">Enter a fraction in the form x/x, or a mixed number in the form x x/x.</string>
<string name="fractions_default_hint_text_no_integer">Enter a fraction in the form x/x.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intended
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
import androidx.test.espresso.intent.matcher.IntentMatchers.hasExtra
import androidx.test.espresso.matcher.ViewMatchers.hasContentDescription
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.isClickable
import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA
Expand Down Expand Up @@ -348,6 +349,29 @@ class TopicLessonsFragmentTest {
}
}

@Test
fun testLessonsPlayFragment_loadRatiosTopic_chapterIsLocked_contentDescriptionIsCorrect() {
launch<TopicActivity>(createTopicActivityIntent(internalProfileId, RATIOS_TOPIC_ID)).use {
clickLessonTab()
clickStoryItem(position = 1, targetViewId = R.id.chapter_list_drop_down_icon)
onView(
atPositionOnView(
recyclerViewId = R.id.chapter_recycler_view,
position = 1,
targetViewId = R.id.chapter_play_state_icon
)
).check(matches(isDisplayed()))
.check(matches(hasContentDescription()))
.check(
matches(
withContentDescription(
"Complete Chapter 1: What is a Ratio? to unlock this chapter."
)
)
)
}
}

@Test
fun testLessonsPlayFragment_loadRatiosTopic_chapterCompletedIsCorrectlyDisplayed() {
storyProgressTestHelper.markCompletedRatiosStory0Exp0(
Expand All @@ -367,6 +391,33 @@ class TopicLessonsFragmentTest {
}
}

@Test
fun testLessonsPlayFragment_loadRatiosTopic_chapterCompleted_contentDescriptionIsCorrect() {
storyProgressTestHelper.markCompletedRatiosStory0Exp0(
profileId,
timestampOlderThanOneWeek = false
)
launch<TopicActivity>(createTopicActivityIntent(internalProfileId, RATIOS_TOPIC_ID)).use {
clickLessonTab()
clickStoryItem(position = 1, targetViewId = R.id.chapter_list_drop_down_icon)
onView(
atPositionOnView(
recyclerViewId = R.id.chapter_recycler_view,
position = 0,
targetViewId = R.id.chapter_index
)
).check(matches(isDisplayed()))
.check(matches(hasContentDescription()))
.check(
matches(
withContentDescription(
"Chapter 1 with title What is a Ratio? is completed"
)
)
)
}
}

@Test
fun testLessonsPlayFragment_loadRatiosTopic_chapterInProgressIsCorrectlyDisplayed() {
fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS)
Expand All @@ -387,6 +438,34 @@ class TopicLessonsFragmentTest {
}
}

@Test
fun testLessonsPlayFragment_loadRatiosTopic_chapterInProgress_contentDescriptionIsCorrect() {
fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS)
storyProgressTestHelper.markInProgressSavedRatiosStory0Exp0(
profileId,
timestampOlderThanOneWeek = false
)
launch<TopicActivity>(createTopicActivityIntent(internalProfileId, RATIOS_TOPIC_ID)).use {
clickLessonTab()
clickStoryItem(position = 1, targetViewId = R.id.chapter_list_drop_down_icon)
onView(
atPositionOnView(
recyclerViewId = R.id.chapter_recycler_view,
position = 0,
targetViewId = R.id.chapter_play_state_icon
)
).check(matches(isDisplayed()))
.check(matches(hasContentDescription()))
.check(
matches(
withContentDescription(
"Chapter 1 with title What is a Ratio? is in progress"
)
)
)
}
}

@Test
fun testLessonsPlayFragment_loadRatiosTopic_configChange_chapterLockedIsCorrectlyDisplayed() {
launch<TopicActivity>(createTopicActivityIntent(internalProfileId, RATIOS_TOPIC_ID)).use {
Expand Down

0 comments on commit c5eac6d

Please sign in to comment.