Skip to content

Commit

Permalink
Fix #1666: Lowfi update for Profile Progress (#1669)
Browse files Browse the repository at this point in the history
* Lowfi update

* Nit change

Co-authored-by: Rajat Talesra <[email protected]>
  • Loading branch information
rt4914 and Rajat Talesra authored Aug 17, 2020
1 parent d3c7258 commit 31152c5
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class ProfileProgressViewModel @Inject constructor(
private var internalProfileId: Int = -1
private lateinit var profileId: ProfileId
private var limit: Int = 0
private var subset: Int = 0

private val headerViewModel = ProfileProgressHeaderViewModel(activity, fragment)

Expand Down Expand Up @@ -97,7 +96,6 @@ class ProfileProgressViewModel @Inject constructor(
*/
fun handleOnConfigurationChange() {
limit = fragment.resources.getInteger(R.integer.profile_progress_limit)
subset = fragment.resources.getInteger(R.integer.profile_progress_subset)
refreshedOngoingStoryListViewModelLiveData =
Transformations.map(ongoingStoryListLiveData, ::processOngoingStoryList) as MutableLiveData
}
Expand All @@ -119,9 +117,8 @@ class ProfileProgressViewModel @Inject constructor(
ongoingStoryList: OngoingStoryList
): List<ProfileProgressItemViewModel> {
limit = fragment.resources.getInteger(R.integer.profile_progress_limit)
subset = fragment.resources.getInteger(R.integer.profile_progress_subset)
val itemList = if (ongoingStoryList.recentStoryList.size > limit) {
ongoingStoryList.recentStoryList.subList(0, subset)
ongoingStoryList.recentStoryList.subList(0, limit)
} else {
ongoingStoryList.recentStoryList
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,84 +14,79 @@
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="96dp"
android:layout_marginTop="28dp"
android:layout_marginEnd="96dp"
android:background="@drawable/grey_card_rounded_border"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="4dp"
app:cardElevation="4dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true">

<org.oppia.app.customview.LessonThumbnailImageView
android:id="@+id/lesson_thumbnail"
android:layout_width="80dp"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:contentDescription="@{@string/lesson_thumbnail_content_description(viewModel.promotedStory.nextChapterName)}"
android:scaleType="centerInside"
android:importantForAccessibility="no"
android:scaleType="fitCenter"
app:entityId="@{viewModel.promotedStory.storyId}"
app:entityType="@{viewModel.entityType}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="16:9"
app:layout_constraintDimensionRatio="4:3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lessonThumbnail="@{viewModel.promotedStory.lessonThumbnail}"
app:roundedRectDrawableWithColor="@{viewModel.promotedStory.lessonThumbnail.backgroundColorRgb}" />

<LinearLayout
android:layout_width="0dp"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="12dp"
android:background="@color/white"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/lesson_thumbnail"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/chapter_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-medium"
android:maxLines="1"
android:text="@{viewModel.promotedStory.nextChapterName}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="18sp" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/lesson_thumbnail">

<TextView
android:id="@+id/story_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:maxLines="1"
android:lines="2"
android:text="@{viewModel.promotedStory.storyName}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="16sp" />
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/topic_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="12dp"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:maxLines="1"
android:text="@{viewModel.promotedStory.topicName}"
android:textAllCaps="true"
android:textColor="@color/oppiaPrimaryText"
android:textSize="14sp" />
</LinearLayout>
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/story_name_text_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
app:layout_constraintTop_toBottomOf="@id/lesson_thumbnail">

<TextView
android:id="@+id/chapter_name_text_view"
android:id="@+id/story_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
Expand All @@ -59,7 +59,7 @@
android:ellipsize="end"
android:fontFamily="sans-serif"
android:lines="2"
android:text="@{viewModel.promotedStory.nextChapterName}"
android:text="@{viewModel.promotedStory.storyName}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="14sp"
android:textStyle="bold"
Expand All @@ -85,7 +85,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chapter_name_text_view" />
app:layout_constraintTop_toBottomOf="@id/story_name_text_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
app:layout_constraintTop_toBottomOf="@id/lesson_thumbnail">

<TextView
android:id="@+id/chapter_name_text_view"
android:id="@+id/story_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
Expand All @@ -59,7 +59,7 @@
android:ellipsize="end"
android:fontFamily="sans-serif"
android:lines="2"
android:text="@{viewModel.promotedStory.nextChapterName}"
android:text="@{viewModel.promotedStory.storyName}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="14sp"
android:textStyle="bold"
Expand All @@ -85,7 +85,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chapter_name_text_view" />
app:layout_constraintTop_toBottomOf="@id/story_name_text_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,84 +14,79 @@
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="28dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="28dp"
android:background="@drawable/grey_card_rounded_border"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
app:cardElevation="4dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true">

<org.oppia.app.customview.LessonThumbnailImageView
android:id="@+id/lesson_thumbnail"
android:layout_width="80dp"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:contentDescription="@{@string/lesson_thumbnail_content_description(viewModel.promotedStory.nextChapterName)}"
android:scaleType="centerInside"
android:importantForAccessibility="no"
android:scaleType="fitCenter"
app:entityId="@{viewModel.promotedStory.storyId}"
app:entityType="@{viewModel.entityType}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="16:9"
app:layout_constraintDimensionRatio="4:3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lessonThumbnail="@{viewModel.promotedStory.lessonThumbnail}"
app:roundedRectDrawableWithColor="@{viewModel.promotedStory.lessonThumbnail.backgroundColorRgb}" />

<LinearLayout
android:layout_width="0dp"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="12dp"
android:background="@color/white"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/lesson_thumbnail"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/chapter_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-medium"
android:maxLines="1"
android:text="@{viewModel.promotedStory.nextChapterName}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="18sp" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/lesson_thumbnail">

<TextView
android:id="@+id/story_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:maxLines="1"
android:lines="2"
android:text="@{viewModel.promotedStory.storyName}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="16sp" />
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/topic_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="12dp"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:maxLines="1"
android:text="@{viewModel.promotedStory.topicName}"
android:textAllCaps="true"
android:textColor="@color/oppiaPrimaryText"
android:textSize="14sp" />
</LinearLayout>
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/story_name_text_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
3 changes: 1 addition & 2 deletions app/src/main/res/values-land/integers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<integer name="topic_revision_span_count">3</integer>
<integer name="ongoing_topics_span_count">3</integer>
<integer name="completed_story_span_count">3</integer>
<integer name="profile_progress_span_count">1</integer>
<integer name="profile_progress_span_count">3</integer>
<integer name="profile_progress_limit">3</integer>
<integer name="profile_progress_subset">2</integer>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-sw600dp-land/integers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
<integer name="completed_story_span_count">4</integer>
<integer name="profile_progress_span_count">4</integer>
<integer name="profile_progress_limit">4</integer>
<integer name="profile_progress_subset">4</integer>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-sw600dp-port/integers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
<integer name="completed_story_span_count">3</integer>
<integer name="profile_progress_span_count">3</integer>
<integer name="profile_progress_limit">3</integer>
<integer name="profile_progress_subset">3</integer>
</resources>
3 changes: 1 addition & 2 deletions app/src/main/res/values/integers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<integer name="topic_revision_span_count">2</integer>
<integer name="ongoing_topics_span_count">2</integer>
<integer name="completed_story_span_count">2</integer>
<integer name="profile_progress_span_count">1</integer>
<integer name="profile_progress_span_count">2</integer>
<integer name="profile_progress_limit">3</integer>
<integer name="profile_progress_subset">2</integer>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -410,37 +410,16 @@ class ProfileProgressFragmentTest {
}

@Test
fun testProfileProgressActivity_recyclerViewItem1_chapterNameIsCorrect() {
launch<ProfileProgressActivity>(createProfileProgressActivityIntent(internalProfileId)).use {
onView(withId(R.id.profile_progress_list)).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
waitForTheView(withText("Prototype Exploration"))
onView(
atPositionOnView(
R.id.profile_progress_list,
1, R.id.chapter_name_text_view
)
).check(
matches(withText(containsString("Prototype Exploration")))
)
}
}

@Test
@Config(qualifiers = "port-xxhdpi")
fun testProfileProgressActivity_changeConfiguration_recyclerViewItem1_chapterNameIsCorrect() {
fun testProfileProgressActivity_changeConfiguration_recyclerViewItem1_storyNameIsCorrect() {
launch<ProfileProgressActivity>(createProfileProgressActivityIntent(internalProfileId)).use {
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.profile_progress_list))
.perform(scrollToPosition<RecyclerView.ViewHolder>(1))
waitForTheView(withText("Prototype Exploration"))
waitForTheView(withText("First Story"))
onView(
atPositionOnView(R.id.profile_progress_list, 1, R.id.chapter_name_text_view)
atPositionOnView(R.id.profile_progress_list, 1, R.id.story_name_text_view)
).check(
matches(withText(containsString("Prototype Exploration")))
matches(withText(containsString("First Story")))
)
}
}
Expand Down
Loading

0 comments on commit 31152c5

Please sign in to comment.