Add select on map
This commit is contained in:
parent
12ce326221
commit
031c399ba2
8 changed files with 58 additions and 30 deletions
|
@ -748,6 +748,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
// Update routing position and get location for sticking mode
|
||||
updatedLocation = routingHelper.setCurrentLocation(location, settings.SNAP_TO_ROAD.get());
|
||||
}
|
||||
} else if(routingHelper.isRoutePlanningMode() && settings.getPointToStart() == null) {
|
||||
routingHelper.setCurrentLocation(location, false);
|
||||
}
|
||||
this.location = updatedLocation;
|
||||
|
||||
|
|
|
@ -369,8 +369,10 @@ public class MapActivityActions implements DialogProvider {
|
|||
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
|
||||
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter;
|
||||
|
||||
adapter.item(R.string.context_menu_item_directions_to).icons(
|
||||
R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light).reg();
|
||||
if(!mapActivity.getRoutingHelper().isRoutePlanningMode()) {
|
||||
adapter.item(R.string.context_menu_item_directions_to).icons(
|
||||
R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light).reg();
|
||||
}
|
||||
final TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
|
||||
if(targets.getPointToNavigate() != null) {
|
||||
adapter.item(R.string.context_menu_item_destination_point).icons(R.drawable.ic_action_flag_dark,
|
||||
|
|
|
@ -198,7 +198,7 @@ public class RoutingHelper {
|
|||
}
|
||||
|
||||
public void updateLocation(Location currentLocation) {
|
||||
if(isFollowingMode()) {
|
||||
if(isFollowingMode() || (settings.getPointToStart() == null && isRoutePlanningMode)) {
|
||||
setCurrentLocation(currentLocation, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -45,6 +48,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private MapNavigateControl mapNavigationControl;
|
||||
private MapRoutePlanControl mapRoutePlanControl;
|
||||
private MapRoutePreferencesControl mapAppModeControl;
|
||||
private List<MapControls> allControls = new ArrayList<MapControls>();
|
||||
|
||||
private float scaleCoefficient;
|
||||
|
||||
|
@ -103,6 +107,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private <T extends MapControls> T init(T c, FrameLayout parent, int gravity) {
|
||||
c.init(parent);
|
||||
c.setGravity(gravity);
|
||||
allControls.add(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -188,14 +193,11 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
mapMenuControls.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS);
|
||||
mapRoutePlanControl.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS);
|
||||
}
|
||||
if(mapMenuControls.isVisible() && mapMenuControls.onSingleTap(point, tileBox)) {
|
||||
return true;
|
||||
}
|
||||
if(zoomControls.isVisible() ) {
|
||||
if(zoomControls.onSingleTap(point, tileBox)) {
|
||||
for(MapControls m : allControls) {
|
||||
if(m.isVisible() && m.onSingleTap(point, tileBox)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ public abstract class OsmandMapLayer {
|
|||
public boolean isUpdateVectorRendering() {
|
||||
return updateVectorRendering;
|
||||
}
|
||||
|
||||
public boolean isNightMode() {
|
||||
return nightMode;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ import android.widget.Toast;
|
|||
public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCallback, Callback {
|
||||
|
||||
private static final int MAP_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 4;
|
||||
private static final int MAP_FORCE_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 5;
|
||||
private static final int BASE_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 3;
|
||||
protected final static int LOWEST_ZOOM_TO_ROTATE = 9;
|
||||
private boolean MEASURE_FPS = false;
|
||||
|
@ -447,7 +448,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
}
|
||||
|
||||
private void refreshMapInternal(DrawSettings drawSettings) {
|
||||
handler.removeMessages(MAP_REFRESH_MESSAGE);
|
||||
SurfaceHolder holder = getHolder();
|
||||
long ms = SystemClock.elapsedRealtime();
|
||||
synchronized (holder) {
|
||||
|
@ -530,10 +530,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
}
|
||||
}
|
||||
|
||||
public boolean mapIsRefreshing() {
|
||||
return handler.hasMessages(MAP_REFRESH_MESSAGE);
|
||||
}
|
||||
|
||||
private void refreshBufferImage(final DrawSettings drawSettings) {
|
||||
if (!baseHandler.hasMessages(BASE_REFRESH_MESSAGE) || drawSettings.isUpdateVectorRendering()) {
|
||||
Message msg = Message.obtain(baseHandler, new Runnable() {
|
||||
|
@ -541,14 +537,21 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
public void run() {
|
||||
baseHandler.removeMessages(BASE_REFRESH_MESSAGE);
|
||||
try {
|
||||
refreshBaseMapInternal(currentViewport.copy(), drawSettings);
|
||||
sendRefreshMapMsg(drawSettings, 0);
|
||||
DrawSettings param = drawSettings;
|
||||
if (handler.hasMessages(MAP_FORCE_REFRESH_MESSAGE)) {
|
||||
if (!param.isUpdateVectorRendering()) {
|
||||
param = new DrawSettings(drawSettings.isNightMode(), true);
|
||||
}
|
||||
handler.removeMessages(MAP_FORCE_REFRESH_MESSAGE);
|
||||
}
|
||||
refreshBaseMapInternal(currentViewport.copy(), param);
|
||||
sendRefreshMapMsg(param, 0);
|
||||
} catch(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
msg.what = BASE_REFRESH_MESSAGE;
|
||||
msg.what = drawSettings.isUpdateVectorRendering() ? MAP_FORCE_REFRESH_MESSAGE : BASE_REFRESH_MESSAGE;
|
||||
// baseHandler.sendMessageDelayed(msg, 0);
|
||||
baseHandler.sendMessage(msg);
|
||||
}
|
||||
|
@ -574,8 +577,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
Message msg = Message.obtain(handler, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DrawSettings param = drawSettings;
|
||||
handler.removeMessages(MAP_REFRESH_MESSAGE);
|
||||
refreshMapInternal(drawSettings);
|
||||
|
||||
refreshMapInternal(param);
|
||||
}
|
||||
});
|
||||
msg.what = MAP_REFRESH_MESSAGE;
|
||||
|
|
|
@ -37,15 +37,15 @@ public class MapNavigateControl extends MapControls {
|
|||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
} else {
|
||||
OsmandApplication ctx = mapActivity.getMyApplication();
|
||||
if(!ctx.getTargetPointsHelper().checkPointToNavigate()) {
|
||||
if(!ctx.getTargetPointsHelper().checkPointToNavigateShort()) {
|
||||
ri.showDialog();
|
||||
} else {
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||
GPXRouteParams gpxRoute = null; // TODO gpx route
|
||||
if (gpxRoute == null) {
|
||||
app.getSettings().FOLLOW_THE_GPX_ROUTE.set(null);
|
||||
}
|
||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||
routingHelper.setFollowingMode(true);
|
||||
routingHelper.setRoutePlanningMode(false);
|
||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.content.DialogInterface;
|
|||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
|
@ -52,6 +53,8 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
private OsmandMapTileView mapView;
|
||||
private Dialog dialog;
|
||||
private AlertDialog favoritesDialog;
|
||||
private boolean selectFromMapTouch;
|
||||
private boolean selectFromMapForTarget;
|
||||
|
||||
|
||||
public MapRouteInfoControl(ContextMenuLayer contextMenu,
|
||||
|
@ -63,6 +66,22 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
routingHelper.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if(selectFromMapTouch) {
|
||||
LatLon latlon = tileBox.getLatLonFromPixel(point.x, point.y);
|
||||
selectFromMapTouch = false;
|
||||
if(selectFromMapForTarget) {
|
||||
getTargets().navigateToPoint(latlon, true, -1);
|
||||
} else {
|
||||
getTargets().setStartPoint(latlon, true, null);
|
||||
}
|
||||
contextMenu.setLocation(latlon, null);
|
||||
return true;
|
||||
}
|
||||
return super.onSingleTap(point, tileBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showControls(FrameLayout parent) {
|
||||
infoButton = addButton(parent, R.string.route_info, R.drawable.map_btn_signpost);
|
||||
|
@ -76,10 +95,10 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
showDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
if(getTargets().getPointToNavigate() == null) {
|
||||
showDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private Dialog createDialog() {
|
||||
|
@ -167,8 +186,9 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
}
|
||||
|
||||
protected void selectOnScreen(View parentView, boolean target) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
selectFromMapTouch = true;
|
||||
selectFromMapForTarget = target;
|
||||
hideDialog();
|
||||
}
|
||||
|
||||
protected void selectFavorite(final View parentView, final boolean target) {
|
||||
|
@ -189,7 +209,6 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
} else {
|
||||
getTargets().setStartPoint(point, true, name);
|
||||
}
|
||||
getTargets().updateRoutingHelper();
|
||||
favoritesDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
@ -311,7 +330,6 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
@Override
|
||||
public void newRouteIsCalculated(boolean newRoute) {
|
||||
directionInfo = -1;
|
||||
mapView.refreshMap();
|
||||
}
|
||||
|
||||
public String generateViaDescription() {
|
||||
|
@ -403,9 +421,7 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
@Override
|
||||
public void routeWasCancelled() {
|
||||
directionInfo = -1;
|
||||
if(dialog != null) {
|
||||
hideDialog();
|
||||
}
|
||||
// do not hide dialog (needed for use case entering Planning mode without destination)
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue