From 632e6ad06c435ca8d044e5ae3209cde36cf42743 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 14 Mar 2017 09:11:11 +0500 Subject: - Use ternary operator - Apply server.forceSettings to speed units, distance units and timezone - Use hyphens for date formatting --- src/org/traccar/model/Server.java | 6 +----- src/org/traccar/model/User.java | 6 +----- src/org/traccar/reports/ReportUtils.java | 6 +++--- 3 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/org/traccar/model/Server.java b/src/org/traccar/model/Server.java index db3f021a9..4ded65204 100644 --- a/src/org/traccar/model/Server.java +++ b/src/org/traccar/model/Server.java @@ -171,11 +171,7 @@ public class Server extends Extensible { private String timezone; public void setTimezone(String timezone) { - if (timezone != null) { - this.timezone = TimeZone.getTimeZone(timezone).getID(); - } else { - this.timezone = null; - } + this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null; } public String getTimezone() { diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java index 71bb563a8..366ced503 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -269,11 +269,7 @@ public class User extends Extensible { private String timezone; public void setTimezone(String timezone) { - if (timezone != null) { - this.timezone = TimeZone.getTimeZone(timezone).getID(); - } else { - this.timezone = null; - } + this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null; } public String getTimezone() { diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 968fb357b..3699b1bea 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -33,7 +33,7 @@ public final class ReportUtils { public static String getDistanceUnit(long userId) { String unit = Context.getPermissionsManager().getUser(userId).getDistanceUnit(); - if (unit == null) { + if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) { unit = Context.getPermissionsManager().getServer().getDistanceUnit(); } return unit != null ? unit : "km"; @@ -41,7 +41,7 @@ public final class ReportUtils { public static String getSpeedUnit(long userId) { String unit = Context.getPermissionsManager().getUser(userId).getSpeedUnit(); - if (unit == null) { + if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) { unit = Context.getPermissionsManager().getServer().getSpeedUnit(); } return unit != null ? unit : "kn"; @@ -49,7 +49,7 @@ public final class ReportUtils { public static TimeZone getTimezone(long userId) { String timezone = Context.getPermissionsManager().getUser(userId).getTimezone(); - if (timezone == null) { + if (timezone == null || Context.getPermissionsManager().getServer().getForceSettings()) { timezone = Context.getPermissionsManager().getServer().getTimezone(); } return timezone != null ? TimeZone.getTimeZone(timezone) : TimeZone.getDefault(); -- cgit v1.2.3