diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index 09825b31df..63b40471a6 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -27,7 +27,7 @@ import android.provider.Settings; public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlServices { private OsmandApplication app; - public static final String ID = "osmand.osmodroid.v2"; + public static final String ID = "osmand.osmo"; private static final Log log = PlatformUtil.getLog(OsMoPlugin.class); private OsMoService service; @@ -68,10 +68,9 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer } @Override - public void addMonitorActions(ContextMenuAdapter qa, MonitoringInfoControl li, OsmandMapTileView view) { + public void addMonitorActions(ContextMenuAdapter qa, MonitoringInfoControl li, final OsmandMapTileView view) { final boolean off = service.isActive(); - qa.item(off ? R.string.osmodroid_mode_off : R.string.osmodroid_mode_on -) + qa.item(off ? R.string.osmodroid_mode_off : R.string.osmodroid_mode_on) .icon(off ? R.drawable.monitoring_rec_inactive : R.drawable.monitoring_rec_big) .listen(new OnContextMenuClick() { @@ -92,6 +91,21 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer }).reg(); + qa.item("Test (send)"). + icons(R.drawable.ic_action_grefresh_dark, R.drawable.ic_action_grefresh_light). listen(new OnContextMenuClick() { + + @Override + public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) { + try { + String response = service.sendCoordinate(view.getLatitude(), view.getLongitude(), 0, 0, 0, 0); + app.showToastMessage(response); + } catch (Exception e) { + app.showToastMessage(app.getString(R.string.error_io_error) + ": " + e.getMessage()); + } + } + + + }).reg(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java index f9f401fb68..e7bc9bc82b 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java @@ -8,7 +8,7 @@ import java.net.URL; import java.net.URLConnection; public class OsMoService { - private static String TRACKER_URL = "ws://srv.osmo.mobi"; + private static String TRACKER_URL = "ws://srv.osmo.mobi:4242"; private URLConnection conn; private OutputStreamWriter out; private BufferedReader in; @@ -37,8 +37,8 @@ public class OsMoService { return in.readLine(); } - public void sendCoordinate(double lat, double lon, float hdop, float alt, float speed, float bearing) throws IOException { - sendCommand("p|"+lat+":"+lon+":"+hdop+":"+alt+":"+speed+":"+bearing); + public String sendCoordinate(double lat, double lon, float hdop, float alt, float speed, float bearing) throws IOException { + return sendCommand("p|"+lat+":"+lon+":"+hdop+":"+alt+":"+speed+":"+bearing); } public String deactivate() throws IOException {