Skip to content

Commit

Permalink
Merge pull request #20361 from wordpress-mobile/task/20298-reader-likes
Browse files Browse the repository at this point in the history
Reader: Change "N bloggers like this" to "N likes"
  • Loading branch information
AjeshRPai authored Mar 6, 2024
2 parents 5f540cc + 3fcc032 commit 96d72f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class ReaderPostDetailViewModel @Inject constructor(
}

private fun buildLikersUiState(updateLikesState: GetLikesState?): TrainOfFacesUiState {
val (likers, numLikes, iLiked) = getLikersEssentials(updateLikesState)
val (likers, numLikes) = getLikersEssentials(updateLikesState)

val showLoading = updateLikesState is Loading
var showEmptyState = false
Expand All @@ -717,7 +717,7 @@ class ReaderPostDetailViewModel @Inject constructor(
} ?: false

val engageItemsList = if (showLikeFacesTrainContainer) {
likers + getLikersFacesText(showEmptyState, numLikes, iLiked)
likers + getLikersFacesText(showEmptyState, numLikes)
} else {
listOf()
}
Expand Down Expand Up @@ -750,56 +750,25 @@ class ReaderPostDetailViewModel @Inject constructor(
}

@Suppress("LongMethod")
private fun getLikersFacesText(showEmptyState: Boolean, numLikes: Int, iLiked: Boolean): List<TrainOfAvatarsItem> {
private fun getLikersFacesText(showEmptyState: Boolean, numLikes: Int): List<TrainOfAvatarsItem> {
@AttrRes val labelColor = R.attr.wpColorOnSurfaceMedium
return when {
showEmptyState -> {
listOf()
}
numLikes == 1 && iLiked -> {
numLikes == 1 -> {
TrailingLabelTextItem(
UiStringText(
htmlMessageUtils.getHtmlMessageFromStringFormatResId(R.string.like_faces_you_like_text)
htmlMessageUtils.getHtmlMessageFromStringFormatResId(R.string.like_title_singular)
),
labelColor
).toList()
}
numLikes == 2 && iLiked -> {
numLikes > 1 -> {
TrailingLabelTextItem(
UiStringText(
htmlMessageUtils.getHtmlMessageFromStringFormatResId(
R.string.like_faces_you_plus_one_like_text
)
),
labelColor
).toList()
}
numLikes > 2 && iLiked -> {
TrailingLabelTextItem(
UiStringText(
htmlMessageUtils.getHtmlMessageFromStringFormatResId(
R.string.like_faces_you_plus_others_like_text,
numLikes - 1
)
),
labelColor
).toList()
}
numLikes == 1 && !iLiked -> {
TrailingLabelTextItem(
UiStringText(
htmlMessageUtils.getHtmlMessageFromStringFormatResId(
R.string.like_faces_one_blogger_likes_text
)
),
labelColor
).toList()
}
numLikes > 1 && !iLiked -> {
TrailingLabelTextItem(
UiStringText(
htmlMessageUtils.getHtmlMessageFromStringFormatResId(
R.string.like_faces_others_like_text,
R.string.like_title_plural,
numLikes
)
),
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/layout/trailing_label_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
android:paddingBottom="@dimen/margin_medium"
android:paddingTop="@dimen/margin_medium"
android:textAppearance="?attr/textAppearanceCaption"
tools:text="19 bloggers like this." />
tools:text="19 likes" />

</FrameLayout>
8 changes: 0 additions & 8 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1629,14 +1629,6 @@
<string name="like_title_singular">1 Like</string>
<string name="like_title_plural">%d Likes</string>
<string name="like_faces_error_loading_message">Error loading like data. %s.</string>
<!-- Note for translators: the '&lt;a href=""&gt;' and '&lt;/a&gt;' must be kept without
translations/modifications and are used to enclose the portion of the text
that will be rendered as underlined. -->
<string name="like_faces_you_like_text">&lt;a href=""&gt;You&lt;/a&gt; like this.</string>
<string name="like_faces_you_plus_one_like_text">&lt;a href=""&gt;You and 1 blogger&lt;/a&gt; like this.</string>
<string name="like_faces_you_plus_others_like_text">&lt;a href=""&gt;You and %1$s bloggers&lt;/a&gt; like this.</string>
<string name="like_faces_one_blogger_likes_text">&lt;a href=""&gt;1 blogger&lt;/a&gt; likes this.</string>
<string name="like_faces_others_like_text">&lt;a href=""&gt;%1$s bloggers&lt;/a&gt; like this.</string>

<!-- reader -->
<string name="reader">Reader</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ class ReaderPostDetailViewModelTest : BaseUnitTest() {
fun `ui state show likers faces when data available`() {
val likesState = getGetLikesState(TEST_CONFIG_1) as LikesData
val likers = MutableList(5) { mock<AvatarItem>() }
val testTextString = "10 bloggers like this."
val testTextString = "10 likes"

getLikesState.value = likesState
whenever(accountStore.account).thenReturn(AccountModel().apply { userId = -1 })
Expand Down

0 comments on commit 96d72f8

Please sign in to comment.