Skip to content

Commit 494f7ff

Browse files
authored
Merge pull request #14768 from wordpress-mobile/feature/14706-epilogue-screen-for-blogging-reminders
Feature/14706 epilogue screen for blogging reminders
2 parents 7124028 + 418b6c4 commit 494f7ff

File tree

9 files changed

+126
-4
lines changed

9 files changed

+126
-4
lines changed

WordPress/src/main/java/org/wordpress/android/ui/bloggingreminders/BloggingRemindersAdapter.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.wordpress.android.ui.bloggingreminders
33
import android.view.ViewGroup
44
import androidx.recyclerview.widget.DiffUtil
55
import androidx.recyclerview.widget.RecyclerView.Adapter
6+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Caption
67
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersDiffCallback.DayButtonsPayload
78
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.DayButtons
89
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.HighEmphasisText
@@ -11,12 +12,14 @@ import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.MediumEm
1112
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Tip
1213
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Title
1314
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type
15+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.CAPTION
1416
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.DAY_BUTTONS
1517
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.HIGH_EMPHASIS_TEXT
1618
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.ILLUSTRATION
1719
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.LOW_EMPHASIS_TEXT
1820
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.TIP
1921
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.TITLE
22+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewHolder.CaptionViewHolder
2023
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewHolder.DayButtonsViewHolder
2124
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewHolder.HighEmphasisTextViewHolder
2225
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewHolder.IllustrationViewHolder
@@ -55,6 +58,7 @@ class BloggingRemindersAdapter
5558
is TitleViewHolder -> holder.onBind(item as Title)
5659
is HighEmphasisTextViewHolder -> holder.onBind(item as HighEmphasisText)
5760
is MediumEmphasisTextViewHolder -> holder.onBind(item as MediumEmphasisText)
61+
is CaptionViewHolder -> holder.onBind(item as Caption)
5862
is DayButtonsViewHolder -> holder.onBind(item as DayButtons, payloads.firstOrNull() as? DayButtonsPayload)
5963
is TipViewHolder -> holder.onBind(item as Tip)
6064
}
@@ -66,6 +70,7 @@ class BloggingRemindersAdapter
6670
ILLUSTRATION -> IllustrationViewHolder(parent)
6771
HIGH_EMPHASIS_TEXT -> HighEmphasisTextViewHolder(parent, uiHelpers)
6872
LOW_EMPHASIS_TEXT -> MediumEmphasisTextViewHolder(parent, uiHelpers)
73+
CAPTION -> CaptionViewHolder(parent, uiHelpers)
6974
DAY_BUTTONS -> DayButtonsViewHolder(parent, uiHelpers)
7075
TIP -> TipViewHolder(parent, uiHelpers)
7176
}

WordPress/src/main/java/org/wordpress/android/ui/bloggingreminders/BloggingRemindersItem.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.wordpress.android.ui.bloggingreminders
22

33
import androidx.annotation.DrawableRes
44
import org.wordpress.android.fluxc.model.BloggingRemindersModel
5+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.CAPTION
56
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.DAY_BUTTONS
67
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.HIGH_EMPHASIS_TEXT
78
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Type.ILLUSTRATION
@@ -13,11 +14,12 @@ import org.wordpress.android.ui.utils.UiString
1314

1415
sealed class BloggingRemindersItem(val type: Type) {
1516
enum class Type {
16-
ILLUSTRATION, TITLE, HIGH_EMPHASIS_TEXT, LOW_EMPHASIS_TEXT, DAY_BUTTONS, TIP
17+
ILLUSTRATION, TITLE, HIGH_EMPHASIS_TEXT, LOW_EMPHASIS_TEXT, CAPTION, DAY_BUTTONS, TIP
1718
}
1819

1920
data class Illustration(@DrawableRes val illustration: Int) : BloggingRemindersItem(ILLUSTRATION)
2021
data class Title(val text: UiString) : BloggingRemindersItem(TITLE)
22+
data class Caption(val text: UiString) : BloggingRemindersItem(CAPTION)
2123
data class HighEmphasisText(val text: EmphasizedText) : BloggingRemindersItem(
2224
HIGH_EMPHASIS_TEXT
2325
) {

WordPress/src/main/java/org/wordpress/android/ui/bloggingreminders/BloggingRemindersViewHolder.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import android.view.ViewGroup
99
import android.widget.TextView
1010
import androidx.recyclerview.widget.RecyclerView
1111
import androidx.viewbinding.ViewBinding
12+
import org.wordpress.android.databinding.BloggingRemindersCaptionBinding
1213
import org.wordpress.android.databinding.BloggingRemindersDayButtonsBinding
1314
import org.wordpress.android.databinding.BloggingRemindersIllustrationBinding
1415
import org.wordpress.android.databinding.BloggingRemindersTextHighEmphasisBinding
1516
import org.wordpress.android.databinding.BloggingRemindersTextMediumEmphasisBinding
1617
import org.wordpress.android.databinding.BloggingRemindersTipBinding
1718
import org.wordpress.android.databinding.BloggingRemindersTitleBinding
19+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Caption
1820
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersDiffCallback.DayButtonsPayload
1921
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.DayButtons
2022
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.DayButtons.DayItem
@@ -81,6 +83,15 @@ sealed class BloggingRemindersViewHolder<T : ViewBinding>(protected val binding:
8183
}
8284
}
8385

86+
class CaptionViewHolder(parentView: ViewGroup, private val uiHelpers: UiHelpers) :
87+
BloggingRemindersViewHolder<BloggingRemindersCaptionBinding>(
88+
parentView.viewBinding(BloggingRemindersCaptionBinding::inflate)
89+
) {
90+
fun onBind(item: Caption) = with(binding) {
91+
uiHelpers.setTextOrHide(text, item.text)
92+
}
93+
}
94+
8495
fun TextView.drawEmphasizedText(uiHelpers: UiHelpers, text: EmphasizedText) {
8596
val message = text.text
8697
if (text.emphasizeTextParams && message is UiStringResWithParams) {

WordPress/src/main/java/org/wordpress/android/ui/bloggingreminders/BloggingRemindersViewModel.kt

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,30 @@ import org.wordpress.android.fluxc.model.BloggingRemindersModel
1313
import org.wordpress.android.fluxc.model.BloggingRemindersModel.Day
1414
import org.wordpress.android.fluxc.store.BloggingRemindersStore
1515
import org.wordpress.android.modules.UI_THREAD
16+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Caption
17+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.HighEmphasisText
18+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Illustration
19+
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersItem.Title
1620
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewModel.Screen.EPILOGUE
1721
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewModel.Screen.PROLOGUE
1822
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewModel.Screen.SELECTION
1923
import org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewModel.UiState.PrimaryButton
2024
import org.wordpress.android.ui.utils.ListItemInteraction
2125
import org.wordpress.android.ui.utils.UiString
2226
import org.wordpress.android.ui.utils.UiString.UiStringRes
27+
import org.wordpress.android.ui.utils.UiString.UiStringResWithParams
28+
import org.wordpress.android.ui.utils.UiString.UiStringText
2329
import org.wordpress.android.util.merge
2430
import org.wordpress.android.viewmodel.Event
2531
import org.wordpress.android.viewmodel.ResourceProvider
2632
import org.wordpress.android.viewmodel.ScopedViewModel
33+
import java.time.DayOfWeek
2734
import java.util.ArrayList
35+
import java.util.Locale
2836
import javax.inject.Inject
2937
import javax.inject.Named
3038

39+
@Suppress("TooManyFunctions")
3140
class BloggingRemindersViewModel @Inject constructor(
3241
@Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher,
3342
private val bloggingRemindersManager: BloggingRemindersManager,
@@ -99,10 +108,44 @@ class BloggingRemindersViewModel @Inject constructor(
99108
}
100109

101110
private fun buildEpilogue(): List<BloggingRemindersItem> {
102-
// TODO Add epilogue view items
103-
return listOf()
111+
val numberOfTimes = dayLabelUtils.buildNTimesLabel(_bloggingRemindersModel.value)
112+
val enabledDays = _bloggingRemindersModel.value?.let { model ->
113+
model.enabledDays.map { DayOfWeek.valueOf(it.name) }
114+
}
115+
116+
// TODO: Format number of times and selected days properly after PRs leading up to this are merged
117+
val selectedDays = when (enabledDays?.count()) {
118+
ONE_DAY -> enabledDays.joinToString { formattedDay(it) }
119+
TWO_DAYS -> enabledDays.joinToString(separator = " and ") { formattedDay(it) }
120+
in THREE_DAYS..SIX_DAYS -> {
121+
val firstDays = enabledDays?.dropLast(1)
122+
val lastDay = enabledDays?.drop(enabledDays.count() - 1)
123+
firstDays?.joinToString(postfix = " and ") {
124+
formattedDay(it)
125+
} + lastDay?.joinToString { formattedDay(it) }
126+
}
127+
else -> UiStringRes(R.string.blogging_reminders_epilogue_body_everyday).toString()
128+
}
129+
130+
val body = when (enabledDays?.count()) {
131+
ZERO -> UiStringRes(R.string.blogging_reminders_epilogue_body_no_reminders)
132+
SEVEN_DAYS -> UiStringRes(R.string.blogging_reminders_epilogue_body_everyday)
133+
else -> UiStringResWithParams(
134+
R.string.blogging_reminders_epilogue_body_days,
135+
listOf(numberOfTimes, UiStringText(selectedDays)))
136+
}
137+
138+
return listOf(
139+
Illustration(R.drawable.img_illustration_bell_yellow_96dp),
140+
Title(UiStringRes(R.string.blogging_reminders_epilogue_title)),
141+
HighEmphasisText(body),
142+
Caption(UiStringRes(R.string.blogging_reminders_epilogue_caption))
143+
)
104144
}
105145

146+
private fun formattedDay(it: DayOfWeek) =
147+
it.name.toLowerCase(Locale.getDefault()) // TODO: Capitalize first letter
148+
106149
private fun buildEpiloguePrimaryButton(): PrimaryButton {
107150
return PrimaryButton(
108151
UiStringRes(R.string.blogging_reminders_done),
@@ -170,5 +213,11 @@ class BloggingRemindersViewModel @Inject constructor(
170213
private const val SELECTED_DAYS = "key_selected_days"
171214
private const val IS_FIRST_TIME_FLOW = "is_first_time_flow"
172215
private const val SITE_ID = "key_site_id"
216+
private const val ZERO = 0
217+
private const val ONE_DAY = 1
218+
private const val TWO_DAYS = 2
219+
private const val THREE_DAYS = 3
220+
private const val SIX_DAYS = 6
221+
private const val SEVEN_DAYS = 7
173222
}
174223
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="96dp"
3+
android:height="85dp"
4+
android:viewportWidth="96"
5+
android:viewportHeight="85">
6+
<path
7+
android:pathData="M13.8097,70.8208L14.2246,70.0355C14.2839,69.9146 14.1653,69.7334 13.9875,69.8542L13.2169,70.2771L12.5649,69.673C12.4463,69.5521 12.2685,69.673 12.3278,69.7938L12.5056,70.7L11.735,71.1229C11.6164,71.1833 11.6164,71.425 11.7943,71.425L12.6241,71.4854L12.802,72.452C12.802,72.6333 13.0391,72.6333 13.0984,72.5124L13.454,71.6062L14.4024,71.7271C14.5803,71.7271 14.6395,71.5458 14.521,71.425L13.8097,70.8208Z"
8+
android:fillColor="#F0C930"/>
9+
<path
10+
android:pathData="M23.2715,6.61L23.9925,5.1403C24.1528,4.8954 23.8323,4.6505 23.592,4.7321L22.15,5.5486L20.9483,4.4055C20.708,4.2422 20.4676,4.4055 20.4676,4.6505L20.7881,6.2834L19.4262,7.0999C19.1859,7.2632 19.266,7.5898 19.5063,7.6715L21.0284,7.8348L21.3489,9.5494C21.429,9.7943 21.7494,9.8759 21.9096,9.631L22.6306,7.998L24.313,8.243C24.5533,8.243 24.7135,7.9164 24.5533,7.7531L23.2715,6.61Z"
11+
android:fillColor="#8C8F94"/>
12+
<path
13+
android:pathData="M85.2211,80.9626L86.1397,79.0901C86.3439,78.778 85.9356,78.466 85.6294,78.57L83.7922,79.6102L82.2611,78.1539C81.9549,77.9458 81.6487,78.1539 81.6487,78.466L82.057,80.5465L80.3218,81.5867C80.0156,81.7948 80.1177,82.2109 80.4239,82.3149L82.3632,82.523L82.7715,84.7075C82.8735,85.0196 83.2818,85.1236 83.4859,84.8116L84.4046,82.731L86.548,83.0431C86.8542,83.0431 87.0583,82.627 86.8542,82.419L85.2211,80.9626Z"
14+
android:fillColor="#F283AA"/>
15+
<path
16+
android:pathData="M5.9859,58.5104L7.0674,56.3059C7.3078,55.9384 6.8271,55.571 6.4665,55.6935L4.3035,56.9182L2.5009,55.2036C2.1404,54.9586 1.7799,55.2036 1.7799,55.571L2.2606,58.0205L0.2177,59.2453C-0.1428,59.4902 -0.0227,59.9801 0.3379,60.1026L2.6211,60.3476L3.1018,62.9196C3.222,63.287 3.7026,63.4095 3.943,63.042L5.0245,60.5925L7.5481,60.9599C7.9086,60.9599 8.1489,60.47 7.9086,60.2251L5.9859,58.5104Z"
17+
android:fillColor="#68B3E8"/>
18+
<path
19+
android:pathData="M94.2818,11.5913C94.7729,11.5913 95.1709,11.1856 95.1709,10.6851C95.1709,10.1846 94.7729,9.7789 94.2818,9.7789C93.7907,9.7789 93.3927,10.1846 93.3927,10.6851C93.3927,11.1856 93.7907,11.5913 94.2818,11.5913Z"
20+
android:fillColor="#1ED15A"/>
21+
<path
22+
android:pathData="M91.9825,46.2845C92.8675,46.2845 93.585,45.5533 93.585,44.6513C93.585,43.7492 92.8675,43.018 91.9825,43.018C91.0975,43.018 90.38,43.7492 90.38,44.6513C90.38,45.5533 91.0975,46.2845 91.9825,46.2845Z"
23+
android:fillColor="#C475BD"/>
24+
<path
25+
android:pathData="M38.7558,65.0124a4.6906,5.2065 108.182,1 0,9.9268 3.1442a4.6906,5.2065 108.182,1 0,-9.9268 -3.1442z"
26+
android:fillColor="#F0C930"/>
27+
<path
28+
android:pathData="M55.9657,11.4892a4.6906,5.2065 108.182,1 0,9.9268 3.1442a4.6906,5.2065 108.182,1 0,-9.9268 -3.1442z"
29+
android:fillColor="#F2D76B"/>
30+
<path
31+
android:pathData="M31.4797,28.6024C35.3999,16.1193 48.6896,9.2025 61.1631,13.1534C73.6365,17.1042 80.5703,30.4266 76.6502,42.9097L68.444,69.0409L23.2736,54.7336L31.4797,28.6024Z"
32+
android:fillColor="#F0C930"/>
33+
<path
34+
android:pathData="M21.5346,53.0038L69.6546,68.2338A2.8661,2.8603 62.5051,0 1,71.5259 71.8293L71.5259,71.8293A2.8661,2.8603 62.5051,0 1,67.9377 73.6969L19.8177,58.4668A2.8661,2.8603 62.5051,0 1,17.9464 54.8713L17.9464,54.8713A2.8661,2.8603 62.5051,0 1,21.5346 53.0038z"
35+
android:fillColor="#DEB100"/>
36+
</vector>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:id="@+id/text"
5+
style="@style/BloggingRemindersCaption"
6+
android:layout_width="match_parent"
7+
android:layout_height="wrap_content"
8+
android:paddingBottom="@dimen/margin_extra_large"
9+
android:paddingEnd="@dimen/margin_extra_large"
10+
android:paddingStart="@dimen/margin_extra_large"
11+
tools:text="@string/blogging_reminders_epilogue_caption" />

WordPress/src/main/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3650,6 +3650,11 @@
36503650
<string name="blogging_reminders_notify_me">Notify me</string>
36513651
<string name="blogging_reminders_update">Update</string>
36523652
<string name="blogging_reminders_done">Done</string>
3653+
<string name="blogging_reminders_epilogue_title">All set!</string>
3654+
<string name="blogging_reminders_epilogue_body_days">You\'ll get reminders to blog %1$s on %2$s.</string>
3655+
<string name="blogging_reminders_epilogue_body_everyday">You\'ll get reminders to blog everyday.</string>
3656+
<string name="blogging_reminders_epilogue_body_no_reminders">You have no reminders set.</string>
3657+
<string name="blogging_reminders_epilogue_caption">You can update this anytime via My Site > Settings > Blogging goals.</string>
36533658
<string name="blogging_reminders_select_days">Select the days you want to blog on</string>
36543659
<string name="blogging_reminders_select_days_message">You can update this anytime</string>
36553660
<string name="blogging_reminders_tip">Tip</string>

WordPress/src/main/res/values/styles.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,10 @@
15641564
<item name="fontFamily">serif</item>
15651565
</style>
15661566

1567+
<style name="BloggingRemindersCaption" parent="BloggingRemindersText">
1568+
<item name="android:textAppearance">?attr/textAppearanceCaption</item>
1569+
</style>
1570+
15671571
<style name="BloggingRemindersDayBubble">
15681572
<item name="android:gravity">center</item>
15691573
<item name="android:background">@drawable/bg_oval_surface_overlay_emphasis_extra_low</item>

WordPress/src/test/java/org/wordpress/android/ui/bloggingreminders/BloggingRemindersViewModelTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ class BloggingRemindersViewModelTest : BaseUnitTest() {
176176

177177
private fun assertEpilogue() {
178178
val state = uiState.last()
179-
// TODO change this method when the list contains the updated UI
180179
assertPrimaryButton(state.primaryButton!!, R.string.blogging_reminders_done, isEnabled = true)
181180
}
182181

0 commit comments

Comments
 (0)