aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/PocketQueryList.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java13
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java17
-rw-r--r--main/src/cgeo/geocaching/export/GpxSerializer.java25
-rw-r--r--main/src/cgeo/geocaching/utils/TextUtils.java12
5 files changed, 56 insertions, 14 deletions
diff --git a/main/src/cgeo/geocaching/PocketQueryList.java b/main/src/cgeo/geocaching/PocketQueryList.java
index e1a921c..9d1110d 100644
--- a/main/src/cgeo/geocaching/PocketQueryList.java
+++ b/main/src/cgeo/geocaching/PocketQueryList.java
@@ -53,8 +53,7 @@ public final class PocketQueryList {
for (int i = 0; i < pocketQueryList.size(); i++) {
PocketQueryList pq = pocketQueryList.get(i);
-
- items[i] = pq.name + " (" + pq.maxCaches + ")";
+ items[i] = pq.name;
}
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
index 75ea056..a1c752c 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
@@ -24,7 +24,10 @@ abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNa
@Override
public void navigate(Activity activity, Geocache cache) {
- final Geopoint coords = cache.getCoords();
+ navigateWithNullCheck(activity, cache.getCoords());
+ }
+
+ private void navigateWithNullCheck(Activity activity, final Geopoint coords) {
if (coords != null) {
navigate(activity, coords);
} else {
@@ -34,13 +37,7 @@ abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNa
@Override
public void navigate(Activity activity, Waypoint waypoint) {
- final Geopoint coords = waypoint.getCoords();
- if (coords != null) {
- navigate(activity, coords);
- } else {
- ActivityMixin.showToast(activity, activity.getResources().getString(R.string.err_nav_no_coordinates));
- }
- navigate(activity, waypoint.getCoords());
+ navigateWithNullCheck(activity, waypoint.getCoords());
}
@Override
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 2be811a..4f5d293 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -56,6 +56,7 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
import java.util.EnumSet;
import java.util.GregorianCalendar;
@@ -1027,6 +1028,15 @@ public abstract class GCParser {
list.add(pqList);
}
+ // just in case, lets sort the resulting list
+ Collections.sort(list, new Comparator<PocketQueryList>() {
+
+ @Override
+ public int compare(PocketQueryList left, PocketQueryList right) {
+ return String.CASE_INSENSITIVE_ORDER.compare(left.getName(), right.getName());
+ }
+ });
+
return list;
}
@@ -1694,11 +1704,12 @@ public abstract class GCParser {
// better to integrate those coordinates into the text rather than not
// display them at all.
final String latLon = entry.getString("LatLonString");
+ final String logText = (StringUtils.isEmpty(latLon) ? "" : (latLon + "<br/><br/>")) + TextUtils.removeControlCharacters(entry.getString("LogText"));
final LogEntry logDone = new LogEntry(
- entry.getString("UserName"),
+ TextUtils.removeControlCharacters(entry.getString("UserName")),
date,
LogType.getByIconName(logIconName),
- (StringUtils.isEmpty(latLon) ? "" : (latLon + "<br/><br/>")) + entry.getString("LogText"));
+ logText);
logDone.found = entry.getInt("GeocacheFindCount");
logDone.friend = friends;
@@ -1706,7 +1717,7 @@ public abstract class GCParser {
for (int i = 0; i < images.length(); i++) {
final JSONObject image = images.getJSONObject(i);
final String url = "http://img.geocaching.com/cache/log/large/" + image.getString("FileName");
- final String title = image.getString("Name");
+ final String title = TextUtils.removeControlCharacters(image.getString("Name"));
final Image logImage = new Image(url, title);
logDone.addLogImage(logImage);
}
diff --git a/main/src/cgeo/geocaching/export/GpxSerializer.java b/main/src/cgeo/geocaching/export/GpxSerializer.java
index da179da..3ff8879 100644
--- a/main/src/cgeo/geocaching/export/GpxSerializer.java
+++ b/main/src/cgeo/geocaching/export/GpxSerializer.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.export;
import cgeo.geocaching.DataStore;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.LogEntry;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.Waypoint;
import cgeo.geocaching.enumerations.CacheAttribute;
import cgeo.geocaching.enumerations.LoadFlags;
@@ -11,6 +12,7 @@ import cgeo.geocaching.utils.TextUtils;
import cgeo.geocaching.utils.XmlUtils;
import cgeo.org.kxml2.io.KXmlSerializer;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.FastDateFormat;
@@ -103,7 +105,7 @@ public final class GpxSerializer {
gpx.startTag(PREFIX_GROUNDSPEAK, "cache");
gpx.attribute("", "id", cache.getCacheId());
gpx.attribute("", "available", !cache.isDisabled() ? "True" : "False");
- gpx.attribute("", "archives", cache.isArchived() ? "True" : "False");
+ gpx.attribute("", "archived", cache.isArchived() ? "True" : "False");
XmlUtils.multipleTexts(gpx, PREFIX_GROUNDSPEAK,
"name", cache.getName(),
@@ -130,6 +132,7 @@ public final class GpxSerializer {
gpx.endTag(PREFIX_GROUNDSPEAK, "long_description");
writeLogs(cache);
+ writeTravelBugs(cache);
gpx.endTag(PREFIX_GROUNDSPEAK, "cache");
gpx.endTag(PREFIX_GPX, "wpt");
@@ -229,6 +232,26 @@ public final class GpxSerializer {
gpx.endTag(PREFIX_GROUNDSPEAK, "logs");
}
+ private void writeTravelBugs(final Geocache cache) throws IOException {
+ List<Trackable> inventory = cache.getInventory();
+ if (CollectionUtils.isEmpty(inventory)) {
+ return;
+ }
+ gpx.startTag(PREFIX_GROUNDSPEAK, "travelbugs");
+
+ for (final Trackable trackable : inventory) {
+ gpx.startTag(PREFIX_GROUNDSPEAK, "travelbug");
+
+ // in most cases the geocode will be empty (only the guid is known). those travel bugs cannot be imported again!
+ gpx.attribute("", "ref", trackable.getGeocode());
+ XmlUtils.simpleText(gpx, PREFIX_GROUNDSPEAK, "name", trackable.getName());
+
+ gpx.endTag(PREFIX_GROUNDSPEAK, "travelbug");
+ }
+
+ gpx.endTag(PREFIX_GROUNDSPEAK, "travelbugs");
+ }
+
private void writeAttributes(final Geocache cache) throws IOException {
if (cache.getAttributes().isEmpty()) {
return;
diff --git a/main/src/cgeo/geocaching/utils/TextUtils.java b/main/src/cgeo/geocaching/utils/TextUtils.java
index 302a65d..14caf1d 100644
--- a/main/src/cgeo/geocaching/utils/TextUtils.java
+++ b/main/src/cgeo/geocaching/utils/TextUtils.java
@@ -153,4 +153,16 @@ public final class TextUtils {
return str.indexOf('<') != -1 || str.indexOf('&') != -1;
}
+ /**
+ * Remove all control characters (which are not valid in XML or HTML), as those should not appear in cache texts
+ * anyway
+ *
+ * @param input
+ * @return
+ */
+ public static String removeControlCharacters(final String input) {
+ Matcher remover = PATTERN_REMOVE_NONPRINTABLE.matcher(input);
+ return remover.replaceAll(" ").trim();
+ }
+
}