aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorTorsten Keil <github@torsten-keil.net>2012-02-03 00:48:12 +0100
committerTorsten Keil <github@torsten-keil.net>2012-02-03 00:48:12 +0100
commitbedaf58bc5bf9bb74d7f2d8985752421ffd69b6c (patch)
tree0bd1f916403d71355d03ed0b41bb34a4c7127b9e /main
parent4711a02fa036fd23c604937ac4a60a7be48c2d4b (diff)
parent9a53d3a65760180687a113a745cbca04bd8401f6 (diff)
downloadcgeo-bedaf58bc5bf9bb74d7f2d8985752421ffd69b6c.zip
cgeo-bedaf58bc5bf9bb74d7f2d8985752421ffd69b6c.tar.gz
cgeo-bedaf58bc5bf9bb74d7f2d8985752421ffd69b6c.tar.bz2
Merge remote-tracking branch 'upstream/master' into issue#1061
Diffstat (limited to 'main')
-rw-r--r--main/res/layout-land/coords.xml127
-rw-r--r--main/res/layout/coords.xml7
-rw-r--r--main/res/values-de/strings.xml7
-rw-r--r--main/res/values/strings.xml5
-rw-r--r--main/src/cgeo/geocaching/GCConstants.java3
-rw-r--r--main/src/cgeo/geocaching/apps/AbstractApp.java22
-rw-r--r--main/src/cgeo/geocaching/cgCache.java10
-rw-r--r--main/src/cgeo/geocaching/cgCoord.java2
-rw-r--r--main/src/cgeo/geocaching/cgeo.java4
-rw-r--r--main/src/cgeo/geocaching/cgeoadvsearch.java2
-rw-r--r--main/src/cgeo/geocaching/cgeocoords.java24
-rw-r--r--main/src/cgeo/geocaching/cgeopoint.java2
-rw-r--r--main/src/cgeo/geocaching/cgeowaypointadd.java3
-rw-r--r--main/src/cgeo/geocaching/files/LocParser.java2
-rw-r--r--main/src/cgeo/geocaching/ui/CacheListAdapter.java10
15 files changed, 188 insertions, 42 deletions
diff --git a/main/res/layout-land/coords.xml b/main/res/layout-land/coords.xml
new file mode 100644
index 0000000..c25a2c0
--- /dev/null
+++ b/main/res/layout-land/coords.xml
@@ -0,0 +1,127 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/linearLayout1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:background="?background_color">
+ <LinearLayout style="@style/action_bar">
+ <TextView style="@style/action_bar_title"
+ android:text="@string/cache_coordinates" />
+ <View style="@style/action_bar_separator" />
+ <ImageView android:id="@+id/actionBarManualbutton"
+ style="@style/action_bar_action"
+ android:src="@drawable/actionbar_manual" />
+ </LinearLayout>
+ <ScrollView android:id="@+id/scroller"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:fillViewport="true" >
+ <LinearLayout android:id="@+id/scroller_child"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+ <Spinner android:id="@+id/spinnerCoordinateFormats"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/coordTable"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:stretchColumns="0,1,3,5,7"
+ android:layout_weight="1">
+ <TableRow android:id="@+id/tableRow1">
+ <Button android:id="@+id/ButtonLat"
+ style="@style/button"/>
+ <EditText style="@style/edittext"
+ android:id="@+id/EditTextLatDeg"
+ android:gravity="right"
+ android:inputType="number"
+ android:selectAllOnFocus="true" />
+ <TextView android:id="@+id/LatSeparator1"
+ android:text="°" />
+ <EditText android:id="@+id/EditTextLatMin"
+ style="@style/edittext"
+ android:gravity="right"
+ android:inputType="number"
+ android:selectAllOnFocus="true" />
+ <TextView android:id="@+id/LatSeparator2"
+ android:text="," />
+ <EditText android:id="@+id/EditTextLatSec"
+ style="@style/edittext"
+ android:gravity="right"
+ android:inputType="number"
+ android:selectAllOnFocus="true" />
+ <TextView android:id="@+id/LatSeparator3"
+ android:text="," />
+ <EditText android:id="@+id/EditTextLatSecFrac"
+ style="@style/edittext"
+ android:inputType="number"
+ android:selectAllOnFocus="true" />
+ </TableRow>
+ <TableRow android:id="@+id/tableRow2">
+ <Button android:id="@+id/ButtonLon"
+ style="@style/button"/>
+ <EditText android:id="@+id/EditTextLonDeg"
+ style="@style/edittext"
+ android:gravity="right"
+ android:inputType="number"
+ android:selectAllOnFocus="true" />
+ <TextView android:id="@+id/LonSeparator1"
+ android:text="°" />
+ <EditText android:id="@+id/EditTextLonMin"
+ style="@style/edittext"
+ android:gravity="right"
+ android:inputType="number"
+ android:selectAllOnFocus="true" />
+ <TextView android:id="@+id/LonSeparator2"
+ android:text="," />
+ <EditText android:id="@+id/EditTextLonSec"
+ style="@style/edittext"
+ android:gravity="right"
+ android:inputType="number"
+ android:selectAllOnFocus="true" />
+ <TextView android:id="@+id/LonSeparator3"
+ android:text="," />
+ <EditText android:id="@+id/EditTextLonSecFrac"
+ style="@style/edittext"
+ android:inputType="number"
+ android:selectAllOnFocus="true" />
+ </TableRow>
+ </TableLayout>
+ <EditText
+ android:id="@+id/latitude"
+ style="@style/edittext"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:hint="@string/latitude" />
+ <EditText
+ android:id="@+id/longitude"
+ style="@style/edittext"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:hint="@string/longitude" />
+ <LinearLayout
+ android:id="@+id/linearLayout2"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+ <Button style="@style/button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/current"
+ android:layout_weight="1"
+ android:text="@string/waypoint_my_coordinates" />
+ <Button style="@style/button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/cache"
+ android:layout_weight="1"
+ android:text="@string/waypoint_cache_coordinates" />
+ </LinearLayout>
+ <Button style="@style/button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/done"
+ android:text="@string/waypoint_done" />
+ </LinearLayout>
+ </ScrollView>
+</LinearLayout>
diff --git a/main/res/layout/coords.xml b/main/res/layout/coords.xml
index fdf7f49..d673d00 100644
--- a/main/res/layout/coords.xml
+++ b/main/res/layout/coords.xml
@@ -88,7 +88,7 @@
android:selectAllOnFocus="true" />
</TableRow>
</TableLayout>
- <EditText style="@style/edittext"
+ <EditText style="@style/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/latitude"
@@ -106,6 +106,11 @@
<Button style="@style/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:id="@+id/cache"
+ android:text="@string/waypoint_cache_coordinates" />
+ <Button style="@style/button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
android:id="@+id/done"
android:text="@string/waypoint_done" />
</LinearLayout>
diff --git a/main/res/values-de/strings.xml b/main/res/values-de/strings.xml
index 41921af..a00d575 100644
--- a/main/res/values-de/strings.xml
+++ b/main/res/values-de/strings.xml
@@ -122,7 +122,7 @@
<string name="err_server">Verbindung zu Geocaching.com konnte nicht hergestellt werden (Server oder Verbindung inaktiv?)</string>
<string name="err_login">Keine Anmeldedaten gespeichert.</string>
<string name="err_login_failed">Login fehlgeschlagen.</string>
- <string name="err_login_failed_toast">c:geo konnte sich nicht einloggen. c:geo arbeitet im Offline-Modus. Überprüfe den Login in den Einstellungen oder stelle eine Internetverbindung her.</string>
+ <string name="err_login_failed_toast">c:geo konnte sich nicht einloggen und arbeitet im Offline-Modus. Überprüfe deine Login-Daten in den Einstellungen oder stelle eine Internetverbindung her.</string>
<string name="err_unknown">Unbekannter Fehler</string>
<string name="err_comm">Unbekannter Kommunikationsfehler</string>
<string name="err_missing_auth">Benutzername oder Passwort nicht gesetzt.</string>
@@ -605,10 +605,11 @@
<!-- waypoint -->
<string name="waypoint">Wegpunkt</string>
<string name="waypoint_title">Wegpunkt</string>
+ <string name="waypoint_cache_coordinates">Cache Koordinaten</string>
<string name="waypoint_custom">Benutzerdefiniert</string>
<string name="waypoint_my_coordinates">Meine Koordinaten</string>
- <string name="waypoint_bearing">Richtung</string>
- <string name="waypoint_distance">Entfernung</string>
+ <string name="waypoint_bearing">Richtung in °</string>
+ <string name="waypoint_distance">Entfernung in m</string>
<string name="waypoint_name">Name</string>
<string name="waypoint_edit">Bearbeiten</string>
<string name="waypoint_delete">Löschen</string>
diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml
index b06ab22..7a87576 100644
--- a/main/res/values/strings.xml
+++ b/main/res/values/strings.xml
@@ -619,10 +619,11 @@
<!-- waypoint -->
<string name="waypoint">Waypoint</string>
<string name="waypoint_title">Waypoint</string>
+ <string name="waypoint_cache_coordinates">Cache coordinates</string>
<string name="waypoint_custom">Custom</string>
<string name="waypoint_my_coordinates">My coordinates</string>
- <string name="waypoint_bearing">Bearing</string>
- <string name="waypoint_distance">Distance</string>
+ <string name="waypoint_bearing">Bearing in °</string>
+ <string name="waypoint_distance">Distance in m</string>
<string name="waypoint_name">Name</string>
<string name="waypoint_edit">Edit</string>
<string name="waypoint_delete">Delete</string>
diff --git a/main/src/cgeo/geocaching/GCConstants.java b/main/src/cgeo/geocaching/GCConstants.java
index eb6f61e..a37b264 100644
--- a/main/src/cgeo/geocaching/GCConstants.java
+++ b/main/src/cgeo/geocaching/GCConstants.java
@@ -59,8 +59,7 @@ public final class GCConstants {
// Info box top-right
public static final Pattern PATTERN_LOGIN_NAME = Pattern.compile("\"SignedInProfileLink\">([^<]+)</a>");
public static final Pattern PATTERN_MEMBER_STATUS = Pattern.compile("<span id=\"ctl00_litPMLevel\" style=\"display: block;\">([^<]+)</span>");
- public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile("title=\"Caches Found\"\\s*/>\\s*(\\d+)<");
-
+ public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile("title=\"Caches Found\"\\s*/>\\s*(\\d+)");
public static final Pattern PATTERN_AVATAR_IMAGE_PROFILE_PAGE = Pattern.compile("<img src=\"(http://img.geocaching.com/user/avatar/[0-9a-f-]+\\.jpg)\"[^>]*\\salt=\"Avatar\"");
public static final Pattern PATTERN_LOGIN_NAME_LOGIN_PAGE = Pattern.compile("<span class=\"Success\">You are logged in as[^<]*<strong[^>]*>([^<]+)</strong>[^<]*</span>");
public static final Pattern PATTERN_USERLOGGEDIN = Pattern.compile("<strong>Hello, <a href=\"/my/default.aspx\" title=\"View Profile for[^\"]*\" class=\"SignedInProfileLink\">(.*?)</a></strong>");
diff --git a/main/src/cgeo/geocaching/apps/AbstractApp.java b/main/src/cgeo/geocaching/apps/AbstractApp.java
index 0c38b02..1161a05 100644
--- a/main/src/cgeo/geocaching/apps/AbstractApp.java
+++ b/main/src/cgeo/geocaching/apps/AbstractApp.java
@@ -1,15 +1,11 @@
package cgeo.geocaching.apps;
+import cgeo.geocaching.cgeo;
import cgeo.geocaching.cgeoapplication;
-import org.apache.commons.collections.CollectionUtils;
-
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-
-import java.util.List;
public abstract class AbstractApp implements App {
@@ -48,21 +44,7 @@ public abstract class AbstractApp implements App {
if (getLaunchIntent(context) != null) {
return true;
}
- return isIntentAvailable(context, intent);
- }
-
- private static boolean isIntentAvailable(Context context, String action) {
- final Intent intent = new Intent(action);
-
- return isIntentAvailable(context, intent);
- }
-
- protected static boolean isIntentAvailable(Context context, Intent intent) {
- final PackageManager packageManager = context.getPackageManager();
- final List<ResolveInfo> list = packageManager.queryIntentActivities(
- intent, PackageManager.MATCH_DEFAULT_ONLY);
-
- return CollectionUtils.isNotEmpty(list);
+ return cgeo.isIntentAvailable(context, intent);
}
@Override
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 432bd93..9fdaaaf 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -507,6 +507,9 @@ public class cgCache implements ICache {
@Override
public CacheSize getSize() {
+ if (size == null) {
+ return CacheSize.UNKNOWN;
+ }
return size;
}
@@ -986,7 +989,12 @@ public class cgCache implements ICache {
}
public void setSize(CacheSize size) {
- this.size = size;
+ if (size == null) {
+ this.size = CacheSize.UNKNOWN;
+ }
+ else {
+ this.size = size;
+ }
}
public void setDifficulty(float difficulty) {
diff --git a/main/src/cgeo/geocaching/cgCoord.java b/main/src/cgeo/geocaching/cgCoord.java
index 010fc22..0c5b5b5 100644
--- a/main/src/cgeo/geocaching/cgCoord.java
+++ b/main/src/cgeo/geocaching/cgCoord.java
@@ -20,7 +20,7 @@ public class cgCoord implements IBasicCache, IWaypoint {
private Geopoint coords = new Geopoint(0, 0);
private float difficulty = 0;
private float terrain = 0;
- private CacheSize size = null;
+ private CacheSize size = CacheSize.UNKNOWN;
public cgCoord() {
}
diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java
index ff47b15..4de8e50 100644
--- a/main/src/cgeo/geocaching/cgeo.java
+++ b/main/src/cgeo/geocaching/cgeo.java
@@ -262,12 +262,12 @@ public class cgeo extends AbstractActivity {
return true;
}
- private static boolean isIntentAvailable(Context context, String intent) {
+ public static boolean isIntentAvailable(Context context, String intent) {
final PackageManager packageManager = context.getPackageManager();
final List<ResolveInfo> list = packageManager.queryIntentActivities(
new Intent(intent), PackageManager.MATCH_DEFAULT_ONLY);
- return list.size() > 0;
+ return CollectionUtils.isNotEmpty(list);
}
@Override
diff --git a/main/src/cgeo/geocaching/cgeoadvsearch.java b/main/src/cgeo/geocaching/cgeoadvsearch.java
index 0951b31..754cbdb 100644
--- a/main/src/cgeo/geocaching/cgeoadvsearch.java
+++ b/main/src/cgeo/geocaching/cgeoadvsearch.java
@@ -263,7 +263,7 @@ public class cgeoadvsearch extends AbstractActivity {
@Override
public void onClick(View arg0) {
- cgeocoords coordsDialog = new cgeocoords(cgeoadvsearch.this, null, geo);
+ cgeocoords coordsDialog = new cgeocoords(cgeoadvsearch.this, null, null, geo);
coordsDialog.setCancelable(true);
coordsDialog.setOnCoordinateUpdate(new cgeocoords.CoordinateUpdate() {
@Override
diff --git a/main/src/cgeo/geocaching/cgeocoords.java b/main/src/cgeo/geocaching/cgeocoords.java
index 367fb22..3aadf05 100644
--- a/main/src/cgeo/geocaching/cgeocoords.java
+++ b/main/src/cgeo/geocaching/cgeocoords.java
@@ -29,6 +29,7 @@ public class cgeocoords extends Dialog {
final private AbstractActivity context;
final private cgGeo geo;
+ final private cgCache cache;
private Geopoint gp;
private EditText eLat, eLon;
@@ -44,10 +45,11 @@ public class cgeocoords extends Dialog {
private coordInputFormatEnum currentFormat = null;
- public cgeocoords(final AbstractActivity context, final Geopoint gp, final cgGeo geo) {
+ public cgeocoords(final AbstractActivity context, final cgCache cache, final Geopoint gp, final cgGeo geo) {
super(context);
this.context = context;
this.geo = geo;
+ this.cache = cache;
if (gp != null) {
this.gp = gp;
@@ -131,6 +133,12 @@ public class cgeocoords extends Dialog {
final Button buttonCurrent = (Button) findViewById(R.id.current);
buttonCurrent.setOnClickListener(new CurrentListener());
+ final Button buttonCache = (Button) findViewById(R.id.cache);
+ if (cache != null) {
+ buttonCache.setOnClickListener(new CacheListener());
+ } else {
+ buttonCache.setVisibility(View.GONE);
+ }
final Button buttonDone = (Button) findViewById(R.id.done);
buttonDone.setOnClickListener(new InputDoneListener());
}
@@ -481,6 +489,20 @@ public class cgeocoords extends Dialog {
}
}
+ private class CacheListener implements View.OnClickListener {
+
+ @Override
+ public void onClick(View v) {
+ if (cache == null || cache.getCoords() == null) {
+ context.showToast(context.getResources().getString(R.string.err_location_unknown));
+ return;
+ }
+
+ gp = cache.getCoords();
+ updateGUI();
+ }
+ }
+
private class InputDoneListener implements View.OnClickListener {
@Override
diff --git a/main/src/cgeo/geocaching/cgeopoint.java b/main/src/cgeo/geocaching/cgeopoint.java
index a976b20..56e5866 100644
--- a/main/src/cgeo/geocaching/cgeopoint.java
+++ b/main/src/cgeo/geocaching/cgeopoint.java
@@ -282,7 +282,7 @@ public class cgeopoint extends AbstractActivity {
if (latButton.getText().length() > 0 && lonButton.getText().length() > 0) {
gp = new Geopoint(latButton.getText().toString() + " " + lonButton.getText().toString());
}
- cgeocoords coordsDialog = new cgeocoords(cgeopoint.this, gp, geo);
+ cgeocoords coordsDialog = new cgeocoords(cgeopoint.this, null, gp, geo);
coordsDialog.setCancelable(true);
coordsDialog.setOnCoordinateUpdate(new cgeocoords.CoordinateUpdate() {
@Override
diff --git a/main/src/cgeo/geocaching/cgeowaypointadd.java b/main/src/cgeo/geocaching/cgeowaypointadd.java
index 74aee55..66e000e 100644
--- a/main/src/cgeo/geocaching/cgeowaypointadd.java
+++ b/main/src/cgeo/geocaching/cgeowaypointadd.java
@@ -229,7 +229,8 @@ public class cgeowaypointadd extends AbstractActivity {
if (waypoint != null && waypoint.getCoords() != null) {
gp = waypoint.getCoords();
}
- cgeocoords coordsDialog = new cgeocoords(cgeowaypointadd.this, gp, geo);
+ cgCache cache = app.getCacheByGeocode(geocode);
+ cgeocoords coordsDialog = new cgeocoords(cgeowaypointadd.this, cache, gp, geo);
coordsDialog.setCancelable(true);
coordsDialog.setOnCoordinateUpdate(new cgeocoords.CoordinateUpdate() {
@Override
diff --git a/main/src/cgeo/geocaching/files/LocParser.java b/main/src/cgeo/geocaching/files/LocParser.java
index 38ddb80..7a8a674 100644
--- a/main/src/cgeo/geocaching/files/LocParser.java
+++ b/main/src/cgeo/geocaching/files/LocParser.java
@@ -125,7 +125,7 @@ public final class LocParser extends FileParser {
} else if (size == 8) {
pointCoord.setSize(CacheSize.SMALL);
} else {
- pointCoord.setSize(null);
+ pointCoord.setSize(CacheSize.UNKNOWN);
}
}
diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
index bc046f1..0a4e395 100644
--- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java
+++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
@@ -570,11 +570,11 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
holder.favourite.setBackgroundResource(favoriteBack);
if (cacheListType == CacheListType.HISTORY && cache.getVisitedDate() > 0) {
- StringBuilder cacheInfo = new StringBuilder(50);
- cacheInfo.append(cgBase.formatTime(cache.getVisitedDate()));
- cacheInfo.append("; ");
- cacheInfo.append(cgBase.formatDate(cache.getVisitedDate()));
- holder.info.setText(cacheInfo.toString());
+ ArrayList<String> infos = new ArrayList<String>();
+ infos.add(StringUtils.upperCase(cache.getGeocode()));
+ infos.add(cgBase.formatDate(cache.getVisitedDate()));
+ infos.add(cgBase.formatTime(cache.getVisitedDate()));
+ holder.info.setText(StringUtils.join(infos, SEPARATOR));
} else {
ArrayList<String> infos = new ArrayList<String>();
if (StringUtils.isNotBlank(cache.getGeocode())) {