use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class ProfileSettingsItem method getReader.
@Nullable
@Override
public SettingsItemReader<? extends SettingsItem> getReader() {
return new OsmandSettingsItemReader<ProfileSettingsItem>(this, getSettings()) {
@Override
protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
if (!appModeBeanPrefsIds.contains(preference.getId())) {
preference.readFromJson(json, appMode);
}
}
@Override
public void readPreferencesFromJson(final JSONObject json) {
getSettings().getContext().runInUIThread(() -> {
OsmandSettings settings = getSettings();
Map<String, OsmandPreference<?>> prefs = settings.getRegisteredPreferences();
Iterator<String> iterator = json.keys();
while (iterator.hasNext()) {
String key = iterator.next();
OsmandPreference<?> p = prefs.get(key);
if (p == null) {
if (OsmandSettings.isRoutingPreference(key)) {
p = settings.registerStringPreference(key, "");
}
}
if (p != null) {
try {
readPreferenceFromJson(p, json);
if (OsmandSettings.isRoutingPreference(p.getId())) {
if (p.getId().endsWith(GeneralRouter.USE_SHORTEST_WAY)) {
settings.FAST_ROUTE_MODE.setModeValue(appMode, !settings.getCustomRoutingBooleanProperty(GeneralRouter.USE_SHORTEST_WAY, false).getModeValue(appMode));
}
}
} catch (Exception e) {
SettingsHelper.LOG.error("Failed to read preference: " + key, e);
}
} else {
SettingsHelper.LOG.warn("No preference while importing settings: " + key);
}
}
});
}
};
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class RouteLineAppearanceFragment method saveRouteLineAppearance.
private void saveRouteLineAppearance() {
if (getMyApplication() != null) {
OsmandSettings settings = getMyApplication().getSettings();
settings.CUSTOM_ROUTE_COLOR_DAY.setModeValue(appMode, previewRouteLineInfo.getCustomColor(false));
settings.CUSTOM_ROUTE_COLOR_NIGHT.setModeValue(appMode, previewRouteLineInfo.getCustomColor(true));
settings.ROUTE_COLORING_TYPE.setModeValue(appMode, previewRouteLineInfo.getRouteColoringType());
settings.ROUTE_INFO_ATTRIBUTE.setModeValue(appMode, previewRouteLineInfo.getRouteInfoAttribute());
settings.ROUTE_LINE_WIDTH.setModeValue(appMode, previewRouteLineInfo.getWidth());
settings.ROUTE_SHOW_TURN_ARROWS.setModeValue(appMode, previewRouteLineInfo.shouldShowTurnArrows());
}
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class RouteLineAppearanceFragment method createPreviewRouteLineInfo.
private PreviewRouteLineInfo createPreviewRouteLineInfo() {
OsmandSettings settings = requireSettings();
int colorDay = settings.CUSTOM_ROUTE_COLOR_DAY.getModeValue(appMode);
int colorNight = settings.CUSTOM_ROUTE_COLOR_NIGHT.getModeValue(appMode);
ColoringType coloringType = settings.ROUTE_COLORING_TYPE.getModeValue(appMode);
String routeInfoAttribute = settings.ROUTE_INFO_ATTRIBUTE.getModeValue(appMode);
String widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode);
boolean showTurnArrows = settings.ROUTE_SHOW_TURN_ARROWS.getModeValue(appMode);
PreviewRouteLineInfo previewRouteLineInfo = new PreviewRouteLineInfo(colorDay, colorNight, coloringType, routeInfoAttribute, widthKey, showTurnArrows);
previewRouteLineInfo.setIconId(appMode.getNavigationIcon().getIconId());
previewRouteLineInfo.setIconColor(appMode.getProfileColor(isNightMode()));
return previewRouteLineInfo;
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class TrackDrawInfo method initCurrentTrackParams.
private void initCurrentTrackParams(@NonNull OsmandApplication app) {
OsmandSettings settings = app.getSettings();
width = settings.CURRENT_TRACK_WIDTH.get();
color = settings.CURRENT_TRACK_COLOR.get();
coloringType = settings.CURRENT_TRACK_COLORING_TYPE.get();
routeInfoAttribute = settings.CURRENT_TRACK_ROUTE_INFO_ATTRIBUTE.get();
showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get();
showStartFinish = settings.CURRENT_TRACK_SHOW_START_FINISH.get();
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class MapMarkersLayer method runExclusiveAction.
@Override
public boolean runExclusiveAction(Object o, boolean unknownLocation) {
MapActivity mapActivity = getMapActivity();
OsmandSettings settings = getApplication().getSettings();
if (unknownLocation || mapActivity == null || !(o instanceof MapMarker) || !settings.SELECT_MARKER_ON_SINGLE_TAP.get() || !settings.SHOW_MAP_MARKERS.get()) {
return false;
}
final MapMarkersHelper helper = getApplication().getMapMarkersHelper();
final MapMarker old = helper.getMapMarkers().get(0);
helper.moveMarkerToTop((MapMarker) o);
String title = getContext().getString(R.string.marker_activated, helper.getMapMarkers().get(0).getName(getContext()));
Snackbar.make(mapActivity.findViewById(R.id.bottomFragmentContainer), title, Snackbar.LENGTH_LONG).setAction(R.string.shared_string_cancel, v -> helper.moveMarkerToTop(old)).show();
return true;
}
Aggregations