Show markers groups in import settings UI

This commit is contained in:
Vitaliy 2020-11-08 17:00:41 +02:00
parent bb10f31f86
commit 4d3ef1fa91
3 changed files with 25 additions and 7 deletions

View file

@ -96,7 +96,7 @@ public class MarkersSettingsItem extends CollectionSettingsItem<MapMarkersGroup>
public boolean isDuplicate(@NonNull MapMarkersGroup markersGroup) {
String name = markersGroup.getName();
for (MapMarkersGroup group : existingItems) {
if (group.getName().equals(name)) {
if (Algorithms.stringsEqual(group.getName(), name)) {
return true;
}
}
@ -139,12 +139,13 @@ public class MarkersSettingsItem extends CollectionSettingsItem<MapMarkersGroup>
@Override
public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException {
// Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile);
// if (error != null) {
// warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
// SettingsHelper.LOG.error("Failed write to gpx file", error);
// return false;
// }
GPXFile gpxFile = generateGpx();
Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile);
if (error != null) {
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
SettingsHelper.LOG.error("Failed write to gpx file", error);
return false;
}
return true;
}
};

View file

@ -32,6 +32,7 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.osmedit.OpenstreetmapPoint;
import net.osmand.plus.osmedit.OsmNotesPoint;
import net.osmand.plus.poi.PoiUIFilter;
@ -200,6 +201,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
List<File> ttsVoiceFilesList = new ArrayList<>();
List<File> voiceFilesList = new ArrayList<>();
List<File> mapFilesList = new ArrayList<>();
List<MapMarkersGroup> markersGroups = new ArrayList<>();
for (Object object : duplicatesList) {
if (object instanceof ApplicationMode.ApplicationModeBean) {
@ -236,6 +238,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
osmNotesPointList.add((OsmNotesPoint) object);
} else if (object instanceof OpenstreetmapPoint) {
osmEditsPointList.add((OpenstreetmapPoint) object);
} else if (object instanceof MapMarkersGroup) {
markersGroups.add((MapMarkersGroup) object);
}
}
if (!profiles.isEmpty()) {
@ -298,6 +302,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
duplicates.add(getString(R.string.local_indexes_cat_voice));
duplicates.addAll(voiceFilesList);
}
if (!markersGroups.isEmpty()) {
duplicates.add(getString(R.string.map_markers));
duplicates.addAll(markersGroups);
}
return duplicates;
}

View file

@ -41,6 +41,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.osmedit.OpenstreetmapPoint;
import net.osmand.plus.osmedit.OsmNotesPoint;
import net.osmand.plus.poi.PoiUIFilter;
@ -49,6 +50,7 @@ import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.plus.settings.backend.ExportSettingsType;
import net.osmand.plus.settings.backend.backup.FavoritesSettingsItem;
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
import net.osmand.plus.settings.backend.backup.MarkersSettingsItem;
import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem;
import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem;
import net.osmand.plus.settings.backend.backup.SettingsHelper;
@ -436,6 +438,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
List<FavoriteGroup> favoriteGroups = new ArrayList<>();
List<MapMarkersGroup> markersGroups = new ArrayList<>();
for (Object object : data) {
if (object instanceof ApplicationModeBean) {
appModeBeans.add((ApplicationModeBean) object);
@ -459,6 +462,8 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
favoriteGroups.add((FavoriteGroup) object);
} else if (object instanceof GlobalSettingsItem) {
settingsItems.add((GlobalSettingsItem) object);
} else if (object instanceof MapMarkersGroup) {
markersGroups.add((MapMarkersGroup) object);
}
}
if (!appModeBeans.isEmpty()) {
@ -490,6 +495,10 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
FavoritesSettingsItem baseItem = getBaseItem(SettingsItemType.FAVOURITES, FavoritesSettingsItem.class);
settingsItems.add(new FavoritesSettingsItem(app, baseItem, favoriteGroups));
}
if (!markersGroups.isEmpty()) {
MarkersSettingsItem baseItem = getBaseItem(SettingsItemType.MARKERS, MarkersSettingsItem.class);
settingsItems.add(new MarkersSettingsItem(app, baseItem, markersGroups));
}
return settingsItems;
}