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;
}
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);
}
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);
}
}
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);
}
}
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;
}
Aggregations