Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8f38cb94ad
12 changed files with 271 additions and 40 deletions
|
@ -106,6 +106,7 @@
|
|||
<activity android:name="net.osmand.plus.activities.SettingsNavigationActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.monitoring.SettingsMonitoringActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.rastermaps.SettingsRasterMapsActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.osmo.SettingsOsMoActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.osmedit.SettingsOsmEditingActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.development.SettingsDevelopmentActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.audionotes.SettingsAudioVideoActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="osmo_settings_uuid">Unique device id</string>
|
||||
<string name="osmo_settings_descr">View unique device registration key and other monitoring specific settings </string>
|
||||
<string name="osmo_settings">OSMo (OpenStreetMap-Monitoring)</string>
|
||||
<string name="osmo_plugin_description">OpenStreetMap-Monitoring - Advanced Live Monitoring with lots of features for remote control http://osmo.mobi</string>
|
||||
<string name="osmo_plugin_name">OSMo (Advanced Live Monitoring)</string>
|
||||
<string name="osmo_settings">OSMo settings</string>
|
||||
<string name="always_center_position_on_map">Display position always in center</string>
|
||||
<string name="voice_pref_title">Voice</string>
|
||||
<string name="misc_pref_title">Miscallenious</string>
|
||||
|
|
|
@ -705,7 +705,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
scheduleCheckIfGpsLost(location);
|
||||
}
|
||||
app.getSavingTrackHelper().updateLocation(location);
|
||||
app.getLiveMonitoringHelper().updateLocation(location);
|
||||
OsmandPlugin.updateLocationPlugins(location);
|
||||
// 2. accessibility routing
|
||||
navigationInfo.setLocation(location);
|
||||
|
||||
|
@ -736,7 +736,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
// 1. Logging services
|
||||
if (location != null) {
|
||||
app.getSavingTrackHelper().updateLocation(location);
|
||||
app.getLiveMonitoringHelper().updateLocation(location);
|
||||
OsmandPlugin.updateLocationPlugins(location);
|
||||
}
|
||||
// 2. accessibility routing
|
||||
navigationInfo.setLocation(location);
|
||||
|
|
|
@ -22,11 +22,11 @@ import net.osmand.plus.GPXUtilities.GPXFile;
|
|||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.access.AccessibilityMode;
|
||||
import net.osmand.plus.activities.DayNightHelper;
|
||||
import net.osmand.plus.activities.LiveMonitoringHelper;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.api.SQLiteAPI;
|
||||
import net.osmand.plus.api.SQLiteAPIImpl;
|
||||
import net.osmand.plus.monitoring.LiveMonitoringHelper;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.preference.PreferenceScreen;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibilityPlugin;
|
||||
import net.osmand.plus.activities.LocalIndexInfo;
|
||||
|
@ -17,6 +18,7 @@ import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
|||
import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmo.OsMoPlugin;
|
||||
import net.osmand.plus.osmodroid.OsMoDroidPlugin;
|
||||
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
|
@ -75,6 +77,7 @@ public abstract class OsmandPlugin {
|
|||
installedPlugins.add(new DistanceCalculatorPlugin(app));
|
||||
installedPlugins.add(new AudioVideoNotesPlugin(app));
|
||||
installedPlugins.add(new OsmEditingPlugin(app));
|
||||
installedPlugins.add(new OsMoPlugin(app));
|
||||
installedPlugins.add(new OsmandDevelopmentPlugin(app));
|
||||
|
||||
|
||||
|
@ -130,7 +133,9 @@ public abstract class OsmandPlugin {
|
|||
|
||||
public void registerOptionsMenuItems(MapActivity mapActivity, ContextMenuAdapter helper) {}
|
||||
|
||||
public void loadLocalIndexes(List<LocalIndexInfo> result, LoadLocalIndexTask loadTask) {};
|
||||
public void loadLocalIndexes(List<LocalIndexInfo> result, LoadLocalIndexTask loadTask) {}
|
||||
|
||||
public void updateLocation(Location location) {}
|
||||
|
||||
public void contextMenuLocalIndexes(LocalIndexesActivity la, LocalIndexInfo info, ContextMenuAdapter adapter) {};
|
||||
|
||||
|
@ -300,5 +305,11 @@ public abstract class OsmandPlugin {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void updateLocationPlugins(net.osmand.Location location) {
|
||||
for(OsmandPlugin p : installedPlugins){
|
||||
p.updateLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.activities;
|
||||
package net.osmand.plus.monitoring;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
|
@ -13,7 +13,6 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.http.HttpResponse;
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
|
@ -36,11 +37,18 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
|
|||
private OsmandSettings settings;
|
||||
private OsmandApplication app;
|
||||
private BaseMapWidget monitoringControl;
|
||||
private LiveMonitoringHelper liveMonitoringHelper;
|
||||
|
||||
public OsmandMonitoringPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
liveMonitoringHelper = new LiveMonitoringHelper(app);
|
||||
ApplicationMode.regWidget("monitoring", (ApplicationMode[])null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
liveMonitoringHelper.updateLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(OsmandApplication app) {
|
||||
|
|
118
OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java
Normal file
118
OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java
Normal file
|
@ -0,0 +1,118 @@
|
|||
package net.osmand.plus.osmo;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.views.MonitoringInfoControl;
|
||||
import net.osmand.plus.views.MonitoringInfoControl.MonitoringInfoControlServices;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
|
||||
public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlServices {
|
||||
|
||||
private OsmandApplication app;
|
||||
public static final String ID = "osmand.osmodroid.v2";
|
||||
private static final Log log = PlatformUtil.getLog(OsMoPlugin.class);
|
||||
private OsMoService service;
|
||||
|
||||
public OsMoPlugin(final OsmandApplication app){
|
||||
service = new OsMoService();
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(final OsmandApplication app) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
if(service.isActive()) {
|
||||
try {
|
||||
service.sendCoordinate(location.getLatitude(), location.getLongitude(), location.getAccuracy(),
|
||||
(float) location.getAltitude(), location.getSpeed(), location.getBearing());
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUUID(Context ctx) {
|
||||
return Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return app.getString(R.string.osmo_plugin_description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return app.getString(R.string.osmo_plugin_name) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMonitorActions(ContextMenuAdapter qa, MonitoringInfoControl li, OsmandMapTileView view) {
|
||||
final boolean off = service.isActive();
|
||||
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() {
|
||||
|
||||
@Override
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
try {
|
||||
String response;
|
||||
if (off) {
|
||||
response = service.activate(getUUID(app));
|
||||
} else {
|
||||
response = service.deactivate();
|
||||
}
|
||||
app.showToastMessage(response);
|
||||
} catch (Exception e) {
|
||||
app.showToastMessage(app.getString(R.string.error_io_error) + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}).reg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingsActivityCreate(final SettingsActivity activity, PreferenceScreen screen) {
|
||||
Preference grp = new Preference(activity);
|
||||
grp.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
activity.startActivity(new Intent(activity, SettingsOsMoActivity.class));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
grp.setSummary(R.string.osmo_settings_descr);
|
||||
grp.setTitle(R.string.osmo_settings);
|
||||
grp.setKey("osmo_settings");
|
||||
screen.addPreference(grp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
}
|
52
OsmAnd/src/net/osmand/plus/osmo/OsMoService.java
Normal file
52
OsmAnd/src/net/osmand/plus/osmo/OsMoService.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package net.osmand.plus.osmo;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public class OsMoService {
|
||||
private static String TRACKER_URL = "ws://srv.osmo.mobi";
|
||||
private URLConnection conn;
|
||||
private OutputStreamWriter out;
|
||||
private BufferedReader in;
|
||||
|
||||
public boolean isActive() {
|
||||
return conn != null;
|
||||
}
|
||||
|
||||
public String activate(String hash) throws IOException {
|
||||
URL tu = new URL(TRACKER_URL);
|
||||
conn = tu.openConnection();
|
||||
conn.connect();
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
||||
out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
|
||||
|
||||
String t = sendCommand("auth|"+hash);
|
||||
t += sendCommand("session_open");
|
||||
return t;
|
||||
}
|
||||
|
||||
private String sendCommand(String s) throws IOException {
|
||||
if(s.endsWith("\n")) {
|
||||
s += "\n";
|
||||
}
|
||||
out.write(s);
|
||||
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 deactivate() throws IOException {
|
||||
String t = sendCommand("session_close");
|
||||
in.close();
|
||||
out.close();
|
||||
conn = null;
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
38
OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java
Normal file
38
OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package net.osmand.plus.osmo;
|
||||
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
|
||||
public class SettingsOsMoActivity extends SettingsBaseActivity {
|
||||
|
||||
public static final String MORE_VALUE = "MORE_VALUE";
|
||||
public static final String DEFINE_EDIT = "DEFINE_EDIT";
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportActionBar().setTitle(R.string.online_map_settings);
|
||||
PreferenceScreen grp = getPreferenceScreen();
|
||||
|
||||
Preference pref = new Preference(this);
|
||||
pref.setTitle(R.string.osmo_settings_uuid);
|
||||
pref.setSummary(OsMoPlugin.getUUID(this));
|
||||
|
||||
grp.addPreference(pref);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void updateAllSettings() {
|
||||
super.updateAllSettings();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -161,12 +161,12 @@ public class OsMoDroidPlugin extends OsmandPlugin implements MonitoringInfoContr
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return app.getString(R.string.osmodroid_plugin_description);
|
||||
return app.getString(R.string.osmodroid_plugin_description) + "\n External application.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return app.getString(R.string.osmodroid_plugin_name);
|
||||
return app.getString(R.string.osmodroid_plugin_name) + " (external)";
|
||||
}
|
||||
|
||||
// test
|
||||
|
|
|
@ -1,42 +1,40 @@
|
|||
package net.osmand.plus.osmodroid;
|
||||
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
|
||||
public class OsMoDroidPoint {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if((o instanceof OsMoDroidPoint) && this.id == ((OsMoDroidPoint)o).id )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((o instanceof OsMoDroidPoint) && this.id == ((OsMoDroidPoint) o).id) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LatLon latlon;
|
||||
LatLon prevlatlon;
|
||||
String name;
|
||||
String description;
|
||||
int id;
|
||||
int layerId;
|
||||
String speed="";
|
||||
String color="AAAAAA";
|
||||
LatLon latlon;
|
||||
LatLon prevlatlon;
|
||||
String name;
|
||||
String description;
|
||||
int id;
|
||||
int layerId;
|
||||
String speed = "";
|
||||
String color = "AAAAAA";
|
||||
|
||||
public OsMoDroidPoint(float objectLat, float objectLon, String objectName, String objectDescription, int objectId, int layerId ,String speed, String color) {
|
||||
this.latlon=new LatLon(objectLat, objectLon);
|
||||
this.name=objectName;
|
||||
this.description=objectDescription;
|
||||
this.id=objectId;
|
||||
this.layerId=layerId;
|
||||
if(speed!=null){ this.speed=speed;}
|
||||
if(color!=null){ this.color=color;}
|
||||
}
|
||||
public OsMoDroidPoint(float objectLat, float objectLon, String objectName, String objectDescription, int objectId,
|
||||
int layerId, String speed, String color) {
|
||||
this.latlon = new LatLon(objectLat, objectLon);
|
||||
this.name = objectName;
|
||||
this.description = objectDescription;
|
||||
this.id = objectId;
|
||||
this.layerId = layerId;
|
||||
if (speed != null) {
|
||||
this.speed = speed;
|
||||
}
|
||||
if (color != null) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue