From d676cb3d5536c09c93b3109a7188dea5f7ba6708 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 16 Oct 2020 19:21:03 +0300 Subject: [PATCH] Export OSM Note, OSM Edit --- .../main/java/net/osmand/osm/edit/Entity.java | 7 + .../plus/osmedit/OpenstreetmapPoint.java | 14 ++ .../osmand/plus/osmedit/OsmEditingPlugin.java | 15 ++ .../osmand/plus/osmedit/OsmEditsAdapter.java | 18 +-- .../osmand/plus/osmedit/OsmEditsFragment.java | 22 +-- .../settings/backend/ExportSettingsType.java | 3 +- .../backend/backup/OsmEditsSettingsItem.java | 140 ++++++++++++++++++ .../backend/backup/OsmNotesSettingsItem.java | 119 +++++++++++++++ .../backend/backup/SettingsHelper.java | 51 +++++++ .../backend/backup/SettingsItemType.java | 3 +- .../ExportImportSettingsAdapter.java | 30 ++-- .../ImportedSettingsItemsAdapter.java | 8 + 12 files changed, 379 insertions(+), 51 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java create mode 100644 OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/edit/Entity.java b/OsmAnd-java/src/main/java/net/osmand/osm/edit/Entity.java index 6005f85035..7bb8edbf49 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/edit/Entity.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/edit/Entity.java @@ -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 getTagKeySet() { if (tags == null) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java index 69bc753ab4..7e7a35d6f1 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java @@ -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()) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 5030530f88..ec774134e5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -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(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java index f965318109..92159c49df 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java @@ -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 { 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 { 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 { return true; } - private String getCategory(OsmPoint point) { - return OsmEditingPlugin.getCategory(point, getContext()); - } - private String getDescription(OsmPoint point) { return OsmEditingPlugin.getDescription(point, getContext(), true); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index f39b695d50..40f62e55b6 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -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 { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java index 79e35ffdf8..1b4231b873 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java @@ -12,5 +12,6 @@ public enum ExportSettingsType { FAVORITES, TRACKS, MULTIMEDIA_NOTES, - OSM_CHANGES + OSM_NOTES, + OSM_EDITS } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java new file mode 100644 index 0000000000..1eb1e25393 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -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 { + + public OsmEditsSettingsItem(@NonNull OsmandApplication app, @NonNull List 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 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 getReader() { + return getJsonReader(); + } + + @Nullable + @Override + SettingsItemWriter getWriter() { + return null; + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java new file mode 100644 index 0000000000..500d70f426 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java @@ -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 { + + public OsmNotesSettingsItem(@NonNull OsmandApplication app, @NonNull List 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 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 getReader() { + return getJsonReader(); + } + + @Nullable + @Override + SettingsItemWriter getWriter() { + return null; + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index 530147b84f..c8d116241c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -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 notesPointList = osmEditingPlugin.getDBBug().getOsmbugsPoints(); + if (!notesPointList.isEmpty()) { + dataList.put(ExportSettingsType.OSM_NOTES, notesPointList); + } + List editsPointList = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints(); + if (!editsPointList.isEmpty()) { + dataList.put(ExportSettingsType.OSM_EDITS, editsPointList); + } + } return dataList; } @@ -514,6 +528,9 @@ public class SettingsHelper { List poiUIFilters = new ArrayList<>(); List tileSourceTemplates = new ArrayList<>(); List avoidRoads = new ArrayList<>(); + List osmNotesPointList = new ArrayList<>(); + List 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 multimediaFilesList = new ArrayList<>(); List tracksFilesList = new ArrayList<>(); List avoidRoads = new ArrayList<>(); + List notesPointList = new ArrayList<>(); + List 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; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java index 163e457e58..051f122c2e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -17,5 +17,6 @@ public enum SettingsItemType { FAVORITES, TRACKS, AUDIO_VIDEO_NOTES, - OSM_CHANGES + OSM_NOTES, + OSM_EDITS } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java index eac1917850..c1ca0fb590 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java @@ -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 getData() { return this.data; } -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java index 57198c2f04..7acd88ee4b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java @@ -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; } }