diff --git a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerHeaderViewModel.kt b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerHeaderViewModel.kt index b46e7a63275..d75c0d03287 100644 --- a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerHeaderViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerHeaderViewModel.kt @@ -22,7 +22,10 @@ class NavigationDrawerHeaderViewModel @Inject constructor( val profile = ObservableField(Profile.getDefaultInstance()) private var ongoingTopicCount = DEFAULT_ONGOING_TOPIC_COUNT private var completedStoryCount = DEFAULT_COMPLETED_STORY_COUNT - val profileProgressText: ObservableField = ObservableField(computeProfileProgressText()) + val profileTopicProgressText: ObservableField = + ObservableField(computeProfileTopicProgressText()) + val profileStoryProgressText: ObservableField = + ObservableField(computeProfileStoryProgressText()) fun onHeaderClicked() { routeToProfileProgressListener.routeToProfileProgress(profile.get()!!.id.internalId) @@ -30,25 +33,29 @@ class NavigationDrawerHeaderViewModel @Inject constructor( fun setOngoingTopicProgress(ongoingTopicCount: Int) { this.ongoingTopicCount = ongoingTopicCount - profileProgressText.set(computeProfileProgressText()) + profileTopicProgressText.set(computeProfileTopicProgressText()) } fun setCompletedStoryProgress(completedStoryCount: Int) { this.completedStoryCount = completedStoryCount - profileProgressText.set(computeProfileProgressText()) + profileStoryProgressText.set(computeProfileStoryProgressText()) } - private fun computeProfileProgressText(): String { - // TODO(#3843): Either combine these strings into one or use separate views to display them. - val completedStoryCountText = - resourceHandler.getQuantityStringInLocaleWithWrapping( - R.plurals.completed_story_count, completedStoryCount, completedStoryCount.toString() - ) - val ongoingTopicCountText = - resourceHandler.getQuantityStringInLocaleWithWrapping( - R.plurals.ongoing_topic_count, ongoingTopicCount, ongoingTopicCount.toString() - ) - val barSeparator = resourceHandler.getStringInLocale(R.string.bar_separator) - return "$completedStoryCountText$barSeparator$ongoingTopicCountText" + private fun computeProfileStoryProgressText(): String { + return resourceHandler.getQuantityStringInLocaleWithWrapping( + R.plurals.completed_story_count, + completedStoryCount, + completedStoryCount.toString() + ) + } + + fun getBarSeparator() = resourceHandler.getStringInLocale(R.string.bar_separator) + + private fun computeProfileTopicProgressText(): String { + return resourceHandler.getQuantityStringInLocaleWithWrapping( + R.plurals.ongoing_topic_count, + ongoingTopicCount, + ongoingTopicCount.toString() + ) } } diff --git a/app/src/main/res/layout/nav_header_navigation_drawer.xml b/app/src/main/res/layout/nav_header_navigation_drawer.xml index eb9d9a0ccad..d85e97e337b 100644 --- a/app/src/main/res/layout/nav_header_navigation_drawer.xml +++ b/app/src/main/res/layout/nav_header_navigation_drawer.xml @@ -27,10 +27,10 @@ - + android:orientation="horizontal"> + + + + + + + diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt index bce54aac8a1..08512202fb7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt @@ -256,7 +256,7 @@ class NavigationDrawerActivityProdTest { } @Test - fun testNavDrawer_openNavDrawer_oneTopicInProgress_profileProgressIsDisplayedCorrectly() { + fun testNavDrawer_openNavDrawer_oneTopicInProgress_profileStoryProgressIsDisplayedCorrectly() { storyProfileTestHelper.markCompletedRatiosStory1Exp0( ProfileId.newBuilder().setInternalId( internalProfileId @@ -270,10 +270,32 @@ class NavigationDrawerActivityProdTest { it.openNavigationDrawer() onView( allOf( - withId(R.id.profile_progress_text_view), - isDescendantOfA(withId(R.id.header_linear_layout)) + withId(R.id.profile_story_progress_text_view), + isDescendantOfA(withId(R.id.progress_linear_layout)) + ) + ).check(matches(withText("1 Story Completed"))) + } + } + + @Test + fun testNavDrawer_openNavDrawer_oneTopicInProgress_profileTopicProgressIsDisplayedCorrectly() { + storyProfileTestHelper.markCompletedRatiosStory1Exp0( + ProfileId.newBuilder().setInternalId( + internalProfileId + ).build(), + timestampOlderThanOneWeek = false + ) + launch( + createNavigationDrawerActivityIntent(internalProfileId) + ).use { + testCoroutineDispatchers.runCurrent() + it.openNavigationDrawer() + onView( + allOf( + withId(R.id.profile_topic_progress_text_view), + isDescendantOfA(withId(R.id.progress_linear_layout)) ) - ).check(matches(withText("1 Story Completed | 1 Topic in Progress"))) + ).check(matches(withText("1 Topic in Progress"))) } }