From c26c8d115cd895ac1c187552ac46350a501c250a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 17 Nov 2010 21:46:12 +0100 Subject: [PATCH] Add notifications for Sones that are rescued. --- .../net/pterodactylus/sone/core/CoreListener.java | 16 +++++++++++ .../sone/core/CoreListenerManager.java | 26 ++++++++++++++++++ .../net/pterodactylus/sone/web/WebInterface.java | 31 ++++++++++++++++++++++ src/main/resources/i18n/sone.en.properties | 4 +++ .../notify/rescuingSonesNotification.html | 6 +++++ .../templates/notify/sonesRescuedNotification.html | 7 +++++ 6 files changed, 90 insertions(+) create mode 100644 src/main/resources/templates/notify/rescuingSonesNotification.html create mode 100644 src/main/resources/templates/notify/sonesRescuedNotification.html diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index ca99e87..595d11a 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListener.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListener.java @@ -32,6 +32,22 @@ import net.pterodactylus.sone.data.Sone; public interface CoreListener extends EventListener { /** + * Notifies a listener that a Sone is now being rescued. + * + * @param sone + * The Sone that is rescued + */ + public void rescuingSone(Sone sone); + + /** + * Notifies a listener that the Sone was rescued and can now be unlocked. + * + * @param sone + * The Sone that was rescued + */ + public void rescuedSone(Sone sone); + + /** * Notifies a listener that a new Sone has been discovered. * * @param sone diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java index 74838a1..0fd8b1a 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java @@ -44,6 +44,32 @@ public class CoreListenerManager extends AbstractListenerManager newReplyNotification; + /** The “rescuing Sone” notification. */ + private final ListNotification rescuingSonesNotification; + + /** The “Sone rescued” notification. */ + private final ListNotification sonesRescuedNotification; + /** * Creates a new web interface. * @@ -158,6 +164,12 @@ public class WebInterface implements CoreListener { Template newReplyNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/newReplyNotification.html")); newReplyNotification = new ListNotification("new-replies-notification", "replies", newReplyNotificationTemplate); + + Template rescuingSonesTemplate = templateFactory.createTemplate(createReader("/templates/notify/rescuingSonesNotification.html")); + rescuingSonesNotification = new ListNotification("sones-being-rescued-notification", "sones", rescuingSonesTemplate); + + Template sonesRescuedTemplate = templateFactory.createTemplate(createReader("/templates/notify/sonesRescuedNotification.html")); + sonesRescuedNotification = new ListNotification("sones-rescued-notification", "sones", sonesRescuedTemplate); } // @@ -387,6 +399,25 @@ public class WebInterface implements CoreListener { * {@inheritDoc} */ @Override + public void rescuingSone(Sone sone) { + rescuingSonesNotification.add(sone); + notificationManager.addNotification(rescuingSonesNotification); + } + + /** + * {@inheritDoc} + */ + @Override + public void rescuedSone(Sone sone) { + rescuingSonesNotification.remove(sone); + sonesRescuedNotification.add(sone); + notificationManager.addNotification(sonesRescuedNotification); + } + + /** + * {@inheritDoc} + */ + @Override public void newSoneFound(Sone sone) { newSoneNotification.add(sone); notificationManager.addNotification(newSoneNotification); diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index efd6c76..a412903 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -173,3 +173,7 @@ Notification.Button.Dismiss=Dismiss Notification.NewSone.Text=New Sones have been discovered: Notification.NewPost.Text=New posts have been discovered by the following Sones: Notification.NewReply.Text=New replies have been discovered by the following Sones: +Notification.SoneIsBeingRescued.Text=The following Sones are currently being rescued: +Notification.SoneRescued.Text=The following Sones have been rescued: +Notification.SoneRescued.Text.RememberToUnlock=Please remember to control the posts and replies you have given and don’t forget to unlock your Sones! + diff --git a/src/main/resources/templates/notify/rescuingSonesNotification.html b/src/main/resources/templates/notify/rescuingSonesNotification.html new file mode 100644 index 0000000..eef06ac --- /dev/null +++ b/src/main/resources/templates/notify/rescuingSonesNotification.html @@ -0,0 +1,6 @@ +
+ <%= Notification.SoneIsBeingRescued.Text|l10n|html> + <%foreach sones sone> + <% sone.niceName|html><%notlast>,<%/notlast><%last>.<%/last> + <%/foreach> +
diff --git a/src/main/resources/templates/notify/sonesRescuedNotification.html b/src/main/resources/templates/notify/sonesRescuedNotification.html new file mode 100644 index 0000000..84f015d --- /dev/null +++ b/src/main/resources/templates/notify/sonesRescuedNotification.html @@ -0,0 +1,7 @@ +
+ <%= Notification.SoneRescued.Text|l10n|html> + <%foreach sones sone> + <% sone.niceName|html><%notlast>,<%/notlast><%last>.<%/last> + <%/foreach> + <%= Notification.SoneRescued.Text.RememberToUnlock|l10n|html> +
-- 2.7.4