diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-12 10:13:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-12 10:13:45 +0300 |
commit | 5d3b7cbe5924d4a4552035626a83e26b1e756255 (patch) | |
tree | 18c1caaba30f7bb9e6c21cce492d93a85ebc1c73 /src/org/traccar/notification/NotificationFormatter.java | |
parent | 1f11fa7db020f8a46e4b298dc61277460d76b678 (diff) | |
parent | 9a55f2b000956717d5caf6fb53793264c0376ce7 (diff) | |
download | traccar-server-5d3b7cbe5924d4a4552035626a83e26b1e756255.tar.gz traccar-server-5d3b7cbe5924d4a4552035626a83e26b1e756255.tar.bz2 traccar-server-5d3b7cbe5924d4a4552035626a83e26b1e756255.zip |
Merge pull request #2206 from Abyss777/ignition
Ignition and Motor Hours
Diffstat (limited to 'src/org/traccar/notification/NotificationFormatter.java')
-rw-r--r-- | src/org/traccar/notification/NotificationFormatter.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java index 449426df0..1d5257b4f 100644 --- a/src/org/traccar/notification/NotificationFormatter.java +++ b/src/org/traccar/notification/NotificationFormatter.java @@ -70,6 +70,23 @@ public final class NotificationFormatter { + "Point: http://www.openstreetmap.org/?mlat=%3$f&mlon=%4$f#map=16/%3$f/%4$f%n" + "Time: %2$tc%n"; + public static final String TITLE_TEMPLATE_TYPE_ALARM = "%1$s: alarm!"; + public static final String MESSAGE_TEMPLATE_TYPE_ALARM = "Device: %1$s%n" + + "Alarm: %5$s%n" + + "Point: http://www.openstreetmap.org/?mlat=%3$f&mlon=%4$f#map=16/%3$f/%4$f%n" + + "Time: %2$tc%n"; + + public static final String TITLE_TEMPLATE_TYPE_IGNITION_ON = "%1$s: ignition ON"; + public static final String MESSAGE_TEMPLATE_TYPE_IGNITION_ON = "Device: %1$s%n" + + "Ignition ON%n" + + "Point: http://www.openstreetmap.org/?mlat=%3$f&mlon=%4$f#map=16/%3$f/%4$f%n" + + "Time: %2$tc%n"; + public static final String TITLE_TEMPLATE_TYPE_IGNITION_OFF = "%1$s: ignition OFF"; + public static final String MESSAGE_TEMPLATE_TYPE_IGNITION_OFF = "Device: %1$s%n" + + "Ignition OFF%n" + + "Point: http://www.openstreetmap.org/?mlat=%3$f&mlon=%4$f#map=16/%3$f/%4$f%n" + + "Time: %2$tc%n"; + public static String formatTitle(long userId, Event event, Position position) { Device device = Context.getIdentityManager().getDeviceById(event.getDeviceId()); StringBuilder stringBuilder = new StringBuilder(); @@ -100,6 +117,15 @@ public final class NotificationFormatter { case Event.TYPE_GEOFENCE_EXIT: formatter.format(TITLE_TEMPLATE_TYPE_GEOFENCE_EXIT, device.getName()); break; + case Event.TYPE_ALARM: + formatter.format(TITLE_TEMPLATE_TYPE_ALARM, device.getName()); + break; + case Event.TYPE_IGNITION_ON: + formatter.format(TITLE_TEMPLATE_TYPE_IGNITION_ON, device.getName()); + break; + case Event.TYPE_IGNITION_OFF: + formatter.format(TITLE_TEMPLATE_TYPE_IGNITION_OFF, device.getName()); + break; default: formatter.format("Unknown type"); break; @@ -117,7 +143,7 @@ public final class NotificationFormatter { switch (event.getType()) { case Event.TYPE_COMMAND_RESULT: formatter.format(MESSAGE_TEMPLATE_TYPE_COMMAND_RESULT, device.getName(), event.getServerTime(), - position.getAttributes().get("result")); + position.getAttributes().get(Position.KEY_RESULT)); break; case Event.TYPE_DEVICE_ONLINE: formatter.format(MESSAGE_TEMPLATE_TYPE_DEVICE_ONLINE, device.getName(), event.getServerTime()); @@ -147,6 +173,19 @@ public final class NotificationFormatter { position.getLatitude(), position.getLongitude(), Context.getGeofenceManager().getGeofence(event.getGeofenceId()).getName()); break; + case Event.TYPE_ALARM: + formatter.format(MESSAGE_TEMPLATE_TYPE_ALARM, device.getName(), event.getServerTime(), + position.getLatitude(), position.getLongitude(), + position.getAttributes().get(Position.KEY_ALARM)); + break; + case Event.TYPE_IGNITION_ON: + formatter.format(MESSAGE_TEMPLATE_TYPE_IGNITION_ON, device.getName(), position.getFixTime(), + position.getLatitude(), position.getLongitude()); + break; + case Event.TYPE_IGNITION_OFF: + formatter.format(MESSAGE_TEMPLATE_TYPE_IGNITION_OFF, device.getName(), position.getFixTime(), + position.getLatitude(), position.getLongitude()); + break; default: formatter.format("Unknown type"); break; |