aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsudev <rasch@munin-soft.de>2013-07-19 10:59:37 -0700
committerrsudev <rasch@munin-soft.de>2013-07-19 10:59:37 -0700
commit05f8940bd3c7911fae8902f315b4d5f3931678a7 (patch)
tree8193dbd9302ade6ce773d4481d6584f7f5064747
parent46bcd8d179e95a80680e83eb43e9bf6ddfaf6f12 (diff)
parent509499b5afdf91242b0cf1f13559236ccd7d9f1d (diff)
downloadcgeo-05f8940bd3c7911fae8902f315b4d5f3931678a7.zip
cgeo-05f8940bd3c7911fae8902f315b4d5f3931678a7.tar.gz
cgeo-05f8940bd3c7911fae8902f315b4d5f3931678a7.tar.bz2
Merge pull request #3030 from culmor30/issue-2234
Implements #2234: Hide own/found from Live Map
-rw-r--r--main/res/menu/map_activity.xml5
-rw-r--r--main/res/values/strings.xml2
-rw-r--r--main/src/cgeo/geocaching/connector/gc/Tile.java4
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java24
-rw-r--r--main/src/cgeo/geocaching/settings/Settings.java2
5 files changed, 32 insertions, 5 deletions
diff --git a/main/res/menu/map_activity.xml b/main/res/menu/map_activity.xml
index df8fe09..d81a49b 100644
--- a/main/res/menu/map_activity.xml
+++ b/main/res/menu/map_activity.xml
@@ -39,6 +39,11 @@
android:title="@string/map_circles_hide">
</item>
<item
+ android:id="@+id/menu_mycaches_mode"
+ android:icon="@android:drawable/ic_menu_myplaces"
+ android:title="@string/map_mycaches_hide">
+ </item>
+ <item
android:id="@+id/menu_theme_mode"
android:icon="@drawable/ic_menu_preferences"
android:title="@string/map_theme_select">
diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml
index c0bbded..22e5fbe 100644
--- a/main/res/values/strings.xml
+++ b/main/res/values/strings.xml
@@ -786,6 +786,8 @@
<string name="map_trail_hide">Hide trail</string>
<string name="map_circles_show">Show circles</string>
<string name="map_circles_hide">Hide circles</string>
+ <string name="map_mycaches_show">Show own/found caches</string>
+ <string name="map_mycaches_hide">Hide own/found caches</string>
<string name="map_theme_builtin">Default</string>
<string name="map_theme_select">Select map theme</string>
<string name="map_live_enable">Enable live</string>
diff --git a/main/src/cgeo/geocaching/connector/gc/Tile.java b/main/src/cgeo/geocaching/connector/gc/Tile.java
index ec90036..3177f2c 100644
--- a/main/src/cgeo/geocaching/connector/gc/Tile.java
+++ b/main/src/cgeo/geocaching/connector/gc/Tile.java
@@ -324,6 +324,10 @@ public class Tile {
public static void add(final Tile tile) {
tileCache.put(tile.hashCode(), tile);
}
+
+ public static void clear() {
+ tileCache.clear();
+ }
}
}
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 007f707..f892622 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -13,6 +13,7 @@ import cgeo.geocaching.cgeocaches;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.gc.Login;
+import cgeo.geocaching.connector.gc.Tile;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LiveMapStrategy.Strategy;
import cgeo.geocaching.enumerations.LoadFlags;
@@ -182,7 +183,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
/** Live mode enabled for map. **/
private boolean isLiveEnabled;
// other things
- private boolean liveChanged = false; // previous state for loadTimer
+ private boolean markersInvalidated = false; // previous state for loadTimer
private boolean centered = false; // if map is already centered
private boolean alreadyCentered = false; // -""- for setting my location
private static Set<String> dirtyCaches = null;
@@ -571,6 +572,13 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
item.setTitle(res.getString(R.string.map_live_enable));
}
+ item = menu.findItem(R.id.menu_mycaches_mode); // own & found caches
+ if (Settings.isExcludeMyCaches()) {
+ item.setTitle(res.getString(R.string.map_mycaches_show));
+ } else {
+ item.setTitle(res.getString(R.string.map_mycaches_hide));
+ }
+
final Set<String> geocodesInViewport = getGeocodesForCachesInViewport();
menu.findItem(R.id.menu_store_caches).setEnabled(!isLoading() && CollectionUtils.isNotEmpty(geocodesInViewport) && new SearchResult(geocodesInViewport).hasUnsavedCaches());
@@ -622,7 +630,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (mapMode == MapMode.LIVE) {
Settings.setLiveMap(isLiveEnabled);
}
- liveChanged = true;
+ markersInvalidated = true;
lastSearchResult = null;
searchIntent = null;
ActivityMixin.invalidateOptionsMenu(activity);
@@ -670,6 +678,14 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
mapView.repaintRequired(overlayCaches);
ActivityMixin.invalidateOptionsMenu(activity);
return true;
+ case R.id.menu_mycaches_mode:
+ Settings.setExcludeMine(!Settings.isExcludeMyCaches());
+ markersInvalidated = true;
+ ActivityMixin.invalidateOptionsMenu(activity);
+ if (!Settings.isExcludeMyCaches()) {
+ Tile.Cache.clear();
+ }
+ return true;
case R.id.menu_theme_mode:
selectMapTheme();
return true;
@@ -1018,7 +1034,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
// check if map moved or zoomed
//TODO Portree Use Rectangle inside with bigger search window. That will stop reloading on every move
- final boolean moved = liveChanged || (isLiveEnabled && !downloaded) || (viewport == null) || zoomNow != zoom ||
+ final boolean moved = markersInvalidated || (isLiveEnabled && !downloaded) || (viewport == null) || zoomNow != zoom ||
(mapMoved(viewport, viewportNow) && (cachesCnt <= 0 || CollectionUtils.isEmpty(caches) || !viewport.includes(viewportNow)));
// update title on any change
@@ -1029,7 +1045,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
// save new values
if (moved) {
- liveChanged = false;
+ markersInvalidated = false;
long currentTime = System.currentTimeMillis();
diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java
index 08f30af..e44f9c0 100644
--- a/main/src/cgeo/geocaching/settings/Settings.java
+++ b/main/src/cgeo/geocaching/settings/Settings.java
@@ -934,7 +934,7 @@ public final class Settings {
putBoolean(R.string.pref_excludedisabled, exclude);
}
- static void setExcludeMine(final boolean exclude) {
+ public static void setExcludeMine(final boolean exclude) {
putBoolean(R.string.pref_excludemine, exclude);
}