Fix review
This commit is contained in:
parent
6112b20a6d
commit
890d41a56f
20 changed files with 81 additions and 59 deletions
|
@ -58,7 +58,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static net.osmand.plus.osmedit.AdvancedEditPoiFragment.addPoiToStringSet;
|
import static net.osmand.plus.osmedit.AdvancedEditPoiFragment.addPoiToStringSet;
|
||||||
import static net.osmand.plus.osmedit.EditPoiData.POI_TYPE_TAG;
|
import static net.osmand.osm.edit.Entity.POI_TYPE_TAG;
|
||||||
|
|
||||||
public class AddPOIAction extends QuickAction {
|
public class AddPOIAction extends QuickAction {
|
||||||
public static final QuickActionType TYPE = new QuickActionType(13,
|
public static final QuickActionType TYPE = new QuickActionType(13,
|
||||||
|
@ -140,7 +140,7 @@ public class AddPOIAction extends QuickAction {
|
||||||
Node newNode = new Node(node.getLatitude(), node.getLongitude(), node.getId());
|
Node newNode = new Node(node.getLatitude(), node.getLongitude(), node.getId());
|
||||||
OsmPoint.Action action = newNode.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
OsmPoint.Action action = newNode.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
||||||
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
||||||
if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) {
|
if (tag.getKey().equals(POI_TYPE_TAG)) {
|
||||||
final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase());
|
final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase());
|
||||||
if (poiType != null) {
|
if (poiType != null) {
|
||||||
newNode.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue());
|
newNode.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue());
|
||||||
|
|
|
@ -28,6 +28,7 @@ import net.osmand.osm.MapPoiTypes;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiFilter;
|
import net.osmand.osm.PoiFilter;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
|
import net.osmand.osm.edit.Entity;
|
||||||
import net.osmand.osm.edit.OSMSettings;
|
import net.osmand.osm.edit.OSMSettings;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -112,7 +113,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
||||||
if (Algorithms.objectEquals(anyTag, OSMSettings.OSMTagKey.NAME.getValue())) {
|
if (Algorithms.objectEquals(anyTag, OSMSettings.OSMTagKey.NAME.getValue())) {
|
||||||
updateName();
|
updateName();
|
||||||
}
|
}
|
||||||
if (Algorithms.objectEquals(anyTag, EditPoiData.POI_TYPE_TAG)) {
|
if (Algorithms.objectEquals(anyTag, Entity.POI_TYPE_TAG)) {
|
||||||
updatePoiType();
|
updatePoiType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,9 +198,9 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
||||||
currentPoiTypeKey = pt.getEditOsmTag();
|
currentPoiTypeKey = pt.getEditOsmTag();
|
||||||
}
|
}
|
||||||
for (Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
for (Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
||||||
if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)
|
if (tag.getKey().equals(Entity.POI_TYPE_TAG)
|
||||||
|| tag.getKey().equals(OSMSettings.OSMTagKey.NAME.getValue())
|
|| tag.getKey().equals(OSMSettings.OSMTagKey.NAME.getValue())
|
||||||
|| tag.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX)
|
|| tag.getKey().startsWith(Entity.REMOVE_TAG_PREFIX)
|
||||||
|| tag.getKey().equals(currentPoiTypeKey))
|
|| tag.getKey().equals(currentPoiTypeKey))
|
||||||
continue;
|
continue;
|
||||||
addTagView(tag.getKey(), tag.getValue());
|
addTagView(tag.getKey(), tag.getValue());
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
|
import net.osmand.osm.edit.Entity;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
|
@ -12,6 +13,8 @@ import net.osmand.plus.render.RenderingIcons;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static net.osmand.osm.edit.Entity.POI_TYPE_TAG;
|
||||||
|
|
||||||
public class EditPOIMenuBuilder extends MenuBuilder {
|
public class EditPOIMenuBuilder extends MenuBuilder {
|
||||||
|
|
||||||
private final OsmPoint osmPoint;
|
private final OsmPoint osmPoint;
|
||||||
|
@ -38,7 +41,7 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
||||||
OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint;
|
OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint;
|
||||||
|
|
||||||
for (Map.Entry<String, String> e : point.getEntity().getTags().entrySet()) {
|
for (Map.Entry<String, String> e : point.getEntity().getTags().entrySet()) {
|
||||||
if (EditPoiData.POI_TYPE_TAG.equals(e.getKey())) {
|
if (POI_TYPE_TAG.equals(e.getKey())) {
|
||||||
String poiTranslation = e.getValue();
|
String poiTranslation = e.getValue();
|
||||||
Map<String, PoiType> poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false);
|
Map<String, PoiType> poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false);
|
||||||
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
|
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
|
||||||
|
@ -63,8 +66,8 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, String> e : point.getEntity().getTags().entrySet()) {
|
for (Map.Entry<String, String> e : point.getEntity().getTags().entrySet()) {
|
||||||
if (EditPoiData.POI_TYPE_TAG.equals(e.getKey()) ||
|
if (POI_TYPE_TAG.equals(e.getKey()) ||
|
||||||
e.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX)) {
|
e.getKey().startsWith(Entity.REMOVE_TAG_PREFIX)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String text = e.getKey() + "=" + e.getValue();
|
String text = e.getKey() + "=" + e.getValue();
|
||||||
|
|
|
@ -18,6 +18,8 @@ import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static net.osmand.osm.edit.Entity.POI_TYPE_TAG;
|
||||||
|
|
||||||
public class EditPOIMenuController extends MenuController {
|
public class EditPOIMenuController extends MenuController {
|
||||||
|
|
||||||
private OsmPoint osmPoint;
|
private OsmPoint osmPoint;
|
||||||
|
@ -166,7 +168,7 @@ public class EditPOIMenuController extends MenuController {
|
||||||
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
||||||
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
|
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
|
||||||
int iconResId = 0;
|
int iconResId = 0;
|
||||||
String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG);
|
String poiTranslation = osmP.getEntity().getTag(POI_TYPE_TAG);
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (poiTranslation != null && mapActivity != null) {
|
if (poiTranslation != null && mapActivity != null) {
|
||||||
Map<String, PoiType> poiTypeMap = mapActivity.getMyApplication().getPoiTypes().getAllTranslatedNames(false);
|
Map<String, PoiType> poiTypeMap = mapActivity.getMyApplication().getPoiTypes().getAllTranslatedNames(false);
|
||||||
|
|
|
@ -17,15 +17,15 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static net.osmand.osm.edit.Entity.POI_TYPE_TAG;
|
||||||
|
|
||||||
public class EditPoiData {
|
public class EditPoiData {
|
||||||
private static final Log LOG = PlatformUtil.getLog(EditPoiData.class);
|
private static final Log LOG = PlatformUtil.getLog(EditPoiData.class);
|
||||||
private Set<TagsChangedListener> mListeners = new HashSet<>();
|
private Set<TagsChangedListener> mListeners = new HashSet<>();
|
||||||
private LinkedHashMap<String, String > tagValues = new LinkedHashMap<String, String>();
|
private final LinkedHashMap<String, String> tagValues = new LinkedHashMap<String, String>();
|
||||||
private boolean isInEdit = false;
|
private boolean isInEdit = false;
|
||||||
private Entity entity;
|
private Entity entity;
|
||||||
|
|
||||||
public static final String POI_TYPE_TAG = "poi_type_tag";
|
|
||||||
public static final String REMOVE_TAG_PREFIX = "----";
|
|
||||||
public static final String REMOVE_TAG_VALUE = "DELETE";
|
public static final String REMOVE_TAG_VALUE = "DELETE";
|
||||||
private boolean hasChangesBeenMade = false;
|
private boolean hasChangesBeenMade = false;
|
||||||
private Map<String, PoiType> allTranslatedSubTypes;
|
private Map<String, PoiType> allTranslatedSubTypes;
|
||||||
|
@ -123,7 +123,7 @@ public class EditPoiData {
|
||||||
checkNotInEdit();
|
checkNotInEdit();
|
||||||
try {
|
try {
|
||||||
isInEdit = true;
|
isInEdit = true;
|
||||||
tagValues.remove(REMOVE_TAG_PREFIX+tag);
|
tagValues.remove(Entity.REMOVE_TAG_PREFIX + tag);
|
||||||
String oldValue = tagValues.get(tag);
|
String oldValue = tagValues.get(tag);
|
||||||
if (oldValue == null || !oldValue.equals(value)) {
|
if (oldValue == null || !oldValue.equals(value)) {
|
||||||
changedTags.add(tag);
|
changedTags.add(tag);
|
||||||
|
@ -156,7 +156,7 @@ public class EditPoiData {
|
||||||
checkNotInEdit();
|
checkNotInEdit();
|
||||||
try {
|
try {
|
||||||
isInEdit = true;
|
isInEdit = true;
|
||||||
tagValues.put(REMOVE_TAG_PREFIX+tag, REMOVE_TAG_VALUE);
|
tagValues.put(Entity.REMOVE_TAG_PREFIX + tag, REMOVE_TAG_VALUE);
|
||||||
tagValues.remove(tag);
|
tagValues.remove(tag);
|
||||||
changedTags.remove(tag);
|
changedTags.remove(tag);
|
||||||
notifyDatasetChanged(tag);
|
notifyDatasetChanged(tag);
|
||||||
|
@ -216,7 +216,7 @@ public class EditPoiData {
|
||||||
PoiType pt = getPoiTypeDefined();
|
PoiType pt = getPoiTypeDefined();
|
||||||
String editOsmTag = pt != null ? pt.getEditOsmTag() : null;
|
String editOsmTag = pt != null ? pt.getEditOsmTag() : null;
|
||||||
if (editOsmTag != null) {
|
if (editOsmTag != null) {
|
||||||
removeTypeTagWithPrefix(!tagValues.containsKey(REMOVE_TAG_PREFIX + editOsmTag));
|
removeTypeTagWithPrefix(!tagValues.containsKey(Entity.REMOVE_TAG_PREFIX + editOsmTag));
|
||||||
currentPoiType = pt;
|
currentPoiType = pt;
|
||||||
String tagVal = pt.getEditOsmValue() != null ? pt.getEditOsmValue() : "";
|
String tagVal = pt.getEditOsmValue() != null ? pt.getEditOsmValue() : "";
|
||||||
tagValues.put(editOsmTag, tagVal);
|
tagValues.put(editOsmTag, tagVal);
|
||||||
|
@ -237,11 +237,11 @@ public class EditPoiData {
|
||||||
private void removeTypeTagWithPrefix(boolean needRemovePrefix) {
|
private void removeTypeTagWithPrefix(boolean needRemovePrefix) {
|
||||||
if (currentPoiType != null) {
|
if (currentPoiType != null) {
|
||||||
if (needRemovePrefix) {
|
if (needRemovePrefix) {
|
||||||
tagValues.put(REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE);
|
tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE);
|
||||||
tagValues.put(REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE);
|
tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE);
|
||||||
} else {
|
} else {
|
||||||
tagValues.remove(REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag());
|
tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag());
|
||||||
tagValues.remove(REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2());
|
tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2());
|
||||||
}
|
}
|
||||||
removeCurrentTypeTag();
|
removeCurrentTypeTag();
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,8 @@ import java.util.Set;
|
||||||
|
|
||||||
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
|
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
|
||||||
|
|
||||||
|
import static net.osmand.osm.edit.Entity.POI_TYPE_TAG;
|
||||||
|
|
||||||
public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
public static final String TAG = EditPoiDialogFragment.class.getSimpleName();
|
public static final String TAG = EditPoiDialogFragment.class.getSimpleName();
|
||||||
private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class);
|
private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class);
|
||||||
|
@ -500,20 +502,20 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
Action action = entity.getId() < 0 ? Action.CREATE : Action.MODIFY;
|
Action action = entity.getId() < 0 ? Action.CREATE : Action.MODIFY;
|
||||||
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
||||||
if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) &&
|
if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) &&
|
||||||
!tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) {
|
!tag.getKey().equals(POI_TYPE_TAG)) {
|
||||||
entity.putTagNoLC(tag.getKey(), tag.getValue());
|
entity.putTagNoLC(tag.getKey(), tag.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String poiTypeTag = editPoiData.getTagValues().get(EditPoiData.POI_TYPE_TAG);
|
String poiTypeTag = editPoiData.getTagValues().get(POI_TYPE_TAG);
|
||||||
String comment = "";
|
String comment = "";
|
||||||
if (poiTypeTag != null) {
|
if (poiTypeTag != null) {
|
||||||
final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(poiTypeTag.trim().toLowerCase());
|
final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(poiTypeTag.trim().toLowerCase());
|
||||||
if (poiType != null) {
|
if (poiType != null) {
|
||||||
entity.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue());
|
entity.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue());
|
||||||
entity.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getEditOsmTag());
|
entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getEditOsmTag());
|
||||||
if (poiType.getOsmTag2() != null) {
|
if (poiType.getOsmTag2() != null) {
|
||||||
entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
|
entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
|
||||||
entity.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2());
|
entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getOsmTag2());
|
||||||
}
|
}
|
||||||
} else if (!Algorithms.isEmpty(poiTypeTag)) {
|
} else if (!Algorithms.isEmpty(poiTypeTag)) {
|
||||||
PoiCategory category = editPoiData.getPoiCategory();
|
PoiCategory category = editPoiData.getPoiCategory();
|
||||||
|
@ -522,7 +524,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) {
|
if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) {
|
||||||
entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag);
|
entity.putTagNoLC(POI_TYPE_TAG, poiTypeTag);
|
||||||
}
|
}
|
||||||
String actionString = action == Action.CREATE ? getString(R.string.default_changeset_add) : getString(R.string.default_changeset_edit);
|
String actionString = action == Action.CREATE ? getString(R.string.default_changeset_add) : getString(R.string.default_changeset_edit);
|
||||||
comment = actionString + " " + poiTypeTag;
|
comment = actionString + " " + poiTypeTag;
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static net.osmand.osm.edit.Entity.POI_TYPE_TAG;
|
||||||
|
|
||||||
public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
||||||
|
|
||||||
public final static Log LOG = PlatformUtil.getLog(OpenstreetmapLocalUtil.class);
|
public final static Log LOG = PlatformUtil.getLog(OpenstreetmapLocalUtil.class);
|
||||||
|
@ -122,7 +124,7 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
||||||
entity = new Node(loc.getLatitude(), loc.getLongitude(), entityId);
|
entity = new Node(loc.getLatitude(), loc.getLongitude(), entityId);
|
||||||
}
|
}
|
||||||
if (poiType != null) {
|
if (poiType != null) {
|
||||||
entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation());
|
entity.putTagNoLC(POI_TYPE_TAG, poiType.getTranslation());
|
||||||
if (poiType.getOsmTag2() != null) {
|
if (poiType.getOsmTag2() != null) {
|
||||||
entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
|
entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class OpenstreetmapPoint extends OsmPoint {
|
||||||
String type = "amenity";
|
String type = "amenity";
|
||||||
for (String k : entity.getTagKeySet()) {
|
for (String k : entity.getTagKeySet()) {
|
||||||
if (!OSMTagKey.NAME.getValue().equals(k) && !OSMTagKey.OPENING_HOURS.getValue().equals(k) &&
|
if (!OSMTagKey.NAME.getValue().equals(k) && !OSMTagKey.OPENING_HOURS.getValue().equals(k) &&
|
||||||
!k.startsWith(EditPoiData.REMOVE_TAG_PREFIX)) {
|
!k.startsWith(Entity.REMOVE_TAG_PREFIX)) {
|
||||||
type = k;
|
type = k;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
import static net.osmand.osm.edit.Entity.POI_TYPE_TAG;
|
||||||
|
|
||||||
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||||
|
|
||||||
|
@ -273,8 +274,8 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||||
throws IllegalArgumentException, IllegalStateException, IOException {
|
throws IllegalArgumentException, IllegalStateException, IOException {
|
||||||
for (String k : entity.getTagKeySet()) {
|
for (String k : entity.getTagKeySet()) {
|
||||||
String val = entity.getTag(k);
|
String val = entity.getTag(k);
|
||||||
if (val.length() == 0 || k.length() == 0 || EditPoiData.POI_TYPE_TAG.equals(k) ||
|
if (val.length() == 0 || k.length() == 0 || POI_TYPE_TAG.equals(k) ||
|
||||||
k.startsWith(EditPoiData.REMOVE_TAG_PREFIX) || k.contains(EditPoiData.REMOVE_TAG_PREFIX))
|
k.startsWith(Entity.REMOVE_TAG_PREFIX) || k.contains(Entity.REMOVE_TAG_PREFIX))
|
||||||
continue;
|
continue;
|
||||||
ser.startTag(null, "tag"); //$NON-NLS-1$
|
ser.startTag(null, "tag"); //$NON-NLS-1$
|
||||||
ser.attribute(null, "k", k); //$NON-NLS-1$
|
ser.attribute(null, "k", k); //$NON-NLS-1$
|
||||||
|
@ -455,7 +456,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean deletedTag(Entity entity, String tag) {
|
private boolean deletedTag(Entity entity, String tag) {
|
||||||
return entity.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + tag);
|
return entity.getTagKeySet().contains(Entity.REMOVE_TAG_PREFIX + tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -542,12 +543,12 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||||
PoiType poiType = type.getPoiTypeByKeyName(subType);
|
PoiType poiType = type.getPoiTypeByKeyName(subType);
|
||||||
if (poiType != null && poiType.getEditOsmValue().equals(entity.getTag(poiType.getEditOsmTag()))) {
|
if (poiType != null && poiType.getEditOsmValue().equals(entity.getTag(poiType.getEditOsmTag()))) {
|
||||||
entity.removeTag(poiType.getEditOsmTag());
|
entity.removeTag(poiType.getEditOsmTag());
|
||||||
entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation());
|
entity.putTagNoLC(POI_TYPE_TAG, poiType.getTranslation());
|
||||||
} else {
|
} else {
|
||||||
for (PoiType pt : type.getPoiTypes()) {
|
for (PoiType pt : type.getPoiTypes()) {
|
||||||
if (pt.getEditOsmValue().equals(entity.getTag(pt.getEditOsmTag()))) {
|
if (pt.getEditOsmValue().equals(entity.getTag(pt.getEditOsmTag()))) {
|
||||||
entity.removeTag(pt.getEditOsmTag());
|
entity.removeTag(pt.getEditOsmTag());
|
||||||
entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, pt.getTranslation());
|
entity.putTagNoLC(POI_TYPE_TAG, pt.getTranslation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_C
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES;
|
||||||
|
import static net.osmand.osm.edit.Entity.POI_TYPE_TAG;
|
||||||
import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction;
|
import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction;
|
||||||
|
|
||||||
|
|
||||||
|
@ -554,7 +555,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
public static String getCategory(OsmPoint osmPoint, Context context) {
|
public static String getCategory(OsmPoint osmPoint, Context context) {
|
||||||
String category = "";
|
String category = "";
|
||||||
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
||||||
category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(EditPoiData.POI_TYPE_TAG);
|
category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(POI_TYPE_TAG);
|
||||||
if (Algorithms.isEmpty(category)) {
|
if (Algorithms.isEmpty(category)) {
|
||||||
category = context.getString(R.string.shared_string_without_name);
|
category = context.getString(R.string.shared_string_without_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
|
import net.osmand.osm.edit.Entity;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
@ -244,7 +245,7 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
||||||
if (point.getGroup() == OsmPoint.Group.POI) {
|
if (point.getGroup() == OsmPoint.Group.POI) {
|
||||||
OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point;
|
OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point;
|
||||||
int iconResId = 0;
|
int iconResId = 0;
|
||||||
String poiTranslation = osmPoint.getEntity().getTag(EditPoiData.POI_TYPE_TAG);
|
String poiTranslation = osmPoint.getEntity().getTag(Entity.POI_TYPE_TAG);
|
||||||
if (poiTranslation != null) {
|
if (poiTranslation != null) {
|
||||||
Map<String, PoiType> poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false);
|
Map<String, PoiType> poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false);
|
||||||
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
|
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
||||||
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
|
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
|
||||||
int iconResId = 0;
|
int iconResId = 0;
|
||||||
String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG);
|
String poiTranslation = osmP.getEntity().getTag(Entity.POI_TYPE_TAG);
|
||||||
if (poiTranslation != null && activity != null) {
|
if (poiTranslation != null && activity != null) {
|
||||||
Map<String, PoiType> poiTypeMap = activity.getMyApplication().getPoiTypes().getAllTranslatedNames(false);
|
Map<String, PoiType> poiTypeMap = activity.getMyApplication().getPoiTypes().getAllTranslatedNames(false);
|
||||||
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
|
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
|
||||||
|
|
|
@ -16,13 +16,13 @@ import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
|
import net.osmand.osm.edit.Entity;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dialogs.ProgressDialogFragment;
|
import net.osmand.plus.dialogs.ProgressDialogFragment;
|
||||||
import net.osmand.plus.osmedit.EditPoiData;
|
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
import net.osmand.plus.osmedit.OsmBugsLayer;
|
import net.osmand.plus.osmedit.OsmBugsLayer;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
|
@ -152,7 +152,7 @@ public class SendPoiDialogFragment extends DialogFragment {
|
||||||
for (OsmPoint p : poi) {
|
for (OsmPoint p : poi) {
|
||||||
if (p.getGroup() == OsmPoint.Group.POI) {
|
if (p.getGroup() == OsmPoint.Group.POI) {
|
||||||
OsmPoint.Action action = p.getAction();
|
OsmPoint.Action action = p.getAction();
|
||||||
String type = ((OpenstreetmapPoint) p).getEntity().getTag(EditPoiData.POI_TYPE_TAG);
|
String type = ((OpenstreetmapPoint) p).getEntity().getTag(Entity.POI_TYPE_TAG);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@ public class FileSettingsItem extends StreamSettingsItem {
|
||||||
this.subtypeFolder = subtypeFolder;
|
this.subtypeFolder = subtypeFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMap() {
|
||||||
|
return this == OBF_MAP || this == WIKI_MAP || this == SRTM_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSubtypeName() {
|
public String getSubtypeName() {
|
||||||
return subtypeName;
|
return subtypeName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import net.osmand.osm.edit.Entity;
|
import net.osmand.osm.edit.Entity;
|
||||||
import net.osmand.osm.edit.Node;
|
import net.osmand.osm.edit.Node;
|
||||||
|
import net.osmand.osm.edit.Way;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -78,9 +79,8 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem<OpenstreetmapPo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
OpenstreetmapsDbHelper db;
|
|
||||||
if (osmEditingPlugin != null) {
|
if (osmEditingPlugin != null) {
|
||||||
db = osmEditingPlugin.getDBPOI();
|
OpenstreetmapsDbHelper db = osmEditingPlugin.getDBPOI();
|
||||||
for (OpenstreetmapPoint point : appliedItems) {
|
for (OpenstreetmapPoint point : appliedItems) {
|
||||||
db.addOpenstreetmap(point);
|
db.addOpenstreetmap(point);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,13 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem<OpenstreetmapPo
|
||||||
);
|
);
|
||||||
String action = entityJson.getString(ACTION_KEY);
|
String action = entityJson.getString(ACTION_KEY);
|
||||||
Entity entity;
|
Entity entity;
|
||||||
entity = new Node(lat, lon, id);
|
if (entityJson.get(TYPE_KEY).equals(Entity.EntityType.NODE.name())) {
|
||||||
|
entity = new Node(lat, lon, id);
|
||||||
|
} else {
|
||||||
|
entity = new Way(id);
|
||||||
|
entity.setLatitude(lat);
|
||||||
|
entity.setLongitude(lon);
|
||||||
|
}
|
||||||
entity.replaceTags(tagMap);
|
entity.replaceTags(tagMap);
|
||||||
OpenstreetmapPoint point = new OpenstreetmapPoint();
|
OpenstreetmapPoint point = new OpenstreetmapPoint();
|
||||||
point.setComment(comment);
|
point.setComment(comment);
|
||||||
|
|
|
@ -67,9 +67,8 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem<OsmNotesPoint>
|
||||||
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
|
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
|
||||||
}
|
}
|
||||||
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
OsmBugsDbHelper db;
|
|
||||||
if (osmEditingPlugin != null) {
|
if (osmEditingPlugin != null) {
|
||||||
db = osmEditingPlugin.getDBBug();
|
OsmBugsDbHelper db = osmEditingPlugin.getDBBug();
|
||||||
for (OsmNotesPoint point : appliedItems) {
|
for (OsmNotesPoint point : appliedItems) {
|
||||||
db.addOsmbugs(point);
|
db.addOsmbugs(point);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ class SettingsImporter {
|
||||||
Enumeration<? extends ZipEntry> zipEnum = zipfile.entries();
|
Enumeration<? extends ZipEntry> zipEnum = zipfile.entries();
|
||||||
while (zipEnum.hasMoreElements()) {
|
while (zipEnum.hasMoreElements()) {
|
||||||
ZipEntry zipEntry = zipEnum.nextElement();
|
ZipEntry zipEntry = zipEnum.nextElement();
|
||||||
int size = (int) zipEntry.getSize();
|
long size = zipEntry.getSize();
|
||||||
for (SettingsItem settingsItem : settingsItemList) {
|
for (SettingsItem settingsItem : settingsItemList) {
|
||||||
if (settingsItem instanceof FileSettingsItem
|
if (settingsItem instanceof FileSettingsItem
|
||||||
&& zipEntry.getName().equals(settingsItem.getFileName())) {
|
&& zipEntry.getName().equals(settingsItem.getFileName())) {
|
||||||
|
|
|
@ -13,11 +13,6 @@ public enum SettingsItemType {
|
||||||
AVOID_ROADS,
|
AVOID_ROADS,
|
||||||
SUGGESTED_DOWNLOADS,
|
SUGGESTED_DOWNLOADS,
|
||||||
DOWNLOADS,
|
DOWNLOADS,
|
||||||
MARKERS,
|
|
||||||
FAVORITES,
|
|
||||||
TRACKS,
|
|
||||||
AUDIO_VIDEO_NOTES,
|
|
||||||
OSM_NOTES,
|
OSM_NOTES,
|
||||||
OSM_EDITS,
|
OSM_EDITS,
|
||||||
OFFLINE_MAPS
|
|
||||||
}
|
}
|
|
@ -269,12 +269,20 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected);
|
setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected);
|
||||||
break;
|
break;
|
||||||
case OFFLINE_MAPS:
|
case OFFLINE_MAPS:
|
||||||
FileSettingsItem currentFileItem = (FileSettingsItem) currentItem;
|
long size;
|
||||||
file = currentFileItem.getFile();
|
if (currentItem instanceof FileSettingsItem) {
|
||||||
|
FileSettingsItem currentFileItem = (FileSettingsItem) currentItem;
|
||||||
|
file = currentFileItem.getFile();
|
||||||
|
size = currentFileItem.getSize();
|
||||||
|
} else {
|
||||||
|
file = (File) currentItem;
|
||||||
|
size = file.length();
|
||||||
|
}
|
||||||
title.setText(FileNameTranslationHelper.getFileName(app,
|
title.setText(FileNameTranslationHelper.getFileName(app,
|
||||||
app.getResourceManager().getOsmandRegions(),
|
app.getResourceManager().getOsmandRegions(),
|
||||||
file.getName()));
|
file.getName()));
|
||||||
FileSubtype subtype = FileSubtype.getSubtypeByFileName(file.getPath().replace(app.getAppPath(null).getPath(), ""));
|
FileSubtype subtype = FileSubtype.getSubtypeByFileName(file.getPath().replace(
|
||||||
|
app.getAppPath(null).getPath(), ""));
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case SRTM_MAP:
|
case SRTM_MAP:
|
||||||
iconId = R.drawable.ic_plugin_srtm;
|
iconId = R.drawable.ic_plugin_srtm;
|
||||||
|
@ -286,7 +294,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
iconId = R.drawable.ic_map;
|
iconId = R.drawable.ic_map;
|
||||||
}
|
}
|
||||||
setupIcon(icon, iconId, itemSelected);
|
setupIcon(icon, iconId, itemSelected);
|
||||||
subText.setText(AndroidUtils.formatSize(app, currentFileItem.getSize()));
|
subText.setText(AndroidUtils.formatSize(app, size));
|
||||||
subText.setVisibility(View.VISIBLE);
|
subText.setVisibility(View.VISIBLE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -71,9 +71,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype.*;
|
|
||||||
|
|
||||||
|
|
||||||
public class ImportSettingsFragment extends BaseOsmAndFragment
|
public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
implements View.OnClickListener {
|
implements View.OnClickListener {
|
||||||
|
|
||||||
|
@ -287,7 +284,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
|
|
||||||
private void reloadIndexes(@NonNull List<SettingsItem> items) {
|
private void reloadIndexes(@NonNull List<SettingsItem> items) {
|
||||||
for (SettingsItem item : items) {
|
for (SettingsItem item : items) {
|
||||||
if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype() == OBF_MAP) {
|
if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype().isMap()) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
new ReloadIndexesTack((MapActivity) activity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new ReloadIndexesTack((MapActivity) activity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
Loading…
Reference in a new issue