aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2011-11-13 14:49:35 +0100
committerBananeweizen <bananeweizen@gmx.de>2011-11-13 14:49:35 +0100
commit97fb2c4a230a3ea974d8a1146890c8f5fd25a472 (patch)
tree256cf020483861718c98192bc1bab4c77a266046 /main
parent587475434447e23c2f37ba3a25ad0b1ed987a511 (diff)
downloadcgeo-97fb2c4a230a3ea974d8a1146890c8f5fd25a472.zip
cgeo-97fb2c4a230a3ea974d8a1146890c8f5fd25a472.tar.gz
cgeo-97fb2c4a230a3ea974d8a1146890c8f5fd25a472.tar.bz2
have Go4Cache localized, show also age of information, fixes #782
Diffstat (limited to 'main')
-rw-r--r--main/res/values-de/strings.xml7
-rw-r--r--main/res/values/strings.xml8
-rw-r--r--main/src/cgeo/geocaching/cgBase.java1
-rw-r--r--main/src/cgeo/geocaching/go4cache/Go4Cache.java7
-rw-r--r--main/src/cgeo/geocaching/go4cache/Go4CacheUser.java35
-rw-r--r--main/src/cgeo/geocaching/maps/OtherCachersOverlay.java22
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java2
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java2
8 files changed, 53 insertions, 31 deletions
diff --git a/main/res/values-de/strings.xml b/main/res/values-de/strings.xml
index 0c20bf7..e5c991e 100644
--- a/main/res/values-de/strings.xml
+++ b/main/res/values-de/strings.xml
@@ -861,4 +861,11 @@
<string name="about_twitter">Soll jeder neue Fund auf Twitter veröffentlicht werden, wenn er über <b>c:geo</b> geloggt wird?</string>
<string name="about_auth_1">Der folgende Prozess erlaubt es <b>c:geo</b> auf den persönlichen Twitter-Account zuzugreifen, wenn zugestimmt wird.</string>
<string name="about_auth_2">Ein Klick auf \"Starte Autorisierung\" öffnet eine Twitter-Seite in einem Browserfenster. Durch die Anmeldung und die Bestätigung wird <b>c:geo</b> ermöglicht, auf den persönlichen Twitter-Account zuzugreifen. Wird dies bestätigt, nennt Twitter eine numerische PIN, diese muss kopiert und in <b>c:geo</b> eingefügt werden. Das ist alles.</string>
+
+ <!-- go4cache -->
+ <string name="go4cache_looking_around">Schaut umher</string>
+ <string name="go4cache_tweeting">Twittert</string>
+ <string name="go4cache_heading_to">Unterwegs zu</string>
+ <string name="go4cache_minutes">Minuten</string>
+
</resources>
diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml
index cd0626f..40f292a 100644
--- a/main/res/values/strings.xml
+++ b/main/res/values/strings.xml
@@ -888,7 +888,13 @@
<string name="about_twitter">Should <b>c:geo</b> publish new status on Twitter every time a cache is logged?</string>
<string name="about_auth_1">The following process allows <b>c:geo</b> to access Twitter - if agreed.</string>
<string name="about_auth_2">Click on \"authorize c:geo\" button will start the process. This process will open up a web browser with Twitter page. Login on this page and allow <b>c:geo</b> to access your account. If accepted, Twitter will show up a numeric PIN code. This PIN must be pasted into <b>c:geo</b> and be confirmed. That\'s all.</string>
-
+
+ <!-- go4cache -->
+ <string name="go4cache_looking_around">Looking around</string>
+ <string name="go4cache_tweeting">Tweeting</string>
+ <string name="go4cache_heading_to">Heading to</string>
+ <string name="go4cache_minutes">Minutes</string>
+
<!-- ====== please, do not translate (and include in translation) things below this line ====== -->
<!-- contributors -->
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java
index 8f278f1..8470f2a 100644
--- a/main/src/cgeo/geocaching/cgBase.java
+++ b/main/src/cgeo/geocaching/cgBase.java
@@ -129,7 +129,6 @@ public class cgBase {
}
public final static SimpleDateFormat dateTbIn1 = new SimpleDateFormat("EEEEE, dd MMMMM yyyy", Locale.ENGLISH); // Saturday, 28 March 2009
public final static SimpleDateFormat dateTbIn2 = new SimpleDateFormat("EEEEE, MMMMM dd, yyyy", Locale.ENGLISH); // Saturday, March 28, 2009
- public final static SimpleDateFormat dateSqlIn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 2010-07-25 14:44:01
private static final Pattern patternLoggedIn = Pattern.compile("<span class=\"Success\">You are logged in as[^<]*<strong[^>]*>([^<]+)</strong>[^<]*</span>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
private static final Pattern patternLogged2In = Pattern.compile("<strong>\\W*Hello,[^<]*<a[^>]+>([^<]+)</a>[^<]*</strong>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
private static final Pattern patternViewstateFieldCount = Pattern.compile("id=\"__VIEWSTATEFIELDCOUNT\"[^(value)]+value=\"(\\d+)\"[^>]+>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
diff --git a/main/src/cgeo/geocaching/go4cache/Go4Cache.java b/main/src/cgeo/geocaching/go4cache/Go4Cache.java
index ffd5974..e407b2f 100644
--- a/main/src/cgeo/geocaching/go4cache/Go4Cache.java
+++ b/main/src/cgeo/geocaching/go4cache/Go4Cache.java
@@ -17,6 +17,7 @@ import org.json.JSONObject;
import android.util.Log;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -33,6 +34,7 @@ import java.util.concurrent.ArrayBlockingQueue;
public class Go4Cache extends Thread {
+ private final static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 2010-07-25 14:44:01
private static Go4Cache instance;
final private ArrayBlockingQueue<Geopoint> queue = new ArrayBlockingQueue<Geopoint>(1);
@@ -172,12 +174,11 @@ public class Go4Cache extends Thread {
* if the date could not be parsed as expected
*/
private static Go4CacheUser parseUser(final JSONObject user) throws JSONException, ParseException {
- final String located = user.getString("located");
- final Date userlocated = cgBase.dateSqlIn.parse(located);
+ final Date date = dateFormat.parse(user.getString("located"));
final String username = user.getString("user");
final Geopoint coords = new Geopoint(user.getDouble("latitude"), user.getDouble("longitude"));
final String action = user.getString("action");
final String client = user.getString("client");
- return new Go4CacheUser(username, coords, userlocated, action, client);
+ return new Go4CacheUser(username, coords, date, action, client);
}
}
diff --git a/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java b/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java
index 931bdaf..94399bd 100644
--- a/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java
+++ b/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java
@@ -1,8 +1,11 @@
package cgeo.geocaching.go4cache;
import cgeo.geocaching.R;
+import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.geopoint.Geopoint;
+import android.content.res.Resources;
+
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -10,7 +13,7 @@ import java.util.regex.Pattern;
public class Go4CacheUser {
private static final Pattern patternGeocode = Pattern.compile("^(GC[A-Z0-9]+)(\\: ?(.+))?$", Pattern.CASE_INSENSITIVE);
- private final Date located;
+ private final Date date;
private final String username;
private final Geopoint coords;
private final String action;
@@ -18,17 +21,18 @@ public class Go4CacheUser {
private String actionForDisplay;
private String geocode;
+ private Resources res;
- public Go4CacheUser(final String username, final Geopoint coords, final Date located, final String action, final String client) {
+ public Go4CacheUser(final String username, final Geopoint coords, final Date date, final String action, final String client) {
this.username = username;
this.coords = coords;
- this.located = located;
+ this.date = date;
this.action = action;
this.client = client;
}
- public Date getLocated() {
- return located;
+ public Date getDate() {
+ return date;
}
public String getUsername() {
@@ -55,20 +59,21 @@ public class Go4CacheUser {
private void getGeocodeAndAction() {
final Matcher matcherGeocode = patternGeocode.matcher(action.trim());
+ res = cgeoapplication.getInstance().getResources();
geocode = "";
if (0 == action.length() || action.equalsIgnoreCase("pending")) {
- actionForDisplay = "Looking around";
+ actionForDisplay = res.getString(R.string.go4cache_looking_around);
} else if (action.equalsIgnoreCase("tweeting")) {
- actionForDisplay = "Tweeting";
+ actionForDisplay = res.getString(R.string.go4cache_tweeting);
} else if (matcherGeocode.find()) {
if (null != matcherGeocode.group(1)) {
geocode = matcherGeocode.group(1).trim().toUpperCase();
}
if (null != matcherGeocode.group(3)) {
- actionForDisplay = "Heading to " + geocode + " (" + matcherGeocode.group(3).trim() + ")";
+ actionForDisplay = res.getString(R.string.go4cache_heading_to) + " " + geocode + " (" + matcherGeocode.group(3).trim() + ")";
} else {
- actionForDisplay = "Heading to " + geocode;
+ actionForDisplay = res.getString(R.string.go4cache_heading_to) + " " + geocode;
}
} else {
actionForDisplay = action;
@@ -79,7 +84,15 @@ public class Go4CacheUser {
if (null == actionForDisplay) {
getGeocodeAndAction();
}
- return actionForDisplay;
+ return actionForDisplay + getTime();
+ }
+
+ private String getTime() {
+ long minutes = (System.currentTimeMillis() - date.getTime()) / 60000;
+ if (minutes < 0) {
+ minutes = 0;
+ }
+ return " " + minutes + " " + res.getString(R.string.go4cache_minutes);
}
public String getGeocode() {
@@ -88,4 +101,4 @@ public class Go4CacheUser {
}
return geocode;
}
-}
+} \ No newline at end of file
diff --git a/main/src/cgeo/geocaching/maps/OtherCachersOverlay.java b/main/src/cgeo/geocaching/maps/OtherCachersOverlay.java
index 8498b29..9306041 100644
--- a/main/src/cgeo/geocaching/maps/OtherCachersOverlay.java
+++ b/main/src/cgeo/geocaching/maps/OtherCachersOverlay.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.maps;
import cgeo.geocaching.Settings;
+import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.cgeodetail;
import cgeo.geocaching.go4cache.Go4CacheUser;
import cgeo.geocaching.maps.interfaces.ItemizedOverlayImpl;
@@ -34,7 +35,7 @@ public class OtherCachersOverlay extends AbstractItemizedOverlay {
}
protected void updateItems(OtherCachersOverlayItemImpl item) {
- List<OtherCachersOverlayItemImpl> itemsPre = new ArrayList<OtherCachersOverlayItemImpl>();
+ final List<OtherCachersOverlayItemImpl> itemsPre = new ArrayList<OtherCachersOverlayItemImpl>();
itemsPre.add(item);
updateItems(itemsPre);
@@ -69,32 +70,27 @@ public class OtherCachersOverlay extends AbstractItemizedOverlay {
final OtherCachersOverlayItemImpl item = items.get(index);
final Go4CacheUser user = item.getUser();
- // set action
- String action = user.getAction();
- String geocode = user.getGeocode();
-
- // set icon
- int icon = user.getIconId();
+ final String geocode = user.getGeocode();
+ final int icon = user.getIconId();
final AlertDialog.Builder dialog = new AlertDialog.Builder(context);
if (icon > -1) {
dialog.setIcon(icon);
}
dialog.setTitle(user.getUsername());
- dialog.setMessage(action);
+ dialog.setMessage(user.getAction());
dialog.setCancelable(true);
if (StringUtils.isNotBlank(geocode)) {
- dialog.setPositiveButton(geocode + "?", new cacheDetails(geocode));
+ dialog.setPositiveButton(geocode, new cacheDetails(geocode));
}
- dialog.setNeutralButton("Dismiss", new DialogInterface.OnClickListener() {
+ dialog.setNeutralButton(cgeoapplication.getInstance().getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
- AlertDialog alert = dialog.create();
- alert.show();
+ dialog.create().show();
return true;
} catch (Exception e) {
@@ -147,7 +143,7 @@ public class OtherCachersOverlay extends AbstractItemizedOverlay {
public void onClick(DialogInterface dialog, int id) {
if (geocode != null) {
- Intent detailIntent = new Intent(context, cgeodetail.class);
+ final Intent detailIntent = new Intent(context, cgeodetail.class);
detailIntent.putExtra("geocode", geocode);
context.startActivity(detailIntent);
}
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java b/main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java
index ac8e725..286129d 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java
@@ -25,7 +25,7 @@ public class GoogleOtherCachersOverlayItem extends OverlayItem implements OtherC
public Drawable getMarker(int state) {
Drawable marker = null;
- if (user != null && user.getLocated() != null && user.getLocated().getTime() >= (System.currentTimeMillis() - (20 * 60 * 1000))) {
+ if (user != null && user.getDate() != null && user.getDate().getTime() >= (System.currentTimeMillis() - (20 * 60 * 1000))) {
marker = context.getResources().getDrawable(R.drawable.user_location_active);
} else {
marker = context.getResources().getDrawable(R.drawable.user_location);
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java
index f2cae3a..10f62b9 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java
@@ -25,7 +25,7 @@ public class MapsforgeOtherCachersOverlayItem extends OverlayItem implements Oth
public Drawable getMarker(int state) {
Drawable marker = null;
- if (user != null && user.getLocated() != null && user.getLocated().getTime() >= (System.currentTimeMillis() - (20 * 60 * 1000))) {
+ if (user != null && user.getDate() != null && user.getDate().getTime() >= (System.currentTimeMillis() - (20 * 60 * 1000))) {
marker = context.getResources().getDrawable(R.drawable.user_location_active);
} else {
marker = context.getResources().getDrawable(R.drawable.user_location);