aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/apps/cache
diff options
context:
space:
mode:
authorTorsten Keil <github@torsten-keil.net>2012-02-03 22:41:29 +0100
committerTorsten Keil <github@torsten-keil.net>2012-02-03 22:41:29 +0100
commitcc96d7528f661bc65d5de4a09a625400718fe831 (patch)
tree4922dfa03c1ab4e7ba8b3e33c94ca8f22e4078d1 /main/src/cgeo/geocaching/apps/cache
parentf80652303c09c112cc1759d75a10c766eacc7568 (diff)
downloadcgeo-cc96d7528f661bc65d5de4a09a625400718fe831.zip
cgeo-cc96d7528f661bc65d5de4a09a625400718fe831.tar.gz
cgeo-cc96d7528f661bc65d5de4a09a625400718fe831.tar.bz2
Added check for static maps.
Diffstat (limited to 'main/src/cgeo/geocaching/apps/cache')
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java29
1 files changed, 26 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 9ac752f..0ec3a0a 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -3,12 +3,16 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
+import cgeo.geocaching.StaticMapsProvider;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.apps.AbstractAppFactory;
import cgeo.geocaching.geopoint.Geopoint;
+import org.apache.commons.lang3.StringUtils;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -113,10 +117,13 @@ public final class NavigationAppFactory extends AbstractAppFactory {
builder.setIcon(android.R.drawable.ic_menu_mapmode);
final List<NavigationAppsEnum> items = new ArrayList<NavigationAppFactory.NavigationAppsEnum>();
final int defaultNavigationTool = Settings.getDefaultNavigationTool();
-// final boolean isOffline = cache != null ? cgeoapplication.getInstance().isOffline(cache.getGeocode(), null) : false;
- // (isOffline && NavigationAppsEnum.STATIC_MAP.id == navApp.id) <== must be changed, isn't working for waypoints for example
+ final boolean hasStaticMaps = hasStaticMap(cache, waypoint);
for (NavigationAppsEnum navApp : getInstalledNavigationApps(activity)) {
- if ((showInternalMap || !(navApp.app instanceof InternalMap)) &&
+ if (NavigationAppsEnum.STATIC_MAP.id == navApp.id) {
+ if (hasStaticMaps) {
+ items.add(navApp);
+ }
+ } else if ((showInternalMap || !(navApp.app instanceof InternalMap)) &&
(showDefaultNavigation || defaultNavigationTool != navApp.id)) {
items.add(navApp);
}
@@ -150,7 +157,23 @@ public final class NavigationAppFactory extends AbstractAppFactory {
});
final AlertDialog alert = builder.create();
alert.show();
+ }
+ private static boolean hasStaticMap(cgCache cache, cgWaypoint waypoint) {
+ if (waypoint != null) {
+ String geocode = waypoint.getGeocode();
+ int id = waypoint.getId();
+ if (StringUtils.isNotEmpty(geocode) && cgeoapplication.getInstance().isOffline(geocode, null)) {
+ return StaticMapsProvider.doesExistStaticMapForWaypoint(geocode, id);
+ }
+ }
+ if (cache != null) {
+ String geocode = cache.getGeocode();
+ if (StringUtils.isNotEmpty(geocode) && cgeoapplication.getInstance().isOffline(geocode, null)) {
+ return StaticMapsProvider.doesExistStaticMapForCache(geocode);
+ }
+ }
+ return false;
}
/**