aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/Settings.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/Settings.java')
-rw-r--r--main/src/cgeo/geocaching/Settings.java42
1 files changed, 38 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/Settings.java b/main/src/cgeo/geocaching/Settings.java
index 70d6851..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";
@@ -91,6 +94,7 @@ public final class Settings {
private static final String KEY_SETTINGS_VERSION = "settingsversion";
private static final String KEY_DB_ON_SDCARD = "dbonsdcard";
private static final String KEY_LAST_TRACKABLE_ACTION = "trackableaction";
+ private static final String KEY_SHARE_AFTER_EXPORT = "shareafterexport";
private final static int unitsMetric = 1;
@@ -199,7 +203,7 @@ public final class Settings {
e.putBoolean(KEY_HIDE_LIVE_MAP_HINT, old.getInt(KEY_HIDE_LIVE_MAP_HINT, 0) != 0);
e.putInt(KEY_LIVE_MAP_HINT_SHOW_COUNT, old.getInt(KEY_LIVE_MAP_HINT_SHOW_COUNT, 0));
- e.putInt(KEY_SETTINGS_VERSION, 1) ; // mark migrated
+ e.putInt(KEY_SETTINGS_VERSION, 1); // mark migrated
e.commit();
}
}
@@ -804,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);
}
@@ -1089,7 +1110,6 @@ public final class Settings {
});
}
-
public static boolean isDebug() {
return Log.isDebug();
}
@@ -1097,7 +1117,8 @@ public final class Settings {
public static void setDebug(final boolean debug) {
editSharedSettings(new PrefRunnable() {
- @Override public void edit(Editor edit) {
+ @Override
+ public void edit(Editor edit) {
edit.putBoolean(KEY_DEBUG, debug);
}
});
@@ -1138,7 +1159,6 @@ public final class Settings {
public static void setDbOnSDCard(final boolean dbOnSDCard) {
editSharedSettings(new PrefRunnable() {
-
@Override
public void edit(Editor edit) {
edit.putBoolean(KEY_DB_ON_SDCARD, dbOnSDCard);
@@ -1146,6 +1166,15 @@ public final class Settings {
});
}
+ public static void setShareAfterExport(final boolean shareAfterExport) {
+ editSharedSettings(new PrefRunnable() {
+ @Override
+ public void edit(Editor edit) {
+ edit.putBoolean(KEY_SHARE_AFTER_EXPORT, shareAfterExport);
+ }
+ });
+ }
+
public static int getTrackableAction() {
return sharedPrefs.getInt(KEY_LAST_TRACKABLE_ACTION, LogType.RETRIEVED_IT.id);
}
@@ -1158,10 +1187,15 @@ public final class Settings {
edit.putInt(KEY_LAST_TRACKABLE_ACTION, trackableAction);
}
});
+ }
+
+ public static boolean getShareAfterExport() {
+ return sharedPrefs.getBoolean(KEY_SHARE_AFTER_EXPORT, true);
}
public static String getPreferencesName() {
// there is currently no Android API to get the file name of the shared preferences
return cgeoapplication.getInstance().getPackageName() + "_preferences";
}
+
}