Start adding random motivational tips to daily checkin.

See #1007
This commit is contained in:
Phillip Thelen 2018-08-22 20:07:41 +02:00
parent aa54bef02c
commit 941ce87fd9
2 changed files with 17 additions and 0 deletions

View file

@ -793,4 +793,8 @@
<string name="same_day_reminder_text">The more you add, the more you\'ll be rewarded. Even small habits add up to big change.</string>
<string name="next_day_reminder_title">Remember to check your tasks!</string>
<string name="next_day_reminder_text">There\'s lots of unlock and discover at you level up, so keep up with your tasks and have fun!</string>
<string name="daily_tip_0">Use the mobile apps to set reminders for your tasks.</string>
<string name="daily_tip_1">Add checklists to your To-Dos to multiply your rewards!</string>
<string name="daily_tip_2">Complete all your Dailies to get a Perfect Day Buff that increases your Stats!</string>
<string name="daily_tip_3">Occasionally re-evaluate your tasks to make sure theyre up-to-date!</string>
</resources>

View file

@ -77,6 +77,7 @@ class NotificationPublisher : WakefulBroadcastReceiver() {
val notification: Notification
val builder = Notification.Builder(thisContext)
builder.setContentTitle(thisContext.getString(R.string.reminder_title))
builder.setContentText(getRandomDailyTip())
if (registrationDate != null) {
val registrationCal = Calendar.getInstance()
registrationCal.time = registrationDate
@ -119,6 +120,18 @@ class NotificationPublisher : WakefulBroadcastReceiver() {
return notification
}
private fun getRandomDailyTip(): String {
val thisContext = context ?: return ""
val index = Random().nextInt(4)
return when (index) {
0 -> thisContext.getString(R.string.daily_tip_0)
1 -> thisContext.getString(R.string.daily_tip_1)
2 -> thisContext.getString(R.string.daily_tip_2)
3 -> thisContext.getString(R.string.daily_tip_3)
else -> ""
}
}
companion object {
var NOTIFICATION_ID = "notification-id"