aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/apps/cache/navi
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgeo/geocaching/apps/cache/navi')
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java21
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java33
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/InternalMap.java7
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/LocusApp.java33
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/NavigationApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java12
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RMapsApp.java20
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RadarApp.java21
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java18
10 files changed, 85 insertions, 86 deletions
diff --git a/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
index 273be5c..6307434 100644
--- a/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
@@ -14,6 +14,7 @@ import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.geopoint.Geopoint;
class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
@@ -28,18 +29,16 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
- if (cache == null && waypoint == null && latitude == null && longitude == null) {
+ final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ if (cache == null && waypoint == null && coords == null) {
return false;
}
try {
- if (cache != null && cache.latitude != null && cache.longitude != null) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("geo:" + cache.latitude + "," + cache.longitude)));
- // INFO: q parameter works with Google Maps, but breaks cooperation with all other apps
- } else if (waypoint != null && waypoint.latitude != null && waypoint.longitude != null) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("geo:" + waypoint.latitude + "," + waypoint.longitude)));
- // INFO: q parameter works with Google Maps, but breaks cooperation with all other apps
+ if (cache != null && cache.coords != null) {
+ startActivity(activity, cache.coords);
+ } else if (waypoint != null && waypoint.coords != null) {
+ startActivity(activity, waypoint.coords);
}
return true;
@@ -56,4 +55,10 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
return false;
}
+ private void startActivity(Activity activity, final Geopoint coords) {
+ activity.startActivity(new Intent(Intent.ACTION_VIEW,
+ Uri.parse("geo:" + coords.getLatitude() + "," + coords.getLongitude())));
+ // INFO: q parameter works with Google Maps, but breaks cooperation with all other apps
+ }
+
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
index 4a7a49e..c106988 100644
--- a/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
@@ -14,6 +14,7 @@ import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.geopoint.Geopoint;
class GoogleNavigationApp extends AbstractNavigationApp implements
NavigationApp {
@@ -30,20 +31,20 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
@Override
public boolean invoke(final cgGeo geo, final Activity activity, final Resources res,
final cgCache cache,
- final UUID searchId, final cgWaypoint waypoint, final Double latitude, final Double longitude) {
+ final UUID searchId, final cgWaypoint waypoint, final Geopoint coords) {
if (activity == null) {
return false;
}
boolean navigationResult = false;
- if (latitude != null && longitude != null) {
- navigationResult = navigateToCoordinates(geo, activity, latitude, longitude);
+ if (coords != null) {
+ navigationResult = navigateToCoordinates(geo, activity, coords);
}
else if (waypoint != null) {
- navigationResult = navigateToCoordinates(geo, activity, waypoint.latitude, waypoint.longitude);
+ navigationResult = navigateToCoordinates(geo, activity, waypoint.coords);
}
else if (cache != null) {
- navigationResult = navigateToCoordinates(geo, activity, cache.latitude, cache.longitude);
+ navigationResult = navigateToCoordinates(geo, activity, cache.coords);
}
if (!navigationResult) {
@@ -56,14 +57,8 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
return true;
}
- private static boolean navigateToCoordinates(cgGeo geo, Activity activity, Double latitude,
- Double longitude) {
- Double latitudeNow = null;
- Double longitudeNow = null;
- if (geo != null) {
- latitudeNow = geo.latitudeNow;
- longitudeNow = geo.longitudeNow;
- }
+ private static boolean navigateToCoordinates(cgGeo geo, Activity activity, final Geopoint coords) {
+ final Geopoint coordsNow = geo == null ? null : geo.coordsNow;
cgSettings settings = getSettings(activity);
@@ -71,8 +66,8 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
if (settings.useGNavigation == 1) {
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
- .parse("google.navigation:ll=" + latitude + ","
- + longitude)));
+ .parse("google.navigation:ll=" + coords.getLatitude() + ","
+ + coords.getLongitude())));
return true;
} catch (Exception e) {
@@ -82,15 +77,15 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
// Google Maps Directions
try {
- if (latitudeNow != null && longitudeNow != null) {
+ if (coordsNow != null) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://maps.google.com/maps?f=d&saddr="
- + latitudeNow + "," + longitudeNow + "&daddr="
- + latitude + "," + longitude)));
+ + coordsNow.getLatitude() + "," + coordsNow.getLongitude() + "&daddr="
+ + coords.getLatitude() + "," + coords.getLongitude())));
} else {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://maps.google.com/maps?f=d&daddr="
- + latitude + "," + longitude)));
+ + coords.getLatitude() + "," + coords.getLongitude())));
}
return true;
diff --git a/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
index 513172c..4936842 100644
--- a/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
+++ b/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
@@ -10,6 +10,7 @@ import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.geopoint.Geopoint;
class InternalMap extends AbstractInternalMap implements
NavigationApp {
@@ -21,7 +22,7 @@ class InternalMap extends AbstractInternalMap implements
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
cgSettings settings = getSettings(activity);
Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass());
if (cache != null) {
@@ -33,8 +34,8 @@ class InternalMap extends AbstractInternalMap implements
mapIntent.putExtra("searchid", searchId.toString());
}
if (waypoint != null) {
- mapIntent.putExtra("latitude", waypoint.latitude);
- mapIntent.putExtra("longitude", waypoint.longitude);
+ mapIntent.putExtra("latitude", waypoint.coords.getLatitude());
+ mapIntent.putExtra("longitude", waypoint.coords.getLongitude());
mapIntent.putExtra("wpttype", waypoint.type);
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
index fdba2fc..3c9928e 100644
--- a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
@@ -19,6 +19,7 @@ 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 {
@@ -30,9 +31,8 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
- if (cache == null && waypoint == null && latitude == null
- && longitude == null) {
+ final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ if (cache == null && waypoint == null && coords == null) {
return false;
}
try {
@@ -42,7 +42,7 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
if (cache != null && cache.waypoints != null
&& cache.waypoints.isEmpty() == false) {
for (cgWaypoint wp : cache.waypoints) {
- if (wp.latitude != null && wp.longitude != null) {
+ if (wp.coords != null) {
waypoints.add(wp);
}
}
@@ -118,24 +118,21 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
dos.writeUTF("");
}
- if (cache != null && cache.latitude != null
- && cache.longitude != null) {
- dos.writeDouble(cache.latitude); // latitude
- dos.writeDouble(cache.longitude); // longitude
- } else if (waypoint != null && waypoint.latitude != null
- && waypoint.longitude != null) {
- dos.writeDouble(waypoint.latitude); // latitude
- dos.writeDouble(waypoint.longitude); // longitude
+ 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(latitude); // latitude
- dos.writeDouble(longitude); // longitude
+ dos.writeDouble(coords.getLatitude()); // latitude
+ dos.writeDouble(coords.getLongitude()); // longitude
}
// cache waypoints
if (CollectionUtils.isNotEmpty(waypoints)) {
for (cgWaypoint wp : waypoints) {
- if (wp == null || wp.latitude == null
- || wp.longitude == null) {
+ if (wp == null || wp.coords == null) {
continue;
}
@@ -181,8 +178,8 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
dos.writeUTF("");
}
- dos.writeDouble(wp.latitude); // latitude
- dos.writeDouble(wp.longitude); // longitude
+ dos.writeDouble(wp.coords.getLatitude()); // latitude
+ dos.writeDouble(wp.coords.getLongitude()); // longitude
}
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java b/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
index db0c1e3..8a5bd13 100644
--- a/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
@@ -8,11 +8,12 @@ import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.App;
+import cgeo.geocaching.geopoint.Geopoint;
interface NavigationApp extends App {
public boolean invoke(final cgGeo geo, final Activity activity,
final Resources res,
final cgCache cache,
final UUID searchId, final cgWaypoint waypoint,
- final Double latitude, final Double longitude);
+ final Geopoint coords);
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index b8872e3..70609de 100644
--- a/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.ArrayUtils;
@@ -15,6 +14,7 @@ import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractAppFactory;
+import cgeo.geocaching.geopoint.Geopoint;
public final class NavigationAppFactory extends AbstractAppFactory {
private static NavigationApp[] apps = new NavigationApp[] {};
@@ -47,18 +47,12 @@ public final class NavigationAppFactory extends AbstractAppFactory {
public static boolean onMenuItemSelected(final MenuItem item,
final cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, List<Double> destination) {
+ final UUID searchId, cgWaypoint waypoint, final Geopoint destination) {
NavigationApp app = (NavigationApp) getAppFromMenuItem(item, apps);
if (app != null) {
- Double latitude = null;
- Double longitude = null;
- if (destination != null && destination.size() >= 2) {
- latitude = destination.get(0);
- longitude = destination.get(1);
- }
try {
return app.invoke(geo, activity, res, cache,
- searchId, waypoint, latitude, longitude);
+ searchId, waypoint, destination);
} catch (Exception e) {
Log.e(cgSettings.tag, "NavigationAppFactory.onMenuItemSelected: " + e.toString());
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
index 8e75aaa..37c727d 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
@@ -11,6 +11,7 @@ import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.geopoint.Geopoint;
class RMapsApp extends AbstractNavigationApp implements NavigationApp {
@@ -23,32 +24,29 @@ class RMapsApp extends AbstractNavigationApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
- if (cache == null && waypoint == null && latitude == null
- && longitude == null) {
+ final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ if (cache == null && waypoint == null && coords == null) {
return false;
}
try {
if (isInstalled(activity)) {
final ArrayList<String> locations = new ArrayList<String>();
- if (cache != null && cache.latitude != null
- && cache.longitude != null) {
+ if (cache != null && cache.coords != null) {
locations.add(String.format((Locale) null, "%.6f",
- cache.latitude)
+ cache.coords.getLatitude())
+ ","
+ String.format((Locale) null, "%.6f",
- cache.longitude)
+ cache.coords.getLongitude())
+ ";"
+ cache.geocode
+ ";" + cache.name);
- } else if (waypoint != null && waypoint.latitude != null
- && waypoint.longitude != null) {
+ } else if (waypoint != null && waypoint.coords != null) {
locations.add(String.format((Locale) null, "%.6f",
- waypoint.latitude)
+ waypoint.coords.getLatitude())
+ ","
+ String.format((Locale) null, "%.6f",
- waypoint.longitude)
+ waypoint.coords.getLongitude())
+ ";"
+ waypoint.lookup
+ ";" + waypoint.name);
diff --git a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
index 7dc7676..1e5278f 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
@@ -9,6 +9,7 @@ import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.geopoint.Geopoint;
class RadarApp extends AbstractNavigationApp implements NavigationApp {
@@ -19,31 +20,31 @@ class RadarApp extends AbstractNavigationApp implements NavigationApp {
super(res.getString(R.string.cache_menu_radar), INTENT, PACKAGE_NAME);
}
- private static void navigateTo(Activity activity, Double latitude, Double longitude) {
+ private static void navigateTo(Activity activity, final Geopoint coords) {
Intent radarIntent = new Intent(INTENT);
- radarIntent.putExtra("latitude", Float.valueOf(latitude.floatValue()));
- radarIntent.putExtra("longitude", Float.valueOf(longitude.floatValue()));
+ radarIntent.putExtra("latitude", (float) coords.getLatitude());
+ radarIntent.putExtra("longitude", (float) coords.getLongitude());
activity.startActivity(radarIntent);
}
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
if (cache != null) {
- if (cache.latitude != null && cache.longitude != null) {
- navigateTo(activity, cache.latitude, cache.longitude);
+ if (cache.coords != null) {
+ navigateTo(activity, cache.coords);
return true;
}
}
if (waypoint != null) {
- if (waypoint.latitude != null && waypoint.longitude != null) {
- navigateTo(activity, waypoint.latitude, waypoint.longitude);
+ if (waypoint.coords != null) {
+ navigateTo(activity, waypoint.coords);
return true;
}
}
- if (latitude != null && longitude != null) {
- navigateTo(activity, latitude, longitude);
+ if (coords != null) {
+ navigateTo(activity, coords);
return true;
}
return false;
diff --git a/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
index db6b27b..e989981 100644
--- a/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
@@ -12,6 +12,7 @@ import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeosmaps;
import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.geopoint.Geopoint;
class StaticMapApp extends AbstractNavigationApp implements
NavigationApp {
@@ -28,7 +29,7 @@ class StaticMapApp extends AbstractNavigationApp implements
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
if (cache == null || cache.reason == 0) {
ActivityMixin.showToast(activity, res.getString(R.string.err_detail_no_map_static));
diff --git a/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java b/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
index 250bc65..1b8a101 100644
--- a/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
@@ -13,6 +13,7 @@ import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.geopoint.Geopoint;
class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
@@ -27,16 +28,16 @@ class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
- if (cache == null && waypoint == null && latitude == null && longitude == null) {
+ final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ if (cache == null && waypoint == null && coords == null) {
return false;
}
try {
- if (cache != null && cache.latitude != null && cache.longitude != null) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("google.streetview:cbll=" + cache.latitude + "," + cache.longitude)));
- } else if (waypoint != null && waypoint.latitude != null && waypoint.longitude != null) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("google.streetview:cbll=" + waypoint.latitude + "," + waypoint.longitude)));
+ if (cache != null && cache.coords != null) {
+ startActivity(activity, cache.coords);
+ } else if (waypoint != null && waypoint.coords != null) {
+ startActivity(activity, waypoint.coords);
}
return true;
@@ -48,4 +49,9 @@ class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
return false;
}
+
+ private void startActivity(Activity activity, final Geopoint coords) {
+ activity.startActivity(new Intent(Intent.ACTION_VIEW,
+ Uri.parse("google.streetview:cbll=" + coords.getLatitude() + "," + coords.getLongitude())));
+ }
}