use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class MapSourceAction method executeWithParams.
@Override
public void executeWithParams(@NonNull MapActivity mapActivity, String params) {
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
if (params.equals(LAYER_OSM_VECTOR)) {
settings.MAP_ONLINE_DATA.set(false);
mapActivity.getMapLayers().updateMapSource(mapActivity.getMapView(), null);
} else {
settings.MAP_TILE_SOURCES.set(params);
settings.MAP_ONLINE_DATA.set(true);
mapActivity.getMapLayers().updateMapSource(mapActivity.getMapView(), settings.MAP_TILE_SOURCES);
}
Toast.makeText(mapActivity, mapActivity.getString(R.string.quick_action_map_source_switch, getTranslatedItemName(mapActivity, params)), Toast.LENGTH_SHORT).show();
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class MapRouteInfoMenu method createSimpleRoutingParameterButton.
private void createSimpleRoutingParameterButton(MapActivity mapActivity, final LocalRoutingParameter parameter, LinearLayout optionsContainer) {
OsmandApplication app = mapActivity.getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper();
final int colorActive = ContextCompat.getColor(app, ColorUtilities.getActiveColorId(nightMode));
final int colorDisabled = ContextCompat.getColor(app, R.color.description_font_and_bottom_sheet_icons);
int margin = AndroidUtils.dpToPx(app, 3);
final OsmandSettings settings = app.getSettings();
String text;
boolean active;
if (parameter.routingParameter != null) {
if (parameter.routingParameter.getId().equals(GeneralRouter.USE_SHORTEST_WAY)) {
// if short route settings - it should be inverse of fast_route_mode
active = !settings.FAST_ROUTE_MODE.getModeValue(routingHelper.getAppMode());
} else {
active = parameter.isSelected(settings);
}
text = parameter.getText(mapActivity);
View item = createToolbarOptionView(active, text, parameter.getActiveIconId(), parameter.getDisabledIconId(), v -> {
OsmandApplication app1 = getApp();
if (parameter.routingParameter != null && app1 != null) {
boolean selected = !parameter.isSelected(settings);
app1.getRoutingOptionsHelper().applyRoutingParameter(parameter, selected);
Drawable itemDrawable = app1.getUIUtilities().getIcon(selected ? parameter.getActiveIconId() : parameter.getDisabledIconId(), nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
Drawable activeItemDrawable = app1.getUIUtilities().getIcon(selected ? parameter.getActiveIconId() : parameter.getDisabledIconId(), ColorUtilities.getActiveColorId(nightMode));
if (Build.VERSION.SDK_INT >= 21) {
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
}
((ImageView) v.findViewById(R.id.route_option_image_view)).setImageDrawable(selected ? activeItemDrawable : itemDrawable);
((TextView) v.findViewById(R.id.route_option_title)).setTextColor(selected ? colorActive : colorDisabled);
}
});
if (item != null) {
LinearLayout.LayoutParams layoutParams = getContainerButtonLayoutParams(mapActivity, false);
AndroidUtils.setMargins(layoutParams, margin, 0, margin, 0);
optionsContainer.addView(item, layoutParams);
}
}
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class MapRouteInfoMenu method createAvoidParametersItems.
private void createAvoidParametersItems(MapActivity mapActivity, final List<RoutingParameter> avoidedParameters, final LocalRoutingParameter parameter, final RouteMenuAppModes mode, final LinearLayout item) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
for (int i = 0; i < avoidedParameters.size(); i++) {
final RoutingParameter routingParameter = avoidedParameters.get(i);
final View container = createToolbarSubOptionView(false, AndroidUtils.getRoutingStringPropertyName(app, routingParameter.getId(), routingParameter.getName()), R.drawable.ic_action_remove_dark, i == avoidedParameters.size() - 1, v -> {
OsmandApplication app = getApp();
if (app == null) {
return;
}
CommonPreference<Boolean> preference = settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
preference.setModeValue(app.getRoutingHelper().getAppMode(), false);
avoidedParameters.remove(routingParameter);
app.getRoutingHelper().onSettingsChanged(true);
if (app.getAvoidSpecificRoads().getImpassableRoads().isEmpty() && avoidedParameters.isEmpty()) {
mode.parameters.remove(parameter);
}
if (mode.parameters.size() > 2) {
item.removeView(v);
} else {
updateOptionsButtons();
}
});
if (container != null) {
item.addView(container, getContainerButtonLayoutParams(mapActivity, false));
}
}
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class RouteDetailsFragment method showDirectionsInfo.
private void showDirectionsInfo(int directionInfoIndex) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
RoutingHelper helper = mapActivity.getRoutingHelper();
List<RouteDirectionInfo> routeDirections = helper.getRouteDirections();
if (routeDirections.size() > directionInfoIndex) {
RouteDirectionInfo routeDirectionInfo = routeDirections.get(directionInfoIndex);
Location loc = helper.getLocationFromRouteDirection(routeDirectionInfo);
if (loc != null) {
MapRouteInfoMenu.directionInfo = directionInfoIndex;
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
settings.setMapLocationToShow(loc.getLatitude(), loc.getLongitude(), Math.max(13, settings.getLastKnownMapZoom()), new PointDescription(PointDescription.POINT_TYPE_MARKER, routeDirectionInfo.getDescriptionRoutePart() + " " + getTimeDescription(mapActivity.getMyApplication(), routeDirectionInfo)), false, null);
MapActivity.launchMapActivityMoveToTop(mapActivity);
dismiss();
}
}
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class RoutingOptionsHelper method getOsmandRouterParameters.
public List<LocalRoutingParameter> getOsmandRouterParameters(ApplicationMode am) {
OsmandSettings settings = app.getSettings();
List<LocalRoutingParameter> list = new ArrayList<LocalRoutingParameter>();
boolean osmandRouter = am.getRouteService() == RouteService.OSMAND;
if (!osmandRouter) {
list.add(new OtherLocalRoutingParameter(R.string.calculate_osmand_route_without_internet, app.getString(R.string.calculate_osmand_route_without_internet), settings.GPX_ROUTE_CALC_OSMAND_PARTS.get()));
list.add(new OtherLocalRoutingParameter(R.string.fast_route_mode, app.getString(R.string.fast_route_mode), settings.FAST_ROUTE_MODE.get()));
}
return list;
}
Aggregations