Fix crash when building notification summary

pull/1111/head
Alex Baker 4 years ago
parent 2072ab719b
commit 2fc8d0f251

@ -23,5 +23,5 @@ interface NotificationDao {
suspend fun deleteAll(taskIds: List<Long>) suspend fun deleteAll(taskIds: List<Long>)
@Query("SELECT MAX(timestamp) FROM notification") @Query("SELECT MAX(timestamp) FROM notification")
suspend fun latestTimestamp(): Long suspend fun latestTimestamp(): Long?
} }

@ -224,7 +224,6 @@ class NotificationManager @Inject constructor(
context.getString(R.string.notifications), context.getString(R.string.notifications),
QueryTemplate() QueryTemplate()
.join(inner(Notification.TABLE, Task.ID.eq(Notification.TASK)))) .join(inner(Notification.TABLE, Task.ID.eq(Notification.TASK))))
val `when` = notificationDao.latestTimestamp()
var maxPriority = 3 var maxPriority = 3
val summaryTitle = context.resources.getQuantityString(R.plurals.task_count, taskCount, taskCount) val summaryTitle = context.resources.getQuantityString(R.plurals.task_count, taskCount, taskCount)
val style = NotificationCompat.InboxStyle().setBigContentTitle(summaryTitle) val style = NotificationCompat.InboxStyle().setBigContentTitle(summaryTitle)
@ -244,7 +243,6 @@ class NotificationManager @Inject constructor(
.setContentText( .setContentText(
titles.joinToString(context.getString(R.string.list_separator_with_space))) titles.joinToString(context.getString(R.string.list_separator_with_space)))
.setShowWhen(true) .setShowWhen(true)
.setWhen(`when`)
.setSmallIcon(R.drawable.ic_done_all_white_24dp) .setSmallIcon(R.drawable.ic_done_all_white_24dp)
.setStyle(style) .setStyle(style)
.setColor(colorProvider.getPriorityColor(maxPriority, true)) .setColor(colorProvider.getPriorityColor(maxPriority, true))
@ -261,6 +259,7 @@ class NotificationManager @Inject constructor(
ticker.joinToString(context.getString(R.string.list_separator_with_space))) ticker.joinToString(context.getString(R.string.list_separator_with_space)))
.setGroupAlertBehavior( .setGroupAlertBehavior(
if (notify) NotificationCompat.GROUP_ALERT_SUMMARY else NotificationCompat.GROUP_ALERT_CHILDREN) if (notify) NotificationCompat.GROUP_ALERT_SUMMARY else NotificationCompat.GROUP_ALERT_CHILDREN)
notificationDao.latestTimestamp()?.let { builder.setWhen(it) }
val snoozeIntent = SnoozeActivity.newIntent(context, taskIds) val snoozeIntent = SnoozeActivity.newIntent(context, taskIds)
builder.addAction( builder.addAction(
R.drawable.ic_snooze_white_24dp, R.drawable.ic_snooze_white_24dp,

Loading…
Cancel
Save