Search in sources :

Example 21 with SwitchPreferenceEx

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

the class MapDuringNavigationFragment method setupSnapToRoadPref.

private void setupSnapToRoadPref() {
    SwitchPreferenceEx snapToRoad = (SwitchPreferenceEx) findPreference(settings.SNAP_TO_ROAD.getId());
    snapToRoad.setTitle(getString(R.string.snap_to_road));
    snapToRoad.setDescription(getString(R.string.snap_to_road_descr));
}
Also used : SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Example 22 with SwitchPreferenceEx

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

the class RouteParametersFragment method updateRouteRecalcDistancePref.

private void updateRouteRecalcDistancePref() {
    SwitchPreferenceEx switchPref = (SwitchPreferenceEx) findPreference(ROUTING_RECALC_DISTANCE);
    if (switchPref == null) {
        return;
    }
    ApplicationMode appMode = getSelectedAppMode();
    float allowedValue = settings.ROUTE_RECALCULATION_DISTANCE.getModeValue(appMode);
    boolean enabled = allowedValue != DISABLE_MODE;
    if (allowedValue <= 0) {
        allowedValue = RoutingHelper.getDefaultAllowedDeviation(settings, appMode);
    }
    String summary = String.format(getString(R.string.ltr_or_rtl_combine_via_bold_point), enabled ? getString(R.string.shared_string_enabled) : getString(R.string.shared_string_disabled), OsmAndFormatter.getFormattedDistance(allowedValue, app, false));
    switchPref.setSummary(summary);
    switchPref.setChecked(enabled);
}
Also used : ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Example 23 with SwitchPreferenceEx

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

the class RouteParametersFragment method setupDisableComplexRoutingPref.

private void setupDisableComplexRoutingPref() {
    SwitchPreferenceEx disableComplexRouting = createSwitchPreferenceEx(settings.DISABLE_COMPLEX_ROUTING.getId(), R.string.use_two_phase_routing, R.layout.preference_with_descr_dialog_and_switch);
    disableComplexRouting.setDescription(getString(R.string.complex_routing_descr));
    disableComplexRouting.setSummaryOn(R.string.shared_string_enabled);
    disableComplexRouting.setSummaryOff(R.string.shared_string_disabled);
    disableComplexRouting.setIconSpaceReserved(true);
    getPreferenceScreen().addPreference(disableComplexRouting);
}
Also used : SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Example 24 with SwitchPreferenceEx

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

the class RouteParametersFragment method setupReverseDirectionRecalculation.

private void setupReverseDirectionRecalculation(PreferenceScreen screen) {
    OsmandPreference<Boolean> preference = settings.DISABLE_WRONG_DIRECTION_RECALC;
    SwitchPreferenceEx switchPreference = createSwitchPreferenceEx(preference.getId(), R.string.in_case_of_reverse_direction, R.layout.preference_with_descr_dialog_and_switch);
    switchPreference.setIcon(getRoutingPrefIcon(preference.getId()));
    switchPreference.setSummaryOn(R.string.shared_string_enabled);
    switchPreference.setSummaryOff(R.string.shared_string_disabled);
    screen.addPreference(switchPreference);
}
Also used : SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Example 25 with SwitchPreferenceEx

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

the class RouteParametersFragment method setupOsmLiveForPublicTransportPref.

private void setupOsmLiveForPublicTransportPref() {
    SwitchPreferenceEx useOsmLiveForPublicTransport = createSwitchPreferenceEx(settings.USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT.getId(), R.string.use_live_public_transport, R.layout.preference_with_descr_dialog_and_switch);
    useOsmLiveForPublicTransport.setDescription(getString(R.string.use_osm_live_public_transport_description));
    useOsmLiveForPublicTransport.setSummaryOn(R.string.shared_string_enabled);
    useOsmLiveForPublicTransport.setSummaryOff(R.string.shared_string_disabled);
    useOsmLiveForPublicTransport.setIcon(getPersistentPrefIcon(R.drawable.ic_action_osm_live));
    useOsmLiveForPublicTransport.setIconSpaceReserved(true);
    getPreferenceScreen().addPreference(useOsmLiveForPublicTransport);
}
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