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/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-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 + 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 + ישנה בחירה חדשה לשלוט ביישומון באופן עיקרי באמצעות לוח המחוונים הגמיש או התפריט הסטטי. ניתן לשנות את בחירתך בהגדרות לוח המחוונים. 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 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 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 diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 0b504a603f..a6be4c71c7 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1,5 +1,7 @@ + Файл GPX с координатами и данными выбранных заметок. + Файл GPX с координатами и данными всех заметок. Место Ваш пункт назначения находится на частной территории. Вы хотите разрешить доступ к частным дорогам для этой поездки? Искать снова @@ -432,7 +434,7 @@ Пользовательские Файл с избранными уже существует. Вы хотите его заменить? Настройка профиля - Профиль + Профиль по умолчанию Выберите профиль работы приложения (в каждом профиле настройки хранятся отдельно). Общие настройки Общие настройки приложения 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 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 diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5d92bd2381..4f04809548 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/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 c43e4fb721..a516fc0b20 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) { @@ -492,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); } } 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)); 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 27d85343e5..df1b6971b1 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,13 +29,15 @@ 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); category = app.getPoiTypes().getOtherPoiCategory(); entity = node; initTags(node); - updateTypeTag(getPoiTypeString()); + updateTypeTag(getPoiTypeString(), false); } public Map getAllTranslatedSubTypes() { @@ -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(); } @@ -104,13 +109,17 @@ 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); notifyDatasetChanged(tag); } finally { @@ -141,6 +150,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 +164,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; @@ -183,8 +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); + if (userChanges) { + changedTags.add(POI_TYPE_TAG); + } retrieveType(); PoiType pt = getPoiTypeDefined(); if(pt != null) { @@ -192,6 +208,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..663faba576 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"; @@ -255,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) { @@ -267,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()); } @@ -276,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) { @@ -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 0370cfb7ff..a168788001 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,8 @@ 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 { @@ -42,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); @@ -86,6 +92,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; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index d091660db2..fa8a086283 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,23 @@ 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.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { @@ -250,7 +252,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(); @@ -329,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 (!n.getTagKeySet().contains(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()); @@ -352,6 +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); + } + @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); } }