Export OSM Note, OSM Edit
This commit is contained in:
parent
a7af2a3cf0
commit
d676cb3d55
12 changed files with 379 additions and 51 deletions
|
@ -114,6 +114,8 @@ public abstract class Entity implements Serializable {
|
|||
public static final int MODIFY_DELETED = -1;
|
||||
public static final int MODIFY_MODIFIED = 1;
|
||||
public static final int MODIFY_CREATED = 2;
|
||||
public static final String POI_TYPE_TAG = "poi_type_tag";
|
||||
public static final String REMOVE_TAG_PREFIX = "----";
|
||||
|
||||
public Entity(long id) {
|
||||
this.id = id;
|
||||
|
@ -241,6 +243,11 @@ public abstract class Entity implements Serializable {
|
|||
return Collections.unmodifiableMap(tags);
|
||||
}
|
||||
|
||||
public boolean isNotValid(String tag) {
|
||||
String val = getTag(tag);
|
||||
return val == null || val.length() == 0 || tag.length() == 0
|
||||
|| tag.startsWith(REMOVE_TAG_PREFIX) || tag.equals(POI_TYPE_TAG);
|
||||
}
|
||||
|
||||
public Collection<String> getTagKeySet() {
|
||||
if (tags == null) {
|
||||
|
|
|
@ -75,6 +75,20 @@ public class OpenstreetmapPoint extends OsmPoint {
|
|||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getTagsString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String tag : entity.getTagKeySet()) {
|
||||
String val = entity.getTag(tag);
|
||||
if (entity.isNotValid(tag)) {
|
||||
continue;
|
||||
}
|
||||
sb.append(tag).append(" : ");
|
||||
sb.append(val).append("; ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuffer("Openstreetmap Point ").append(this.getAction()).append(" ").append(this.getName())
|
||||
|
|
|
@ -5,17 +5,23 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.Amenity;
|
||||
|
@ -528,6 +534,15 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static SpannableString getTitle(OsmPoint osmPoint, Context ctx) {
|
||||
SpannableString title = new SpannableString(getName(osmPoint));
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
title = SpannableString.valueOf(getCategory(osmPoint, ctx));
|
||||
title.setSpan(new StyleSpan(Typeface.ITALIC), 0, title.length(), 0);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
public static String getName(OsmPoint point) {
|
||||
if (point.getGroup() == OsmPoint.Group.POI) {
|
||||
return ((OpenstreetmapPoint) point).getName();
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -182,7 +178,7 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
|||
|
||||
private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, final int position) {
|
||||
setupBackground(holder.mainView);
|
||||
holder.titleTextView.setText(getTitle(osmEdit));
|
||||
holder.titleTextView.setText(OsmEditingPlugin.getTitle(osmEdit, getContext()));
|
||||
holder.descriptionTextView.setText(getDescription(osmEdit));
|
||||
Drawable icon = getIcon(osmEdit);
|
||||
if (icon != null) {
|
||||
|
@ -243,14 +239,6 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
|||
return items.size();
|
||||
}
|
||||
|
||||
private SpannableString getTitle(OsmPoint osmPoint) {
|
||||
SpannableString title = new SpannableString(OsmEditingPlugin.getName(osmPoint));
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
title = SpannableString.valueOf(getCategory(osmPoint));
|
||||
title.setSpan(new StyleSpan(Typeface.ITALIC), 0, title.length(), 0);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
private Drawable getIcon(OsmPoint point) {
|
||||
if (point.getGroup() == OsmPoint.Group.POI) {
|
||||
|
@ -304,10 +292,6 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
|||
return true;
|
||||
}
|
||||
|
||||
private String getCategory(OsmPoint point) {
|
||||
return OsmEditingPlugin.getCategory(point, getContext());
|
||||
}
|
||||
|
||||
private String getDescription(OsmPoint point) {
|
||||
return OsmEditingPlugin.getDescription(point, getContext(), true);
|
||||
}
|
||||
|
|
|
@ -781,7 +781,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
if (point.getGroup() == Group.POI) {
|
||||
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
|
||||
WptPt wpt = new WptPt();
|
||||
wpt.name = getTagsString(p);
|
||||
wpt.name = p.getTagsString();
|
||||
wpt.lat = p.getLatitude();
|
||||
wpt.lon = p.getLongitude();
|
||||
wpt.desc = "id: " + String.valueOf(p.getId()) +
|
||||
|
@ -817,24 +817,6 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getTagsString(OpenstreetmapPoint point) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String tag : point.getEntity().getTagKeySet()) {
|
||||
String val = point.getEntity().getTag(tag);
|
||||
if (isNotValid(tag, val)) {
|
||||
continue;
|
||||
}
|
||||
sb.append(tag).append(" : ");
|
||||
sb.append(val).append("; ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private boolean isNotValid(String tag, String val) {
|
||||
return val == null || val.length() == 0 || tag.length() == 0
|
||||
|| tag.startsWith(EditPoiData.REMOVE_TAG_PREFIX) || tag.equals("poi_type_tag");
|
||||
}
|
||||
|
||||
private void writeContent(XmlSerializer sz, OsmPoint[] points, OsmPoint.Action a) throws IllegalArgumentException, IllegalStateException, IOException {
|
||||
for (OsmPoint point : points) {
|
||||
if (point.getGroup() == Group.POI) {
|
||||
|
@ -878,7 +860,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
private void writeTags(XmlSerializer sz, Entity p) {
|
||||
for (String tag : p.getTagKeySet()) {
|
||||
String val = p.getTag(tag);
|
||||
if (isNotValid(tag, val)) {
|
||||
if (p.isNotValid(tag)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -12,5 +12,6 @@ public enum ExportSettingsType {
|
|||
FAVORITES,
|
||||
TRACKS,
|
||||
MULTIMEDIA_NOTES,
|
||||
OSM_CHANGES
|
||||
OSM_NOTES,
|
||||
OSM_EDITS
|
||||
}
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
package net.osmand.plus.settings.backend.backup;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.osm.edit.Entity;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmedit.OsmPoint;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OsmEditsSettingsItem extends CollectionSettingsItem<OpenstreetmapPoint> {
|
||||
|
||||
public OsmEditsSettingsItem(@NonNull OsmandApplication app, @NonNull List<OpenstreetmapPoint> items) {
|
||||
super(app, null, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
if (osmEditingPlugin != null) {
|
||||
existingItems = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SettingsItemType getType() {
|
||||
return SettingsItemType.OSM_EDITS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
List<OpenstreetmapPoint> newItems = getNewItems();
|
||||
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
|
||||
appliedItems = new ArrayList<>(newItems);
|
||||
|
||||
for (OpenstreetmapPoint duplicate : duplicateItems) {
|
||||
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDuplicate(@NonNull OpenstreetmapPoint item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public OpenstreetmapPoint renameItem(@NonNull OpenstreetmapPoint item) {
|
||||
return item;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "osm_edits";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPublicName(@NonNull Context ctx) {
|
||||
return ctx.getString(R.string.osm_edits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||
}
|
||||
|
||||
@Override
|
||||
void writeItemsToJson(@NonNull JSONObject json) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if (!items.isEmpty()) {
|
||||
try {
|
||||
for (OpenstreetmapPoint point : items) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", point.getTagsString());
|
||||
jsonObject.put("lat", point.getLatitude());
|
||||
jsonObject.put("lon", point.getLongitude());
|
||||
jsonObject.put("action", OsmPoint.stringAction.get(point.getAction()));
|
||||
jsonArray.put(jsonObject);
|
||||
jsonArray.put(writeTags(point.getEntity()));
|
||||
}
|
||||
json.put("items", jsonArray);
|
||||
} catch (JSONException e) {
|
||||
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
|
||||
SettingsHelper.LOG.error("Failed write to json", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JSONArray writeTags(Entity entity) {
|
||||
JSONArray tagList = new JSONArray();
|
||||
for (String tag : entity.getTagKeySet()) {
|
||||
String val = entity.getTag(tag);
|
||||
if (entity.isNotValid(tag)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
JSONObject tagItem = new JSONObject();
|
||||
tagItem.put("k", tag);
|
||||
tagItem.put("v", val);
|
||||
tagList.put(tagItem);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return tagList;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
SettingsItemReader<? extends SettingsItem> getReader() {
|
||||
return getJsonReader();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
SettingsItemWriter<? extends SettingsItem> getWriter() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package net.osmand.plus.settings.backend.backup;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||
import net.osmand.plus.osmedit.OsmPoint;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OsmNotesSettingsItem extends CollectionSettingsItem<OsmNotesPoint> {
|
||||
|
||||
public OsmNotesSettingsItem(@NonNull OsmandApplication app, @NonNull List<OsmNotesPoint> items) {
|
||||
super(app, null, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
if (osmEditingPlugin != null) {
|
||||
existingItems = osmEditingPlugin.getDBBug().getOsmbugsPoints();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SettingsItemType getType() {
|
||||
return SettingsItemType.OSM_NOTES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
List<OsmNotesPoint> newItems = getNewItems();
|
||||
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
|
||||
appliedItems = new ArrayList<>(newItems);
|
||||
|
||||
for (OsmNotesPoint duplicate : duplicateItems) {
|
||||
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDuplicate(@NonNull OsmNotesPoint item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public OsmNotesPoint renameItem(@NonNull OsmNotesPoint item) {
|
||||
return item;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "osm_notes";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPublicName(@NonNull Context ctx) {
|
||||
return ctx.getString(R.string.osm_notes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||
}
|
||||
|
||||
@Override
|
||||
void writeItemsToJson(@NonNull JSONObject json) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if (!items.isEmpty()) {
|
||||
try {
|
||||
for (OsmNotesPoint point : items) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("text", point.getText());
|
||||
jsonObject.put("lat", point.getLatitude());
|
||||
jsonObject.put("lon", point.getLongitude());
|
||||
jsonObject.put("action", OsmPoint.stringAction.get(point.getAction()));
|
||||
jsonArray.put(jsonObject);
|
||||
}
|
||||
json.put("items", jsonArray);
|
||||
} catch (JSONException e) {
|
||||
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
|
||||
SettingsHelper.LOG.error("Failed write to json", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
SettingsItemReader<? extends SettingsItem> getReader() {
|
||||
return getJsonReader();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
SettingsItemWriter<? extends SettingsItem> getWriter() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,9 @@ import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
|||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
|
@ -505,6 +508,17 @@ public class SettingsHelper {
|
|||
dataList.put(ExportSettingsType.TRACKS, files);
|
||||
}
|
||||
}
|
||||
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
if (osmEditingPlugin != null) {
|
||||
List<OsmNotesPoint> notesPointList = osmEditingPlugin.getDBBug().getOsmbugsPoints();
|
||||
if (!notesPointList.isEmpty()) {
|
||||
dataList.put(ExportSettingsType.OSM_NOTES, notesPointList);
|
||||
}
|
||||
List<OpenstreetmapPoint> editsPointList = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints();
|
||||
if (!editsPointList.isEmpty()) {
|
||||
dataList.put(ExportSettingsType.OSM_EDITS, editsPointList);
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
|
@ -514,6 +528,9 @@ public class SettingsHelper {
|
|||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
|
||||
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
|
||||
|
||||
for (Object object : data) {
|
||||
if (object instanceof QuickAction) {
|
||||
quickActions.add((QuickAction) object);
|
||||
|
@ -529,6 +546,10 @@ public class SettingsHelper {
|
|||
}
|
||||
} else if (object instanceof AvoidRoadInfo) {
|
||||
avoidRoads.add((AvoidRoadInfo) object);
|
||||
} else if (object instanceof OsmNotesPoint) {
|
||||
osmNotesPointList.add((OsmNotesPoint) object);
|
||||
} else if (object instanceof OpenstreetmapPoint) {
|
||||
osmEditsPointList.add((OpenstreetmapPoint) object);
|
||||
}
|
||||
}
|
||||
if (!quickActions.isEmpty()) {
|
||||
|
@ -543,6 +564,12 @@ public class SettingsHelper {
|
|||
if (!avoidRoads.isEmpty()) {
|
||||
settingsItems.add(new AvoidRoadsSettingsItem(app, avoidRoads));
|
||||
}
|
||||
if (!osmNotesPointList.isEmpty()) {
|
||||
settingsItems.add(new OsmNotesSettingsItem(app, osmNotesPointList));
|
||||
}
|
||||
if (!osmEditsPointList.isEmpty()) {
|
||||
settingsItems.add(new OsmEditsSettingsItem(app, osmEditsPointList));
|
||||
}
|
||||
return settingsItems;
|
||||
}
|
||||
|
||||
|
@ -557,6 +584,8 @@ public class SettingsHelper {
|
|||
List<File> multimediaFilesList = new ArrayList<>();
|
||||
List<File> tracksFilesList = new ArrayList<>();
|
||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||
List<OsmNotesPoint> notesPointList = new ArrayList<>();
|
||||
List<OpenstreetmapPoint> editsPointList = new ArrayList<>();
|
||||
for (SettingsItem item : settingsItems) {
|
||||
switch (item.getType()) {
|
||||
case PROFILE:
|
||||
|
@ -606,6 +635,22 @@ public class SettingsHelper {
|
|||
avoidRoads.addAll(avoidRoadsItem.getItems());
|
||||
}
|
||||
break;
|
||||
case OSM_NOTES:
|
||||
OsmNotesSettingsItem osmNotesSettingsItem = (OsmNotesSettingsItem) item;
|
||||
if (importComplete) {
|
||||
notesPointList.addAll(osmNotesSettingsItem.getAppliedItems());
|
||||
} else {
|
||||
notesPointList.addAll(osmNotesSettingsItem.getItems());
|
||||
}
|
||||
break;
|
||||
case OSM_EDITS:
|
||||
OsmEditsSettingsItem osmEditsSettingsItem = (OsmEditsSettingsItem) item;
|
||||
if (importComplete) {
|
||||
editsPointList.addAll(osmEditsSettingsItem.getAppliedItems());
|
||||
} else {
|
||||
editsPointList.addAll(osmEditsSettingsItem.getItems());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -638,6 +683,12 @@ public class SettingsHelper {
|
|||
if (!tracksFilesList.isEmpty()) {
|
||||
settingsToOperate.put(ExportSettingsType.TRACKS, tracksFilesList);
|
||||
}
|
||||
if (!notesPointList.isEmpty()) {
|
||||
settingsToOperate.put(ExportSettingsType.OSM_NOTES, notesPointList);
|
||||
}
|
||||
if (!editsPointList.isEmpty()) {
|
||||
settingsToOperate.put(ExportSettingsType.OSM_NOTES, editsPointList);
|
||||
}
|
||||
return settingsToOperate;
|
||||
}
|
||||
}
|
|
@ -17,5 +17,6 @@ public enum SettingsItemType {
|
|||
FAVORITES,
|
||||
TRACKS,
|
||||
AUDIO_VIDEO_NOTES,
|
||||
OSM_CHANGES
|
||||
OSM_NOTES,
|
||||
OSM_EDITS
|
||||
}
|
|
@ -23,6 +23,9 @@ import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
|||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.profiles.ProfileIconColors;
|
||||
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
|
||||
|
@ -153,6 +156,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
|
||||
TextView title = child.findViewById(R.id.title_tv);
|
||||
TextView subText = child.findViewById(R.id.sub_title_tv);
|
||||
subText.setVisibility(View.GONE);
|
||||
final CheckBox checkBox = child.findViewById(R.id.check_box);
|
||||
ImageView icon = child.findViewById(R.id.icon);
|
||||
View lineDivider = child.findViewById(R.id.divider);
|
||||
|
@ -197,9 +201,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e);
|
||||
}
|
||||
}
|
||||
if (Algorithms.isEmpty(routingProfile)) {
|
||||
subText.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (!Algorithms.isEmpty(routingProfile)) {
|
||||
subText.setText(String.format(
|
||||
app.getString(R.string.ltr_or_rtl_combine_via_colon),
|
||||
app.getString(R.string.nav_type_hint),
|
||||
|
@ -213,38 +215,32 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
case QUICK_ACTIONS:
|
||||
title.setText(((QuickAction) currentItem).getName(app.getApplicationContext()));
|
||||
setupIcon(icon, ((QuickAction) currentItem).getIconRes(), itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case POI_TYPES:
|
||||
title.setText(((PoiUIFilter) currentItem).getName());
|
||||
int iconRes = RenderingIcons.getBigIconResourceId(((PoiUIFilter) currentItem).getIconId());
|
||||
setupIcon(icon, iconRes != 0 ? iconRes : R.drawable.ic_action_user, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case MAP_SOURCES:
|
||||
title.setText(((ITileSource) currentItem).getName());
|
||||
setupIcon(icon, R.drawable.ic_map, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case CUSTOM_RENDER_STYLE:
|
||||
String renderName = ((File) currentItem).getName();
|
||||
renderName = renderName.replace('_', ' ').replaceAll(IndexConstants.RENDERER_INDEX_EXT, "");
|
||||
title.setText(renderName);
|
||||
setupIcon(icon, R.drawable.ic_action_map_style, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case CUSTOM_ROUTING:
|
||||
String routingName = ((File) currentItem).getName();
|
||||
routingName = routingName.replace('_', ' ').replaceAll(".xml", "");
|
||||
title.setText(routingName);
|
||||
setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case AVOID_ROADS:
|
||||
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) currentItem;
|
||||
title.setText(avoidRoadInfo.name);
|
||||
setupIcon(icon, R.drawable.ic_action_alert, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case MULTIMEDIA_NOTES:
|
||||
File file = (File) currentItem;
|
||||
|
@ -254,13 +250,19 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
iconId = R.drawable.ic_action_photo_dark;
|
||||
}
|
||||
setupIcon(icon, iconId, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case TRACKS:
|
||||
String fileName = ((File) currentItem).getName();
|
||||
title.setText(GpxUiHelper.getGpxTitle(fileName));
|
||||
setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected);
|
||||
subText.setVisibility(View.GONE);
|
||||
break;
|
||||
case OSM_NOTES:
|
||||
title.setText(((OsmNotesPoint) currentItem).getText());
|
||||
setupIcon(icon, R.drawable.ic_action_osm_note_add, itemSelected);
|
||||
break;
|
||||
case OSM_EDITS:
|
||||
title.setText(OsmEditingPlugin.getTitle((OpenstreetmapPoint) currentItem, app));
|
||||
setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected);
|
||||
break;
|
||||
default:
|
||||
return child;
|
||||
|
@ -338,6 +340,10 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
return R.string.shared_string_tracks;
|
||||
case MULTIMEDIA_NOTES:
|
||||
return R.string.audionotes_plugin_name;
|
||||
case OSM_NOTES:
|
||||
return R.string.osm_notes;
|
||||
case OSM_EDITS:
|
||||
return R.string.osm_edit_modified_poi;
|
||||
default:
|
||||
return R.string.access_empty_list;
|
||||
}
|
||||
|
@ -377,4 +383,4 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
List<? super Object> getData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -114,6 +114,14 @@ public class ImportedSettingsItemsAdapter extends
|
|||
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
|
||||
holder.title.setText(R.string.shared_string_tracks);
|
||||
break;
|
||||
case OSM_NOTES:
|
||||
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_osm_note_add, activeColorRes));
|
||||
holder.title.setText(R.string.osm_notes);
|
||||
break;
|
||||
case OSM_EDITS:
|
||||
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_info_dark, activeColorRes));
|
||||
holder.title.setText(R.string.osm_edit_modified_poi);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue