diff --git a/application/res/values/settings.xml b/application/res/values/settings.xml
index ad9ed75..2d3b2c0 100644
--- a/application/res/values/settings.xml
+++ b/application/res/values/settings.xml
@@ -15,6 +15,9 @@
24h_format
true
+ include_seconds
+ true
+
reconnect
false
diff --git a/application/res/values/strings.xml b/application/res/values/strings.xml
index 467ab93..d43778c 100644
--- a/application/res/values/strings.xml
+++ b/application/res/values/strings.xml
@@ -199,6 +199,8 @@
Prefix all messages with a timestamp
24 hour format
Use 24 hour format for timestamps
+ Show seconds
+ Include seconds in timestamps
Highlight
Play sound on highlight
diff --git a/application/res/xml/preferences.xml b/application/res/xml/preferences.xml
index 19c961a..51feba4 100644
--- a/application/res/xml/preferences.xml
+++ b/application/res/xml/preferences.xml
@@ -80,6 +80,12 @@ along with Yaaic. If not, see .
android:key="@string/key_24h_format"
android:defaultValue="@string/default_24h_format"
android:dependency="@string/key_show_timestamp" />
+
" : "";
- String timestamp = settings.showTimestamp() ? renderTimeStamp(settings.use24hFormat()) : "";
+ String timestamp = settings.showTimestamp() ? renderTimeStamp(settings.use24hFormat(), settings.includeSeconds()) : "";
canvas = new SpannableString(prefix + timestamp + nick);
SpannableString renderedText;
@@ -353,12 +353,13 @@ public class Message
* @param use24hFormat
* @return
*/
- public String renderTimeStamp(boolean use24hFormat)
+ public String renderTimeStamp(boolean use24hFormat, boolean includeSeconds)
{
Date date = new Date(timestamp);
int hours = date.getHours();
int minutes = date.getMinutes();
+ int seconds = date.getSeconds();
if (!use24hFormat) {
hours = Math.abs(12 - hours);
@@ -367,6 +368,17 @@ public class Message
}
}
- return "[" + (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + "] ";
+ if (includeSeconds) {
+ return String.format(
+ "[%02d:%02d:%02d]",
+ hours,
+ minutes,
+ seconds);
+ } else {
+ return String.format(
+ "[%02d:%02d]",
+ hours,
+ minutes);
+ }
}
}
diff --git a/application/src/org/yaaic/model/Settings.java b/application/src/org/yaaic/model/Settings.java
index bc63902..b2ff56d 100644
--- a/application/src/org/yaaic/model/Settings.java
+++ b/application/src/org/yaaic/model/Settings.java
@@ -119,6 +119,20 @@ public class Settings
);
}
+ /**
+ * Include seconds in timestamps?
+ *
+ * @return
+ */
+ public boolean includeSeconds()
+ {
+ return preferences.getBoolean(
+ resources.getString(R.string.key_include_seconds),
+ Boolean.parseBoolean(resources.getString(R.string.default_include_seconds))
+ );
+ }
+
+
/**
* Is reconnect on disconnect enabled?
*