diff options
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/cgeo/geocaching/StaticMapsProvider.java | 17 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/apps/cache/CacheBeaconApp.java | 21 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java | 7 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 19 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeotrackable.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/enumerations/CacheAttribute.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 2 |
7 files changed, 68 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java index 6de1291..ea99d54 100644 --- a/main/src/cgeo/geocaching/StaticMapsProvider.java +++ b/main/src/cgeo/geocaching/StaticMapsProvider.java @@ -85,10 +85,13 @@ public class StaticMapsProvider { } private static void downloadMaps(cgCache cache, Display display) { + if (cache == null) { + Log.e("downloadMaps - missing input parameter cache"); + return; + } if ((!Settings.isStoreOfflineMaps() && !Settings.isStoreOfflineWpMaps()) || StringUtils.isBlank(cache.getGeocode())) { return; } - int edge = guessMaxDisplaySide(display); if (Settings.isStoreOfflineMaps() && cache.getCoords() != null) { @@ -112,6 +115,14 @@ public class StaticMapsProvider { } private static void storeWaypointStaticMap(final String geocode, int edge, cgWaypoint waypoint, final boolean waitForResult) { + if (geocode == null) { + Log.e("storeWaypointStaticMap - missing input parameter geocode"); + return; + } + if (waypoint == null) { + Log.e("storeWaypointStaticMap - missing input parameter waypoint"); + return; + } if (waypoint.getCoords() == null) { return; } @@ -142,6 +153,10 @@ public class StaticMapsProvider { } public static void storeCachePreviewMap(final cgCache cache) { + if (cache == null) { + Log.e("storeCachePreviewMap - missing input parameter cache"); + return; + } final String latlonMap = cache.getCoords().format(Format.LAT_LON_DECDEGREE_COMMA); final String markerUrl = MARKERS_URL + "my_location_mdpi.png"; final Display display = ((WindowManager) cgeoapplication.getInstance().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); diff --git a/main/src/cgeo/geocaching/apps/cache/CacheBeaconApp.java b/main/src/cgeo/geocaching/apps/cache/CacheBeaconApp.java new file mode 100644 index 0000000..6e7cdca --- /dev/null +++ b/main/src/cgeo/geocaching/apps/cache/CacheBeaconApp.java @@ -0,0 +1,21 @@ +package cgeo.geocaching.apps.cache; + +import cgeo.geocaching.R; +import cgeo.geocaching.cgCache; +import cgeo.geocaching.enumerations.CacheAttribute; + +public class CacheBeaconApp extends AbstractGeneralApp { + + protected CacheBeaconApp() { + super(getString(R.string.cache_menu_cachebeacon), "de.fun2code.android.cachebeacon"); + } + + @Override + public boolean isEnabled(cgCache cache) { + if (cache == null) { + return false; + } + return cache.hasAttribute(CacheAttribute.WIRELESS_BEACON, true); + } + +} diff --git a/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java b/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java index 98e7db8..57eb957 100644 --- a/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java @@ -15,8 +15,11 @@ public final class GeneralAppsFactory extends AbstractAppFactory { private static GeneralApp[] getGeneralApps() { if (ArrayUtils.isEmpty(apps)) { - apps = new GeneralApp[] { new GccApp(), - new WhereYouGoApp() }; + apps = new GeneralApp[] { + new CacheBeaconApp(), + new GccApp(), + new WhereYouGoApp() + }; } return apps; } diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index b8590e5..cd4e15c 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -10,9 +10,11 @@ import cgeo.geocaching.connector.capability.ISearchByGeocode; import cgeo.geocaching.connector.gc.GCConnector; import cgeo.geocaching.connector.gc.GCConstants; import cgeo.geocaching.connector.gc.Tile; +import cgeo.geocaching.enumerations.CacheAttribute; import cgeo.geocaching.enumerations.CacheSize; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LoadFlags; +import cgeo.geocaching.enumerations.LoadFlags.LoadFlag; import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag; import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.LogType; @@ -1591,4 +1593,21 @@ public class cgCache implements ICache, IWaypoint { } return null; } + + /** + * check whether the cache has a given attribute + * + * @param attribute + * @param yes + * true if we are looking for the attribute_yes version, false for the attribute_no version + * @return + */ + public boolean hasAttribute(CacheAttribute attribute, boolean yes) { + // lazy loading of attributes + cgCache fullCache = cgeoapplication.getInstance().loadCache(getGeocode(), EnumSet.of(LoadFlag.LOAD_ATTRIBUTES)); + if (fullCache == null) { + fullCache = this; + } + return fullCache.getAttributes().contains(attribute.getAttributeName(yes)); + } }
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/cgeotrackable.java b/main/src/cgeo/geocaching/cgeotrackable.java index acd351d..3cdc58d 100644 --- a/main/src/cgeo/geocaching/cgeotrackable.java +++ b/main/src/cgeo/geocaching/cgeotrackable.java @@ -395,7 +395,7 @@ public class cgeotrackable extends AbstractActivity { @Override public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(MENU_LOG_TOUCH).setEnabled(trackable.isLoggable()); + menu.findItem(MENU_LOG_TOUCH).setEnabled(StringUtils.isNotBlank(geocode) && trackable.isLoggable()); menu.findItem(MENU_BROWSER_TRACKABLE).setEnabled(StringUtils.isNotBlank(trackable.getUrl())); return super.onPrepareOptionsMenu(menu); } diff --git a/main/src/cgeo/geocaching/enumerations/CacheAttribute.java b/main/src/cgeo/geocaching/enumerations/CacheAttribute.java index 6456f71..a31b0cc 100644 --- a/main/src/cgeo/geocaching/enumerations/CacheAttribute.java +++ b/main/src/cgeo/geocaching/enumerations/CacheAttribute.java @@ -137,4 +137,8 @@ public enum CacheAttribute { public static boolean isEnabled(final String attributeName) { return !StringUtils.endsWithIgnoreCase(attributeName, INTERNAL_NO); } + + public String getAttributeName(final boolean yes) { + return gcRawName + (yes ? INTERNAL_YES : INTERNAL_NO); + } } diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index c4d2192..d2910c4 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -389,6 +389,8 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto waypointTypeIntent = WaypointType.findById(extras.getString(EXTRAS_WPTTYPE)); mapStateIntent = extras.getIntArray(EXTRAS_MAPSTATE); mapTitle = extras.getString(EXTRAS_MAP_TITLE); + + Settings.setLiveMap(mapMode == MapMode.LIVE_ONLINE ? true : false); } else { mapMode = Settings.isLiveMap() ? MapMode.LIVE_ONLINE : MapMode.LIVE_OFFLINE; |