Wpt context menu fixes
This commit is contained in:
parent
ba1c7848bc
commit
308cdae795
3 changed files with 43 additions and 23 deletions
|
@ -203,6 +203,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
||||||
originalGPX = null;
|
originalGPX = null;
|
||||||
measurementPoints.clear();
|
measurementPoints.clear();
|
||||||
calculateDistance();
|
calculateDistance();
|
||||||
|
activity.getContextMenu().close();
|
||||||
} else if (id == R.string.shared_string_save_as_gpx) {
|
} else if (id == R.string.shared_string_save_as_gpx) {
|
||||||
saveGpx(activity);
|
saveGpx(activity);
|
||||||
} else if (id == R.string.distance_measurement_load_gpx) {
|
} else if (id == R.string.distance_measurement_load_gpx) {
|
||||||
|
@ -637,6 +638,17 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
||||||
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
|
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
|
||||||
if(o instanceof WptPt) {
|
if(o instanceof WptPt) {
|
||||||
final WptPt p = (WptPt) o;
|
final WptPt p = (WptPt) o;
|
||||||
|
boolean containsPoint = false;
|
||||||
|
for (int i = 0; i < measurementPoints.size(); i++) {
|
||||||
|
Iterator<WptPt> it = measurementPoints.get(i).iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if (it.next() == p) {
|
||||||
|
containsPoint = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (containsPoint) {
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -651,6 +663,9 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
calculateDistance();
|
calculateDistance();
|
||||||
|
if (adapter.getContext() instanceof MapActivity) {
|
||||||
|
((MapActivity)adapter.getContext()).getContextMenu().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -658,6 +673,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
||||||
adapter.item(R.string.delete_point).iconColor(R.drawable.ic_action_delete_dark).listen(listener).reg();
|
adapter.item(R.string.delete_point).iconColor(R.drawable.ic_action_delete_dark).listen(listener).reg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getObjectDescription(Object o) {
|
public String getObjectDescription(Object o) {
|
||||||
|
|
|
@ -246,6 +246,7 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
if (active) {
|
||||||
active = false;
|
active = false;
|
||||||
if (this.object != null) {
|
if (this.object != null) {
|
||||||
clearSelectedObject(this.object);
|
clearSelectedObject(this.object);
|
||||||
|
@ -253,6 +254,7 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
hide();
|
hide();
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void hide() {
|
public void hide() {
|
||||||
if (mapPosition != 0) {
|
if (mapPosition != 0) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import net.osmand.ValueHolder;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||||
import net.osmand.plus.GPXUtilities;
|
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.NavigationService;
|
import net.osmand.plus.NavigationService;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
@ -144,10 +143,13 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
adapter.item(R.string.context_menu_item_add_waypoint).iconColor(R.drawable.ic_action_gnew_label_dark)
|
adapter.item(R.string.context_menu_item_add_waypoint).iconColor(R.drawable.ic_action_gnew_label_dark)
|
||||||
.listen(listener).reg();
|
.listen(listener).reg();
|
||||||
if (selectedObj instanceof WptPt) {
|
if (selectedObj instanceof WptPt) {
|
||||||
|
WptPt pt = (WptPt) selectedObj;
|
||||||
|
if (app.getSelectedGpxHelper().getSelectedGPXFile(pt) != null) {
|
||||||
adapter.item(R.string.context_menu_item_edit_waypoint).iconColor(R.drawable.ic_action_edit_dark)
|
adapter.item(R.string.context_menu_item_edit_waypoint).iconColor(R.drawable.ic_action_edit_dark)
|
||||||
.listen(listener).reg();
|
.listen(listener).reg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final int[] SECONDS = new int[] {0, 1, 2, 3, 5, 10, 15, 30, 60, 90};
|
public static final int[] SECONDS = new int[] {0, 1, 2, 3, 5, 10, 15, 30, 60, 90};
|
||||||
public static final int[] MINUTES = new int[] {2, 3, 5};
|
public static final int[] MINUTES = new int[] {2, 3, 5};
|
||||||
|
|
Loading…
Reference in a new issue