use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class SettingsHelper method getResourcesItems.
private Map<ExportSettingsType, List<?>> getResourcesItems(@Nullable List<ExportSettingsType> settingsTypes, boolean addEmptyItems) {
Map<ExportSettingsType, List<?>> resourcesItems = new LinkedHashMap<>();
Map<String, File> externalRenderers = settingsTypes == null || settingsTypes.contains(ExportSettingsType.CUSTOM_RENDER_STYLE) ? app.getRendererRegistry().getExternalRenderers() : Collections.emptyMap();
if (!externalRenderers.isEmpty() || addEmptyItems) {
resourcesItems.put(ExportSettingsType.CUSTOM_RENDER_STYLE, new ArrayList<>(externalRenderers.values()));
}
List<File> routingProfiles = new ArrayList<>();
if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.CUSTOM_ROUTING)) {
File routingProfilesFolder = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
if (routingProfilesFolder.exists() && routingProfilesFolder.isDirectory()) {
File[] fl = routingProfilesFolder.listFiles();
if (fl != null && fl.length > 0) {
routingProfiles.addAll(Arrays.asList(fl));
}
}
}
if (!Algorithms.isEmpty(routingProfiles) || addEmptyItems) {
resourcesItems.put(ExportSettingsType.CUSTOM_ROUTING, routingProfiles);
}
List<OnlineRoutingEngine> onlineRoutingEngines = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ONLINE_ROUTING_ENGINES) ? app.getOnlineRoutingHelper().getOnlyCustomEngines() : Collections.emptyList();
if (!Algorithms.isEmpty(onlineRoutingEngines) || addEmptyItems) {
resourcesItems.put(ExportSettingsType.ONLINE_ROUTING_ENGINES, onlineRoutingEngines);
}
List<ITileSource> iTileSources = new ArrayList<>();
if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.MAP_SOURCES)) {
Set<String> tileSourceNames = app.getSettings().getTileSourceEntries(true).keySet();
for (String name : tileSourceNames) {
File f = app.getAppPath(IndexConstants.TILES_INDEX_DIR + name);
if (f != null) {
ITileSource template;
if (f.getName().endsWith(SQLiteTileSource.EXT)) {
template = new SQLiteTileSource(app, f, TileSourceManager.getKnownSourceTemplates());
} else {
template = TileSourceManager.createTileSourceTemplate(f);
}
if (template.getUrlTemplate() != null) {
iTileSources.add(template);
}
}
}
}
if (!iTileSources.isEmpty() || addEmptyItems) {
resourcesItems.put(ExportSettingsType.MAP_SOURCES, iTileSources);
}
List<LocalIndexInfo> localIndexInfoList;
List<LocalIndexType> dataTypes = new ArrayList<>();
if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.OFFLINE_MAPS)) {
dataTypes.add(LocalIndexType.MAP_DATA);
dataTypes.add(LocalIndexType.TILES_DATA);
dataTypes.add(LocalIndexType.SRTM_DATA);
dataTypes.add(LocalIndexType.WIKI_DATA);
}
if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.TTS_VOICE)) {
dataTypes.add(LocalIndexType.TTS_VOICE_DATA);
}
if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.VOICE)) {
dataTypes.add(LocalIndexType.VOICE_DATA);
}
localIndexInfoList = !dataTypes.isEmpty() ? getLocalIndexData(dataTypes.toArray(new LocalIndexType[0])) : Collections.emptyList();
List<File> files = getFilesByType(localIndexInfoList, LocalIndexType.MAP_DATA, LocalIndexType.TILES_DATA, LocalIndexType.SRTM_DATA, LocalIndexType.WIKI_DATA);
if (!files.isEmpty() || addEmptyItems) {
sortLocalFiles(files);
resourcesItems.put(ExportSettingsType.OFFLINE_MAPS, files);
}
files = getFilesByType(localIndexInfoList, LocalIndexType.TTS_VOICE_DATA);
if (!files.isEmpty() || addEmptyItems) {
resourcesItems.put(ExportSettingsType.TTS_VOICE, files);
}
files = getFilesByType(localIndexInfoList, LocalIndexType.VOICE_DATA);
if (!files.isEmpty() || addEmptyItems) {
resourcesItems.put(ExportSettingsType.VOICE, files);
}
return resourcesItems;
}
use of net.osmand.plus.settings.backend.ExportSettingsType 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;
}
use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class SettingsHelper method getSettingsToOperate.
public static Map<ExportSettingsType, List<?>> getSettingsToOperate(List<SettingsItem> settingsItems, boolean importComplete, boolean addEmptyItems) {
Map<ExportSettingsType, List<?>> settingsToOperate = new EnumMap<>(ExportSettingsType.class);
List<ApplicationModeBean> profiles = new ArrayList<>();
List<QuickAction> quickActions = new ArrayList<>();
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
List<ITileSource> tileSourceTemplates = new ArrayList<>();
List<File> routingFilesList = new ArrayList<>();
List<File> renderFilesList = new ArrayList<>();
List<File> ttsVoiceFilesList = new ArrayList<>();
List<File> voiceFilesList = new ArrayList<>();
List<FileSettingsItem> mapFilesList = new ArrayList<>();
List<FileSettingsItem> tracksFilesList = new ArrayList<>();
List<FileSettingsItem> multimediaFilesList = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
List<GlobalSettingsItem> globalSettingsItems = new ArrayList<>();
List<OsmNotesPoint> notesPointList = new ArrayList<>();
List<OpenstreetmapPoint> editsPointList = new ArrayList<>();
List<FavoriteGroup> favoriteGroups = new ArrayList<>();
List<MapMarkersGroup> markersGroups = new ArrayList<>();
List<HistoryEntry> historyEntries = new ArrayList<>();
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
List<MapMarkersGroup> itineraryGroups = new ArrayList<>();
for (SettingsItem item : settingsItems) {
switch(item.getType()) {
case PROFILE:
profiles.add(((ProfileSettingsItem) item).getModeBean());
break;
case FILE:
FileSettingsItem fileItem = (FileSettingsItem) item;
if (fileItem.getSubtype() == FileSubtype.RENDERING_STYLE) {
renderFilesList.add(fileItem.getFile());
} else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) {
routingFilesList.add(fileItem.getFile());
} else if (fileItem.getSubtype() == FileSubtype.MULTIMEDIA_NOTES) {
multimediaFilesList.add(fileItem);
} else if (fileItem.getSubtype() == FileSubtype.GPX) {
tracksFilesList.add(fileItem);
} else if (fileItem.getSubtype().isMap()) {
mapFilesList.add(fileItem);
} else if (fileItem.getSubtype() == FileSubtype.TTS_VOICE) {
ttsVoiceFilesList.add(fileItem.getFile());
} else if (fileItem.getSubtype() == FileSubtype.VOICE) {
voiceFilesList.add(fileItem.getFile());
}
break;
case QUICK_ACTIONS:
QuickActionsSettingsItem quickActionsItem = (QuickActionsSettingsItem) item;
if (importComplete) {
quickActions.addAll(quickActionsItem.getAppliedItems());
} else {
quickActions.addAll(quickActionsItem.getItems());
}
break;
case POI_UI_FILTERS:
PoiUiFiltersSettingsItem poiUiFilterItem = (PoiUiFiltersSettingsItem) item;
if (importComplete) {
poiUIFilters.addAll(poiUiFilterItem.getAppliedItems());
} else {
poiUIFilters.addAll(poiUiFilterItem.getItems());
}
break;
case MAP_SOURCES:
MapSourcesSettingsItem mapSourcesItem = (MapSourcesSettingsItem) item;
if (importComplete) {
tileSourceTemplates.addAll(mapSourcesItem.getAppliedItems());
} else {
tileSourceTemplates.addAll(mapSourcesItem.getItems());
}
break;
case AVOID_ROADS:
AvoidRoadsSettingsItem avoidRoadsItem = (AvoidRoadsSettingsItem) item;
if (importComplete) {
avoidRoads.addAll(avoidRoadsItem.getAppliedItems());
} else {
avoidRoads.addAll(avoidRoadsItem.getItems());
}
break;
case GLOBAL:
globalSettingsItems.add((GlobalSettingsItem) item);
break;
case OSM_NOTES:
OsmNotesSettingsItem osmNotesSettingsItem = (OsmNotesSettingsItem) item;
if (importComplete) {
notesPointList.addAll(osmNotesSettingsItem.getAppliedItems());
} else {
notesPointList.addAll(osmNotesSettingsItem.getItems());
}
break;
case OSM_EDITS:
OsmEditsSettingsItem osmEditsSettingsItem = (OsmEditsSettingsItem) item;
if (importComplete) {
editsPointList.addAll(osmEditsSettingsItem.getAppliedItems());
} else {
editsPointList.addAll(osmEditsSettingsItem.getItems());
}
break;
case FAVOURITES:
FavoritesSettingsItem favoritesSettingsItem = (FavoritesSettingsItem) item;
favoriteGroups.addAll(favoritesSettingsItem.getItems());
break;
case ACTIVE_MARKERS:
MarkersSettingsItem markersSettingsItem = (MarkersSettingsItem) item;
markersGroups.add(markersSettingsItem.getMarkersGroup());
break;
case HISTORY_MARKERS:
HistoryMarkersSettingsItem historyMarkersSettingsItem = (HistoryMarkersSettingsItem) item;
markersGroups.add(historyMarkersSettingsItem.getMarkersGroup());
break;
case SEARCH_HISTORY:
SearchHistorySettingsItem searchHistorySettingsItem = (SearchHistorySettingsItem) item;
historyEntries.addAll(searchHistorySettingsItem.getItems());
break;
case GPX:
tracksFilesList.add((GpxSettingsItem) item);
break;
case ONLINE_ROUTING_ENGINES:
OnlineRoutingSettingsItem onlineRoutingSettingsItem = (OnlineRoutingSettingsItem) item;
onlineRoutingEngines.addAll(onlineRoutingSettingsItem.getItems());
break;
case ITINERARY_GROUPS:
ItinerarySettingsItem itinerarySettingsItem = (ItinerarySettingsItem) item;
itineraryGroups.addAll(itinerarySettingsItem.getItems());
break;
default:
break;
}
}
for (SettingsItem item : settingsItems) {
switch(item.getType()) {
case PROFILE:
if (!profiles.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.PROFILE, profiles);
}
break;
case FILE:
FileSettingsItem fileItem = (FileSettingsItem) item;
if (fileItem.getSubtype() == FileSubtype.RENDERING_STYLE) {
if (!renderFilesList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.CUSTOM_RENDER_STYLE, renderFilesList);
}
} else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) {
if (!routingFilesList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.CUSTOM_ROUTING, routingFilesList);
}
} else if (fileItem.getSubtype() == FileSubtype.MULTIMEDIA_NOTES) {
if (!multimediaFilesList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.MULTIMEDIA_NOTES, multimediaFilesList);
}
} else if (fileItem.getSubtype() == FileSubtype.GPX) {
if (!tracksFilesList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.TRACKS, tracksFilesList);
}
} else if (fileItem.getSubtype().isMap()) {
if (!mapFilesList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.OFFLINE_MAPS, mapFilesList);
}
} else if (fileItem.getSubtype() == FileSubtype.TTS_VOICE) {
if (!ttsVoiceFilesList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.TTS_VOICE, ttsVoiceFilesList);
}
} else if (fileItem.getSubtype() == FileSubtype.VOICE) {
if (!voiceFilesList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.VOICE, voiceFilesList);
}
}
break;
case QUICK_ACTIONS:
if (!quickActions.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.QUICK_ACTIONS, quickActions);
}
break;
case POI_UI_FILTERS:
if (!poiUIFilters.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.POI_TYPES, poiUIFilters);
}
break;
case MAP_SOURCES:
if (!tileSourceTemplates.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.MAP_SOURCES, tileSourceTemplates);
}
break;
case AVOID_ROADS:
if (!avoidRoads.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.AVOID_ROADS, avoidRoads);
}
break;
case GLOBAL:
if (!globalSettingsItems.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.GLOBAL, globalSettingsItems);
}
break;
case OSM_NOTES:
if (!notesPointList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.OSM_NOTES, notesPointList);
}
break;
case OSM_EDITS:
if (!editsPointList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.OSM_EDITS, editsPointList);
}
break;
case FAVOURITES:
if (!favoriteGroups.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.FAVORITES, favoriteGroups);
}
break;
case ACTIVE_MARKERS:
case HISTORY_MARKERS:
if (!markersGroups.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.ACTIVE_MARKERS, markersGroups);
}
break;
case SEARCH_HISTORY:
if (!historyEntries.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
}
break;
case GPX:
if (!tracksFilesList.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.TRACKS, tracksFilesList);
}
break;
case ONLINE_ROUTING_ENGINES:
if (!onlineRoutingEngines.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.ONLINE_ROUTING_ENGINES, onlineRoutingEngines);
}
break;
case ITINERARY_GROUPS:
if (!itineraryGroups.isEmpty() || addEmptyItems) {
settingsToOperate.put(ExportSettingsType.ITINERARY_GROUPS, itineraryGroups);
}
break;
default:
break;
}
}
return settingsToOperate;
}
use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class ImportCompleteFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (settingsItems != null) {
ImportedSettingsItemsAdapter adapter = new ImportedSettingsItemsAdapter(app, SettingsHelper.getSettingsToOperate(settingsItems, true, false), nightMode, new OnItemClickListener() {
@Override
public void onItemClick(ExportSettingsType type) {
navigateTo(type);
}
});
recyclerView.setLayoutManager(new LinearLayoutManager(getMyApplication()));
recyclerView.setAdapter(adapter);
}
}
use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class HistorySettingsFragment method onPreferenceClick.
@Override
public boolean onPreferenceClick(Preference preference) {
String prefId = preference.getKey();
if (prefId.equals(BACKUP_TO_FILE)) {
MapActivity activity = getMapActivity();
if (AndroidUtils.isActivityNotDestroyed(activity)) {
ApplicationMode mode = getSelectedAppMode();
List<ExportSettingsType> types = new ArrayList<>();
types.add(ExportSettingsType.SEARCH_HISTORY);
types.add(ExportSettingsType.HISTORY_MARKERS);
ExportSettingsFragment.showInstance(activity.getSupportFragmentManager(), mode, types, true);
}
} else if (prefId.equals(CLEAR_ALL_HISTORY)) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
ClearAllHistoryBottomSheet.showInstance(fragmentManager, this);
}
} else if (prefId.equals(SEARCH_HISTORY)) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
SearchHistorySettingsFragment.showInstance(fragmentManager, this);
}
} else if (prefId.equals(NAVIGATION_HISTORY)) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
NavigationHistorySettingsFragment.showInstance(fragmentManager, this);
}
} else if (prefId.equals(MAP_MARKERS_HISTORY)) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
MarkersHistorySettingsFragment.showInstance(fragmentManager, this);
}
}
return super.onPreferenceClick(preference);
}
Aggregations