Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previews and labels for Stats widgets #10122

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
12.8
-----
Add percentage bar to following Stats cards - Posts and Pages, Authors, Tags and Categories
* Add percentage bar to following Stats cards - Posts and Pages, Authors, Tags and Categories
* Add All-time, Today, Weekly and Minified widgets

12.7
-----
Expand Down
16 changes: 12 additions & 4 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,9 @@
android:name="android.appwidget.provider"
android:resource="@xml/stats_widget_info" />
</receiver>
<receiver android:name=".ui.stats.refresh.lists.widget.views.StatsViewsWidget">
<receiver
android:name=".ui.stats.refresh.lists.widget.views.StatsViewsWidget"
android:label="@string/stats_widget_weekly_views_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
Expand All @@ -734,7 +736,9 @@
android:name="android.appwidget.provider"
android:resource="@xml/stats_views_widget_info"/>
</receiver>
<receiver android:name=".ui.stats.refresh.lists.widget.alltime.StatsAllTimeWidget">
<receiver
android:name=".ui.stats.refresh.lists.widget.alltime.StatsAllTimeWidget"
android:label="@string/stats_widget_all_time_insights_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
Expand All @@ -743,7 +747,9 @@
android:name="android.appwidget.provider"
android:resource="@xml/stats_all_time_widget_info"/>
</receiver>
<receiver android:name=".ui.stats.refresh.lists.widget.today.StatsTodayWidget">
<receiver
android:name=".ui.stats.refresh.lists.widget.today.StatsTodayWidget"
android:label="@string/stats_widget_today_insights_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
Expand All @@ -752,7 +758,9 @@
android:name="android.appwidget.provider"
android:resource="@xml/stats_today_widget_info"/>
</receiver>
<receiver android:name=".ui.stats.refresh.lists.widget.minified.StatsMinifiedWidget">
<receiver
android:name=".ui.stats.refresh.lists.widget.minified.StatsMinifiedWidget"
android:label="@string/stats_widget_minified_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class TodayWidgetBlockListViewModel
BlockItemUiModel(
layout,
localSiteId,
resourceProvider.getString(R.string.posts),
domainModel.posts.toFormattedString(MILLION),
resourceProvider.getString(R.string.likes),
domainModel.likes.toFormattedString(MILLION),
resourceProvider.getString(R.string.stats_comments),
domainModel.comments.toFormattedString(MILLION)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class TodayWidgetListViewModel
TodayItemUiModel(
layout,
localSiteId,
resourceProvider.getString(R.string.posts),
domainModel.posts.toFormattedString(ONE_THOUSAND)
resourceProvider.getString(R.string.likes),
domainModel.likes.toFormattedString(ONE_THOUSAND)
),
TodayItemUiModel(
layout,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,12 @@
<string name="stats_insights_add_insights_header">Add Insights</string>
<string name="stats_insights_management_drag_and_drop_hint">Items shown above will show in your Insights tab. Drag and drop to customize.</string>

<!-- Stats refreshed widgets -->
<string name="stats_widget_log_in_message">Please log in to the WordPress app to add a widget.</string>
<string name="stats_widget_weekly_views_name">Views this week</string>
<string name="stats_widget_all_time_insights_name">All-time</string>
<string name="stats_widget_today_insights_name">Today</string>
<string name="stats_widget_minified_name">At a glance</string>

<!-- Stats post detail -->
<string name="stats_detail_months_and_years">Months and Years</string>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/xml/stats_all_time_widget_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:minHeight="110dp"
android:minResizeWidth="150dp"
android:minWidth="250dp"
android:previewImage="@drawable/ic_placeholder_blavatar_grey_lighten_20_40dp"
android:previewImage="@drawable/stats_all_time_widget_preview"
android:resizeMode="horizontal"
android:updatePeriodMillis="600000"
android:widgetCategory="home_screen">
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/xml/stats_minified_widget_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:initialLayout="@layout/stats_widget_minified_light"
android:minHeight="50dp"
android:minWidth="110dp"
android:previewImage="@drawable/ic_placeholder_blavatar_grey_lighten_20_40dp"
android:previewImage="@drawable/stats_minified_widget_preview"
android:resizeMode="horizontal"
android:updatePeriodMillis="600000"
android:widgetCategory="home_screen">
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/xml/stats_today_widget_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:minHeight="110dp"
android:minResizeWidth="150dp"
android:minWidth="250dp"
android:previewImage="@drawable/ic_placeholder_blavatar_grey_lighten_20_40dp"
android:previewImage="@drawable/stats_today_widget_preview"
android:resizeMode="horizontal"
android:updatePeriodMillis="600000"
android:widgetCategory="home_screen">
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/xml/stats_views_widget_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:minResizeHeight="50dp"
android:minResizeWidth="150dp"
android:minWidth="250dp"
android:previewImage="@drawable/stats_widget_preview"
android:previewImage="@drawable/stats_views_widget_preview"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="600000"
android:widgetCategory="home_screen">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ class TodayWidgetBlockListViewModelTest {
whenever(siteStore.getSiteByLocalId(siteId)).thenReturn(site)
val viewsKey = "Views"
val visitorsKey = "Visitors"
val postsKey = "Posts"
val likesKey = "Posts"
malinajirka marked this conversation as resolved.
Show resolved Hide resolved
val commentsKey = "Comments"
val views = 500
val visitors = 100
val posts = 50
val likes = 50
val comments = 300
whenever(resourceProvider.getString(string.stats_views)).thenReturn(viewsKey)
whenever(resourceProvider.getString(string.stats_visitors)).thenReturn(visitorsKey)
whenever(resourceProvider.getString(string.posts)).thenReturn(postsKey)
whenever(resourceProvider.getString(string.likes)).thenReturn(likesKey)
whenever(resourceProvider.getString(string.stats_comments)).thenReturn(commentsKey)
whenever(store.getTodayInsights(site)).thenReturn(
VisitsModel("2019-10-10", views, visitors, 0, 0, comments, posts)
VisitsModel("2019-10-10", views, visitors, likes, 0, comments, 0)
)

viewModel.onDataSetChanged(context)

Assertions.assertThat(viewModel.data).hasSize(2)
assertListItem(viewModel.data[0], viewsKey, views, visitorsKey, visitors)
assertListItem(viewModel.data[1], postsKey, posts, commentsKey, comments)
assertListItem(viewModel.data[1], likesKey, likes, commentsKey, comments)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,26 @@ class TodayWidgetListViewModelTest {
whenever(siteStore.getSiteByLocalId(siteId)).thenReturn(site)
val viewsKey = "Views"
val visitorsKey = "Visitors"
val postsKey = "Posts"
val likesKey = "Likes"
val commentsKey = "Comments"
val views = 500
val visitors = 100
val posts = 50
val likes = 50
val comments = 300
whenever(resourceProvider.getString(R.string.stats_views)).thenReturn(viewsKey)
whenever(resourceProvider.getString(R.string.stats_visitors)).thenReturn(visitorsKey)
whenever(resourceProvider.getString(R.string.posts)).thenReturn(postsKey)
whenever(resourceProvider.getString(R.string.likes)).thenReturn(likesKey)
whenever(resourceProvider.getString(R.string.stats_comments)).thenReturn(commentsKey)
whenever(store.getTodayInsights(site)).thenReturn(
VisitsModel("2019-10-10", views, visitors, 0, 0, comments, posts)
VisitsModel("2019-10-10", views, visitors, likes, 0, comments, 0)
)

viewModel.onDataSetChanged { }

assertThat(viewModel.data).hasSize(4)
assertListItem(viewModel.data[0], viewsKey, views)
assertListItem(viewModel.data[1], visitorsKey, visitors)
assertListItem(viewModel.data[2], postsKey, posts)
assertListItem(viewModel.data[2], likesKey, likes)
assertListItem(viewModel.data[3], commentsKey, comments)
}

Expand Down