From 75d37ce76e31508046f7aadb4745487aa27deca8 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 15 Dec 2017 16:29:06 +0200 Subject: [PATCH 01/16] Fix #4698 --- .../osmand/plus/osmedit/OpenstreetmapLocalUtil.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java index 0370cfb7ff..591d502ec5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java @@ -2,6 +2,8 @@ package net.osmand.plus.osmedit; import net.osmand.PlatformUtil; import net.osmand.data.Amenity; +import net.osmand.osm.AbstractPoiType; +import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiType; import net.osmand.osm.edit.EntityInfo; import net.osmand.osm.edit.Node; @@ -13,6 +15,7 @@ import org.apache.commons.logging.Log; import java.util.ArrayList; import java.util.List; +import java.util.Map; public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { @@ -86,6 +89,16 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { entity.putTagNoLC(OSMTagKey.OPENING_HOURS.getValue(), n.getOpeningHours()); } + for (Map.Entry entry : n.getAdditionalInfo().entrySet()) { + AbstractPoiType abstractPoi = MapPoiTypes.getDefault().getAnyPoiAdditionalTypeByKey(entry.getKey()); + if (abstractPoi != null && abstractPoi instanceof PoiType) { + PoiType p = (PoiType) abstractPoi; + if (!p.isNotEditableOsm() && !Algorithms.isEmpty(p.getOsmTag())) { + entity.putTagNoLC(p.getOsmTag(), entry.getValue()); + } + } + } + // check whether this is node (because id of node could be the same as relation) if(entity != null && MapUtils.getDistance(entity.getLatLon(), n.getLocation()) < 50){ return entity; From 1a32ce290ee535ab3b107666bb9d0037d68a76f2 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 18 Dec 2017 18:44:15 +0200 Subject: [PATCH 02/16] Fix #4849 --- .../plus/osmedit/OpenstreetmapRemoteUtil.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index d091660db2..15fab879fc 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -1,20 +1,7 @@ package net.osmand.plus.osmedit; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.StringWriter; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.text.MessageFormat; -import java.util.LinkedHashMap; -import java.util.Map; +import android.util.Xml; +import android.widget.Toast; import net.osmand.PlatformUtil; import net.osmand.data.Amenity; @@ -37,8 +24,21 @@ import org.apache.commons.logging.Log; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlSerializer; -import android.util.Xml; -import android.widget.Toast; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.text.MessageFormat; +import java.util.LinkedHashMap; +import java.util.Map; public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { @@ -330,7 +330,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { Node entity = (Node) st.getRegisteredEntities().get(id); // merge non existing tags for (String rtag : entity.getTagKeySet()) { - if (!n.getTagKeySet().contains(rtag)) { + if (!n.getTagKeySet().contains(rtag) && !n.getTagKeySet().contains("----" + rtag)) { n.putTagNoLC(rtag, entity.getTag(rtag)); } } From 2ae67410091e12270c616722a35fd979418da4c9 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 19 Dec 2017 12:38:31 +0200 Subject: [PATCH 03/16] Replace hardcode with constant --- OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index 15fab879fc..f0df9f2f38 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -330,7 +330,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { Node entity = (Node) st.getRegisteredEntities().get(id); // merge non existing tags for (String rtag : entity.getTagKeySet()) { - if (!n.getTagKeySet().contains(rtag) && !n.getTagKeySet().contains("----" + rtag)) { + if (!n.getTagKeySet().contains(rtag) && !n.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + rtag)) { n.putTagNoLC(rtag, entity.getTag(rtag)); } } From 81d0ce060b4707fa4c7eb9af99a2df5a9ba7e5f6 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 19 Dec 2017 17:27:16 +0200 Subject: [PATCH 04/16] Use values from the openstreetmap for all tags, except for changed --- .../src/net/osmand/osm/edit/Entity.java | 9 ++++ .../net/osmand/plus/osmedit/EditPoiData.java | 16 +++++- .../plus/osmedit/EditPoiDialogFragment.java | 22 ++++---- .../plus/osmedit/OpenstreetmapLocalUtil.java | 5 +- .../plus/osmedit/OpenstreetmapRemoteUtil.java | 17 +++++- .../plus/osmedit/OpenstreetmapUtil.java | 12 +++-- .../plus/osmedit/OpenstreetmapsDbHelper.java | 52 ++++++++++++++++--- .../osmand/plus/osmedit/OsmEditsLayer.java | 2 +- .../UploadOpenstreetmapPointAsyncTask.java | 2 +- .../quickaction/actions/AddPOIAction.java | 2 +- 10 files changed, 110 insertions(+), 29 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/osm/edit/Entity.java b/OsmAnd-java/src/net/osmand/osm/edit/Entity.java index 685131981d..63d776b73e 100644 --- a/OsmAnd-java/src/net/osmand/osm/edit/Entity.java +++ b/OsmAnd-java/src/net/osmand/osm/edit/Entity.java @@ -103,6 +103,7 @@ public abstract class Entity implements Serializable { // lazy initializing private Map tags = null; + private Set changedTags; private final long id; private boolean dataLoaded; private int modify; @@ -125,6 +126,14 @@ public abstract class Entity implements Serializable { this.dataLoaded = copy.dataLoaded; } + public Set getChangedTags() { + return changedTags; + } + + public void setChangedTags(Set changedTags) { + this.changedTags = changedTags; + } + public int getModify() { return modify; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index 27d85343e5..146ec426f2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -9,6 +9,7 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; @@ -28,6 +29,8 @@ public class EditPoiData { private boolean hasChangesBeenMade = false; private Map allTranslatedSubTypes; private PoiCategory category; + + private Set changedTags = new HashSet<>(); public EditPoiData(Node node, OsmandApplication app) { allTranslatedSubTypes = app.getPoiTypes().getAllTranslatedNames(true); @@ -45,6 +48,7 @@ public class EditPoiData { if(type != null && type != category) { category = type; tagValues.put(POI_TYPE_TAG, ""); + changedTags.add(POI_TYPE_TAG); } } @@ -74,6 +78,7 @@ public class EditPoiData { checkNotInEdit(); this.tagValues.clear(); this.tagValues.putAll(mp); + changedTags.clear(); retrieveType(); } @@ -112,6 +117,7 @@ public class EditPoiData { isInEdit = true; tagValues.remove(REMOVE_TAG_PREFIX+tag); tagValues.put(tag, value); + changedTags.add(tag); notifyDatasetChanged(tag); } finally { isInEdit = false; @@ -141,6 +147,7 @@ public class EditPoiData { isInEdit = true; tagValues.put(REMOVE_TAG_PREFIX+tag, REMOVE_TAG_VALUE); tagValues.remove(tag); + changedTags.remove(tag); notifyDatasetChanged(tag); } finally { isInEdit = false; @@ -154,8 +161,11 @@ public class EditPoiData { public boolean isInEdit() { return isInEdit; } - - + + public Set getChangedTags() { + return changedTags; + } + private void notifyDatasetChanged(String tag) { if (mListeners.size() > 0) { hasChangesBeenMade = true; @@ -185,6 +195,7 @@ public class EditPoiData { public void updateTypeTag(String string) { tagValues.put(POI_TYPE_TAG, string); + changedTags.add(POI_TYPE_TAG); retrieveType(); PoiType pt = getPoiTypeDefined(); if(pt != null) { @@ -192,6 +203,7 @@ public class EditPoiData { tagValues.put(REMOVE_TAG_PREFIX+pt.getOsmTag2(), REMOVE_TAG_VALUE); tagValues.remove(pt.getOsmTag()); tagValues.remove(pt.getOsmTag2()); + changedTags.removeAll(Arrays.asList(pt.getOsmTag(), pt.getOsmTag2())); category = pt.getCategory(); } notifyDatasetChanged(POI_TYPE_TAG); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 1d2ec237c8..01c5e57447 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -11,6 +11,7 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.design.widget.TextInputLayout; import android.support.v4.app.DialogFragment; @@ -61,6 +62,7 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndDialogFragment; +import net.osmand.plus.osmedit.OsmPoint.Action; import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment; import net.osmand.plus.osmedit.dialogs.PoiTypeDialogFragment; import net.osmand.util.Algorithms; @@ -74,6 +76,7 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { public static final String TAG = "EditPoiDialogFragment"; @@ -426,7 +429,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { Node original = editPoiData.getEntity(); final boolean offlineEdit = mOpenstreetmapUtil instanceof OpenstreetmapLocalUtil; Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId()); - OsmPoint.Action action = node.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; + Action action = node.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)) { @@ -451,7 +454,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) { node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag); } - String actionString = action == OsmPoint.Action.CREATE ? getString(R.string.default_changeset_add) : getString(R.string.default_changeset_edit); + String actionString = action == Action.CREATE ? getString(R.string.default_changeset_add) : getString(R.string.default_changeset_edit); comment = actionString + " " + poiTypeTag; } commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), comment, false, @@ -486,7 +489,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { return false; } - }, getActivity(), mOpenstreetmapUtil); + }, getActivity(), mOpenstreetmapUtil, action == Action.MODIFY ? editPoiData.getChangedTags() : null); } private void dismissCheckForChanges() { @@ -506,15 +509,16 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { poiTypeEditText.setText(subCategory); } - public static void commitNode(final OsmPoint.Action action, + public static void commitNode(final Action action, final Node node, final EntityInfo info, final String comment, final boolean closeChangeSet, final CallbackWithObject postExecute, final Activity activity, - final OpenstreetmapUtil openstreetmapUtil) { - if (info == null && OsmPoint.Action.CREATE != action && openstreetmapUtil instanceof OpenstreetmapRemoteUtil) { + final OpenstreetmapUtil openstreetmapUtil, + @Nullable final Set changedTags) { + if (info == null && Action.CREATE != action && openstreetmapUtil instanceof OpenstreetmapRemoteUtil) { Toast.makeText(activity, activity.getResources().getString(R.string.poi_error_info_not_loaded), Toast.LENGTH_LONG).show(); return; } @@ -529,7 +533,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { @Override protected Node doInBackground(Void... params) { - return openstreetmapUtil.commitNodeImpl(action, node, info, comment, closeChangeSet); + return openstreetmapUtil.commitNodeImpl(action, node, info, comment, closeChangeSet, changedTags); } @Override @@ -757,7 +761,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { private void deleteNode(final Node n, final String c, final boolean closeChangeSet) { final boolean isLocalEdit = openstreetmapUtil instanceof OpenstreetmapLocalUtil; - commitNode(OsmPoint.Action.DELETE, n, openstreetmapUtil.getEntityInfo(n.getId()), c, closeChangeSet, + commitNode(Action.DELETE, n, openstreetmapUtil.getEntityInfo(n.getId()), c, closeChangeSet, new CallbackWithObject() { @Override @@ -776,7 +780,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { } return false; } - }, activity, openstreetmapUtil); + }, activity, openstreetmapUtil, null); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java index 591d502ec5..a168788001 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java @@ -16,6 +16,7 @@ import org.apache.commons.logging.Log; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { @@ -45,12 +46,14 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { } @Override - public Node commitNodeImpl(OsmPoint.Action action, Node n, EntityInfo info, String comment, boolean closeChangeSet){ + public Node commitNodeImpl(OsmPoint.Action action, Node n, EntityInfo info, String comment, + boolean closeChangeSet, Set changedTags){ Node newNode = n; if (n.getId() == -1) { newNode = new Node(n, Math.min(-2, plugin.getDBPOI().getMinID() - 1)); // generate local id for the created node } OpenstreetmapPoint p = new OpenstreetmapPoint(); + newNode.setChangedTags(changedTags); p.setEntity(newNode); p.setAction(action); p.setComment(comment); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index f0df9f2f38..a03185e54f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -39,6 +39,7 @@ import java.net.MalformedURLException; import java.text.MessageFormat; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { @@ -250,7 +251,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { @Override public Node commitNodeImpl(OsmPoint.Action action, final Node n, EntityInfo info, String comment, - boolean closeChangeSet) { + boolean closeChangeSet, Set changedTags) { if (isNewChangesetRequired()) { changeSetId = openChangeSet(comment); changeSetTimeStamp = System.currentTimeMillis(); @@ -330,7 +331,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { Node entity = (Node) st.getRegisteredEntities().get(id); // merge non existing tags for (String rtag : entity.getTagKeySet()) { - if (!n.getTagKeySet().contains(rtag) && !n.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + rtag)) { + if (!deletedTag(n, rtag) && (!containsTag(n, rtag) || !tagChanged(n, rtag))) { n.putTagNoLC(rtag, entity.getTag(rtag)); } } @@ -352,6 +353,18 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { return null; } + private boolean deletedTag(Node node, String tag) { + return node.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + tag); + } + + private boolean containsTag(Node node, String tag) { + return node.getTagKeySet().contains(tag); + } + + private boolean tagChanged(Node node, String tag) { + return node.getChangedTags() != null && node.getChangedTags().contains(tag); + } + @Override public Node loadNode(Amenity n) { if (n.getId() % 2 == 1) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapUtil.java index 5e092d438b..ae313fa17f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapUtil.java @@ -1,16 +1,20 @@ package net.osmand.plus.osmedit; +import android.support.annotation.Nullable; + import net.osmand.data.Amenity; import net.osmand.osm.edit.EntityInfo; import net.osmand.osm.edit.Node; +import java.util.Set; + public interface OpenstreetmapUtil { - public EntityInfo getEntityInfo(long id); + EntityInfo getEntityInfo(long id); - public Node commitNodeImpl(OsmPoint.Action action, Node n, EntityInfo info, String comment, boolean closeChangeSet); + Node commitNodeImpl(OsmPoint.Action action, Node n, EntityInfo info, String comment, boolean closeChangeSet, @Nullable Set changedTags); - public void closeChangeSet(); + void closeChangeSet(); - public Node loadNode(Amenity n); + Node loadNode(Amenity n); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java index 72a5da6165..08d73c1702 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java @@ -9,13 +9,16 @@ import net.osmand.osm.edit.Node; import net.osmand.util.Algorithms; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; +import java.util.Set; public class OpenstreetmapsDbHelper extends SQLiteOpenHelper { - private static final int DATABASE_VERSION = 4; + private static final int DATABASE_VERSION = 5; public static final String OPENSTREETMAP_DB_NAME = "openstreetmap"; //$NON-NLS-1$ private static final String OPENSTREETMAP_TABLE_NAME = "openstreetmaptable"; //$NON-NLS-1$ private static final String OPENSTREETMAP_COL_ID = "id"; //$NON-NLS-1$ @@ -24,11 +27,12 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper { private static final String OPENSTREETMAP_COL_TAGS = "tags"; //$NON-NLS-1$ private static final String OPENSTREETMAP_COL_ACTION = "action"; //$NON-NLS-1$ private static final String OPENSTREETMAP_COL_COMMENT = "comment"; //$NON-NLS-1$ + private static final String OPENSTREETMAP_COL_CHANGED_TAGS = "changed_tags"; private static final String OPENSTREETMAP_TABLE_CREATE = "CREATE TABLE " + OPENSTREETMAP_TABLE_NAME + " (" + //$NON-NLS-1$ //$NON-NLS-2$ OPENSTREETMAP_COL_ID + " bigint,"+ OPENSTREETMAP_COL_LAT + " double," + OPENSTREETMAP_COL_LON + " double," + OPENSTREETMAP_COL_TAGS + " VARCHAR(2048)," + - OPENSTREETMAP_COL_ACTION + " TEXT, " + OPENSTREETMAP_COL_COMMENT + " TEXT);"; //$NON-NLS-1$ //$NON-NLS-2$ + OPENSTREETMAP_COL_ACTION + " TEXT, " + OPENSTREETMAP_COL_COMMENT + " TEXT, " + OPENSTREETMAP_COL_CHANGED_TAGS + " TEXT);"; List cache = null; public OpenstreetmapsDbHelper(Context context) { @@ -46,6 +50,9 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper { db.execSQL("DROP TABLE IF EXISTS " + OPENSTREETMAP_TABLE_NAME); db.execSQL(OPENSTREETMAP_TABLE_CREATE); } + if (oldVersion < 5) { + db.execSQL("ALTER TABLE " + OPENSTREETMAP_TABLE_NAME + " ADD " + OPENSTREETMAP_COL_CHANGED_TAGS + " TEXT"); + } } public List getOpenstreetmapPoints() { @@ -70,12 +77,30 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper { tags.append("$$$"); } } + Set chTags = p.getEntity().getChangedTags(); + StringBuilder changedTags = new StringBuilder(); + if (chTags != null) { + Iterator iterator = chTags.iterator(); + while (iterator.hasNext()) { + changedTags.append(iterator.next()); + if (iterator.hasNext()) { + changedTags.append("$$$"); + } + } + } db.execSQL("DELETE FROM " + OPENSTREETMAP_TABLE_NAME + - " WHERE " + OPENSTREETMAP_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$ + " WHERE " + OPENSTREETMAP_COL_ID + " = ?", new Object[]{p.getId()}); db.execSQL("INSERT INTO " + OPENSTREETMAP_TABLE_NAME + - " (" + OPENSTREETMAP_COL_ID + ", " + OPENSTREETMAP_COL_LAT + ", " + OPENSTREETMAP_COL_LON + ", " + OPENSTREETMAP_COL_TAGS + ", " + OPENSTREETMAP_COL_ACTION + "," + OPENSTREETMAP_COL_COMMENT + ")" + - " VALUES (?, ?, ?, ?, ?, ?)", - new Object[] { p.getId(),p.getLatitude(), p.getLongitude(), tags.toString() , OsmPoint.stringAction.get(p.getAction()), p.getComment(), }); //$NON-NLS-1$ //$NON-NLS-2$ + " (" + OPENSTREETMAP_COL_ID + ", " + + OPENSTREETMAP_COL_LAT + ", " + + OPENSTREETMAP_COL_LON + ", " + + OPENSTREETMAP_COL_TAGS + ", " + + OPENSTREETMAP_COL_ACTION + ", " + + OPENSTREETMAP_COL_COMMENT + ", " + + OPENSTREETMAP_COL_CHANGED_TAGS + ")" + + " VALUES (?, ?, ?, ?, ?, ?, ?)", + new Object[]{p.getId(), p.getLatitude(), p.getLongitude(), tags.toString(), + OsmPoint.stringAction.get(p.getAction()), p.getComment(), chTags == null ? null : changedTags.toString()}); db.close(); checkOpenstreetmapPoints(); return true; @@ -102,8 +127,15 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper { SQLiteDatabase db = getReadableDatabase(); List points = new ArrayList(); if (db != null) { - Cursor query = db.rawQuery("SELECT " + OPENSTREETMAP_COL_ID + ", " + OPENSTREETMAP_COL_LAT + "," + OPENSTREETMAP_COL_LON + "," + OPENSTREETMAP_COL_ACTION + "," + OPENSTREETMAP_COL_COMMENT + "," + OPENSTREETMAP_COL_TAGS+ " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - OPENSTREETMAP_TABLE_NAME, null); + Cursor query = db.rawQuery("SELECT " + + OPENSTREETMAP_COL_ID + ", " + + OPENSTREETMAP_COL_LAT + "," + + OPENSTREETMAP_COL_LON + "," + + OPENSTREETMAP_COL_ACTION + "," + + OPENSTREETMAP_COL_COMMENT + "," + + OPENSTREETMAP_COL_TAGS + "," + + OPENSTREETMAP_COL_CHANGED_TAGS + + " FROM " + OPENSTREETMAP_TABLE_NAME, null); if (query.moveToFirst()) { do { OpenstreetmapPoint p = new OpenstreetmapPoint(); @@ -115,6 +147,10 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper { for(int i=0; i(Arrays.asList(changedTags.split("\\$\\$\\$")))); + } p.setEntity(entity); p.setAction(query.getString(3)); p.setComment(query.getString(4)); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java index 97ac98fb29..2735f88168 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java @@ -240,7 +240,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC protected Node doInBackground(Void... params) { Node node = objectInMotion.getEntity(); return mOpenstreetmapUtil.commitNodeImpl(objectInMotion.getAction(), node, - mOpenstreetmapUtil.getEntityInfo(node.getId()), "", false); + mOpenstreetmapUtil.getEntityInfo(node.getId()), "", false, null); } @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java b/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java index 86fd7d853c..3c58892d57 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java @@ -56,7 +56,7 @@ public class UploadOpenstreetmapPointAsyncTask entityInfo = remotepoi.loadNode(p.getEntity()); } Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, - p.getComment(), false); + p.getComment(), false, null); if (n != null) { uploaded = true; plugin.getDBPOI().deletePOI(p); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java index 2ce3a736de..75f02de5cd 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java @@ -157,7 +157,7 @@ public class AddPOIAction extends QuickAction { return false; } - }, activity, mOpenstreetmapUtil); + }, activity, mOpenstreetmapUtil, null); } } From 5dbfde166d9cda6e7e0e11b53ab530ffc071ad54 Mon Sep 17 00:00:00 2001 From: samyakbvs Date: Wed, 20 Dec 2017 13:00:42 +0000 Subject: [PATCH 05/16] Translated using Weblate (Spanish) Currently translated at 99.8% (3316 of 3322 strings) --- OsmAnd/res/values-es/phrases.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-es/phrases.xml b/OsmAnd/res/values-es/phrases.xml index ee9d313496..d5578a2e3d 100644 --- a/OsmAnd/res/values-es/phrases.xml +++ b/OsmAnd/res/values-es/phrases.xml @@ -3690,4 +3690,5 @@ Depósito - +Buzón + From 88b97cb9fcb889a858d9051c77a9408e38cfb346 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Tue, 19 Dec 2017 15:28:15 +0000 Subject: [PATCH 06/16] Translated using Weblate (Hebrew) Currently translated at 85.0% (2141 of 2516 strings) --- OsmAnd/res/values-he/strings.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/OsmAnd/res/values-he/strings.xml b/OsmAnd/res/values-he/strings.xml index 0bfdcd2a93..21c0886fd7 100644 --- a/OsmAnd/res/values-he/strings.xml +++ b/OsmAnd/res/values-he/strings.xml @@ -2484,4 +2484,22 @@ הפעלת הנפשת גלישת מפה של המיקום שלי במהלך ניווט. ב־%1$s ניתן לגעת בסמן על המפה כדי להעביר אותו לראש הסמנים הפעילים מבלי לפתוח את תפריט ההקשר. + \\022 זיהוי של שלטי עצור מתחשב בכיוון הניווט +\n +\n • אלגוריתם חדש מספק ערכים בעלי משמעות לעלייה/ירידה למסלולי GPX +\n +\n • זמן הטיול (כלל נייסמית׳) מודע לתוואי הדרך (עלייה) +\n +\n + הפעלה בנגיעה אחת + נא לבחור להלן באיזו מהירות כיוון המפה יתחלף ממצב ‚לפי כיוון התנועה’ למצב ‚לפי מצפן’. + נקודות עומק ימיות בחצי הכדור הדרומי + נקודות עומק ימיות בחצי הכדור הצפוני + ב־OsmAnd נאסף מידע על אילו חלקים ביישומון משמשים אותך. המיקום שלך אף פעם לא נשלח, גם לא הקלט שלך ביישומון או פרטים על אזורים בהם צפית, חיפשת או הורדת. + הכרזה מחודשת של הנחיות הניווט במרווחי זמן קבועים. + חזרה על הנחיות הניווט + אחרים + לשמור את הנתונים כקובץ GPX ולייבא את נקודות הדרך למועדפים? + מועדפים משותפים דרך OsmAnd + ישנה בחירה חדשה לשלוט ביישומון באופן עיקרי באמצעות לוח המחוונים הגמיש או התפריט הסטטי. ניתן לשנות את בחירתך בהגדרות לוח המחוונים. From d2ab00d638b3bc171ec669d003a8c3ebd33511bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kompiuteri=C5=B3=20meistras=20+37060040?= Date: Wed, 20 Dec 2017 11:30:51 +0000 Subject: [PATCH 07/16] Translated using Weblate (Lithuanian) Currently translated at 95.7% (2410 of 2516 strings) --- OsmAnd/res/values-lt/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-lt/strings.xml b/OsmAnd/res/values-lt/strings.xml index e5c41dc44f..3c26f37065 100644 --- a/OsmAnd/res/values-lt/strings.xml +++ b/OsmAnd/res/values-lt/strings.xml @@ -2866,4 +2866,6 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka. Rodyti rodykles žemėlapyje Rodyti praeitą Slėpti praeitą + Užrašai pagal datą + Išvaizda žemėlapyje From 51d6b3e178d7f22e86f79dd4ea920eeb40862008 Mon Sep 17 00:00:00 2001 From: Igor Eliezer Date: Tue, 19 Dec 2017 19:19:50 +0000 Subject: [PATCH 08/16] Translated using Weblate (Portuguese (Brazil)) Currently translated at 80.5% (2026 of 2516 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 8dbb292cb6..acba9bc074 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -2265,7 +2265,7 @@ Pôr do Sol: %2$s Suprime a exibição de descontos do aplicativo e mensagens de eventos locais especiais. Registro Velocidade mínima para registro - Acuidade mínima para registro + Precisão mínima para registro Formato para as coordenadas geográficas. Voltar Ver @@ -2413,7 +2413,7 @@ Pôr do Sol: %2$s Sem dados Esquema de cores das curvas de nível Filtro: Definir velocidade mínima para um ponto ser registrado. - Deslocamento mínimo de registo + Deslocamento mínimo de registro Filtro: Definir a distância mínima da última posição para o ponto ser registrado. Filtro: Definir precisão mínima para um ponto ser registrado. POI de Natal From 47ffcd8b6ef555db5938ad3a45a6d1e9f5b6277a Mon Sep 17 00:00:00 2001 From: Matej U Date: Mon, 18 Dec 2017 20:10:52 +0000 Subject: [PATCH 09/16] Translated using Weblate (Slovenian) Currently translated at 100.0% (2516 of 2516 strings) --- OsmAnd/res/values-sl/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml index 2cf7fda636..0cb8c66ce8 100644 --- a/OsmAnd/res/values-sl/strings.xml +++ b/OsmAnd/res/values-sl/strings.xml @@ -2967,10 +2967,10 @@ Koda predstavlja območje: %1$s x %2$s \n • OsmAnd Live: odprava hroščev, posodobitve, ki so samodejno vključene v navigacijo, se objavljajo vsakih 30 minut \n \n - \\022 Zaznava znakov STOP po novem vpliva na usmerjanje vožnje -\n -\n • Z novim algoritmom so vrednosti spustov in vzponov na sledeh GPX bolj smiselne -\n + \\022 Zaznava znakov STOP po novem vpliva na usmerjanje vožnje +\n +\n • Z novim algoritmom so vrednosti spustov in vzponov na sledeh GPX bolj smiselne +\n \n • Čas hoje upošteva tudi vrsto terena (vzpon) po Naismithovem pravilu \n \n From c80acceda50a49cc96533af7a079c10552367440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Tue, 19 Dec 2017 11:31:14 +0000 Subject: [PATCH 10/16] Translated using Weblate (Hungarian) Currently translated at 100.0% (3322 of 3322 strings) --- OsmAnd/res/values-hu/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-hu/phrases.xml b/OsmAnd/res/values-hu/phrases.xml index ec396ceb05..82afa6fee2 100644 --- a/OsmAnd/res/values-hu/phrases.xml +++ b/OsmAnd/res/values-hu/phrases.xml @@ -288,7 +288,7 @@ Horgászfelszerelés Képkeretbolt Bútorbolt - Vegyesbolt + Egyéb bolt Üveges Hallókészülékbolt Vadászfelszerelés From 03d3ecce4b16a028857de09c7b01241bf99eb123 Mon Sep 17 00:00:00 2001 From: Matej U Date: Mon, 18 Dec 2017 20:52:15 +0000 Subject: [PATCH 11/16] Translated using Weblate (Slovenian) Currently translated at 11.9% (396 of 3322 strings) --- OsmAnd/res/values-sl/phrases.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-sl/phrases.xml b/OsmAnd/res/values-sl/phrases.xml index 1b298d56c4..0c58823a3f 100644 --- a/OsmAnd/res/values-sl/phrases.xml +++ b/OsmAnd/res/values-sl/phrases.xml @@ -380,7 +380,7 @@ Internetni dostop: storitev Samostan - Turistične informacije + Informacije Ura Potovalna agencija Razgledna točka @@ -414,7 +414,7 @@ Glavni vhod Vhod Pohodniške poti - Vrsta + Vrsta goriva Vrsta Način plačila Vrsta dostopa do interneta From ea3fa0cc37374e1a55e0744ae9c2cc6c26018426 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 20 Dec 2017 16:36:59 +0200 Subject: [PATCH 12/16] Fix some issues with "Use values from the openstreetmap for all tags, except for changed" commit --- .../plus/osmedit/AdvancedEditPoiFragment.java | 8 +++-- .../net/osmand/plus/osmedit/EditPoiData.java | 17 +++++++---- .../plus/osmedit/EditPoiDialogFragment.java | 4 +-- .../plus/osmedit/OpenstreetmapRemoteUtil.java | 30 ++++++++++++------- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 990da169d1..19c62eeecd 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -201,9 +201,11 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment if (!hasFocus) { if (!editPoiData.isInEdit()) { String s = tagEditText.getText().toString(); - editPoiData.removeTag(previousTag[0]); - editPoiData.putTag(s.toString(), valueEditText.getText().toString()); - previousTag[0] = s.toString(); + if (!previousTag[0].equals(s)) { + editPoiData.removeTag(previousTag[0]); + editPoiData.putTag(s, valueEditText.getText().toString()); + previousTag[0] = s; + } } } else { tagAdapter.getFilter().filter(tagEditText.getText()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index 146ec426f2..df1b6971b1 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -37,7 +37,7 @@ public class EditPoiData { category = app.getPoiTypes().getOtherPoiCategory(); entity = node; initTags(node); - updateTypeTag(getPoiTypeString()); + updateTypeTag(getPoiTypeString(), false); } public Map getAllTranslatedSubTypes() { @@ -109,15 +109,18 @@ public class EditPoiData { public Map getTagValues() { return Collections.unmodifiableMap(tagValues); } - + public void putTag(String tag, String value) { checkNotInEdit(); - try { + try { isInEdit = true; tagValues.remove(REMOVE_TAG_PREFIX+tag); + String oldValue = tagValues.get(tag); + if (oldValue == null || !oldValue.equals(value)) { + changedTags.add(tag); + } tagValues.put(tag, value); - changedTags.add(tag); notifyDatasetChanged(tag); } finally { isInEdit = false; @@ -193,9 +196,11 @@ public class EditPoiData { return hasChangesBeenMade; } - public void updateTypeTag(String string) { + public void updateTypeTag(String string, boolean userChanges) { tagValues.put(POI_TYPE_TAG, string); - changedTags.add(POI_TYPE_TAG); + if (userChanges) { + changedTags.add(POI_TYPE_TAG); + } retrieveType(); PoiType pt = getPoiTypeDefined(); if(pt != null) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 01c5e57447..663faba576 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -258,6 +258,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { poiNameEditText.setText(editPoiData.getTag(OSMSettings.OSMTagKey.NAME.getValue())); poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout); poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText); + poiTypeEditText.setText(editPoiData.getPoiTypeString()); poiTypeEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -270,7 +271,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { @Override public void afterTextChanged(Editable s) { if (!getEditPoiData().isInEdit()) { - getEditPoiData().updateTypeTag(s.toString()); + getEditPoiData().updateTypeTag(s.toString(), true); if (!getMyApplication().isApplicationInitializing()) { poiTypeTextInputLayout.setHint(editPoiData.getPoiCategory().getTranslation()); } @@ -279,7 +280,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { }); poiNameEditText.setOnEditorActionListener(mOnEditorActionListener); poiTypeEditText.setOnEditorActionListener(mOnEditorActionListener); - poiTypeEditText.setText(editPoiData.getPoiTypeString()); poiTypeEditText.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(final View v, MotionEvent event) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index a03185e54f..fa8a086283 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -37,6 +37,7 @@ import java.io.StringWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.text.MessageFormat; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; @@ -330,11 +331,20 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { EntityId id = new Entity.EntityId(EntityType.NODE, nodeId); Node entity = (Node) st.getRegisteredEntities().get(id); // merge non existing tags - for (String rtag : entity.getTagKeySet()) { - if (!deletedTag(n, rtag) && (!containsTag(n, rtag) || !tagChanged(n, rtag))) { - n.putTagNoLC(rtag, entity.getTag(rtag)); + Map updatedTags = new HashMap<>(); + for (String tagKey : entity.getTagKeySet()) { + if (tagKey != null && !deletedTag(n, tagKey)) { + addIfNotNull(tagKey, entity.getTag(tagKey), updatedTags); } } + if (n.getChangedTags() != null) { + for (String tagKey : n.getChangedTags()) { + if (tagKey != null) { + addIfNotNull(tagKey, n.getTag(tagKey), updatedTags); + } + } + } + n.replaceTags(updatedTags); if(MapUtils.getDistance(n.getLatLon(), entity.getLatLon()) < 10) { // avoid shifting due to round error n.setLatitude(entity.getLatitude()); @@ -353,18 +363,16 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { return null; } + private void addIfNotNull(String key, String value, Map tags) { + if (value != null) { + tags.put(key, value); + } + } + private boolean deletedTag(Node node, String tag) { return node.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + tag); } - private boolean containsTag(Node node, String tag) { - return node.getTagKeySet().contains(tag); - } - - private boolean tagChanged(Node node, String tag) { - return node.getChangedTags() != null && node.getChangedTags().contains(tag); - } - @Override public Node loadNode(Amenity n) { if (n.getId() % 2 == 1) { From 37e68dc582010d172dc817fe451a1b17b37cd738 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 20 Dec 2017 19:16:09 +0200 Subject: [PATCH 13/16] Import all notes to the gpx if selected only locations item and import selected notes otherwise --- OsmAnd/res/layout/note_list_item.xml | 12 +++++++----- OsmAnd/res/values/strings.xml | 2 ++ .../net/osmand/plus/audionotes/NotesFragment.java | 9 ++++++++- .../plus/audionotes/adapters/NotesAdapter.java | 9 ++++++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/layout/note_list_item.xml b/OsmAnd/res/layout/note_list_item.xml index 91f89197c9..b0aa6c6c20 100644 --- a/OsmAnd/res/layout/note_list_item.xml +++ b/OsmAnd/res/layout/note_list_item.xml @@ -9,8 +9,9 @@ + android:layout_height="wrap_content" + android:background="?attr/selectableItemBackground" + android:minHeight="@dimen/bottom_sheet_selected_item_title_height"> diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index ddd4d52ea3..8284ca7348 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + GPX file with coordinates and data of the selected notes. + GPX file with coordinates and data of all notes. \u2022 Detection of stop signs now considers driving direction\n\n \u2022 New algorithm providing meaningful ascent/descent values for GPX tracks\n\n diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java index c43e4fb721..f92ad0d035 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java @@ -470,6 +470,13 @@ public class NotesFragment extends OsmAndListFragment { startActivity(Intent.createChooser(intent, getString(R.string.share_note))); } + private Set getRecordingsForGpx(Set selected) { + if (selected.size() == 1 && selected.contains(SHARE_LOCATION_FILE)) { + return new HashSet<>(plugin.getAllRecordings()); + } + return selected; + } + @Nullable private File generateGPXForRecordings(Set selected) { File externalCacheDir = getActivity().getExternalCacheDir(); @@ -479,7 +486,7 @@ public class NotesFragment extends OsmAndListFragment { File tmpFile = new File(externalCacheDir, "share/noteLocations.gpx"); tmpFile.getParentFile().mkdirs(); GPXFile file = new GPXFile(); - for (Recording r : selected) { + for (Recording r : getRecordingsForGpx(selected)) { if (r != SHARE_LOCATION_FILE) { String desc = r.getDescriptionName(r.getFileName()); if (desc == null) { diff --git a/OsmAnd/src/net/osmand/plus/audionotes/adapters/NotesAdapter.java b/OsmAnd/src/net/osmand/plus/audionotes/adapters/NotesAdapter.java index fa7f286156..1fe1548665 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/adapters/NotesAdapter.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/adapters/NotesAdapter.java @@ -205,7 +205,7 @@ public class NotesAdapter extends ArrayAdapter { setupBackground(holder.view); if (recording == NotesFragment.SHARE_LOCATION_FILE) { holder.title.setText(R.string.av_locations); - holder.description.setText(R.string.av_locations_descr); + holder.description.setText(getLocationsDescId()); } else { holder.title.setText(recording.getName(app, true)); holder.description.setText(recording.getExtendedDescription(app)); @@ -255,6 +255,13 @@ public class NotesAdapter extends ArrayAdapter { }); } + private int getLocationsDescId() { + if (selected.contains(NotesFragment.SHARE_LOCATION_FILE)) { + return selected.size() == 1 ? R.string.av_locations_all_desc : R.string.av_locations_selected_desc; + } + return R.string.av_locations_descr; + } + private void setupBackground(View view) { if (!portrait) { view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.color_transparent)); From 91e7c9d7e69b4af8ddd1b4942d165a36baadb2c8 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Wed, 20 Dec 2017 20:58:25 +0100 Subject: [PATCH 14/16] Update strings.xml --- OsmAnd/res/values-ru/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 0b504a603f..dc562754ce 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -432,7 +432,7 @@ Пользовательские Файл с избранными уже существует. Вы хотите его заменить? Настройка профиля - Профиль + Профиль по умолчанию Выберите профиль работы приложения (в каждом профиле настройки хранятся отдельно). Общие настройки Общие настройки приложения From 1ba84e719aee05c9d43dd6693719c0fdaf6eae42 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 20 Dec 2017 22:46:06 +0200 Subject: [PATCH 15/16] Add translations --- OsmAnd/res/values-ru/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index dc562754ce..a6be4c71c7 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1,5 +1,7 @@ + Файл GPX с координатами и данными выбранных заметок. + Файл GPX с координатами и данными всех заметок. Место Ваш пункт назначения находится на частной территории. Вы хотите разрешить доступ к частным дорогам для этой поездки? Искать снова From bd8b497d10d6aa4e4b83e8b4133028b9dabc3f7c Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 20 Dec 2017 23:25:24 +0200 Subject: [PATCH 16/16] Fix #4814 --- .../osmand/plus/audionotes/AudioVideoNotesPlugin.java | 9 +++++++++ OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java | 1 + 2 files changed, 10 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 379fb7339f..f811b6abc6 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -481,6 +481,15 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { return date + " • " + sz + " • " + getDuration(ctx, false); } + public String getTypeWithDuration(Context ctx) { + StringBuilder res = new StringBuilder(getType(ctx)); + if (isAudio() || isVideo()) { + updateInternalDescription(); + res.append(", ").append(getDuration(ctx, false)); + } + return res.toString(); + } + public String getPlainDuration(boolean accessibilityEnabled) { updateInternalDescription(); if (duration > 0) { diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java index f92ad0d035..a516fc0b20 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java @@ -499,6 +499,7 @@ public class NotesFragment extends OsmAndListFragment { wpt.link = r.getFileName(); wpt.time = r.getFile().lastModified(); wpt.category = r.getSearchHistoryType(); + wpt.desc = r.getTypeWithDuration(getContext()); getMyApplication().getSelectedGpxHelper().addPoint(wpt, file); } }