Fix osmo plugin
This commit is contained in:
parent
02774b1c1f
commit
1deeef93c9
2 changed files with 21 additions and 7 deletions
|
@ -27,7 +27,7 @@ import android.provider.Settings;
|
||||||
public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlServices {
|
public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlServices {
|
||||||
|
|
||||||
private OsmandApplication app;
|
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 static final Log log = PlatformUtil.getLog(OsMoPlugin.class);
|
||||||
private OsMoService service;
|
private OsMoService service;
|
||||||
|
|
||||||
|
@ -68,10 +68,9 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
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)
|
.icon(off ? R.drawable.monitoring_rec_inactive : R.drawable.monitoring_rec_big)
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
|
|
||||||
|
@ -92,6 +91,21 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
||||||
|
|
||||||
|
|
||||||
}).reg();
|
}).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
|
@Override
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
public class OsMoService {
|
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 URLConnection conn;
|
||||||
private OutputStreamWriter out;
|
private OutputStreamWriter out;
|
||||||
private BufferedReader in;
|
private BufferedReader in;
|
||||||
|
@ -37,8 +37,8 @@ public class OsMoService {
|
||||||
return in.readLine();
|
return in.readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendCoordinate(double lat, double lon, float hdop, float alt, float speed, float bearing) throws IOException {
|
public String sendCoordinate(double lat, double lon, float hdop, float alt, float speed, float bearing) throws IOException {
|
||||||
sendCommand("p|"+lat+":"+lon+":"+hdop+":"+alt+":"+speed+":"+bearing);
|
return sendCommand("p|"+lat+":"+lon+":"+hdop+":"+alt+":"+speed+":"+bearing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String deactivate() throws IOException {
|
public String deactivate() throws IOException {
|
||||||
|
|
Loading…
Reference in a new issue