Search in sources :

Example 1 with ProfileSettingsItem

use of net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem in project Osmand by osmandapp.

the class SettingsItemsFactory method createItem.

@Nullable
private SettingsItem createItem(@NonNull JSONObject json) throws IllegalArgumentException, JSONException {
    SettingsItem item = null;
    SettingsItemType type = SettingsItem.parseItemType(json);
    if (type == null) {
        return null;
    }
    OsmandSettings settings = app.getSettings();
    switch(type) {
        case GLOBAL:
            item = new GlobalSettingsItem(settings, json);
            break;
        case PROFILE:
            item = new ProfileSettingsItem(app, json);
            break;
        case PLUGIN:
            item = new PluginSettingsItem(app, json);
            break;
        case DATA:
            item = new DataSettingsItem(app, json);
            break;
        case FILE:
            item = new FileSettingsItem(app, json);
            break;
        case RESOURCES:
            item = new ResourcesSettingsItem(app, json);
            break;
        case QUICK_ACTIONS:
            item = new QuickActionsSettingsItem(app, json);
            break;
        case POI_UI_FILTERS:
            item = new PoiUiFiltersSettingsItem(app, json);
            break;
        case MAP_SOURCES:
            item = new MapSourcesSettingsItem(app, json);
            break;
        case AVOID_ROADS:
            item = new AvoidRoadsSettingsItem(app, json);
            break;
        case SUGGESTED_DOWNLOADS:
            item = new SuggestedDownloadsItem(app, json);
            break;
        case DOWNLOADS:
            item = new DownloadsItem(app, json);
            break;
        case OSM_NOTES:
            item = new OsmNotesSettingsItem(app, json);
            break;
        case OSM_EDITS:
            item = new OsmEditsSettingsItem(app, json);
            break;
        case FAVOURITES:
            item = new FavoritesSettingsItem(app, json);
            break;
        case ACTIVE_MARKERS:
            item = new MarkersSettingsItem(app, json);
            break;
        case HISTORY_MARKERS:
            item = new HistoryMarkersSettingsItem(app, json);
            break;
        case SEARCH_HISTORY:
            item = new SearchHistorySettingsItem(app, json);
            break;
        case GPX:
            item = new GpxSettingsItem(app, json);
            break;
        case ONLINE_ROUTING_ENGINES:
            item = new OnlineRoutingSettingsItem(app, json);
            break;
        case ITINERARY_GROUPS:
            item = new ItinerarySettingsItem(app, json);
            break;
    }
    return item;
}
Also used : SearchHistorySettingsItem(net.osmand.plus.settings.backend.backup.items.SearchHistorySettingsItem) ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) OsmEditsSettingsItem(net.osmand.plus.settings.backend.backup.items.OsmEditsSettingsItem) DataSettingsItem(net.osmand.plus.settings.backend.backup.items.DataSettingsItem) GpxSettingsItem(net.osmand.plus.settings.backend.backup.items.GpxSettingsItem) ResourcesSettingsItem(net.osmand.plus.settings.backend.backup.items.ResourcesSettingsItem) OsmNotesSettingsItem(net.osmand.plus.settings.backend.backup.items.OsmNotesSettingsItem) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) QuickActionsSettingsItem(net.osmand.plus.settings.backend.backup.items.QuickActionsSettingsItem) PoiUiFiltersSettingsItem(net.osmand.plus.settings.backend.backup.items.PoiUiFiltersSettingsItem) ItinerarySettingsItem(net.osmand.plus.settings.backend.backup.items.ItinerarySettingsItem) GlobalSettingsItem(net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem) DownloadsItem(net.osmand.plus.settings.backend.backup.items.DownloadsItem) SuggestedDownloadsItem(net.osmand.plus.settings.backend.backup.items.SuggestedDownloadsItem) PoiUiFiltersSettingsItem(net.osmand.plus.settings.backend.backup.items.PoiUiFiltersSettingsItem) FavoritesSettingsItem(net.osmand.plus.settings.backend.backup.items.FavoritesSettingsItem) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) OsmEditsSettingsItem(net.osmand.plus.settings.backend.backup.items.OsmEditsSettingsItem) 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) PluginSettingsItem(net.osmand.plus.settings.backend.backup.items.PluginSettingsItem) ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) 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) HistoryMarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.HistoryMarkersSettingsItem) MapSourcesSettingsItem(net.osmand.plus.settings.backend.backup.items.MapSourcesSettingsItem) DataSettingsItem(net.osmand.plus.settings.backend.backup.items.DataSettingsItem) OnlineRoutingSettingsItem(net.osmand.plus.settings.backend.backup.items.OnlineRoutingSettingsItem) ItinerarySettingsItem(net.osmand.plus.settings.backend.backup.items.ItinerarySettingsItem) ResourcesSettingsItem(net.osmand.plus.settings.backend.backup.items.ResourcesSettingsItem) QuickActionsSettingsItem(net.osmand.plus.settings.backend.backup.items.QuickActionsSettingsItem) FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) OnlineRoutingSettingsItem(net.osmand.plus.settings.backend.backup.items.OnlineRoutingSettingsItem) SuggestedDownloadsItem(net.osmand.plus.settings.backend.backup.items.SuggestedDownloadsItem) MapSourcesSettingsItem(net.osmand.plus.settings.backend.backup.items.MapSourcesSettingsItem) FavoritesSettingsItem(net.osmand.plus.settings.backend.backup.items.FavoritesSettingsItem) MarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.MarkersSettingsItem) HistoryMarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.HistoryMarkersSettingsItem) HistoryMarkersSettingsItem(net.osmand.plus.settings.backend.backup.items.HistoryMarkersSettingsItem) PluginSettingsItem(net.osmand.plus.settings.backend.backup.items.PluginSettingsItem) AvoidRoadsSettingsItem(net.osmand.plus.settings.backend.backup.items.AvoidRoadsSettingsItem) Nullable(androidx.annotation.Nullable)

Example 2 with ProfileSettingsItem

use of net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem in project Osmand by osmandapp.

the class SettingsHelper method getBaseProfileSettingsItem.

@Nullable
private ProfileSettingsItem getBaseProfileSettingsItem(ApplicationModeBean modeBean, List<SettingsItem> settingsItems) {
    for (SettingsItem settingsItem : settingsItems) {
        if (settingsItem.getType() == SettingsItemType.PROFILE) {
            ProfileSettingsItem profileItem = (ProfileSettingsItem) settingsItem;
            ApplicationModeBean bean = profileItem.getModeBean();
            if (Algorithms.objectEquals(bean.stringKey, modeBean.stringKey) && Algorithms.objectEquals(bean.userProfileName, modeBean.userProfileName)) {
                return profileItem;
            }
        }
    }
    return null;
}
Also used : ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) ApplicationModeBean(net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean) 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) Nullable(androidx.annotation.Nullable)

Example 3 with ProfileSettingsItem

use of net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem in project Osmand by osmandapp.

the class OsmandAidlApi method exportProfile.

public boolean exportProfile(String appModeKey, List<String> settingsTypesKeys) {
    ApplicationMode appMode = ApplicationMode.valueOfStringKey(appModeKey, null);
    if (app != null && appMode != null) {
        List<ExportSettingsType> settingsTypes = new ArrayList<>();
        for (String key : settingsTypesKeys) {
            settingsTypes.add(ExportSettingsType.valueOf(key));
        }
        settingsTypes.remove(ExportSettingsType.PROFILE);
        List<SettingsItem> settingsItems = new ArrayList<>();
        settingsItems.add(new ProfileSettingsItem(app, appMode));
        File exportDir = app.getSettings().getExternalStorageDirectory();
        String fileName = appMode.toHumanString();
        FileSettingsHelper settingsHelper = app.getFileSettingsHelper();
        settingsItems.addAll(settingsHelper.getFilteredSettingsItems(settingsTypes, true, false));
        settingsHelper.exportSettings(exportDir, fileName, null, settingsItems, true);
        return true;
    }
    return false;
}
Also used : ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) ArrayList(java.util.ArrayList) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) GPXFile(net.osmand.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) ASqliteDbFile(net.osmand.aidl.tiles.ASqliteDbFile) File(java.io.File) ASelectedGpxFile(net.osmand.aidl.gpx.ASelectedGpxFile) AGpxFile(net.osmand.aidl.gpx.AGpxFile) FileSettingsHelper(net.osmand.plus.settings.backend.backup.FileSettingsHelper) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 4 with ProfileSettingsItem

use of net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem in project Osmand by osmandapp.

the class ItemViewHolder method getItemIcon.

@Nullable
protected Drawable getItemIcon(@NonNull SettingsItem item) {
    if (item instanceof ProfileSettingsItem) {
        ProfileSettingsItem profileItem = (ProfileSettingsItem) item;
        ApplicationMode mode = profileItem.getAppMode();
        return getContentIcon(mode.getIconRes());
    }
    ExportSettingsType type = ExportSettingsType.getExportSettingsTypeForItem(item);
    if (type != null) {
        return getContentIcon(type.getIconRes());
    }
    return null;
}
Also used : ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType) Nullable(androidx.annotation.Nullable)

Example 5 with ProfileSettingsItem

use of net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem in project Osmand by osmandapp.

the class CustomOsmandPlugin method removePluginItemsFromFile.

private void removePluginItemsFromFile(final File file, final PluginItemsListener itemsListener) {
    app.getFileSettingsHelper().collectSettings(file, "", 1, new CollectListener() {

        @Override
        public void onCollectFinished(boolean succeed, boolean empty, @NonNull List<SettingsItem> items) {
            if (succeed && !items.isEmpty()) {
                for (SettingsItem item : items) {
                    if (item instanceof QuickActionsSettingsItem) {
                        QuickActionsSettingsItem quickActionsSettingsItem = (QuickActionsSettingsItem) item;
                        List<QuickAction> quickActions = quickActionsSettingsItem.getItems();
                        QuickActionRegistry actionRegistry = app.getQuickActionRegistry();
                        for (QuickAction action : quickActions) {
                            QuickAction savedAction = actionRegistry.getQuickAction(app, action.getType(), action.getName(app), action.getParams());
                            if (savedAction != null) {
                                actionRegistry.deleteQuickAction(savedAction);
                            }
                        }
                    } else if (item instanceof MapSourcesSettingsItem) {
                        MapSourcesSettingsItem mapSourcesSettingsItem = (MapSourcesSettingsItem) item;
                        List<ITileSource> mapSources = mapSourcesSettingsItem.getItems();
                        for (ITileSource tileSource : mapSources) {
                            String tileSourceName = tileSource.getName();
                            if (tileSource instanceof SQLiteTileSource) {
                                tileSourceName += SQLITE_EXT;
                            }
                            ITileSource savedTileSource = app.getSettings().getTileSourceByName(tileSourceName, false);
                            if (savedTileSource != null) {
                                if (savedTileSource instanceof SQLiteTileSource) {
                                    SQLiteTileSource sqLiteTileSource = ((SQLiteTileSource) savedTileSource);
                                    sqLiteTileSource.closeDB();
                                }
                                File tPath = app.getAppPath(IndexConstants.TILES_INDEX_DIR);
                                File dir = new File(tPath, tileSourceName);
                                Algorithms.removeAllFiles(dir);
                            }
                        }
                    } else if (item instanceof PoiUiFiltersSettingsItem) {
                        PoiUiFiltersSettingsItem poiUiFiltersSettingsItem = (PoiUiFiltersSettingsItem) item;
                        List<PoiUIFilter> poiUIFilters = poiUiFiltersSettingsItem.getItems();
                        for (PoiUIFilter filter : poiUIFilters) {
                            app.getPoiFilters().removePoiFilter(filter);
                        }
                        app.getPoiFilters().reloadAllPoiFilters();
                        app.getPoiFilters().loadSelectedPoiFilters();
                        app.getSearchUICore().refreshCustomPoiFilters();
                    } else if (item instanceof AvoidRoadsSettingsItem) {
                        AvoidRoadsSettingsItem avoidRoadsSettingsItem = (AvoidRoadsSettingsItem) item;
                        List<AvoidSpecificRoads.AvoidRoadInfo> avoidRoadInfos = avoidRoadsSettingsItem.getItems();
                        for (AvoidSpecificRoads.AvoidRoadInfo avoidRoad : avoidRoadInfos) {
                            app.getAvoidSpecificRoads().removeImpassableRoad(avoidRoad);
                        }
                    } else if (item instanceof ProfileSettingsItem) {
                        ProfileSettingsItem profileSettingsItem = (ProfileSettingsItem) item;
                        ApplicationMode mode = profileSettingsItem.getAppMode();
                        ApplicationMode savedMode = ApplicationMode.valueOfStringKey(mode.getStringKey(), null);
                        if (savedMode != null) {
                            ApplicationMode.changeProfileAvailability(savedMode, false, app);
                        }
                    }
                }
            }
            if (itemsListener != null) {
                itemsListener.onItemsRemoved();
            }
        }
    });
}
Also used : QuickAction(net.osmand.plus.quickaction.QuickAction) ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) AvoidSpecificRoads(net.osmand.plus.helpers.AvoidSpecificRoads) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) SQLiteTileSource(net.osmand.plus.resources.SQLiteTileSource) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) QuickActionsSettingsItem(net.osmand.plus.settings.backend.backup.items.QuickActionsSettingsItem) PoiUiFiltersSettingsItem(net.osmand.plus.settings.backend.backup.items.PoiUiFiltersSettingsItem) CollectListener(net.osmand.plus.settings.backend.backup.SettingsHelper.CollectListener) AvoidRoadsSettingsItem(net.osmand.plus.settings.backend.backup.items.AvoidRoadsSettingsItem) ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) MapSourcesSettingsItem(net.osmand.plus.settings.backend.backup.items.MapSourcesSettingsItem) PoiUiFiltersSettingsItem(net.osmand.plus.settings.backend.backup.items.PoiUiFiltersSettingsItem) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) PluginSettingsItem(net.osmand.plus.settings.backend.backup.items.PluginSettingsItem) QuickActionsSettingsItem(net.osmand.plus.settings.backend.backup.items.QuickActionsSettingsItem) ITileSource(net.osmand.map.ITileSource) List(java.util.List) ArrayList(java.util.ArrayList) MapSourcesSettingsItem(net.osmand.plus.settings.backend.backup.items.MapSourcesSettingsItem) QuickActionRegistry(net.osmand.plus.quickaction.QuickActionRegistry) File(java.io.File) AvoidRoadsSettingsItem(net.osmand.plus.settings.backend.backup.items.AvoidRoadsSettingsItem)

Aggregations

ProfileSettingsItem (net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem)9 SettingsItem (net.osmand.plus.settings.backend.backup.items.SettingsItem)7 AvoidRoadsSettingsItem (net.osmand.plus.settings.backend.backup.items.AvoidRoadsSettingsItem)6 MapSourcesSettingsItem (net.osmand.plus.settings.backend.backup.items.MapSourcesSettingsItem)6 PoiUiFiltersSettingsItem (net.osmand.plus.settings.backend.backup.items.PoiUiFiltersSettingsItem)6 QuickActionsSettingsItem (net.osmand.plus.settings.backend.backup.items.QuickActionsSettingsItem)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)5 FavoritesSettingsItem (net.osmand.plus.settings.backend.backup.items.FavoritesSettingsItem)4 FileSettingsItem (net.osmand.plus.settings.backend.backup.items.FileSettingsItem)4 GlobalSettingsItem (net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem)4 GpxSettingsItem (net.osmand.plus.settings.backend.backup.items.GpxSettingsItem)4 HistoryMarkersSettingsItem (net.osmand.plus.settings.backend.backup.items.HistoryMarkersSettingsItem)4 ItinerarySettingsItem (net.osmand.plus.settings.backend.backup.items.ItinerarySettingsItem)4 MarkersSettingsItem (net.osmand.plus.settings.backend.backup.items.MarkersSettingsItem)4 OnlineRoutingSettingsItem (net.osmand.plus.settings.backend.backup.items.OnlineRoutingSettingsItem)4 OsmEditsSettingsItem (net.osmand.plus.settings.backend.backup.items.OsmEditsSettingsItem)4 OsmNotesSettingsItem (net.osmand.plus.settings.backend.backup.items.OsmNotesSettingsItem)4 SearchHistorySettingsItem (net.osmand.plus.settings.backend.backup.items.SearchHistorySettingsItem)4