diff --git a/app/src/main/java/org/oppia/android/app/home/WelcomeViewModel.kt b/app/src/main/java/org/oppia/android/app/home/WelcomeViewModel.kt index 181f7465bfa..40cf74ec589 100644 --- a/app/src/main/java/org/oppia/android/app/home/WelcomeViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/home/WelcomeViewModel.kt @@ -13,15 +13,18 @@ class WelcomeViewModel( dateTimeUtil: DateTimeUtil ) : HomeItemViewModel() { - /** Text [String] to greet the learner and display on-screen when launching the home activity. */ + /** Text [String] to greet the learner. */ val greeting: String = dateTimeUtil.getGreetingMessage() /** - * Returns the user-readable portion of the welcome screen greeting that contains the user's name. + * Returns the string which contains greeting message with user's name and + * display on-screen when launching the home activity. */ - fun computeProfileNameText(): String { - return resourceHandler.getStringInLocaleWithWrapping(R.string.welcome_profile_name, profileName) - } + fun computeWelcomeText(): String = resourceHandler.getStringInLocaleWithWrapping( + R.string.welcome_profile_name, + greeting, + profileName + ) // Overriding equals is needed so that DataProvider combine functions used in the HomeViewModel // will only rebind when the actual data in the data list changes, rather than when the ViewModel diff --git a/app/src/main/res/layout/welcome.xml b/app/src/main/res/layout/welcome.xml index e4a87b27e94..8fcc751ec56 100644 --- a/app/src/main/res/layout/welcome.xml +++ b/app/src/main/res/layout/welcome.xml @@ -33,16 +33,7 @@ android:layout_height="wrap_content" android:layout_marginEnd="@dimen/home_welcome_text_view_margin_end" android:fontFamily="sans-serif" - android:text="@{viewModel.greeting}" - android:textColor="@color/component_color_shared_primary_text_color" - android:textSize="24sp" /> - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0f02760b7ae..081bea57539 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -176,7 +176,7 @@ %s GB Correct! Topic: %s - %s! + %s %s! 1 Chapter %s Chapters diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt index 55a31dd8066..a0e79d44c34 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt @@ -246,19 +246,6 @@ class HomeActivityTest { assertThat(screenName).isEqualTo(ScreenName.HOME_ACTIVITY) } - @Test - fun testHomeActivity_withAdminProfile_profileNameIsDisplayed() { - launch(createHomeActivityIntent(internalProfileId)).use { - testCoroutineDispatchers.runCurrent() - scrollToPosition(position = 0) - verifyExactTextOnHomeListItemAtPosition( - itemPosition = 0, - targetViewId = R.id.profile_name_text_view, - stringToMatch = "Admin!" - ) - } - } - @Test fun testHomeActivity_hasCorrectActivityLabel() { launch(HomeActivity::class.java).use { scenario -> @@ -271,59 +258,61 @@ class HomeActivityTest { @Test fun testHomeActivity_withAdminProfile_configChange_profileNameIsDisplayed() { + fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) + fakeOppiaClock.setCurrentTimeToSameDateTime(EVENING_TIMESTAMP) launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() onView(isRoot()).perform(orientationLandscape()) scrollToPosition(position = 0) verifyExactTextOnHomeListItemAtPosition( itemPosition = 0, - targetViewId = R.id.profile_name_text_view, - stringToMatch = "Admin!" + targetViewId = R.id.welcome_text_view, + stringToMatch = "Good evening, Admin!" ) } } @Test - fun testHomeActivity_morningTimestamp_goodMorningMessageIsDisplayed() { + fun testHomeActivity_morningTimestamp_goodMorningMessageIsDisplayed_withAdminProfileName() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(MORNING_TIMESTAMP) - launch(createHomeActivityIntent(internalProfileId1)).use { + launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() scrollToPosition(position = 0) verifyExactTextOnHomeListItemAtPosition( itemPosition = 0, targetViewId = R.id.welcome_text_view, - stringToMatch = "Good morning," + stringToMatch = "Good morning, Admin!" ) } } @Test - fun testHomeActivity_afternoonTimestamp_goodAfternoonMessageIsDisplayed() { + fun testHomeActivity_afternoonTimestamp_goodAfternoonMessageIsDisplayed_withAdminProfileName() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(AFTERNOON_TIMESTAMP) - launch(createHomeActivityIntent(internalProfileId1)).use { + launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() scrollToPosition(position = 0) verifyExactTextOnHomeListItemAtPosition( itemPosition = 0, targetViewId = R.id.welcome_text_view, - stringToMatch = "Good afternoon," + stringToMatch = "Good afternoon, Admin!" ) } } @Test - fun testHomeActivity_eveningTimestamp_goodEveningMessageIsDisplayed() { + fun testHomeActivity_eveningTimestamp_goodEveningMessageIsDisplayed_withAdminProfileName() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(EVENING_TIMESTAMP) - launch(createHomeActivityIntent(internalProfileId1)).use { + launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() scrollToPosition(position = 0) verifyExactTextOnHomeListItemAtPosition( itemPosition = 0, targetViewId = R.id.welcome_text_view, - stringToMatch = "Good evening," + stringToMatch = "Good evening, Admin!" ) } } @@ -1094,7 +1083,7 @@ class HomeActivityTest { atPositionOnView( R.id.home_recycler_view, 0, - R.id.profile_name_text_view + R.id.welcome_text_view ) ).check(matches(not(isEllipsized()))) } @@ -1113,7 +1102,7 @@ class HomeActivityTest { atPositionOnView( R.id.home_recycler_view, 0, - R.id.profile_name_text_view + R.id.welcome_text_view ) ).check(matches(not(isEllipsized()))) } @@ -1131,7 +1120,7 @@ class HomeActivityTest { atPositionOnView( R.id.home_recycler_view, 0, - R.id.profile_name_text_view + R.id.welcome_text_view ) ).check(matches(not(isEllipsized()))) } @@ -1150,7 +1139,7 @@ class HomeActivityTest { atPositionOnView( R.id.home_recycler_view, 0, - R.id.profile_name_text_view + R.id.welcome_text_view ) ).check(matches(not(isEllipsized()))) } @@ -1574,7 +1563,7 @@ class HomeActivityTest { verifyExactTextOnHomeListItemAtPosition( itemPosition = 0, targetViewId = R.id.welcome_text_view, - stringToMatch = "Good morning," + stringToMatch = "Good morning, Admin!" ) } } @@ -1634,7 +1623,7 @@ class HomeActivityTest { verifyExactTextOnHomeListItemAtPosition( itemPosition = 0, targetViewId = R.id.welcome_text_view, - stringToMatch = "Bom dia," + stringToMatch = "Bom dia, Admin!" ) assertThat(testActivityRecreator.getRecreateCount()).isEqualTo(1) // Verify that the display locale is set up correctly (for string formatting). @@ -1664,7 +1653,7 @@ class HomeActivityTest { verifyExactTextOnHomeListItemAtPosition( itemPosition = 0, targetViewId = R.id.welcome_text_view, - stringToMatch = "صباح الخير" + stringToMatch = "صباح الخير \u200F\u202AAdmin\u202C\u200F!" ) } } @@ -1734,7 +1723,7 @@ class HomeActivityTest { verifyExactTextOnHomeListItemAtPosition( itemPosition = 0, targetViewId = R.id.welcome_text_view, - stringToMatch = "Bom dia," + stringToMatch = "Bom dia, Admin!" ) } }