From d676cb3d5536c09c93b3109a7188dea5f7ba6708 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 16 Oct 2020 19:21:03 +0300 Subject: [PATCH 01/31] 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; } } From 4021d38635b9c17257a885dc9b3ff5c51b25120e Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Mon, 19 Oct 2020 18:36:13 +0300 Subject: [PATCH 02/31] Import OSM Note --- .../backend/backup/OsmEditsSettingsItem.java | 26 ++++++-- .../backend/backup/OsmNotesSettingsItem.java | 62 +++++++++++++++++-- .../backend/backup/SettingsHelper.java | 2 +- .../backend/backup/SettingsItemsFactory.java | 6 ++ .../fragments/ImportSettingsFragment.java | 28 +++++++++ 5 files changed, 115 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java index 1eb1e25393..3d84d23487 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -22,10 +22,26 @@ import java.util.List; public class OsmEditsSettingsItem extends CollectionSettingsItem { + public static final String ID_KEY = "id"; + public static final String NAME_KEY = "name"; + public static final String LAT_KEY = "lat"; + public static final String LON_KEY = "lon"; + public static final String COMMENT_KEY = "comment"; + public static final String ACTION_KEY = "action"; + public OsmEditsSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { super(app, null, items); } + public OsmEditsSettingsItem(@NonNull OsmandApplication app, @Nullable OsmEditsSettingsItem baseItem, + @NonNull List items) { + super(app, baseItem, items); + } + + public OsmEditsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + super(app, json); + } + @Override protected void init() { super.init(); @@ -92,10 +108,12 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem { + public static final String ID_KEY = "id"; + public static final String TEXT_KEY = "text"; + public static final String LAT_KEY = "lat"; + public static final String LON_KEY = "lon"; + public static final String AUTHOR_KEY = "author"; + public static final String ACTION_KEY = "action"; + public OsmNotesSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { super(app, null, items); } + public OsmNotesSettingsItem(@NonNull OsmandApplication app, @Nullable OsmNotesSettingsItem baseItem, + @NonNull List items) { + super(app, baseItem, items); + } + + public OsmNotesSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + super(app, json); + } + @Override protected void init() { super.init(); @@ -49,6 +66,14 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem for (OsmNotesPoint duplicate : duplicateItems) { appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); } + OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + OsmBugsDbHelper db; + if (osmEditingPlugin != null) { + db = osmEditingPlugin.getDBBug(); + for (OsmNotesPoint point : appliedItems) { + db.addOsmbugs(point); + } + } } } @@ -82,6 +107,33 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem @Override void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException { + try { + if (!json.has("items")) { + return; + } + JSONArray jsonArray = json.getJSONArray("items"); + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject object = jsonArray.getJSONObject(i); + long id = object.getLong(ID_KEY); + String text = object.optString(TEXT_KEY); + double lat = object.getDouble(LAT_KEY); + double lon = object.getDouble(LON_KEY); + String author = object.optString(AUTHOR_KEY, null); + String action = object.getString(ACTION_KEY); + + OsmNotesPoint point = new OsmNotesPoint(); + point.setId(id); + point.setText(text); + point.setLatitude(lat); + point.setLongitude(lon); + point.setAuthor(author); + point.setAction(action); + items.add(point); + } + } catch (JSONException e) { + warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); + throw new IllegalArgumentException("Json parse error", e); + } } @Override @@ -91,10 +143,12 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem 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())); + jsonObject.put(ID_KEY, point.getId()); + jsonObject.put(TEXT_KEY, point.getText()); + jsonObject.put(LAT_KEY, point.getLatitude()); + jsonObject.put(LON_KEY, point.getLongitude()); + jsonObject.put(AUTHOR_KEY, point.getAuthor()); + jsonObject.put(ACTION_KEY, OsmPoint.stringAction.get(point.getAction())); jsonArray.put(jsonObject); } json.put("items", jsonArray); 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 c8d116241c..7bcb692058 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -687,7 +687,7 @@ public class SettingsHelper { settingsToOperate.put(ExportSettingsType.OSM_NOTES, notesPointList); } if (!editsPointList.isEmpty()) { - settingsToOperate.put(ExportSettingsType.OSM_NOTES, editsPointList); + settingsToOperate.put(ExportSettingsType.OSM_EDITS, editsPointList); } return settingsToOperate; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java index d4a639da4d..8545b37503 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java @@ -125,6 +125,12 @@ class SettingsItemsFactory { case DOWNLOADS: item = new DownloadsItem(app, json); break; + case OSM_NOTES: + item = new OsmNotesSettingsItem(app, json); + break; + case OSM_EDITS: + item = new OsmEditsSettingsItem(app, json); + break; } return item; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index 6002c8a58e..b564f733cf 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -38,10 +38,14 @@ 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.osmedit.OpenstreetmapPoint; +import net.osmand.plus.osmedit.OsmNotesPoint; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.plus.settings.backend.ExportSettingsType; +import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem; +import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem; import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem; import net.osmand.plus.settings.backend.backup.FileSettingsItem; @@ -374,6 +378,16 @@ public class ImportSettingsFragment extends BaseOsmAndFragment return null; } + @Nullable + private T getBaseItem(SettingsItemType settingsItemType, Class clazz) { + for (SettingsItem settingsItem : settingsItems) { + if (settingsItem.getType() == settingsItemType && clazz.isInstance(settingsItem)) { + return clazz.cast(settingsItem); + } + } + return null; + } + private List getSettingsItemsFromData(List data) { List settingsItems = new ArrayList<>(); List appModeBeans = new ArrayList<>(); @@ -381,6 +395,8 @@ public class ImportSettingsFragment extends BaseOsmAndFragment 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 ApplicationModeBean) { appModeBeans.add((ApplicationModeBean) object); @@ -394,6 +410,10 @@ public class ImportSettingsFragment extends BaseOsmAndFragment settingsItems.add(new FileSettingsItem(app, (File) object)); } 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 (!appModeBeans.isEmpty()) { @@ -413,6 +433,14 @@ public class ImportSettingsFragment extends BaseOsmAndFragment if (!avoidRoads.isEmpty()) { settingsItems.add(new AvoidRoadsSettingsItem(app, getBaseAvoidRoadsSettingsItem(), avoidRoads)); } + if (!osmNotesPointList.isEmpty()) { + OsmNotesSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_NOTES, OsmNotesSettingsItem.class); + settingsItems.add(new OsmNotesSettingsItem(app, baseItem, osmNotesPointList)); + } + if (!osmEditsPointList.isEmpty()) { + OsmEditsSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_EDITS, OsmEditsSettingsItem.class); + settingsItems.add(new OsmEditsSettingsItem(app, baseItem, osmEditsPointList)); + } return settingsItems; } From 1d6a0b39b7ca8b5e229551bdd814d54bb129c000 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 20 Oct 2020 18:48:41 +0300 Subject: [PATCH 03/31] Import OSM Edit --- .../backend/backup/OsmEditsSettingsItem.java | 70 +++++++++++-------- .../backend/backup/OsmNotesSettingsItem.java | 4 +- .../fragments/ImportCompleteFragment.java | 10 +++ 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java index 3d84d23487..f0af94a009 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -6,6 +6,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import net.osmand.osm.edit.Entity; +import net.osmand.osm.edit.Node; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; @@ -28,6 +29,9 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem items) { super(app, null, items); @@ -99,6 +103,32 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem getReader() { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java index 3288aa5a20..c90e44b45e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java @@ -118,9 +118,9 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem String text = object.optString(TEXT_KEY); double lat = object.getDouble(LAT_KEY); double lon = object.getDouble(LON_KEY); - String author = object.optString(AUTHOR_KEY, null); + String author = object.optString(AUTHOR_KEY); + author = author.isEmpty() ? null : author; String action = object.getString(ACTION_KEY); - OsmNotesPoint point = new OsmNotesPoint(); point.setId(id); point.setText(text); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java index 27278775f0..f11df23d09 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java @@ -1,6 +1,7 @@ package net.osmand.plus.settings.fragments; import android.app.Activity; +import android.content.Intent; import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; @@ -31,6 +32,7 @@ import net.osmand.plus.quickaction.QuickActionListFragment; import net.osmand.plus.routepreparationmenu.AvoidRoadsBottomSheetDialogFragment; import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.settings.backend.ExportSettingsType; +import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.backend.backup.SettingsItem; @@ -187,6 +189,14 @@ public class ImportCompleteFragment extends BaseOsmAndFragment { case AVOID_ROADS: new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG); break; + case OSM_NOTES: + case OSM_EDITS: + OsmAndAppCustomization appCustomization = app.getAppCustomization(); + final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity()); + favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + app.getSettings().FAVORITES_TAB.set(R.string.osm_edits); + startActivity(favorites); + break; default: break; } From d89d48474ad37ab00dc0016234c3369b7587a2f5 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 21 Oct 2020 15:41:36 +0300 Subject: [PATCH 04/31] Import OSM Edit tags --- .../backend/backup/OsmEditsSettingsItem.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java index f0af94a009..e2c06d14d6 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -5,12 +5,16 @@ import android.content.Context; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.Node; 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.OpenstreetmapsDbHelper; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmPoint; @@ -19,7 +23,9 @@ import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class OsmEditsSettingsItem extends CollectionSettingsItem { @@ -71,6 +77,14 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem tagMap = new Gson().fromJson( + tags, new TypeToken>() { + }.getType() + ); String action = entityJson.getString(ACTION_KEY); Entity entity; entity = new Node(lat, lon, id); + entity.replaceTags(tagMap); OpenstreetmapPoint point = new OpenstreetmapPoint(); point.setComment(comment); point.setEntity(entity); @@ -144,7 +164,8 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem Date: Thu, 22 Oct 2020 11:29:41 +0300 Subject: [PATCH 05/31] Import/export offline maps --- .../settings/backend/ExportSettingsType.java | 3 +- .../backend/backup/SettingsHelper.java | 30 +++++++++++++ .../backend/backup/SettingsItemType.java | 3 +- .../ExportImportSettingsAdapter.java | 7 +++ .../fragments/ImportSettingsFragment.java | 43 +++++++++++++++++++ 5 files changed, 84 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java index 1b4231b873..d6718d9579 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java @@ -13,5 +13,6 @@ public enum ExportSettingsType { TRACKS, MULTIMEDIA_NOTES, OSM_NOTES, - OSM_EDITS + OSM_EDITS, + OFFLINE_MAPS } 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 7bcb692058..e7d30ce30f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -16,8 +16,11 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.SQLiteTileSource; +import net.osmand.plus.activities.LocalIndexHelper; +import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording; +import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; @@ -519,9 +522,30 @@ public class SettingsHelper { dataList.put(ExportSettingsType.OSM_EDITS, editsPointList); } } + List files = getLocalMapFiles(); + if (!files.isEmpty()) { + dataList.put(ExportSettingsType.OFFLINE_MAPS, files); + } return dataList; } + private List getLocalMapFiles() { + List files = new ArrayList<>(); + LocalIndexHelper helper = new LocalIndexHelper(app); + List localMapFileList = helper.getLocalFullMaps(new AbstractLoadLocalIndexTask() { + @Override + public void loadFile(LocalIndexInfo... loaded) { + } + }); + for (LocalIndexInfo map : localMapFileList) { + File file = new File(map.getPathToData()); + if (file != null && file.exists()) { + files.add(file); + } + } + return files; + } + public List prepareAdditionalSettingsItems(List data) { List settingsItems = new ArrayList<>(); List quickActions = new ArrayList<>(); @@ -583,6 +607,7 @@ public class SettingsHelper { List renderFilesList = new ArrayList<>(); List multimediaFilesList = new ArrayList<>(); List tracksFilesList = new ArrayList<>(); + List mapFilesList = new ArrayList<>(); List avoidRoads = new ArrayList<>(); List notesPointList = new ArrayList<>(); List editsPointList = new ArrayList<>(); @@ -601,6 +626,8 @@ public class SettingsHelper { multimediaFilesList.add(fileItem.getFile()); } else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.GPX) { tracksFilesList.add(fileItem.getFile()); + } else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.OBF_MAP) { + mapFilesList.add(fileItem.getFile()); } break; case QUICK_ACTIONS: @@ -689,6 +716,9 @@ public class SettingsHelper { if (!editsPointList.isEmpty()) { settingsToOperate.put(ExportSettingsType.OSM_EDITS, editsPointList); } + if (!mapFilesList.isEmpty()) { + settingsToOperate.put(ExportSettingsType.OFFLINE_MAPS, mapFilesList); + } 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 051f122c2e..d931e5a5c4 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -18,5 +18,6 @@ public enum SettingsItemType { TRACKS, AUDIO_VIDEO_NOTES, OSM_NOTES, - OSM_EDITS + OSM_EDITS, + OFFLINE_MAPS } \ 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 c1ca0fb590..8fa7c93a14 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java @@ -264,6 +264,11 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { title.setText(OsmEditingPlugin.getTitle((OpenstreetmapPoint) currentItem, app)); setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected); break; + case OFFLINE_MAPS: + file = (File) currentItem; + title.setText(file.getName()); + setupIcon(icon, R.drawable.ic_map, itemSelected); + break; default: return child; } @@ -344,6 +349,8 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { return R.string.osm_notes; case OSM_EDITS: return R.string.osm_edit_modified_poi; + case OFFLINE_MAPS: + return R.string.download_regular_maps; default: return R.string.access_empty_list; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index b564f733cf..52a85fee11 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.graphics.Typeface; +import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.text.style.StyleSpan; @@ -27,6 +28,7 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.appbar.CollapsingToolbarLayout; import net.osmand.AndroidUtils; +import net.osmand.IProgress; import net.osmand.PlatformUtil; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager.TileSourceTemplate; @@ -63,11 +65,14 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; import java.io.File; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype.*; + public class ImportSettingsFragment extends BaseOsmAndFragment implements View.OnClickListener { @@ -271,6 +276,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment if (succeed) { app.getRendererRegistry().updateExternalRenderers(); AppInitializer.loadRoutingFiles(app, null); + reloadIndexes(items); if (fm != null && file != null) { ImportCompleteFragment.showInstance(fm, items, file.getName()); } @@ -279,6 +285,43 @@ public class ImportSettingsFragment extends BaseOsmAndFragment }; } + private void reloadIndexes(@NonNull List items) { + for (SettingsItem item : items) { + if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype() == OBF_MAP) { + Activity activity = getActivity(); + if (activity instanceof MapActivity) { + new ReloadIndexesTack((MapActivity) activity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + break; + } + } + } + + private static class ReloadIndexesTack extends AsyncTask { + + private final WeakReference mapActivityRef; + private final OsmandApplication app; + + ReloadIndexesTack(@NonNull MapActivity mapActivity) { + this.mapActivityRef = new WeakReference<>(mapActivity); + this.app = mapActivity.getMyApplication(); + } + + @Override + protected Void doInBackground(Void[] params) { + app.getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS, new ArrayList()); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + MapActivity mapActivity = mapActivityRef.get(); + if (mapActivity != null) { + mapActivity.refreshMap(); + } + } + } + private SettingsHelper.CheckDuplicatesListener getDuplicatesListener() { return new SettingsHelper.CheckDuplicatesListener() { @Override From e2cf56dd85f17d0bd00d25a2cf6b42bbba97a6ea Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Mon, 26 Oct 2020 18:16:57 +0200 Subject: [PATCH 06/31] temp --- OsmAnd/res/layout/follow_track_options.xml | 22 +++++++ .../FollowTrackFragment.java | 64 ++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/layout/follow_track_options.xml b/OsmAnd/res/layout/follow_track_options.xml index 60c6a885b3..7e7843d510 100644 --- a/OsmAnd/res/layout/follow_track_options.xml +++ b/OsmAnd/res/layout/follow_track_options.xml @@ -55,6 +55,20 @@ android:textSize="@dimen/default_list_text_size" osmand:typeface="@string/font_roboto_medium" /> + + + @@ -81,6 +95,14 @@ android:orientation="vertical" android:paddingBottom="@dimen/dialog_button_ex_height"> + + diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 8537c8df7a..fcfa4ab68f 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -24,12 +24,16 @@ import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.fragment.app.FragmentManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; +import net.osmand.Collator; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.WptPt; import net.osmand.IndexConstants; +import net.osmand.OsmAndCollator; import net.osmand.PlatformUtil; import net.osmand.ValueHolder; import net.osmand.data.QuadRect; @@ -37,6 +41,7 @@ import net.osmand.data.RotatedTileBox; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.SimplePopUpMenuItemAdapter; import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.activities.MapActivity; @@ -44,6 +49,7 @@ import net.osmand.plus.base.ContextMenuScrollFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.helpers.enums.TracksSortByMode; import net.osmand.plus.importfiles.ImportHelper; import net.osmand.plus.importfiles.ImportHelper.OnGpxImportCompleteListener; import net.osmand.plus.measurementtool.GpxData; @@ -71,6 +77,9 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; @@ -89,10 +98,12 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca private GPXFile gpxFile; private View buttonsShadow; + protected boolean nightMode; private boolean editingTrack; private boolean selectingTrack; private int menuTitleHeight; + TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; @Override public int getMainLayoutId() { @@ -151,6 +162,36 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) { + final ImageButton sortButton = view.findViewById(R.id.sort_button); + Drawable background = app.getUIUtilities().getIcon(R.drawable.bg_dash_line_dark, + nightMode + ? R.color.inactive_buttons_and_links_bg_dark + : R.color.inactive_buttons_and_links_bg_light); + sortButton.setImageResource(sortByMode.getIconId()); + AndroidUtils.setBackground(sortButton, background); + sortButton.setVisibility(View.VISIBLE); + final RecyclerView filesRecyclerView = view.findViewById(R.id.gpx_track_list); + filesRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + sortButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + final List items = new ArrayList<>(); + for (final TracksSortByMode mode : TracksSortByMode.values()) { + items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( + getString(mode.getNameId()), + app.getUIUtilities().getThemedIcon(mode.getIconId()), + new View.OnClickListener() { + @Override + public void onClick(View v) { + sortByMode = mode; + sortGPXInfoItems(list); + } + }, sortByMode == mode + )); + } + UiUtilities.showPopUpMenu(v, items); + } + }); ImageButton closeButton = view.findViewById(R.id.close_button); buttonsShadow = view.findViewById(R.id.buttons_shadow); closeButton.setImageDrawable(getContentIcon(AndroidUtils.getNavigationIconResId(app))); @@ -204,7 +245,6 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca if (gpxFile == null || selectingTrack) { ImportTrackCard importTrackCard = new ImportTrackCard(mapActivity); importTrackCard.setListener(this); - cardsContainer.addView(importTrackCard.build(mapActivity)); setupTracksCard(); } else { @@ -264,6 +304,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca List selectedTrackNames = GpxUiHelper.getSelectedTrackPaths(app); List list = GpxUiHelper.getSortedGPXFilesInfo(dir, selectedTrackNames, false); if (list.size() > 0) { + sortGPXInfoItems(list); String defaultCategory = app.getString(R.string.shared_string_all); TracksToFollowCard tracksCard = new TracksToFollowCard(mapActivity, list, defaultCategory); tracksCard.setListener(FollowTrackFragment.this); @@ -272,6 +313,27 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } } + public void sortGPXInfoItems(List gpxInfoList) { + final Collator collator = OsmAndCollator.primaryCollator(); + Collections.sort(gpxInfoList, new Comparator() { + @Override + public int compare(GPXInfo i1, GPXInfo i2) { + if (sortByMode == TracksSortByMode.BY_NAME_ASCENDING) { + return collator.compare(i1.getFileName(), i2.getFileName()); + } else if (sortByMode == TracksSortByMode.BY_NAME_DESCENDING) { + return -collator.compare(i1.getFileName(), i2.getFileName()); + } else { + long time1 = i1.getLastModified(); + long time2 = i2.getLastModified(); + if (time1 == time2) { + return collator.compare(i1.getFileName(), i2.getFileName()); + } + return -((time1 < time2) ? -1 : ((time1 == time2) ? 0 : 1)); + } + } + }); + } + private void setupNavigateOptionsCard(GPXRouteParamsBuilder rparams) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { From bee69a9a187bc6671f43bda0b7fcfe4c04693c94 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Mon, 26 Oct 2020 18:18:38 +0200 Subject: [PATCH 07/31] 2 --- .../osmand/plus/routepreparationmenu/FollowTrackFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index fcfa4ab68f..a6411f2c46 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -184,7 +184,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca @Override public void onClick(View v) { sortByMode = mode; - sortGPXInfoItems(list); + setupTracksCard(); } }, sortByMode == mode )); From 62995c120fa4d9fff48c49d72546edf37ffc4078 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Tue, 27 Oct 2020 10:04:17 +0200 Subject: [PATCH 08/31] update card --- .../osmand/plus/routepreparationmenu/FollowTrackFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index a6411f2c46..b8446e9ac7 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -184,7 +184,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca @Override public void onClick(View v) { sortByMode = mode; - setupTracksCard(); + setupCards(); } }, sortByMode == mode )); From 06ecfe7e8c5de2d667f6762d5d3a970b2431f395 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Tue, 27 Oct 2020 12:25:21 +0200 Subject: [PATCH 09/31] redo --- .../FollowTrackFragment.java | 33 +++++---------- .../cards/TracksToFollowCard.java | 40 ++++++++++++++++++- 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index b8446e9ac7..6184c6bd54 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -99,6 +99,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca private View buttonsShadow; protected boolean nightMode; + private TracksToFollowCard tracksCard; private boolean editingTrack; private boolean selectingTrack; @@ -184,7 +185,13 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca @Override public void onClick(View v) { sortByMode = mode; - setupCards(); + sortButton.setImageResource(mode.getIconId()); + if (tracksCard != null) { + List list = tracksCard.getGpxInfoList(); + tracksCard.setSortByMode(mode); + tracksCard.setGpxInfoList(list); + + } } }, sortByMode == mode )); @@ -304,35 +311,15 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca List selectedTrackNames = GpxUiHelper.getSelectedTrackPaths(app); List list = GpxUiHelper.getSortedGPXFilesInfo(dir, selectedTrackNames, false); if (list.size() > 0) { - sortGPXInfoItems(list); String defaultCategory = app.getString(R.string.shared_string_all); - TracksToFollowCard tracksCard = new TracksToFollowCard(mapActivity, list, defaultCategory); + tracksCard = new TracksToFollowCard(mapActivity, list, defaultCategory); tracksCard.setListener(FollowTrackFragment.this); getCardsContainer().addView(tracksCard.build(mapActivity)); } } } - public void sortGPXInfoItems(List gpxInfoList) { - final Collator collator = OsmAndCollator.primaryCollator(); - Collections.sort(gpxInfoList, new Comparator() { - @Override - public int compare(GPXInfo i1, GPXInfo i2) { - if (sortByMode == TracksSortByMode.BY_NAME_ASCENDING) { - return collator.compare(i1.getFileName(), i2.getFileName()); - } else if (sortByMode == TracksSortByMode.BY_NAME_DESCENDING) { - return -collator.compare(i1.getFileName(), i2.getFileName()); - } else { - long time1 = i1.getLastModified(); - long time2 = i2.getLastModified(); - if (time1 == time2) { - return collator.compare(i1.getFileName(), i2.getFileName()); - } - return -((time1 < time2) ? -1 : ((time1 == time2) ? 0 : 1)); - } - } - }); - } + private void setupNavigateOptionsCard(GPXRouteParamsBuilder rparams) { MapActivity mapActivity = getMapActivity(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java index c21b508116..c6cfe7247d 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java @@ -3,16 +3,21 @@ package net.osmand.plus.routepreparationmenu.cards; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import net.osmand.Collator; import net.osmand.IndexConstants; +import net.osmand.OsmAndCollator; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxTrackAdapter; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.helpers.enums.TracksSortByMode; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.util.Algorithms; import java.io.File; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -25,6 +30,11 @@ public class TracksToFollowCard extends BaseCard { private String selectedCategory; private String defaultCategory; private String visibleCategory; + TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; + + public void setSortByMode(TracksSortByMode sortByMode) { + this.sortByMode = sortByMode; + } private GpxTrackAdapter tracksAdapter; @@ -34,18 +44,24 @@ public class TracksToFollowCard extends BaseCard { this.selectedCategory = selectedCategory; defaultCategory = app.getString(R.string.shared_string_all); visibleCategory = app.getString(R.string.shared_string_visible); + sortGPXInfoItems(gpxInfoList); gpxInfoCategories = getGpxInfoCategories(); } public void setGpxInfoList(List gpxInfoList) { this.gpxInfoList = gpxInfoList; + sortGPXInfoItems(gpxInfoList); gpxInfoCategories = getGpxInfoCategories(); + List items = gpxInfoCategories.get(selectedCategory); + tracksAdapter.setGpxInfoList(items != null ? items : new ArrayList()); + tracksAdapter.notifyDataSetChanged(); } public List getGpxInfoList() { return gpxInfoList; } + public String getSelectedCategory() { return selectedCategory; } @@ -141,4 +157,26 @@ public class TracksToFollowCard extends BaseCard { } items.add(info); } -} \ No newline at end of file + + public void sortGPXInfoItems(List gpxInfoList) { + final Collator collator = OsmAndCollator.primaryCollator(); + Collections.sort(gpxInfoList, new Comparator() { + @Override + public int compare(GPXInfo i1, GPXInfo i2) { + if (sortByMode == TracksSortByMode.BY_NAME_ASCENDING) { + return collator.compare(i1.getFileName(), i2.getFileName()); + } else if (sortByMode == TracksSortByMode.BY_NAME_DESCENDING) { + return -collator.compare(i1.getFileName(), i2.getFileName()); + } else { + long time1 = i1.getLastModified(); + long time2 = i2.getLastModified(); + if (time1 == time2) { + return collator.compare(i1.getFileName(), i2.getFileName()); + } + return -((time1 < time2) ? -1 : ((time1 == time2) ? 0 : 1)); + } + } + }); + } +} + From 040616144d7ac9e9b5bf003c59dddc5875142d9c Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Tue, 27 Oct 2020 13:01:16 +0200 Subject: [PATCH 10/31] fix icon colors --- .../osmand/plus/routepreparationmenu/FollowTrackFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 6184c6bd54..f304123de8 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -98,7 +98,6 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca private GPXFile gpxFile; private View buttonsShadow; - protected boolean nightMode; private TracksToFollowCard tracksCard; private boolean editingTrack; @@ -165,7 +164,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca if (view != null) { final ImageButton sortButton = view.findViewById(R.id.sort_button); Drawable background = app.getUIUtilities().getIcon(R.drawable.bg_dash_line_dark, - nightMode + isNightMode() ? R.color.inactive_buttons_and_links_bg_dark : R.color.inactive_buttons_and_links_bg_light); sortButton.setImageResource(sortByMode.getIconId()); From cab7484e4aadb2d1298047b6b6c3631f9ff3f970 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 27 Oct 2020 21:39:45 +0200 Subject: [PATCH 11/31] Export/import all offline maps --- OsmAnd/res/values/strings.xml | 1 + .../backend/backup/FileSettingsItem.java | 25 +++++++++++- .../backend/backup/SettingsHelper.java | 14 ++++--- .../backend/backup/SettingsImporter.java | 22 +++++++++- .../ExportImportSettingsAdapter.java | 40 +++++++++++++++---- .../fragments/ImportSettingsFragment.java | 2 + 6 files changed, 90 insertions(+), 14 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a30f9c4fc5..cd0d9dd2b0 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Local maps Wait for the route recalculation.\nGraph will be available after recalculation. %1$s data available only on the roads, you need to calculate a route using “Route between points” to get it. Graph diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java index 357c0aadbf..6afddc9664 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java @@ -21,11 +21,15 @@ import java.io.OutputStream; public class FileSettingsItem extends StreamSettingsItem { + + public enum FileSubtype { UNKNOWN("", null), OTHER("other", ""), ROUTING_CONFIG("routing_config", IndexConstants.ROUTING_PROFILES_DIR), RENDERING_STYLE("rendering_style", IndexConstants.RENDERERS_DIR), + WIKI_MAP("wiki_map", IndexConstants.WIKI_INDEX_DIR), + SRTM_MAP("srtm_map", IndexConstants.SRTM_INDEX_DIR), OBF_MAP("obf_map", IndexConstants.MAPS_PATH), TILES_MAP("tiles_map", IndexConstants.TILES_INDEX_DIR), GPX("gpx", IndexConstants.GPX_INDEX_DIR), @@ -68,8 +72,18 @@ public class FileSettingsItem extends StreamSettingsItem { case UNKNOWN: case OTHER: break; + case SRTM_MAP: + if (name.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)) { + return subtype; + } + break; + case WIKI_MAP: + if (name.endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) { + return subtype; + } + break; case OBF_MAP: - if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) { + if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT) && !name.contains(File.separator)) { return subtype; } break; @@ -93,6 +107,7 @@ public class FileSettingsItem extends StreamSettingsItem { protected File file; private File appPath; protected FileSubtype subtype; + private long size; public FileSettingsItem(@NonNull OsmandApplication app, @NonNull File file) throws IllegalArgumentException { super(app, file.getPath().replace(app.getAppPath(null).getPath(), "")); @@ -171,6 +186,14 @@ public class FileSettingsItem extends StreamSettingsItem { } } + public long getSize() { + return size; + } + + public void setSize(long size) { + this.size = size; + } + @NonNull public File getFile() { return file; 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 e7d30ce30f..df44ee2337 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -46,6 +46,7 @@ import java.util.Map; import java.util.Set; import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT; +import static net.osmand.plus.activities.LocalIndexHelper.*; /* Usage: @@ -532,14 +533,14 @@ public class SettingsHelper { private List getLocalMapFiles() { List files = new ArrayList<>(); LocalIndexHelper helper = new LocalIndexHelper(app); - List localMapFileList = helper.getLocalFullMaps(new AbstractLoadLocalIndexTask() { + List localMapFileList = helper.getLocalIndexData(new AbstractLoadLocalIndexTask() { @Override public void loadFile(LocalIndexInfo... loaded) { } }); for (LocalIndexInfo map : localMapFileList) { File file = new File(map.getPathToData()); - if (file != null && file.exists()) { + if (file != null && file.exists() && map.getType() != LocalIndexType.TTS_VOICE_DATA) { files.add(file); } } @@ -607,7 +608,7 @@ public class SettingsHelper { List renderFilesList = new ArrayList<>(); List multimediaFilesList = new ArrayList<>(); List tracksFilesList = new ArrayList<>(); - List mapFilesList = new ArrayList<>(); + List mapFilesList = new ArrayList<>(); List avoidRoads = new ArrayList<>(); List notesPointList = new ArrayList<>(); List editsPointList = new ArrayList<>(); @@ -626,8 +627,11 @@ public class SettingsHelper { multimediaFilesList.add(fileItem.getFile()); } else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.GPX) { tracksFilesList.add(fileItem.getFile()); - } else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.OBF_MAP) { - mapFilesList.add(fileItem.getFile()); + } else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.OBF_MAP + || fileItem.getSubtype() == FileSettingsItem.FileSubtype.WIKI_MAP + || fileItem.getSubtype() == FileSettingsItem.FileSubtype.SRTM_MAP + || fileItem.getSubtype() == FileSettingsItem.FileSubtype.TILES_MAP) { + mapFilesList.add(fileItem); } break; case QUICK_ACTIONS: diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java index a06b8e8749..c9eb980b9d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java @@ -15,8 +15,10 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Enumeration; import java.util.List; import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT; @@ -57,7 +59,9 @@ class SettingsImporter { } try { SettingsItemsFactory itemsFactory = new SettingsItemsFactory(app, itemsJson); - items.addAll(itemsFactory.getItems()); + List settingsItemList = itemsFactory.getItems(); + getFilesSize(file, settingsItemList); + items.addAll(settingsItemList); } catch (IllegalArgumentException e) { SettingsHelper.LOG.error("Error parsing items: " + itemsJson, e); throw new IllegalArgumentException("No items"); @@ -77,6 +81,22 @@ class SettingsImporter { return items; } + private void getFilesSize(@NonNull File file, List settingsItemList) throws IOException { + ZipFile zipfile = new ZipFile(file.getPath()); + Enumeration zipEnum = zipfile.entries(); + while (zipEnum.hasMoreElements()) { + ZipEntry zipEntry = zipEnum.nextElement(); + int size = (int) zipEntry.getSize(); + for (SettingsItem settingsItem : settingsItemList) { + if (settingsItem instanceof FileSettingsItem + && zipEntry.getName().equals(settingsItem.getFileName())) { + ((FileSettingsItem) settingsItem).setSize(size); + break; + } + } + } + } + private List processItems(@NonNull File file, @Nullable List items) throws IllegalArgumentException, IOException { boolean collecting = items == null; if (collecting) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java index 8fa7c93a14..ea702e8c85 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java @@ -22,6 +22,7 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmEditingPlugin; @@ -34,6 +35,7 @@ import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.plus.settings.backend.ExportSettingsType; +import net.osmand.plus.settings.backend.backup.FileSettingsItem; import net.osmand.util.Algorithms; import net.osmand.view.ThreeStateCheckbox; @@ -46,6 +48,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static net.osmand.plus.settings.backend.ExportSettingsType.*; +import static net.osmand.plus.settings.backend.backup.FileSettingsItem.*; import static net.osmand.view.ThreeStateCheckbox.State.CHECKED; import static net.osmand.view.ThreeStateCheckbox.State.MISC; import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED; @@ -105,7 +109,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { cardBottomDivider.setVisibility(importState && !isExpanded ? View.VISIBLE : View.GONE); final List listItems = itemsMap.get(type); - subTextTv.setText(getSelectedItemsAmount(listItems)); + subTextTv.setText(getSelectedItemsAmount(listItems, type)); if (data.containsAll(listItems)) { checkBox.setState(CHECKED); @@ -265,9 +269,25 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected); break; case OFFLINE_MAPS: - file = (File) currentItem; - title.setText(file.getName()); - setupIcon(icon, R.drawable.ic_map, itemSelected); + FileSettingsItem currentFileItem = (FileSettingsItem) currentItem; + file = currentFileItem.getFile(); + title.setText(FileNameTranslationHelper.getFileName(app, + app.getResourceManager().getOsmandRegions(), + file.getName())); + FileSubtype subtype = FileSubtype.getSubtypeByFileName(file.getPath().replace(app.getAppPath(null).getPath(), "")); + switch (subtype) { + case SRTM_MAP: + iconId = R.drawable.ic_plugin_srtm; + break; + case WIKI_MAP: + iconId = R.drawable.ic_plugin_wikipedia; + break; + default: + iconId = R.drawable.ic_map; + } + setupIcon(icon, iconId, itemSelected); + subText.setText(AndroidUtils.formatSize(app, currentFileItem.getSize())); + subText.setVisibility(View.VISIBLE); break; default: return child; @@ -315,14 +335,20 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { return true; } - private String getSelectedItemsAmount(List listItems) { + private String getSelectedItemsAmount(List listItems, ExportSettingsType type) { int amount = 0; + long amountSize = 0; for (Object item : listItems) { if (data.contains(item)) { amount++; + if (type == OFFLINE_MAPS && item instanceof FileSettingsItem) { + amountSize += ((FileSettingsItem) item).getSize(); + } } } - return app.getString(R.string.n_items_of_z, String.valueOf(amount), String.valueOf(listItems.size())); + String itemsOf = app.getString(R.string.n_items_of_z, String.valueOf(amount), String.valueOf(listItems.size())); + return amountSize == 0 ? itemsOf : app.getString(R.string.ltr_or_rtl_combine_via_bold_point, itemsOf, + AndroidUtils.formatSize(app, amountSize)); } private int getGroupTitle(ExportSettingsType type) { @@ -350,7 +376,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { case OSM_EDITS: return R.string.osm_edit_modified_poi; case OFFLINE_MAPS: - return R.string.download_regular_maps; + return R.string.shared_string_local_maps; default: return R.string.access_empty_list; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index 52a85fee11..46752fd758 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -451,6 +451,8 @@ public class ImportSettingsFragment extends BaseOsmAndFragment tileSourceTemplates.add((ITileSource) object); } else if (object instanceof File) { settingsItems.add(new FileSettingsItem(app, (File) object)); + } else if (object instanceof FileSettingsItem) { + settingsItems.add((FileSettingsItem) object); } else if (object instanceof AvoidRoadInfo) { avoidRoads.add((AvoidRoadInfo) object); } else if (object instanceof OsmNotesPoint) { From 890d41a56fe6452d75f7c8322eef310863b873e6 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 28 Oct 2020 21:11:06 +0200 Subject: [PATCH 12/31] Fix review --- .../net/osmand/plus/osmedit/AddPOIAction.java | 4 ++-- .../plus/osmedit/AdvancedEditPoiFragment.java | 7 +++--- .../plus/osmedit/EditPOIMenuBuilder.java | 9 ++++--- .../plus/osmedit/EditPOIMenuController.java | 4 +++- .../net/osmand/plus/osmedit/EditPoiData.java | 24 +++++++++---------- .../plus/osmedit/EditPoiDialogFragment.java | 14 ++++++----- .../plus/osmedit/OpenstreetmapLocalUtil.java | 4 +++- .../plus/osmedit/OpenstreetmapPoint.java | 2 +- .../plus/osmedit/OpenstreetmapRemoteUtil.java | 13 +++++----- .../osmand/plus/osmedit/OsmEditingPlugin.java | 3 ++- .../osmand/plus/osmedit/OsmEditsAdapter.java | 3 ++- .../osmand/plus/osmedit/OsmEditsLayer.java | 2 +- .../dialogs/SendPoiDialogFragment.java | 4 ++-- .../backend/backup/FileSettingsItem.java | 4 ++++ .../backend/backup/OsmEditsSettingsItem.java | 12 +++++++--- .../backend/backup/OsmNotesSettingsItem.java | 3 +-- .../backend/backup/SettingsImporter.java | 2 +- .../backend/backup/SettingsItemType.java | 5 ---- .../ExportImportSettingsAdapter.java | 16 +++++++++---- .../fragments/ImportSettingsFragment.java | 5 +--- 20 files changed, 81 insertions(+), 59 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java index 81462b1d4d..1db6bd0542 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java @@ -58,7 +58,7 @@ import java.util.List; import java.util.Map; import static net.osmand.plus.osmedit.AdvancedEditPoiFragment.addPoiToStringSet; -import static net.osmand.plus.osmedit.EditPoiData.POI_TYPE_TAG; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; public class AddPOIAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(13, @@ -140,7 +140,7 @@ public class AddPOIAction extends QuickAction { Node newNode = new Node(node.getLatitude(), node.getLongitude(), node.getId()); OsmPoint.Action action = newNode.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; for (Map.Entry tag : editPoiData.getTagValues().entrySet()) { - if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { + if (tag.getKey().equals(POI_TYPE_TAG)) { final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase()); if (poiType != null) { newNode.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 3eabf35f6c..b538ccd0c5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -28,6 +28,7 @@ import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiFilter; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.OSMSettings; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -112,7 +113,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment if (Algorithms.objectEquals(anyTag, OSMSettings.OSMTagKey.NAME.getValue())) { updateName(); } - if (Algorithms.objectEquals(anyTag, EditPoiData.POI_TYPE_TAG)) { + if (Algorithms.objectEquals(anyTag, Entity.POI_TYPE_TAG)) { updatePoiType(); } } @@ -197,9 +198,9 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment currentPoiTypeKey = pt.getEditOsmTag(); } for (Entry tag : editPoiData.getTagValues().entrySet()) { - if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG) + if (tag.getKey().equals(Entity.POI_TYPE_TAG) || tag.getKey().equals(OSMSettings.OSMTagKey.NAME.getValue()) - || tag.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX) + || tag.getKey().startsWith(Entity.REMOVE_TAG_PREFIX) || tag.getKey().equals(currentPoiTypeKey)) continue; addTagView(tag.getKey(), tag.getValue()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java index 9a47563fe4..eb2b7b8c2b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java @@ -5,6 +5,7 @@ import android.view.View; import androidx.annotation.NonNull; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuBuilder; @@ -12,6 +13,8 @@ import net.osmand.plus.render.RenderingIcons; import java.util.Map; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPOIMenuBuilder extends MenuBuilder { private final OsmPoint osmPoint; @@ -38,7 +41,7 @@ public class EditPOIMenuBuilder extends MenuBuilder { OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint; for (Map.Entry e : point.getEntity().getTags().entrySet()) { - if (EditPoiData.POI_TYPE_TAG.equals(e.getKey())) { + if (POI_TYPE_TAG.equals(e.getKey())) { String poiTranslation = e.getValue(); Map poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); @@ -63,8 +66,8 @@ public class EditPOIMenuBuilder extends MenuBuilder { } for (Map.Entry e : point.getEntity().getTags().entrySet()) { - if (EditPoiData.POI_TYPE_TAG.equals(e.getKey()) || - e.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX)) { + if (POI_TYPE_TAG.equals(e.getKey()) || + e.getKey().startsWith(Entity.REMOVE_TAG_PREFIX)) { continue; } String text = e.getKey() + "=" + e.getValue(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 7d04c73252..8134e5a3be 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -18,6 +18,8 @@ import net.osmand.util.Algorithms; import java.util.Map; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPOIMenuController extends MenuController { private OsmPoint osmPoint; @@ -166,7 +168,7 @@ public class EditPOIMenuController extends MenuController { if (osmPoint.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; int iconResId = 0; - String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmP.getEntity().getTag(POI_TYPE_TAG); MapActivity mapActivity = getMapActivity(); if (poiTranslation != null && mapActivity != null) { Map poiTypeMap = mapActivity.getMyApplication().getPoiTypes().getAllTranslatedNames(false); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index b11c828436..7dab7780b0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -17,15 +17,15 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPoiData { private static final Log LOG = PlatformUtil.getLog(EditPoiData.class); private Set mListeners = new HashSet<>(); - private LinkedHashMap tagValues = new LinkedHashMap(); + private final LinkedHashMap tagValues = new LinkedHashMap(); private boolean isInEdit = false; private Entity entity; - - public static final String POI_TYPE_TAG = "poi_type_tag"; - public static final String REMOVE_TAG_PREFIX = "----"; + public static final String REMOVE_TAG_VALUE = "DELETE"; private boolean hasChangesBeenMade = false; private Map allTranslatedSubTypes; @@ -123,7 +123,7 @@ public class EditPoiData { checkNotInEdit(); try { isInEdit = true; - tagValues.remove(REMOVE_TAG_PREFIX+tag); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + tag); String oldValue = tagValues.get(tag); if (oldValue == null || !oldValue.equals(value)) { changedTags.add(tag); @@ -154,9 +154,9 @@ public class EditPoiData { public void removeTag(String tag) { checkNotInEdit(); - try { + try { isInEdit = true; - tagValues.put(REMOVE_TAG_PREFIX+tag, REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + tag, REMOVE_TAG_VALUE); tagValues.remove(tag); changedTags.remove(tag); notifyDatasetChanged(tag); @@ -216,7 +216,7 @@ public class EditPoiData { PoiType pt = getPoiTypeDefined(); String editOsmTag = pt != null ? pt.getEditOsmTag() : null; if (editOsmTag != null) { - removeTypeTagWithPrefix(!tagValues.containsKey(REMOVE_TAG_PREFIX + editOsmTag)); + removeTypeTagWithPrefix(!tagValues.containsKey(Entity.REMOVE_TAG_PREFIX + editOsmTag)); currentPoiType = pt; String tagVal = pt.getEditOsmValue() != null ? pt.getEditOsmValue() : ""; tagValues.put(editOsmTag, tagVal); @@ -237,11 +237,11 @@ public class EditPoiData { private void removeTypeTagWithPrefix(boolean needRemovePrefix) { if (currentPoiType != null) { if (needRemovePrefix) { - tagValues.put(REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE); - tagValues.put(REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE); } else { - tagValues.remove(REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag()); - tagValues.remove(REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2()); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag()); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2()); } removeCurrentTypeTag(); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 7c0edb7168..ecdc776c78 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -90,6 +90,8 @@ import java.util.Set; import studio.carbonylgroup.textfieldboxes.ExtendedEditText; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { public static final String TAG = EditPoiDialogFragment.class.getSimpleName(); private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class); @@ -499,21 +501,21 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { Action action = entity.getId() < 0 ? Action.CREATE : Action.MODIFY; for (Map.Entry tag : editPoiData.getTagValues().entrySet()) { - if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) && - !tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { + if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) && + !tag.getKey().equals(POI_TYPE_TAG)) { entity.putTagNoLC(tag.getKey(), tag.getValue()); } } - String poiTypeTag = editPoiData.getTagValues().get(EditPoiData.POI_TYPE_TAG); + String poiTypeTag = editPoiData.getTagValues().get(POI_TYPE_TAG); String comment = ""; if (poiTypeTag != null) { final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(poiTypeTag.trim().toLowerCase()); if (poiType != null) { entity.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue()); - entity.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getEditOsmTag()); + entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getEditOsmTag()); if (poiType.getOsmTag2() != null) { entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); - entity.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); + entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); } } else if (!Algorithms.isEmpty(poiTypeTag)) { PoiCategory category = editPoiData.getPoiCategory(); @@ -522,7 +524,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { } } if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) { - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag); + entity.putTagNoLC(POI_TYPE_TAG, poiTypeTag); } String actionString = action == Action.CREATE ? getString(R.string.default_changeset_add) : getString(R.string.default_changeset_edit); comment = actionString + " " + poiTypeTag; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java index c55e2099ed..26eda5f4e5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java @@ -24,6 +24,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { public final static Log LOG = PlatformUtil.getLog(OpenstreetmapLocalUtil.class); @@ -122,7 +124,7 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { entity = new Node(loc.getLatitude(), loc.getLongitude(), entityId); } if (poiType != null) { - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, poiType.getTranslation()); if (poiType.getOsmTag2() != null) { entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java index 7e7a35d6f1..d7c17c1ec2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java @@ -28,7 +28,7 @@ public class OpenstreetmapPoint extends OsmPoint { String type = "amenity"; for (String k : entity.getTagKeySet()) { if (!OSMTagKey.NAME.getValue().equals(k) && !OSMTagKey.OPENING_HOURS.getValue().equals(k) && - !k.startsWith(EditPoiData.REMOVE_TAG_PREFIX)) { + !k.startsWith(Entity.REMOVE_TAG_PREFIX)) { type = k; break; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index b90a22c0b9..8940093c19 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -39,7 +39,8 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import java.util.concurrent.ExecutionException; + +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { @@ -273,8 +274,8 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { throws IllegalArgumentException, IllegalStateException, IOException { for (String k : entity.getTagKeySet()) { String val = entity.getTag(k); - if (val.length() == 0 || k.length() == 0 || EditPoiData.POI_TYPE_TAG.equals(k) || - k.startsWith(EditPoiData.REMOVE_TAG_PREFIX) || k.contains(EditPoiData.REMOVE_TAG_PREFIX)) + if (val.length() == 0 || k.length() == 0 || POI_TYPE_TAG.equals(k) || + k.startsWith(Entity.REMOVE_TAG_PREFIX) || k.contains(Entity.REMOVE_TAG_PREFIX)) continue; ser.startTag(null, "tag"); //$NON-NLS-1$ ser.attribute(null, "k", k); //$NON-NLS-1$ @@ -455,7 +456,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { } private boolean deletedTag(Entity entity, String tag) { - return entity.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + tag); + return entity.getTagKeySet().contains(Entity.REMOVE_TAG_PREFIX + tag); } @Override @@ -542,12 +543,12 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { PoiType poiType = type.getPoiTypeByKeyName(subType); if (poiType != null && poiType.getEditOsmValue().equals(entity.getTag(poiType.getEditOsmTag()))) { entity.removeTag(poiType.getEditOsmTag()); - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, poiType.getTranslation()); } else { for (PoiType pt : type.getPoiTypes()) { if (pt.getEditOsmValue().equals(entity.getTag(pt.getEditOsmTag()))) { entity.removeTag(pt.getEditOsmTag()); - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, pt.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, pt.getTranslation()); } } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index bee84a5e68..5b9b9eb7ce 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -61,6 +61,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_C import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE; import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS; import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; @@ -554,7 +555,7 @@ public class OsmEditingPlugin extends OsmandPlugin { public static String getCategory(OsmPoint osmPoint, Context context) { String category = ""; if (osmPoint.getGroup() == OsmPoint.Group.POI) { - category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(EditPoiData.POI_TYPE_TAG); + category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(POI_TYPE_TAG); if (Algorithms.isEmpty(category)) { category = context.getString(R.string.shared_string_without_name); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java index 92159c49df..d4c2ad099f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java @@ -17,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -244,7 +245,7 @@ public class OsmEditsAdapter extends ArrayAdapter { if (point.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point; int iconResId = 0; - String poiTranslation = osmPoint.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmPoint.getEntity().getTag(Entity.POI_TYPE_TAG); if (poiTranslation != null) { Map poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java index 99947c7de2..59c07afbaa 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java @@ -101,7 +101,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC if (osmPoint.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; int iconResId = 0; - String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmP.getEntity().getTag(Entity.POI_TYPE_TAG); if (poiTranslation != null && activity != null) { Map poiTypeMap = activity.getMyApplication().getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java index 7af0286ae4..d402cdfe49 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -16,13 +16,13 @@ import androidx.appcompat.widget.SwitchCompat; import androidx.fragment.app.DialogFragment; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dialogs.ProgressDialogFragment; -import net.osmand.plus.osmedit.EditPoiData; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmBugsLayer; import net.osmand.plus.osmedit.OsmEditingPlugin; @@ -152,7 +152,7 @@ public class SendPoiDialogFragment extends DialogFragment { for (OsmPoint p : poi) { if (p.getGroup() == OsmPoint.Group.POI) { OsmPoint.Action action = p.getAction(); - String type = ((OpenstreetmapPoint) p).getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String type = ((OpenstreetmapPoint) p).getEntity().getTag(Entity.POI_TYPE_TAG); if (type == null) { continue; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java index 6afddc9664..097e64b0d2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java @@ -45,6 +45,10 @@ public class FileSettingsItem extends StreamSettingsItem { this.subtypeFolder = subtypeFolder; } + public boolean isMap() { + return this == OBF_MAP || this == WIKI_MAP || this == SRTM_MAP; + } + public String getSubtypeName() { return subtypeName; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java index e2c06d14d6..03e1e39ad5 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken; import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.Node; +import net.osmand.osm.edit.Way; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; @@ -78,9 +79,8 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); } OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); - OsmBugsDbHelper db; if (osmEditingPlugin != null) { - db = osmEditingPlugin.getDBBug(); + OsmBugsDbHelper db = osmEditingPlugin.getDBBug(); for (OsmNotesPoint point : appliedItems) { db.addOsmbugs(point); } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java index c9eb980b9d..a03f363542 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java @@ -86,7 +86,7 @@ class SettingsImporter { Enumeration zipEnum = zipfile.entries(); while (zipEnum.hasMoreElements()) { ZipEntry zipEntry = zipEnum.nextElement(); - int size = (int) zipEntry.getSize(); + long size = zipEntry.getSize(); for (SettingsItem settingsItem : settingsItemList) { if (settingsItem instanceof FileSettingsItem && zipEntry.getName().equals(settingsItem.getFileName())) { 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 d931e5a5c4..a513dc748c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -13,11 +13,6 @@ public enum SettingsItemType { AVOID_ROADS, SUGGESTED_DOWNLOADS, DOWNLOADS, - MARKERS, - FAVORITES, - TRACKS, - AUDIO_VIDEO_NOTES, OSM_NOTES, OSM_EDITS, - OFFLINE_MAPS } \ 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 ea702e8c85..9093c01c87 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java @@ -269,12 +269,20 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected); break; case OFFLINE_MAPS: - FileSettingsItem currentFileItem = (FileSettingsItem) currentItem; - file = currentFileItem.getFile(); + long size; + if (currentItem instanceof FileSettingsItem) { + FileSettingsItem currentFileItem = (FileSettingsItem) currentItem; + file = currentFileItem.getFile(); + size = currentFileItem.getSize(); + } else { + file = (File) currentItem; + size = file.length(); + } title.setText(FileNameTranslationHelper.getFileName(app, app.getResourceManager().getOsmandRegions(), file.getName())); - FileSubtype subtype = FileSubtype.getSubtypeByFileName(file.getPath().replace(app.getAppPath(null).getPath(), "")); + FileSubtype subtype = FileSubtype.getSubtypeByFileName(file.getPath().replace( + app.getAppPath(null).getPath(), "")); switch (subtype) { case SRTM_MAP: iconId = R.drawable.ic_plugin_srtm; @@ -286,7 +294,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { iconId = R.drawable.ic_map; } setupIcon(icon, iconId, itemSelected); - subText.setText(AndroidUtils.formatSize(app, currentFileItem.getSize())); + subText.setText(AndroidUtils.formatSize(app, size)); subText.setVisibility(View.VISIBLE); break; default: diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index 46752fd758..8250477d20 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -71,9 +71,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype.*; - - public class ImportSettingsFragment extends BaseOsmAndFragment implements View.OnClickListener { @@ -287,7 +284,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment private void reloadIndexes(@NonNull List items) { for (SettingsItem item : items) { - if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype() == OBF_MAP) { + if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype().isMap()) { Activity activity = getActivity(); if (activity instanceof MapActivity) { new ReloadIndexesTack((MapActivity) activity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); From e9925fbddddb8958acafd5531583df8718ba89f0 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 29 Oct 2020 11:58:08 +0200 Subject: [PATCH 13/31] Clean up sorting in tracks to follow --- OsmAnd/res/layout/follow_track_options.xml | 19 +--- .../FollowTrackFragment.java | 86 +++++++------------ .../cards/TracksToFollowCard.java | 40 ++++----- 3 files changed, 54 insertions(+), 91 deletions(-) diff --git a/OsmAnd/res/layout/follow_track_options.xml b/OsmAnd/res/layout/follow_track_options.xml index 7e7843d510..0877fcc307 100644 --- a/OsmAnd/res/layout/follow_track_options.xml +++ b/OsmAnd/res/layout/follow_track_options.xml @@ -60,14 +60,11 @@ android:layout_width="@dimen/wikipedia_options_button_width" android:layout_height="@dimen/dialog_button_height" android:layout_gravity="center" - osmand:srcCompat="@drawable/ic_sort_waypoint_dark" - android:tint="?attr/color_dialog_buttons" - android:background="?attr/bg_dash_line" - android:visibility="gone" - tools:visibility="visible" android:layout_marginEnd="@dimen/content_padding" - android:layout_marginRight="@dimen/content_padding" /> - + android:layout_marginRight="@dimen/content_padding" + android:background="?attr/bg_dash_line" + android:tint="?attr/color_dialog_buttons" + osmand:srcCompat="@drawable/ic_sort_waypoint_dark" /> @@ -95,14 +92,6 @@ android:orientation="vertical" android:paddingBottom="@dimen/dialog_button_ex_height"> - - diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index f304123de8..b01e49bd12 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -1,11 +1,8 @@ package net.osmand.plus.routepreparationmenu; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; -import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; @@ -19,21 +16,16 @@ import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewTreeObserver.OnScrollChangedListener; import android.widget.FrameLayout; import android.widget.ImageButton; -import android.widget.ImageView; import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.fragment.app.FragmentManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; -import net.osmand.Collator; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.WptPt; import net.osmand.IndexConstants; -import net.osmand.OsmAndCollator; import net.osmand.PlatformUtil; import net.osmand.ValueHolder; import net.osmand.data.QuadRect; @@ -41,7 +33,7 @@ import net.osmand.data.RotatedTileBox; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.SimplePopUpMenuItemAdapter; +import net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem; import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.activities.MapActivity; @@ -78,8 +70,6 @@ import org.apache.commons.logging.Log; import java.io.File; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; @@ -98,12 +88,14 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca private GPXFile gpxFile; private View buttonsShadow; + private ImageButton sortButton; + private TracksToFollowCard tracksCard; + private TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; private boolean editingTrack; private boolean selectingTrack; private int menuTitleHeight; - TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; @Override public int getMainLayoutId() { @@ -162,42 +154,6 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) { - final ImageButton sortButton = view.findViewById(R.id.sort_button); - Drawable background = app.getUIUtilities().getIcon(R.drawable.bg_dash_line_dark, - isNightMode() - ? R.color.inactive_buttons_and_links_bg_dark - : R.color.inactive_buttons_and_links_bg_light); - sortButton.setImageResource(sortByMode.getIconId()); - AndroidUtils.setBackground(sortButton, background); - sortButton.setVisibility(View.VISIBLE); - final RecyclerView filesRecyclerView = view.findViewById(R.id.gpx_track_list); - filesRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - sortButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final List items = new ArrayList<>(); - for (final TracksSortByMode mode : TracksSortByMode.values()) { - items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( - getString(mode.getNameId()), - app.getUIUtilities().getThemedIcon(mode.getIconId()), - new View.OnClickListener() { - @Override - public void onClick(View v) { - sortByMode = mode; - sortButton.setImageResource(mode.getIconId()); - if (tracksCard != null) { - List list = tracksCard.getGpxInfoList(); - tracksCard.setSortByMode(mode); - tracksCard.setGpxInfoList(list); - - } - } - }, sortByMode == mode - )); - } - UiUtilities.showPopUpMenu(v, items); - } - }); ImageButton closeButton = view.findViewById(R.id.close_button); buttonsShadow = view.findViewById(R.id.buttons_shadow); closeButton.setImageDrawable(getContentIcon(AndroidUtils.getNavigationIconResId(app))); @@ -213,6 +169,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } setupCards(); setupButtons(view); + setupSortButton(view); setupScrollShadow(); if (!isPortrait()) { int widthNoShadow = getLandscapeNoShadowWidth(); @@ -249,9 +206,6 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca cardsContainer.removeAllViews(); if (gpxFile == null || selectingTrack) { - ImportTrackCard importTrackCard = new ImportTrackCard(mapActivity); - importTrackCard.setListener(this); - setupTracksCard(); } else { String fileName = null; @@ -318,8 +272,6 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } } - - private void setupNavigateOptionsCard(GPXRouteParamsBuilder rparams) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { @@ -649,6 +601,34 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } } + private void setupSortButton(View view) { + final ImageButton sortButton = view.findViewById(R.id.sort_button); + int colorId = isNightMode() ? R.color.inactive_buttons_and_links_bg_dark : R.color.inactive_buttons_and_links_bg_light; + Drawable background = app.getUIUtilities().getIcon(R.drawable.bg_dash_line_dark, colorId); + sortButton.setImageResource(sortByMode.getIconId()); + AndroidUtils.setBackground(sortButton, background); + sortButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List items = new ArrayList<>(); + for (final TracksSortByMode mode : TracksSortByMode.values()) { + items.add(new SimplePopUpMenuItem(getString(mode.getNameId()), + app.getUIUtilities().getThemedIcon(mode.getIconId()), + new View.OnClickListener() { + @Override + public void onClick(View v) { + sortByMode = mode; + tracksCard.setSortByMode(mode); + sortButton.setImageResource(mode.getIconId()); + } + }, sortByMode == mode + )); + } + UiUtilities.showPopUpMenu(v, items); + } + }); + } + private void setupButtons(View view) { View buttonsContainer = view.findViewById(R.id.buttons_container); buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.bg_color)); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java index c6cfe7247d..0897894730 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java @@ -24,19 +24,15 @@ import java.util.Map; public class TracksToFollowCard extends BaseCard { + private List gpxInfoList; private Map> gpxInfoCategories; - private List gpxInfoList; - private String selectedCategory; + private GpxTrackAdapter tracksAdapter; + private TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; + private String defaultCategory; private String visibleCategory; - TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; - - public void setSortByMode(TracksSortByMode sortByMode) { - this.sortByMode = sortByMode; - } - - private GpxTrackAdapter tracksAdapter; + private String selectedCategory; public TracksToFollowCard(MapActivity mapActivity, List gpxInfoList, String selectedCategory) { super(mapActivity); @@ -44,24 +40,19 @@ public class TracksToFollowCard extends BaseCard { this.selectedCategory = selectedCategory; defaultCategory = app.getString(R.string.shared_string_all); visibleCategory = app.getString(R.string.shared_string_visible); - sortGPXInfoItems(gpxInfoList); gpxInfoCategories = getGpxInfoCategories(); } - public void setGpxInfoList(List gpxInfoList) { - this.gpxInfoList = gpxInfoList; - sortGPXInfoItems(gpxInfoList); + public void setSortByMode(TracksSortByMode sortByMode) { + this.sortByMode = sortByMode; gpxInfoCategories = getGpxInfoCategories(); - List items = gpxInfoCategories.get(selectedCategory); - tracksAdapter.setGpxInfoList(items != null ? items : new ArrayList()); - tracksAdapter.notifyDataSetChanged(); + updateTracksAdapter(); } public List getGpxInfoList() { return gpxInfoList; } - public String getSelectedCategory() { return selectedCategory; } @@ -107,11 +98,8 @@ public class TracksToFollowCard extends BaseCard { @Override public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) { selectedCategory = item.getTitle(); - List items = gpxInfoCategories.get(selectedCategory); tracksAdapter.setShowFolderName(showFoldersName()); - tracksAdapter.setGpxInfoList(items != null ? items : new ArrayList()); - tracksAdapter.notifyDataSetChanged(); - + updateTracksAdapter(); selectionAdapter.notifyDataSetChanged(); } }); @@ -122,6 +110,12 @@ public class TracksToFollowCard extends BaseCard { selectionAdapter.notifyDataSetChanged(); } + private void updateTracksAdapter() { + List items = gpxInfoCategories.get(selectedCategory); + tracksAdapter.setGpxInfoList(items != null ? items : new ArrayList()); + tracksAdapter.notifyDataSetChanged(); + } + private boolean showFoldersName() { return defaultCategory.equals(selectedCategory) || visibleCategory.equals(selectedCategory); } @@ -132,6 +126,7 @@ public class TracksToFollowCard extends BaseCard { gpxInfoCategories.put(visibleCategory, new ArrayList()); gpxInfoCategories.put(defaultCategory, new ArrayList()); + sortGPXInfoItems(gpxInfoList); for (GPXInfo info : gpxInfoList) { if (info.isSelected()) { addGpxInfoCategory(gpxInfoCategories, info, visibleCategory); @@ -178,5 +173,4 @@ public class TracksToFollowCard extends BaseCard { } }); } -} - +} \ No newline at end of file From f1597a3a1c743045306faa6198bfdb351439982c Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 29 Oct 2020 12:28:23 +0200 Subject: [PATCH 14/31] Fix possible npe --- .../osmand/plus/routepreparationmenu/FollowTrackFragment.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index b01e49bd12..d805cde0df 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -618,8 +618,10 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca @Override public void onClick(View v) { sortByMode = mode; - tracksCard.setSortByMode(mode); sortButton.setImageResource(mode.getIconId()); + if (tracksCard != null) { + tracksCard.setSortByMode(mode); + } } }, sortByMode == mode )); From 4484451771f08d22060f6897701ef406ba4bb4c4 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Wed, 28 Oct 2020 06:43:29 +0000 Subject: [PATCH 15/31] Translated using Weblate (French) Currently translated at 100.0% (3512 of 3512 strings) --- OsmAnd/res/values-fr/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 2a4458f148..3dda9b8adc 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3801,7 +3801,7 @@ Sélectionnez un fichier de trace à ouvrir. Terminé Remplacer la trace - Sélectionnez comment relier les points : par une ligne droite ou en calculant un itinéraire reliant les points comme indiqué ci-dessous. + Définissez comment relier les points : par une ligne droite ou en calculant un itinéraire avec le profil ci-dessous. Toute la trace sera recalculée en utilisant le profil sélectionné. Seul le prochain segment sera recalculé en utilisant le profil sélectionné. Ensuite, sélectionnez le profil de navigation pour détecter les routes autorisées et le seuil de distance afin de déplacer votre trace. From 1c84be59c6f8995f82ed506914564049c46410f4 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 29 Oct 2020 08:41:44 +0000 Subject: [PATCH 16/31] Translated using Weblate (German) Currently translated at 99.9% (3509 of 3512 strings) --- OsmAnd/res/values-de/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 697326c31c..397bf22044 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3933,4 +3933,5 @@ Für das Schneemobilfahren mit speziellen Straßen und Tracks. Durchführen eines OAuth-Logins zur Nutzung der osmedit-Funktionen 2-Phasen-A*-Routing-Algorithmus verwenden + %1$s Daten sind nur auf den Straßen verfügbar, Sie müssen eine Route mit \"Route zwischen Punkten\" berechnen, um sie zu erhalten. \ No newline at end of file From d1221c8c2de2e5027a17b5a7fdb6abb043c2efbc Mon Sep 17 00:00:00 2001 From: nautilusx Date: Thu, 29 Oct 2020 06:23:21 +0000 Subject: [PATCH 17/31] Translated using Weblate (German) Currently translated at 99.9% (3509 of 3512 strings) --- OsmAnd/res/values-de/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 397bf22044..20b7fd68f2 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3934,4 +3934,5 @@ Durchführen eines OAuth-Logins zur Nutzung der osmedit-Funktionen 2-Phasen-A*-Routing-Algorithmus verwenden %1$s Daten sind nur auf den Straßen verfügbar, Sie müssen eine Route mit \"Route zwischen Punkten\" berechnen, um sie zu erhalten. + %1$s — %2$s \ No newline at end of file From 1cf419391c80545fd7c91f13e904ec65d4adb5f7 Mon Sep 17 00:00:00 2001 From: Mirco Zorzo Date: Thu, 29 Oct 2020 08:11:37 +0000 Subject: [PATCH 18/31] Translated using Weblate (Italian) Currently translated at 89.8% (3155 of 3512 strings) --- OsmAnd/res/values-it/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index 7b4c8ad764..e950feca34 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -3718,7 +3718,7 @@ Questi elementi sono nascosti dal menu, ma le opzioni rappresentate o i plugins continueranno a funzionare. Nascondere le opzioni le reimposta al loro valore originale. Azioni principali - Puoi accedere a queste azioni toccando il pulsante \"Azioni aggiuntive\". + Puoi accedere a queste azioni toccando il pulsante “%1$s”. Puoi spostare gli elementi solo all\'interno di questa categoria. Seleziona i linguaggi in cui gli articoli di Wikipedia appariranno sulla mappa. Puoi cambiare fra tutte le lingue disponibili mentre leggi questo articolo. Alcuni articoli di Wikipedia potrebbero non essere disponibili nella tua lingua. From 13fd8cf31bd8f677c741aa70230501701b39a964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allan=20Nordh=C3=B8y?= Date: Thu, 29 Oct 2020 10:23:32 +0000 Subject: [PATCH 19/31] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegian?= =?UTF-8?q?=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 48.2% (1696 of 3512 strings) --- OsmAnd/res/values-nb/strings.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index 85f13702a1..12e10abaef 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -628,7 +628,7 @@ Oversiktskart (verden) Skikart (verden) Kroatisk - Nettfrakoblet beregning av OsmAnd-rutesegment + Frakoblet beregning av OsmAnd-rutesegment Beregn OsmAnd-rute for første og siste rutesegment Statuslinje Foretrukket språk for påskrifter på kartet (hvis utilgjengelig brukes engelsk eller lokale navn). @@ -3694,7 +3694,7 @@ Egendefinert Retningspiler tonn - Rute mellom punkter + Rut mellom punkter Enduro-motorsykkel Skjermkontroll Bruk systemets skjermtidsavbrudd @@ -3706,7 +3706,7 @@ Snu rute Overskriv spor Hele sporet blir beregnet på nytt med den valgte profilen. - Velg hvordan punkter skal forbindes; med en rett linje, eller beregn en rute mellom dem som spesifisert nedenfor. + Velg hvordan punktene skal forbindes; med en rett linje, eller beregn en rute mellom dem som spesifisert nedenfor. Kun det neste segmentet blir beregnet på nytt med den valgte profilen. Hele sporet Neste segment @@ -3872,4 +3872,6 @@ \nGraf vil være tilgjengelig etter omberegning. %1$s — %2$s Graf + %1$s-data er tilgjengelig kun på veiene, du må beregne en rute med “Rut mellom punkter”. + Spor rute \ No newline at end of file From 07b9c263fc523f769f3f6d714350ae46c7621ac0 Mon Sep 17 00:00:00 2001 From: ffff23 Date: Wed, 28 Oct 2020 15:20:48 +0000 Subject: [PATCH 20/31] Translated using Weblate (Japanese) Currently translated at 99.2% (3802 of 3829 strings) --- OsmAnd/res/values-ja/phrases.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-ja/phrases.xml b/OsmAnd/res/values-ja/phrases.xml index 865fa35edc..495b894b2c 100644 --- a/OsmAnd/res/values-ja/phrases.xml +++ b/OsmAnd/res/values-ja/phrases.xml @@ -1479,7 +1479,7 @@ 持ち帰り不可 テイクアウト・持ち帰りのみ 遺跡の種類 - 医療機関 + 専門分野 総合診療医 眼科 婦人科 @@ -1487,7 +1487,7 @@ 整形外科 耳鼻咽喉科 小児科 - 医療機関:小児科:無し + 専門分野:小児科:無し 皮膚科 泌尿器科 一般外科 From 5ddbc7677dbfe9914614d7f551bd98e7cc7c0445 Mon Sep 17 00:00:00 2001 From: Franco Date: Wed, 28 Oct 2020 21:53:25 +0000 Subject: [PATCH 21/31] Translated using Weblate (Spanish (Argentina)) Currently translated at 99.9% (3510 of 3512 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 4da8d4966b..ad60cd64f0 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -3551,14 +3551,14 @@ Guardando el nuevo perfil No se pudo respaldar el perfil. ¿Borrar los datos registrados\? - Importación de datos de %1$s - Importación + Importando de datos de «%1$s» + Importando OsmAnd comprueba %1$s para ver si hay duplicados con los elementos existentes en la aplicación. \n \nPuede llevar algún tiempo. Elementos añadidos Importación completa - Todos los datos de %1$s son importados, puedes usar los botones de abajo para abrir la parte necesaria de la aplicación para manejarla. + Todos los datos de «%1$s» fueron importados. Puedes usar los botones de abajo para gestionar la sección necesaria de la aplicación. Min %1$s de %2$s Terreno From 1aeed646798889774992709268d27e75a699ce8c Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Tue, 27 Oct 2020 23:19:58 +0000 Subject: [PATCH 22/31] Translated using Weblate (Portuguese (Brazil)) Currently translated at 99.9% (3511 of 3512 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 43ef613eb1..f6e3fc9f64 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -3819,7 +3819,7 @@ Rota reversa A trilha inteira será recalculada usando o perfil selecionado. Apenas o próximo segmento será recalculado usando o perfil selecionado. - Selecione como conectar pontos, por uma linha reta, ou calcular uma rota entre eles conforme especificado abaixo. + Escolha como conectar os pontos, por uma linha reta, ou calcular uma rota entre eles conforme especificado abaixo. Trilha inteira Próximo segmento Para usar esta opção, OsmAnd precisa ajustar sua trilha para as estradas do mapa. From 52472493b7cfa523e9b4fb83d5fad2a1726e9597 Mon Sep 17 00:00:00 2001 From: Verdulo Date: Wed, 28 Oct 2020 18:35:44 +0000 Subject: [PATCH 23/31] Translated using Weblate (Esperanto) Currently translated at 99.9% (3511 of 3512 strings) --- OsmAnd/res/values-eo/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index ece67180a8..c469f7f4bd 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -3932,4 +3932,6 @@ Datumoj de %1$s estas disponeblaj nur por vojoj, vi devas kalkuli la kurson uzante “kalkuli kurson inter punktoj” por akiri ĝin. Atendado ĝis la kurso estos rekalkulita. \nDiagramo estos videbla post rekalkulado. + %1$s — %2$s + Manko \ No newline at end of file From a92181d3ab0fe431ce9a4e031275bb89d08b3ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sveinn=20=C3=AD=20Felli?= Date: Wed, 28 Oct 2020 18:08:00 +0000 Subject: [PATCH 24/31] Translated using Weblate (Icelandic) Currently translated at 100.0% (3512 of 3512 strings) --- OsmAnd/res/values-is/strings.xml | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-is/strings.xml b/OsmAnd/res/values-is/strings.xml index c5ce396f03..182d438a1c 100644 --- a/OsmAnd/res/values-is/strings.xml +++ b/OsmAnd/res/values-is/strings.xml @@ -3777,7 +3777,7 @@ \n \nVeldu %2$s: öllum gögnum sem tengjast hraðamyndavélum; t.d. aðvaranir, tilkynningar, staðsetningar o.fl. verður eytt þar til OsmAnd er sett inn aftur frá grunni. Veldu ferilskrá þar sem nýjum bút verður bætt inn. - Veldu hvernig eigi að tengja punkta; með beinni línu eða reikna leið milli þeirra eins og tiltekið er hér að neðan. + Veldu hvernig eigi að tengja punktana; með beinni línu eða reikna leið milli þeirra eins og tiltekið er hér að neðan. Allur ferillinn verður endurreiknaður með völdu sniði. Lokaður OSM-minnispunktur Allur ferillinn @@ -3914,4 +3914,35 @@ Veldu millibil skráninga í almenna leiðarskráningu (virkjað með viðmótshlutanum fyrir GPX-skráningu á kortinu). Setja skráningu í bið Halda áfram með skráningu + • Uppfærðar aðgerðir í skipulagningu leiða: mismunandi leiðsögn á hverjum bút auk slóða +\n +\n • Ný útlitsvalmynd fyrir slóðir: val á lit, þykkt, birting stefnuörva, táknmynda við upphaf/endi +\n +\n • Bættur sýnileiki hjólreiðahnúta. +\n +\n • Hægt að ýta á slóðir, hafa samhengisvalmynd með grunnupplýsingum. +\n +\n • Bætt reiknirit leitar +\n +\n • Bættir valkostir fyrir \'Fylgja slóð\' í leiðsögn +\n +\n • Lagfærð vandamál við inn/útflutning á stillingum sniða +\n +\n + Bíddu eftir endurútreikningi leiðar. +\nGrafið verður tiltækt eftir endurútreikning. + Fyrir akstur vélsleða á sérstökum vegum og slóðum. + %1$s gögn aðeins tiltæk á vegunum, þú þarft að reikna leið með “Leið milli punkta” til að fá hana. + Skrá hefur þegar verið flutt inn í OsmAnd + Bil + Takk fyrir að kaupa \'Hæðarlínur\' + Áskriftargjaldið verður rukkað miðað við valið tímabil. Þú getur sagt áskriftinni upp hvenær sem er á AppGallery. + Nota 2-umferða A* leiðararútreikning + Greiðsla verður gjaldfærð á AppGallery reikninginn þinn við staðfestingu á kaupunum. +\n +\n Áskrift endurnýjast sjálfkrafa nema hún sé felld niður fyrir endurnýjunardag. Reikningur þinn verður einungis gjaldfærður fyrir endurnýjunartímabil (mánuður / þrír mánuðir / ár) á endurnýjunardegi. +\n +\n Þú getur stýrt og aflýst áskriftunum þínum með því að fara í AppGallery stillingarnar þínar. + Graf + %1$s — %2$s \ No newline at end of file From a267ff4b9c1354ae3dd96dabc59c2e3b935f35e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sveinn=20=C3=AD=20Felli?= Date: Wed, 28 Oct 2020 14:26:11 +0000 Subject: [PATCH 25/31] Translated using Weblate (Icelandic) Currently translated at 100.0% (3829 of 3829 strings) --- OsmAnd/res/values-is/phrases.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-is/phrases.xml b/OsmAnd/res/values-is/phrases.xml index 07ff354d7e..564d5dfea5 100644 --- a/OsmAnd/res/values-is/phrases.xml +++ b/OsmAnd/res/values-is/phrases.xml @@ -3802,7 +3802,7 @@ Vatnsyfirborð: í kafi Vatnsyfirborð: að hluta í kafi Gróft - Merki til að finna staurinn + Internetaðgangur: viðskiptavinir Staða dælu: vantar bita Sog Undir þrýstingi @@ -3830,4 +3830,8 @@ LNG Brottfaratafla: nei Brottfaratafla + Meðfram götu + Skýli + Á þaki + GPX-punktur \ No newline at end of file From 245192bceaf88637883e8ac8cbac5908f48ec311 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Wed, 28 Oct 2020 07:47:15 +0000 Subject: [PATCH 26/31] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3512 of 3512 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index e01741d9c3..c25c031f20 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -3821,7 +3821,7 @@ 反向路線 整個軌跡都會使用選定的設定檔重新計算。 僅下一個片段會使用選定的設定檔重新計算。 - 選取如何連接點,透過直線或以下面選定的方法計算其間的路徑。 + 選擇如何連接點,透過直線或以下面選定的方法計算其間的路徑。 整個軌道 下一段 接下來,使用您其中一個導航設定檔來將路線貼齊到最近可用的道路上以使用此選項。 From 2fe577601308255f510065762be77d860f9f4f55 Mon Sep 17 00:00:00 2001 From: Franco Date: Wed, 28 Oct 2020 21:58:27 +0000 Subject: [PATCH 27/31] Translated using Weblate (Spanish) Currently translated at 100.0% (271 of 271 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/es/ --- OsmAnd-telegram/res/values-es/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd-telegram/res/values-es/strings.xml b/OsmAnd-telegram/res/values-es/strings.xml index 63c0fcf19b..29442e4212 100644 --- a/OsmAnd-telegram/res/values-es/strings.xml +++ b/OsmAnd-telegram/res/values-es/strings.xml @@ -268,4 +268,8 @@ Última respuesta: hace %1$s hace %1$s ERR + Exportar + Búfer de Logcat + Selecciona y comparte logs detallados de la app + Enviar informe \ No newline at end of file From 2d5f5e13486d1a38c6b531d3dd2e9e663f8bce9f Mon Sep 17 00:00:00 2001 From: Gilbert Lowel Date: Wed, 28 Oct 2020 15:02:37 +0000 Subject: [PATCH 28/31] Translated using Weblate (Dutch) Currently translated at 95.5% (3357 of 3512 strings) --- OsmAnd/res/values-nl/strings.xml | 92 +++++++++++++++++--------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index ee068917d6..6557da422c 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -12,7 +12,7 @@ Kijkrichting Transparante widgets continu - Vectorkaarten worden vaak sneller weergegeven. Werkt niet op sommige apparaten. + Vectorkaarten worden vaak sneller weergegeven. Werkt niet op alle toestellen. Kies een stem en test door aankondigingen af te spelen: OsmAnd fout-opsporing en ontwikkeling Interne kaartgeneratie @@ -218,7 +218,7 @@ Taal niet ondersteund De gekozen taal wordt niet ondersteund door de geïnstalleerde Android TTS (tekst-naar-spraak) stemgenerator. De standaard TTS taal zal worden gebruikt. Zoek een andere TTS stemgenerator op de markt\? Ontbrekende gegevens - Geen gegevens voor de geselecteerde taal geïnstalleerd. Wil je naar de Play-store gaan om deze te installeren? + Geen gegevens voor de geselecteerde taal geïnstalleerd. Ga naar \"Play Store\" om deze te installeren\? Keer richting van GPX-track om Huidige bestemming gebruiken Volg de gehele track @@ -251,7 +251,7 @@ Fout bij offline zoeken. Zoek adres in de offline kaarten Systeem - App toon talen (OsmAnd dient opnieuw gestart). + App \"Toon talen\" (OsmAnd dient opnieuw gestart). Toon talen Wijzig de eenheid van afstand voor metingen. Afstand eenheden @@ -433,7 +433,7 @@ Naar signaal zoeken… Zoek bij het midden van de kaart Zoek dichtbij - Zelfde als apparaat-instelling + Zelfde als apparaatinstelling Portret Landschap Kaartscherm-oriëntatie @@ -642,7 +642,7 @@ \n \nRasterkaarten zijn direct via online bronnen verkrijgbaar of kunnen voor offline gebruik gereedgemaakt worden (en handmatig gekopieerd naar de OsmAnd gegevensmap) als SQLite database door diverse hulpprogramma\'s van derden. Instellingen om tracking en navigatie te kunnen gebruiken met het scherm uit (schakelt de GPS periodiek in). - "Maakt de toegankelijkheidsopties van het toestel rechtstreeks beschikbaar in OsmAnd. Hiermee kan o.a. de spreeksnelheid van tekst-naar-spraak-stemmen aangepast worden, D-pad schermnavigatie geconfigureerd worden, een trackball gebruikt worden voor de zoomregeling, of het gebruiken van meldingen via tekst-naar-spraak, bijvoorbeeld het automatisch melden van de positie." + Maakt de toegankelijkheidsopties van het toestel rechtstreeks beschikbaar in OsmAnd. Hiermee kan o.a. de spreeksnelheid van tekst-naar-spraak stemmen aangepast worden, D-pad schermnavigatie geconfigureerd worden, een trackball gebruikt worden voor de zoomregeling, of het gebruiken van meldingen via tekst-naar-spraak, bijvoorbeeld het automatisch melden van de positie. Deze plug-in toont de instellingen voor ontwikkel- en debug-opties, zoals routetest en -simulatie, schermweergave-prestaties, en spraaksturing. Deze instellingen zijn bedoeld voor programmeurs die OsmAnd willen verbeteren en zijn niet nodig voor normaal gebruik. Plugins beheren Schakel plugins in voor speciale functies en extra instellingen. @@ -750,7 +750,7 @@ OsmAnd is een open-source navigatiesysteem met online en offline kaarten OsmAnd (OSM Automated Navigation Directions) \n -\n OsmAnd is een open-source navigatie-app die toegang geeft tot een grote variëteit aan wereldwijde OSM-gegevens. Alle kaartgegevens (vector- of rasterkaarten) kunnen in het telefoongeheugen worden opgeslagen voor offline gebruik. OsmAnd biedt ook zowel offline als online routeaanwijzingen, met stembegeleiding. +\nOsmAnd is een open-source navigatie-app die toegang geeft tot een grote variëteit aan wereldwijde OSM-gegevens. Alle kaartgegevens (vector- of rasterkaarten) kunnen in het telefoongeheugen worden opgeslagen voor offline gebruik. OsmAnd biedt ook zowel offline als online routeaanwijzingen, met stembegeleiding. \n \n Enkele van de belangrijkste mogelijkheden: \n - Volledig offline gebruik (gedownloade vector- of rasterkaarten worden opgeslagen op het apparaat) @@ -767,9 +767,9 @@ \n \n Beperkingen van deze gratis versie van OsmAnd: \n - Beperkt aantal kaartdownloads -\n - Geen toegang tot offline Wikipedia POI\'s. +\n - Geen toegang tot offline Wikipedia POI\'s \n -\n OsmAnd wordt actief ontwikkeld en ons project en de verdere vooruitgang ervan is afhankelijk van +\nOsmAnd wordt actief ontwikkeld en ons project en de verdere vooruitgang ervan is afhankelijk van \nfinanciële bijdragen om de ontwikkeling en testen van nieuwe functionaliteit te kunnen bekostigen. \nWij verzoeken je om OsmAnd+ te kopen, of om een donatie over te maken via https://osmand.net. OsmAnd+ (OSM Automated Navigation Directions) @@ -1283,7 +1283,7 @@ Widgets Linker Kolom Kaart instellen Binnen - Anonieme gebruikesr kunnen geen + Anonieme gebruikers kunnen geen \n- groepen aanmaken; \n- groepen en apparaten synchroniseren met de server; \n- groepen en apparaten beheren in een eigen omgeving op de website. @@ -1437,7 +1437,7 @@ Start Stop Importeren - Export naar OSM + Exporteer naar OSM Meer… Meer acties Toon niet meer @@ -2285,10 +2285,10 @@ \n • Toon POIs (Points Of Interest) in uw omgeving \n • Draai de kaart in uw bewegingsrichting (of kompasrichting) \n • Toon uw positie en waar u naar kijkt -\n • Deel uw lokatie met vrienden +\n • Deel uw locatie met vrienden \n • Bewaar belangrijke plaatsen in ‘Favorieten’ \n • Toon namen in het Engels, de lokale taal, of fonetisch -\n • Toon extra online tiles, zoals een satellietfoto (van Bing), verschillende extra lagen zoals GPX-tracks voor navigatie e.d. met instelbare transparantie +\n • Toon extra online tegels, zoals een satellietfoto (van Bing), verschillende extra lagen zoals GPX-tracks voor navigatie e.d. met instelbare transparantie \n Skiën \nMet de OsmAnd Ski plug-in ziet u pistes met hun moeilijkheidsgraad, en extra informatie zoals liften en andere faciliteiten. @@ -2302,7 +2302,7 @@ \n • De kaart toont voetpaden en wandelpaden \n • Wikipedia kan je veel vertellen tijdens een stadswandeling, in je eigen taal \n • OV-haltes (tram, bus, trein, metro), inclusief lijnnummers, helpen je bij het reizen in een onbekende stad -\n • GPS-navigatie in voetgangermodus gebruikt voor het berekenen van de route voet- en wandelpaden +\n • GPS-navigatie in voetgangersmodus gebruikt voor het berekenen van de route voet- en wandelpaden \n • Upload en volg een GPX-route of neem er zelf één op en deel deze. \n Draag bij aan OpenStreetMap (OSM) @@ -2384,7 +2384,7 @@ \n • Kaart draaien in kompas- of bewegingsrichting \n • Bewaar belangrijke plaatsen in ‘Favorieten’. \n • Toon POI’s (points of interest) in de buurt -\n • Toon specifieke online tiles, satellietbeelden (van Bing), en extra lagen zoals GPX-tracks met rit-/routeinformatie e.d., met instelbare transparantie +\n • Toon specifieke online tegels, satellietbeelden (van Bing), en extra lagen zoals GPX-tracks met rit-/routeinformatie e.d., met instelbare transparantie \n • Toon plaatsnamen in het Engels, de lokale taal of fonetisch weergegeven \n Gebruik OSM- en Wikipedia-gegevens @@ -3235,7 +3235,7 @@ \'Freeride\' en \'Off-piste\' zijn officieuze routes en passages. Meestal onverzorgd en niet onderhouden, en niet \'s avonds gecontroleerd. Betreden op eigen risico. Verzamelde data Laatste OsmAnd uitvoering gecrasht. Help ons alstublieft OsmAnd te verbeteren door de foutmelding te delen. - Personal transporter + Persoonlijke transporteur Offroad WunderLINQ Wegtype @@ -3298,24 +3298,24 @@ Uitschakelen Nieuwe plug-in toegevoegd Segmenten samenvoegen - • App profiles: Create a custom profile for your own needs, with a custom icon and color -\n -\n • Nu aan te passen standaard en min / max snelheden voor elk profiel -\n -\n • Widget toegevoegd voor de huidige coördinaten -\n -\n • Opties toegevoegd om het kompas en een straalliniaal op de kaart te tonen -\n -\n • Fix background track logging -\n -\n • Improved background map downloads -\n -\n • \'Zet scherm aan\' optie is terug -\n -\n • Wikipedia taalkeuze aangepast -\n -\n • Vast kompasknop tijdens navigatie -\n + • App-profielen: maak een eigen profiel, met een aangepast pictogram en kleur +\n +\n • Nu aan te passen standaard en min / max snelheden voor elk profiel +\n +\n • Widget toegevoegd voor de huidige coördinaten +\n +\n • Opties toegevoegd om het kompas en een straalliniaal op de kaart te tonen +\n +\n • Trackregistratie op de achtergrond herstellen +\n +\n • Verbeterde downloads van achtergrondkaarten +\n +\n • \'Zet scherm aan\' optie is terug +\n +\n • Wikipedia taalkeuze aangepast +\n +\n • Vast kompasknop tijdens navigatie +\n \n • Andere fouten verholpen \n \n @@ -3567,7 +3567,7 @@ Vervang een ander punt door dit punt. Toerskiën Sneeuwscooter - Aangepaste OsmAnd-plug-in + Aangepaste OsmAnd plug-in Elementen Wijzigingen toegepast op het \'%1$s\'-profiel. Kon niet lezen van \'%1$s\'. @@ -3579,7 +3579,7 @@ Alle talen Om Wikipedia-POI’s op de kaart te tonen zijn extra kaarten nodig. Selecteer de talen voor Wikipedia-artikelen op de kaart. Tijdens het lezen van het artikel kan omgeschakeld worden naar een andere beschikbare taal. - Sommige Wikipedia-artikelen zijn mogelijk niet beschikbaar in de eigen taal. + Sommige Wikipedia-artikelen zijn mogelijk niet beschikbaar in je eigen taal. Kantonees Minnanyu Yoruba @@ -3624,8 +3624,8 @@ App-profiel wijzigingen Wereldoverzichtskaart (gedetailleerd) Niet ondersteund type - Geef de voertuigbreedte op, er zijn mogelijk routebeperkingen voor brede voertuigen. - Geef de voertuighoogte op, er zijn mogelijk routebeperkingen voor hoge voertuigen. + Geef de voertuigbreedte op, er zijn mogelijk routebeperkingen voor te brede voertuigen. + Geef de voertuighoogte op, er zijn mogelijk routebeperkingen voor te hoge voertuigen. Geef het voertuiggewicht op, er zijn mogelijk routebeperkingen voor zwaar verkeer. OsmAnd GPX is corrupt, neem contact op met het support team voor verder onderzoek. Altijd @@ -3636,7 +3636,7 @@ Scherm aanzetten bij elke routeaanwijzing. Routeaanwijzingen Uitgeschakeld. De instelling ‘Timeout na wakker worden’ moet ingesteld zijn op ‘Scherm aanlaten’. - Door op de aan/uit-knop te drukken gaat het scherm aan met OsmAnd op de voorgrond van het vergrendelscherm. + Door op de aan/uit knop te drukken gaat het scherm aan met OsmAnd op de voorgrond van het vergrendelde scherm. Aan/uit-knop Nabijheidssensor Selecteer de schermtimeout na wakker worden. (Kies “%1$s” om geen timeout te gebruiken.) @@ -3682,7 +3682,7 @@ Kies hoe gedownloade rasterkaartsegmenten worden opgeslagen. Geen overeenkomende profielen gevonden. Time-out van het scherm - Inschakelen om het zoomniveau van de kaart in te stellen met de volumeknoppen. + Regel het zoomniveau, van de kaart, met de volumeknop op het apparaat. Gebruik volumeknoppen om in en uit te zoomen Verkrijg informatie over POIs uit Wikipedia. Het is je offline reisgidsje - schakel de Wikipedia-plug-in in en geniet van artikelen over de bezienswaardigheden in je omgeving. Geef de voertuiglengte op, er zijn mogelijk routebeperkingen voor lange voertuigen. @@ -3704,10 +3704,10 @@ Selecteer dikte Toon start en aankomst pictogrammen Richtingaanwijzers - Het toegevoegde punt zal niet zichtbaar zijn op de kaart, aangezien de geselecteerde groep verborgen is, je kan het vinden in \"% s\". + Het toegevoegde punt zal niet zichtbaar zijn op de kaart, aangezien de geselecteerde groep verborgen is, je kan het vinden in \"%s\". Standaard Route tussen punten - "Vervolgens, zet uw track vast op de dichtstbijzijnde toegestane weg met een van uw navigatieprofielen om deze optie te gebruiken." + Vervolgens, zet uw track vast op de dichtstbijzijnde toegestane weg met een van uw navigatieprofielen om deze optie te gebruiken. %1$s gegevens alleen beschikbaar op de wegen, u moet een route berekenen met behulp van \"Route tussen punten\" om deze te krijgen. Selecteer hoe de punten verbonden worden, via een rechte lijn, of een route berekenen tussen de punten zoals hieronder aangegeven. Alleen het volgende segment wordt opnieuw berekend met het geselecteerde profiel. @@ -3744,7 +3744,7 @@ Alleen de routelijn wordt opgeslagen, de waypoints worden verwijderd. Bewaar Route omkeren - "Selecteer een track waaraan je een nieuw segment wil toevoegen." + Selecteer een track waaraan je een nieuw segment wil toevoegen. Selecteer een trackbestand om te openen. Weet u zeker dat u alle wijzigingen in de geplande route wilt annuleren door deze te sluiten\? Opsmukken voor @@ -3771,4 +3771,12 @@ Maak een nieuwe route Open een bestaande track Plan een route + Gebruik 2-fasen A* routeringsalgoritme + Grafiek + Wacht op de herberekening van de route. +\nDe grafiek is beschikbaar na herberekening. + %1$s — %2$s + Kies een trackbestand om te volgen of importeer het, vanaf uw apparaat. + Kloof + Op maat \ No newline at end of file From 2d4ea903787eda67f7696cd4c406d3c4f96566a3 Mon Sep 17 00:00:00 2001 From: Gilbert Lowel Date: Wed, 28 Oct 2020 14:58:27 +0000 Subject: [PATCH 29/31] Translated using Weblate (Dutch) Currently translated at 93.3% (253 of 271 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/nl/ --- OsmAnd-telegram/res/values-nl/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd-telegram/res/values-nl/strings.xml b/OsmAnd-telegram/res/values-nl/strings.xml index b77535908e..ebddf36454 100644 --- a/OsmAnd-telegram/res/values-nl/strings.xml +++ b/OsmAnd-telegram/res/values-nl/strings.xml @@ -257,4 +257,8 @@ Afstand eenheden Definieer de eenheid voor snelheid. Eenheid van snelheid + Stuur rapport + Exporteer naar OSM + Logcat buffer + Controleer en deel gedetailleerde logs van de app \ No newline at end of file From 1a9f9229cf17ad436b62cf4b5b1432f97e6bc940 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 29 Oct 2020 13:19:32 +0200 Subject: [PATCH 30/31] Fix possible CursorWindowAllocationException --- .../src/net/osmand/plus/SQLiteTileSource.java | 21 ++++++------- .../osmand/plus/srtmplugin/TerrainLayer.java | 30 +++++++++---------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java index b3d7ceb144..da9af5dca9 100644 --- a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java +++ b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java @@ -509,26 +509,27 @@ public class SQLiteTileSource implements ITileSource { if(db == null || coordinatesZoom > 25 ){ return null; } - SQLiteCursor q ; + SQLiteCursor cursor ; if (inversiveZoom) { int minZoom = (17 - minZ) + 1; // 17 - z = zoom, x << (25 - zoom) = 25th x tile = 8 + z, - q = db.rawQuery("SELECT max(x << (8+z)), min(x << (8+z)), max(y << (8+z)), min(y << (8+z))" + + cursor = db.rawQuery("SELECT max(x << (8+z)), min(x << (8+z)), max(y << (8+z)), min(y << (8+z))" + " from tiles where z < " + minZoom, new String[0]); } else { - q = db.rawQuery("SELECT max(x << (25-z)), min(x << (25-z)), max(y << (25-z)), min(y << (25-z))" + cursor = db.rawQuery("SELECT max(x << (25-z)), min(x << (25-z)), max(y << (25-z)), min(y << (25-z))" + " from tiles where z > " + minZ, new String[0]); } - q.moveToFirst(); - int right = (int) (q.getInt(0) >> (25 - coordinatesZoom)); - int left = (int) (q.getInt(1) >> (25 - coordinatesZoom)); - int top = (int) (q.getInt(3) >> (25 - coordinatesZoom)); - int bottom = (int) (q.getInt(2) >> (25 - coordinatesZoom)); + cursor.moveToFirst(); + int right = (int) (cursor.getInt(0) >> (25 - coordinatesZoom)); + int left = (int) (cursor.getInt(1) >> (25 - coordinatesZoom)); + int top = (int) (cursor.getInt(3) >> (25 - coordinatesZoom)); + int bottom = (int) (cursor.getInt(2) >> (25 - coordinatesZoom)); + + cursor.close(); + return new QuadRect(left, top, right, bottom); - - } public void deleteImage(int x, int y, int zoom) { diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java index 79e47de648..b58dc807a8 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java @@ -35,7 +35,7 @@ import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE; public class TerrainLayer extends MapTileLayer { private final static Log log = PlatformUtil.getLog(TerrainLayer.class); - private Map resources = new LinkedHashMap(); + private Map resources = new LinkedHashMap(); private final static String HILLSHADE_CACHE = "hillshade.cache"; private final static String SLOPE_CACHE = "slope.cache"; private int ZOOM_BOUNDARY = 15; @@ -68,7 +68,6 @@ public class TerrainLayer extends MapTileLayer { } else { // ignore } - } private void indexTerrainFiles(final OsmandApplication app) { @@ -77,7 +76,6 @@ public class TerrainLayer extends MapTileLayer { private String type = mode.name().toLowerCase(); @Override protected Void doInBackground(Void... params) { - File tilesDir = app.getAppPath(IndexConstants.TILES_INDEX_DIR); File cacheDir = app.getCacheDir(); // fix http://stackoverflow.com/questions/26937152/workaround-for-nexus-9-sqlite-file-write-operations-on-external-dirs @@ -91,17 +89,21 @@ public class TerrainLayer extends MapTileLayer { sqliteDb = null; } if (sqliteDb != null) { - if (sqliteDb.getVersion() == 0) { - sqliteDb.setVersion(1); - } - sqliteDb.execSQL("CREATE TABLE IF NOT EXISTS TILE_SOURCES(filename varchar2(256), date_modified int, left int, right int, top int, bottom int)"); + try { + if (sqliteDb.getVersion() == 0) { + sqliteDb.setVersion(1); + } + sqliteDb.execSQL("CREATE TABLE IF NOT EXISTS TILE_SOURCES(filename varchar2(256), date_modified int, left int, right int, top int, bottom int)"); - Map fileModified = new HashMap(); - Map rs = readFiles(app, tilesDir, fileModified); - indexCachedResources(fileModified, rs); - indexNonCachedResources(fileModified, rs); - sqliteDb.close(); - resources = rs; + Map fileModified = new HashMap(); + Map rs = readFiles(app, tilesDir, fileModified); + indexCachedResources(fileModified, rs); + indexNonCachedResources(fileModified, rs); + sqliteDb.close(); + resources = rs; + } catch (RuntimeException e) { + log.error(e.getMessage(), e); + } } return null; } @@ -150,7 +152,6 @@ public class TerrainLayer extends MapTileLayer { indexedResources.insert(filename, new QuadRect(left, top, right, bottom)); fileModified.remove(filename); } - } while(cursor.moveToNext()); } cursor.close(); @@ -172,7 +173,6 @@ public class TerrainLayer extends MapTileLayer { } return rs; } - }; executeTaskInBackground(task); } From a8560b8667e5ba704194ff49fdcf981d51d8d309 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 29 Oct 2020 14:35:26 +0200 Subject: [PATCH 31/31] Try to fix sound pools --- .../audionotes/AudioVideoNotesPlugin.java | 53 +++++++++++------ .../net/osmand/plus/routing/VoiceRouter.java | 57 +++++++++++++------ 2 files changed, 75 insertions(+), 35 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index c28b110c85..b8d4ef0c92 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -44,6 +44,7 @@ import net.osmand.IProgress; import net.osmand.IndexConstants; import net.osmand.Location; import net.osmand.PlatformUtil; +import net.osmand.StateChangedListener; import net.osmand.data.DataTileManager; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -158,7 +159,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public static final int AV_CAMERA_FOCUS_CONTINUOUS = 5; // photo shot: private static int shotId = 0; - private SoundPool sp = null; + private SoundPool soundPool = null; public static final int FULL_SCEEN_RESULT_DELAY_MS = 3000; public final CommonPreference AV_CAMERA_PICTURE_SIZE; @@ -596,6 +597,17 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public boolean init(@NonNull final OsmandApplication app, Activity activity) { + if (AV_PHOTO_PLAY_SOUND.get()) { + loadCameraSound(); + } + AV_PHOTO_PLAY_SOUND.addListener(new StateChangedListener() { + @Override + public void stateChanged(Boolean change) { + if (AV_PHOTO_PLAY_SOUND.get() && soundPool == null) { + loadCameraSound(); + } + } + }); // initializeRemoteControlRegistrationMethods(); // AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE); // if (am != null) { @@ -604,6 +616,21 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { return true; } + private void loadCameraSound() { + if (soundPool == null) { + soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); + } + if (shotId == 0) { + try { + AssetFileDescriptor assetFileDescriptor = app.getAssets().openFd("sounds/camera_click.ogg"); + shotId = soundPool.load(assetFileDescriptor, 1); + assetFileDescriptor.close(); + } catch (Exception e) { + log.error("cannot get shotId for sounds/camera_click.ogg"); + } + } + } + @Override public void registerLayers(MapActivity activity) { this.mapActivity = activity; @@ -1338,21 +1365,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void surfaceCreated(SurfaceHolder holder) { try { - // load sound befor shot - if (AV_PHOTO_PLAY_SOUND.get()) { - if (sp == null) - sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); - if (shotId == 0) { - try { - AssetFileDescriptor assetFileDescriptor = app.getAssets().openFd("sounds/camera_click.ogg"); - shotId = sp.load(assetFileDescriptor, 1); - assetFileDescriptor.close(); - } catch (Exception e) { - log.error("cannot get shotId for sounds/camera_click.ogg"); - } - } - } - Parameters parameters = cam.getParameters(); parameters.setPictureSize(selectedCamPicSize.width, selectedCamPicSize.height); log.debug("takePhotoWithCamera() set Picture size: width=" + selectedCamPicSize.width @@ -1734,6 +1746,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void disable(OsmandApplication app) { + if (soundPool != null) { + soundPool.release(); + soundPool = null; + shotId = 0; + } // AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE); // if (am != null) { // unregisterMediaListener(am); @@ -2043,8 +2060,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { photoJpegData = data; if (AV_PHOTO_PLAY_SOUND.get()) { - if (sp != null && shotId != 0) { - sp.play(shotId, 0.7f, 0.7f, 0, 0, 1); + if (soundPool != null && shotId != 0) { + soundPool.play(shotId, 0.7f, 0.7f, 0, 0, 1); } } diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index b4cabfb389..4358938079 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -1,20 +1,22 @@ package net.osmand.plus.routing; +import android.content.res.AssetFileDescriptor; import android.media.AudioManager; import android.media.SoundPool; import net.osmand.Location; +import net.osmand.StateChangedListener; import net.osmand.binary.RouteDataObject; import net.osmand.data.PointDescription; -import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.data.StreetName; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.voice.AbstractPrologCommandPlayer; import net.osmand.plus.voice.CommandBuilder; import net.osmand.plus.voice.CommandPlayer; @@ -80,7 +82,10 @@ public class VoiceRouter { private int TURN_IN_DISTANCE; private int TURN_IN_DISTANCE_END; private int TURN_NOW_DISTANCE; - + + private SoundPool soundPool; + private int soundClick = -1; + private VoiceCommandPending pendingCommand = null; private RouteDirectionInfo nextRouteDirection; @@ -103,8 +108,36 @@ public class VoiceRouter { } }; app.getAppCustomization().addListener(customizationListener); + + if (!isMute()) { + loadCameraSound(); + } + settings.VOICE_MUTE.addListener(new StateChangedListener() { + @Override + public void stateChanged(Boolean change) { + if (!isMute() && soundPool == null) { + loadCameraSound(); + } + } + }); } - + + private void loadCameraSound() { + if (soundPool == null) { + soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); + } + if (soundClick == -1) { + try { + // Taken unaltered from https://freesound.org/people/Corsica_S/sounds/91926/ under license http://creativecommons.org/licenses/by/3.0/ : + AssetFileDescriptor assetFileDescriptor = app.getAssets().openFd("sounds/ding.ogg"); + soundClick = soundPool.load(assetFileDescriptor, 1); + assetFileDescriptor.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + public void setPlayer(CommandPlayer player) { this.player = player; if (pendingCommand != null && player != null) { @@ -1015,18 +1048,8 @@ public class VoiceRouter { if (isMute()) { return; } - SoundPool sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); - int soundClick = -1; - boolean success = true; - try { - // Taken unaltered from https://freesound.org/people/Corsica_S/sounds/91926/ under license http://creativecommons.org/licenses/by/3.0/ : - soundClick = sp.load(settings.getContext().getAssets().openFd("sounds/ding.ogg"), 1); - } catch (IOException e) { - e.printStackTrace(); - success = false; - } - if (success) { - sp.play(soundClick, 1 ,1, 0, 0, 1); + if (soundPool != null && soundClick != -1) { + soundPool.play(soundClick, 1, 1, 0, 0, 1); } }