diff options
| author | Bananeweizen <Bananeweizen@gmx.de> | 2012-06-23 21:29:52 -0700 |
|---|---|---|
| committer | Bananeweizen <Bananeweizen@gmx.de> | 2012-06-23 21:29:52 -0700 |
| commit | 41bb57de4796cf1935b256df9801e3be860d840c (patch) | |
| tree | f4137253f5c223430a56e0f776d9eb379ba26e06 /main/src/cgeo/geocaching/Settings.java | |
| parent | 789b58bcb158ca99ba36dff711c8b6658b31d8ab (diff) | |
| parent | 9957988aeb5a6cf64dc34eb44dc4670bca53bbbc (diff) | |
| download | cgeo-41bb57de4796cf1935b256df9801e3be860d840c.zip cgeo-41bb57de4796cf1935b256df9801e3be860d840c.tar.gz cgeo-41bb57de4796cf1935b256df9801e3be860d840c.tar.bz2 | |
Merge pull request #1821 from rsudev/issue374
Fix #374, store last known location
Diffstat (limited to 'main/src/cgeo/geocaching/Settings.java')
| -rw-r--r-- | main/src/cgeo/geocaching/Settings.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/Settings.java b/main/src/cgeo/geocaching/Settings.java index e610844..bbcb80b 100644 --- a/main/src/cgeo/geocaching/Settings.java +++ b/main/src/cgeo/geocaching/Settings.java @@ -8,6 +8,7 @@ import cgeo.geocaching.enumerations.LiveMapStrategy.Strategy; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.maps.MapProviderFactory; +import cgeo.geocaching.maps.interfaces.GeoPointImpl; import cgeo.geocaching.maps.interfaces.MapProvider; import cgeo.geocaching.maps.mapsforge.MapsforgeMapProvider; import cgeo.geocaching.utils.CryptUtils; @@ -47,6 +48,8 @@ public final class Settings { private static final String KEY_SHOW_CAPTCHA = "showcaptcha"; private static final String KEY_MAP_TRAIL = "maptrail"; private static final String KEY_LAST_MAP_ZOOM = "mapzoom"; + private static final String KEY_LAST_MAP_LAT = "maplat"; + private static final String KEY_LAST_MAP_LON = "maplon"; private static final String KEY_LIVE_LIST = "livelist"; private static final String KEY_METRIC_UNITS = "units"; private static final String KEY_SKIN = "skin"; @@ -805,6 +808,23 @@ public final class Settings { }); } + public static GeoPointImpl getMapCenter() { + return getMapProvider().getMapItemFactory() + .getGeoPointBase(new Geopoint(sharedPrefs.getInt(KEY_LAST_MAP_LAT, 0) / 1e6, + sharedPrefs.getInt(KEY_LAST_MAP_LON, 0) / 1e6)); + } + + public static void setMapCenter(final GeoPointImpl mapViewCenter) { + editSharedSettings(new PrefRunnable() { + + @Override + public void edit(Editor edit) { + edit.putInt(KEY_LAST_MAP_LAT, mapViewCenter.getLatitudeE6()); + edit.putInt(KEY_LAST_MAP_LON, mapViewCenter.getLongitudeE6()); + } + }); + } + public static int getMapSource() { return sharedPrefs.getInt(KEY_MAP_SOURCE, 0); } @@ -1177,4 +1197,5 @@ public final class Settings { // there is currently no Android API to get the file name of the shared preferences return cgeoapplication.getInstance().getPackageName() + "_preferences"; } + } |
