|
|
@ -172,6 +172,9 @@ public class NotificationTray
|
|
|
|
|
|
|
|
|
|
|
|
private final long reminderTime;
|
|
|
|
private final long reminderTime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final String GROUP_KEY_HABITS = "group_key_habits";
|
|
|
|
|
|
|
|
private static final int SUMMARY_ID = 0;
|
|
|
|
|
|
|
|
|
|
|
|
public ShowNotificationTask(Habit habit, NotificationData data)
|
|
|
|
public ShowNotificationTask(Habit habit, NotificationData data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.habit = habit;
|
|
|
|
this.habit = habit;
|
|
|
@ -221,17 +224,29 @@ public class NotificationTray
|
|
|
|
.addAction(snoozeAction)
|
|
|
|
.addAction(snoozeAction)
|
|
|
|
.setSound(getRingtoneUri(context))
|
|
|
|
.setSound(getRingtoneUri(context))
|
|
|
|
.extend(wearableExtender)
|
|
|
|
.extend(wearableExtender)
|
|
|
|
|
|
|
|
.setGroup(GROUP_KEY_HABITS)
|
|
|
|
.setWhen(reminderTime)
|
|
|
|
.setWhen(reminderTime)
|
|
|
|
.setShowWhen(true)
|
|
|
|
.setShowWhen(true)
|
|
|
|
.setOngoing(preferences.shouldMakeNotificationsSticky())
|
|
|
|
.setOngoing(preferences.shouldMakeNotificationsSticky())
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//you need to create a summary notification to group notifications together.
|
|
|
|
|
|
|
|
Notification summaryNotification = new Builder(context)
|
|
|
|
|
|
|
|
.setSmallIcon(R.drawable.ic_notification)
|
|
|
|
|
|
|
|
.setContentTitle(context.getString(R.string.summary_notification_title))
|
|
|
|
|
|
|
|
.setWhen(reminderTime)
|
|
|
|
|
|
|
|
.setGroupSummary(true)
|
|
|
|
|
|
|
|
.setGroup(GROUP_KEY_HABITS)
|
|
|
|
|
|
|
|
.setShowWhen(true)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
NotificationManager notificationManager =
|
|
|
|
NotificationManager notificationManager =
|
|
|
|
(NotificationManager) context.getSystemService(
|
|
|
|
(NotificationManager) context.getSystemService(
|
|
|
|
Activity.NOTIFICATION_SERVICE);
|
|
|
|
Activity.NOTIFICATION_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
int notificationId = getNotificationId(habit);
|
|
|
|
int notificationId = getNotificationId(habit);
|
|
|
|
notificationManager.notify(notificationId, notification);
|
|
|
|
notificationManager.notify(notificationId, notification);
|
|
|
|
|
|
|
|
notificationManager.notify(SUMMARY_ID, summaryNotification);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean shouldShowReminderToday()
|
|
|
|
private boolean shouldShowReminderToday()
|
|
|
|