Create different files for different exports

This commit is contained in:
Alexander Sytnyk 2018-01-31 14:09:15 +02:00
parent 7f41c6a542
commit 82722937f7

View file

@ -566,7 +566,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
@Override @Override
public void onClick(int type) { public void onClick(int type) {
List<OsmPoint> points = getPointsToExport(); List<OsmPoint> points = getPointsToExport();
new BackupOpenstreetmapPointAsyncTask(type).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new BackupOpenstreetmapPointAsyncTask(type, exportType).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
points.toArray(new OsmPoint[points.size()])); points.toArray(new OsmPoint[points.size()]));
} }
}; };
@ -705,13 +705,12 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
private File osmchange; private File osmchange;
private boolean oscFile; private boolean oscFile;
public BackupOpenstreetmapPointAsyncTask(int fileType) { public BackupOpenstreetmapPointAsyncTask(int fileType, int exportType) {
OsmandApplication app = (OsmandApplication) getActivity().getApplication(); OsmandApplication app = (OsmandApplication) getActivity().getApplication();
oscFile = fileType == FILE_TYPE_OSC; oscFile = fileType == FILE_TYPE_OSC;
osmchange = app.getAppPath(oscFile ? "poi_modification.osc" : "poi_modifications.gpx"); osmchange = app.getAppPath(getFileName(exportType));
} }
@Override @Override
protected String doInBackground(OsmPoint... points) { protected String doInBackground(OsmPoint... points) {
if (oscFile) { if (oscFile) {
@ -776,6 +775,19 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
return null; return null;
} }
private String getFileName(int exportType) {
StringBuilder sb = new StringBuilder();
if (exportType == EXPORT_TYPE_POI) {
sb.append("osm_edits_modification");
} else if (exportType == EXPORT_TYPE_NOTES) {
sb.append("osm_notes_modification");
} else {
sb.append("osm_modification");
}
sb.append(oscFile ? ".osc" : ".gpx");
return sb.toString();
}
private String getTagsString(OpenstreetmapPoint point) { private String getTagsString(OpenstreetmapPoint point) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String tag : point.getEntity().getTagKeySet()) { for (String tag : point.getEntity().getTagKeySet()) {