Search in sources :

Example 1 with FileSettingsHelper

use of net.osmand.plus.settings.backend.backup.FileSettingsHelper 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 2 with FileSettingsHelper

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

the class AppInitializer method onCreateApplication.

public void onCreateApplication() {
    // always update application mode to default
    OsmandSettings osmandSettings = app.getSettings();
    if (osmandSettings.FOLLOW_THE_ROUTE.get()) {
        ApplicationMode savedMode = osmandSettings.readApplicationMode();
        if (!osmandSettings.APPLICATION_MODE.get().getStringKey().equals(savedMode.getStringKey())) {
            osmandSettings.setApplicationMode(savedMode);
        }
    } else {
        osmandSettings.setApplicationMode(osmandSettings.DEFAULT_APPLICATION_MODE.get());
    }
    startTime = System.currentTimeMillis();
    getLazyRoutingConfig();
    app.applyTheme(app);
    startupInit(app.reconnectToBRouter(), IBRouterService.class);
    app.backupHelper = startupInit(new BackupHelper(app), BackupHelper.class);
    app.inAppPurchaseHelper = startupInit(new InAppPurchaseHelperImpl(app), InAppPurchaseHelperImpl.class);
    app.poiTypes = startupInit(MapPoiTypes.getDefaultNoInit(), MapPoiTypes.class);
    app.transportRoutingHelper = startupInit(new TransportRoutingHelper(app), TransportRoutingHelper.class);
    app.routingHelper = startupInit(new RoutingHelper(app), RoutingHelper.class);
    app.routingOptionsHelper = startupInit(new RoutingOptionsHelper(app), RoutingOptionsHelper.class);
    app.resourceManager = startupInit(new ResourceManager(app), ResourceManager.class);
    app.daynightHelper = startupInit(new DayNightHelper(app), DayNightHelper.class);
    app.locationProvider = startupInit(new OsmAndLocationProvider(app), OsmAndLocationProvider.class);
    app.avoidSpecificRoads = startupInit(new AvoidSpecificRoads(app), AvoidSpecificRoads.class);
    app.avoidRoadsHelper = startupInit(new AvoidRoadsHelper(app), AvoidRoadsHelper.class);
    app.savingTrackHelper = startupInit(new SavingTrackHelper(app), SavingTrackHelper.class);
    app.analyticsHelper = startupInit(new AnalyticsHelper(app), AnalyticsHelper.class);
    app.notificationHelper = startupInit(new NotificationHelper(app), NotificationHelper.class);
    app.liveMonitoringHelper = startupInit(new LiveMonitoringHelper(app), LiveMonitoringHelper.class);
    app.selectedGpxHelper = startupInit(new GpxSelectionHelper(app, app.savingTrackHelper), GpxSelectionHelper.class);
    app.gpxDbHelper = startupInit(new GpxDbHelper(app), GpxDbHelper.class);
    app.favoritesHelper = startupInit(new FavouritesHelper(app), FavouritesHelper.class);
    app.waypointHelper = startupInit(new WaypointHelper(app), WaypointHelper.class);
    app.aidlApi = startupInit(new OsmandAidlApi(app), OsmandAidlApi.class);
    app.regions = startupInit(new OsmandRegions(), OsmandRegions.class);
    updateRegionVars();
    app.poiFilters = startupInit(new PoiFiltersHelper(app), PoiFiltersHelper.class);
    app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class);
    app.geocodingLookupService = startupInit(new GeocodingLookupService(app), GeocodingLookupService.class);
    app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);
    app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
    app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
    app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
    app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class);
    app.osmandMap = startupInit(new OsmandMap(app), OsmandMap.class);
    // TODO TRAVEL_OBF_HELPER check ResourceManager and use TravelObfHelper
    TravelHelper travelHelper = !TravelDbHelper.checkIfDbFileExists(app) ? new TravelObfHelper(app) : new TravelDbHelper(app);
    app.travelHelper = startupInit(travelHelper, TravelHelper.class);
    app.travelRendererHelper = startupInit(new TravelRendererHelper(app), TravelRendererHelper.class);
    app.lockHelper = startupInit(new LockHelper(app), LockHelper.class);
    app.fileSettingsHelper = startupInit(new FileSettingsHelper(app), FileSettingsHelper.class);
    app.networkSettingsHelper = startupInit(new NetworkSettingsHelper(app), NetworkSettingsHelper.class);
    app.quickActionRegistry = startupInit(new QuickActionRegistry(app.getSettings()), QuickActionRegistry.class);
    app.osmOAuthHelper = startupInit(new OsmOAuthHelper(app), OsmOAuthHelper.class);
    app.oprAuthHelper = startupInit(new OprAuthHelper(app), OprAuthHelper.class);
    app.onlineRoutingHelper = startupInit(new OnlineRoutingHelper(app), OnlineRoutingHelper.class);
    app.launcherShortcutsHelper = startupInit(new LauncherShortcutsHelper(app), LauncherShortcutsHelper.class);
    app.gpsFilterHelper = startupInit(new GpsFilterHelper(app), GpsFilterHelper.class);
    app.downloadTilesHelper = startupInit(new DownloadTilesHelper(app), DownloadTilesHelper.class);
    initOpeningHoursParser();
}
Also used : DayNightHelper(net.osmand.plus.helpers.DayNightHelper) OsmOAuthHelper(net.osmand.plus.plugins.osmedit.oauth.OsmOAuthHelper) FavouritesHelper(net.osmand.plus.myplaces.FavouritesHelper) AvoidSpecificRoads(net.osmand.plus.helpers.AvoidSpecificRoads) BackupHelper(net.osmand.plus.backup.BackupHelper) MapViewTrackingUtilities(net.osmand.plus.base.MapViewTrackingUtilities) WaypointHelper(net.osmand.plus.helpers.WaypointHelper) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) TravelObfHelper(net.osmand.plus.wikivoyage.data.TravelObfHelper) AvoidRoadsHelper(net.osmand.plus.routing.AvoidRoadsHelper) GpxDbHelper(net.osmand.plus.track.helpers.GpxDbHelper) OsmandRegions(net.osmand.map.OsmandRegions) LauncherShortcutsHelper(net.osmand.plus.helpers.LauncherShortcutsHelper) RendererRegistry(net.osmand.plus.render.RendererRegistry) DownloadTilesHelper(net.osmand.plus.plugins.rastermaps.DownloadTilesHelper) TargetPointsHelper(net.osmand.plus.helpers.TargetPointsHelper) QuickActionRegistry(net.osmand.plus.quickaction.QuickActionRegistry) AnalyticsHelper(net.osmand.plus.helpers.AnalyticsHelper) TravelHelper(net.osmand.plus.wikivoyage.data.TravelHelper) OsmandMap(net.osmand.plus.views.OsmandMap) TravelDbHelper(net.osmand.plus.wikivoyage.data.TravelDbHelper) MapMarkersDbHelper(net.osmand.plus.mapmarkers.MapMarkersDbHelper) GpsFilterHelper(net.osmand.plus.track.helpers.GpsFilterHelper) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) ResourceManager(net.osmand.plus.resources.ResourceManager) GpxSelectionHelper(net.osmand.plus.track.helpers.GpxSelectionHelper) TravelRendererHelper(net.osmand.plus.render.TravelRendererHelper) LiveMonitoringHelper(net.osmand.plus.plugins.monitoring.LiveMonitoringHelper) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) MapPoiTypes(net.osmand.osm.MapPoiTypes) QuickSearchHelper(net.osmand.plus.search.QuickSearchHelper) NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) RoutingOptionsHelper(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper) MapMarkersHelper(net.osmand.plus.mapmarkers.MapMarkersHelper) NotificationHelper(net.osmand.plus.notifications.NotificationHelper) InAppPurchaseHelperImpl(net.osmand.plus.inapp.InAppPurchaseHelperImpl) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) FileSettingsHelper(net.osmand.plus.settings.backend.backup.FileSettingsHelper) OprAuthHelper(net.osmand.plus.plugins.openplacereviews.OprAuthHelper) OsmandAidlApi(net.osmand.aidl.OsmandAidlApi) LockHelper(net.osmand.plus.helpers.LockHelper)

Example 3 with FileSettingsHelper

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

the class SettingsImportTask method onPostExecute.

@Override
protected void onPostExecute(String error) {
    File tempDir = FileUtils.getTempDir(app);
    final File file = new File(tempDir, name);
    if (error == null && file.exists()) {
        final FileSettingsHelper settingsHelper = app.getFileSettingsHelper();
        settingsHelper.collectSettings(file, latestChanges, version, new CollectListener() {

            @Override
            public void onCollectFinished(boolean succeed, boolean empty, @NonNull List<SettingsItem> items) {
                hideProgress();
                if (succeed) {
                    List<SettingsItem> pluginIndependentItems = new ArrayList<>();
                    List<PluginSettingsItem> pluginSettingsItems = new ArrayList<>();
                    for (SettingsItem item : items) {
                        if (item instanceof PluginSettingsItem) {
                            pluginSettingsItems.add((PluginSettingsItem) item);
                        } else if (Algorithms.isEmpty(item.getPluginId())) {
                            pluginIndependentItems.add(item);
                        }
                    }
                    for (PluginSettingsItem pluginItem : pluginSettingsItems) {
                        handlePluginImport(pluginItem, file);
                    }
                    if (!pluginIndependentItems.isEmpty()) {
                        if (settingsTypes == null) {
                            FragmentActivity activity = activityRef.get();
                            if (!silentImport && activity != null) {
                                FragmentManager fragmentManager = activity.getSupportFragmentManager();
                                FileImportSettingsFragment.showInstance(fragmentManager, pluginIndependentItems, file);
                            }
                        } else {
                            Map<ExportSettingsType, List<?>> allSettingsMap = getSettingsToOperate(pluginIndependentItems, false, false);
                            List<SettingsItem> settingsList = settingsHelper.getFilteredSettingsItems(allSettingsMap, settingsTypes, pluginIndependentItems, false);
                            settingsHelper.checkDuplicates(file, settingsList, settingsList, getDuplicatesListener(file, replace));
                        }
                    }
                } else if (empty) {
                    app.showShortToastMessage(app.getString(R.string.file_import_error, name, app.getString(R.string.shared_string_unexpected_error)));
                }
            }
        });
    } else {
        hideProgress();
        app.showShortToastMessage(app.getString(R.string.file_import_error, name, error));
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentActivity(androidx.fragment.app.FragmentActivity) CollectListener(net.osmand.plus.settings.backend.backup.SettingsHelper.CollectListener) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) PluginSettingsItem(net.osmand.plus.settings.backend.backup.items.PluginSettingsItem) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) FileSettingsHelper(net.osmand.plus.settings.backend.backup.FileSettingsHelper) Map(java.util.Map) PluginSettingsItem(net.osmand.plus.settings.backend.backup.items.PluginSettingsItem)

Aggregations

FileSettingsHelper (net.osmand.plus.settings.backend.backup.FileSettingsHelper)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)2 FragmentActivity (androidx.fragment.app.FragmentActivity)1 FragmentManager (androidx.fragment.app.FragmentManager)1 List (java.util.List)1 Map (java.util.Map)1 GPXFile (net.osmand.GPXUtilities.GPXFile)1 OsmandAidlApi (net.osmand.aidl.OsmandAidlApi)1 AGpxFile (net.osmand.aidl.gpx.AGpxFile)1 ASelectedGpxFile (net.osmand.aidl.gpx.ASelectedGpxFile)1 ASqliteDbFile (net.osmand.aidl.tiles.ASqliteDbFile)1 OsmandRegions (net.osmand.map.OsmandRegions)1 MapPoiTypes (net.osmand.osm.MapPoiTypes)1 BackupHelper (net.osmand.plus.backup.BackupHelper)1 NetworkSettingsHelper (net.osmand.plus.backup.NetworkSettingsHelper)1 MapViewTrackingUtilities (net.osmand.plus.base.MapViewTrackingUtilities)1 AnalyticsHelper (net.osmand.plus.helpers.AnalyticsHelper)1 AvoidSpecificRoads (net.osmand.plus.helpers.AvoidSpecificRoads)1