Skip to content

Commit

Permalink
Revert "Fix #4449: Modify the design of the chapter list in lessons t…
Browse files Browse the repository at this point in the history
…ab (#4535)"

This reverts commit e91de5d.
  • Loading branch information
BenHenning authored Sep 20, 2022
1 parent e91de5d commit 3a98829
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 597 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class HomeFragmentPresenter @Inject constructor(
private val dateTimeUtil: DateTimeUtil,
private val translationController: TranslationController
) {
private val routeToTopicPlayStoryListener = activity as RouteToTopicPlayStoryListener
private val routeToTopicListener = activity as RouteToTopicListener
private lateinit var binding: HomeFragmentBinding
private var internalProfileId: Int = -1

Expand Down Expand Up @@ -149,11 +149,7 @@ class HomeFragmentPresenter @Inject constructor(
}

fun onTopicSummaryClicked(topicSummary: TopicSummary) {
routeToTopicPlayStoryListener.routeToTopicPlayStory(
internalProfileId,
topicSummary.topicId,
topicSummary.firstStoryId
)
routeToTopicListener.routeToTopic(internalProfileId, topicSummary.topicId)
}

private fun logHomeActivityEvent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import org.oppia.android.app.model.StorySummary
import org.oppia.android.app.recyclerview.BindableAdapter
import org.oppia.android.app.topic.RouteToResumeLessonListener
import org.oppia.android.app.topic.RouteToStoryListener
import org.oppia.android.databinding.LessonsCompletedChapterViewBinding
import org.oppia.android.databinding.LessonsInProgressChapterViewBinding
import org.oppia.android.databinding.LessonsLockedChapterViewBinding
import org.oppia.android.databinding.LessonsNotStartedChapterViewBinding
import org.oppia.android.databinding.LessonsChapterViewBinding
import org.oppia.android.databinding.TopicLessonsFragmentBinding
import org.oppia.android.databinding.TopicLessonsStorySummaryBinding
import org.oppia.android.databinding.TopicLessonsTitleBinding
Expand Down Expand Up @@ -227,50 +224,12 @@ class TopicLessonsFragmentPresenter @Inject constructor(
}

private fun createChapterRecyclerViewAdapter(): BindableAdapter<ChapterSummaryViewModel> {
return BindableAdapter.MultiTypeBuilder
.newBuilder<ChapterSummaryViewModel, ChapterViewType> { viewModel ->
when (viewModel.chapterPlayState) {
ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES -> ChapterViewType.CHAPTER_LOCKED
ChapterPlayState.COMPLETED -> ChapterViewType.CHAPTER_COMPLETED
ChapterPlayState.IN_PROGRESS_SAVED, ChapterPlayState.IN_PROGRESS_NOT_SAVED,
ChapterPlayState.STARTED_NOT_COMPLETED, ChapterPlayState.COMPLETION_STATUS_UNSPECIFIED
-> ChapterViewType.CHAPTER_IN_PROGRESS
ChapterPlayState.NOT_STARTED -> ChapterViewType.CHAPTER_NOT_STARTED
ChapterPlayState.UNRECOGNIZED -> throw IllegalArgumentException("Play state unknown")
}
}
.registerViewDataBinder(
viewType = ChapterViewType.CHAPTER_LOCKED,
inflateDataBinding = LessonsLockedChapterViewBinding::inflate,
setViewModel = LessonsLockedChapterViewBinding::setViewModel,
transformViewModel = { it }
)
.registerViewDataBinder(
viewType = ChapterViewType.CHAPTER_COMPLETED,
inflateDataBinding = LessonsCompletedChapterViewBinding::inflate,
setViewModel = LessonsCompletedChapterViewBinding::setViewModel,
transformViewModel = { it }
)
.registerViewDataBinder(
viewType = ChapterViewType.CHAPTER_NOT_STARTED,
inflateDataBinding = LessonsNotStartedChapterViewBinding::inflate,
setViewModel = LessonsNotStartedChapterViewBinding::setViewModel,
transformViewModel = { it }
)
.registerViewDataBinder(
viewType = ChapterViewType.CHAPTER_IN_PROGRESS,
inflateDataBinding = LessonsInProgressChapterViewBinding::inflate,
setViewModel = LessonsInProgressChapterViewBinding::setViewModel,
transformViewModel = { it }
)
.build()
}

private enum class ChapterViewType {
CHAPTER_NOT_STARTED,
CHAPTER_COMPLETED,
CHAPTER_LOCKED,
CHAPTER_IN_PROGRESS
return BindableAdapter.SingleTypeBuilder
.newBuilder<ChapterSummaryViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = LessonsChapterViewBinding::inflate,
setViewModel = LessonsChapterViewBinding::setViewModel
).build()
}

fun storySummaryClicked(storySummary: StorySummary) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 9 additions & 4 deletions app/src/main/res/drawable/ic_baseline_lock_24.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="80dp"
android:height="80dp"
android:tint="#FFFFFF"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z" />
</vector>
8 changes: 4 additions & 4 deletions app/src/main/res/drawable/ic_pending_24dp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:fillColor="#FF333333"
android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8c0,-4.42 3.58,-8 8,-8s8,3.58 8,8C20,16.42 16.42,20 12,20z" />
<path
android:fillColor="#FFFFFF"
android:fillColor="#FF333333"
android:pathData="M7,12m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0" />
<path
android:fillColor="#FFFFFF"
android:fillColor="#FF333333"
android:pathData="M12,12m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0" />
<path
android:fillColor="#FFFFFF"
android:fillColor="#FF333333"
android:pathData="M17,12m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:contentDescription="@{viewModel.computeProgressContainerContentDescription()}"
android:gravity="center"
android:contentDescription="@{viewModel.computeProgressContainerContentDescription()}"
android:orientation="vertical">

<FrameLayout
Expand Down Expand Up @@ -141,37 +141,37 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:contentDescription="@{isListExpanded ? @string/hide_chapter_list : @string/show_chapter_list}"
app:srcCompat="@drawable/ic_arrow_drop_down_black_24dp"
app:isRotationAnimationClockwise="@{isListExpanded}"
app:rotationAnimationAngle="@{180f}"
app:srcCompat="@drawable/ic_arrow_drop_down_black_24dp" />
app:rotationAnimationAngle="@{180f}" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
<!-- FrameLayout is used here instead of LinearLayout to properly adjust the spacing of the
dashed divider by allowing the divider to render slightly on top of the container. -->
<FrameLayout

<LinearLayout
android:id="@+id/chapter_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_def_white_light"
android:orientation="vertical"
android:visibility="@{isListExpanded? View.VISIBLE : View.GONE}">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/chapter_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:list="@{viewModel.chapterSummaryItemList}" />

<View
android:id="@+id/topic_play_story_dashed_line_view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/dashed_divider" />
</FrameLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/chapter_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:list="@{viewModel.chapterSummaryItemList}" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>
Expand Down
64 changes: 64 additions & 0 deletions app/src/main/res/layout/lessons_chapter_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<import type="android.view.View" />

<import type="org.oppia.android.app.model.ChapterPlayState" />

<variable
name="viewModel"
type="org.oppia.android.app.topic.lessons.ChapterSummaryViewModel" />
</data>

<LinearLayout
android:id="@+id/chapter_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="@{viewModel.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? true : false}"
android:minHeight="48dp"
android:onClick="@{() -> viewModel.onClick(viewModel.explorationId)}"
android:orientation="horizontal"
android:paddingStart="4dp"
android:paddingTop="4dp"
android:paddingEnd="4dp">

<ImageView
android:id="@+id/chapter_play_state_icon"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
app:srcCompat="@{viewModel.chapterPlayState == ChapterPlayState.COMPLETED?@drawable/ic_check_24dp:@drawable/ic_pending_24dp}"
android:visibility="@{(viewModel.chapterPlayState == ChapterPlayState.COMPLETED || viewModel.chapterPlayState == ChapterPlayState.IN_PROGRESS_SAVED)?View.VISIBLE : View.INVISIBLE}" />

<TextView
android:id="@+id/chapter_index"
style="@style/TextViewStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:fontFamily="sans-serif"
android:importantForAccessibility="@{viewModel.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO}"
android:text="@{viewModel.computePlayChapterIndexText()}"
android:textColor="@{viewModel.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? @color/oppia_primary_text : @color/oppia_primary_text_30}"
android:textSize="14sp" />

<TextView
android:id="@+id/chapter_name"
style="@style/TextViewStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="28dp"
android:fontFamily="sans-serif"
android:importantForAccessibility="@{viewModel.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO}"
android:contentDescription="@{viewModel.computeChapterPlayStateIconContentDescription()}"
android:text="@{viewModel.chapterTitle}"
android:textColor="@{viewModel.chapterPlayState != ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES ? @color/oppia_primary_text : @color/oppia_primary_text_30}"
android:textSize="14sp" />
</LinearLayout>
</layout>
70 changes: 0 additions & 70 deletions app/src/main/res/layout/lessons_completed_chapter_view.xml

This file was deleted.

Loading

0 comments on commit 3a98829

Please sign in to comment.