Fix version upgrade and remove unnecessary changes
This commit is contained in:
parent
e7fc000036
commit
dc55878c92
33 changed files with 237 additions and 232 deletions
|
@ -7,8 +7,10 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint.SpecialPointType;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||||
|
import net.osmand.plus.AppInitializer.InitEvents;
|
||||||
import net.osmand.plus.api.SettingsAPI;
|
import net.osmand.plus.api.SettingsAPI;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.backend.CommonPreference;
|
import net.osmand.plus.settings.backend.CommonPreference;
|
||||||
|
@ -24,6 +26,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
class AppVersionUpgradeOnInit {
|
class AppVersionUpgradeOnInit {
|
||||||
|
|
||||||
public static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
|
public static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
|
||||||
public static final String VERSION_INSTALLED_NUMBER = "VERSION_INSTALLED_NUMBER"; //$NON-NLS-1$
|
public static final String VERSION_INSTALLED_NUMBER = "VERSION_INSTALLED_NUMBER"; //$NON-NLS-1$
|
||||||
public static final String NUMBER_OF_STARTS = "NUMBER_OF_STARTS"; //$NON-NLS-1$
|
public static final String NUMBER_OF_STARTS = "NUMBER_OF_STARTS"; //$NON-NLS-1$
|
||||||
|
@ -56,16 +59,14 @@ class AppVersionUpgradeOnInit {
|
||||||
private int prevAppVersion;
|
private int prevAppVersion;
|
||||||
private boolean appVersionChanged;
|
private boolean appVersionChanged;
|
||||||
private boolean firstTime;
|
private boolean firstTime;
|
||||||
private OsmandSettings settings;
|
|
||||||
|
|
||||||
AppVersionUpgradeOnInit(OsmandApplication app) {
|
AppVersionUpgradeOnInit(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
settings = app.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
void upgradeVersion(SharedPreferences startPrefs, int lastVersion) {
|
void upgradeVersion(SharedPreferences startPrefs, int lastVersion) {
|
||||||
if(!startPrefs.contains(NUMBER_OF_STARTS)) {
|
if (!startPrefs.contains(NUMBER_OF_STARTS)) {
|
||||||
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
|
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
|
||||||
} else {
|
} else {
|
||||||
startPrefs.edit().putInt(NUMBER_OF_STARTS, startPrefs.getInt(NUMBER_OF_STARTS, 0) + 1).commit();
|
startPrefs.edit().putInt(NUMBER_OF_STARTS, startPrefs.getInt(NUMBER_OF_STARTS, 0) + 1).commit();
|
||||||
|
@ -81,7 +82,7 @@ class AppVersionUpgradeOnInit {
|
||||||
} else {
|
} else {
|
||||||
prevAppVersion = startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0);
|
prevAppVersion = startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0);
|
||||||
if (needsUpgrade(startPrefs, lastVersion)) {
|
if (needsUpgrade(startPrefs, lastVersion)) {
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
if (prevAppVersion < VERSION_2_2) {
|
if (prevAppVersion < VERSION_2_2) {
|
||||||
settings.SHOW_DASHBOARD_ON_START.set(true);
|
settings.SHOW_DASHBOARD_ON_START.set(true);
|
||||||
settings.SHOW_DASHBOARD_ON_MAP_SCREEN.set(true);
|
settings.SHOW_DASHBOARD_ON_MAP_SCREEN.set(true);
|
||||||
|
@ -121,13 +122,14 @@ class AppVersionUpgradeOnInit {
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7).commit();
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7).commit();
|
||||||
}
|
}
|
||||||
if (prevAppVersion < VERSION_3_7_01) {
|
if (prevAppVersion < VERSION_3_7_01) {
|
||||||
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
|
app.getAppInitializer().addListener(new AppInitializeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
||||||
if (event.equals(AppInitializer.InitEvents.FAVORITES_INITIALIZED)) {
|
if (event.equals(InitEvents.FAVORITES_INITIALIZED)) {
|
||||||
app.getFavorites().fixBlackBackground();
|
app.getFavorites().fixBlackBackground();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinish(AppInitializer init) {
|
public void onFinish(AppInitializer init) {
|
||||||
}
|
}
|
||||||
|
@ -158,20 +160,20 @@ class AppVersionUpgradeOnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetFirstTimeRun(SharedPreferences startPrefs) {
|
public void resetFirstTimeRun(SharedPreferences startPrefs) {
|
||||||
if(startPrefs != null) {
|
if (startPrefs != null) {
|
||||||
startPrefs.edit().remove(FIRST_TIME_APP_RUN).commit();
|
startPrefs.edit().remove(FIRST_TIME_APP_RUN).commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfStarts(SharedPreferences startPrefs) {
|
public int getNumberOfStarts(SharedPreferences startPrefs) {
|
||||||
if(startPrefs == null) {
|
if (startPrefs == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return startPrefs.getInt(NUMBER_OF_STARTS, 1);
|
return startPrefs.getInt(NUMBER_OF_STARTS, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getFirstInstalledDays(SharedPreferences startPrefs) {
|
public long getFirstInstalledDays(SharedPreferences startPrefs) {
|
||||||
if(startPrefs == null) {
|
if (startPrefs == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
long nd = startPrefs.getLong(FIRST_INSTALLED, 0);
|
long nd = startPrefs.getLong(FIRST_INSTALLED, 0);
|
||||||
|
@ -183,9 +185,8 @@ class AppVersionUpgradeOnInit {
|
||||||
return firstTime;
|
return firstTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void migratePreferences() {
|
public void migratePreferences() {
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
migrateEnumPreferences();
|
migrateEnumPreferences();
|
||||||
SharedPreferences globalSharedPreferences = (SharedPreferences) settings.getGlobalPreferences();
|
SharedPreferences globalSharedPreferences = (SharedPreferences) settings.getGlobalPreferences();
|
||||||
Map<String, ?> globalPrefsMap = globalSharedPreferences.getAll();
|
Map<String, ?> globalPrefsMap = globalSharedPreferences.getAll();
|
||||||
|
@ -213,7 +214,7 @@ class AppVersionUpgradeOnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (OsmandPreference<?> pref : settings.getGeneralPrefs()) {
|
for (OsmandPreference<?> pref : getGeneralPrefs()) {
|
||||||
if (pref instanceof CommonPreference) {
|
if (pref instanceof CommonPreference) {
|
||||||
CommonPreference<?> commonPref = (CommonPreference<?>) pref;
|
CommonPreference<?> commonPref = (CommonPreference<?>) pref;
|
||||||
Object defaultVal = commonPref.getModeValue(ApplicationMode.DEFAULT);
|
Object defaultVal = commonPref.getModeValue(ApplicationMode.DEFAULT);
|
||||||
|
@ -224,7 +225,6 @@ class AppVersionUpgradeOnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = settings.getSettingsAPI().getString(settings.getGlobalPreferences(), "custom_app_profiles", "");
|
String json = settings.getSettingsAPI().getString(settings.getGlobalPreferences(), "custom_app_profiles", "");
|
||||||
if (!Algorithms.isEmpty(json)) {
|
if (!Algorithms.isEmpty(json)) {
|
||||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
|
@ -241,9 +241,10 @@ class AppVersionUpgradeOnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrateEnumPreferences() {
|
public void migrateEnumPreferences() {
|
||||||
for (OsmandPreference pref : settings.getRegisteredPreferences().values()) {
|
OsmandSettings settings = app.getSettings();
|
||||||
|
for (OsmandPreference<?> pref : settings.getRegisteredPreferences().values()) {
|
||||||
if (pref instanceof EnumStringPreference) {
|
if (pref instanceof EnumStringPreference) {
|
||||||
EnumStringPreference enumPref = (EnumStringPreference) pref;
|
EnumStringPreference<?> enumPref = (EnumStringPreference<?>) pref;
|
||||||
if (enumPref.isGlobal()) {
|
if (enumPref.isGlobal()) {
|
||||||
migrateEnumPref(enumPref, (SharedPreferences) settings.getGlobalPreferences());
|
migrateEnumPref(enumPref, (SharedPreferences) settings.getGlobalPreferences());
|
||||||
} else {
|
} else {
|
||||||
|
@ -256,6 +257,7 @@ class AppVersionUpgradeOnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrateQuickActionStates() {
|
public void migrateQuickActionStates() {
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
String quickActionsJson = settings.getSettingsAPI().getString(settings.getGlobalPreferences(), "quick_action_new", "");
|
String quickActionsJson = settings.getSettingsAPI().getString(settings.getGlobalPreferences(), "quick_action_new", "");
|
||||||
if (!Algorithms.isEmpty(quickActionsJson)) {
|
if (!Algorithms.isEmpty(quickActionsJson)) {
|
||||||
Gson gson = new GsonBuilder().create();
|
Gson gson = new GsonBuilder().create();
|
||||||
|
@ -282,9 +284,10 @@ class AppVersionUpgradeOnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrateHomeWorkParkingToFavorites() {
|
public void migrateHomeWorkParkingToFavorites() {
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
FavouritesDbHelper favorites = app.getFavorites();
|
FavouritesDbHelper favorites = app.getFavorites();
|
||||||
SettingsAPI settingsAPI = settings.getSettingsAPI();
|
SettingsAPI settingsAPI = settings.getSettingsAPI();
|
||||||
Object globalPreferences= settings.getGlobalPreferences();
|
Object globalPreferences = settings.getGlobalPreferences();
|
||||||
|
|
||||||
LatLon homePoint = null;
|
LatLon homePoint = null;
|
||||||
float lat = settingsAPI.getFloat(globalPreferences, "home_point_lat", 0);
|
float lat = settingsAPI.getFloat(globalPreferences, "home_point_lat", 0);
|
||||||
|
@ -299,10 +302,47 @@ class AppVersionUpgradeOnInit {
|
||||||
workPoint = new LatLon(lat, lon);
|
workPoint = new LatLon(lat, lon);
|
||||||
}
|
}
|
||||||
if (homePoint != null) {
|
if (homePoint != null) {
|
||||||
favorites.setSpecialPoint(homePoint, FavouritePoint.SpecialPointType.HOME, null);
|
favorites.setSpecialPoint(homePoint, SpecialPointType.HOME, null);
|
||||||
}
|
}
|
||||||
if (workPoint != null) {
|
if (workPoint != null) {
|
||||||
favorites.setSpecialPoint(workPoint, FavouritePoint.SpecialPointType.WORK, null);
|
favorites.setSpecialPoint(workPoint, SpecialPointType.WORK, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public OsmandPreference<?>[] getGeneralPrefs() {
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
|
return new OsmandPreference[] {
|
||||||
|
settings.EXTERNAL_INPUT_DEVICE,
|
||||||
|
settings.CENTER_POSITION_ON_MAP,
|
||||||
|
settings.ROTATE_MAP,
|
||||||
|
settings.MAP_SCREEN_ORIENTATION,
|
||||||
|
settings.LIVE_MONITORING_URL,
|
||||||
|
settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND,
|
||||||
|
settings.LIVE_MONITORING_INTERVAL,
|
||||||
|
settings.LIVE_MONITORING,
|
||||||
|
settings.SHOW_TRIP_REC_NOTIFICATION,
|
||||||
|
settings.AUTO_SPLIT_RECORDING,
|
||||||
|
settings.SAVE_TRACK_MIN_SPEED,
|
||||||
|
settings.SAVE_TRACK_PRECISION,
|
||||||
|
settings.SAVE_TRACK_MIN_DISTANCE,
|
||||||
|
settings.SAVE_TRACK_INTERVAL,
|
||||||
|
settings.TRACK_STORAGE_DIRECTORY,
|
||||||
|
settings.SAVE_HEADING_TO_GPX,
|
||||||
|
settings.DISABLE_RECORDING_ONCE_APP_KILLED,
|
||||||
|
settings.SAVE_TRACK_TO_GPX,
|
||||||
|
settings.SAVE_GLOBAL_TRACK_REMEMBER,
|
||||||
|
settings.SAVE_GLOBAL_TRACK_INTERVAL,
|
||||||
|
settings.MAP_EMPTY_STATE_ALLOWED,
|
||||||
|
settings.DO_NOT_USE_ANIMATIONS,
|
||||||
|
settings.USE_KALMAN_FILTER_FOR_COMPASS,
|
||||||
|
settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS,
|
||||||
|
settings.USE_TRACKBALL_FOR_MOVEMENTS,
|
||||||
|
settings.SPEED_SYSTEM,
|
||||||
|
settings.ANGULAR_UNITS,
|
||||||
|
settings.METRIC_SYSTEM,
|
||||||
|
settings.DRIVING_REGION,
|
||||||
|
settings.DRIVING_REGION_AUTOMATIC
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,20 +1,6 @@
|
||||||
package net.osmand.plus.helpers;
|
package net.osmand.plus.helpers;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
import net.osmand.Location;
|
|
||||||
import net.osmand.PlatformUtil;
|
|
||||||
import net.osmand.StateChangedListener;
|
|
||||||
import net.osmand.plus.helpers.enums.DayNightMode;
|
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.util.SunriseSunset;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
|
@ -22,6 +8,20 @@ import android.hardware.SensorEventListener;
|
||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
|
|
||||||
|
import net.osmand.Location;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.StateChangedListener;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.helpers.enums.DayNightMode;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
import net.osmand.util.SunriseSunset;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to help determine if we want to render day or night map - it uses the
|
* Class to help determine if we want to render day or night map - it uses the
|
||||||
* DayNightMode enumeration for its behavior<BR>
|
* DayNightMode enumeration for its behavior<BR>
|
||||||
|
|
|
@ -24,5 +24,4 @@ public enum AngularConstants {
|
||||||
public String getUnitSymbol() {
|
public String getUnitSymbol() {
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ public enum AutoZoomMap {
|
||||||
FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f),
|
FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f),
|
||||||
FAR(R.string.auto_zoom_far, 1.4f, 17f),
|
FAR(R.string.auto_zoom_far, 1.4f, 17f),
|
||||||
CLOSE(R.string.auto_zoom_close, 2f, 19f);
|
CLOSE(R.string.auto_zoom_close, 2f, 19f);
|
||||||
|
|
||||||
public final float coefficient;
|
public final float coefficient;
|
||||||
public final int name;
|
public final int name;
|
||||||
public final float maxZoom;
|
public final float maxZoom;
|
||||||
|
@ -14,6 +15,5 @@ public enum AutoZoomMap {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.coefficient = coefficient;
|
this.coefficient = coefficient;
|
||||||
this.maxZoom = maxZoom;
|
this.maxZoom = maxZoom;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -54,7 +54,7 @@ public enum DrivingRegion {
|
||||||
return DrivingRegion.JAPAN;
|
return DrivingRegion.JAPAN;
|
||||||
} else if (df.getCountry().equalsIgnoreCase("au")) {
|
} else if (df.getCountry().equalsIgnoreCase("au")) {
|
||||||
return DrivingRegion.AUSTRALIA;
|
return DrivingRegion.AUSTRALIA;
|
||||||
} else if(df.getCountry().equalsIgnoreCase(Locale.UK.getCountry())) {
|
} else if (df.getCountry().equalsIgnoreCase(Locale.UK.getCountry())) {
|
||||||
return DrivingRegion.UK_AND_OTHERS;
|
return DrivingRegion.UK_AND_OTHERS;
|
||||||
}
|
}
|
||||||
return DrivingRegion.EUROPE_ASIA;
|
return DrivingRegion.EUROPE_ASIA;
|
||||||
|
|
|
@ -26,5 +26,4 @@ public enum MetricsConstants {
|
||||||
public String toTTSString() {
|
public String toTTSString() {
|
||||||
return ttsString;
|
return ttsString;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -29,5 +29,4 @@ public enum SpeedConstants {
|
||||||
public String toShortString(Context ctx) {
|
public String toShortString(Context ctx) {
|
||||||
return ctx.getString(key);
|
return ctx.getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,12 +2,12 @@ package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
public class BooleanPreference extends CommonPreference<Boolean> {
|
public class BooleanPreference extends CommonPreference<Boolean> {
|
||||||
|
|
||||||
BooleanPreference(OsmandSettings osmandSettings, String id, boolean defaultValue) {
|
BooleanPreference(OsmandSettings settings, String id, boolean defaultValue) {
|
||||||
super(osmandSettings, id, defaultValue);
|
super(settings, id, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean getValue(Object prefs, Boolean defaultValue) {
|
protected Boolean getValue(Object prefs, Boolean defaultValue) {
|
||||||
return getSettingsAPI().getBoolean(prefs, getId(), defaultValue);
|
return getSettingsAPI().getBoolean(prefs, getId(), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class BooleanStringPreference extends BooleanPreference {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean getValue(Object prefs, Boolean defaultValue) {
|
protected Boolean getValue(Object prefs, Boolean defaultValue) {
|
||||||
Boolean value;
|
Boolean value;
|
||||||
try {
|
try {
|
||||||
value = parseString(getSettingsAPI().getString(prefs, getId(), defaultValue.toString()));
|
value = parseString(getSettingsAPI().getString(prefs, getId(), defaultValue.toString()));
|
||||||
|
|
|
@ -10,25 +10,29 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
private OsmandSettings osmandSettings;
|
|
||||||
private final String id;
|
private OsmandSettings settings;
|
||||||
private boolean global;
|
|
||||||
private T cachedValue;
|
|
||||||
private Object cachedPreference;
|
private Object cachedPreference;
|
||||||
private boolean cache;
|
|
||||||
private Map<ApplicationMode, T> defaultValues;
|
private final String id;
|
||||||
|
|
||||||
|
private T cachedValue;
|
||||||
private T defaultValue;
|
private T defaultValue;
|
||||||
|
private Map<ApplicationMode, T> defaultValues;
|
||||||
|
|
||||||
|
private boolean cache;
|
||||||
|
private boolean global;
|
||||||
|
|
||||||
|
|
||||||
public CommonPreference(OsmandSettings osmandSettings, String id, T defaultValue) {
|
public CommonPreference(OsmandSettings settings, String id, T defaultValue) {
|
||||||
this.osmandSettings = osmandSettings;
|
this.settings = settings;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
osmandSettings.registerInternalPreference(id, this);
|
settings.registerInternalPreference(id, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods to possibly override
|
// Methods to possibly override
|
||||||
public abstract T getValue(Object prefs, T defaultValue);
|
protected abstract T getValue(Object prefs, T defaultValue);
|
||||||
|
|
||||||
protected abstract boolean setValue(Object prefs, T val);
|
protected abstract boolean setValue(Object prefs, T val);
|
||||||
|
|
||||||
|
@ -39,15 +43,15 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SettingsAPI getSettingsAPI() {
|
protected SettingsAPI getSettingsAPI() {
|
||||||
return osmandSettings.getSettingsAPI();
|
return settings.getSettingsAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ApplicationMode getApplicationMode() {
|
protected ApplicationMode getApplicationMode() {
|
||||||
return osmandSettings.getApplicationMode();
|
return settings.getApplicationMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected OsmandApplication getContext() {
|
protected OsmandApplication getContext() {
|
||||||
return osmandSettings.getContext();
|
return settings.getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
// common methods
|
// common methods
|
||||||
|
@ -68,7 +72,7 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object getPreferences() {
|
protected final Object getPreferences() {
|
||||||
return osmandSettings.getPreferences(global);
|
return settings.getPreferences(global);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +90,7 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
return set(obj);
|
return set(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object profilePrefs = osmandSettings.getProfilePreferences(mode);
|
Object profilePrefs = settings.getProfilePreferences(mode);
|
||||||
boolean valueSaved = setValue(profilePrefs, obj);
|
boolean valueSaved = setValue(profilePrefs, obj);
|
||||||
if (valueSaved && cache && cachedPreference == profilePrefs) {
|
if (valueSaved && cache && cachedPreference == profilePrefs) {
|
||||||
cachedValue = obj;
|
cachedValue = obj;
|
||||||
|
@ -121,7 +125,7 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
|
|
||||||
// TODO final
|
// TODO final
|
||||||
protected T getDefaultValue() {
|
protected T getDefaultValue() {
|
||||||
return getProfileDefaultValue(osmandSettings.currentMode);
|
return getProfileDefaultValue(settings.APPLICATION_MODE.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -129,8 +133,6 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
this.defaultValue = newDefaultValue;
|
this.defaultValue = newDefaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO final
|
// TODO final
|
||||||
@Override
|
@Override
|
||||||
public T getModeValue(ApplicationMode mode) {
|
public T getModeValue(ApplicationMode mode) {
|
||||||
|
@ -138,7 +140,7 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
T defaultV = getProfileDefaultValue(mode);
|
T defaultV = getProfileDefaultValue(mode);
|
||||||
return getValue(osmandSettings.getProfilePreferences(mode), defaultV);
|
return getValue(settings.getProfilePreferences(mode), defaultV);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO final
|
// TODO final
|
||||||
|
@ -148,7 +150,7 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
return cachedValue;
|
return cachedValue;
|
||||||
}
|
}
|
||||||
cachedPreference = getPreferences();
|
cachedPreference = getPreferences();
|
||||||
cachedValue = getValue(cachedPreference, getProfileDefaultValue(osmandSettings.currentMode));
|
cachedValue = getValue(cachedPreference, getProfileDefaultValue(settings.APPLICATION_MODE.get()));
|
||||||
return cachedValue;
|
return cachedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +161,7 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void resetToDefault() {
|
public final void resetToDefault() {
|
||||||
T o = getProfileDefaultValue(osmandSettings.currentMode);
|
T o = getProfileDefaultValue(settings.APPLICATION_MODE.get());
|
||||||
set(o);
|
set(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,11 +189,11 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isSet() {
|
public final boolean isSet() {
|
||||||
return osmandSettings.isSet(global, getId());
|
return settings.isSet(global, getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSetForMode(ApplicationMode mode) {
|
public boolean isSetForMode(ApplicationMode mode) {
|
||||||
return osmandSettings.isSet(mode, getId());
|
return settings.isSet(mode, getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isGlobal() {
|
public final boolean isGlobal() {
|
||||||
|
@ -218,6 +220,7 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO final
|
// TODO final
|
||||||
@Override
|
@Override
|
||||||
public void readFromJson(JSONObject json, ApplicationMode appMode) throws JSONException {
|
public void readFromJson(JSONObject json, ApplicationMode appMode) throws JSONException {
|
||||||
|
|
|
@ -6,13 +6,13 @@ public class ContextMenuItemsPreference extends CommonPreference<ContextMenuItem
|
||||||
@NonNull
|
@NonNull
|
||||||
private String idScheme;
|
private String idScheme;
|
||||||
|
|
||||||
ContextMenuItemsPreference(OsmandSettings osmandSettings, String id, @NonNull String idScheme, @NonNull ContextMenuItemsSettings defValue) {
|
ContextMenuItemsPreference(OsmandSettings settings, String id, @NonNull String idScheme, @NonNull ContextMenuItemsSettings defValue) {
|
||||||
super(osmandSettings, id, defValue);
|
super(settings, id, defValue);
|
||||||
this.idScheme = idScheme;
|
this.idScheme = idScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContextMenuItemsSettings getValue(Object prefs, ContextMenuItemsSettings defaultValue) {
|
protected ContextMenuItemsSettings getValue(Object prefs, ContextMenuItemsSettings defaultValue) {
|
||||||
String s = getSettingsAPI().getString(prefs, getId(), "");
|
String s = getSettingsAPI().getString(prefs, getId(), "");
|
||||||
return readValue(s);
|
return readValue(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package net.osmand.plus.settings.backend;
|
package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -13,14 +15,13 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
public class ContextMenuItemsSettings implements Serializable {
|
public class ContextMenuItemsSettings implements Serializable {
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(ContextMenuItemsSettings.class.getName());
|
private static final Log LOG = PlatformUtil.getLog(ContextMenuItemsSettings.class.getName());
|
||||||
|
|
||||||
private static final String HIDDEN = "hidden";
|
private static final String HIDDEN = "hidden";
|
||||||
private static final String ORDER = "order";
|
private static final String ORDER = "order";
|
||||||
|
|
||||||
private List<String> hiddenIds = new ArrayList<>();
|
private List<String> hiddenIds = new ArrayList<>();
|
||||||
private List<String> orderIds = new ArrayList<>();
|
private List<String> orderIds = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ public class EnumStringPreference<E extends Enum<E>> extends CommonPreference<E>
|
||||||
|
|
||||||
private final E[] values;
|
private final E[] values;
|
||||||
|
|
||||||
EnumStringPreference(OsmandSettings osmandSettings, String id, E defaultValue, E[] values) {
|
EnumStringPreference(OsmandSettings settings, String id, E defaultValue, E[] values) {
|
||||||
super(osmandSettings, id, defaultValue);
|
super(settings, id, defaultValue);
|
||||||
this.values = values;
|
this.values = values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E getValue(Object prefs, E defaultValue) {
|
protected E getValue(Object prefs, E defaultValue) {
|
||||||
try {
|
try {
|
||||||
String name = getSettingsAPI().getString(prefs, getId(), defaultValue.name());
|
String name = getSettingsAPI().getString(prefs, getId(), defaultValue.name());
|
||||||
E value = parseString(name);
|
E value = parseString(name);
|
||||||
|
|
|
@ -2,12 +2,12 @@ package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
public class FloatPreference extends CommonPreference<Float> {
|
public class FloatPreference extends CommonPreference<Float> {
|
||||||
|
|
||||||
FloatPreference(OsmandSettings osmandSettings, String id, float defaultValue) {
|
FloatPreference(OsmandSettings settings, String id, float defaultValue) {
|
||||||
super(osmandSettings, id, defaultValue);
|
super(settings, id, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Float getValue(Object prefs, Float defaultValue) {
|
protected Float getValue(Object prefs, Float defaultValue) {
|
||||||
return getSettingsAPI().getFloat(prefs, getId(), defaultValue);
|
return getSettingsAPI().getFloat(prefs, getId(), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -24,7 +24,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage {
|
||||||
|
|
||||||
public List<Long> getRoadIds(int size) {
|
public List<Long> getRoadIds(int size) {
|
||||||
List<Long> list = new ArrayList<>();
|
List<Long> list = new ArrayList<>();
|
||||||
String roadIds = getSettingsAPI().getString(getOsmandSettings().globalPreferences, roadsIdsKey, "");
|
String roadIds = getSettingsAPI().getString(getOsmandSettings().getGlobalPreferences(), roadsIdsKey, "");
|
||||||
if (roadIds.trim().length() > 0) {
|
if (roadIds.trim().length() > 0) {
|
||||||
StringTokenizer tok = new StringTokenizer(roadIds, ",");
|
StringTokenizer tok = new StringTokenizer(roadIds, ",");
|
||||||
while (tok.hasMoreTokens() && list.size() <= size) {
|
while (tok.hasMoreTokens() && list.size() <= size) {
|
||||||
|
@ -39,7 +39,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage {
|
||||||
|
|
||||||
public List<String> getAppModeKeys(int size) {
|
public List<String> getAppModeKeys(int size) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
String roadIds = getSettingsAPI().getString(getOsmandSettings().globalPreferences, appModeKey, "");
|
String roadIds = getSettingsAPI().getString(getOsmandSettings().getGlobalPreferences(), appModeKey, "");
|
||||||
if (roadIds.trim().length() > 0) {
|
if (roadIds.trim().length() > 0) {
|
||||||
StringTokenizer tok = new StringTokenizer(roadIds, ",");
|
StringTokenizer tok = new StringTokenizer(roadIds, ",");
|
||||||
while (tok.hasMoreTokens() && list.size() <= size) {
|
while (tok.hasMoreTokens() && list.size() <= size) {
|
||||||
|
@ -52,19 +52,19 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AvoidSpecificRoads.AvoidRoadInfo> getImpassableRoadsInfo() {
|
public List<AvoidRoadInfo> getImpassableRoadsInfo() {
|
||||||
List<LatLon> points = getPoints();
|
List<LatLon> points = getPoints();
|
||||||
List<Long> roadIds = getRoadIds(points.size());
|
List<Long> roadIds = getRoadIds(points.size());
|
||||||
List<String> appModeKeys = getAppModeKeys(points.size());
|
List<String> appModeKeys = getAppModeKeys(points.size());
|
||||||
List<String> descriptions = getPointDescriptions(points.size());
|
List<String> descriptions = getPointDescriptions(points.size());
|
||||||
|
|
||||||
List<AvoidSpecificRoads.AvoidRoadInfo> avoidRoadsInfo = new ArrayList<>();
|
List<AvoidRoadInfo> avoidRoadsInfo = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < points.size(); i++) {
|
for (int i = 0; i < points.size(); i++) {
|
||||||
LatLon latLon = points.get(i);
|
LatLon latLon = points.get(i);
|
||||||
PointDescription description = PointDescription.deserializeFromString(descriptions.get(i), null);
|
PointDescription description = PointDescription.deserializeFromString(descriptions.get(i), null);
|
||||||
|
|
||||||
AvoidSpecificRoads.AvoidRoadInfo avoidRoadInfo = new AvoidSpecificRoads.AvoidRoadInfo();
|
AvoidRoadInfo avoidRoadInfo = new AvoidRoadInfo();
|
||||||
avoidRoadInfo.id = roadIds.get(i);
|
avoidRoadInfo.id = roadIds.get(i);
|
||||||
avoidRoadInfo.latitude = latLon.getLatitude();
|
avoidRoadInfo.latitude = latLon.getLatitude();
|
||||||
avoidRoadInfo.longitude = latLon.getLongitude();
|
avoidRoadInfo.longitude = latLon.getLongitude();
|
||||||
|
@ -76,7 +76,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage {
|
||||||
return avoidRoadsInfo;
|
return avoidRoadsInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addImpassableRoadInfo(AvoidSpecificRoads.AvoidRoadInfo avoidRoadInfo) {
|
public boolean addImpassableRoadInfo(AvoidRoadInfo avoidRoadInfo) {
|
||||||
List<LatLon> points = getPoints();
|
List<LatLon> points = getPoints();
|
||||||
List<Long> roadIds = getRoadIds(points.size());
|
List<Long> roadIds = getRoadIds(points.size());
|
||||||
List<String> appModeKeys = getAppModeKeys(points.size());
|
List<String> appModeKeys = getAppModeKeys(points.size());
|
||||||
|
@ -90,7 +90,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage {
|
||||||
return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys);
|
return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateImpassableRoadInfo(AvoidSpecificRoads.AvoidRoadInfo avoidRoadInfo) {
|
public boolean updateImpassableRoadInfo(AvoidRoadInfo avoidRoadInfo) {
|
||||||
List<LatLon> points = getPoints();
|
List<LatLon> points = getPoints();
|
||||||
|
|
||||||
int index = points.indexOf(new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude));
|
int index = points.indexOf(new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude));
|
||||||
|
@ -172,7 +172,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage {
|
||||||
stringBuilder.append(",");
|
stringBuilder.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getSettingsAPI().edit(getOsmandSettings().globalPreferences)
|
return getSettingsAPI().edit(getOsmandSettings().getGlobalPreferences())
|
||||||
.putString(roadsIdsKey, stringBuilder.toString())
|
.putString(roadsIdsKey, stringBuilder.toString())
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage {
|
||||||
stringBuilder.append(",");
|
stringBuilder.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getSettingsAPI().edit(getOsmandSettings().globalPreferences)
|
return getSettingsAPI().edit(getOsmandSettings().getGlobalPreferences())
|
||||||
.putString(appModeKey, stringBuilder.toString())
|
.putString(appModeKey, stringBuilder.toString())
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package net.osmand.plus.settings.backend;
|
package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
class IntPreference extends CommonPreference<Integer> {
|
public class IntPreference extends CommonPreference<Integer> {
|
||||||
|
|
||||||
IntPreference(OsmandSettings osmandSettings, String id, int defaultValue) {
|
IntPreference(OsmandSettings settings, String id, int defaultValue) {
|
||||||
super(osmandSettings, id, defaultValue);
|
super(settings, id, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getValue(Object prefs, Integer defaultValue) {
|
protected Integer getValue(Object prefs, Integer defaultValue) {
|
||||||
return getSettingsAPI().getInt(prefs, getId(), defaultValue);
|
return getSettingsAPI().getInt(prefs, getId(), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,20 +53,18 @@ public class ListStringPreference extends StringPreference {
|
||||||
public boolean removeValueForProfile(ApplicationMode appMode, String res) {
|
public boolean removeValueForProfile(ApplicationMode appMode, String res) {
|
||||||
String vl = getModeValue(appMode);
|
String vl = getModeValue(appMode);
|
||||||
String r = res + delimiter;
|
String r = res + delimiter;
|
||||||
if(vl != null) {
|
if (vl != null) {
|
||||||
if(vl.startsWith(r)) {
|
if (vl.startsWith(r)) {
|
||||||
vl = vl.substring(r.length());
|
vl = vl.substring(r.length());
|
||||||
setModeValue(appMode, vl);
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
int it = vl.indexOf(delimiter + r);
|
int it = vl.indexOf(delimiter + r);
|
||||||
if(it >= 0) {
|
if (it >= 0) {
|
||||||
vl = vl.substring(0, it + delimiter.length()) + vl.substring(it + delimiter.length() + r.length());
|
vl = vl.substring(0, it + delimiter.length()) + vl.substring(it + delimiter.length() + r.length());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setModeValue(appMode, vl);
|
setModeValue(appMode, vl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +79,9 @@ public class ListStringPreference extends StringPreference {
|
||||||
return Arrays.asList(listAsString.split(delimiter));
|
return Arrays.asList(listAsString.split(delimiter));
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<String>() {
|
return new ArrayList<String>() {
|
||||||
{add(listAsString);}
|
{
|
||||||
|
add(listAsString);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class ListStringPreference extends StringPreference {
|
||||||
|
|
||||||
public boolean setModeValues(ApplicationMode mode, List<String> values) {
|
public boolean setModeValues(ApplicationMode mode, List<String> values) {
|
||||||
if (values == null || values.size() == 0) {
|
if (values == null || values.size() == 0) {
|
||||||
setModeValue(mode,null);
|
setModeValue(mode, null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
clearAll();
|
clearAll();
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package net.osmand.plus.settings.backend;
|
package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
class LongPreference extends CommonPreference<Long> {
|
public class LongPreference extends CommonPreference<Long> {
|
||||||
|
|
||||||
LongPreference(OsmandSettings osmandSettings, String id, long defaultValue) {
|
LongPreference(OsmandSettings settings, String id, long defaultValue) {
|
||||||
super(osmandSettings, id, defaultValue);
|
super(settings, id, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getValue(Object prefs, Long defaultValue) {
|
protected Long getValue(Object prefs, Long defaultValue) {
|
||||||
return getSettingsAPI().getLong(prefs, getId(), defaultValue);
|
return getSettingsAPI().getLong(prefs, getId(), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package net.osmand.plus.settings.backend;
|
package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -7,10 +9,10 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
public class MainContextMenuItemsSettings extends ContextMenuItemsSettings {
|
public class MainContextMenuItemsSettings extends ContextMenuItemsSettings {
|
||||||
|
|
||||||
private static final String MAIN = "main";
|
private static final String MAIN = "main";
|
||||||
|
|
||||||
private List<String> mainIds = new ArrayList<>();
|
private List<String> mainIds = new ArrayList<>();
|
||||||
|
|
||||||
public MainContextMenuItemsSettings() {
|
public MainContextMenuItemsSettings() {
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package net.osmand.plus.settings.backend;
|
package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.preference.PreferenceDataStore;
|
import androidx.preference.PreferenceDataStore;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class OsmAndPreferencesDataStore extends PreferenceDataStore {
|
public class OsmAndPreferencesDataStore extends PreferenceDataStore {
|
||||||
|
|
||||||
private OsmandSettings osmandSettings;
|
private OsmandSettings osmandSettings;
|
||||||
private ApplicationMode appMode;
|
private ApplicationMode appMode;
|
||||||
|
|
||||||
public OsmAndPreferencesDataStore(OsmandSettings osmandSettings, @NonNull ApplicationMode appMode) {
|
public OsmAndPreferencesDataStore(OsmandSettings settings, @NonNull ApplicationMode appMode) {
|
||||||
this.osmandSettings = osmandSettings;
|
this.osmandSettings = settings;
|
||||||
this.appMode = appMode;
|
this.appMode = appMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode;
|
||||||
import net.osmand.plus.render.RendererRegistry;
|
import net.osmand.plus.render.RendererRegistry;
|
||||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||||
import net.osmand.plus.srtmplugin.TerrainMode;
|
import net.osmand.plus.srtmplugin.TerrainMode;
|
||||||
import net.osmand.plus.views.layers.RulerMode;
|
import net.osmand.plus.views.layers.RulerControlLayer.RulerMode;
|
||||||
import net.osmand.plus.voice.CommandPlayer;
|
import net.osmand.plus.voice.CommandPlayer;
|
||||||
import net.osmand.plus.wikipedia.WikiArticleShowImages;
|
import net.osmand.plus.wikipedia.WikiArticleShowImages;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
@ -102,36 +102,35 @@ public class OsmandSettings {
|
||||||
/// Settings variables
|
/// Settings variables
|
||||||
private final OsmandApplication ctx;
|
private final OsmandApplication ctx;
|
||||||
private SettingsAPI settingsAPI;
|
private SettingsAPI settingsAPI;
|
||||||
Object globalPreferences;
|
private Object globalPreferences;
|
||||||
Object profilePreferences;
|
private Object profilePreferences;
|
||||||
ApplicationMode currentMode;
|
private ApplicationMode currentMode;
|
||||||
Map<String, OsmandPreference<?>> registeredPreferences =
|
private Map<String, OsmandPreference<?>> registeredPreferences = new LinkedHashMap<>();
|
||||||
new LinkedHashMap<String, OsmandPreference<?>>();
|
|
||||||
|
|
||||||
|
|
||||||
// cache variables
|
// cache variables
|
||||||
private long lastTimeInternetConnectionChecked = 0;
|
private long lastTimeInternetConnectionChecked = 0;
|
||||||
private boolean internetConnectionAvailable = true;
|
private boolean internetConnectionAvailable = true;
|
||||||
|
|
||||||
// TODO variable
|
// TODO variable
|
||||||
Map<String, CommonPreference<Boolean>> customBooleanRendersProps = new LinkedHashMap<String, CommonPreference<Boolean>>();
|
private Map<String, CommonPreference<String>> customRoutingProps = new LinkedHashMap<String, CommonPreference<String>>();
|
||||||
Map<String, CommonPreference<String>> customRoutingProps = new LinkedHashMap<String, CommonPreference<String>>();
|
private Map<String, CommonPreference<String>> customRendersProps = new LinkedHashMap<String, CommonPreference<String>>();
|
||||||
Map<String, CommonPreference<Boolean>> customBooleanRoutingProps = new LinkedHashMap<String, CommonPreference<Boolean>>();
|
private Map<String, CommonPreference<Boolean>> customBooleanRoutingProps = new LinkedHashMap<String, CommonPreference<Boolean>>();
|
||||||
Map<String, CommonPreference<String>> customRendersProps = new LinkedHashMap<String, CommonPreference<String>>();
|
private Map<String, CommonPreference<Boolean>> customBooleanRendersProps = new LinkedHashMap<String, CommonPreference<Boolean>>();
|
||||||
|
|
||||||
|
private ImpassableRoadsStorage impassableRoadsStorage = new ImpassableRoadsStorage(this);
|
||||||
private IntermediatePointsStorage intermediatePointsStorage = new IntermediatePointsStorage(this);
|
private IntermediatePointsStorage intermediatePointsStorage = new IntermediatePointsStorage(this);
|
||||||
private ImpassableRoadsStorage mImpassableRoadsStorage = new ImpassableRoadsStorage(this);
|
|
||||||
|
|
||||||
private Object objectToShow;
|
private Object objectToShow;
|
||||||
private boolean editObjectToShow;
|
private boolean editObjectToShow;
|
||||||
private String searchRequestToShow;
|
private String searchRequestToShow;
|
||||||
|
|
||||||
public OsmandSettings(OsmandApplication clientContext, SettingsAPI settinsAPI) {
|
protected OsmandSettings(OsmandApplication clientContext, SettingsAPI settinsAPI) {
|
||||||
ctx = clientContext;
|
ctx = clientContext;
|
||||||
this.settingsAPI = settinsAPI;
|
this.settingsAPI = settinsAPI;
|
||||||
initPrefs();
|
initPrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandSettings(OsmandApplication clientContext, SettingsAPI settinsAPI, String sharedPreferencesName) {
|
protected OsmandSettings(OsmandApplication clientContext, SettingsAPI settinsAPI, String sharedPreferencesName) {
|
||||||
ctx = clientContext;
|
ctx = clientContext;
|
||||||
this.settingsAPI = settinsAPI;
|
this.settingsAPI = settinsAPI;
|
||||||
CUSTOM_SHARED_PREFERENCES_NAME = CUSTOM_SHARED_PREFERENCES_PREFIX + sharedPreferencesName;
|
CUSTOM_SHARED_PREFERENCES_NAME = CUSTOM_SHARED_PREFERENCES_PREFIX + sharedPreferencesName;
|
||||||
|
@ -203,8 +202,6 @@ public class OsmandSettings {
|
||||||
return globalPreferences != null && globalPreferences.getBoolean(SETTING_CUSTOMIZED_ID, false);
|
return globalPreferences != null && globalPreferences.getBoolean(SETTING_CUSTOMIZED_ID, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO doesn't look correct package visibility
|
// TODO doesn't look correct package visibility
|
||||||
public Object getProfilePreferences(ApplicationMode mode) {
|
public Object getProfilePreferences(ApplicationMode mode) {
|
||||||
return settingsAPI.getPreferenceObject(getSharedPreferencesName(mode));
|
return settingsAPI.getPreferenceObject(getSharedPreferencesName(mode));
|
||||||
|
@ -638,6 +635,7 @@ public class OsmandSettings {
|
||||||
registeredPreferences.put(id, p);
|
registeredPreferences.put(id, p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////// PREFERENCES ////////////////
|
///////////////////// PREFERENCES ////////////////
|
||||||
|
|
||||||
public static final String NUMBER_OF_FREE_DOWNLOADS_ID = "free_downloads_v3";
|
public static final String NUMBER_OF_FREE_DOWNLOADS_ID = "free_downloads_v3";
|
||||||
|
@ -740,13 +738,13 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<ApplicationMode> DEFAULT_APPLICATION_MODE = new CommonPreference<ApplicationMode>(this, "default_application_mode_string", ApplicationMode.DEFAULT) {
|
public final OsmandPreference<ApplicationMode> DEFAULT_APPLICATION_MODE = new CommonPreference<ApplicationMode>(this, "default_application_mode_string", ApplicationMode.DEFAULT) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationMode getValue(Object prefs, ApplicationMode defaultValue) {
|
protected ApplicationMode getValue(Object prefs, ApplicationMode defaultValue) {
|
||||||
String key = settingsAPI.getString(prefs, getId(), defaultValue.getStringKey());
|
String key = settingsAPI.getString(prefs, getId(), defaultValue.getStringKey());
|
||||||
return ApplicationMode.valueOfStringKey(key, defaultValue);
|
return ApplicationMode.valueOfStringKey(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setValue(Object prefs, ApplicationMode val) {
|
protected boolean setValue(Object prefs, ApplicationMode val) {
|
||||||
boolean valueSaved = settingsAPI.edit(prefs).putString(getId(), val.getStringKey()).commit();
|
boolean valueSaved = settingsAPI.edit(prefs).putString(getId(), val.getStringKey()).commit();
|
||||||
if (valueSaved) {
|
if (valueSaved) {
|
||||||
APPLICATION_MODE.set(val);
|
APPLICATION_MODE.set(val);
|
||||||
|
@ -786,13 +784,13 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<ApplicationMode> LAST_ROUTE_APPLICATION_MODE = new CommonPreference<ApplicationMode>(this, "last_route_application_mode_backup_string", ApplicationMode.DEFAULT) {
|
public final OsmandPreference<ApplicationMode> LAST_ROUTE_APPLICATION_MODE = new CommonPreference<ApplicationMode>(this, "last_route_application_mode_backup_string", ApplicationMode.DEFAULT) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationMode getValue(Object prefs, ApplicationMode defaultValue) {
|
protected ApplicationMode getValue(Object prefs, ApplicationMode defaultValue) {
|
||||||
String key = settingsAPI.getString(prefs, getId(), defaultValue.getStringKey());
|
String key = settingsAPI.getString(prefs, getId(), defaultValue.getStringKey());
|
||||||
return ApplicationMode.valueOfStringKey(key, defaultValue);
|
return ApplicationMode.valueOfStringKey(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setValue(Object prefs, ApplicationMode val) {
|
protected boolean setValue(Object prefs, ApplicationMode val) {
|
||||||
return settingsAPI.edit(prefs).putString(getId(), val.getStringKey()).commit();
|
return settingsAPI.edit(prefs).putString(getId(), val.getStringKey()).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,8 +822,7 @@ public class OsmandSettings {
|
||||||
}
|
}
|
||||||
}.makeGlobal();
|
}.makeGlobal();
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> FIRST_MAP_IS_DOWNLOADED = new BooleanPreference(this,
|
public final OsmandPreference<Boolean> FIRST_MAP_IS_DOWNLOADED = new BooleanPreference(this, "first_map_is_downloaded", false);
|
||||||
"first_map_is_downloaded", false);
|
|
||||||
|
|
||||||
public final CommonPreference<Boolean> DRIVING_REGION_AUTOMATIC = new BooleanPreference(this, "driving_region_automatic", true).makeProfile().cache();
|
public final CommonPreference<Boolean> DRIVING_REGION_AUTOMATIC = new BooleanPreference(this, "driving_region_automatic", true).makeProfile().cache();
|
||||||
public final OsmandPreference<DrivingRegion> DRIVING_REGION = new EnumStringPreference<DrivingRegion>(this,
|
public final OsmandPreference<DrivingRegion> DRIVING_REGION = new EnumStringPreference<DrivingRegion>(this,
|
||||||
|
@ -960,7 +957,8 @@ public class OsmandSettings {
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.SKI, "ic_action_skiing");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.SKI, "ic_action_skiing");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CommonPreference<ProfileIconColors> ICON_COLOR = new EnumStringPreference<>(this, "app_mode_icon_color", ProfileIconColors.DEFAULT, ProfileIconColors.values()).makeProfile().cache();
|
public final CommonPreference<ProfileIconColors> ICON_COLOR = new EnumStringPreference<>(this,
|
||||||
|
"app_mode_icon_color", ProfileIconColors.DEFAULT, ProfileIconColors.values()).makeProfile().cache();
|
||||||
|
|
||||||
public final CommonPreference<String> USER_PROFILE_NAME = new StringPreference(this, "user_profile_name", "").makeProfile().cache();
|
public final CommonPreference<String> USER_PROFILE_NAME = new StringPreference(this, "user_profile_name", "").makeProfile().cache();
|
||||||
|
|
||||||
|
@ -2291,27 +2289,27 @@ public class OsmandSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AvoidRoadInfo> getImpassableRoadPoints() {
|
public List<AvoidRoadInfo> getImpassableRoadPoints() {
|
||||||
return mImpassableRoadsStorage.getImpassableRoadsInfo();
|
return impassableRoadsStorage.getImpassableRoadsInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addImpassableRoad(AvoidRoadInfo avoidRoadInfo) {
|
public boolean addImpassableRoad(AvoidRoadInfo avoidRoadInfo) {
|
||||||
return mImpassableRoadsStorage.addImpassableRoadInfo(avoidRoadInfo);
|
return impassableRoadsStorage.addImpassableRoadInfo(avoidRoadInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateImpassableRoadInfo(AvoidRoadInfo avoidRoadInfo) {
|
public boolean updateImpassableRoadInfo(AvoidRoadInfo avoidRoadInfo) {
|
||||||
return mImpassableRoadsStorage.updateImpassableRoadInfo(avoidRoadInfo);
|
return impassableRoadsStorage.updateImpassableRoadInfo(avoidRoadInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeImpassableRoad(int index) {
|
public boolean removeImpassableRoad(int index) {
|
||||||
return mImpassableRoadsStorage.deletePoint(index);
|
return impassableRoadsStorage.deletePoint(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeImpassableRoad(LatLon latLon) {
|
public boolean removeImpassableRoad(LatLon latLon) {
|
||||||
return mImpassableRoadsStorage.deletePoint(latLon);
|
return impassableRoadsStorage.deletePoint(latLon);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean moveImpassableRoad(LatLon latLonEx, LatLon latLonNew) {
|
public boolean moveImpassableRoad(LatLon latLonEx, LatLon latLonNew) {
|
||||||
return mImpassableRoadsStorage.movePoint(latLonEx, latLonNew);
|
return impassableRoadsStorage.movePoint(latLonEx, latLonNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2784,53 +2782,4 @@ public class OsmandSettings {
|
||||||
setPreference(QUICK_ACTION.getId(), actionState, mode);
|
setPreference(QUICK_ACTION.getId(), actionState, mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getAppModeBeanPrefsIds() {
|
|
||||||
return new String[]{
|
|
||||||
ICON_COLOR.getId(),
|
|
||||||
ICON_RES_NAME.getId(),
|
|
||||||
PARENT_APP_MODE.getId(),
|
|
||||||
ROUTING_PROFILE.getId(),
|
|
||||||
ROUTE_SERVICE.getId(),
|
|
||||||
USER_PROFILE_NAME.getId(),
|
|
||||||
LOCATION_ICON.getId(),
|
|
||||||
NAVIGATION_ICON.getId(),
|
|
||||||
APP_MODE_ORDER.getId()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public OsmandPreference<?>[] getGeneralPrefs() {
|
|
||||||
return new OsmandPreference[]{
|
|
||||||
EXTERNAL_INPUT_DEVICE,
|
|
||||||
CENTER_POSITION_ON_MAP,
|
|
||||||
ROTATE_MAP,
|
|
||||||
MAP_SCREEN_ORIENTATION,
|
|
||||||
LIVE_MONITORING_URL,
|
|
||||||
LIVE_MONITORING_MAX_INTERVAL_TO_SEND,
|
|
||||||
LIVE_MONITORING_INTERVAL,
|
|
||||||
LIVE_MONITORING,
|
|
||||||
SHOW_TRIP_REC_NOTIFICATION,
|
|
||||||
AUTO_SPLIT_RECORDING,
|
|
||||||
SAVE_TRACK_MIN_SPEED,
|
|
||||||
SAVE_TRACK_PRECISION,
|
|
||||||
SAVE_TRACK_MIN_DISTANCE,
|
|
||||||
SAVE_TRACK_INTERVAL,
|
|
||||||
TRACK_STORAGE_DIRECTORY,
|
|
||||||
SAVE_HEADING_TO_GPX,
|
|
||||||
DISABLE_RECORDING_ONCE_APP_KILLED,
|
|
||||||
SAVE_TRACK_TO_GPX,
|
|
||||||
SAVE_GLOBAL_TRACK_REMEMBER,
|
|
||||||
SAVE_GLOBAL_TRACK_INTERVAL,
|
|
||||||
MAP_EMPTY_STATE_ALLOWED,
|
|
||||||
DO_NOT_USE_ANIMATIONS,
|
|
||||||
USE_KALMAN_FILTER_FOR_COMPASS,
|
|
||||||
USE_MAGNETIC_FIELD_SENSOR_COMPASS,
|
|
||||||
USE_TRACKBALL_FOR_MOVEMENTS,
|
|
||||||
SPEED_SYSTEM,
|
|
||||||
ANGULAR_UNITS,
|
|
||||||
METRIC_SYSTEM,
|
|
||||||
DRIVING_REGION,
|
|
||||||
DRIVING_REGION_AUTOMATIC
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -20,8 +20,6 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||||
import net.osmand.map.WorldRegion;
|
import net.osmand.map.WorldRegion;
|
||||||
import net.osmand.osm.MapPoiTypes;
|
import net.osmand.osm.MapPoiTypes;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBuilder;
|
|
||||||
import net.osmand.plus.CustomOsmandPlugin;
|
import net.osmand.plus.CustomOsmandPlugin;
|
||||||
import net.osmand.plus.CustomOsmandPlugin.SuggestedDownloadItem;
|
import net.osmand.plus.CustomOsmandPlugin.SuggestedDownloadItem;
|
||||||
import net.osmand.plus.CustomRegion;
|
import net.osmand.plus.CustomRegion;
|
||||||
|
@ -34,6 +32,8 @@ import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBuilder;
|
||||||
import net.osmand.router.GeneralRouter;
|
import net.osmand.router.GeneralRouter;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -918,7 +918,6 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class ProfileSettingsItem extends OsmandSettingsItem {
|
public static class ProfileSettingsItem extends OsmandSettingsItem {
|
||||||
|
|
||||||
private ApplicationMode appMode;
|
private ApplicationMode appMode;
|
||||||
|
@ -947,7 +946,7 @@ public class SettingsHelper {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
appModeBeanPrefsIds = new HashSet<>(Arrays.asList(app.getSettings().getAppModeBeanPrefsIds()));
|
appModeBeanPrefsIds = new HashSet<>(Arrays.asList(getAppModeBeanPrefsIds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -1188,6 +1187,21 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String[] getAppModeBeanPrefsIds() {
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
|
return new String[] {
|
||||||
|
settings.ICON_COLOR.getId(),
|
||||||
|
settings.ICON_RES_NAME.getId(),
|
||||||
|
settings.PARENT_APP_MODE.getId(),
|
||||||
|
settings.ROUTING_PROFILE.getId(),
|
||||||
|
settings.ROUTE_SERVICE.getId(),
|
||||||
|
settings.USER_PROFILE_NAME.getId(),
|
||||||
|
settings.LOCATION_ICON.getId(),
|
||||||
|
settings.NAVIGATION_ICON.getId(),
|
||||||
|
settings.APP_MODE_ORDER.getId()
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class StreamSettingsItemReader extends SettingsItemReader<StreamSettingsItem> {
|
public abstract static class StreamSettingsItemReader extends SettingsItemReader<StreamSettingsItem> {
|
||||||
|
|
|
@ -30,7 +30,7 @@ abstract class SettingsMapPointsStorage {
|
||||||
|
|
||||||
public List<String> getPointDescriptions(int sz) {
|
public List<String> getPointDescriptions(int sz) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
String ip = getSettingsAPI().getString(osmandSettings.globalPreferences, descriptionsKey, "");
|
String ip = getSettingsAPI().getString(osmandSettings.getGlobalPreferences(), descriptionsKey, "");
|
||||||
if (ip.trim().length() > 0) {
|
if (ip.trim().length() > 0) {
|
||||||
list.addAll(Arrays.asList(ip.split("--")));
|
list.addAll(Arrays.asList(ip.split("--")));
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ abstract class SettingsMapPointsStorage {
|
||||||
|
|
||||||
public List<LatLon> getPoints() {
|
public List<LatLon> getPoints() {
|
||||||
List<LatLon> list = new ArrayList<>();
|
List<LatLon> list = new ArrayList<>();
|
||||||
String ip = getSettingsAPI().getString(osmandSettings.globalPreferences, pointsKey, "");
|
String ip = getSettingsAPI().getString(osmandSettings.getGlobalPreferences(), pointsKey, "");
|
||||||
if (ip.trim().length() > 0) {
|
if (ip.trim().length() > 0) {
|
||||||
StringTokenizer tok = new StringTokenizer(ip, ",");
|
StringTokenizer tok = new StringTokenizer(ip, ",");
|
||||||
while (tok.hasMoreTokens()) {
|
while (tok.hasMoreTokens()) {
|
||||||
|
@ -130,7 +130,7 @@ abstract class SettingsMapPointsStorage {
|
||||||
tb.append(ds.get(i));
|
tb.append(ds.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getSettingsAPI().edit(osmandSettings.globalPreferences)
|
return getSettingsAPI().edit(osmandSettings.getGlobalPreferences())
|
||||||
.putString(pointsKey, sb.toString())
|
.putString(pointsKey, sb.toString())
|
||||||
.putString(descriptionsKey, tb.toString())
|
.putString(descriptionsKey, tb.toString())
|
||||||
.commit();
|
.commit();
|
||||||
|
|
|
@ -2,12 +2,12 @@ package net.osmand.plus.settings.backend;
|
||||||
|
|
||||||
public class StringPreference extends CommonPreference<String> {
|
public class StringPreference extends CommonPreference<String> {
|
||||||
|
|
||||||
StringPreference(OsmandSettings osmandSettings, String id, String defaultValue) {
|
StringPreference(OsmandSettings settings, String id, String defaultValue) {
|
||||||
super(osmandSettings, id, defaultValue);
|
super(settings, id, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue(Object prefs, String defaultValue) {
|
protected String getValue(Object prefs, String defaultValue) {
|
||||||
return getSettingsAPI().getString(prefs, getId(), defaultValue);
|
return getSettingsAPI().getString(prefs, getId(), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -822,4 +822,10 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
public boolean drawInScreenPixels() {
|
public boolean drawInScreenPixels() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum RulerMode {
|
||||||
|
FIRST,
|
||||||
|
SECOND,
|
||||||
|
EMPTY
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
package net.osmand.plus.views.layers;
|
|
||||||
|
|
||||||
public enum RulerMode {
|
|
||||||
FIRST,
|
|
||||||
SECOND,
|
|
||||||
EMPTY
|
|
||||||
}
|
|
|
@ -49,7 +49,6 @@ import net.osmand.plus.OsmAndLocationProvider;
|
||||||
import net.osmand.plus.OsmAndLocationProvider.GPSInfo;
|
import net.osmand.plus.OsmAndLocationProvider.GPSInfo;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.views.layers.RulerMode;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -68,6 +67,7 @@ import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.layers.RulerControlLayer;
|
import net.osmand.plus.views.layers.RulerControlLayer;
|
||||||
|
import net.osmand.plus.views.layers.RulerControlLayer.RulerMode;
|
||||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||||
import net.osmand.render.RenderingRuleSearchRequest;
|
import net.osmand.render.RenderingRuleSearchRequest;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
|
Loading…
Reference in a new issue