aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/LogEntry.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-10-06 08:11:37 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-10-06 08:11:37 +0200
commite1ab6d08f4573a58f5fc895c6332929d66766b0d (patch)
tree179acfe45319c97f468813789ed19031fa215265 /main/src/cgeo/geocaching/LogEntry.java
parentf43bfc70a519c1697443e7564730b31abf29e219 (diff)
downloadcgeo-e1ab6d08f4573a58f5fc895c6332929d66766b0d.zip
cgeo-e1ab6d08f4573a58f5fc895c6332929d66766b0d.tar.gz
cgeo-e1ab6d08f4573a58f5fc895c6332929d66766b0d.tar.bz2
#2074: Option to remove colors from log entries
* forgot TB logs
Diffstat (limited to 'main/src/cgeo/geocaching/LogEntry.java')
-rw-r--r--main/src/cgeo/geocaching/LogEntry.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/LogEntry.java b/main/src/cgeo/geocaching/LogEntry.java
index e03dc66..b625bb5 100644
--- a/main/src/cgeo/geocaching/LogEntry.java
+++ b/main/src/cgeo/geocaching/LogEntry.java
@@ -10,9 +10,13 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public final class LogEntry {
+ private static final Pattern PATTERN_REMOVE_COLORS = Pattern.compile("</?font.*?>", Pattern.CASE_INSENSITIVE);
+
public int id = 0;
public LogType type = LogType.UNKNOWN;
public String author = "";
@@ -97,4 +101,15 @@ public final class LogEntry {
public int daysSinceLog() {
return DateUtils.daysSince(date);
}
+
+ /**
+ * Get the log text to be displayed. Depending on the settings, color tags might be removed.
+ */
+ public String getDisplayText() {
+ if (Settings.getPlainLogs()) {
+ Matcher matcher = PATTERN_REMOVE_COLORS.matcher(log);
+ return matcher.replaceAll("");
+ }
+ return log;
+ }
}