diff options
Diffstat (limited to 'main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java')
-rw-r--r-- | main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java new file mode 100644 index 0000000..71430ae --- /dev/null +++ b/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java @@ -0,0 +1,59 @@ +package cgeo.geocaching.apps.cache.navi; + +import cgeo.geocaching.R; +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; + +import java.util.UUID; + +class OruxMapsApp extends AbstractNavigationApp implements NavigationApp { + + private static final String INTENT = "com.oruxmaps.VIEW_MAP_ONLINE"; + + OruxMapsApp(final Resources res) { + super(res.getString(R.string.cache_menu_oruxmaps), INTENT); + } + + @Override + public boolean invoke(cgGeo geo, Activity activity, Resources res, + cgCache cache, + final UUID searchId, cgWaypoint waypoint, final 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); + intent.putExtra("latitude", usedCoords.getLatitude());//latitude, wgs84 datum + intent.putExtra("longitude", usedCoords.getLongitude());//longitude, wgs84 datum + + 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.coords; + } + else if (waypoint != null) { + return waypoint.coords; + } + return coords; + } +} |