diff options
author | Torsten Keil <github@torsten-keil.net> | 2012-02-21 21:50:41 +0100 |
---|---|---|
committer | Torsten Keil <github@torsten-keil.net> | 2012-02-22 00:09:27 +0100 |
commit | f60a64ef2349a1f9fe6933f028f50e146ec958fd (patch) | |
tree | 37556ea43fd35d0bdffdb415ea45ad9016db3325 /main/src/cgeo/geocaching/apps/cache | |
parent | 009c9575e84379612a710955436f703c7a27bdbc (diff) | |
download | cgeo-f60a64ef2349a1f9fe6933f028f50e146ec958fd.zip cgeo-f60a64ef2349a1f9fe6933f028f50e146ec958fd.tar.gz cgeo-f60a64ef2349a1f9fe6933f028f50e146ec958fd.tar.bz2 |
Implementation for #1155 - the second default navigation tool is
introduced
Diffstat (limited to 'main/src/cgeo/geocaching/apps/cache')
-rw-r--r-- | main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index 53240bc..e2a1fc1 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -90,7 +90,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { /** * 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 @@ -103,7 +103,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * should be <code>false</code> only when called from within the internal map * @param showDefaultNavigation * should be <code>false</code> by default - * + * * @see #showNavigationMenu(cgGeo, Activity, cgCache, cgWaypoint, Geopoint) */ public static void showNavigationMenu(final cgGeo geo, final Activity activity, @@ -297,8 +297,31 @@ public final class NavigationAppFactory extends AbstractAppFactory { } /** + * 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 search + * @param waypoint + * @param destination + */ + public static void startDefaultNavigationApplication2(final cgGeo geo, 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(Settings.tag, "NavigationAppFactory.startDefaultNavigationApplication2: " + e.toString()); + } + } + } + + /** * Returns the default navigation tool if correctly set and installed or the compass app as default fallback - * + * * @param activity * @return never <code>null</code> */ @@ -316,4 +339,24 @@ 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) { + final int defaultNavigationTool = Settings.getDefaultNavigationTool2(); + + final List<NavigationAppsEnum> installedNavigationApps = getInstalledNavigationApps(activity); + + for (NavigationAppsEnum navigationApp : installedNavigationApps) { + if (navigationApp.id == defaultNavigationTool) { + return navigationApp.app; + } + } + // second default navigation tool wasn't set already or couldn't be found (not installed any more for example) + return NavigationAppsEnum.COMPASS.app; + } + } |