Search in sources :

Example 61 with OsmandSettings

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();
}
Also used : OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 62 with OsmandSettings

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);
        }
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) ImageView(android.widget.ImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) TextView(android.widget.TextView) FavouritePoint(net.osmand.data.FavouritePoint) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) LinearLayout(android.widget.LinearLayout)

Example 63 with OsmandSettings

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));
        }
    }
}
Also used : AvoidRoadsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter) OtherLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter) MuteSoundRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) AvoidPTTypesRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter) RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) OsmandApplication(net.osmand.plus.OsmandApplication) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) TextView(android.widget.TextView) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) FavouritePoint(net.osmand.data.FavouritePoint) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)

Example 64 with OsmandSettings

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();
        }
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) RouteDirectionInfo(net.osmand.plus.routing.RouteDirectionInfo) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) RoutingHelper(net.osmand.plus.routing.RoutingHelper) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) MapActivity(net.osmand.plus.activities.MapActivity) Location(net.osmand.Location)

Example 65 with OsmandSettings

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;
}
Also used : ArrayList(java.util.ArrayList) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Aggregations

OsmandSettings (net.osmand.plus.settings.backend.OsmandSettings)154 OsmandApplication (net.osmand.plus.OsmandApplication)52 View (android.view.View)25 ArrayList (java.util.ArrayList)23 LatLon (net.osmand.data.LatLon)17 MapActivity (net.osmand.plus.activities.MapActivity)17 TextView (android.widget.TextView)16 NonNull (androidx.annotation.NonNull)16 AlertDialog (androidx.appcompat.app.AlertDialog)15 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)15 ArrayAdapter (android.widget.ArrayAdapter)13 ContextMenuItem (net.osmand.plus.ContextMenuItem)13 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)12 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)12 Context (android.content.Context)11 ImageView (android.widget.ImageView)11 Intent (android.content.Intent)8 List (java.util.List)8 PointDescription (net.osmand.data.PointDescription)8 DialogInterface (android.content.DialogInterface)7