aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/apps/cache
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-05-05 18:53:59 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-05-05 18:53:59 +0200
commit9c34c714484eb0791d02f85af396aeeba940d103 (patch)
treefd722280c9a99a5a795bcdb0ddb5a0eed8e83e89 /main/src/cgeo/geocaching/apps/cache
parentc3f97cce33fedadf7d33b6d603c31de872ca0a79 (diff)
downloadcgeo-9c34c714484eb0791d02f85af396aeeba940d103.zip
cgeo-9c34c714484eb0791d02f85af396aeeba940d103.tar.gz
cgeo-9c34c714484eb0791d02f85af396aeeba940d103.tar.bz2
fix #1459: Refactoring navigation menu
Diffstat (limited to 'main/src/cgeo/geocaching/apps/cache')
-rw-r--r--main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java2
-rw-r--r--main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java7
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java5
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java7
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java9
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java7
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java128
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java3
15 files changed, 73 insertions, 116 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java b/main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java
index 2b1dff4..61528ea 100644
--- a/main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java
@@ -14,7 +14,7 @@ abstract class AbstractGeneralApp extends AbstractApp implements GeneralApp {
@Override
public boolean invoke(Activity activity, cgCache cache) {
- final Intent intent = getLaunchIntent(activity);
+ final Intent intent = getLaunchIntent();
if (intent != null) {
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(intent);
diff --git a/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java b/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
index 49db025..22ce677 100644
--- a/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
@@ -21,16 +21,15 @@ public final class GeneralAppsFactory extends AbstractAppFactory {
return apps;
}
- public static void addMenuItems(Menu menu, Activity activity, cgCache cache) {
+ public static void addMenuItems(Menu menu, cgCache cache) {
for (GeneralApp app : getGeneralApps()) {
- if (app.isInstalled(activity) && app.isEnabled(cache)) {
+ if (app.isInstalled() && app.isEnabled(cache)) {
menu.add(0, app.getId(), 0, app.getName());
}
}
}
- public static boolean onMenuItemSelected(final MenuItem item,
- Activity activity, cgCache cache) {
+ public static boolean onMenuItemSelected(final MenuItem item, Activity activity, cgCache cache) {
final GeneralApp app = (GeneralApp) getAppFromMenuItem(item, apps);
if (app != null) {
try {
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
index 16b641e..893b9d6 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.geopoint.Geopoint;
@@ -24,13 +23,13 @@ abstract class AbstractPointNavigationApp extends AbstractNavigationApp {
}
@Override
- public final boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, Geopoint coords) {
+ public final boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, Geopoint coords) {
if (cache == null && waypoint == null && coords == null) {
return false;
}
try {
- if (isInstalled(activity)) {
+ if (isInstalled()) {
final Geopoint point = getCoordinates(cache, waypoint, coords);
if (point != null) {
navigate(activity, point);
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
index cfef583..ffcac8e 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
@@ -12,7 +12,6 @@ import cgeo.geocaching.activity.ActivityMixin;
import org.apache.commons.lang3.StringUtils;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
abstract class AbstractStaticMapsApp extends AbstractNavigationApp {
@@ -21,7 +20,7 @@ abstract class AbstractStaticMapsApp extends AbstractNavigationApp {
}
@Override
- public boolean isInstalled(Context context) {
+ public boolean isInstalled() {
return true;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java
index 720b85a..1576617 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
@@ -8,7 +7,6 @@ import cgeo.geocaching.cgeonavigate;
import cgeo.geocaching.geopoint.Geopoint;
import android.app.Activity;
-import android.content.Context;
class CompassApp extends AbstractNavigationApp {
@@ -17,13 +15,12 @@ class CompassApp extends AbstractNavigationApp {
}
@Override
- public boolean isInstalled(Context context) {
+ public boolean isInstalled() {
return true;
}
@Override
- public boolean invoke(IGeoData geo, Activity activity, cgCache cache,
- cgWaypoint waypoint, final Geopoint coords) {
+ public boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
if (cache != null && cache.getGeocode() != null) {
cgeonavigate.startActivity(activity, cache.getGeocode(), cache.getName(), cache.getCoords(), null);
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
index b6407e7..e104f9b 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
@@ -15,7 +14,7 @@ class DownloadStaticMapsApp extends AbstractStaticMapsApp {
}
@Override
- public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
+ public boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
return invoke(activity, cache, waypoint, true);
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
index 24aa693..4e6e62b 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
@@ -6,7 +6,6 @@ import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.utils.Log;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -17,7 +16,7 @@ class GoogleMapsApp extends AbstractPointNavigationApp {
}
@Override
- public boolean isInstalled(Context context) {
+ public boolean isInstalled() {
return true;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
index fb72157..31d99e9 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
@@ -3,14 +3,14 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
import cgeo.geocaching.Settings;
-import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.utils.Log;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -21,16 +21,17 @@ class GoogleNavigationApp extends AbstractNavigationApp {
}
@Override
- public boolean isInstalled(Context context) {
+ public boolean isInstalled() {
return true;
}
@Override
- public boolean invoke(final IGeoData geo, final Activity activity, final cgCache cache, final cgWaypoint waypoint, final Geopoint coords) {
+ public boolean invoke(final Activity activity, final cgCache cache, final cgWaypoint waypoint, final Geopoint coords) {
if (activity == null) {
return false;
}
+ IGeoData geo = cgeoapplication.getInstance().currentGeo();
boolean navigationResult = false;
if (coords != null) {
navigationResult = navigateToCoordinates(geo, activity, coords);
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
index 2f05459..f1e03ed 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
@@ -9,7 +8,6 @@ import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.CGeoMap;
import android.app.Activity;
-import android.content.Context;
class InternalMap extends AbstractNavigationApp {
@@ -18,8 +16,7 @@ class InternalMap extends AbstractNavigationApp {
}
@Override
- public boolean invoke(IGeoData geo, Activity activity, cgCache cache,
- cgWaypoint waypoint, final Geopoint coords) {
+ public boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
if (cache != null) {
CGeoMap.startActivityGeoCode(activity, cache.getGeocode());
// may need some code from CGeoMap.startActivitySearch(activity, search, cache != null ? cache.getGeocode() : null, true);
@@ -35,7 +32,7 @@ class InternalMap extends AbstractNavigationApp {
}
@Override
- public boolean isInstalled(Context context) {
+ public boolean isInstalled() {
return true;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
index 43e86c4..cd2440e 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractLocusApp;
@@ -20,7 +19,7 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
* @author koem
*/
@Override
- public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
+ public boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
final ArrayList<Object> points = new ArrayList<Object>();
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
index f073331..9ec273e 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.App;
@@ -9,7 +8,7 @@ import cgeo.geocaching.geopoint.Geopoint;
import android.app.Activity;
public interface NavigationApp extends App {
- public boolean invoke(final IGeoData geo, final Activity activity,
+ public boolean invoke(final Activity activity,
final cgCache cache, final cgWaypoint waypoint,
final Geopoint coords);
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index 4602a04..903dbd4 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
@@ -76,26 +75,23 @@ public final class NavigationAppFactory extends AbstractAppFactory {
* Default way to handle selection of navigation tool.<br />
* A dialog is created for tool selection and the selected tool is started afterwards.
* <p />
- * Delegates to
- * {@link #showNavigationMenu(IGeoData, Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} with
+ * Delegates to {@link #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} with
* <code>showInternalMap = true</code> and <code>showDefaultNavigation = false</code>
*
- * @param geo
* @param activity
* @param cache
* @param waypoint
* @param destination
*/
- public static void showNavigationMenu(final IGeoData geo, final Activity activity,
+ public static void showNavigationMenu(final Activity activity,
final cgCache cache, final cgWaypoint waypoint, final Geopoint destination) {
- showNavigationMenu(geo, activity, cache, waypoint, destination, true, false);
+ showNavigationMenu(activity, cache, waypoint, destination, true, false);
}
/**
* Specialized way to handle selection of navigation tool.<br />
* A dialog is created for tool selection and the selected tool is started afterwards.
*
- * @param geo
* @param activity
* @param cache
* may be <code>null</code>
@@ -108,9 +104,9 @@ public final class NavigationAppFactory extends AbstractAppFactory {
* @param showDefaultNavigation
* should be <code>false</code> by default
*
- * @see #showNavigationMenu(IGeoData, Activity, cgCache, cgWaypoint, Geopoint)
+ * @see #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint)
*/
- public static void showNavigationMenu(final IGeoData geo, final Activity activity,
+ public static void showNavigationMenu(final Activity activity,
final cgCache cache, final cgWaypoint waypoint, final Geopoint destination,
final boolean showInternalMap, final boolean showDefaultNavigation) {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
@@ -118,7 +114,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
builder.setIcon(R.drawable.ic_menu_mapmode);
final List<NavigationAppsEnum> items = new ArrayList<NavigationAppFactory.NavigationAppsEnum>();
final int defaultNavigationTool = Settings.getDefaultNavigationTool();
- for (NavigationAppsEnum navApp : getInstalledNavigationApps(activity)) {
+ for (NavigationAppsEnum navApp : getInstalledNavigationApps()) {
if ((showInternalMap || !(navApp.app instanceof InternalMap)) &&
(showDefaultNavigation || defaultNavigationTool != navApp.id)) {
if ((cache != null && navApp.app.isEnabled(cache)) || (waypoint != null && navApp.app.isEnabled(waypoint))) {
@@ -135,7 +131,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
NavigationAppsEnum selectedItem = adapter.getItem(item);
- selectedItem.app.invoke(geo, activity, cache, waypoint, destination);
+ selectedItem.app.invoke(activity, cache, waypoint, destination);
}
});
final AlertDialog alert = builder.create();
@@ -145,13 +141,12 @@ public final class NavigationAppFactory extends AbstractAppFactory {
/**
* Returns all installed navigation apps.
*
- * @param activity
* @return
*/
- public static List<NavigationAppsEnum> getInstalledNavigationApps(final Activity activity) {
+ public static List<NavigationAppsEnum> getInstalledNavigationApps() {
final List<NavigationAppsEnum> installedNavigationApps = new ArrayList<NavigationAppsEnum>();
for (NavigationAppsEnum appEnum : NavigationAppsEnum.values()) {
- if (appEnum.app.isInstalled(activity)) {
+ if (appEnum.app.isInstalled()) {
installedNavigationApps.add(appEnum);
}
}
@@ -166,51 +161,57 @@ public final class NavigationAppFactory extends AbstractAppFactory {
/**
* Adds the installed navigation tools to the given menu.
- * Use {@link #onMenuItemSelected(MenuItem, IGeoData, Activity, cgCache, cgWaypoint, Geopoint)} on
+ * Use {@link #onMenuItemSelected(MenuItem, Activity, cgCache)} on
* selection event to start the selected navigation tool.
- *
- * <b>Only use this way if
- * {@link #showNavigationMenu(IGeoData, Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} is
+ *
+ * <b>Only use this way if {@link #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} is
* not suitable for the given usecase.</b>
- *
+ *
* @param menu
- * @param activity
- * @param filter
*/
- public static void addMenuItems(final Menu menu, final Activity activity, final List<NavigationAppsEnum> filter) {
- for (NavigationAppsEnum navApp : getInstalledNavigationApps(activity)) {
- if (filter.contains(navApp)) {
- continue;
+ public static void addMenuItems(final Menu menu, final cgCache cache) {
+ for (NavigationAppsEnum navApp : getInstalledNavigationApps()) {
+ if (navApp.app.isEnabled(cache)) {
+ menu.add(0, MENU_ITEM_OFFSET + navApp.id, 0, navApp.app.getName());
+ }
+ }
+ }
+
+ public static void addMenuItems(final Menu menu, final cgWaypoint waypoint) {
+ for (NavigationAppsEnum navApp : getInstalledNavigationApps()) {
+ if (navApp.app.isEnabled(waypoint)) {
+ menu.add(0, MENU_ITEM_OFFSET + navApp.id, 0, navApp.app.getName());
}
- menu.add(0, MENU_ITEM_OFFSET + navApp.id, 0, navApp.app.getName());
}
}
/**
- * Handles menu selections for menu entries created with {@link #addMenuItems(Menu, Activity)} or
- * {@link #addMenuItems(Menu, Activity, boolean, boolean)}.
+ * Handles menu selections for menu entries created with {@link #addMenuItems(Menu, cgCache)}.
*
* @param item
- * @param geo
* @param activity
* @param cache
- * @param waypoint
- * @param destination
* @return
*/
- public static boolean onMenuItemSelected(final MenuItem item,
- final IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint destination) {
+ public static boolean onMenuItemSelected(final MenuItem item, Activity activity, cgCache cache) {
+ return invokeApp(activity, cache, null, null, getAppFromMenuItem(item));
+ }
+
+ public static boolean onMenuItemSelected(final MenuItem item, Activity activity, cgWaypoint waypoint) {
+ return invokeApp(activity, null, waypoint, null, getAppFromMenuItem(item));
+ }
+
+ private static boolean invokeApp(Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint destination, final NavigationApp app) {
+ if (app == null) {
+ return false;
+ }
if (cache == null && waypoint == null && destination == null) {
return false;
}
-
- final NavigationApp app = getAppFromMenuItem(item);
- if (app != null) {
- try {
- return app.invoke(geo, activity, cache, waypoint, destination);
- } catch (Exception e) {
- Log.e("NavigationAppFactory.onMenuItemSelected: " + e.toString());
- }
+ try {
+ return app.invoke(activity, cache, waypoint, destination);
+ } catch (Exception e) {
+ Log.e("NavigationAppFactory.onMenuItemSelected: " + e.toString());
}
return false;
}
@@ -228,59 +229,40 @@ public final class NavigationAppFactory extends AbstractAppFactory {
/**
* Starts the default navigation tool if correctly set and installed or the compass app as default fallback.
*
- * @param geo
* @param activity
* @param cache
* @param waypoint
* @param destination
*/
- public static void startDefaultNavigationApplication(final IGeoData geo, Activity activity, cgCache cache,
+ public static void startDefaultNavigationApplication(Activity activity, cgCache cache,
cgWaypoint waypoint, final Geopoint destination) {
- final NavigationApp app = getDefaultNavigationApplication(activity);
-
- if (app != null) {
- try {
- app.invoke(geo, activity, cache, waypoint, destination);
- } catch (Exception e) {
- Log.e("NavigationAppFactory.startDefaultNavigationApplication: " + e.toString());
- }
- }
+ invokeApp(activity, cache, waypoint, destination, getDefaultNavigationApplication());
}
/**
* Starts the second default navigation tool if correctly set and installed or the compass app as default fallback.
*
- * @param geo
* @param activity
* @param cache
* @param waypoint
* @param destination
*/
- public static void startDefaultNavigationApplication2(final IGeoData geo, Activity activity, cgCache cache,
+ public static void startDefaultNavigationApplication2(Activity activity, cgCache cache,
cgWaypoint waypoint, final Geopoint destination) {
- final NavigationApp app = getDefaultNavigationApplication2(activity);
-
- if (app != null) {
- try {
- app.invoke(geo, activity, cache, waypoint, destination);
- } catch (Exception e) {
- Log.e("NavigationAppFactory.startDefaultNavigationApplication2: " + e.toString());
- }
- }
+ invokeApp(activity, cache, waypoint, destination, getNavigationAppFromSetting(Settings.getDefaultNavigationTool2()));
}
/**
* Returns the default navigation tool if correctly set and installed or the compass app as default fallback
*
- * @param activity
* @return never <code>null</code>
*/
- public static NavigationApp getDefaultNavigationApplication(Activity activity) {
- return getNavigationAppFromSetting(activity, Settings.getDefaultNavigationTool());
+ public static NavigationApp getDefaultNavigationApplication() {
+ return getNavigationAppFromSetting(Settings.getDefaultNavigationTool());
}
- private static NavigationApp getNavigationAppFromSetting(Activity activity, final int defaultNavigationTool) {
- final List<NavigationAppsEnum> installedNavigationApps = getInstalledNavigationApps(activity);
+ private static NavigationApp getNavigationAppFromSetting(final int defaultNavigationTool) {
+ final List<NavigationAppsEnum> installedNavigationApps = getInstalledNavigationApps();
for (NavigationAppsEnum navigationApp : installedNavigationApps) {
if (navigationApp.id == defaultNavigationTool) {
@@ -291,14 +273,4 @@ public final class NavigationAppFactory extends AbstractAppFactory {
return NavigationAppsEnum.COMPASS.app;
}
- /**
- * Returns the second default navigation tool if correctly set and installed or the compass app as default fallback
- *
- * @param activity
- * @return never <code>null</code>
- */
- public static NavigationApp getDefaultNavigationApplication2(Activity activity) {
- return getNavigationAppFromSetting(activity, Settings.getDefaultNavigationTool2());
- }
-
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
index 9af90ac..8044cc6 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
@@ -21,7 +20,7 @@ class RMapsApp extends AbstractNavigationApp {
}
@Override
- public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
+ public boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
try {
final ArrayList<String> locations = new ArrayList<String>();
if (cache != null && cache.getCoords() != null) {
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
index 2f6e7c0..078343b 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
@@ -15,7 +14,7 @@ class StaticMapApp extends AbstractStaticMapsApp {
}
@Override
- public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
+ public boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {
return invoke(activity, cache, waypoint, false);
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
index 12b1a13..41f958d 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
@@ -7,7 +7,6 @@ import cgeo.geocaching.geopoint.Geopoint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
-import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -18,7 +17,7 @@ class StreetviewApp extends AbstractPointNavigationApp {
}
@Override
- public boolean isInstalled(Context context) {
+ public boolean isInstalled() {
return true;
}