Search in sources :

Example 1 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.

the class SettingsHelper method getSettingsByCategory.

public Map<ExportSettingsCategory, SettingsCategoryItems> getSettingsByCategory(boolean addEmptyItems) {
    Map<ExportSettingsCategory, SettingsCategoryItems> dataList = new LinkedHashMap<>();
    Map<ExportSettingsType, List<?>> settingsItems = getSettingsItems(null, addEmptyItems);
    Map<ExportSettingsType, List<?>> myPlacesItems = getMyPlacesItems(null, addEmptyItems);
    Map<ExportSettingsType, List<?>> resourcesItems = getResourcesItems(null, addEmptyItems);
    if (!settingsItems.isEmpty() || addEmptyItems) {
        dataList.put(ExportSettingsCategory.SETTINGS, new SettingsCategoryItems(settingsItems));
    }
    if (!myPlacesItems.isEmpty() || addEmptyItems) {
        dataList.put(ExportSettingsCategory.MY_PLACES, new SettingsCategoryItems(myPlacesItems));
    }
    if (!resourcesItems.isEmpty() || addEmptyItems) {
        dataList.put(ExportSettingsCategory.RESOURCES, new SettingsCategoryItems(resourcesItems));
    }
    return dataList;
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) ExportSettingsCategory(net.osmand.plus.settings.backend.ExportSettingsCategory) List(java.util.List) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 2 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.

the class BackupTypesAdapter method getCategoryDescr.

private String getCategoryDescr(ExportSettingsCategory category) {
    long itemsSize = 0;
    int selectedTypes = 0;
    SettingsCategoryItems items = itemsMap.get(category);
    for (ExportSettingsType type : items.getTypes()) {
        if (selectedItemsMap.get(type) != null) {
            selectedTypes++;
            itemsSize += ExportSettingsAdapter.calculateItemsSize(items.getItemsForType(type));
        }
    }
    String description;
    if (selectedTypes == 0) {
        description = app.getString(R.string.shared_string_none);
    } else if (selectedTypes == items.getTypes().size()) {
        description = app.getString(R.string.shared_string_all);
    } else {
        description = app.getString(R.string.ltr_or_rtl_combine_via_slash, String.valueOf(selectedTypes), String.valueOf(items.getTypes().size()));
    }
    String formattedSize = AndroidUtils.formatSize(app, itemsSize);
    return itemsSize == 0 ? description : app.getString(R.string.ltr_or_rtl_combine_via_comma, description, formattedSize);
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 3 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.

the class BackupTypesFragment method onCategorySelected.

@Override
public void onCategorySelected(ExportSettingsCategory category, boolean selected) {
    super.onCategorySelected(category, selected);
    SettingsCategoryItems categoryItems = dataList.get(category);
    for (ExportSettingsType type : categoryItems.getTypes()) {
        backupHelper.getBackupTypePref(type).set(selected);
    }
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 4 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.

the class VersionHistoryFragment method onCategorySelected.

@Override
public void onCategorySelected(ExportSettingsCategory category, boolean selected) {
    super.onCategorySelected(category, selected);
    SettingsCategoryItems categoryItems = dataList.get(category);
    for (ExportSettingsType type : categoryItems.getTypes()) {
        backupHelper.getVersionHistoryTypePref(type).set(selected);
    }
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 5 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.

the class SettingsHelper method getSettingsToOperateByCategory.

public static Map<ExportSettingsCategory, SettingsCategoryItems> getSettingsToOperateByCategory(Map<ExportSettingsType, List<?>> settingsToOperate, boolean addEmptyItems) {
    Map<ExportSettingsType, List<?>> settingsItems = new LinkedHashMap<>();
    Map<ExportSettingsType, List<?>> myPlacesItems = new LinkedHashMap<>();
    Map<ExportSettingsType, List<?>> resourcesItems = new LinkedHashMap<>();
    for (Map.Entry<ExportSettingsType, List<?>> entry : settingsToOperate.entrySet()) {
        ExportSettingsType type = entry.getKey();
        if (type.isSettingsCategory()) {
            settingsItems.put(type, entry.getValue());
        } else if (type.isMyPlacesCategory()) {
            myPlacesItems.put(type, entry.getValue());
        } else if (type.isResourcesCategory()) {
            resourcesItems.put(type, entry.getValue());
        }
    }
    Map<ExportSettingsCategory, SettingsCategoryItems> exportMap = new LinkedHashMap<>();
    if (!settingsItems.isEmpty() || addEmptyItems) {
        exportMap.put(ExportSettingsCategory.SETTINGS, new SettingsCategoryItems(settingsItems));
    }
    if (!myPlacesItems.isEmpty() || addEmptyItems) {
        exportMap.put(ExportSettingsCategory.MY_PLACES, new SettingsCategoryItems(myPlacesItems));
    }
    if (!resourcesItems.isEmpty() || addEmptyItems) {
        exportMap.put(ExportSettingsCategory.RESOURCES, new SettingsCategoryItems(resourcesItems));
    }
    return exportMap;
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) List(java.util.List) ArrayList(java.util.ArrayList) ExportSettingsCategory(net.osmand.plus.settings.backend.ExportSettingsCategory) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ExportSettingsType (net.osmand.plus.settings.backend.ExportSettingsType)9 SettingsCategoryItems (net.osmand.plus.settings.fragments.SettingsCategoryItems)9 ExportSettingsCategory (net.osmand.plus.settings.backend.ExportSettingsCategory)4 View (android.view.View)2 CompoundButton (android.widget.CompoundButton)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Typeface (android.graphics.Typeface)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1