diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java index 81462b1d4d..1db6bd0542 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java @@ -58,7 +58,7 @@ import java.util.List; import java.util.Map; import static net.osmand.plus.osmedit.AdvancedEditPoiFragment.addPoiToStringSet; -import static net.osmand.plus.osmedit.EditPoiData.POI_TYPE_TAG; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; public class AddPOIAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(13, @@ -140,7 +140,7 @@ public class AddPOIAction extends QuickAction { Node newNode = new Node(node.getLatitude(), node.getLongitude(), node.getId()); OsmPoint.Action action = newNode.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; for (Map.Entry tag : editPoiData.getTagValues().entrySet()) { - if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { + if (tag.getKey().equals(POI_TYPE_TAG)) { final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase()); if (poiType != null) { newNode.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 3eabf35f6c..b538ccd0c5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -28,6 +28,7 @@ import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiFilter; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.OSMSettings; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -112,7 +113,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment if (Algorithms.objectEquals(anyTag, OSMSettings.OSMTagKey.NAME.getValue())) { updateName(); } - if (Algorithms.objectEquals(anyTag, EditPoiData.POI_TYPE_TAG)) { + if (Algorithms.objectEquals(anyTag, Entity.POI_TYPE_TAG)) { updatePoiType(); } } @@ -197,9 +198,9 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment currentPoiTypeKey = pt.getEditOsmTag(); } for (Entry tag : editPoiData.getTagValues().entrySet()) { - if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG) + if (tag.getKey().equals(Entity.POI_TYPE_TAG) || tag.getKey().equals(OSMSettings.OSMTagKey.NAME.getValue()) - || tag.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX) + || tag.getKey().startsWith(Entity.REMOVE_TAG_PREFIX) || tag.getKey().equals(currentPoiTypeKey)) continue; addTagView(tag.getKey(), tag.getValue()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java index 9a47563fe4..eb2b7b8c2b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java @@ -5,6 +5,7 @@ import android.view.View; import androidx.annotation.NonNull; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuBuilder; @@ -12,6 +13,8 @@ import net.osmand.plus.render.RenderingIcons; import java.util.Map; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPOIMenuBuilder extends MenuBuilder { private final OsmPoint osmPoint; @@ -38,7 +41,7 @@ public class EditPOIMenuBuilder extends MenuBuilder { OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint; for (Map.Entry e : point.getEntity().getTags().entrySet()) { - if (EditPoiData.POI_TYPE_TAG.equals(e.getKey())) { + if (POI_TYPE_TAG.equals(e.getKey())) { String poiTranslation = e.getValue(); Map poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); @@ -63,8 +66,8 @@ public class EditPOIMenuBuilder extends MenuBuilder { } for (Map.Entry e : point.getEntity().getTags().entrySet()) { - if (EditPoiData.POI_TYPE_TAG.equals(e.getKey()) || - e.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX)) { + if (POI_TYPE_TAG.equals(e.getKey()) || + e.getKey().startsWith(Entity.REMOVE_TAG_PREFIX)) { continue; } String text = e.getKey() + "=" + e.getValue(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 7d04c73252..8134e5a3be 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -18,6 +18,8 @@ import net.osmand.util.Algorithms; import java.util.Map; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPOIMenuController extends MenuController { private OsmPoint osmPoint; @@ -166,7 +168,7 @@ public class EditPOIMenuController extends MenuController { if (osmPoint.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; int iconResId = 0; - String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmP.getEntity().getTag(POI_TYPE_TAG); MapActivity mapActivity = getMapActivity(); if (poiTranslation != null && mapActivity != null) { Map poiTypeMap = mapActivity.getMyApplication().getPoiTypes().getAllTranslatedNames(false); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index b11c828436..7dab7780b0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -17,15 +17,15 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPoiData { private static final Log LOG = PlatformUtil.getLog(EditPoiData.class); private Set mListeners = new HashSet<>(); - private LinkedHashMap tagValues = new LinkedHashMap(); + private final LinkedHashMap tagValues = new LinkedHashMap(); private boolean isInEdit = false; private Entity entity; - - public static final String POI_TYPE_TAG = "poi_type_tag"; - public static final String REMOVE_TAG_PREFIX = "----"; + public static final String REMOVE_TAG_VALUE = "DELETE"; private boolean hasChangesBeenMade = false; private Map allTranslatedSubTypes; @@ -123,7 +123,7 @@ public class EditPoiData { checkNotInEdit(); try { isInEdit = true; - tagValues.remove(REMOVE_TAG_PREFIX+tag); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + tag); String oldValue = tagValues.get(tag); if (oldValue == null || !oldValue.equals(value)) { changedTags.add(tag); @@ -154,9 +154,9 @@ public class EditPoiData { public void removeTag(String tag) { checkNotInEdit(); - try { + try { isInEdit = true; - tagValues.put(REMOVE_TAG_PREFIX+tag, REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + tag, REMOVE_TAG_VALUE); tagValues.remove(tag); changedTags.remove(tag); notifyDatasetChanged(tag); @@ -216,7 +216,7 @@ public class EditPoiData { PoiType pt = getPoiTypeDefined(); String editOsmTag = pt != null ? pt.getEditOsmTag() : null; if (editOsmTag != null) { - removeTypeTagWithPrefix(!tagValues.containsKey(REMOVE_TAG_PREFIX + editOsmTag)); + removeTypeTagWithPrefix(!tagValues.containsKey(Entity.REMOVE_TAG_PREFIX + editOsmTag)); currentPoiType = pt; String tagVal = pt.getEditOsmValue() != null ? pt.getEditOsmValue() : ""; tagValues.put(editOsmTag, tagVal); @@ -237,11 +237,11 @@ public class EditPoiData { private void removeTypeTagWithPrefix(boolean needRemovePrefix) { if (currentPoiType != null) { if (needRemovePrefix) { - tagValues.put(REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE); - tagValues.put(REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE); } else { - tagValues.remove(REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag()); - tagValues.remove(REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2()); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag()); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2()); } removeCurrentTypeTag(); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 7c0edb7168..ecdc776c78 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -90,6 +90,8 @@ import java.util.Set; import studio.carbonylgroup.textfieldboxes.ExtendedEditText; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { public static final String TAG = EditPoiDialogFragment.class.getSimpleName(); private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class); @@ -499,21 +501,21 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { Action action = entity.getId() < 0 ? Action.CREATE : Action.MODIFY; for (Map.Entry tag : editPoiData.getTagValues().entrySet()) { - if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) && - !tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { + if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) && + !tag.getKey().equals(POI_TYPE_TAG)) { entity.putTagNoLC(tag.getKey(), tag.getValue()); } } - String poiTypeTag = editPoiData.getTagValues().get(EditPoiData.POI_TYPE_TAG); + String poiTypeTag = editPoiData.getTagValues().get(POI_TYPE_TAG); String comment = ""; if (poiTypeTag != null) { final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(poiTypeTag.trim().toLowerCase()); if (poiType != null) { entity.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue()); - entity.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getEditOsmTag()); + entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getEditOsmTag()); if (poiType.getOsmTag2() != null) { entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); - entity.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); + entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); } } else if (!Algorithms.isEmpty(poiTypeTag)) { PoiCategory category = editPoiData.getPoiCategory(); @@ -522,7 +524,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { } } if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) { - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag); + entity.putTagNoLC(POI_TYPE_TAG, poiTypeTag); } String actionString = action == Action.CREATE ? getString(R.string.default_changeset_add) : getString(R.string.default_changeset_edit); comment = actionString + " " + poiTypeTag; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java index c55e2099ed..26eda5f4e5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java @@ -24,6 +24,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { public final static Log LOG = PlatformUtil.getLog(OpenstreetmapLocalUtil.class); @@ -122,7 +124,7 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { entity = new Node(loc.getLatitude(), loc.getLongitude(), entityId); } if (poiType != null) { - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, poiType.getTranslation()); if (poiType.getOsmTag2() != null) { entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java index 7e7a35d6f1..d7c17c1ec2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java @@ -28,7 +28,7 @@ public class OpenstreetmapPoint extends OsmPoint { String type = "amenity"; for (String k : entity.getTagKeySet()) { if (!OSMTagKey.NAME.getValue().equals(k) && !OSMTagKey.OPENING_HOURS.getValue().equals(k) && - !k.startsWith(EditPoiData.REMOVE_TAG_PREFIX)) { + !k.startsWith(Entity.REMOVE_TAG_PREFIX)) { type = k; break; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index b90a22c0b9..8940093c19 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -39,7 +39,8 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import java.util.concurrent.ExecutionException; + +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { @@ -273,8 +274,8 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { throws IllegalArgumentException, IllegalStateException, IOException { for (String k : entity.getTagKeySet()) { String val = entity.getTag(k); - if (val.length() == 0 || k.length() == 0 || EditPoiData.POI_TYPE_TAG.equals(k) || - k.startsWith(EditPoiData.REMOVE_TAG_PREFIX) || k.contains(EditPoiData.REMOVE_TAG_PREFIX)) + if (val.length() == 0 || k.length() == 0 || POI_TYPE_TAG.equals(k) || + k.startsWith(Entity.REMOVE_TAG_PREFIX) || k.contains(Entity.REMOVE_TAG_PREFIX)) continue; ser.startTag(null, "tag"); //$NON-NLS-1$ ser.attribute(null, "k", k); //$NON-NLS-1$ @@ -455,7 +456,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { } private boolean deletedTag(Entity entity, String tag) { - return entity.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + tag); + return entity.getTagKeySet().contains(Entity.REMOVE_TAG_PREFIX + tag); } @Override @@ -542,12 +543,12 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { PoiType poiType = type.getPoiTypeByKeyName(subType); if (poiType != null && poiType.getEditOsmValue().equals(entity.getTag(poiType.getEditOsmTag()))) { entity.removeTag(poiType.getEditOsmTag()); - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, poiType.getTranslation()); } else { for (PoiType pt : type.getPoiTypes()) { if (pt.getEditOsmValue().equals(entity.getTag(pt.getEditOsmTag()))) { entity.removeTag(pt.getEditOsmTag()); - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, pt.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, pt.getTranslation()); } } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index bee84a5e68..5b9b9eb7ce 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -61,6 +61,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_C import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE; import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS; import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; @@ -554,7 +555,7 @@ public class OsmEditingPlugin extends OsmandPlugin { public static String getCategory(OsmPoint osmPoint, Context context) { String category = ""; if (osmPoint.getGroup() == OsmPoint.Group.POI) { - category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(EditPoiData.POI_TYPE_TAG); + category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(POI_TYPE_TAG); if (Algorithms.isEmpty(category)) { category = context.getString(R.string.shared_string_without_name); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java index 92159c49df..d4c2ad099f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java @@ -17,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -244,7 +245,7 @@ public class OsmEditsAdapter extends ArrayAdapter { if (point.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point; int iconResId = 0; - String poiTranslation = osmPoint.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmPoint.getEntity().getTag(Entity.POI_TYPE_TAG); if (poiTranslation != null) { Map poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java index 99947c7de2..59c07afbaa 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java @@ -101,7 +101,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC if (osmPoint.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; int iconResId = 0; - String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmP.getEntity().getTag(Entity.POI_TYPE_TAG); if (poiTranslation != null && activity != null) { Map poiTypeMap = activity.getMyApplication().getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java index 7af0286ae4..d402cdfe49 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -16,13 +16,13 @@ import androidx.appcompat.widget.SwitchCompat; import androidx.fragment.app.DialogFragment; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dialogs.ProgressDialogFragment; -import net.osmand.plus.osmedit.EditPoiData; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmBugsLayer; import net.osmand.plus.osmedit.OsmEditingPlugin; @@ -152,7 +152,7 @@ public class SendPoiDialogFragment extends DialogFragment { for (OsmPoint p : poi) { if (p.getGroup() == OsmPoint.Group.POI) { OsmPoint.Action action = p.getAction(); - String type = ((OpenstreetmapPoint) p).getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String type = ((OpenstreetmapPoint) p).getEntity().getTag(Entity.POI_TYPE_TAG); if (type == null) { continue; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java index 6afddc9664..097e64b0d2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java @@ -45,6 +45,10 @@ public class FileSettingsItem extends StreamSettingsItem { this.subtypeFolder = subtypeFolder; } + public boolean isMap() { + return this == OBF_MAP || this == WIKI_MAP || this == SRTM_MAP; + } + public String getSubtypeName() { return subtypeName; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java index e2c06d14d6..03e1e39ad5 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken; import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.Node; +import net.osmand.osm.edit.Way; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; @@ -78,9 +79,8 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); } OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); - OsmBugsDbHelper db; if (osmEditingPlugin != null) { - db = osmEditingPlugin.getDBBug(); + OsmBugsDbHelper db = osmEditingPlugin.getDBBug(); for (OsmNotesPoint point : appliedItems) { db.addOsmbugs(point); } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java index c9eb980b9d..a03f363542 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java @@ -86,7 +86,7 @@ class SettingsImporter { Enumeration zipEnum = zipfile.entries(); while (zipEnum.hasMoreElements()) { ZipEntry zipEntry = zipEnum.nextElement(); - int size = (int) zipEntry.getSize(); + long size = zipEntry.getSize(); for (SettingsItem settingsItem : settingsItemList) { if (settingsItem instanceof FileSettingsItem && zipEntry.getName().equals(settingsItem.getFileName())) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java index d931e5a5c4..a513dc748c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -13,11 +13,6 @@ public enum SettingsItemType { AVOID_ROADS, SUGGESTED_DOWNLOADS, DOWNLOADS, - MARKERS, - FAVORITES, - TRACKS, - AUDIO_VIDEO_NOTES, OSM_NOTES, OSM_EDITS, - OFFLINE_MAPS } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java index ea702e8c85..9093c01c87 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java @@ -269,12 +269,20 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected); break; case OFFLINE_MAPS: - FileSettingsItem currentFileItem = (FileSettingsItem) currentItem; - file = currentFileItem.getFile(); + long size; + if (currentItem instanceof FileSettingsItem) { + FileSettingsItem currentFileItem = (FileSettingsItem) currentItem; + file = currentFileItem.getFile(); + size = currentFileItem.getSize(); + } else { + file = (File) currentItem; + size = file.length(); + } title.setText(FileNameTranslationHelper.getFileName(app, app.getResourceManager().getOsmandRegions(), file.getName())); - FileSubtype subtype = FileSubtype.getSubtypeByFileName(file.getPath().replace(app.getAppPath(null).getPath(), "")); + FileSubtype subtype = FileSubtype.getSubtypeByFileName(file.getPath().replace( + app.getAppPath(null).getPath(), "")); switch (subtype) { case SRTM_MAP: iconId = R.drawable.ic_plugin_srtm; @@ -286,7 +294,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { iconId = R.drawable.ic_map; } setupIcon(icon, iconId, itemSelected); - subText.setText(AndroidUtils.formatSize(app, currentFileItem.getSize())); + subText.setText(AndroidUtils.formatSize(app, size)); subText.setVisibility(View.VISIBLE); break; default: diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index 46752fd758..8250477d20 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -71,9 +71,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype.*; - - public class ImportSettingsFragment extends BaseOsmAndFragment implements View.OnClickListener { @@ -287,7 +284,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment private void reloadIndexes(@NonNull List items) { for (SettingsItem item : items) { - if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype() == OBF_MAP) { + if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype().isMap()) { Activity activity = getActivity(); if (activity instanceof MapActivity) { new ReloadIndexesTack((MapActivity) activity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);