Search in sources :

Example 6 with ExportSettingsType

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

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

the class ImportHelper method handleOsmAndSettingsImport.

private void handleOsmAndSettingsImport(Uri intentUri, String fileName, Bundle extras, CallbackWithObject<List<SettingsItem>> callback) {
    fileName = fileName.replace(IndexConstants.ZIP_EXT, "");
    if (extras != null && extras.containsKey(SettingsHelper.SETTINGS_VERSION_KEY) && extras.containsKey(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY)) {
        int version = extras.getInt(SettingsHelper.SETTINGS_VERSION_KEY, -1);
        String latestChanges = extras.getString(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY);
        boolean replace = extras.getBoolean(REPLACE_KEY);
        boolean silentImport = extras.getBoolean(SILENT_IMPORT_KEY);
        ArrayList<String> settingsTypeKeys = extras.getStringArrayList(SETTINGS_TYPE_LIST_KEY);
        List<ExportSettingsType> settingsTypes = null;
        if (settingsTypeKeys != null) {
            settingsTypes = new ArrayList<>();
            for (String key : settingsTypeKeys) {
                settingsTypes.add(ExportSettingsType.valueOf(key));
            }
        }
        handleOsmAndSettingsImport(intentUri, fileName, settingsTypes, replace, silentImport, latestChanges, version, callback);
    } else {
        handleOsmAndSettingsImport(intentUri, fileName, null, false, false, null, -1, callback);
    }
}
Also used : FavouritePoint(net.osmand.data.FavouritePoint) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 8 with ExportSettingsType

use of net.osmand.plus.settings.backend.ExportSettingsType 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);
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 9 with ExportSettingsType

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

the class BaseBackupTypesFragment method getDataList.

protected Map<ExportSettingsCategory, SettingsCategoryItems> getDataList() {
    Map<String, RemoteFile> remoteFiles = backupHelper.getBackup().getRemoteFiles(getRemoteFilesType());
    if (remoteFiles == null) {
        remoteFiles = Collections.emptyMap();
    }
    Map<ExportSettingsType, List<?>> settingsToOperate = new EnumMap<>(ExportSettingsType.class);
    for (ExportSettingsType type : ExportSettingsType.getEnabledTypes()) {
        List<RemoteFile> filesByType = new ArrayList<>();
        for (RemoteFile remoteFile : remoteFiles.values()) {
            if (ExportSettingsType.getExportSettingsTypeForRemoteFile(remoteFile) == type) {
                filesByType.add(remoteFile);
            }
        }
        settingsToOperate.put(type, filesByType);
    }
    return SettingsHelper.getSettingsToOperateByCategory(settingsToOperate, true);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) EnumMap(java.util.EnumMap) RemoteFile(net.osmand.plus.backup.RemoteFile) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 10 with ExportSettingsType

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

the class BackupExporter method markOldFileForDeletion.

private void markOldFileForDeletion(@NonNull SettingsItem item, @NonNull String fileName) {
    String type = item.getType().name();
    ExportSettingsType exportType = ExportSettingsType.getExportSettingsTypeForItem(item);
    if (exportType != null && !backupHelper.getVersionHistoryTypePref(exportType).get()) {
        RemoteFile remoteFile = backupHelper.getBackup().getRemoteFile(type, fileName);
        if (remoteFile != null) {
            oldFilesToDelete.add(remoteFile);
        }
    }
}
Also used : 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