@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Notification) { Notification that = (Notification) o; return (this.message.equals(that.message())) && (this.title.equals(that.title())) && ((this.subtitle == null) ? (that.subtitle() == null) : this.subtitle.equals(that.subtitle())) && (this.icon.equals(that.icon())) && (this.level.equals(that.level())); } return false; }
private String attachments(Notification notification) { return "[{" + "\"fallback\":\"" + notification.message() + "\"," + "\"color\":\"" + colorize(notification) + "\"," + "\"author_name\":\"" + application.name() + "\"," + "\"title\":\"" + notification.title() + "\"," + "\"text\":\"" + notification.message() + "\n" + notification.subtitle() + "\"," + "}]"; }
@Override public void send(Notification notification) { List<String> commands = new ArrayList<>(); commands.add(configuration.bin()); commands.add("-t"); commands.add(DOUBLE_QUOTE + notification.title() + DOUBLE_QUOTE); commands.add("-m"); commands.add(DOUBLE_QUOTE + notification.message() + DOUBLE_QUOTE); commands.add("-p"); commands.add(DOUBLE_QUOTE + notification.icon().asPath() + DOUBLE_QUOTE); try { executor.exec(commands.toArray(new String[0])); } catch (RuntimeException e) { throw new ToasterNotificationException("Error while sending notification with toaster", e); } }
public static Builder builder(String title, String message, Icon icon) { return builder() .title(title) .message(message) .icon(icon); }
@Override public void send(Notification notification) { List<String> commands = new ArrayList<>(); commands.add(configuration.bin()); commands.add("/p"); commands.add(escape(notification.title())); commands.add("/m"); commands.add(escape(notification.message())); commands.add("/d"); if (application.timeout() == -1) { commands.add(String.valueOf(TimeUnit.SECONDS.toMillis(10))); } else { commands.add(String.valueOf(application.timeout())); } commands.add("/t"); commands.add(toType(notification.level())); commands.add("/q"); try { executor.exec(commands.toArray(new String[0])); } catch (RuntimeException e) { throw new NotifuException("Error while sending notification to notifu.", e.getCause()); } }
commands.add("-title"); commands.add(application.name()); if (notification.subtitle() != null) { commands.add("-subtitle"); commands.add(notification.subtitle()); commands.add(notification.message()); commands.add("-group"); commands.add(application.id()); commands.add(notification.icon().asPath()); if (configuration.sound() != null) { commands.add("-sound");
private RequestBody buildRequestBody(Notification notification) { FormEncoding.Builder builder = new FormEncoding.Builder(); if (configuration.device() != null) { builder.add("device_iden", configuration.device()); } if (configuration.email() != null) { builder.add("email", configuration.email()); } builder.add("type", "note") .add("title", notification.title()) .add("body", notification.message()); ByteArrayOutputStream data; try { data = new ByteArrayOutputStream(); builder.build().writeBodyTo(data); } catch (IOException e) { String message = "Can't build request body."; LOGGER.error(message, e); throw new PushbulletNotificationException(message, e); } return RequestBody.create(MediaType.parse("application/x-www-form-urlencoded"), data.toByteArray()); }
private static String colorize(Notification notification) { switch (notification.level()) { case INFO: return "good"; case WARNING: return "warning"; case ERROR: return "danger"; default: return "warning"; } }
@Override public void send(Notification notification) { changeIcon(notification.icon()); }
public static Builder builder(String title, String message, Icon icon) { return builder() .title(title) .message(message) .icon(icon); }
@Override public void send(Notification notification) { List<String> commands = new ArrayList<>(); commands.add(configuration.bin()); commands.add("-t"); commands.add(DOUBLE_QUOTE + notification.title() + DOUBLE_QUOTE); commands.add("-m"); commands.add(DOUBLE_QUOTE + notification.message() + DOUBLE_QUOTE); commands.add("-p"); commands.add(DOUBLE_QUOTE + notification.icon().asPath() + DOUBLE_QUOTE); try { executor.exec(commands.toArray(new String[0])); } catch (RuntimeException e) { throw new ToasterNotificationException("Error while sending notification with toaster", e); } }
private String attachments(Notification notification) { return "[{" + "\"fallback\":\"" + notification.message() + "\"," + "\"color\":\"" + colorize(notification) + "\"," + "\"author_name\":\"" + application.name() + "\"," + "\"title\":\"" + notification.title() + "\"," + "\"text\":\"" + notification.message() + "\n" + notification.subtitle() + "\"," + "}]"; }
@Override public void send(Notification notification) { List<String> commands = new ArrayList<>(); commands.add(configuration.bin()); commands.add("/p"); commands.add(escape(notification.title())); commands.add("/m"); commands.add(escape(notification.message())); commands.add("/d"); if (application.timeout() == -1) { commands.add(String.valueOf(TimeUnit.SECONDS.toMillis(10))); } else { commands.add(String.valueOf(application.timeout())); } commands.add("/t"); commands.add(toType(notification.level())); commands.add("/q"); try { executor.exec(commands.toArray(new String[0])); } catch (RuntimeException e) { throw new NotifuException("Error while sending notification to notifu.", e.getCause()); } }
commands.add("-title"); commands.add(application.name()); if (notification.subtitle() != null) { commands.add("-subtitle"); commands.add(notification.subtitle()); commands.add(notification.message()); commands.add("-group"); commands.add(application.id()); commands.add(notification.icon().asPath()); if (configuration.sound() != null) { commands.add("-sound");
private RequestBody buildRequestBody(Notification notification) { FormEncoding.Builder builder = new FormEncoding.Builder(); if (configuration.device() != null) { builder.add("device_iden", configuration.device()); } if (configuration.email() != null) { builder.add("email", configuration.email()); } builder.add("type", "note") .add("title", notification.title()) .add("body", notification.message()); ByteArrayOutputStream data; try { data = new ByteArrayOutputStream(); builder.build().writeBodyTo(data); } catch (IOException e) { String message = "Can't build request body."; LOGGER.error(message, e); throw new PushbulletNotificationException(message, e); } return RequestBody.create(MediaType.parse("application/x-www-form-urlencoded"), data.toByteArray()); }
private static String colorize(Notification notification) { switch (notification.level()) { case INFO: return "good"; case WARNING: return "warning"; case ERROR: return "danger"; default: return "warning"; } }
@Override public void send(Notification notification) { changeIcon(notification.icon()); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Notification) { Notification that = (Notification) o; return (this.message.equals(that.message())) && (this.title.equals(that.title())) && ((this.subtitle == null) ? (that.subtitle() == null) : this.subtitle.equals(that.subtitle())) && (this.icon.equals(that.icon())) && (this.level.equals(that.level())); } return false; }
private void sendNotificationUsing(Notifier notify) { try { Notification.Builder notification = Notification.builder() .title(title) .message(message) .icon(notificationIcon()) .subtitle(subtitle); if (level != null) { notification.level(level); } notify.send(notification.build()); } finally { notify.close(); } }
@Override public void send(Notification notification) { List<String> commands = new ArrayList<>(); commands.add(configuration.bin()); commands.add("--passivepopup"); commands.add(notification.message()); if (application.timeout() != -1) { commands.add(String.valueOf(TimeUnit.MILLISECONDS.toSeconds(application.timeout()))); } commands.add("--title"); commands.add(notification.title()); commands.add("--icon"); commands.add(notification.icon().asPath()); try { executor.exec(commands.toArray(new String[0])); } catch (RuntimeException e) { throw new KdialogException("Error while sending notification with Kdialog.", e); } }