Update poi
This commit is contained in:
parent
0314ef16e6
commit
854c15d158
2 changed files with 61 additions and 39 deletions
|
@ -44,7 +44,7 @@ import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
|
@ -97,6 +97,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
private OpenstreetmapUtil mOpenstreetmapUtil;
|
private OpenstreetmapUtil mOpenstreetmapUtil;
|
||||||
private TextInputLayout poiTypeTextInputLayout;
|
private TextInputLayout poiTypeTextInputLayout;
|
||||||
|
private View view;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
|
@ -128,7 +129,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.fragment_edit_poi, container, false);
|
view = inflater.inflate(R.layout.fragment_edit_poi, container, false);
|
||||||
final OsmandSettings settings = getMyApplication().getSettings();
|
final OsmandSettings settings = getMyApplication().getSettings();
|
||||||
boolean isLightTheme = settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
boolean isLightTheme = settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||||
|
|
||||||
|
@ -327,27 +328,37 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
node.putTag(tag.getKey(), tag.getValue());
|
node.putTag(tag.getKey(), tag.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()),
|
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), "", false,
|
||||||
"",
|
new CallbackWithObject<Node>() {
|
||||||
false,
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public boolean processResult(Node result) {
|
||||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
if (result != null) {
|
||||||
if (plugin != null && offlineEdit) {
|
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
List<OpenstreetmapPoint> points = plugin.getDBPOI().getOpenstreetmapPoints();
|
if (plugin != null && offlineEdit) {
|
||||||
if (getActivity() instanceof MapActivity && points.size() > 0) {
|
List<OpenstreetmapPoint> points = plugin.getDBPOI().getOpenstreetmapPoints();
|
||||||
OsmPoint point = points.get(points.size() - 1);
|
if (getActivity() instanceof MapActivity && points.size() > 0) {
|
||||||
MapActivity mapActivity = (MapActivity) getActivity();
|
OsmPoint point = points.get(points.size() - 1);
|
||||||
mapActivity.getContextMenu().showOrUpdate(new LatLon(point.getLatitude(), point.getLongitude()),
|
MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
plugin.getOsmEditsLayer(mapActivity).getObjectName(point), point);
|
mapActivity.getContextMenu().showOrUpdate(
|
||||||
|
new LatLon(point.getLatitude(), point.getLongitude()),
|
||||||
|
plugin.getOsmEditsLayer(mapActivity).getObjectName(point), point);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getActivity() instanceof MapActivity) {
|
||||||
|
((MapActivity) getActivity()).getMapView().refreshMap(true);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
} else {
|
||||||
|
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
|
mOpenstreetmapUtil = plugin.getPoiModificationLocalUtil();
|
||||||
|
Button saveButton = (Button) view.findViewById(R.id.saveButton);
|
||||||
|
saveButton.setText(mOpenstreetmapUtil instanceof OpenstreetmapRemoteUtil
|
||||||
|
? R.string.shared_string_upload : R.string.shared_string_save);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getActivity() instanceof MapActivity) {
|
return false;
|
||||||
((MapActivity) getActivity()).getMapView().refreshMap(true);
|
|
||||||
}
|
|
||||||
dismiss();
|
|
||||||
}
|
}
|
||||||
}, getActivity(), mOpenstreetmapUtil);
|
}, getActivity(), mOpenstreetmapUtil);
|
||||||
}
|
}
|
||||||
|
@ -399,7 +410,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
final EntityInfo info,
|
final EntityInfo info,
|
||||||
final String comment,
|
final String comment,
|
||||||
final boolean closeChangeSet,
|
final boolean closeChangeSet,
|
||||||
final Runnable successAction,
|
final CallbackWithObject<Node> postExecute,
|
||||||
final Activity activity,
|
final Activity activity,
|
||||||
final OpenstreetmapUtil openstreetmapUtil) {
|
final OpenstreetmapUtil openstreetmapUtil) {
|
||||||
if (info == null && OsmPoint.Action.CREATE != action && openstreetmapUtil instanceof OpenstreetmapRemoteUtil) {
|
if (info == null && OsmPoint.Action.CREATE != action && openstreetmapUtil instanceof OpenstreetmapRemoteUtil) {
|
||||||
|
@ -423,8 +434,8 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Node result) {
|
protected void onPostExecute(Node result) {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
if (result != null) {
|
if(postExecute != null) {
|
||||||
successAction.run();
|
postExecute.processResult(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
|
@ -640,26 +651,37 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
String c = comment == null ? null : comment.getText().toString();
|
String c = comment == null ? null : comment.getText().toString();
|
||||||
boolean closeChangeSet = closeChangesetCheckBox != null
|
boolean closeChangeSet = closeChangesetCheckBox != null
|
||||||
&& closeChangesetCheckBox.isChecked();
|
&& closeChangesetCheckBox.isChecked();
|
||||||
commitNode(OsmPoint.Action.DELETE, n, openstreetmapUtil.getEntityInfo(n.getId()), c,
|
deleteNode(n, c, closeChangeSet);
|
||||||
closeChangeSet, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (isLocalEdit) {
|
|
||||||
AccessibleToast.makeText(
|
|
||||||
activity, R.string.osm_changes_added_to_local_edits,
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
} else {
|
|
||||||
AccessibleToast.makeText(activity, R.string.poi_remove_success, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
if (activity instanceof MapActivity) {
|
|
||||||
((MapActivity) activity).getMapView().refreshMap(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, activity, openstreetmapUtil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteNode(final Node n, final String c, final boolean closeChangeSet) {
|
||||||
|
final boolean isLocalEdit = openstreetmapUtil instanceof OpenstreetmapLocalUtil;
|
||||||
|
commitNode(OsmPoint.Action.DELETE, n, openstreetmapUtil.getEntityInfo(n.getId()), c, closeChangeSet,
|
||||||
|
new CallbackWithObject<Node>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean processResult(Node result) {
|
||||||
|
if (result != null) {
|
||||||
|
if (isLocalEdit) {
|
||||||
|
AccessibleToast.makeText(activity, R.string.osm_changes_added_to_local_edits,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
AccessibleToast.makeText(activity, R.string.poi_remove_success, Toast.LENGTH_LONG)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
if (activity instanceof MapActivity) {
|
||||||
|
((MapActivity) activity).getMapView().refreshMap(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, activity, openstreetmapUtil);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SaveWithAdvancedTagsDialogFragment extends DialogFragment {
|
public static class SaveWithAdvancedTagsDialogFragment extends DialogFragment {
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
public OsmBugsLocalUtil getOsmNotesLocalUtil() {
|
public OsmBugsLocalUtil getOsmNotesLocalUtil() {
|
||||||
if(localNotesUtil == null) {
|
if(localNotesUtil == null) {
|
||||||
localNotesUtil = new OsmBugsLocalUtil(app, dbbug);
|
localNotesUtil = new OsmBugsLocalUtil(app, getDBBug());
|
||||||
}
|
}
|
||||||
return localNotesUtil;
|
return localNotesUtil;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue