Show timestamp on summary notification

pull/574/head
Alex Baker 8 years ago
parent 2314c28458
commit 0105d034b6

@ -22,4 +22,7 @@ public interface NotificationDao {
@Query("DELETE FROM notification WHERE task = :taskId") @Query("DELETE FROM notification WHERE task = :taskId")
void delete(long taskId); void delete(long taskId);
@Query("SELECT MAX(timestamp) FROM notification")
long latestTimestamp();
} }

@ -139,17 +139,18 @@ public class NotificationManager {
Iterable<Long> notificationIds = transform(appDatabase.notificationDao().getAll(), n -> n.taskId); Iterable<Long> notificationIds = transform(appDatabase.notificationDao().getAll(), n -> n.taskId);
Filter notifications = new Filter(context.getString(R.string.notifications), Filter notifications = new Filter(context.getString(R.string.notifications),
new QueryTemplate().where(Task.ID.in(notificationIds))); new QueryTemplate().where(Task.ID.in(notificationIds)));
long when = appDatabase.notificationDao().latestTimestamp();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationManager.NOTIFICATION_CHANNEL_DEFAULT) NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationManager.NOTIFICATION_CHANNEL_DEFAULT)
.setGroupSummary(true) .setGroupSummary(true)
.setGroup(GROUP_KEY) .setGroup(GROUP_KEY)
.setShowWhen(false) .setShowWhen(true)
.setWhen(when)
.setSmallIcon(R.drawable.ic_done_all_white_24dp) .setSmallIcon(R.drawable.ic_done_all_white_24dp)
.setContentIntent(PendingIntent.getActivity(context, 0, TaskIntents.getTaskListIntent(context, notifications), PendingIntent.FLAG_UPDATE_CURRENT)); .setContentIntent(PendingIntent.getActivity(context, 0, TaskIntents.getTaskListIntent(context, notifications), PendingIntent.FLAG_UPDATE_CURRENT));
if (notify) { if (notify) {
builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY)
.setPriority(NotificationCompat.PRIORITY_HIGH) .setPriority(NotificationCompat.PRIORITY_HIGH)
.setSound(preferences.getRingtone()); .setSound(preferences.getRingtone());
} else { } else {
builder.setOnlyAlertOnce(true) builder.setOnlyAlertOnce(true)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN); .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);

Loading…
Cancel
Save