Added stackable notifications

pull/258/head
Rechee Jozil 9 years ago
parent 611dfa00a5
commit de45f3fe6b

@ -172,6 +172,9 @@ public class NotificationTray
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)
{
this.habit = habit;
@ -221,17 +224,29 @@ public class NotificationTray
.addAction(snoozeAction)
.setSound(getRingtoneUri(context))
.extend(wearableExtender)
.setGroup(GROUP_KEY_HABITS)
.setWhen(reminderTime)
.setShowWhen(true)
.setOngoing(preferences.shouldMakeNotificationsSticky())
.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) context.getSystemService(
Activity.NOTIFICATION_SERVICE);
int notificationId = getNotificationId(habit);
notificationManager.notify(notificationId, notification);
notificationManager.notify(SUMMARY_ID, summaryNotification);
}
private boolean shouldShowReminderToday()

@ -203,4 +203,5 @@
<string name="by_color">By color</string>
<string name="by_score">By score</string>
<string name="download">Download</string>
<string name="summary_notification_title">Habit Reminders</string>
</resources>
Loading…
Cancel
Save