Fix for Edit/Delete existing POI broken functionality.
Deletion now implemented with dialog fragment. And editing is working with new editing screen. Editing screen fixed to work with existing poi
This commit is contained in:
parent
4a7c7f9c0e
commit
b65bbdc779
6 changed files with 52 additions and 17 deletions
|
@ -1,7 +1,8 @@
|
|||
package net.osmand.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class LatLon {
|
||||
public class LatLon implements Serializable {
|
||||
private final double longitude;
|
||||
private final double latitude;
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ public class BasicDataFragment extends Fragment {
|
|||
mIsUserInput = true;
|
||||
}
|
||||
};
|
||||
mTagsChangedListener.onTagsChanged();
|
||||
getData().addListener(mTagsChangedListener);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ public class EditPoiFragment extends Fragment {
|
|||
public static final String TAG = "EditPoiFragment";
|
||||
private static final Log LOG = PlatformUtil.getLog(EditPoiFragment.class);
|
||||
|
||||
private static final String KEY_AMENITY_NODE = "amenity_node";
|
||||
private static final String KEY_AMENITY = "amenity";
|
||||
private static final String KEY_AMENITY_NODE = "key_amenity_node";
|
||||
private static final String KEY_AMENITY = "key_amenity";
|
||||
private static final String TAGS_LIST = "tags_list";
|
||||
|
||||
private final EditPoiData editPoiData = new EditPoiData();
|
||||
|
@ -114,6 +114,34 @@ public class EditPoiFragment extends Fragment {
|
|||
editPoiData.tags = (LinkedHashSet<Tag>) savedInstanceState.getSerializable(TAGS_LIST);
|
||||
} else {
|
||||
editPoiData.tags = new LinkedHashSet<>();
|
||||
LOG.debug("node.tags=" + node.getTags());
|
||||
|
||||
tryAddTag(OSMSettings.OSMTagKey.ADDR_STREET.getValue(),
|
||||
node.getTag(OSMSettings.OSMTagKey.ADDR_STREET));
|
||||
tryAddTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue(),
|
||||
node.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER));
|
||||
tryAddTag(OSMSettings.OSMTagKey.PHONE.getValue(),
|
||||
editPoiData.amenity.getPhone());
|
||||
tryAddTag(OSMSettings.OSMTagKey.WEBSITE.getValue(),
|
||||
editPoiData.amenity.getSite());
|
||||
for (String tag : node.getTagKeySet()) {
|
||||
tryAddTag(tag, node.getTag(tag));
|
||||
}
|
||||
String subType = editPoiData.amenity.getSubType();
|
||||
String key;
|
||||
String value;
|
||||
if (allTranslatedSubTypes.get(subType) != null) {
|
||||
PoiType pt = allTranslatedSubTypes.get(subType);
|
||||
key = pt.getOsmTag();
|
||||
value = pt.getOsmValue();
|
||||
} else {
|
||||
key = editPoiData.amenity.getType().getDefaultTag();
|
||||
value = subType;
|
||||
}
|
||||
final Tag tag = new Tag(key, value);
|
||||
editPoiData.tags.remove(tag);
|
||||
tag.tag = POI_TYPE_TAG;
|
||||
editPoiData.tags.add(tag);
|
||||
}
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_edit_poi, container, false);
|
||||
|
@ -193,6 +221,7 @@ public class EditPoiFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
});
|
||||
poiNameEditText.setText(node.getTag(OSMSettings.OSMTagKey.NAME));
|
||||
poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout);
|
||||
poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText);
|
||||
poiTypeEditText.addTextChangedListener(new TextWatcher() {
|
||||
|
@ -305,6 +334,12 @@ public class EditPoiFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
private void tryAddTag(String key, String value) {
|
||||
if (!Algorithms.isEmpty(value)) {
|
||||
editPoiData.tags.add(new Tag(key, value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putSerializable(TAGS_LIST, editPoiData.tags);
|
||||
|
@ -412,8 +447,9 @@ public class EditPoiFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
|
||||
public static void showEditInstance(final Amenity amenity, OsmandSettings settings,
|
||||
public static void showEditInstance(final Amenity amenity,
|
||||
final MapActivity mapActivity) {
|
||||
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||
final OpenstreetmapUtil openstreetmapUtilToLoad;
|
||||
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
|
@ -427,15 +463,16 @@ public class EditPoiFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
protected Node doInBackground(Void... params) {
|
||||
return openstreetmapUtilToLoad.loadNode((Amenity) amenity);
|
||||
return openstreetmapUtilToLoad.loadNode(amenity);
|
||||
}
|
||||
|
||||
protected void onPostExecute(Node n) {
|
||||
if (n != null) {
|
||||
EditPoiFragment fragment =
|
||||
EditPoiFragment.createInstance(n, (Amenity) amenity);
|
||||
EditPoiFragment.createInstance(n, amenity);
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
.add(fragment, "EditPoiFragment").commit();
|
||||
.add(R.id.fragmentContainer, fragment, "EditPoiFragment")
|
||||
.addToBackStack(null).commit();
|
||||
} else {
|
||||
AccessibleToast.makeText(mapActivity,
|
||||
mapActivity.getString(R.string.poi_error_poi_not_found),
|
||||
|
|
|
@ -139,9 +139,9 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
|||
} else {
|
||||
AccessibleToast.makeText(activity, activity.getString(R.string.poi_error_poi_not_found), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}.execute(new Void[0]);
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void showCreateDialog(double latitude, double longitude){
|
||||
|
|
|
@ -28,7 +28,6 @@ import net.osmand.plus.activities.EnumAdapter;
|
|||
import net.osmand.plus.activities.EnumAdapter.IEnumWithResource;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TabActivity;
|
||||
import net.osmand.plus.dashboard.DashPluginsFragment;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.myplaces.AvailableGPXFragment;
|
||||
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
|
||||
|
@ -171,13 +170,11 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
osmBugsLayer.openBug(latitude, longitude);
|
||||
} else if (resId == R.string.poi_context_menu_delete) {
|
||||
LOG.debug("delete poi");
|
||||
// new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity)
|
||||
// .execute((Amenity) selectedObj);
|
||||
// TODO implement delete
|
||||
getPoiActions(mapActivity).showDeleteDialog((Amenity) selectedObj);
|
||||
new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity)
|
||||
.execute((Amenity) selectedObj);
|
||||
} else if (resId == R.string.poi_context_menu_modify) {
|
||||
// TODO implement edit
|
||||
getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj);
|
||||
LOG.debug("edit poi");
|
||||
EditPoiFragment.showEditInstance((Amenity) selectedObj, mapActivity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ public class Tag implements Serializable {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Tag tag1 = (Tag) o;
|
||||
LOG.debug("this=" + this + "; that=" + tag1);
|
||||
return tag.equals(tag1.tag);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue