Search in sources :

Example 21 with ExportSettingsType

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;
}
Also used : ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SQLiteTileSource(net.osmand.plus.resources.SQLiteTileSource) LocalIndexType(net.osmand.plus.download.LocalIndexHelper.LocalIndexType) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) ITileSource(net.osmand.map.ITileSource) List(java.util.List) ArrayList(java.util.ArrayList) LocalIndexInfo(net.osmand.plus.download.LocalIndexInfo) File(java.io.File) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 22 with ExportSettingsType

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

Example 23 with ExportSettingsType

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;
}
Also used : SearchHistorySettingsItem(net.osmand.plus.settings.backend.backup.items.SearchHistorySettingsItem) QuickAction(net.osmand.plus.quickaction.QuickAction) ApplicationModeBean(net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ArrayList(java.util.ArrayList) OsmNotesSettingsItem(net.osmand.plus.settings.backend.backup.items.OsmNotesSettingsItem) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) QuickActionsSettingsItem(net.osmand.plus.settings.backend.backup.items.QuickActionsSettingsItem) ItinerarySettingsItem(net.osmand.plus.settings.backend.backup.items.ItinerarySettingsItem) FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) FavoritesSettingsItem(net.osmand.plus.settings.backend.backup.items.FavoritesSettingsItem) AvoidRoadsSettingsItem(net.osmand.plus.settings.backend.backup.items.AvoidRoadsSettingsItem) SearchHistorySettingsItem(net.osmand.plus.settings.backend.backup.items.SearchHistorySettingsItem) GpxSettingsItem(net.osmand.plus.settings.backend.backup.items.GpxSettingsItem) ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) HistoryMarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.HistoryMarkersSettingsItem) MapSourcesSettingsItem(net.osmand.plus.settings.backend.backup.items.MapSourcesSettingsItem) ItinerarySettingsItem(net.osmand.plus.settings.backend.backup.items.ItinerarySettingsItem) PoiUiFiltersSettingsItem(net.osmand.plus.settings.backend.backup.items.PoiUiFiltersSettingsItem) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) OsmEditsSettingsItem(net.osmand.plus.settings.backend.backup.items.OsmEditsSettingsItem) OsmNotesSettingsItem(net.osmand.plus.settings.backend.backup.items.OsmNotesSettingsItem) MarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.MarkersSettingsItem) GlobalSettingsItem(net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem) FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) OnlineRoutingSettingsItem(net.osmand.plus.settings.backend.backup.items.OnlineRoutingSettingsItem) QuickActionsSettingsItem(net.osmand.plus.settings.backend.backup.items.QuickActionsSettingsItem) OnlineRoutingSettingsItem(net.osmand.plus.settings.backend.backup.items.OnlineRoutingSettingsItem) List(java.util.List) ArrayList(java.util.ArrayList) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) EnumMap(java.util.EnumMap) AvoidRoadsSettingsItem(net.osmand.plus.settings.backend.backup.items.AvoidRoadsSettingsItem) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType) OsmEditsSettingsItem(net.osmand.plus.settings.backend.backup.items.OsmEditsSettingsItem) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) PoiUiFiltersSettingsItem(net.osmand.plus.settings.backend.backup.items.PoiUiFiltersSettingsItem) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) GlobalSettingsItem(net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem) ITileSource(net.osmand.map.ITileSource) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) MapSourcesSettingsItem(net.osmand.plus.settings.backend.backup.items.MapSourcesSettingsItem) FavoritesSettingsItem(net.osmand.plus.settings.backend.backup.items.FavoritesSettingsItem) HistoryMarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.HistoryMarkersSettingsItem) MarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.MarkersSettingsItem) File(java.io.File) HistoryMarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.HistoryMarkersSettingsItem)

Example 24 with ExportSettingsType

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);
    }
}
Also used : OnItemClickListener(net.osmand.plus.settings.fragments.ImportedSettingsItemsAdapter.OnItemClickListener) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 25 with ExportSettingsType

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);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) ArrayList(java.util.ArrayList) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) MapActivity(net.osmand.plus.activities.MapActivity) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Aggregations

ExportSettingsType (net.osmand.plus.settings.backend.ExportSettingsType)36 ArrayList (java.util.ArrayList)18 List (java.util.List)10 SettingsCategoryItems (net.osmand.plus.settings.fragments.SettingsCategoryItems)9 ExportSettingsCategory (net.osmand.plus.settings.backend.ExportSettingsCategory)6 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 File (java.io.File)5 LinkedHashMap (java.util.LinkedHashMap)5 Nullable (androidx.annotation.Nullable)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 SettingsItem (net.osmand.plus.settings.backend.backup.items.SettingsItem)4 NonNull (androidx.annotation.NonNull)3 EnumMap (java.util.EnumMap)3 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)3 SuppressLint (android.annotation.SuppressLint)2 Typeface (android.graphics.Typeface)2 AsyncTask (android.os.AsyncTask)2