Added option for sending message as monospace message

This commit is contained in:
Sven Kubiak 2019-03-14 12:14:28 +01:00
parent f5ad9e859c
commit 21013a6297
2 changed files with 23 additions and 7 deletions

View File

@ -36,6 +36,7 @@ public class Message {
private String proxyHost;
private int proxyPort;
private boolean html;
private boolean monospace;
public Message() {
this.withSound(Sound.PUSHOVER);
@ -141,15 +142,28 @@ public class Message {
this.url = url;
return this;
}
/**
* Enables HTML in the pushover message
* Either HTML or monospace can be enabled
* (optional)
*
* @return Message instance
*/
public final Message enableMonospace() {
this.monospace = (this.html) ? false : true;
return this;
}
/**
* Enables HTML in the pushover message
* Either HTML or monospace can be enabled
* (optional)
*
* @return Message instance
*/
public final Message enableHtml() {
this.html = true;
this.html = (this.monospace) ? false : true;
return this;
}
@ -295,6 +309,7 @@ public class Message {
body.put(Param.TIMESTAMP.toString(), this.timestamp);
body.put(Param.SOUND.toString(), this.sound.toString());
body.put(Param.HTML.toString(), this.html ? "1" : "0");
body.put(Param.MONOSPACE.toString(), this.monospace ? "1" : "0");
return new PushoverRequest().push(MESSAGE_URL, body, this.proxyHost, this.proxyPort);
}

View File

@ -8,23 +8,24 @@ package de.svenkubiak.jpushover.enums;
public enum Param {
ATTACHMENT("attachment"),
CALLBACK("callback"),
COUNT("count"),
DEVICE("device"),
EXPIRE("expire"),
HTML("html"),
MESSAGE("message"),
MONOSPACE("monospace"),
PERCENT("percent"),
PRIORITY("priority"),
RETRY("retry"),
SOUND("sound"),
SUBTEXT("subtext"),
TEXT("text"),
TIMESTAMP("timestamp"),
TITLE("title"),
TOKEN("token"),
URL("url"),
URLTITLE("urltitle"),
USER("user"),
TEXT("text"),
SUBTEXT("subtext"),
COUNT("count"),
PERCENT("percent");
USER("user");
private final String value;