diff options
author | Marco Jacob <mjacob@union06.de> | 2012-05-04 22:49:50 +0200 |
---|---|---|
committer | Marco Jacob <mjacob@union06.de> | 2012-05-04 22:49:50 +0200 |
commit | 7424d471c8b57dbce2acf79c09660bf1a7222b3e (patch) | |
tree | 6fbe0c4c45461e4f966a534173e4683fb3367cfa /main/src/cgeo/geocaching/apps/cache | |
parent | 84c6bd6cc358b2cde2926a62990e4c151c47d6d1 (diff) | |
download | cgeo-7424d471c8b57dbce2acf79c09660bf1a7222b3e.zip cgeo-7424d471c8b57dbce2acf79c09660bf1a7222b3e.tar.gz cgeo-7424d471c8b57dbce2acf79c09660bf1a7222b3e.tar.bz2 |
solves issue #1494 to download static maps on demand without settings
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, 19 insertions, 30 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index e0c773c..9caa856 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -4,10 +4,10 @@ import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.StaticMapsProvider; -import cgeo.geocaching.apps.AbstractAppFactory; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeoapplication; +import cgeo.geocaching.apps.AbstractAppFactory; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.utils.Log; @@ -34,20 +34,22 @@ public final class NavigationAppFactory extends AbstractAppFactory { INTERNAL_MAP(new InternalMap(), 2), /** The internal static map activity */ STATIC_MAP(new StaticMapApp(), 3), + /** Download static maps on demand */ + DOWNLOAD_STATIC_MAPS(new DownloadStaticMapsApp(), 4), /** The external Locus app */ - LOCUS(new LocusApp(), 4), + LOCUS(new LocusApp(), 5), /** The external RMaps app */ - RMAPS(new RMapsApp(), 5), + RMAPS(new RMapsApp(), 6), /** Google Maps */ - GOOGLE_MAPS(new GoogleMapsApp(), 6), + GOOGLE_MAPS(new GoogleMapsApp(), 7), /** Google Navigation */ - GOOGLE_NAVIGATION(new GoogleNavigationApp(), 7), + GOOGLE_NAVIGATION(new GoogleNavigationApp(), 8), /** Google Streetview */ - GOOGLE_STREETVIEW(new StreetviewApp(), 8), + GOOGLE_STREETVIEW(new StreetviewApp(), 9), /** The external OruxMaps app */ - ORUX_MAPS(new OruxMapsApp(), 9), + ORUX_MAPS(new OruxMapsApp(), 10), /** The external navigon app */ - NAVIGON(new NavigonApp(), 10); + NAVIGON(new NavigonApp(), 11); NavigationAppsEnum(NavigationApp app, int id) { this.app = app; @@ -126,6 +128,10 @@ public final class NavigationAppFactory extends AbstractAppFactory { if (hasStaticMaps) { items.add(navApp); } + } else if (NavigationAppsEnum.DOWNLOAD_STATIC_MAPS.id == navApp.id) { + if (!hasStaticMaps) { + items.add(navApp); + } } else if ((showInternalMap || !(navApp.app instanceof InternalMap)) && (showDefaultNavigation || defaultNavigationTool != navApp.id)) { items.add(navApp); @@ -185,20 +191,6 @@ public final class NavigationAppFactory extends AbstractAppFactory { */ private static final int MENU_ITEM_OFFSET = 12345; - /** - * Adds the installed navigation tools to the given menu. - * Use {@link #onMenuItemSelected(MenuItem, IGeoData, Activity, cgCache, cgWaypoint, Geopoint)} on - * selection event to start the selected navigation tool. - * - * <b>Only use this way if {@link #showNavigationMenu(IGeoData, Activity, cgCache, cgWaypoint, Geopoint)} - * is not suitable for the given usecase.</b> - * - * @param menu - * @param activity - */ - public static void addMenuItems(final Menu menu, final Activity activity) { - addMenuItems(menu, activity, true, false); - } /** * Adds the installed navigation tools to the given menu. @@ -211,17 +203,14 @@ public final class NavigationAppFactory extends AbstractAppFactory { * * @param menu * @param activity - * @param showInternalMap - * @param showDefaultNavigation + * @param filter */ - public static void addMenuItems(final Menu menu, final Activity activity, - final boolean showInternalMap, final boolean showDefaultNavigation) { - final int defaultNavigationTool = Settings.getDefaultNavigationTool(); + public static void addMenuItems(final Menu menu, final Activity activity, final List<NavigationAppsEnum> filter) { for (NavigationAppsEnum navApp : getInstalledNavigationApps(activity)) { - if ((showInternalMap || !(navApp.app instanceof InternalMap)) && - (showDefaultNavigation || defaultNavigationTool != navApp.id)) { - menu.add(0, MENU_ITEM_OFFSET + navApp.id, 0, navApp.app.getName()); + if (filter.contains(navApp)) { + continue; } + menu.add(0, MENU_ITEM_OFFSET + navApp.id, 0, navApp.app.getName()); } } |