From: David ‘Bombe’ Roden Date: Wed, 17 Nov 2010 20:46:12 +0000 (+0100) Subject: Add notifications for Sones that are rescued. X-Git-Tag: 0.3-RC1~10 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c26c8d115cd895ac1c187552ac46350a501c250a;p=Sone.git Add notifications for Sones that are rescued. --- 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> +