Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-03-16 15:00:50 +01:00
commit f61360f850
3 changed files with 298 additions and 79 deletions

View file

@ -197,6 +197,14 @@ public class MapMarkersHelper {
return mapMarkers; return mapMarkers;
} }
public MapMarker getFirstMapMarker() {
if (mapMarkers.size() > 0) {
return mapMarkers.get(0);
} else {
return null;
}
}
public List<MapMarker> getSortedMapMarkers() { public List<MapMarker> getSortedMapMarkers() {
return sortedMapMarkers; return sortedMapMarkers;
} }

View file

@ -544,6 +544,8 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
readLocationToShow(); readLocationToShow();
OsmandPlugin.onMapActivityResume(this);
final Intent intent = getIntent(); final Intent intent = getIntent();
if (intent != null) { if (intent != null) {
if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (Intent.ACTION_VIEW.equals(intent.getAction())) {
@ -578,7 +580,6 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
app.getResourceManager().setBusyIndicator(new BusyIndicator(this, progress)); app.getResourceManager().setBusyIndicator(new BusyIndicator(this, progress));
} }
OsmandPlugin.onMapActivityResume(this);
mapView.refreshMap(true); mapView.refreshMap(true);
if (atlasMapRendererView != null) { if (atlasMapRendererView != null) {
atlasMapRendererView.handleOnResume(); atlasMapRendererView.handleOnResume();

View file

@ -5,17 +5,24 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -27,37 +34,65 @@ public class ExternalApiHelper {
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(ExternalApiHelper.class); private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(ExternalApiHelper.class);
private static final String API_CMD_SHOW_GPX = "show_gpx"; public static final String API_CMD_SHOW_GPX = "show_gpx";
private static final String API_CMD_NAVIGATE_GPX = "navigate_gpx"; public static final String API_CMD_NAVIGATE_GPX = "navigate_gpx";
private static final String API_CMD_CALC_ROUTE = "calc_route"; public static final String API_CMD_NAVIGATE = "navigate";
private static final String API_CMD_REC_AV_NOTE = "rec_av_note";
private static final String API_CMD_GET_INFO = "get_info";
private static final String API_CMD_ADD_FAVORITE = "add_favorite"; public static final String API_CMD_RECORD_AUDIO = "record_audio";
private static final String API_CMD_ADD_MAP_MARKER = "add_map_marker"; public static final String API_CMD_RECORD_VIDEO = "record_video";
public static final String API_CMD_RECORD_PHOTO = "record_photo";
public static final String API_CMD_STOP_AV_REC = "stop_av_rec";
private static final String API_CMD_START_GPX_REC = "start_gpx_rec"; public static final String API_CMD_GET_INFO = "get_info";
private static final String API_CMD_STOP_GPX_REC = "stop_gpx_rec";
private static final String API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS = "subscribe_voice_notifications"; public static final String API_CMD_ADD_FAVORITE = "add_favorite";
public static final String API_CMD_ADD_MAP_MARKER = "add_map_marker";
private static final String PARAM_NAME = "name"; public static final String API_CMD_START_GPX_REC = "start_gpx_rec";
private static final String PARAM_DESC = "desc"; public static final String API_CMD_STOP_GPX_REC = "stop_gpx_rec";
private static final String PARAM_CATEGORY = "category";
private static final String PARAM_LAT = "lat";
private static final String PARAM_LON = "lon";
private static final String PARAM_COLOR = "color";
private static final String PARAM_VISIBLE = "visible";
private static final String PARAM_PATH = "path"; public static final String API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS = "subscribe_voice_notifications";
private static final String PARAM_DATA = "data";
public static final String PARAM_NAME = "name";
public static final String PARAM_DESC = "desc";
public static final String PARAM_CATEGORY = "category";
public static final String PARAM_LAT = "lat";
public static final String PARAM_LON = "lon";
public static final String PARAM_COLOR = "color";
public static final String PARAM_VISIBLE = "visible";
public static final String PARAM_PATH = "path";
public static final String PARAM_DATA = "data";
public static final String PARAM_FORCE = "force";
public static final String PARAM_START_NAME = "start_name";
public static final String PARAM_DEST_NAME = "dest_name";
public static final String PARAM_START_LAT = "start_lat";
public static final String PARAM_START_LON = "start_lon";
public static final String PARAM_DEST_LAT = "dest_lat";
public static final String PARAM_DEST_LON = "dest_lon";
public static final String PARAM_PROFILE = "profile";
public static final String PARAM_ETA = "eta";
public static final String PARAM_TIME_LEFT = "time_left";
public static final String PARAM_DISTANCE_LEFT = "time_distance_left";
public static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[]{
ApplicationMode.CAR,
ApplicationMode.BICYCLE,
ApplicationMode.PEDESTRIAN
};
public static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR;
private static final int RESULT_CODE_OK = 0; public static final int RESULT_CODE_OK = 0;
private static final int RESULT_CODE_ERROR_UNKNOWN = -1; public static final int RESULT_CODE_ERROR_UNKNOWN = -1;
private static final int RESULT_CODE_ERROR_GPX_PLUGIN_INACTIVE = 10; public static final int RESULT_CODE_ERROR_NOT_IMPLEMENTED = -2;
private static final int RESULT_CODE_ERROR_GPX_NOT_FOUND = 20; public static final int RESULT_CODE_ERROR_PLUGIN_INACTIVE = 10;
public static final int RESULT_CODE_ERROR_GPX_NOT_FOUND = 20;
public static final int RESULT_CODE_ERROR_INVALID_PROFILE = 30;
private MapActivity mapActivity; private MapActivity mapActivity;
private int resultCode; private int resultCode;
@ -81,49 +116,13 @@ public class ExternalApiHelper {
OsmandApplication app = (OsmandApplication) mapActivity.getApplication(); OsmandApplication app = (OsmandApplication) mapActivity.getApplication();
try { try {
/*
+ 1. Intent to show GPX file / start navigation with GPX
2. Intent to calculate route between points (passing profile mode) and immediately start navigation
3. Intent to request audio/video recording
4. Intent (with result?) Current location, ETA, distance to go, time to go on the route
+ 5. Intent to add Favorites / Markers
+ 6. Intent to start/stop recording GPX
Service:
8. Subscribe to voice notifications
// test marker
Uri uri = Uri.parse("osmand.api://add_map_marker?lat=45.610677&lon=34.368430&name=Marker");
// test favorite
Uri uri = Uri.parse("osmand.api://add_favorite?lat=45.610677&lon=34.368430&name=Favorite&desc=Description&category=test2&color=red&visible=true");
// test start gpx recording
Uri uri = Uri.parse("osmand.api://start_gpx_rec");
// test stop gpx recording
Uri uri = Uri.parse("osmand.api://stop_gpx_rec");
// test show gpx (path)
File gpx = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), "xxx.gpx");
Uri uri = Uri.parse("osmand.api://show_gpx?path=" + URLEncoder.encode(gpx.getAbsolutePath(), "UTF-8"));
Uri uri = Uri.parse("osmand.api://navigate_gpx?path=" + URLEncoder.encode(gpx.getAbsolutePath(), "UTF-8"));
// test show gpx (data)
Uri uri = Uri.parse("osmand.api://show_gpx");
Uri uri = Uri.parse("osmand.api://navigate_gpx");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra("data", AndroidUtils.getFileAsString(
new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), "xxx.gpx")));
*/
Uri uri = intent.getData(); Uri uri = intent.getData();
String cmd = uri.getHost().toLowerCase(); String cmd = uri.getHost().toLowerCase();
if (API_CMD_SHOW_GPX.equals(cmd) || API_CMD_NAVIGATE_GPX.equals(cmd)) { if (API_CMD_SHOW_GPX.equals(cmd) || API_CMD_NAVIGATE_GPX.equals(cmd)) {
boolean navigate = API_CMD_NAVIGATE_GPX.equals(cmd); boolean navigate = API_CMD_NAVIGATE_GPX.equals(cmd);
String path = uri.getQueryParameter(PARAM_PATH); String path = uri.getQueryParameter(PARAM_PATH);
boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false);
GPXFile gpx = null; GPXFile gpx = null;
if (path != null) { if (path != null) {
File f = new File(path); File f = new File(path);
@ -142,7 +141,7 @@ public class ExternalApiHelper {
if (gpx != null) { if (gpx != null) {
if (navigate) { if (navigate) {
final RoutingHelper routingHelper = app.getRoutingHelper(); final RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isFollowingMode()) { if (routingHelper.isFollowingMode() && !force) {
final GPXFile gpxFile = gpx; final GPXFile gpxFile = gpx;
AlertDialog dlg = mapActivity.getMapActions().stopNavigationActionConfirm(); AlertDialog dlg = mapActivity.getMapActions().stopNavigationActionConfirm();
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
@ -150,12 +149,12 @@ public class ExternalApiHelper {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) { if (!routingHelper.isFollowingMode()) {
startNavigation(gpxFile); startNavigation(gpxFile, null, null, null, null, null);
} }
} }
}); });
} else { } else {
startNavigation(gpx); startNavigation(gpx, null, null, null, null, null);
} }
} else { } else {
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
@ -165,12 +164,109 @@ public class ExternalApiHelper {
resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND; resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND;
} }
} else if (API_CMD_CALC_ROUTE.equals(cmd)) { } else if (API_CMD_NAVIGATE.equals(cmd)) {
String profileStr = uri.getQueryParameter(PARAM_PROFILE);
final ApplicationMode profile = ApplicationMode.valueOfStringKey(profileStr, DEFAULT_PROFILE);
boolean validProfile = false;
for (ApplicationMode mode : VALID_PROFILES) {
if (mode == profile) {
validProfile = true;
break;
}
}
if (!validProfile) {
resultCode = RESULT_CODE_ERROR_INVALID_PROFILE;
} else {
String startName = uri.getQueryParameter(PARAM_START_NAME);
if (Algorithms.isEmpty(startName)) {
startName = "";
}
String destName = uri.getQueryParameter(PARAM_DEST_NAME);
if (Algorithms.isEmpty(destName)) {
destName = "";
}
} else if (API_CMD_REC_AV_NOTE.equals(cmd)) {
final LatLon start;
final PointDescription startDesc;
String startLatStr = uri.getQueryParameter(PARAM_START_LAT);
String startLonStr = uri.getQueryParameter(PARAM_START_LON);
if (!Algorithms.isEmpty(startLatStr) && !Algorithms.isEmpty(startLonStr)) {
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_START_LAT));
double lon = Double.parseDouble(uri.getQueryParameter(PARAM_START_LON));
start = new LatLon(lat, lon);
startDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, startName);
} else {
start = null;
startDesc = null;
}
double destLat = Double.parseDouble(uri.getQueryParameter(PARAM_DEST_LAT));
double destLon = Double.parseDouble(uri.getQueryParameter(PARAM_DEST_LON));
final LatLon dest = new LatLon(destLat, destLon);
final PointDescription destDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, destName);
boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false);
final RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isFollowingMode() && !force) {
AlertDialog dlg = mapActivity.getMapActions().stopNavigationActionConfirm();
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) {
startNavigation(null, start, startDesc, dest, destDesc, profile);
}
}
});
} else {
startNavigation(null, start, startDesc, dest, destDesc, profile);
}
}
} else if (API_CMD_RECORD_AUDIO.equals(cmd)
|| API_CMD_RECORD_VIDEO.equals(cmd)
|| API_CMD_RECORD_PHOTO.equals(cmd)
|| API_CMD_STOP_AV_REC.equals(cmd)) {
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
if (plugin == null) {
resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;
} else {
if (API_CMD_STOP_AV_REC.equals(cmd)) {
plugin.stopRecording(mapActivity, false);
} else {
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT));
double lon = Double.parseDouble(uri.getQueryParameter(PARAM_LON));
if (API_CMD_RECORD_AUDIO.equals(cmd)) {
plugin.recordAudio(lat, lon, mapActivity);
} else if (API_CMD_RECORD_VIDEO.equals(cmd)) {
plugin.recordVideo(lat, lon, mapActivity);
} else if (API_CMD_RECORD_PHOTO.equals(cmd)) {
plugin.takePhoto(lat, lon, mapActivity);
}
}
resultCode = RESULT_CODE_OK;
}
} else if (API_CMD_GET_INFO.equals(cmd)) { } else if (API_CMD_GET_INFO.equals(cmd)) {
Location location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
if (location != null) {
result.putExtra(PARAM_LAT, location.getLatitude());
result.putExtra(PARAM_LON, location.getLongitude());
}
final RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isFollowingMode()) {
int time = routingHelper.getLeftTime();
result.putExtra(PARAM_TIME_LEFT, time);
long eta = time + System.currentTimeMillis() / 1000;
result.putExtra(PARAM_ETA, eta);
result.putExtra(PARAM_DISTANCE_LEFT, routingHelper.getLeftDistance());
}
finish = true; finish = true;
resultCode = RESULT_CODE_OK; resultCode = RESULT_CODE_OK;
@ -181,7 +277,7 @@ public class ExternalApiHelper {
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT)); double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT));
double lon = Double.parseDouble(uri.getQueryParameter(PARAM_LON)); double lon = Double.parseDouble(uri.getQueryParameter(PARAM_LON));
String colorTag = uri.getQueryParameter(PARAM_COLOR); String colorTag = uri.getQueryParameter(PARAM_COLOR);
String visibleStr = uri.getQueryParameter(PARAM_VISIBLE); boolean visible = uri.getBooleanQueryParameter(PARAM_VISIBLE, true);
if (name == null) { if (name == null) {
name = ""; name = "";
@ -201,11 +297,6 @@ public class ExternalApiHelper {
} }
} }
boolean visible = true;
if (!Algorithms.isEmpty(visibleStr)) {
visible = Boolean.parseBoolean(visibleStr);
}
FavouritePoint fav = new FavouritePoint(lat, lon, name, category); FavouritePoint fav = new FavouritePoint(lat, lon, name, category);
fav.setDescription(desc); fav.setDescription(desc);
fav.setColor(color); fav.setColor(color);
@ -214,6 +305,9 @@ public class ExternalApiHelper {
FavouritesDbHelper helper = app.getFavorites(); FavouritesDbHelper helper = app.getFavorites();
helper.addFavourite(fav); helper.addFavourite(fav);
mapActivity.getContextMenu().show(new LatLon(lat, lon),
mapActivity.getMapLayers().getFavoritesLayer().getObjectName(fav), fav);
resultCode = RESULT_CODE_OK; resultCode = RESULT_CODE_OK;
} else if (API_CMD_ADD_MAP_MARKER.equals(cmd)) { } else if (API_CMD_ADD_MAP_MARKER.equals(cmd)) {
@ -227,12 +321,18 @@ public class ExternalApiHelper {
MapMarkersHelper markersHelper = app.getMapMarkersHelper(); MapMarkersHelper markersHelper = app.getMapMarkersHelper();
markersHelper.addMapMarker(new LatLon(lat, lon), pd); markersHelper.addMapMarker(new LatLon(lat, lon), pd);
MapMarker marker = markersHelper.getFirstMapMarker();
if (marker != null) {
mapActivity.getContextMenu().show(new LatLon(lat, lon),
mapActivity.getMapLayers().getMapMarkersLayer().getObjectName(marker), marker);
}
resultCode = RESULT_CODE_OK; resultCode = RESULT_CODE_OK;
} else if (API_CMD_START_GPX_REC.equals(cmd)) { } else if (API_CMD_START_GPX_REC.equals(cmd)) {
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
if (plugin == null) { if (plugin == null) {
resultCode = RESULT_CODE_ERROR_GPX_PLUGIN_INACTIVE; resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;
} else { } else {
plugin.startGPXMonitoring(null); plugin.startGPXMonitoring(null);
} }
@ -242,7 +342,7 @@ public class ExternalApiHelper {
} else if (API_CMD_STOP_GPX_REC.equals(cmd)) { } else if (API_CMD_STOP_GPX_REC.equals(cmd)) {
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
if (plugin == null) { if (plugin == null) {
resultCode = RESULT_CODE_ERROR_GPX_PLUGIN_INACTIVE; resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;
} else { } else {
plugin.stopRecording(); plugin.stopRecording();
} }
@ -250,7 +350,8 @@ public class ExternalApiHelper {
resultCode = RESULT_CODE_OK; resultCode = RESULT_CODE_OK;
} else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) { } else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) {
// not implemented yet
resultCode = RESULT_CODE_ERROR_NOT_IMPLEMENTED;
} }
} catch (Exception e) { } catch (Exception e) {
@ -261,14 +362,25 @@ public class ExternalApiHelper {
return result; return result;
} }
private void startNavigation(GPXFile gpx) { private void startNavigation(GPXFile gpx,
LatLon from, PointDescription fromDesc,
LatLon to, PointDescription toDesc,
ApplicationMode mode) {
OsmandApplication app = mapActivity.getMyApplication(); OsmandApplication app = mapActivity.getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpx, null, null, false, false); if (gpx == null) {
app.getSettings().APPLICATION_MODE.set(mode);
final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
targets.removeAllWayPoints(false, true);
targets.navigateToPoint(to, true, -1, toDesc);
}
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpx, from, fromDesc, true, false);
if (!app.getTargetPointsHelper().checkPointToNavigateShort()) { if (!app.getTargetPointsHelper().checkPointToNavigateShort()) {
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().show(); mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().show();
} else { } else {
if (app.getSettings().APPLICATION_MODE.get() != routingHelper.getAppMode()) {
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode()); app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
}
mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
app.getSettings().FOLLOW_THE_ROUTE.set(true); app.getSettings().FOLLOW_THE_ROUTE.set(true);
routingHelper.setFollowingMode(true); routingHelper.setFollowingMode(true);
@ -278,4 +390,102 @@ public class ExternalApiHelper {
routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false); routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false);
} }
} }
public void testApi(OsmandApplication app, String command) {
Uri uri = null;
Intent intent = null;
String lat = "44.98062";
String lon = "34.09258";
String destLat = "44.97799";
String destLon = "34.10286";
String gpxName = "xxx.gpx";
try {
if (API_CMD_GET_INFO.equals(command)) {
uri = Uri.parse("osmand.api://get_info");
}
if (API_CMD_NAVIGATE.equals(command)) {
// test navigate
uri = Uri.parse("osmand.api://navigate" +
"?start_lat=" + lat + "&start_lon=" + lon + "&start_name=Start" +
"&dest_lat=" + destLat + "&dest_lon=" + destLon + "&dest_name=Finish" +
"&profile=bicycle");
}
if (API_CMD_RECORD_AUDIO.equals(command)) {
// test record audio
uri = Uri.parse("osmand.api://record_audio?lat=" + lat + "&lon=" + lon);
}
if (API_CMD_RECORD_VIDEO.equals(command)) {
// test record video
uri = Uri.parse("osmand.api://record_video?lat=" + lat + "&lon=" + lon);
}
if (API_CMD_RECORD_PHOTO.equals(command)) {
// test take photo
uri = Uri.parse("osmand.api://record_photo?lat=" + lat + "&lon=" + lon);
}
if (API_CMD_STOP_AV_REC.equals(command)) {
// test record video
uri = Uri.parse("osmand.api://stop_av_rec");
}
if (API_CMD_ADD_MAP_MARKER.equals(command)) {
// test marker
uri = Uri.parse("osmand.api://add_map_marker?lat=" + lat + "&lon=" + lon + "&name=Marker");
}
if (API_CMD_ADD_FAVORITE.equals(command)) {
// test favorite
uri = Uri.parse("osmand.api://add_favorite?lat=" + lat + "&lon=" + lon + "&name=Favorite&desc=Description&category=test2&color=red&visible=true");
}
if (API_CMD_START_GPX_REC.equals(command)) {
// test start gpx recording
uri = Uri.parse("osmand.api://start_gpx_rec");
}
if (API_CMD_STOP_GPX_REC.equals(command)) {
// test stop gpx recording
uri = Uri.parse("osmand.api://stop_gpx_rec");
}
if (API_CMD_SHOW_GPX.equals(command)) {
// test show gpx (path)
//File gpx = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxName);
//uri = Uri.parse("osmand.api://show_gpx?path=" + URLEncoder.encode(gpx.getAbsolutePath(), "UTF-8"));
// test show gpx (data)
uri = Uri.parse("osmand.api://show_gpx");
intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra("data", AndroidUtils.getFileAsString(
new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxName)));
}
if (API_CMD_NAVIGATE_GPX.equals(command)) {
// test navigate gpx (path)
//File gpx = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxName);
//uri = Uri.parse("osmand.api://navigate_gpx?force=true&path=" + URLEncoder.encode(gpx.getAbsolutePath(), "UTF-8"));
// test navigate gpx (data)
uri = Uri.parse("osmand.api://navigate_gpx?force=true");
intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra("data", AndroidUtils.getFileAsString(
new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxName)));
}
if (intent == null && uri != null) {
intent = new Intent(Intent.ACTION_VIEW, uri);
}
if (intent != null) {
mapActivity.startActivity(intent);
}
} catch (Exception e) {
LOG.error("Test failed", e);
}
}
} }