Merge pull request #10056 from osmandapp/imp_exp_osm_note
Import export OSM changes, offline maps
This commit is contained in:
commit
248bc052e8
28 changed files with 760 additions and 98 deletions
|
@ -114,6 +114,8 @@ public abstract class Entity implements Serializable {
|
||||||
public static final int MODIFY_DELETED = -1;
|
public static final int MODIFY_DELETED = -1;
|
||||||
public static final int MODIFY_MODIFIED = 1;
|
public static final int MODIFY_MODIFIED = 1;
|
||||||
public static final int MODIFY_CREATED = 2;
|
public static final int MODIFY_CREATED = 2;
|
||||||
|
public static final String POI_TYPE_TAG = "poi_type_tag";
|
||||||
|
public static final String REMOVE_TAG_PREFIX = "----";
|
||||||
|
|
||||||
public Entity(long id) {
|
public Entity(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -241,6 +243,11 @@ public abstract class Entity implements Serializable {
|
||||||
return Collections.unmodifiableMap(tags);
|
return Collections.unmodifiableMap(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNotValid(String tag) {
|
||||||
|
String val = getTag(tag);
|
||||||
|
return val == null || val.length() == 0 || tag.length() == 0
|
||||||
|
|| tag.startsWith(REMOVE_TAG_PREFIX) || tag.equals(POI_TYPE_TAG);
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<String> getTagKeySet() {
|
public Collection<String> getTagKeySet() {
|
||||||
if (tags == null) {
|
if (tags == null) {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
<string name="icon_group_amenity">Amenity</string>
|
<string name="icon_group_amenity">Amenity</string>
|
||||||
<string name="app_mode_gap">Gap</string>
|
<string name="app_mode_gap">Gap</string>
|
||||||
<string name="ltr_or_rtl_combine_via_dash">%1$s — %2$s</string>
|
<string name="ltr_or_rtl_combine_via_dash">%1$s — %2$s</string>
|
||||||
|
<string name="shared_string_local_maps">Local maps</string>
|
||||||
<string name="message_graph_will_be_available_after_recalculation">Wait for the route recalculation.\nGraph will be available after recalculation.</string>
|
<string name="message_graph_will_be_available_after_recalculation">Wait for the route recalculation.\nGraph will be available after recalculation.</string>
|
||||||
<string name="message_need_calculate_route_before_show_graph">%1$s data available only on the roads, you need to calculate a route using “Route between points” to get it.</string>
|
<string name="message_need_calculate_route_before_show_graph">%1$s data available only on the roads, you need to calculate a route using “Route between points” to get it.</string>
|
||||||
<string name="shared_string_graph">Graph</string>
|
<string name="shared_string_graph">Graph</string>
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,20 @@ public class OpenstreetmapPoint extends OsmPoint {
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTagsString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String tag : entity.getTagKeySet()) {
|
||||||
|
String val = entity.getTag(tag);
|
||||||
|
if (entity.isNotValid(tag)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sb.append(tag).append(" : ");
|
||||||
|
sb.append(val).append("; ");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringBuffer("Openstreetmap Point ").append(this.getAction()).append(" ").append(this.getName())
|
return new StringBuffer("Openstreetmap Point ").append(this.getAction()).append(" ").append(this.getName())
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,12 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.text.style.StyleSpan;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
@ -57,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;
|
||||||
|
|
||||||
|
|
||||||
|
@ -528,6 +533,15 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SpannableString getTitle(OsmPoint osmPoint, Context ctx) {
|
||||||
|
SpannableString title = new SpannableString(getName(osmPoint));
|
||||||
|
if (TextUtils.isEmpty(title)) {
|
||||||
|
title = SpannableString.valueOf(getCategory(osmPoint, ctx));
|
||||||
|
title.setSpan(new StyleSpan(Typeface.ITALIC), 0, title.length(), 0);
|
||||||
|
}
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getName(OsmPoint point) {
|
public static String getName(OsmPoint point) {
|
||||||
if (point.getGroup() == OsmPoint.Group.POI) {
|
if (point.getGroup() == OsmPoint.Group.POI) {
|
||||||
return ((OpenstreetmapPoint) point).getName();
|
return ((OpenstreetmapPoint) point).getName();
|
||||||
|
@ -541,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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.text.style.StyleSpan;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -21,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;
|
||||||
|
@ -182,7 +179,7 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
||||||
|
|
||||||
private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, final int position) {
|
private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, final int position) {
|
||||||
setupBackground(holder.mainView);
|
setupBackground(holder.mainView);
|
||||||
holder.titleTextView.setText(getTitle(osmEdit));
|
holder.titleTextView.setText(OsmEditingPlugin.getTitle(osmEdit, getContext()));
|
||||||
holder.descriptionTextView.setText(getDescription(osmEdit));
|
holder.descriptionTextView.setText(getDescription(osmEdit));
|
||||||
Drawable icon = getIcon(osmEdit);
|
Drawable icon = getIcon(osmEdit);
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
|
@ -243,20 +240,12 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
||||||
return items.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpannableString getTitle(OsmPoint osmPoint) {
|
|
||||||
SpannableString title = new SpannableString(OsmEditingPlugin.getName(osmPoint));
|
|
||||||
if (TextUtils.isEmpty(title)) {
|
|
||||||
title = SpannableString.valueOf(getCategory(osmPoint));
|
|
||||||
title.setSpan(new StyleSpan(Typeface.ITALIC), 0, title.length(), 0);
|
|
||||||
}
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Drawable getIcon(OsmPoint point) {
|
private Drawable getIcon(OsmPoint point) {
|
||||||
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());
|
||||||
|
@ -304,10 +293,6 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCategory(OsmPoint point) {
|
|
||||||
return OsmEditingPlugin.getCategory(point, getContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDescription(OsmPoint point) {
|
private String getDescription(OsmPoint point) {
|
||||||
return OsmEditingPlugin.getDescription(point, getContext(), true);
|
return OsmEditingPlugin.getDescription(point, getContext(), true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -781,7 +781,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
||||||
if (point.getGroup() == Group.POI) {
|
if (point.getGroup() == Group.POI) {
|
||||||
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
|
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
|
||||||
WptPt wpt = new WptPt();
|
WptPt wpt = new WptPt();
|
||||||
wpt.name = getTagsString(p);
|
wpt.name = p.getTagsString();
|
||||||
wpt.lat = p.getLatitude();
|
wpt.lat = p.getLatitude();
|
||||||
wpt.lon = p.getLongitude();
|
wpt.lon = p.getLongitude();
|
||||||
wpt.desc = "id: " + String.valueOf(p.getId()) +
|
wpt.desc = "id: " + String.valueOf(p.getId()) +
|
||||||
|
@ -817,24 +817,6 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTagsString(OpenstreetmapPoint point) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (String tag : point.getEntity().getTagKeySet()) {
|
|
||||||
String val = point.getEntity().getTag(tag);
|
|
||||||
if (isNotValid(tag, val)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sb.append(tag).append(" : ");
|
|
||||||
sb.append(val).append("; ");
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isNotValid(String tag, String val) {
|
|
||||||
return val == null || val.length() == 0 || tag.length() == 0
|
|
||||||
|| tag.startsWith(EditPoiData.REMOVE_TAG_PREFIX) || tag.equals("poi_type_tag");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeContent(XmlSerializer sz, OsmPoint[] points, OsmPoint.Action a) throws IllegalArgumentException, IllegalStateException, IOException {
|
private void writeContent(XmlSerializer sz, OsmPoint[] points, OsmPoint.Action a) throws IllegalArgumentException, IllegalStateException, IOException {
|
||||||
for (OsmPoint point : points) {
|
for (OsmPoint point : points) {
|
||||||
if (point.getGroup() == Group.POI) {
|
if (point.getGroup() == Group.POI) {
|
||||||
|
@ -878,7 +860,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
||||||
private void writeTags(XmlSerializer sz, Entity p) {
|
private void writeTags(XmlSerializer sz, Entity p) {
|
||||||
for (String tag : p.getTagKeySet()) {
|
for (String tag : p.getTagKeySet()) {
|
||||||
String val = p.getTag(tag);
|
String val = p.getTag(tag);
|
||||||
if (isNotValid(tag, val)) {
|
if (p.isNotValid(tag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,8 @@ public enum ExportSettingsType {
|
||||||
AVOID_ROADS,
|
AVOID_ROADS,
|
||||||
TRACKS,
|
TRACKS,
|
||||||
MULTIMEDIA_NOTES,
|
MULTIMEDIA_NOTES,
|
||||||
GLOBAL
|
GLOBAL,
|
||||||
|
OSM_NOTES,
|
||||||
|
OSM_EDITS,
|
||||||
|
OFFLINE_MAPS
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,15 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
public class FileSettingsItem extends StreamSettingsItem {
|
public class FileSettingsItem extends StreamSettingsItem {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum FileSubtype {
|
public enum FileSubtype {
|
||||||
UNKNOWN("", null),
|
UNKNOWN("", null),
|
||||||
OTHER("other", ""),
|
OTHER("other", ""),
|
||||||
ROUTING_CONFIG("routing_config", IndexConstants.ROUTING_PROFILES_DIR),
|
ROUTING_CONFIG("routing_config", IndexConstants.ROUTING_PROFILES_DIR),
|
||||||
RENDERING_STYLE("rendering_style", IndexConstants.RENDERERS_DIR),
|
RENDERING_STYLE("rendering_style", IndexConstants.RENDERERS_DIR),
|
||||||
|
WIKI_MAP("wiki_map", IndexConstants.WIKI_INDEX_DIR),
|
||||||
|
SRTM_MAP("srtm_map", IndexConstants.SRTM_INDEX_DIR),
|
||||||
OBF_MAP("obf_map", IndexConstants.MAPS_PATH),
|
OBF_MAP("obf_map", IndexConstants.MAPS_PATH),
|
||||||
TILES_MAP("tiles_map", IndexConstants.TILES_INDEX_DIR),
|
TILES_MAP("tiles_map", IndexConstants.TILES_INDEX_DIR),
|
||||||
GPX("gpx", IndexConstants.GPX_INDEX_DIR),
|
GPX("gpx", IndexConstants.GPX_INDEX_DIR),
|
||||||
|
@ -41,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;
|
||||||
}
|
}
|
||||||
|
@ -68,8 +76,18 @@ public class FileSettingsItem extends StreamSettingsItem {
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
case OTHER:
|
case OTHER:
|
||||||
break;
|
break;
|
||||||
|
case SRTM_MAP:
|
||||||
|
if (name.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)) {
|
||||||
|
return subtype;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WIKI_MAP:
|
||||||
|
if (name.endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) {
|
||||||
|
return subtype;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case OBF_MAP:
|
case OBF_MAP:
|
||||||
if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT) && !name.contains(File.separator)) {
|
||||||
return subtype;
|
return subtype;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -93,6 +111,7 @@ public class FileSettingsItem extends StreamSettingsItem {
|
||||||
protected File file;
|
protected File file;
|
||||||
private File appPath;
|
private File appPath;
|
||||||
protected FileSubtype subtype;
|
protected FileSubtype subtype;
|
||||||
|
private long size;
|
||||||
|
|
||||||
public FileSettingsItem(@NonNull OsmandApplication app, @NonNull File file) throws IllegalArgumentException {
|
public FileSettingsItem(@NonNull OsmandApplication app, @NonNull File file) throws IllegalArgumentException {
|
||||||
super(app, file.getPath().replace(app.getAppPath(null).getPath(), ""));
|
super(app, file.getPath().replace(app.getAppPath(null).getPath(), ""));
|
||||||
|
@ -171,6 +190,14 @@ public class FileSettingsItem extends StreamSettingsItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(long size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public File getFile() {
|
public File getFile() {
|
||||||
return file;
|
return file;
|
||||||
|
|
|
@ -0,0 +1,199 @@
|
||||||
|
package net.osmand.plus.settings.backend.backup;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
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;
|
||||||
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
|
import net.osmand.plus.osmedit.OpenstreetmapsDbHelper;
|
||||||
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
|
import net.osmand.plus.osmedit.OsmPoint;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class OsmEditsSettingsItem extends CollectionSettingsItem<OpenstreetmapPoint> {
|
||||||
|
|
||||||
|
public static final String ID_KEY = "id";
|
||||||
|
public static final String NAME_KEY = "name";
|
||||||
|
public static final String LAT_KEY = "lat";
|
||||||
|
public static final String LON_KEY = "lon";
|
||||||
|
public static final String COMMENT_KEY = "comment";
|
||||||
|
public static final String ACTION_KEY = "action";
|
||||||
|
public static final String TYPE_KEY = "type";
|
||||||
|
public static final String TAGS_KEY = "tags";
|
||||||
|
public static final String ENTITY_KEY = "entity";
|
||||||
|
|
||||||
|
public OsmEditsSettingsItem(@NonNull OsmandApplication app, @NonNull List<OpenstreetmapPoint> items) {
|
||||||
|
super(app, null, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OsmEditsSettingsItem(@NonNull OsmandApplication app, @Nullable OsmEditsSettingsItem baseItem,
|
||||||
|
@NonNull List<OpenstreetmapPoint> items) {
|
||||||
|
super(app, baseItem, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OsmEditsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
|
||||||
|
super(app, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
super.init();
|
||||||
|
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
|
if (osmEditingPlugin != null) {
|
||||||
|
existingItems = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public SettingsItemType getType() {
|
||||||
|
return SettingsItemType.OSM_EDITS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
List<OpenstreetmapPoint> newItems = getNewItems();
|
||||||
|
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
|
||||||
|
appliedItems = new ArrayList<>(newItems);
|
||||||
|
|
||||||
|
for (OpenstreetmapPoint duplicate : duplicateItems) {
|
||||||
|
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
|
if (osmEditingPlugin != null) {
|
||||||
|
OpenstreetmapsDbHelper db = osmEditingPlugin.getDBPOI();
|
||||||
|
for (OpenstreetmapPoint point : appliedItems) {
|
||||||
|
db.addOpenstreetmap(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDuplicate(@NonNull OpenstreetmapPoint item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public OpenstreetmapPoint renameItem(@NonNull OpenstreetmapPoint item) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "osm_edits";
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getPublicName(@NonNull Context ctx) {
|
||||||
|
return ctx.getString(R.string.osm_edits);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldReadOnCollecting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||||
|
try {
|
||||||
|
if (!json.has("items")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONArray jsonArray = json.getJSONArray("items");
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject jsonPoint = jsonArray.getJSONObject(i);
|
||||||
|
String comment = jsonPoint.optString(COMMENT_KEY);
|
||||||
|
comment = comment.isEmpty() ? null : comment;
|
||||||
|
JSONObject entityJson = jsonPoint.getJSONObject(ENTITY_KEY);
|
||||||
|
long id = entityJson.getLong(ID_KEY);
|
||||||
|
double lat = entityJson.getDouble(LAT_KEY);
|
||||||
|
double lon = entityJson.getDouble(LON_KEY);
|
||||||
|
String tags = entityJson.getString(TAGS_KEY);
|
||||||
|
Map<String, String> tagMap = new Gson().fromJson(
|
||||||
|
tags, new TypeToken<HashMap<String, String>>() {
|
||||||
|
}.getType()
|
||||||
|
);
|
||||||
|
String action = entityJson.getString(ACTION_KEY);
|
||||||
|
Entity entity;
|
||||||
|
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);
|
||||||
|
OpenstreetmapPoint point = new OpenstreetmapPoint();
|
||||||
|
point.setComment(comment);
|
||||||
|
point.setEntity(entity);
|
||||||
|
point.setAction(action);
|
||||||
|
items.add(point);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));
|
||||||
|
throw new IllegalArgumentException("Json parse error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void writeItemsToJson(@NonNull JSONObject json) {
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
if (!items.isEmpty()) {
|
||||||
|
try {
|
||||||
|
for (OpenstreetmapPoint point : items) {
|
||||||
|
JSONObject jsonPoint = new JSONObject();
|
||||||
|
JSONObject jsonEntity = new JSONObject();
|
||||||
|
jsonEntity.put(ID_KEY, point.getId());
|
||||||
|
jsonEntity.put(NAME_KEY, point.getTagsString());
|
||||||
|
jsonEntity.put(LAT_KEY, point.getLatitude());
|
||||||
|
jsonEntity.put(LON_KEY, point.getLongitude());
|
||||||
|
jsonEntity.put(TYPE_KEY, Entity.EntityType.valueOf(point.getEntity()));
|
||||||
|
JSONObject jsonTags = new JSONObject(point.getEntity().getTags());
|
||||||
|
jsonEntity.put(TAGS_KEY, jsonTags);
|
||||||
|
jsonPoint.put(COMMENT_KEY, point.getComment());
|
||||||
|
jsonEntity.put(ACTION_KEY, OsmPoint.stringAction.get(point.getAction()));
|
||||||
|
jsonPoint.put(ENTITY_KEY, jsonEntity);
|
||||||
|
jsonArray.put(jsonPoint);
|
||||||
|
}
|
||||||
|
json.put("items", jsonArray);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
|
||||||
|
SettingsHelper.LOG.error("Failed write to json", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
SettingsItemReader<? extends SettingsItem> getReader() {
|
||||||
|
return getJsonReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
SettingsItemWriter<? extends SettingsItem> getWriter() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,172 @@
|
||||||
|
package net.osmand.plus.settings.backend.backup;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.osmedit.OsmBugsDbHelper;
|
||||||
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
|
import net.osmand.plus.osmedit.OsmPoint;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OsmNotesSettingsItem extends CollectionSettingsItem<OsmNotesPoint> {
|
||||||
|
|
||||||
|
public static final String ID_KEY = "id";
|
||||||
|
public static final String TEXT_KEY = "text";
|
||||||
|
public static final String LAT_KEY = "lat";
|
||||||
|
public static final String LON_KEY = "lon";
|
||||||
|
public static final String AUTHOR_KEY = "author";
|
||||||
|
public static final String ACTION_KEY = "action";
|
||||||
|
|
||||||
|
public OsmNotesSettingsItem(@NonNull OsmandApplication app, @NonNull List<OsmNotesPoint> items) {
|
||||||
|
super(app, null, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OsmNotesSettingsItem(@NonNull OsmandApplication app, @Nullable OsmNotesSettingsItem baseItem,
|
||||||
|
@NonNull List<OsmNotesPoint> items) {
|
||||||
|
super(app, baseItem, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OsmNotesSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
|
||||||
|
super(app, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
super.init();
|
||||||
|
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
|
if (osmEditingPlugin != null) {
|
||||||
|
existingItems = osmEditingPlugin.getDBBug().getOsmbugsPoints();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public SettingsItemType getType() {
|
||||||
|
return SettingsItemType.OSM_NOTES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
List<OsmNotesPoint> newItems = getNewItems();
|
||||||
|
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
|
||||||
|
appliedItems = new ArrayList<>(newItems);
|
||||||
|
|
||||||
|
for (OsmNotesPoint duplicate : duplicateItems) {
|
||||||
|
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
|
||||||
|
}
|
||||||
|
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
|
if (osmEditingPlugin != null) {
|
||||||
|
OsmBugsDbHelper db = osmEditingPlugin.getDBBug();
|
||||||
|
for (OsmNotesPoint point : appliedItems) {
|
||||||
|
db.addOsmbugs(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDuplicate(@NonNull OsmNotesPoint item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public OsmNotesPoint renameItem(@NonNull OsmNotesPoint item) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "osm_notes";
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getPublicName(@NonNull Context ctx) {
|
||||||
|
return ctx.getString(R.string.osm_notes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldReadOnCollecting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||||
|
try {
|
||||||
|
if (!json.has("items")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONArray jsonArray = json.getJSONArray("items");
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject object = jsonArray.getJSONObject(i);
|
||||||
|
long id = object.getLong(ID_KEY);
|
||||||
|
String text = object.optString(TEXT_KEY);
|
||||||
|
double lat = object.getDouble(LAT_KEY);
|
||||||
|
double lon = object.getDouble(LON_KEY);
|
||||||
|
String author = object.optString(AUTHOR_KEY);
|
||||||
|
author = author.isEmpty() ? null : author;
|
||||||
|
String action = object.getString(ACTION_KEY);
|
||||||
|
OsmNotesPoint point = new OsmNotesPoint();
|
||||||
|
point.setId(id);
|
||||||
|
point.setText(text);
|
||||||
|
point.setLatitude(lat);
|
||||||
|
point.setLongitude(lon);
|
||||||
|
point.setAuthor(author);
|
||||||
|
point.setAction(action);
|
||||||
|
items.add(point);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));
|
||||||
|
throw new IllegalArgumentException("Json parse error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void writeItemsToJson(@NonNull JSONObject json) {
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
if (!items.isEmpty()) {
|
||||||
|
try {
|
||||||
|
for (OsmNotesPoint point : items) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put(ID_KEY, point.getId());
|
||||||
|
jsonObject.put(TEXT_KEY, point.getText());
|
||||||
|
jsonObject.put(LAT_KEY, point.getLatitude());
|
||||||
|
jsonObject.put(LON_KEY, point.getLongitude());
|
||||||
|
jsonObject.put(AUTHOR_KEY, point.getAuthor());
|
||||||
|
jsonObject.put(ACTION_KEY, OsmPoint.stringAction.get(point.getAction()));
|
||||||
|
jsonArray.put(jsonObject);
|
||||||
|
}
|
||||||
|
json.put("items", jsonArray);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
|
||||||
|
SettingsHelper.LOG.error("Failed write to json", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
SettingsItemReader<? extends SettingsItem> getReader() {
|
||||||
|
return getJsonReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
SettingsItemWriter<? extends SettingsItem> getWriter() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,11 +16,17 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.SQLiteTileSource;
|
import net.osmand.plus.SQLiteTileSource;
|
||||||
|
import net.osmand.plus.activities.LocalIndexHelper;
|
||||||
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||||
|
import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
|
||||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||||
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||||
|
@ -41,6 +47,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
|
import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
|
||||||
|
import static net.osmand.plus.activities.LocalIndexHelper.*;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Usage:
|
Usage:
|
||||||
|
@ -513,9 +520,41 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
dataList.put(ExportSettingsType.PROFILE, appModeBeans);
|
dataList.put(ExportSettingsType.PROFILE, appModeBeans);
|
||||||
}
|
}
|
||||||
|
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
|
if (osmEditingPlugin != null) {
|
||||||
|
List<OsmNotesPoint> notesPointList = osmEditingPlugin.getDBBug().getOsmbugsPoints();
|
||||||
|
if (!notesPointList.isEmpty()) {
|
||||||
|
dataList.put(ExportSettingsType.OSM_NOTES, notesPointList);
|
||||||
|
}
|
||||||
|
List<OpenstreetmapPoint> editsPointList = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints();
|
||||||
|
if (!editsPointList.isEmpty()) {
|
||||||
|
dataList.put(ExportSettingsType.OSM_EDITS, editsPointList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<File> files = getLocalMapFiles();
|
||||||
|
if (!files.isEmpty()) {
|
||||||
|
dataList.put(ExportSettingsType.OFFLINE_MAPS, files);
|
||||||
|
}
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<File> getLocalMapFiles() {
|
||||||
|
List<File> files = new ArrayList<>();
|
||||||
|
LocalIndexHelper helper = new LocalIndexHelper(app);
|
||||||
|
List<LocalIndexInfo> localMapFileList = helper.getLocalIndexData(new AbstractLoadLocalIndexTask() {
|
||||||
|
@Override
|
||||||
|
public void loadFile(LocalIndexInfo... loaded) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (LocalIndexInfo map : localMapFileList) {
|
||||||
|
File file = new File(map.getPathToData());
|
||||||
|
if (file != null && file.exists() && map.getType() != LocalIndexType.TTS_VOICE_DATA) {
|
||||||
|
files.add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
public List<SettingsItem> prepareAdditionalSettingsItems(List<? super Object> data) {
|
public List<SettingsItem> prepareAdditionalSettingsItems(List<? super Object> data) {
|
||||||
List<SettingsItem> settingsItems = new ArrayList<>();
|
List<SettingsItem> settingsItems = new ArrayList<>();
|
||||||
List<QuickAction> quickActions = new ArrayList<>();
|
List<QuickAction> quickActions = new ArrayList<>();
|
||||||
|
@ -523,6 +562,9 @@ public class SettingsHelper {
|
||||||
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
||||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||||
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
||||||
|
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
|
||||||
|
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
|
||||||
|
|
||||||
for (Object object : data) {
|
for (Object object : data) {
|
||||||
if (object instanceof QuickAction) {
|
if (object instanceof QuickAction) {
|
||||||
quickActions.add((QuickAction) object);
|
quickActions.add((QuickAction) object);
|
||||||
|
@ -540,6 +582,10 @@ public class SettingsHelper {
|
||||||
avoidRoads.add((AvoidRoadInfo) object);
|
avoidRoads.add((AvoidRoadInfo) object);
|
||||||
} else if (object instanceof ApplicationModeBean) {
|
} else if (object instanceof ApplicationModeBean) {
|
||||||
appModeBeans.add((ApplicationModeBean) object);
|
appModeBeans.add((ApplicationModeBean) object);
|
||||||
|
} else if (object instanceof OsmNotesPoint) {
|
||||||
|
osmNotesPointList.add((OsmNotesPoint) object);
|
||||||
|
} else if (object instanceof OpenstreetmapPoint) {
|
||||||
|
osmEditsPointList.add((OpenstreetmapPoint) object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!quickActions.isEmpty()) {
|
if (!quickActions.isEmpty()) {
|
||||||
|
@ -562,6 +608,12 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!osmNotesPointList.isEmpty()) {
|
||||||
|
settingsItems.add(new OsmNotesSettingsItem(app, osmNotesPointList));
|
||||||
|
}
|
||||||
|
if (!osmEditsPointList.isEmpty()) {
|
||||||
|
settingsItems.add(new OsmEditsSettingsItem(app, osmEditsPointList));
|
||||||
|
}
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,8 +627,11 @@ public class SettingsHelper {
|
||||||
List<File> renderFilesList = new ArrayList<>();
|
List<File> renderFilesList = new ArrayList<>();
|
||||||
List<File> multimediaFilesList = new ArrayList<>();
|
List<File> multimediaFilesList = new ArrayList<>();
|
||||||
List<File> tracksFilesList = new ArrayList<>();
|
List<File> tracksFilesList = new ArrayList<>();
|
||||||
|
List<FileSettingsItem> mapFilesList = new ArrayList<>();
|
||||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||||
List<GlobalSettingsItem> globalSettingsItems = new ArrayList<>();
|
List<GlobalSettingsItem> globalSettingsItems = new ArrayList<>();
|
||||||
|
List<OsmNotesPoint> notesPointList = new ArrayList<>();
|
||||||
|
List<OpenstreetmapPoint> editsPointList = new ArrayList<>();
|
||||||
for (SettingsItem item : settingsItems) {
|
for (SettingsItem item : settingsItems) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case PROFILE:
|
case PROFILE:
|
||||||
|
@ -592,6 +647,11 @@ public class SettingsHelper {
|
||||||
multimediaFilesList.add(fileItem.getFile());
|
multimediaFilesList.add(fileItem.getFile());
|
||||||
} else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.GPX) {
|
} else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.GPX) {
|
||||||
tracksFilesList.add(fileItem.getFile());
|
tracksFilesList.add(fileItem.getFile());
|
||||||
|
} else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.OBF_MAP
|
||||||
|
|| fileItem.getSubtype() == FileSettingsItem.FileSubtype.WIKI_MAP
|
||||||
|
|| fileItem.getSubtype() == FileSettingsItem.FileSubtype.SRTM_MAP
|
||||||
|
|| fileItem.getSubtype() == FileSettingsItem.FileSubtype.TILES_MAP) {
|
||||||
|
mapFilesList.add(fileItem);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QUICK_ACTIONS:
|
case QUICK_ACTIONS:
|
||||||
|
@ -629,6 +689,22 @@ public class SettingsHelper {
|
||||||
case GLOBAL:
|
case GLOBAL:
|
||||||
globalSettingsItems.add((GlobalSettingsItem) item);
|
globalSettingsItems.add((GlobalSettingsItem) item);
|
||||||
break;
|
break;
|
||||||
|
case OSM_NOTES:
|
||||||
|
OsmNotesSettingsItem osmNotesSettingsItem = (OsmNotesSettingsItem) item;
|
||||||
|
if (importComplete) {
|
||||||
|
notesPointList.addAll(osmNotesSettingsItem.getAppliedItems());
|
||||||
|
} else {
|
||||||
|
notesPointList.addAll(osmNotesSettingsItem.getItems());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OSM_EDITS:
|
||||||
|
OsmEditsSettingsItem osmEditsSettingsItem = (OsmEditsSettingsItem) item;
|
||||||
|
if (importComplete) {
|
||||||
|
editsPointList.addAll(osmEditsSettingsItem.getAppliedItems());
|
||||||
|
} else {
|
||||||
|
editsPointList.addAll(osmEditsSettingsItem.getItems());
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -664,6 +740,15 @@ public class SettingsHelper {
|
||||||
if (!globalSettingsItems.isEmpty()) {
|
if (!globalSettingsItems.isEmpty()) {
|
||||||
settingsToOperate.put(ExportSettingsType.GLOBAL, globalSettingsItems);
|
settingsToOperate.put(ExportSettingsType.GLOBAL, globalSettingsItems);
|
||||||
}
|
}
|
||||||
|
if (!notesPointList.isEmpty()) {
|
||||||
|
settingsToOperate.put(ExportSettingsType.OSM_NOTES, notesPointList);
|
||||||
|
}
|
||||||
|
if (!editsPointList.isEmpty()) {
|
||||||
|
settingsToOperate.put(ExportSettingsType.OSM_EDITS, editsPointList);
|
||||||
|
}
|
||||||
|
if (!mapFilesList.isEmpty()) {
|
||||||
|
settingsToOperate.put(ExportSettingsType.OFFLINE_MAPS, mapFilesList);
|
||||||
|
}
|
||||||
return settingsToOperate;
|
return settingsToOperate;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,8 +15,10 @@ import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipFile;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
|
import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
|
||||||
|
@ -57,7 +59,9 @@ class SettingsImporter {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SettingsItemsFactory itemsFactory = new SettingsItemsFactory(app, itemsJson);
|
SettingsItemsFactory itemsFactory = new SettingsItemsFactory(app, itemsJson);
|
||||||
items.addAll(itemsFactory.getItems());
|
List<SettingsItem> settingsItemList = itemsFactory.getItems();
|
||||||
|
getFilesSize(file, settingsItemList);
|
||||||
|
items.addAll(settingsItemList);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
SettingsHelper.LOG.error("Error parsing items: " + itemsJson, e);
|
SettingsHelper.LOG.error("Error parsing items: " + itemsJson, e);
|
||||||
throw new IllegalArgumentException("No items");
|
throw new IllegalArgumentException("No items");
|
||||||
|
@ -77,6 +81,22 @@ class SettingsImporter {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getFilesSize(@NonNull File file, List<SettingsItem> settingsItemList) throws IOException {
|
||||||
|
ZipFile zipfile = new ZipFile(file.getPath());
|
||||||
|
Enumeration<? extends ZipEntry> zipEnum = zipfile.entries();
|
||||||
|
while (zipEnum.hasMoreElements()) {
|
||||||
|
ZipEntry zipEntry = zipEnum.nextElement();
|
||||||
|
long size = zipEntry.getSize();
|
||||||
|
for (SettingsItem settingsItem : settingsItemList) {
|
||||||
|
if (settingsItem instanceof FileSettingsItem
|
||||||
|
&& zipEntry.getName().equals(settingsItem.getFileName())) {
|
||||||
|
((FileSettingsItem) settingsItem).setSize(size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<SettingsItem> processItems(@NonNull File file, @Nullable List<SettingsItem> items) throws IllegalArgumentException, IOException {
|
private List<SettingsItem> processItems(@NonNull File file, @Nullable List<SettingsItem> items) throws IllegalArgumentException, IOException {
|
||||||
boolean collecting = items == null;
|
boolean collecting = items == null;
|
||||||
if (collecting) {
|
if (collecting) {
|
||||||
|
|
|
@ -12,5 +12,7 @@ public enum SettingsItemType {
|
||||||
MAP_SOURCES,
|
MAP_SOURCES,
|
||||||
AVOID_ROADS,
|
AVOID_ROADS,
|
||||||
SUGGESTED_DOWNLOADS,
|
SUGGESTED_DOWNLOADS,
|
||||||
DOWNLOADS
|
DOWNLOADS,
|
||||||
|
OSM_NOTES,
|
||||||
|
OSM_EDITS,
|
||||||
}
|
}
|
|
@ -125,6 +125,12 @@ class SettingsItemsFactory {
|
||||||
case DOWNLOADS:
|
case DOWNLOADS:
|
||||||
item = new DownloadsItem(app, json);
|
item = new DownloadsItem(app, json);
|
||||||
break;
|
break;
|
||||||
|
case OSM_NOTES:
|
||||||
|
item = new OsmNotesSettingsItem(app, json);
|
||||||
|
break;
|
||||||
|
case OSM_EDITS:
|
||||||
|
item = new OsmEditsSettingsItem(app, json);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,11 @@ import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.profiles.ProfileIconColors;
|
import net.osmand.plus.profiles.ProfileIconColors;
|
||||||
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
|
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
|
||||||
|
@ -32,6 +36,7 @@ import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
|
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
|
||||||
|
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.view.ThreeStateCheckbox;
|
import net.osmand.view.ThreeStateCheckbox;
|
||||||
|
|
||||||
|
@ -44,6 +49,8 @@ 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.ExportSettingsType.*;
|
||||||
|
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.*;
|
||||||
import static net.osmand.view.ThreeStateCheckbox.State.CHECKED;
|
import static net.osmand.view.ThreeStateCheckbox.State.CHECKED;
|
||||||
import static net.osmand.view.ThreeStateCheckbox.State.MISC;
|
import static net.osmand.view.ThreeStateCheckbox.State.MISC;
|
||||||
import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED;
|
import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED;
|
||||||
|
@ -103,7 +110,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
cardBottomDivider.setVisibility(importState && !isExpanded ? View.VISIBLE : View.GONE);
|
cardBottomDivider.setVisibility(importState && !isExpanded ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
final List<?> listItems = itemsMap.get(type);
|
final List<?> listItems = itemsMap.get(type);
|
||||||
subTextTv.setText(getSelectedItemsAmount(listItems));
|
subTextTv.setText(getSelectedItemsAmount(listItems, type));
|
||||||
|
|
||||||
if (data.containsAll(listItems)) {
|
if (data.containsAll(listItems)) {
|
||||||
checkBox.setState(CHECKED);
|
checkBox.setState(CHECKED);
|
||||||
|
@ -154,6 +161,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
|
|
||||||
TextView title = child.findViewById(R.id.title_tv);
|
TextView title = child.findViewById(R.id.title_tv);
|
||||||
TextView subText = child.findViewById(R.id.sub_title_tv);
|
TextView subText = child.findViewById(R.id.sub_title_tv);
|
||||||
|
subText.setVisibility(View.GONE);
|
||||||
final CheckBox checkBox = child.findViewById(R.id.check_box);
|
final CheckBox checkBox = child.findViewById(R.id.check_box);
|
||||||
ImageView icon = child.findViewById(R.id.icon);
|
ImageView icon = child.findViewById(R.id.icon);
|
||||||
View lineDivider = child.findViewById(R.id.divider);
|
View lineDivider = child.findViewById(R.id.divider);
|
||||||
|
@ -198,9 +206,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e);
|
LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Algorithms.isEmpty(routingProfile)) {
|
if (!Algorithms.isEmpty(routingProfile)) {
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
subText.setText(String.format(
|
subText.setText(String.format(
|
||||||
app.getString(R.string.ltr_or_rtl_combine_via_colon),
|
app.getString(R.string.ltr_or_rtl_combine_via_colon),
|
||||||
app.getString(R.string.nav_type_hint),
|
app.getString(R.string.nav_type_hint),
|
||||||
|
@ -214,38 +220,32 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
case QUICK_ACTIONS:
|
case QUICK_ACTIONS:
|
||||||
title.setText(((QuickAction) currentItem).getName(app.getApplicationContext()));
|
title.setText(((QuickAction) currentItem).getName(app.getApplicationContext()));
|
||||||
setupIcon(icon, ((QuickAction) currentItem).getIconRes(), itemSelected);
|
setupIcon(icon, ((QuickAction) currentItem).getIconRes(), itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
case POI_TYPES:
|
case POI_TYPES:
|
||||||
title.setText(((PoiUIFilter) currentItem).getName());
|
title.setText(((PoiUIFilter) currentItem).getName());
|
||||||
int iconRes = RenderingIcons.getBigIconResourceId(((PoiUIFilter) currentItem).getIconId());
|
int iconRes = RenderingIcons.getBigIconResourceId(((PoiUIFilter) currentItem).getIconId());
|
||||||
setupIcon(icon, iconRes != 0 ? iconRes : R.drawable.ic_action_user, itemSelected);
|
setupIcon(icon, iconRes != 0 ? iconRes : R.drawable.ic_action_user, itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
case MAP_SOURCES:
|
case MAP_SOURCES:
|
||||||
title.setText(((ITileSource) currentItem).getName());
|
title.setText(((ITileSource) currentItem).getName());
|
||||||
setupIcon(icon, R.drawable.ic_map, itemSelected);
|
setupIcon(icon, R.drawable.ic_map, itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
case CUSTOM_RENDER_STYLE:
|
case CUSTOM_RENDER_STYLE:
|
||||||
String renderName = ((File) currentItem).getName();
|
String renderName = ((File) currentItem).getName();
|
||||||
renderName = renderName.replace('_', ' ').replaceAll(IndexConstants.RENDERER_INDEX_EXT, "");
|
renderName = renderName.replace('_', ' ').replaceAll(IndexConstants.RENDERER_INDEX_EXT, "");
|
||||||
title.setText(renderName);
|
title.setText(renderName);
|
||||||
setupIcon(icon, R.drawable.ic_action_map_style, itemSelected);
|
setupIcon(icon, R.drawable.ic_action_map_style, itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
case CUSTOM_ROUTING:
|
case CUSTOM_ROUTING:
|
||||||
String routingName = ((File) currentItem).getName();
|
String routingName = ((File) currentItem).getName();
|
||||||
routingName = routingName.replace('_', ' ').replaceAll(".xml", "");
|
routingName = routingName.replace('_', ' ').replaceAll(".xml", "");
|
||||||
title.setText(routingName);
|
title.setText(routingName);
|
||||||
setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected);
|
setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
case AVOID_ROADS:
|
case AVOID_ROADS:
|
||||||
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) currentItem;
|
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) currentItem;
|
||||||
title.setText(avoidRoadInfo.name);
|
title.setText(avoidRoadInfo.name);
|
||||||
setupIcon(icon, R.drawable.ic_action_alert, itemSelected);
|
setupIcon(icon, R.drawable.ic_action_alert, itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
case MULTIMEDIA_NOTES:
|
case MULTIMEDIA_NOTES:
|
||||||
File file = (File) currentItem;
|
File file = (File) currentItem;
|
||||||
|
@ -255,19 +255,53 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
iconId = R.drawable.ic_action_photo_dark;
|
iconId = R.drawable.ic_action_photo_dark;
|
||||||
}
|
}
|
||||||
setupIcon(icon, iconId, itemSelected);
|
setupIcon(icon, iconId, itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
case TRACKS:
|
case TRACKS:
|
||||||
String fileName = ((File) currentItem).getName();
|
String fileName = ((File) currentItem).getName();
|
||||||
title.setText(GpxUiHelper.getGpxTitle(fileName));
|
title.setText(GpxUiHelper.getGpxTitle(fileName));
|
||||||
setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected);
|
setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
case GLOBAL:
|
case GLOBAL:
|
||||||
String name = ((GlobalSettingsItem) currentItem).getPublicName(app);
|
String name = ((GlobalSettingsItem) currentItem).getPublicName(app);
|
||||||
title.setText(name);
|
title.setText(name);
|
||||||
setupIcon(icon, R.drawable.ic_action_settings, itemSelected);
|
setupIcon(icon, R.drawable.ic_action_settings, itemSelected);
|
||||||
subText.setVisibility(View.GONE);
|
break;
|
||||||
|
case OSM_NOTES:
|
||||||
|
title.setText(((OsmNotesPoint) currentItem).getText());
|
||||||
|
setupIcon(icon, R.drawable.ic_action_osm_note_add, itemSelected);
|
||||||
|
break;
|
||||||
|
case OSM_EDITS:
|
||||||
|
title.setText(OsmEditingPlugin.getTitle((OpenstreetmapPoint) currentItem, app));
|
||||||
|
setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected);
|
||||||
|
break;
|
||||||
|
case OFFLINE_MAPS:
|
||||||
|
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(), ""));
|
||||||
|
switch (subtype) {
|
||||||
|
case SRTM_MAP:
|
||||||
|
iconId = R.drawable.ic_plugin_srtm;
|
||||||
|
break;
|
||||||
|
case WIKI_MAP:
|
||||||
|
iconId = R.drawable.ic_plugin_wikipedia;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
iconId = R.drawable.ic_map;
|
||||||
|
}
|
||||||
|
setupIcon(icon, iconId, itemSelected);
|
||||||
|
subText.setText(AndroidUtils.formatSize(app, size));
|
||||||
|
subText.setVisibility(View.VISIBLE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return child;
|
return child;
|
||||||
|
@ -315,14 +349,20 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSelectedItemsAmount(List<?> listItems) {
|
private String getSelectedItemsAmount(List<?> listItems, ExportSettingsType type) {
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
|
long amountSize = 0;
|
||||||
for (Object item : listItems) {
|
for (Object item : listItems) {
|
||||||
if (data.contains(item)) {
|
if (data.contains(item)) {
|
||||||
amount++;
|
amount++;
|
||||||
|
if (type == OFFLINE_MAPS && item instanceof FileSettingsItem) {
|
||||||
|
amountSize += ((FileSettingsItem) item).getSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return app.getString(R.string.n_items_of_z, String.valueOf(amount), String.valueOf(listItems.size()));
|
}
|
||||||
|
String itemsOf = app.getString(R.string.n_items_of_z, String.valueOf(amount), String.valueOf(listItems.size()));
|
||||||
|
return amountSize == 0 ? itemsOf : app.getString(R.string.ltr_or_rtl_combine_via_bold_point, itemsOf,
|
||||||
|
AndroidUtils.formatSize(app, amountSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getGroupTitle(ExportSettingsType type) {
|
private int getGroupTitle(ExportSettingsType type) {
|
||||||
|
@ -347,6 +387,12 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
return R.string.audionotes_plugin_name;
|
return R.string.audionotes_plugin_name;
|
||||||
case GLOBAL:
|
case GLOBAL:
|
||||||
return R.string.general_settings_2;
|
return R.string.general_settings_2;
|
||||||
|
case OSM_NOTES:
|
||||||
|
return R.string.osm_notes;
|
||||||
|
case OSM_EDITS:
|
||||||
|
return R.string.osm_edit_modified_poi;
|
||||||
|
case OFFLINE_MAPS:
|
||||||
|
return R.string.shared_string_local_maps;
|
||||||
default:
|
default:
|
||||||
return R.string.access_empty_list;
|
return R.string.access_empty_list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.settings.fragments;
|
package net.osmand.plus.settings.fragments;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -31,6 +32,7 @@ import net.osmand.plus.quickaction.QuickActionListFragment;
|
||||||
import net.osmand.plus.routepreparationmenu.AvoidRoadsBottomSheetDialogFragment;
|
import net.osmand.plus.routepreparationmenu.AvoidRoadsBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.search.QuickSearchDialogFragment;
|
import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
|
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||||
|
|
||||||
|
@ -187,6 +189,14 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
case AVOID_ROADS:
|
case AVOID_ROADS:
|
||||||
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||||
break;
|
break;
|
||||||
|
case OSM_NOTES:
|
||||||
|
case OSM_EDITS:
|
||||||
|
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
||||||
|
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
|
||||||
|
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
app.getSettings().FAVORITES_TAB.set(R.string.osm_edits);
|
||||||
|
startActivity(favorites);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
|
@ -27,6 +28,7 @@ import androidx.fragment.app.FragmentManager;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.IProgress;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.map.ITileSource;
|
import net.osmand.map.ITileSource;
|
||||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||||
|
@ -38,10 +40,14 @@ import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
|
import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem;
|
||||||
|
import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
||||||
import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem;
|
import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
||||||
|
@ -59,12 +65,12 @@ import net.osmand.util.Algorithms;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class ImportSettingsFragment extends BaseOsmAndFragment
|
public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
implements View.OnClickListener {
|
implements View.OnClickListener {
|
||||||
|
|
||||||
|
@ -267,6 +273,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
if (succeed) {
|
if (succeed) {
|
||||||
app.getRendererRegistry().updateExternalRenderers();
|
app.getRendererRegistry().updateExternalRenderers();
|
||||||
AppInitializer.loadRoutingFiles(app, null);
|
AppInitializer.loadRoutingFiles(app, null);
|
||||||
|
reloadIndexes(items);
|
||||||
if (fm != null && file != null) {
|
if (fm != null && file != null) {
|
||||||
ImportCompleteFragment.showInstance(fm, items, file.getName());
|
ImportCompleteFragment.showInstance(fm, items, file.getName());
|
||||||
}
|
}
|
||||||
|
@ -275,6 +282,43 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reloadIndexes(@NonNull List<SettingsItem> items) {
|
||||||
|
for (SettingsItem item : items) {
|
||||||
|
if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype().isMap()) {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity instanceof MapActivity) {
|
||||||
|
new ReloadIndexesTack((MapActivity) activity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ReloadIndexesTack extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
private final WeakReference<MapActivity> mapActivityRef;
|
||||||
|
private final OsmandApplication app;
|
||||||
|
|
||||||
|
ReloadIndexesTack(@NonNull MapActivity mapActivity) {
|
||||||
|
this.mapActivityRef = new WeakReference<>(mapActivity);
|
||||||
|
this.app = mapActivity.getMyApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void[] params) {
|
||||||
|
app.getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS, new ArrayList<String>());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
MapActivity mapActivity = mapActivityRef.get();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private SettingsHelper.CheckDuplicatesListener getDuplicatesListener() {
|
private SettingsHelper.CheckDuplicatesListener getDuplicatesListener() {
|
||||||
return new SettingsHelper.CheckDuplicatesListener() {
|
return new SettingsHelper.CheckDuplicatesListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -374,6 +418,16 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private <T> T getBaseItem(SettingsItemType settingsItemType, Class<T> clazz) {
|
||||||
|
for (SettingsItem settingsItem : settingsItems) {
|
||||||
|
if (settingsItem.getType() == settingsItemType && clazz.isInstance(settingsItem)) {
|
||||||
|
return clazz.cast(settingsItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private List<SettingsItem> getSettingsItemsFromData(List<?> data) {
|
private List<SettingsItem> getSettingsItemsFromData(List<?> data) {
|
||||||
List<SettingsItem> settingsItems = new ArrayList<>();
|
List<SettingsItem> settingsItems = new ArrayList<>();
|
||||||
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
||||||
|
@ -381,6 +435,8 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||||
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
||||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||||
|
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
|
||||||
|
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
|
||||||
for (Object object : data) {
|
for (Object object : data) {
|
||||||
if (object instanceof ApplicationModeBean) {
|
if (object instanceof ApplicationModeBean) {
|
||||||
appModeBeans.add((ApplicationModeBean) object);
|
appModeBeans.add((ApplicationModeBean) object);
|
||||||
|
@ -392,8 +448,14 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
tileSourceTemplates.add((ITileSource) object);
|
tileSourceTemplates.add((ITileSource) object);
|
||||||
} else if (object instanceof File) {
|
} else if (object instanceof File) {
|
||||||
settingsItems.add(new FileSettingsItem(app, (File) object));
|
settingsItems.add(new FileSettingsItem(app, (File) object));
|
||||||
|
} else if (object instanceof FileSettingsItem) {
|
||||||
|
settingsItems.add((FileSettingsItem) object);
|
||||||
} else if (object instanceof AvoidRoadInfo) {
|
} else if (object instanceof AvoidRoadInfo) {
|
||||||
avoidRoads.add((AvoidRoadInfo) object);
|
avoidRoads.add((AvoidRoadInfo) object);
|
||||||
|
} else if (object instanceof OsmNotesPoint) {
|
||||||
|
osmNotesPointList.add((OsmNotesPoint) object);
|
||||||
|
} else if (object instanceof OpenstreetmapPoint) {
|
||||||
|
osmEditsPointList.add((OpenstreetmapPoint) object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!appModeBeans.isEmpty()) {
|
if (!appModeBeans.isEmpty()) {
|
||||||
|
@ -413,6 +475,14 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
|
||||||
if (!avoidRoads.isEmpty()) {
|
if (!avoidRoads.isEmpty()) {
|
||||||
settingsItems.add(new AvoidRoadsSettingsItem(app, getBaseAvoidRoadsSettingsItem(), avoidRoads));
|
settingsItems.add(new AvoidRoadsSettingsItem(app, getBaseAvoidRoadsSettingsItem(), avoidRoads));
|
||||||
}
|
}
|
||||||
|
if (!osmNotesPointList.isEmpty()) {
|
||||||
|
OsmNotesSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_NOTES, OsmNotesSettingsItem.class);
|
||||||
|
settingsItems.add(new OsmNotesSettingsItem(app, baseItem, osmNotesPointList));
|
||||||
|
}
|
||||||
|
if (!osmEditsPointList.isEmpty()) {
|
||||||
|
OsmEditsSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_EDITS, OsmEditsSettingsItem.class);
|
||||||
|
settingsItems.add(new OsmEditsSettingsItem(app, baseItem, osmEditsPointList));
|
||||||
|
}
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,14 @@ public class ImportedSettingsItemsAdapter extends
|
||||||
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
|
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
|
||||||
holder.title.setText(R.string.shared_string_tracks);
|
holder.title.setText(R.string.shared_string_tracks);
|
||||||
break;
|
break;
|
||||||
|
case OSM_NOTES:
|
||||||
|
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_osm_note_add, activeColorRes));
|
||||||
|
holder.title.setText(R.string.osm_notes);
|
||||||
|
break;
|
||||||
|
case OSM_EDITS:
|
||||||
|
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_info_dark, activeColorRes));
|
||||||
|
holder.title.setText(R.string.osm_edit_modified_poi);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue