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