Skip to content

Commit

Permalink
Use singular strings for building weekly roundup notification text
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano committed Apr 8, 2024
1 parent 62fdaee commit 5351dac
Showing 1 changed file with 50 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,56 @@ class WeeklyRoundupNotifier @Inject constructor(
}

private fun buildContentText(data: WeeklyRoundupData) = when {
data.likes <= 0 && data.comments <= 0 -> {
resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_only,
statsUtils.toFormattedString(data.views)
)
}
data.likes > 0 && data.comments <= 0 -> {
resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_and_likes,
statsUtils.toFormattedString(data.views),
statsUtils.toFormattedString(data.likes)
)
}
data.likes <= 0 && data.comments > 0 -> {
resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_and_comments,
statsUtils.toFormattedString(data.views),
statsUtils.toFormattedString(data.comments)
)
}
else -> {
resourceProvider.getString(
R.string.weekly_roundup_notification_text_all,
statsUtils.toFormattedString(data.views),
statsUtils.toFormattedString(data.likes),
statsUtils.toFormattedString(data.comments)
)
}
data.likes <= 0 && data.comments <= 0 -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_only,
statsUtils.toFormattedString(data.views)
)

data.likes.toInt() == 1 && data.comments <= 0 -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_and_like,
statsUtils.toFormattedString(data.views)
)

data.likes > 0 && data.comments <= 0 -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_and_likes,
statsUtils.toFormattedString(data.views),
statsUtils.toFormattedString(data.likes)
)

data.likes <= 0 && data.comments.toInt() == 1 -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_and_comment,
statsUtils.toFormattedString(data.views)
)

data.likes <= 0 && data.comments > 0 -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_and_comments,
statsUtils.toFormattedString(data.views),
statsUtils.toFormattedString(data.comments)
)

data.likes.toInt() == 1 && data.comments.toInt() == 1 -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_like_comment,
statsUtils.toFormattedString(data.views)
)

data.likes.toInt() == 1 -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_like_comments,
statsUtils.toFormattedString(data.views),
statsUtils.toFormattedString(data.comments)
)

data.comments.toInt() == 1 -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_views_likes_comment,
statsUtils.toFormattedString(data.views),
statsUtils.toFormattedString(data.likes)
)

else -> resourceProvider.getString(
R.string.weekly_roundup_notification_text_all,
statsUtils.toFormattedString(data.views),
statsUtils.toFormattedString(data.likes),
statsUtils.toFormattedString(data.comments)
)
}

companion object {
Expand Down

0 comments on commit 5351dac

Please sign in to comment.