Skip to content

Commit

Permalink
Merge pull request #19974 from wordpress-mobile/Stats-Traffic-Update-…
Browse files Browse the repository at this point in the history
…Today-card

Stats traffic update today card
  • Loading branch information
irfano authored Jan 18, 2024
2 parents 916c1cc + ba009ab commit e06eeea
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ sealed class MySiteCardAndItem(open val type: Type, open val activeQuickStartIte
val views: UiString,
val visitors: UiString,
val likes: UiString,
val comments: UiString,
val onCardClick: () -> Unit,
val message: TextWithLinks? = null,
val moreMenuOptions: MoreMenuOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class TodaysStatsCardBuilder @Inject constructor(
views = statToUiString(model.views),
visitors = statToUiString(model.visitors),
likes = statToUiString(model.likes),
comments = statToUiString(model.comments),
onCardClick = params.onTodaysStatsCardClick,
message = model.takeIf { it.isEmptyStats() }?.let {
TextWithLinks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class TodaysStatsCardViewHolder(
uiHelpers.setTextOrHide(viewsCount, card.views)
uiHelpers.setTextOrHide(visitorsCount, card.visitors)
uiHelpers.setTextOrHide(likesCount, card.likes)
uiHelpers.setTextOrHide(commentsCount, card.comments)
uiHelpers.setTextOrHide(getMoreViewsMessage, card.message?.text)
card.message?.links?.let { getMoreViewsMessage.updateLink(it) }
mySiteTodaysStatCard.setOnClickListener {
Expand Down
62 changes: 56 additions & 6 deletions WordPress/src/main/res/layout/my_site_todays_stats_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/views_title"
tools:text="1,743" />

<View
android:id="@+id/vertical_divider_views"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/gray_20"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
Expand All @@ -48,7 +58,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_extra_large"
android:layout_marginTop="@dimen/margin_large"
app:layout_constraintEnd_toStartOf="@+id/likes_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/views_layout"
app:layout_constraintTop_toBottomOf="@+id/my_site_toolbar">

Expand Down Expand Up @@ -79,10 +89,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_extra_large"
android:layout_marginTop="@dimen/margin_large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/visitors_layout"
app:layout_constraintTop_toBottomOf="@+id/my_site_toolbar">
app:layout_constraintEnd_toStartOf="@+id/comments_layout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/views_layout">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/likes_title"
Expand All @@ -104,6 +113,47 @@
app:layout_constraintTop_toBottomOf="@+id/likes_title"
tools:text="1,000" />

<View
android:id="@+id/vertical_divider_likes"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/gray_20"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/comments_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_extra_large"
android:layout_marginTop="@dimen/margin_large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/likes_layout"
app:layout_constraintTop_toBottomOf="@+id/visitors_layout">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/comments_title"
style="@style/MySiteTodaysStatsCardStatTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/my_site_todays_stat_card_comments"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<org.wordpress.android.widgets.MaterialTextViewWithNumerals
android:id="@+id/comments_count"
style="@style/MySiteTodaysStatsCardStatCountText"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/comments_title"
tools:text="1,990" />

</androidx.constraintlayout.widget.ConstraintLayout>

<include
Expand All @@ -120,7 +170,7 @@
android:id="@+id/card_footer_padding"
android:layout_width="match_parent"
android:layout_height="@dimen/margin_large"
app:layout_constraintTop_toBottomOf="@+id/views_layout"/>
app:layout_constraintTop_toBottomOf="@+id/likes_layout"/>

<com.google.android.material.textview.MaterialTextView
android:id="@+id/get_more_views_message"
Expand Down
1 change: 1 addition & 0 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,7 @@
<string name="my_site_todays_stat_card_likes" translatable="false">@string/stats_likes</string>
<string name="my_site_todays_stat_card_views" translatable="false">@string/stats_views</string>
<string name="my_site_todays_stat_card_visitors" translatable="false">@string/stats_visitors</string>
<string name="my_site_todays_stat_card_comments" translatable="false">@string/stats_comments</string>
<string name="my_site_todays_stats_get_more_views_message">Interested in building your audience? Check out our &lt;a href="%1$s"&gt;top tips&lt;/a&gt;.</string>
<string name="my_site_todays_stats_card_menu_hide_this" translatable="false">@string/my_site_dashboard_card_more_menu_hide_card</string>
<string name="my_site_todays_stats_menu_view_stats">View stats</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private const val TODAYS_STATS_COMMENTS = 1000
private const val TODAYS_STATS_VIEWS_FORMATTED_STRING = "10,000"
private const val TODAYS_STATS_VISITORS_FORMATTED_STRING = "1,000"
private const val TODAYS_STATS_LIKES_FORMATTED_STRING = "100"
private const val TODAYS_STATS_COMMENTS_FORMATTED_STRING = "1,000"

private const val GET_MORE_VIEWS_MSG_WITH_CLICKABLE_LINK =
"If you want to try get more views and traffic check out our " +
Expand Down Expand Up @@ -194,6 +195,7 @@ class TodaysStatsCardBuilderTest : BaseUnitTest() {
views = UiStringText(TODAYS_STATS_VIEWS_FORMATTED_STRING),
visitors = UiStringText(TODAYS_STATS_VISITORS_FORMATTED_STRING),
likes = UiStringText(TODAYS_STATS_LIKES_FORMATTED_STRING),
comments = UiStringText(TODAYS_STATS_COMMENTS_FORMATTED_STRING),
onCardClick = onTodaysStatsCardClick,
moreMenuOptions = TodaysStatsCard.MoreMenuOptions(
onMoreMenuClick = onMoreMenuClick,
Expand Down

0 comments on commit e06eeea

Please sign in to comment.