aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgeo/geocaching/apps/AbstractLocusApp.java155
-rwxr-xr-xsrc/cgeo/geocaching/apps/LocusDataStorageProvider.java68
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/LocusApp.java193
-rw-r--r--src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java3
-rw-r--r--src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java91
-rw-r--r--src/cgeo/geocaching/cgBase.java90
-rw-r--r--src/cgeo/geocaching/cgeocaches.java4
-rwxr-xr-xsrc/cgeo/geocaching/enumerations/CacheSize.java36
-rwxr-xr-xsrc/cgeo/geocaching/enumerations/CacheType.java56
-rwxr-xr-xsrc/cgeo/geocaching/enumerations/WaypointType.java35
10 files changed, 402 insertions, 329 deletions
diff --git a/src/cgeo/geocaching/apps/AbstractLocusApp.java b/src/cgeo/geocaching/apps/AbstractLocusApp.java
index b0e9249..1b21b8e 100644
--- a/src/cgeo/geocaching/apps/AbstractLocusApp.java
+++ b/src/cgeo/geocaching/apps/AbstractLocusApp.java
@@ -1,24 +1,167 @@
package cgeo.geocaching.apps;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import menion.android.locus.addon.publiclib.DisplayData;
+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.PointGeocachingDataWaypoint;
+import menion.android.locus.addon.publiclib.geoData.PointsData;
+import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
-import android.net.Uri;
+import android.location.Location;
import cgeo.geocaching.R;
+import cgeo.geocaching.cgCache;
+import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.enumerations.CacheSize;
+import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.WaypointType;
+/**
+ * @see http://forum.asamm.cz/viewtopic.php?f=29&t=767
+ */
public abstract class AbstractLocusApp extends AbstractApp {
private static final String INTENT = Intent.ACTION_VIEW;
-
+ private static final SimpleDateFormat ISO8601DATE = new SimpleDateFormat("yyyy-MM-dd'T'");
+
protected AbstractLocusApp(final Resources res) {
super(res.getString(R.string.caches_map_locus), INTENT);
}
@Override
- public boolean isInstalled(final Context context) {
- final Intent intentTest = new Intent(INTENT);
- intentTest.setData(Uri.parse("menion.points:x"));
- return isIntentAvailable(context, intentTest);
+ public boolean isInstalled(Context context) {
+ return LocusUtils.isLocusAvailable(context);
+ }
+
+ /**
+ * Display a list of caches / waypoints in Locus
+ *
+ * @param objectsToShow which caches/waypoints to show
+ * @param withCacheWaypoints wether to give waypoints of caches to Locus or not
+ * @param activity
+ * @author koem
+ */
+ protected void showInLocus(List<? extends Object> objectsToShow, boolean withCacheWaypoints,
+ Activity activity) {
+ if (objectsToShow == null) return;
+
+ int pc = 0; // counter for points
+ PointsData pd = new PointsData("c:geo");
+ for (Object o : objectsToShow) {
+ // get icon and Point
+ Point p = null;
+ if (o instanceof cgCache) {
+ p = this.getPoint((cgCache) o, withCacheWaypoints);
+ } else if (o instanceof cgWaypoint) {
+ p = this.getPoint((cgWaypoint) o);
+ } else {
+ continue; // no cache, no waypoint => ignore
+ }
+ if (p == null) continue;
+
+ pd.addPoint(p);
+ ++pc;
+ }
+
+ if (pc <= 1000) {
+ DisplayData.sendData(activity, pd, false);
+ } else {
+ ArrayList<PointsData> data = new ArrayList<PointsData>();
+ data.add(pd);
+ DisplayData.sendDataCursor(activity, data,
+ "content://" + LocusDataStorageProvider.class.getCanonicalName().toLowerCase(),
+ false);
+ }
+ }
+
+ /**
+ * This method constructs a <code>Point</code> for displaying in Locus
+ *
+ * @param cache
+ * @param withWaypoints wether to give waypoints to Locus or not
+ * @return null, when the <code>Point</code> could not be constructed
+ * @author koem
+ */
+ private Point getPoint(cgCache cache, boolean withWaypoints) {
+ if (cache == null || cache.coords == null) return null;
+
+ // create one simple point with location
+ Location loc = new Location(cgSettings.tag);
+ loc.setLatitude(cache.coords.getLatitude());
+ loc.setLongitude(cache.coords.getLongitude());
+
+ Point p = new Point(cache.name, loc);
+ PointGeocachingData pg = new PointGeocachingData();
+ p.setGeocachingData(pg);
+
+ // set data in Locus' cache
+ pg.cacheID = cache.geocode;
+ pg.available = ! cache.disabled;
+ pg.archived = cache.archived;
+ pg.premiumOnly = cache.members;
+ pg.name = cache.name;
+ pg.placedBy = cache.owner;
+ if (cache.hidden != null) pg.hidden = ISO8601DATE.format(cache.hidden.getTime());
+ CacheType ct = CacheType.findByCgeoId(cache.type);
+ if (ct != null && ct.locusId != CacheType.NO_LOCUS_ID) pg.type = ct.locusId;
+ CacheSize cs = CacheSize.findByCgeoId(cache.size);
+ if (cs != null) pg.container = cs.locusId;
+ if (cache.difficulty != null) pg.difficulty = cache.difficulty;
+ if (cache.terrain != null) pg.terrain = cache.terrain;
+ pg.found = cache.found;
+
+ if (withWaypoints && cache.waypoints != null) {
+ pg.waypoints = new ArrayList<PointGeocachingDataWaypoint>();
+ for (cgWaypoint waypoint : cache.waypoints) {
+ if (waypoint == null || waypoint.coords == null) continue;
+ PointGeocachingDataWaypoint wp = new PointGeocachingDataWaypoint();
+ wp.code = waypoint.geocode;
+ wp.name = waypoint.name;
+ WaypointType wt = WaypointType.findByCgeoId(waypoint.type);
+ if (wt != null) wp.type = wt.locusId;
+ wp.lat = waypoint.coords.getLatitude();
+ wp.lon = waypoint.coords.getLongitude();
+ pg.waypoints.add(wp);
+ }
+ }
+
+ // Other properties of caches, not used yet. When there are many caches to be displayed
+ // in Locus, using these properties can lead to Exceptions in Locus.
+ // Examination necessary when to display and when not. E. g.: > 200 caches: don't display
+ // these properties.
+
+ //pg.shortDescription = cache.shortdesc;
+ //pg.longDescription = cache.description;
+ //pg.encodedHints = cache.hint;
+
+ return p;
}
+ /**
+ * This method constructs a <code>Point</code> for displaying in Locus
+ *
+ * @param waypoint
+ * @return null, when the <code>Point</code> could not be constructed
+ * @author koem
+ */
+ private Point getPoint(cgWaypoint waypoint) {
+ if (waypoint == null || waypoint.coords == null) return null;
+
+ // create one simple point with location
+ Location loc = new Location(cgSettings.tag);
+ loc.setLatitude(waypoint.coords.getLatitude());
+ loc.setLongitude(waypoint.coords.getLongitude());
+
+ Point p = new Point(waypoint.name, loc);
+ p.setDescription("<a href=\"http://coord.info/" + waypoint.geocode + "\">"
+ + waypoint.geocode + "</a>");
+ return p;
+ }
}
diff --git a/src/cgeo/geocaching/apps/LocusDataStorageProvider.java b/src/cgeo/geocaching/apps/LocusDataStorageProvider.java
new file mode 100755
index 0000000..8da7160
--- /dev/null
+++ b/src/cgeo/geocaching/apps/LocusDataStorageProvider.java
@@ -0,0 +1,68 @@
+package cgeo.geocaching.apps;
+
+import java.util.ArrayList;
+
+import menion.android.locus.addon.publiclib.geoData.PointsData;
+import menion.android.locus.addon.publiclib.utils.DataCursor;
+import menion.android.locus.addon.publiclib.utils.DataStorage;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Parcel;
+
+public class LocusDataStorageProvider extends ContentProvider {
+
+// private final static String TAG = "DataStorageProvider";
+
+ @Override
+ public Cursor query(Uri aUri, String[] aProjection, String aSelection,
+ String[] aSelectionArgs, String aSortOrder) {
+
+ DataCursor cursor = new DataCursor(new String[] {"data"});
+
+ ArrayList<PointsData> data = DataStorage.getData();
+ if (data == null || data.size() == 0)
+ return cursor;
+
+ for (int i = 0; i < data.size(); i++) {
+ // get byte array
+ Parcel par = Parcel.obtain();
+ data.get(i).writeToParcel(par, 0);
+ byte[] byteData = par.marshall();
+ // add to row
+ cursor.addRow(new Object[] {byteData});
+ }
+ // data filled to cursor, clear reference to prevent some memory issue
+ DataStorage.clearData();
+ // now finally return filled cursor
+ return cursor;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public boolean onCreate() {
+ return false;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection,
+ String[] selectionArgs) {
+ return 0;
+ }
+
+}
diff --git a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
index 3c9928e..557c298 100644
--- a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
@@ -1,26 +1,15 @@
package cgeo.geocaching.apps.cache.navi;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
import java.util.ArrayList;
-import java.util.List;
import java.util.UUID;
-import org.apache.commons.lang3.StringUtils;
-
import android.app.Activity;
-import android.content.Intent;
import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import cgeo.geocaching.cgBase;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractLocusApp;
import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.utils.CollectionUtils;
class LocusApp extends AbstractLocusApp implements NavigationApp {
@@ -28,173 +17,41 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
super(res);
}
+ /**
+ * Show a single cache with waypoints or a single waypoint in Locus.
+ * This method constructs a list of cache and waypoints only.
+ *
+ * @see AbstractLocusApp#showInLocus
+ * @author koem
+ */
@Override
- public boolean invoke(cgGeo geo, Activity activity, Resources res,
- cgCache cache,
+ public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache,
final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+
if (cache == null && waypoint == null && coords == null) {
return false;
}
- try {
- if (isInstalled(activity)) {
- final List<cgWaypoint> waypoints = new ArrayList<cgWaypoint>();
- // get only waypoints with coordinates
- if (cache != null && cache.waypoints != null
- && cache.waypoints.isEmpty() == false) {
- for (cgWaypoint wp : cache.waypoints) {
- if (wp.coords != null) {
- waypoints.add(wp);
- }
- }
- }
-
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final DataOutputStream dos = new DataOutputStream(baos);
-
- dos.writeInt(1); // not used
- if (cache != null) {
- if (waypoints == null || waypoints.isEmpty()) {
- dos.writeInt(1); // cache only
- } else {
- dos.writeInt((1 + waypoints.size())); // cache and
- // waypoints
- }
- } else {
- dos.writeInt(1); // one waypoint
- }
-
- int icon = -1;
- if (cache != null) {
- icon = cgBase.getMarkerIcon(true, cache.type, cache.own, cache.found,
- cache.disabled || cache.archived);
- } else if (waypoint != null) {
- icon = cgBase.getMarkerIcon(false, waypoint.type, false, false, false);
- } else {
- icon = cgBase.getMarkerIcon(false, "waypoint", false, false, false);
- }
-
- if (icon > 0) {
- // load icon
- Bitmap bitmap = BitmapFactory.decodeResource(res, icon);
- ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos2);
- byte[] image = baos2.toByteArray();
-
- dos.writeInt(image.length);
- dos.write(image);
- } else {
- // no icon
- dos.writeInt(0); // no image
- }
-
- // name
- if (cache != null && StringUtils.isNotBlank(cache.name)) {
- dos.writeUTF(cache.name);
- } else if (waypoint != null && StringUtils.isNotBlank(waypoint.name)) {
- dos.writeUTF(waypoint.name);
- } else {
- dos.writeUTF("");
- }
-
- // description
- if (cache != null && StringUtils.isNotBlank(cache.geocode)) {
- dos.writeUTF(cache.geocode.toUpperCase());
- } else if (waypoint != null && StringUtils.isNotBlank(waypoint.lookup)) {
- dos.writeUTF(waypoint.lookup.toUpperCase());
- } else {
- dos.writeUTF("");
- }
-
- // additional data :: keyword, button title, package, activity,
- // data name, data content
- if (cache != null && StringUtils.isNotBlank(cache.geocode)) {
- dos.writeUTF("intent;c:geo;cgeo.geocaching;cgeo.geocaching.cgeodetail;geocode;"
- + cache.geocode);
- } else if (waypoint != null && waypoint.id != null
- && waypoint.id > 0) {
- dos.writeUTF("intent;c:geo;cgeo.geocaching;cgeo.geocaching.cgeowaypoint;id;"
- + waypoint.id);
- } else {
- dos.writeUTF("");
- }
-
- if (cache != null && cache.coords != null) {
- dos.writeDouble(cache.coords.getLatitude()); // latitude
- dos.writeDouble(cache.coords.getLongitude()); // longitude
- } else if (waypoint != null && waypoint.coords != null) {
- dos.writeDouble(waypoint.coords.getLatitude()); // latitude
- dos.writeDouble(waypoint.coords.getLongitude()); // longitude
- } else {
- dos.writeDouble(coords.getLatitude()); // latitude
- dos.writeDouble(coords.getLongitude()); // longitude
- }
-
- // cache waypoints
- if (CollectionUtils.isNotEmpty(waypoints)) {
- for (cgWaypoint wp : waypoints) {
- if (wp == null || wp.coords == null) {
- continue;
- }
- final int wpIcon = cgBase.getMarkerIcon(false, wp.type, false,
- false, false);
+ if (isInstalled(activity)) { // TODO: is this if-statement really necessary?
+ final ArrayList<Object> points = new ArrayList<Object>();
- if (wpIcon > 0) {
- // load icon
- Bitmap bitmap = BitmapFactory.decodeResource(res,
- wpIcon);
- ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.PNG, 100,
- baos2);
- byte[] image = baos2.toByteArray();
-
- dos.writeInt(image.length);
- dos.write(image);
- } else {
- // no icon
- dos.writeInt(0); // no image
- }
-
- // name
- if (StringUtils.isNotBlank(wp.lookup)) {
- dos.writeUTF(wp.lookup.toUpperCase());
- } else {
- dos.writeUTF("");
- }
-
- // description
- if (StringUtils.isNotBlank(wp.name)) {
- dos.writeUTF(wp.name);
- } else {
- dos.writeUTF("");
- }
-
- // additional data :: keyword, button title, package,
- // activity, data name, data content
- if (wp.id != null && wp.id > 0) {
- dos.writeUTF("intent;c:geo;cgeo.geocaching;cgeo.geocaching.cgeowaypoint;id;"
- + wp.id);
- } else {
- dos.writeUTF("");
- }
-
- dos.writeDouble(wp.coords.getLatitude()); // latitude
- dos.writeDouble(wp.coords.getLongitude()); // longitude
- }
- }
-
- final Intent intent = new Intent();
- intent.setAction(Intent.ACTION_VIEW);
- intent.setData(Uri.parse("menion.points:data"));
- intent.putExtra("data", baos.toByteArray());
-
- activity.startActivity(intent);
+ // add cache if present
+ if (cache != null) {
+ if (cache.coords == null) cache.coords = coords;
+ if (cache.coords != null) points.add(cache);
+ }
- return true;
+ // add waypoint if present
+ if (waypoint != null) {
+ if (waypoint.coords == null) waypoint.coords = coords;
+ if (waypoint.coords != null) points.add(waypoint);
}
- } catch (Exception e) {
- // nothing
+
+ this.showInLocus(points, true, activity);
+
+ return true;
}
+
return false;
}
diff --git a/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
index cb69e17..91e547a 100644
--- a/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
+++ b/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
@@ -64,8 +64,7 @@ public final class CacheListAppFactory extends AbstractAppFactory {
public static boolean onMenuItemSelected(final MenuItem item,
final cgGeo geo, final List<cgCache> caches, final Activity activity, final Resources res,
final UUID searchId) {
- CacheListApp app = (CacheListApp) getAppFromMenuItem(
- item, apps);
+ CacheListApp app = (CacheListApp) getAppFromMenuItem(item, apps);
if (app != null) {
try {
return app.invoke(geo, caches, activity, res, searchId);
diff --git a/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java b/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
index 41a1cdd..a18010a 100644
--- a/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
+++ b/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
@@ -1,20 +1,10 @@
package cgeo.geocaching.apps.cachelist;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import org.apache.commons.lang3.StringUtils;
-
import android.app.Activity;
-import android.content.Intent;
import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import cgeo.geocaching.cgBase;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.apps.AbstractLocusApp;
@@ -25,78 +15,19 @@ class LocusCacheListApp extends AbstractLocusApp implements CacheListApp {
super(res);
}
+ /**
+ * show caches in Locus
+ *
+ * @see AbstractLocusApp#showInLocus
+ * @author koem
+ */
@Override
- public boolean invoke(cgGeo geo, List<cgCache> cacheList, Activity activity, Resources res, final UUID searchId) {
- if (cacheList == null || cacheList.isEmpty()) {
- return false;
- }
-
- try {
- final List<cgCache> cacheListCoord = new ArrayList<cgCache>();
- for (cgCache cache : cacheList) {
- if (cache.coords != null) {
- cacheListCoord.add(cache);
- }
- }
-
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final DataOutputStream dos = new DataOutputStream(baos);
-
- dos.writeInt(1); // not used
- dos.writeInt(cacheListCoord.size()); // cache and waypoints
-
- // cache waypoints
- for (cgCache cache : cacheListCoord) {
- final int wpIcon = cgBase.getMarkerIcon(true, cache.type, cache.own, cache.found, cache.disabled);
-
- if (wpIcon > 0) {
- // load icon
- Bitmap bitmap = BitmapFactory.decodeResource(res, wpIcon);
- ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos2);
- byte[] image = baos2.toByteArray();
-
- dos.writeInt(image.length);
- dos.write(image);
- } else {
- // no icon
- dos.writeInt(0); // no image
- }
-
- // name
- if (StringUtils.isNotBlank(cache.geocode)) {
- dos.writeUTF(cache.geocode.toUpperCase());
- } else {
- dos.writeUTF("");
- }
-
- // description
- if (StringUtils.isNotBlank(cache.name)) {
- dos.writeUTF(cache.name);
- } else {
- dos.writeUTF("");
- }
-
- // additional data :: keyword, button title, package, activity, data name, data content
- if (StringUtils.isNotBlank(cache.geocode)) {
- dos.writeUTF("intent;c:geo;cgeo.geocaching;cgeo.geocaching.cgeodetail;geocode;" + cache.geocode);
- } else {
- dos.writeUTF("");
- }
-
- dos.writeDouble(cache.coords.getLatitude()); // latitude
- dos.writeDouble(cache.coords.getLongitude()); // longitude
- }
-
- final Intent intent = new Intent();
- intent.setAction(Intent.ACTION_VIEW);
- intent.setData(Uri.parse("menion.points:data"));
- intent.putExtra("data", baos.toByteArray());
+ public boolean invoke(cgGeo geo, List<cgCache> cacheList, Activity activity, Resources res,
+ final UUID searchId) {
+ if (cacheList == null || cacheList.isEmpty()) return false;
+
+ this.showInLocus((List<? extends Object>) cacheList, false, activity);
- activity.startActivity(intent);
- } catch (Exception e) {
- // nothing
- }
return true;
}
diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java
index 72743b9..933d9df 100644
--- a/src/cgeo/geocaching/cgBase.java
+++ b/src/cgeo/geocaching/cgBase.java
@@ -70,6 +70,7 @@ import android.text.style.StrikethroughSpan;
import android.util.Log;
import android.widget.EditText;
import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.files.LocParser;
import cgeo.geocaching.geopoint.DistanceParser;
import cgeo.geocaching.geopoint.Geopoint;
@@ -214,75 +215,20 @@ public class cgBase {
context = appIn.getBaseContext();
res = appIn.getBaseContext().getResources();
- // cache types
- cacheTypes.put("traditional cache", "traditional");
- cacheTypes.put("multi-cache", "multi");
- cacheTypes.put("unknown cache", "mystery");
- cacheTypes.put("letterbox hybrid", "letterbox");
- cacheTypes.put("event cache", "event");
- cacheTypes.put("mega-event cache", "mega");
- cacheTypes.put("earthcache", "earth");
- cacheTypes.put("cache in trash out event", "cito");
- cacheTypes.put("webcam cache", "webcam");
- cacheTypes.put("virtual cache", "virtual");
- cacheTypes.put("wherigo cache", "wherigo");
- cacheTypes.put("lost & found", "lostfound");
- cacheTypes.put("project ape cache", "ape");
- cacheTypes.put("groundspeak hq", "gchq");
- cacheTypes.put("gps cache exhibit", "gps");
-
- // cache types inverted
- cacheTypesInv.put("traditional", res.getString(R.string.traditional));
- cacheTypesInv.put("multi", res.getString(R.string.multi));
- cacheTypesInv.put("mystery", res.getString(R.string.mystery));
- cacheTypesInv.put("letterbox", res.getString(R.string.letterbox));
- cacheTypesInv.put("event", res.getString(R.string.event));
- cacheTypesInv.put("mega", res.getString(R.string.mega));
- cacheTypesInv.put("earth", res.getString(R.string.earth));
- cacheTypesInv.put("cito", res.getString(R.string.cito));
- cacheTypesInv.put("webcam", res.getString(R.string.webcam));
- cacheTypesInv.put("virtual", res.getString(R.string.virtual));
- cacheTypesInv.put("wherigo", res.getString(R.string.wherigo));
- cacheTypesInv.put("lostfound", res.getString(R.string.lostfound));
- cacheTypesInv.put("ape", res.getString(R.string.ape));
- cacheTypesInv.put("gchq", res.getString(R.string.gchq));
- cacheTypesInv.put("gps", res.getString(R.string.gps));
-
- // cache ids
- cacheIDs.put("all", "9a79e6ce-3344-409c-bbe9-496530baf758"); // hard-coded also in cgSettings
- cacheIDs.put("traditional", "32bc9333-5e52-4957-b0f6-5a2c8fc7b257");
- cacheIDs.put("multi", "a5f6d0ad-d2f2-4011-8c14-940a9ebf3c74");
- cacheIDs.put("mystery", "40861821-1835-4e11-b666-8d41064d03fe");
- cacheIDs.put("letterbox", "4bdd8fb2-d7bc-453f-a9c5-968563b15d24");
- cacheIDs.put("event", "69eb8534-b718-4b35-ae3c-a856a55b0874");
- cacheIDs.put("mega-event", "69eb8535-b718-4b35-ae3c-a856a55b0874");
- cacheIDs.put("earth", "c66f5cf3-9523-4549-b8dd-759cd2f18db8");
- cacheIDs.put("cito", "57150806-bc1a-42d6-9cf0-538d171a2d22");
- cacheIDs.put("webcam", "31d2ae3c-c358-4b5f-8dcd-2185bf472d3d");
- cacheIDs.put("virtual", "294d4360-ac86-4c83-84dd-8113ef678d7e");
- cacheIDs.put("wherigo", "0544fa55-772d-4e5c-96a9-36a51ebcf5c9");
- cacheIDs.put("lostfound", "3ea6533d-bb52-42fe-b2d2-79a3424d4728");
- cacheIDs.put("ape", "2555690d-b2bc-4b55-b5ac-0cb704c0b768");
- cacheIDs.put("gchq", "416f2494-dc17-4b6a-9bab-1a29dd292d8c");
- cacheIDs.put("gps", "72e69af2-7986-4990-afd9-bc16cbbb4ce3");
-
- // cache choices
- cacheIDsChoices.put(res.getString(R.string.all), cacheIDs.get("all"));
- cacheIDsChoices.put(res.getString(R.string.traditional), cacheIDs.get("traditional"));
- cacheIDsChoices.put(res.getString(R.string.multi), cacheIDs.get("multi"));
- cacheIDsChoices.put(res.getString(R.string.mystery), cacheIDs.get("mystery"));
- cacheIDsChoices.put(res.getString(R.string.letterbox), cacheIDs.get("letterbox"));
- cacheIDsChoices.put(res.getString(R.string.event), cacheIDs.get("event"));
- cacheIDsChoices.put(res.getString(R.string.mega), cacheIDs.get("mega"));
- cacheIDsChoices.put(res.getString(R.string.earth), cacheIDs.get("earth"));
- cacheIDsChoices.put(res.getString(R.string.cito), cacheIDs.get("cito"));
- cacheIDsChoices.put(res.getString(R.string.webcam), cacheIDs.get("webcam"));
- cacheIDsChoices.put(res.getString(R.string.virtual), cacheIDs.get("virtual"));
- cacheIDsChoices.put(res.getString(R.string.wherigo), cacheIDs.get("whereigo"));
- cacheIDsChoices.put(res.getString(R.string.lostfound), cacheIDs.get("lostfound"));
- cacheIDsChoices.put(res.getString(R.string.ape), cacheIDs.get("ape"));
- cacheIDsChoices.put(res.getString(R.string.gchq), cacheIDs.get("gchq"));
- cacheIDsChoices.put(res.getString(R.string.gps), cacheIDs.get("gps"));
+ // setup cache type mappings
+
+ final String CACHETYPE_ALL_GUID = "9a79e6ce-3344-409c-bbe9-496530baf758";
+
+ cacheIDs.put("all", CACHETYPE_ALL_GUID);
+ cacheIDsChoices.put(res.getString(R.string.all), CACHETYPE_ALL_GUID);
+
+ for (CacheType ct : CacheType.values()) {
+ String l10n = res.getString(ct.stringId);
+ cacheTypes.put(ct.pattern, ct.cgeoId);
+ cacheTypesInv.put(ct.cgeoId, l10n);
+ cacheIDs.put(ct.cgeoId, ct.guid);
+ cacheIDsChoices.put(l10n, ct.guid);
+ }
// waypoint types
waypointTypes.put("flag", res.getString(R.string.wp_final));
@@ -5009,7 +4955,8 @@ public class cgBase {
* @return the formatted string
*/
public String formatFullDate(long date) {
- return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR);
+ return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE
+ | DateUtils.FORMAT_SHOW_YEAR);
}
/**
@@ -5020,7 +4967,8 @@ public class cgBase {
* @return the formatted string
*/
public String formatShortDate(long date) {
- return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE);
+ return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE
+ | DateUtils.FORMAT_NUMERIC_DATE);
}
/**
diff --git a/src/cgeo/geocaching/cgeocaches.java b/src/cgeo/geocaching/cgeocaches.java
index 7a423b1..e87def5 100644
--- a/src/cgeo/geocaching/cgeocaches.java
+++ b/src/cgeo/geocaching/cgeocaches.java
@@ -31,7 +31,6 @@ import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ContextMenu;
-import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -39,11 +38,12 @@ import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.WindowManager;
-import android.widget.AdapterView.AdapterContextMenuInfo;
+import android.view.ContextMenu.ContextMenuInfo;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import android.widget.AdapterView.AdapterContextMenuInfo;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.activity.AbstractListActivity;
import cgeo.geocaching.activity.ActivityMixin;
diff --git a/src/cgeo/geocaching/enumerations/CacheSize.java b/src/cgeo/geocaching/enumerations/CacheSize.java
new file mode 100755
index 0000000..1d0577d
--- /dev/null
+++ b/src/cgeo/geocaching/enumerations/CacheSize.java
@@ -0,0 +1,36 @@
+package cgeo.geocaching.enumerations;
+
+import menion.android.locus.addon.publiclib.geoData.PointGeocachingData;
+
+/**
+ * Enum listing cache sizes
+ *
+ * @author koem
+ */
+public enum CacheSize {
+ MICRO ("micro", 1, PointGeocachingData.CACHE_SIZE_MICRO),
+ SMALL ("small", 2, PointGeocachingData.CACHE_SIZE_SMALL),
+ REGULAR ("regular", 3, PointGeocachingData.CACHE_SIZE_REGULAR),
+ LARGE ("large", 4, PointGeocachingData.CACHE_SIZE_LARGE),
+ NOT_CHOSEN ("not chosen", 0, PointGeocachingData.CACHE_SIZE_NOT_CHOSEN),
+ OTHER ("other", 0, PointGeocachingData.CACHE_SIZE_OTHER);
+
+ public final String cgeoId;
+ public final int comparable;
+ public final int locusId;
+
+ private CacheSize(String cgeoId, int comparable, int locusId) {
+ this.cgeoId = cgeoId;
+ this.comparable = comparable;
+ this.locusId = locusId;
+ }
+
+ public static CacheSize findByCgeoId(String cgeoId) {
+ if (cgeoId == null) return null;
+ for (CacheSize cs : CacheSize.values()) {
+ if (cs.cgeoId.equals(cgeoId)) return cs;
+ }
+ return null;
+ }
+
+}
diff --git a/src/cgeo/geocaching/enumerations/CacheType.java b/src/cgeo/geocaching/enumerations/CacheType.java
new file mode 100755
index 0000000..923972b
--- /dev/null
+++ b/src/cgeo/geocaching/enumerations/CacheType.java
@@ -0,0 +1,56 @@
+package cgeo.geocaching.enumerations;
+
+import menion.android.locus.addon.publiclib.geoData.PointGeocachingData;
+import cgeo.geocaching.R;
+
+/**
+ * Enum listing all cache types
+ *
+ * @author koem
+ */
+public enum CacheType {
+ TRADITIONAL ("traditional", "traditional cache", "32bc9333-5e52-4957-b0f6-5a2c8fc7b257", R.string.traditional, PointGeocachingData.CACHE_TYPE_TRADITIONAL),
+ MULTI ("multi", "multi-cache", "a5f6d0ad-d2f2-4011-8c14-940a9ebf3c74", R.string.multi, PointGeocachingData.CACHE_TYPE_MULTI),
+ MYSTERY ("mystery", "unknown cache", "40861821-1835-4e11-b666-8d41064d03fe", R.string.mystery, PointGeocachingData.CACHE_TYPE_MYSTERY),
+ LETTERBOX ("letterbox", "letterbox hybrid", "4bdd8fb2-d7bc-453f-a9c5-968563b15d24", R.string.letterbox, PointGeocachingData.CACHE_TYPE_LETTERBOX),
+ EVENT ("event", "event cache", "69eb8534-b718-4b35-ae3c-a856a55b0874", R.string.event, PointGeocachingData.CACHE_TYPE_EVENT),
+ MEGA_EVENT ("mega", "mega-event cache", "69eb8535-b718-4b35-ae3c-a856a55b0874", R.string.mega, PointGeocachingData.CACHE_TYPE_MEGA_EVENT),
+ EARTH ("earth", "earthcache", "c66f5cf3-9523-4549-b8dd-759cd2f18db8", R.string.earth, PointGeocachingData.CACHE_TYPE_EARTH),
+ CITO ("cito", "cache in trash out event", "57150806-bc1a-42d6-9cf0-538d171a2d22", R.string.cito, PointGeocachingData.CACHE_TYPE_CACHE_IN_TRASH_OUT),
+ WEBCAM ("webcam", "webcam cache", "31d2ae3c-c358-4b5f-8dcd-2185bf472d3d", R.string.webcam, PointGeocachingData.CACHE_TYPE_WEBCAM),
+ VIRTUAL ("virtual", "virtual cache", "294d4360-ac86-4c83-84dd-8113ef678d7e", R.string.virtual, PointGeocachingData.CACHE_TYPE_VIRTUAL),
+ WHERIGO ("wherigo", "wherigo cache", "0544fa55-772d-4e5c-96a9-36a51ebcf5c9", R.string.wherigo, PointGeocachingData.CACHE_TYPE_WHERIGO),
+ LOSTANDFOUND ("lostfound", "lost & found", "3ea6533d-bb52-42fe-b2d2-79a3424d4728", R.string.lostfound),
+ PROJECT_APE ("ape", "project ape cache", "2555690d-b2bc-4b55-b5ac-0cb704c0b768", R.string.ape, PointGeocachingData.CACHE_TYPE_PROJECT_APE),
+ GCHQ ("gchq", "groundspeak hq", "416f2494-dc17-4b6a-9bab-1a29dd292d8c", R.string.gchq),
+ GPS_EXHIBIT ("gps", "gps cache exhibit", "72e69af2-7986-4990-afd9-bc16cbbb4ce3", R.string.gps, PointGeocachingData.CACHE_TYPE_GPS_ADVENTURE);
+
+ public static final int NO_LOCUS_ID = -1;
+
+ public final String cgeoId;
+ public final String pattern;
+ public final String guid;
+ public final int stringId;
+ public final int locusId;
+
+ private CacheType(String cgeoId, String pattern, String guid, int stringId) {
+ this(cgeoId, pattern, guid, stringId, NO_LOCUS_ID);
+ }
+
+ private CacheType(String cgeoId, String pattern, String guid, int stringId, int locusId) {
+ this.cgeoId = cgeoId;
+ this.pattern = pattern;
+ this.guid = guid;
+ this.stringId = stringId;
+ this.locusId = locusId;
+ }
+
+ public static CacheType findByCgeoId(String cgeoId) {
+ if (cgeoId == null) return null;
+ for (CacheType ct : CacheType.values()) {
+ if (ct.cgeoId.equals(cgeoId)) return ct;
+ }
+ return null;
+ }
+
+}
diff --git a/src/cgeo/geocaching/enumerations/WaypointType.java b/src/cgeo/geocaching/enumerations/WaypointType.java
new file mode 100755
index 0000000..ec442a0
--- /dev/null
+++ b/src/cgeo/geocaching/enumerations/WaypointType.java
@@ -0,0 +1,35 @@
+package cgeo.geocaching.enumerations;
+
+import menion.android.locus.addon.publiclib.geoData.PointGeocachingData;
+
+/**
+ * Enum listing waypoint types
+ *
+ * @author koem
+ */
+public enum WaypointType {
+ FLAG ("flag", PointGeocachingData.CACHE_WAYPOINT_TYPE_FINAL),
+ OWN ("own", PointGeocachingData.CACHE_WAYPOINT_TYPE_STAGES),
+ PKG ("pkg", PointGeocachingData.CACHE_WAYPOINT_TYPE_PARKING),
+ PUZZLE ("puzzle", PointGeocachingData.CACHE_WAYPOINT_TYPE_QUESTION),
+ STAGE ("stage", PointGeocachingData.CACHE_WAYPOINT_TYPE_STAGES),
+ TRAILHEAD ("trailhead", PointGeocachingData.CACHE_WAYPOINT_TYPE_TRAILHEAD),
+ WAYPOINT ("waypoint", PointGeocachingData.CACHE_WAYPOINT_TYPE_STAGES);
+
+ public final String cgeoId;
+ public final String locusId;
+
+ private WaypointType(String cgeoId, String locusId) {
+ this.cgeoId = cgeoId;
+ this.locusId = locusId;
+ }
+
+ public static WaypointType findByCgeoId(String cgeoId) {
+ if (cgeoId == null) return null;
+ for (WaypointType wt : WaypointType.values()) {
+ if (wt.cgeoId.equals(cgeoId)) return wt;
+ }
+ return null;
+ }
+
+}