Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #2132: Chapter List Page Issues #2232

Merged
merged 18 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class StoryViewModel @Inject constructor(
topicId,
storyId,
chapter,
if (index > 0) chapterList.get(index - 1).name else "",
entityType
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class StoryChapterSummaryViewModel(
val topicId: String,
val storyId: String,
val chapterSummary: ChapterSummary,
val previousChapterTitle: String,
val entityType: String
) : StoryItemViewModel() {
val explorationId: String = chapterSummary.explorationId
val name: String = chapterSummary.name
val summary: String = chapterSummary.summary
val chapterThumbnail: LessonThumbnail = chapterSummary.chapterThumbnail
val prerequisiteChapter: ChapterSummary = chapterSummary.prerequisiteChapter

fun onExplorationClicked() {
explorationDataController.stopPlayingExploration()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout-land/story_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:fontFamily="sans-serif"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : String.format(@string/chapter_prerequisite, viewModel.index, viewModel.previousChapterTitle)}"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : @string/chapter_prerequisite_title_label(viewModel.index, viewModel.prerequisiteChapter.name)}"
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
android:textColor="@color/oppiaPrimaryText"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-sw600dp/story_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
android:id="@+id/chapter_thumbnail"
android:layout_width="match_parent"
android:layout_height="0dp"
android:alpha="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? 1.0f : 0.3f}"
android:scaleType="centerInside"
app:entityId="@{viewModel.storyId}"
app:entityType="@{viewModel.entityType}"
Expand Down Expand Up @@ -91,7 +90,7 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:fontFamily="sans-serif"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : String.format(@string/chapter_prerequisite, viewModel.index, viewModel.previousChapterTitle)}"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : @string/chapter_prerequisite_title_label(viewModel.index, viewModel.prerequisiteChapter.name)}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/story_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
android:id="@+id/chapter_thumbnail"
android:layout_width="match_parent"
android:layout_height="0dp"
android:alpha="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? 1.0f : 0.3f}"
android:scaleType="centerInside"
app:entityId="@{viewModel.storyId}"
app:entityType="@{viewModel.entityType}"
Expand Down Expand Up @@ -91,7 +90,7 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:fontFamily="sans-serif"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : String.format(@string/chapter_prerequisite, viewModel.index, viewModel.previousChapterTitle)}"
android:text="@{viewModel.chapterSummary.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? htmlContent : @string/chapter_prerequisite_title_label(viewModel.index, viewModel.prerequisiteChapter.name)}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<string name="topic_play_chapter_index">%s.</string>
<string name="chapter_name">Chapter %s: %s</string>
<string name="chapter_completed">Chapter %s: %s is completed.</string>
<string name="chapter_prerequisite">Complete Chapter <b>%s: %s</b> to unlock this chapter.</string>
<string name="chapter_prerequisite_title_label">Complete <b>Chapter %s: %s</b> 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 @@ -333,24 +333,21 @@ class TopicController @Inject constructor(
if (storyProgress.chapterProgressMap.isNotEmpty()) {
val storyBuilder = storySummary.toBuilder()
storySummary.chapterList.forEachIndexed { chapterIndex, chapterSummary ->
val chapterBuilder = chapterSummary.toBuilder()
if (storyProgress.chapterProgressMap.containsKey(chapterSummary.explorationId)) {
val chapterBuilder = chapterSummary.toBuilder()
chapterBuilder.chapterPlayState =
storyProgress.chapterProgressMap[chapterSummary.explorationId]!!.chapterPlayState
storyBuilder.setChapter(chapterIndex, chapterBuilder)
} else {
if (storyBuilder.getChapter(chapterIndex - 1).chapterPlayState ==
ChapterPlayState.COMPLETED
) {
val chapterBuilder = chapterSummary.toBuilder()
chapterBuilder.chapterPlayState = ChapterPlayState.NOT_STARTED
storyBuilder.setChapter(chapterIndex, chapterBuilder)
} else {
val chapterBuilder = chapterSummary.toBuilder()
chapterBuilder.chapterPlayState = ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES
storyBuilder.setChapter(chapterIndex, chapterBuilder)
chapterBuilder.prerequisiteChapter = storyBuilder.getChapter(chapterIndex - 1)
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
}
}
storyBuilder.setChapter(chapterIndex, chapterBuilder)
}
return storyBuilder.build()
} else {
Expand Down
3 changes: 3 additions & 0 deletions model/src/main/proto/topic.proto
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ message ChapterSummary {

// The thumbnail corresponding to this chapter.
LessonThumbnail chapter_thumbnail = 5;

// Prerequisite chapter to unlock this chapter.
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
ChapterSummary prerequisite_chapter = 6;
}

// A summary of a skill that can be trained or reviewed by the player.
Expand Down