Search in sources :

Example 11 with SwitchPreferenceEx

use of net.osmand.plus.settings.preferences.SwitchPreferenceEx in project Osmand by osmandapp.

the class DevelopmentSettingsFragment method setupShouldShowFreeVersionBannerPref.

private void setupShouldShowFreeVersionBannerPref() {
    SwitchPreferenceEx shouldShowFreeVersionBanner = findPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER.getId());
    shouldShowFreeVersionBanner.setDescription(getString(R.string.show_free_version_banner_description));
    shouldShowFreeVersionBanner.setIconSpaceReserved(false);
}
Also used : SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Example 12 with SwitchPreferenceEx

use of net.osmand.plus.settings.preferences.SwitchPreferenceEx in project Osmand by osmandapp.

the class AccessibilitySettingsFragment method setupDirectionHapticFeedbackPref.

private void setupDirectionHapticFeedbackPref() {
    SwitchPreferenceEx directionHapticFeedback = (SwitchPreferenceEx) findPreference(settings.DIRECTION_HAPTIC_FEEDBACK.getId());
    directionHapticFeedback.setDescription(getString(R.string.access_direction_haptic_feedback_descr));
}
Also used : SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Example 13 with SwitchPreferenceEx

use of net.osmand.plus.settings.preferences.SwitchPreferenceEx in project Osmand by osmandapp.

the class AccessibilitySettingsFragment method setupSmartAutoAnnouncePref.

private void setupSmartAutoAnnouncePref() {
    SwitchPreferenceEx smartAutoAnnounce = (SwitchPreferenceEx) findPreference(settings.ACCESSIBILITY_SMART_AUTOANNOUNCE.getId());
    smartAutoAnnounce.setDescription(getString(R.string.access_smart_autoannounce_descr));
}
Also used : SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Example 14 with SwitchPreferenceEx

use of net.osmand.plus.settings.preferences.SwitchPreferenceEx in project Osmand by osmandapp.

the class RouteParametersFragment method setupRoutingPrefs.

private void setupRoutingPrefs() {
    OsmandApplication app = getMyApplication();
    if (app == null) {
        return;
    }
    PreferenceScreen screen = getPreferenceScreen();
    ApplicationMode am = getSelectedAppMode();
    SwitchPreferenceEx fastRoute = createSwitchPreferenceEx(app.getSettings().FAST_ROUTE_MODE.getId(), R.string.fast_route_mode, R.layout.preference_with_descr_dialog_and_switch);
    fastRoute.setIcon(getRoutingPrefIcon(app.getSettings().FAST_ROUTE_MODE.getId()));
    fastRoute.setDescription(getString(R.string.fast_route_mode_descr));
    fastRoute.setSummaryOn(R.string.shared_string_on);
    fastRoute.setSummaryOff(R.string.shared_string_off);
    if (am.getRouteService() == RouteService.OSMAND) {
        GeneralRouter router = app.getRouter(am);
        clearParameters();
        if (router != null) {
            Map<String, RoutingParameter> parameters = router.getParameters();
            if (!am.isDerivedRoutingFrom(ApplicationMode.CAR)) {
                screen.addPreference(fastRoute);
            }
            for (Map.Entry<String, RoutingParameter> e : parameters.entrySet()) {
                String param = e.getKey();
                RoutingParameter routingParameter = e.getValue();
                if (param.startsWith(AVOID_ROUTING_PARAMETER_PREFIX)) {
                    avoidParameters.add(routingParameter);
                } else if (param.startsWith(PREFER_ROUTING_PARAMETER_PREFIX)) {
                    preferParameters.add(routingParameter);
                } else if (RELIEF_SMOOTHNESS_FACTOR.equals(routingParameter.getGroup())) {
                    reliefFactorParameters.add(routingParameter);
                } else if (DRIVING_STYLE.equals(routingParameter.getGroup())) {
                    drivingStyleParameters.add(routingParameter);
                } else if ((!param.equals(GeneralRouter.USE_SHORTEST_WAY) || am.isDerivedRoutingFrom(ApplicationMode.CAR)) && !param.equals(GeneralRouter.VEHICLE_HEIGHT) && !param.equals(GeneralRouter.VEHICLE_WEIGHT) && !param.equals(GeneralRouter.VEHICLE_WIDTH) && !param.equals(GeneralRouter.VEHICLE_LENGTH)) {
                    otherRoutingParameters.add(routingParameter);
                }
            }
            if (drivingStyleParameters.size() > 0) {
                ListPreferenceEx drivingStyleRouting = createRoutingBooleanListPreference(DRIVING_STYLE, drivingStyleParameters);
                screen.addPreference(drivingStyleRouting);
            }
            if (avoidParameters.size() > 0) {
                String title;
                String description;
                if (am.isDerivedRoutingFrom(ApplicationMode.PUBLIC_TRANSPORT)) {
                    title = getString(R.string.avoid_pt_types);
                    description = getString(R.string.avoid_pt_types_descr);
                } else {
                    title = getString(R.string.impassable_road);
                    description = getString(R.string.avoid_in_routing_descr_);
                }
                MultiSelectBooleanPreference avoidRouting = createRoutingBooleanMultiSelectPref(AVOID_ROUTING_PARAMETER_PREFIX, title, description, avoidParameters);
                screen.addPreference(avoidRouting);
            }
            if (preferParameters.size() > 0) {
                String title = getString(R.string.prefer_in_routing_title);
                MultiSelectBooleanPreference preferRouting = createRoutingBooleanMultiSelectPref(PREFER_ROUTING_PARAMETER_PREFIX, title, "", preferParameters);
                screen.addPreference(preferRouting);
            }
            for (RoutingParameter p : otherRoutingParameters) {
                String title = AndroidUtils.getRoutingStringPropertyName(app, p.getId(), p.getName());
                String description = AndroidUtils.getRoutingStringPropertyDescription(app, p.getId(), p.getDescription());
                if (p.getType() == RoutingParameterType.BOOLEAN) {
                    OsmandPreference pref = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
                    SwitchPreferenceEx switchPreferenceEx = createSwitchPreferenceEx(pref.getId(), title, description, R.layout.preference_with_descr_dialog_and_switch);
                    switchPreferenceEx.setDescription(description);
                    switchPreferenceEx.setIcon(getRoutingPrefIcon(p.getId()));
                    screen.addPreference(switchPreferenceEx);
                    setupOtherBooleanParameterSummary(am, p, switchPreferenceEx);
                } else {
                    Object[] vls = p.getPossibleValues();
                    String[] svlss = new String[vls.length];
                    int i = 0;
                    for (Object o : vls) {
                        svlss[i++] = o.toString();
                    }
                    OsmandPreference pref = settings.getCustomRoutingProperty(p.getId(), p.getType() == RoutingParameterType.NUMERIC ? "0.0" : "-");
                    ListPreferenceEx listPreferenceEx = (ListPreferenceEx) createListPreferenceEx(pref.getId(), p.getPossibleValueDescriptions(), svlss, title, R.layout.preference_with_descr);
                    listPreferenceEx.setDescription(description);
                    listPreferenceEx.setIcon(getRoutingPrefIcon(p.getId()));
                    screen.addPreference(listPreferenceEx);
                }
            }
        }
        setupTimeConditionalRoutingPref();
    } else if (am.getRouteService() == RouteService.BROUTER) {
        screen.addPreference(fastRoute);
        setupTimeConditionalRoutingPref();
    } else if (am.getRouteService() == RouteService.STRAIGHT) {
        Preference straightAngle = new Preference(app.getApplicationContext());
        straightAngle.setPersistent(false);
        straightAngle.setKey(settings.ROUTE_STRAIGHT_ANGLE.getId());
        straightAngle.setTitle(getString(R.string.recalc_angle_dialog_title));
        straightAngle.setSummary(String.format(getString(R.string.shared_string_angle_param), String.valueOf((int) am.getStrAngle())));
        straightAngle.setLayoutResource(R.layout.preference_with_descr);
        // TODO change for appropriate icon when available
        straightAngle.setIcon(getRoutingPrefIcon("routing_recalc_distance"));
        getPreferenceScreen().addPreference(straightAngle);
    }
    addDivider(screen);
    setupRouteRecalcHeader(screen);
    setupSelectRouteRecalcDistance(screen);
    setupReverseDirectionRecalculation(screen);
    if (OsmandPlugin.isActive(OsmandDevelopmentPlugin.class)) {
        setupDevelopmentCategoryPreferences(screen, am);
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) PreferenceScreen(androidx.preference.PreferenceScreen) MultiSelectBooleanPreference(net.osmand.plus.settings.preferences.MultiSelectBooleanPreference) OsmandPreference(net.osmand.plus.settings.backend.preferences.OsmandPreference) GeneralRouter(net.osmand.router.GeneralRouter) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx) RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) MultiSelectBooleanPreference(net.osmand.plus.settings.preferences.MultiSelectBooleanPreference) BooleanPreference(net.osmand.plus.settings.backend.preferences.BooleanPreference) CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference) OsmandPreference(net.osmand.plus.settings.backend.preferences.OsmandPreference) Preference(androidx.preference.Preference) Map(java.util.Map)

Example 15 with SwitchPreferenceEx

use of net.osmand.plus.settings.preferences.SwitchPreferenceEx in project Osmand by osmandapp.

the class RouteParametersFragment method setupOsmLiveForRoutingPref.

private void setupOsmLiveForRoutingPref() {
    SwitchPreferenceEx useOsmLiveForRouting = createSwitchPreferenceEx(settings.USE_OSM_LIVE_FOR_ROUTING.getId(), R.string.use_live_routing, R.layout.preference_with_descr_dialog_and_switch);
    useOsmLiveForRouting.setDescription(getString(R.string.use_osm_live_routing_description));
    useOsmLiveForRouting.setSummaryOn(R.string.shared_string_enabled);
    useOsmLiveForRouting.setSummaryOff(R.string.shared_string_disabled);
    useOsmLiveForRouting.setIcon(getPersistentPrefIcon(R.drawable.ic_action_osm_live));
    useOsmLiveForRouting.setIconSpaceReserved(true);
    getPreferenceScreen().addPreference(useOsmLiveForRouting);
}
Also used : SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Aggregations

SwitchPreferenceEx (net.osmand.plus.settings.preferences.SwitchPreferenceEx)49 Drawable (android.graphics.drawable.Drawable)5 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)5 OsmandApplication (net.osmand.plus.OsmandApplication)3 Context (android.content.Context)2 View (android.view.View)2 Fragment (androidx.fragment.app.Fragment)2 Preference (androidx.preference.Preference)2 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)2 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)2 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)2 BooleanPreference (net.osmand.plus.settings.backend.preferences.BooleanPreference)2 OsmandPreference (net.osmand.plus.settings.backend.preferences.OsmandPreference)2 OnConfirmPreferenceChange (net.osmand.plus.settings.fragments.OnConfirmPreferenceChange)2 ListPreferenceEx (net.osmand.plus.settings.preferences.ListPreferenceEx)2 MultiSelectBooleanPreference (net.osmand.plus.settings.preferences.MultiSelectBooleanPreference)2 TextView (android.widget.TextView)1 FragmentManager (androidx.fragment.app.FragmentManager)1 EditTextPreference (androidx.preference.EditTextPreference)1 PreferenceScreen (androidx.preference.PreferenceScreen)1