aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2011-09-02 21:51:33 +0200
committerBananeweizen <bananeweizen@gmx.de>2011-09-02 21:51:33 +0200
commitb5be8bc2a5c7c7776cf8d3aaa8f5816eaf8c4ec8 (patch)
tree28b873c2d47b1e2a311a5d9a3d2a64598447efcd /src/cgeo
parentab7740274e76ee7b5b1dc9217735b7ad5357e269 (diff)
parent1e1f710ed3a6f7a47b6d3aedcb8a6602b07eba4b (diff)
downloadcgeo-b5be8bc2a5c7c7776cf8d3aaa8f5816eaf8c4ec8.zip
cgeo-b5be8bc2a5c7c7776cf8d3aaa8f5816eaf8c4ec8.tar.gz
cgeo-b5be8bc2a5c7c7776cf8d3aaa8f5816eaf8c4ec8.tar.bz2
Merge branch 'master' of https://Bananeweizen@github.com/cgeo/c-geo-opensource.git
Diffstat (limited to 'src/cgeo')
-rw-r--r--src/cgeo/geocaching/ICache.java88
-rw-r--r--src/cgeo/geocaching/activity/AbstractActivity.java3
-rw-r--r--src/cgeo/geocaching/activity/AbstractListActivity.java3
-rw-r--r--src/cgeo/geocaching/activity/ActivityMixin.java2
-rw-r--r--src/cgeo/geocaching/apps/AbstractApp.java2
-rw-r--r--src/cgeo/geocaching/cgBase.java7
-rw-r--r--src/cgeo/geocaching/cgCache.java102
-rw-r--r--src/cgeo/geocaching/cgCacheWrap.java3
-rw-r--r--src/cgeo/geocaching/cgSettings.java5
-rw-r--r--src/cgeo/geocaching/cgeodetail.java4
-rw-r--r--src/cgeo/geocaching/mapcommon/cgeomap.java9
11 files changed, 215 insertions, 13 deletions
diff --git a/src/cgeo/geocaching/ICache.java b/src/cgeo/geocaching/ICache.java
new file mode 100644
index 0000000..d32c48c
--- /dev/null
+++ b/src/cgeo/geocaching/ICache.java
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package cgeo.geocaching;
+
+
+/**
+ * Basic interface for caches
+ * @author blafoo
+ *
+ */
+public interface ICache {
+
+ /**
+ * @return The data returned by the HTTP-GET request for this cache. Only for testing purposes.
+ */
+ public String getData();
+
+ /**
+ * @return Geocode like GCxxxx
+ */
+ public String getGeocode();
+ /**
+ * @return Tradi, multi etc.
+ */
+ public String getType();
+ /**
+ * @return Displayed owner, might differ from the real owner
+ */
+ public String getOwner();
+ /**
+ * @return GC username of the owner
+ */
+ public String getOwnerReal();
+ /**
+ * @return Micro, small etc.
+ */
+ public String getSize();
+ /**
+ * @return Difficulty assessment
+ */
+ public Float getDifficulty();
+ /**
+ * @return Terrain assessment
+ */
+ public Float getTerrain();
+ /**
+ * @return Latitute, e.g. N 52° 12.345
+ */
+ public String getLatitute();
+ /**
+ * @return Longitude, e.g. E 9° 34.567
+ */
+ public String getLongitude();
+ /**
+ * @return true if the cache is disabled, false else
+ */
+ public boolean isDisabled();
+ /**
+ * @return true if the user is the owner of the cache, false else
+ */
+ public boolean isOwn();
+ /**
+ * @return true is the cache is archived, false else
+ */
+ public boolean isArchived();
+ /**
+ * @return true is the cache is a Premium Member cache only, false else
+ */
+ public boolean isMembersOnly();
+ /**
+ * @return Decrypted hint
+ */
+ public String getHint();
+ /**
+ * @return Descrition
+ */
+ public String getDescription();
+ /**
+ * @return Short Description
+ */
+ public String getShortDescription();
+ /**
+ * @return Name
+ */
+ public String getName();
+
+}
diff --git a/src/cgeo/geocaching/activity/AbstractActivity.java b/src/cgeo/geocaching/activity/AbstractActivity.java
index 96e3e6b..1c2d637 100644
--- a/src/cgeo/geocaching/activity/AbstractActivity.java
+++ b/src/cgeo/geocaching/activity/AbstractActivity.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.activity;
import android.app.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
@@ -68,7 +69,7 @@ public abstract class AbstractActivity extends Activity implements IAbstractActi
// init
res = this.getResources();
app = (cgeoapplication) this.getApplication();
- prefs = getSharedPreferences(cgSettings.preferences, 0);
+ prefs = getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE);
settings = new cgSettings(this, prefs);
base = new cgBase(app, settings, prefs);
}
diff --git a/src/cgeo/geocaching/activity/AbstractListActivity.java b/src/cgeo/geocaching/activity/AbstractListActivity.java
index 873a717..4624d34 100644
--- a/src/cgeo/geocaching/activity/AbstractListActivity.java
+++ b/src/cgeo/geocaching/activity/AbstractListActivity.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.activity;
import android.app.ListActivity;
+import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
@@ -65,7 +66,7 @@ public abstract class AbstractListActivity extends ListActivity implements
// init
res = this.getResources();
app = (cgeoapplication) this.getApplication();
- prefs = getSharedPreferences(cgSettings.preferences, 0);
+ prefs = getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE);
settings = new cgSettings(this, prefs);
base = new cgBase(app, settings, prefs);
}
diff --git a/src/cgeo/geocaching/activity/ActivityMixin.java b/src/cgeo/geocaching/activity/ActivityMixin.java
index acbb405..9a50662 100644
--- a/src/cgeo/geocaching/activity/ActivityMixin.java
+++ b/src/cgeo/geocaching/activity/ActivityMixin.java
@@ -74,7 +74,7 @@ public final class ActivityMixin {
}
public final static void setTheme(final Activity activity) {
- cgSettings settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, 0));
+ cgSettings settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE));
if (settings.skin == 1) {
activity.setTheme(R.style.light);
} else {
diff --git a/src/cgeo/geocaching/apps/AbstractApp.java b/src/cgeo/geocaching/apps/AbstractApp.java
index 803a296..42ce677 100644
--- a/src/cgeo/geocaching/apps/AbstractApp.java
+++ b/src/cgeo/geocaching/apps/AbstractApp.java
@@ -75,6 +75,6 @@ public abstract class AbstractApp implements App {
protected static cgSettings getSettings(Activity activity) {
return new cgSettings(activity,
- activity.getSharedPreferences(cgSettings.preferences, 0));
+ activity.getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE));
}
}
diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java
index 79041a1..9fefac6 100644
--- a/src/cgeo/geocaching/cgBase.java
+++ b/src/cgeo/geocaching/cgBase.java
@@ -202,7 +202,6 @@ public class cgBase {
public static final int LOG_ANNOUNCEMENT = 74;
public cgBase(cgeoapplication appIn, cgSettings settingsIn, SharedPreferences prefsIn) {
- context = appIn.getBaseContext();
res = appIn.getBaseContext().getResources();
// cache types
@@ -4296,7 +4295,11 @@ public class cgBase {
return cookiesDone;
}
- private static void replaceWhitespace(final StringBuffer buffer) {
+ /**
+ * Replace the characters \n, \r and \t with a space
+ * @param buffer The data
+ */
+ public static void replaceWhitespace(final StringBuffer buffer) {
final int length = buffer.length();
final char[] chars = new char[length];
buffer.getChars(0, length, chars, 0);
diff --git a/src/cgeo/geocaching/cgCache.java b/src/cgeo/geocaching/cgCache.java
index 1fed844..5ffa991 100644
--- a/src/cgeo/geocaching/cgCache.java
+++ b/src/cgeo/geocaching/cgCache.java
@@ -17,13 +17,19 @@ import cgeo.geocaching.activity.IAbstractActivity;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.IConnector;
-public class cgCache {
+/**
+ * Internal c:geo representation of a "cache"
+ */
+public class cgCache implements ICache {
public Long updated = null;
public Long detailedUpdate = null;
public Long visitedDate = null;
public Integer reason = 0;
public Boolean detailed = false;
+ /**
+ * Code of the cache like GCABCD
+ */
public String geocode = "";
public String cacheid = "";
public String guid = "";
@@ -382,4 +388,96 @@ public class cgCache {
return getConnector().supportsLogging();
}
-}
+ @Override
+ public String getData() {
+ return null;
+ }
+
+ @Override
+ public Float getDifficulty() {
+ return difficulty;
+ }
+
+ @Override
+ public String getGeocode() {
+ return geocode;
+ }
+
+ @Override
+ public String getLatitute() {
+ return latitudeString;
+ }
+
+ @Override
+ public String getLongitude() {
+ return longitudeString;
+ }
+
+ @Override
+ public String getOwner() {
+ return owner;
+ }
+
+ @Override
+ public String getSize() {
+ return size;
+ }
+
+ @Override
+ public Float getTerrain() {
+ return terrain;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public boolean isArchived() {
+ return archived;
+ }
+
+ @Override
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ @Override
+ public boolean isMembersOnly() {
+ return members;
+ }
+
+ @Override
+ public boolean isOwn() {
+ return own;
+ }
+
+ @Override
+ public String getOwnerReal() {
+ return ownerReal;
+ }
+
+ @Override
+ public String getHint() {
+ return hint;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getShortDescription() {
+ return shortdesc;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+}
+
+
diff --git a/src/cgeo/geocaching/cgCacheWrap.java b/src/cgeo/geocaching/cgCacheWrap.java
index 29b40c7..bfa5b8f 100644
--- a/src/cgeo/geocaching/cgCacheWrap.java
+++ b/src/cgeo/geocaching/cgCacheWrap.java
@@ -2,6 +2,9 @@ package cgeo.geocaching;
import java.util.ArrayList;
+/**
+ * List of caches
+ */
public class cgCacheWrap {
public String error = null;
public String url = "";
diff --git a/src/cgeo/geocaching/cgSettings.java b/src/cgeo/geocaching/cgSettings.java
index 7c6be93..57cdf51 100644
--- a/src/cgeo/geocaching/cgSettings.java
+++ b/src/cgeo/geocaching/cgSettings.java
@@ -17,6 +17,9 @@ import cgeo.geocaching.googlemaps.googleMapFactory;
import cgeo.geocaching.mapinterfaces.MapFactory;
import cgeo.geocaching.mapsforge.mfMapFactory;
+/**
+ * General c:geo preferences/settings set by the user
+ */
public class cgSettings {
private static final String KEY_WEB_DEVICE_CODE = "webDeviceCode";
@@ -152,7 +155,7 @@ public class cgSettings {
// usable values
public static final String tag = "c:geo";
- // preferences file
+ /** Name of the preferences file */
public static final String preferences = "cgeo.pref";
// private variables
diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java
index 61b31e8..e705141 100644
--- a/src/cgeo/geocaching/cgeodetail.java
+++ b/src/cgeo/geocaching/cgeodetail.java
@@ -55,6 +55,10 @@ import cgeo.geocaching.apps.cache.GeneralAppsFactory;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
import cgeo.geocaching.compatibility.Compatibility;
+/**
+ * Activity to display all details of a cache like owner, difficulty, description etc.
+ *
+ */
public class cgeodetail extends AbstractActivity {
public cgeodetail() {
diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java
index 3ada145..22ea40b 100644
--- a/src/cgeo/geocaching/mapcommon/cgeomap.java
+++ b/src/cgeo/geocaching/mapcommon/cgeomap.java
@@ -6,6 +6,7 @@ import java.util.Locale;
import android.app.Activity;
import android.app.ProgressDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -231,9 +232,9 @@ public class cgeomap extends MapBase {
activity = this.getActivity();
app = (cgeoapplication) activity.getApplication();
app.setAction(null);
- settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, activity.getSharedPreferences(cgSettings.preferences, 0));
- prefsEdit = activity.getSharedPreferences(cgSettings.preferences, 0).edit();
+ settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE));
+ base = new cgBase(app, settings, activity.getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE));
+ prefsEdit = activity.getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE).edit();
MapFactory mapFactory = settings.getMapFactory();
// reset status
@@ -719,7 +720,7 @@ public class cgeomap extends MapBase {
}
if (prefsEdit == null) {
- prefsEdit = activity.getSharedPreferences(cgSettings.preferences, 0).edit();
+ prefsEdit = activity.getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE).edit();
}
prefsEdit.putInt("mapzoom", mapView.getMapZoomLevel());