mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] Support icon in notifications
This commit is contained in:
parent
a34b2c206b
commit
d522976f0b
2 changed files with 20 additions and 2 deletions
|
@ -13,7 +13,7 @@ public NotifyCommand(LaunchServer server) {
|
|||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return "[head] [message]";
|
||||
return "[head] [message] (icon)";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,12 @@ public String getUsageDescription() {
|
|||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
verifyArgs(args, 2);
|
||||
NotificationEvent event = new NotificationEvent(args[0], args[1]);
|
||||
NotificationEvent event;
|
||||
if(args.length < 3) {
|
||||
event = new NotificationEvent(args[0], args[1]);
|
||||
} else {
|
||||
event = new NotificationEvent(args[0], args[1], Enum.valueOf(NotificationEvent.NotificationType.class, args[2]));
|
||||
}
|
||||
WebSocketService service = server.nettyServerSocketHandler.nettyServer.service;
|
||||
service.sendObjectAll(event, WebSocketEvent.class);
|
||||
}
|
||||
|
|
|
@ -8,14 +8,27 @@ public class NotificationEvent implements WebSocketEvent {
|
|||
public final String head;
|
||||
@LauncherNetworkAPI
|
||||
public final String message;
|
||||
@LauncherNetworkAPI
|
||||
public final NotificationType icon;
|
||||
|
||||
public NotificationEvent(String head, String message) {
|
||||
this.head = head;
|
||||
this.message = message;
|
||||
this.icon = NotificationType.INFO;
|
||||
}
|
||||
|
||||
public NotificationEvent(String head, String message, NotificationType icon) {
|
||||
this.head = head;
|
||||
this.message = message;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "notification";
|
||||
}
|
||||
|
||||
public enum NotificationType {
|
||||
INFO, WARN, ERROR, OTHER
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue