Search in sources :

Example 6 with BooleanPreference

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

the class RouteParametersFragment method createRoutingBooleanMultiSelectPref.

private MultiSelectBooleanPreference createRoutingBooleanMultiSelectPref(String groupKey, String title, String descr, List<RoutingParameter> routingParameters) {
    MultiSelectBooleanPreference multiSelectPref = new MultiSelectBooleanPreference(app);
    multiSelectPref.setKey(groupKey);
    multiSelectPref.setTitle(title);
    multiSelectPref.setSummary(descr);
    multiSelectPref.setDescription(descr);
    multiSelectPref.setLayoutResource(R.layout.preference_with_descr);
    multiSelectPref.setIcon(getRoutingPrefIcon(groupKey));
    multiSelectPref.setIconSpaceReserved(true);
    String[] entries = new String[routingParameters.size()];
    String[] prefsIds = new String[routingParameters.size()];
    Set<String> enabledPrefsIds = new HashSet<>();
    ApplicationMode selectedMode = getSelectedAppMode();
    for (int i = 0; i < routingParameters.size(); i++) {
        RoutingParameter p = routingParameters.get(i);
        BooleanPreference booleanRoutingPref = (BooleanPreference) settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
        entries[i] = AndroidUtils.getRoutingStringPropertyName(app, p.getId(), p.getName());
        prefsIds[i] = booleanRoutingPref.getId();
        if (booleanRoutingPref.getModeValue(selectedMode)) {
            enabledPrefsIds.add(booleanRoutingPref.getId());
        }
    }
    multiSelectPref.setEntries(entries);
    multiSelectPref.setEntryValues(prefsIds);
    multiSelectPref.setValues(enabledPrefsIds);
    return multiSelectPref;
}
Also used : MultiSelectBooleanPreference(net.osmand.plus.settings.preferences.MultiSelectBooleanPreference) BooleanPreference(net.osmand.plus.settings.backend.preferences.BooleanPreference) RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) MultiSelectBooleanPreference(net.osmand.plus.settings.preferences.MultiSelectBooleanPreference) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) HashSet(java.util.HashSet)

Aggregations

BooleanPreference (net.osmand.plus.settings.backend.preferences.BooleanPreference)6 CommonPreference (net.osmand.plus.settings.backend.preferences.CommonPreference)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 View (android.view.View)1 Fragment (androidx.fragment.app.Fragment)1 HashSet (java.util.HashSet)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)1 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)1 BottomSheetItemWithDescription (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)1 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)1 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)1 ContextMenuItemsSettings (net.osmand.plus.settings.backend.menuitems.ContextMenuItemsSettings)1 MainContextMenuItemsSettings (net.osmand.plus.settings.backend.menuitems.MainContextMenuItemsSettings)1 BooleanAccessibilityPreference (net.osmand.plus.settings.backend.preferences.BooleanAccessibilityPreference)1 BooleanStringPreference (net.osmand.plus.settings.backend.preferences.BooleanStringPreference)1 ContextMenuItemsPreference (net.osmand.plus.settings.backend.preferences.ContextMenuItemsPreference)1 EnumStringPreference (net.osmand.plus.settings.backend.preferences.EnumStringPreference)1 FloatPreference (net.osmand.plus.settings.backend.preferences.FloatPreference)1