Merge branch 'master' of github.com:osmandapp/Osmand into PaulsBranch

This commit is contained in:
PaulStets 2017-12-21 10:15:35 +02:00
commit 04b00ab916
24 changed files with 235 additions and 75 deletions

View file

@ -103,6 +103,7 @@ public abstract class Entity implements Serializable {
// lazy initializing
private Map<String, String> tags = null;
private Set<String> 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<String> getChangedTags() {
return changedTags;
}
public void setChangedTags(Set<String> changedTags) {
this.changedTags = changedTags;
}
public int getModify() {
return modify;
}

View file

@ -9,8 +9,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
android:background="?attr/selectableItemBackground">
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height">
<CheckBox
android:id="@+id/check_box"
@ -34,11 +35,12 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:orientation="vertical">
<TextView
@ -56,9 +58,9 @@
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:layout_marginTop="@dimen/map_widget_icon_margin"
android:ellipsize="end"
android:maxLines="3"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="Oct 13, 2017 * 3 MB * 01:14"/>

View file

@ -3690,4 +3690,5 @@
<string name="poi_depot">Depósito</string>
</resources>
<string name="poi_letter_box">Buzón</string>
</resources>

View file

@ -2484,4 +2484,22 @@
<string name="animate_my_location_desc">הפעלת הנפשת גלישת מפה של המיקום שלי במהלך ניווט.</string>
<string name="shared_string_in_name">ב־%1$s</string>
<string name="one_tap_active_descr">ניתן לגעת בסמן על המפה כדי להעביר אותו לראש הסמנים הפעילים מבלי לפתוח את תפריט ההקשר.</string>
<string name="release_3_0">\\022 זיהוי של שלטי עצור מתחשב בכיוון הניווט
\n
\n • אלגוריתם חדש מספק ערכים בעלי משמעות לעלייה/ירידה למסלולי GPX
\n
\n • זמן הטיול (כלל נייסמית׳) מודע לתוואי הדרך (עלייה)
\n
\n</string>
<string name="one_tap_active">הפעלה בנגיעה אחת</string>
<string name="map_orientation_change_in_accordance_with_speed_descr">נא לבחור להלן באיזו מהירות כיוון המפה יתחלף ממצב ‚לפי כיוון התנועה’ למצב ‚לפי מצפן’.</string>
<string name="index_item_depth_points_southern_hemisphere">נקודות עומק ימיות בחצי הכדור הדרומי</string>
<string name="index_item_depth_points_northern_hemisphere">נקודות עומק ימיות בחצי הכדור הצפוני</string>
<string name="do_not_send_anonymous_app_usage_desc">ב־OsmAnd נאסף מידע על אילו חלקים ביישומון משמשים אותך. המיקום שלך אף פעם לא נשלח, גם לא הקלט שלך ביישומון או פרטים על אזורים בהם צפית, חיפשת או הורדת.</string>
<string name="keep_informing_descr">הכרזה מחודשת של הנחיות הניווט במרווחי זמן קבועים.</string>
<string name="keep_informing">חזרה על הנחיות הניווט</string>
<string name="shared_string_others">אחרים</string>
<string name="import_file_favourites">לשמור את הנתונים כקובץ GPX ולייבא את נקודות הדרך למועדפים?</string>
<string name="share_fav_subject">מועדפים משותפים דרך OsmAnd</string>
<string name="dashboard_or_drawer_description">ישנה בחירה חדשה לשלוט ביישומון באופן עיקרי באמצעות לוח המחוונים הגמיש או התפריט הסטטי. ניתן לשנות את בחירתך בהגדרות לוח המחוונים.</string>
</resources>

View file

@ -288,7 +288,7 @@
<string name="poi_fishing">Horgászfelszerelés</string>
<string name="poi_frame">Képkeretbolt</string>
<string name="poi_furniture">Bútorbolt</string>
<string name="poi_shop_yes">Vegyesbolt</string>
<string name="poi_shop_yes">Egyéb bolt</string>
<string name="poi_glaziery">Üveges</string>
<string name="poi_hearing_aids">Hallókészülékbolt</string>
<string name="poi_hunting">Vadászfelszerelés</string>

View file

@ -2866,4 +2866,6 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka.</string>
<string name="show_arrows_on_the_map">Rodyti rodykles žemėlapyje</string>
<string name="show_passed">Rodyti praeitą</string>
<string name="hide_passed">Slėpti praeitą</string>
<string name="notes_by_date">Užrašai pagal datą</string>
<string name="appearance_on_the_map">Išvaizda žemėlapyje</string>
</resources>

View file

@ -2265,7 +2265,7 @@ Pôr do Sol: %2$s</string>
<string name="do_not_show_startup_messages_desc">Suprime a exibição de descontos do aplicativo e mensagens de eventos locais especiais.</string>
<string name="shared_string_record">Registro</string>
<string name="save_track_min_speed">Velocidade mínima para registro</string>
<string name="save_track_precision">Acuidade mínima para registro</string>
<string name="save_track_precision">Precisão mínima para registro</string>
<string name="coords_format_descr">Formato para as coordenadas geográficas.</string>
<string name="shared_string_back">Voltar</string>
<string name="view">Ver</string>
@ -2413,7 +2413,7 @@ Pôr do Sol: %2$s</string>
<string name="gpx_logging_no_data">Sem dados</string>
<string name="rendering_attr_contourColorScheme_description">Esquema de cores das curvas de nível</string>
<string name="save_track_min_speed_descr">Filtro: Definir velocidade mínima para um ponto ser registrado.</string>
<string name="save_track_min_distance">Deslocamento mínimo de registo</string>
<string name="save_track_min_distance">Deslocamento mínimo de registro</string>
<string name="save_track_min_distance_descr">Filtro: Definir a distância mínima da última posição para o ponto ser registrado.</string>
<string name="save_track_precision_descr">Filtro: Definir precisão mínima para um ponto ser registrado.</string>
<string name="christmas_poi">POI de Natal</string>

View file

@ -1,5 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<string name="av_locations_selected_desc">Файл GPX с координатами и данными выбранных заметок.</string>
<string name="av_locations_all_desc">Файл GPX с координатами и данными всех заметок.</string>
<string name="favorite_empty_place_name">Место</string>
<string name="private_access_routing_req">Ваш пункт назначения находится на частной территории. Вы хотите разрешить доступ к частным дорогам для этой поездки?</string>
<string name="restart_search">Искать снова</string>
@ -432,7 +434,7 @@
<string name="amenity_type_user_defined">Пользовательские</string>
<string name="fav_export_confirmation">Файл с избранными уже существует. Вы хотите его заменить?</string>
<string name="profile_settings">Настройка профиля</string>
<string name="settings_preset">Профиль</string>
<string name="settings_preset">Профиль по умолчанию</string>
<string name="settings_preset_descr">Выберите профиль работы приложения (в каждом профиле настройки хранятся отдельно).</string>
<string name="global_settings">Общие настройки</string>
<string name="global_app_settings">Общие настройки приложения</string>

View file

@ -380,7 +380,7 @@
<string name="poi_internet_access_service">Internetni dostop: storitev</string>
<string name="poi_monastery">Samostan</string>
<string name="poi_information">Turistične informacije</string>
<string name="poi_information">Informacije</string>
<string name="poi_clock">Ura</string>
<string name="poi_travel_agent">Potovalna agencija</string>
<string name="poi_viewpoint">Razgledna točka</string>
@ -414,7 +414,7 @@
<string name="poi_entrance_main">Glavni vhod</string>
<string name="poi_entrance">Vhod</string>
<string name="poi_hiking_routes">Pohodniške poti</string>
<string name="poi_fuel_type">Vrsta</string>
<string name="poi_fuel_type">Vrsta goriva</string>
<string name="poi_fuel_avia_type">Vrsta</string>
<string name="poi_payment_type">Način plačila</string>
<string name="poi_internet_access_type">Vrsta dostopa do interneta</string>

View file

@ -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
-->
<string name="av_locations_selected_desc">GPX file with coordinates and data of the selected notes.</string>
<string name="av_locations_all_desc">GPX file with coordinates and data of all notes.</string>
<string name="release_3_0">
\u2022 Detection of stop signs now considers driving direction\n\n
\u2022 New algorithm providing meaningful ascent/descent values for GPX tracks\n\n

View file

@ -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) {

View file

@ -470,6 +470,13 @@ public class NotesFragment extends OsmAndListFragment {
startActivity(Intent.createChooser(intent, getString(R.string.share_note)));
}
private Set<Recording> getRecordingsForGpx(Set<Recording> selected) {
if (selected.size() == 1 && selected.contains(SHARE_LOCATION_FILE)) {
return new HashSet<>(plugin.getAllRecordings());
}
return selected;
}
@Nullable
private File generateGPXForRecordings(Set<Recording> 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);
}
}

View file

@ -205,7 +205,7 @@ public class NotesAdapter extends ArrayAdapter<Object> {
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<Object> {
});
}
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));

View file

@ -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());

View file

@ -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;
@ -29,12 +30,14 @@ public class EditPoiData {
private Map<String, PoiType> allTranslatedSubTypes;
private PoiCategory category;
private Set<String> 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<String, PoiType> 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();
}
@ -111,6 +116,10 @@ public class EditPoiData {
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;
@ -155,6 +165,9 @@ public class EditPoiData {
return isInEdit;
}
public Set<String> getChangedTags() {
return changedTags;
}
private void notifyDatasetChanged(String tag) {
if (mListeners.size() > 0) {
@ -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);

View file

@ -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<String, String> 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<Node> postExecute,
final Activity activity,
final OpenstreetmapUtil openstreetmapUtil) {
if (info == null && OsmPoint.Action.CREATE != action && openstreetmapUtil instanceof OpenstreetmapRemoteUtil) {
final OpenstreetmapUtil openstreetmapUtil,
@Nullable final Set<String> 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<Node>() {
@Override
@ -776,7 +780,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
}
return false;
}
}, activity, openstreetmapUtil);
}, activity, openstreetmapUtil, null);
}
}

View file

@ -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<String> 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<String, String> 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;

View file

@ -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<String> 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<String, String> 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<String, String> 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) {

View file

@ -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<String> changedTags);
public void closeChangeSet();
void closeChangeSet();
public Node loadNode(Amenity n);
Node loadNode(Amenity n);
}

View file

@ -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<OpenstreetmapPoint> 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<OpenstreetmapPoint> getOpenstreetmapPoints() {
@ -70,12 +77,30 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
tags.append("$$$");
}
}
Set<String> chTags = p.getEntity().getChangedTags();
StringBuilder changedTags = new StringBuilder();
if (chTags != null) {
Iterator<String> 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<OpenstreetmapPoint> points = new ArrayList<OpenstreetmapPoint>();
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<split.length - 1; i+= 2){
entity.putTagNoLC(split[i].trim(), split[i+1].trim());
}
String changedTags = query.getString(6);
if (changedTags != null) {
entity.setChangedTags(new HashSet<>(Arrays.asList(changedTags.split("\\$\\$\\$"))));
}
p.setEntity(entity);
p.setAction(query.getString(3));
p.setComment(query.getString(4));

View file

@ -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

View file

@ -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);

View file

@ -157,7 +157,7 @@ public class AddPOIAction extends QuickAction {
return false;
}
}, activity, mOpenstreetmapUtil);
}, activity, mOpenstreetmapUtil, null);
}
}