diff options
Diffstat (limited to 'main/src')
6 files changed, 52 insertions, 3 deletions
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; |
