aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/apps/cache/navi
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-01-05 07:48:03 +0100
committerBananeweizen <bananeweizen@gmx.de>2012-01-05 07:48:03 +0100
commit63799d93f2c0870b45b2c7c813215014198ade06 (patch)
tree9249a27e6d0308758600c070db0a9b6ff7ff7f03 /main/src/cgeo/geocaching/apps/cache/navi
parent40f8b5a31fc913cba9cc06c5c758a3ebc5acfbc9 (diff)
downloadcgeo-63799d93f2c0870b45b2c7c813215014198ade06.zip
cgeo-63799d93f2c0870b45b2c7c813215014198ade06.tar.gz
cgeo-63799d93f2c0870b45b2c7c813215014198ade06.tar.bz2
fix #944: Navigon support
Diffstat (limited to 'main/src/cgeo/geocaching/apps/cache/navi')
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java64
2 files changed, 66 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index 6e596b0..234b182 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -34,7 +34,8 @@ public final class NavigationAppFactory extends AbstractAppFactory {
new GoogleMapsApp(res),
new GoogleNavigationApp(res),
new StreetviewApp(res),
- new OruxMapsApp(res) };
+ new OruxMapsApp(res),
+ new NavigonApp() };
}
return apps;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java
new file mode 100644
index 0000000..98d95ef
--- /dev/null
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java
@@ -0,0 +1,64 @@
+package cgeo.geocaching.apps.cache.navi;
+
+import cgeo.geocaching.SearchResult;
+import cgeo.geocaching.cgCache;
+import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.geopoint.Geopoint;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Resources;
+
+public class NavigonApp extends AbstractNavigationApp {
+
+ private static final String INTENT = "android.intent.action.navigon.START_PUBLIC";
+ private static final String INTENT_EXTRA_KEY_LATITUDE = "latitude";
+ private static final String INTENT_EXTRA_KEY_LONGITUDE = "longitude";
+
+ NavigonApp() {
+ super("Navigon", INTENT);
+ }
+
+ @Override
+ public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, SearchResult search, cgWaypoint waypoint, Geopoint coords) {
+ if (cache == null && waypoint == null && coords == null) {
+ return false;
+ }
+
+ try {
+ if (isInstalled(activity)) {
+ Geopoint usedCoords = getCoords(cache, waypoint, coords);
+
+ final Intent intent = new Intent(INTENT);
+
+ /*
+ * Long/Lat are float values in decimal degree format (+-DDD.DDDDD).
+ * Example:
+ * intent.putExtra(INTENT_EXTRA_KEY_LATITUDE, 46.12345f);
+ * intent.putExtra(INTENT_EXTRA_KEY_LONGITUDE, 23.12345f);
+ */
+ intent.putExtra(INTENT_EXTRA_KEY_LATITUDE, (float) usedCoords.getLatitude());
+ intent.putExtra(INTENT_EXTRA_KEY_LONGITUDE, (float) usedCoords.getLongitude());
+
+ activity.startActivity(intent);
+
+ return true;
+ }
+ } catch (Exception e) {
+ // nothing
+ }
+
+ return false;
+ }
+
+ private static Geopoint getCoords(cgCache cache, cgWaypoint waypoint, Geopoint coords) {
+ if (cache != null) {
+ return cache.getCoords();
+ }
+ else if (waypoint != null) {
+ return waypoint.getCoords();
+ }
+ return coords;
+ }
+} \ No newline at end of file