aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSammysHP <sven@sammyshp.de>2011-08-24 15:22:27 +0200
committerSammysHP <sven@sammyshp.de>2011-08-24 15:22:27 +0200
commita888c9a75a42944687aa203f0138fce4c5ab971d (patch)
tree95ccf0e5898cc085794738eb14cb9438ce43255e /src
parentb02a3087ab658d38fdc9728112d16645ec3a1279 (diff)
downloadcgeo-a888c9a75a42944687aa203f0138fce4c5ab971d.zip
cgeo-a888c9a75a42944687aa203f0138fce4c5ab971d.tar.gz
cgeo-a888c9a75a42944687aa203f0138fce4c5ab971d.tar.bz2
Add Street View, closes #282
Diffstat (limited to 'src')
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java6
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java49
2 files changed, 53 insertions, 2 deletions
diff --git a/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index 81f251d..e496e33 100644
--- a/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -24,8 +24,10 @@ public final class NavigationAppFactory extends AbstractAppFactory {
new InternalMap(res),
new StaticMapApp(res),
new LocusApp(res),
- new RMapsApp(res), new GoogleMapsApp(res),
- new GoogleNavigationApp(res) };
+ new RMapsApp(res),
+ new GoogleMapsApp(res),
+ new GoogleNavigationApp(res),
+ new StreetviewApp(res)};
}
return apps;
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java b/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
new file mode 100644
index 0000000..24d6606
--- /dev/null
+++ b/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
@@ -0,0 +1,49 @@
+package cgeo.geocaching.apps.cache.navi;
+
+import android.app.Activity;
+import android.content.ActivityNotFoundException;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.net.Uri;
+import cgeo.geocaching.R;
+import cgeo.geocaching.cgCache;
+import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.activity.ActivityMixin;
+
+class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
+
+ StreetviewApp(final Resources res) {
+ super(res.getString(R.string.cache_menu_streetview), null);
+ }
+
+ @Override
+ public boolean isInstalled(Context context) {
+ return true;
+ }
+
+ public boolean invoke(cgGeo geo, Activity activity, Resources res,
+ cgCache cache,
+ Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ if (cache == null && waypoint == null && latitude == null && longitude == 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)));
+ }
+
+ return true;
+ } catch (ActivityNotFoundException e) {
+ if (res != null) {
+ ActivityMixin.showToast(activity, res.getString(R.string.err_application_no));
+ }
+ }
+
+ return false;
+ }
+}