Last active
August 29, 2015 14:14
-
-
Save auricgoldfinger/1b91bc6cb7aa70c15b15 to your computer and use it in GitHub Desktop.
Patch: adding more info to the Locus export in c:geo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: main/src/cgeo/geocaching/apps/AbstractLocusApp.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- main/src/cgeo/geocaching/apps/AbstractLocusApp.java (revision bdb08e4ebca8b7e6cc3c00d98fbb9b1702c8a378) | |
+++ main/src/cgeo/geocaching/apps/AbstractLocusApp.java (revision ) | |
@@ -2,10 +2,15 @@ | |
import cgeo.geocaching.CgeoApplication; | |
import cgeo.geocaching.Geocache; | |
+import cgeo.geocaching.LogEntry; | |
+import cgeo.geocaching.Trackable; | |
import cgeo.geocaching.Waypoint; | |
+import cgeo.geocaching.connector.gc.GCParser; | |
import cgeo.geocaching.enumerations.CacheSize; | |
import cgeo.geocaching.enumerations.CacheType; | |
+import cgeo.geocaching.enumerations.LogType; | |
import cgeo.geocaching.enumerations.WaypointType; | |
+import cgeo.geocaching.location.Geopoint; | |
import cgeo.geocaching.utils.SynchronizedDateFormat; | |
import menion.android.locus.LocusDataStorageProvider; | |
@@ -13,6 +18,8 @@ | |
import menion.android.locus.addon.publiclib.LocusUtils; | |
import menion.android.locus.addon.publiclib.geoData.Point; | |
import menion.android.locus.addon.publiclib.geoData.PointGeocachingData; | |
+import menion.android.locus.addon.publiclib.geoData.PointGeocachingDataLog; | |
+import menion.android.locus.addon.publiclib.geoData.PointGeocachingDataTravelBug; | |
import menion.android.locus.addon.publiclib.geoData.PointGeocachingDataWaypoint; | |
import menion.android.locus.addon.publiclib.geoData.PointsData; | |
@@ -22,6 +29,7 @@ | |
import android.app.Activity; | |
import android.location.Location; | |
+import java.text.SimpleDateFormat; | |
import java.util.ArrayList; | |
import java.util.Date; | |
import java.util.List; | |
@@ -147,12 +155,16 @@ | |
if (withWaypoints && cache.hasWaypoints()) { | |
pg.waypoints = new ArrayList<>(); | |
for (final Waypoint waypoint : cache.getWaypoints()) { | |
- if (waypoint == null || waypoint.getCoords() == null) { | |
+ if (waypoint == null) { | |
continue; | |
} | |
+ if (waypoint.getCoords() == null) { | |
+ waypoint.setCoords(new Geopoint(0,0)); | |
+ } | |
final PointGeocachingDataWaypoint wp = new PointGeocachingDataWaypoint(); | |
- wp.code = waypoint.getGeocode(); | |
+ wp.code = waypoint.getLookup(); | |
wp.name = waypoint.getName(); | |
+ wp.description = waypoint.getNote(); | |
final String locusWpId = toLocusWaypoint(waypoint.getWaypointType()); | |
if (locusWpId != null) { | |
wp.type = locusWpId; | |
@@ -171,8 +183,42 @@ | |
pg.shortDescription = cache.getShortDescription(); | |
pg.longDescription = cache.getDescription(); | |
pg.encodedHints = cache.getHint(); | |
+ | |
+ final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); | |
+ final List<Trackable> inventory = cache.getInventory(); | |
+ if (inventory != null) { | |
+ for (Trackable trackable : inventory) { | |
+ final PointGeocachingDataTravelBug travelBug = new PointGeocachingDataTravelBug(); | |
+ travelBug.name = trackable.getName(); | |
+ | |
+ // TODO this doesn't work as expected. And if it works, it might get configurable (slow process?) | |
+ final Trackable fullTrackable = GCParser.searchTrackable(null,trackable.getGuid(),null); | |
+ if (fullTrackable != null) { | |
+ travelBug.details = fullTrackable.getDetails(); | |
+ travelBug.goal = fullTrackable.getGoal(); | |
+ travelBug.imgUrl = fullTrackable.getImage(); | |
+ travelBug.origin = fullTrackable.getOrigin(); | |
+ travelBug.owner = fullTrackable.getOwner(); | |
+ travelBug.released = dateFormat.format(trackable.getReleased()); | |
+ travelBug.srcDetails = fullTrackable.getTrackingcode(); | |
- } | |
+ } | |
+ pg.travelBugs.add(travelBug); | |
+ } | |
+ } | |
+ final List<LogEntry> logs = cache.getLogs(); | |
+ for (LogEntry log : logs) { | |
+ final PointGeocachingDataLog dataLog = new PointGeocachingDataLog(); | |
+ dataLog.date = dateFormat.format(new Date(log.date)); | |
+ dataLog.finder = log.author; | |
+ dataLog.finderFound = log.found; | |
+ dataLog.id = log.id; | |
+ dataLog.logText = log.log; | |
+ dataLog.type = toLocusLogType(log.type) ; | |
+ pg.logs.add(dataLog); | |
+ } | |
+ } | |
+ | |
return p; | |
} | |
@@ -273,6 +319,41 @@ | |
return PointGeocachingData.CACHE_WAYPOINT_TYPE_STAGES; | |
default: | |
return null; | |
+ } | |
+ } | |
+ | |
+ private static int toLocusLogType(final LogType lt) { | |
+ switch (lt) { | |
+ case ANNOUNCEMENT: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_ANNOUNCEMENT; | |
+ case ATTENDED: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_ATTENDED; | |
+ case DIDNT_FIND_IT: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_NOT_FOUNDED; | |
+ case ENABLE_LISTING: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_ENABLE_LISTING; | |
+ case FOUND_IT: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_FOUNDED; | |
+ case NEEDS_ARCHIVE: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_NEEDS_ARCHIVED; | |
+ case NEEDS_MAINTENANCE: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_NEEDS_MAINTENANCE; | |
+ case NOTE: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_WRITE_NOTE; | |
+ case OWNER_MAINTENANCE: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_OWNER_MAINTENANCE; | |
+ case TEMP_DISABLE_LISTING: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_TEMPORARILY_DISABLE_LISTING; | |
+ case UNKNOWN: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_UNKNOWN; | |
+ case UPDATE_COORDINATES: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_UPDATE_COORDINATES; | |
+ case WEBCAM_PHOTO_TAKEN: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_WEBCAM_PHOTO_TAKEN; | |
+ case WILL_ATTEND: | |
+ return PointGeocachingData.CACHE_LOG_TYPE_WILL_ATTEND; | |
+ default: | |
+ return 0; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment