Adjustify follow status and directions to buttons
This commit is contained in:
parent
bc7dcfa9d0
commit
6005c0a546
6 changed files with 164 additions and 162 deletions
|
@ -901,7 +901,7 @@ public class BinaryRoutePlanner {
|
|||
boolean tr = TurnType.TR.equals(t.getValue());
|
||||
if(tl || tr) {
|
||||
TurnType tnext = getTurnInfo(result, i + 1, leftside);
|
||||
if(tnext != null && result.get(i).getDistance() < 55) {
|
||||
if(tnext != null && result.get(i).getDistance() < 35) {
|
||||
if(tl && TurnType.TL.equals(tnext.getValue()) ) {
|
||||
next = i + 2;
|
||||
t = TurnType.valueOf(TurnType.TU, true);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
1. 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="route_updated_loc_found">Route will be recalculated when location will be found</string>
|
||||
<string name="osmand_parking_hours">Hours</string>
|
||||
<string name="osmand_parking_minutes">Minutes</string>
|
||||
<string name="osmand_parking_position_description_add_time">The car was parked at:</string>
|
||||
|
|
|
@ -83,11 +83,11 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
|
||||
private static final int SHOW_POSITION_MSG_ID = 7;
|
||||
private static final int SHOW_POSITION_DELAY = 2500;
|
||||
private static final float ACCURACY_FOR_GPX_AND_ROUTING = 50;
|
||||
public static final float ACCURACY_FOR_GPX_AND_ROUTING = 50;
|
||||
|
||||
private static final int AUTO_FOLLOW_MSG_ID = 8;
|
||||
private static final int LOST_LOCATION_MSG_ID = 10;
|
||||
private static final long LOST_LOCATION_CHECK_DELAY = 20000;
|
||||
private static final long LOST_LOCATION_CHECK_DELAY = 18000;
|
||||
|
||||
private static final int LONG_KEYPRESS_MSG_ID = 28;
|
||||
private static final int LONG_KEYPRESS_DELAY = 500;
|
||||
|
@ -704,6 +704,10 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isPointAccurateForRouting(Location loc) {
|
||||
return loc != null && loc.getAccuracy() < ACCURACY_FOR_GPX_AND_ROUTING * 3 /2;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
if (Log.isLoggable(LogUtil.TAG, Log.DEBUG)) {
|
||||
Log.d(LogUtil.TAG, "Location changed " + location.getProvider()); //$NON-NLS-1$
|
||||
|
@ -728,14 +732,25 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
updateSpeedBearingEmulator(location);
|
||||
}
|
||||
|
||||
boolean enableSensorNavigation = routingHelper.isFollowingMode() && settings.USE_COMPASS_IN_NAVIGATION.get() ?
|
||||
location == null || !location.hasBearing() : false;
|
||||
boolean enableSensorNavigation = routingHelper.isFollowingMode() && settings.USE_COMPASS_IN_NAVIGATION.get() ? location == null
|
||||
|| !location.hasBearing() : false;
|
||||
registerUnregisterSensor(location, enableSensorNavigation);
|
||||
|
||||
if (routingHelper.isFollowingMode()) {
|
||||
if (location == null || !location.hasAccuracy() || location.getAccuracy() < ACCURACY_FOR_GPX_AND_ROUTING) {
|
||||
// Update routing position and get location for sticking mode
|
||||
Location updatedLocation = routingHelper.setCurrentLocation(location);
|
||||
if(!routingHelper.isFollowingMode()) {
|
||||
// finished
|
||||
Message msg = Message.obtain(uiHandler, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
settings.APPLICATION_MODE.set(settings.PREV_APPLICATION_MODE.get());
|
||||
updateApplicationModeSettings();
|
||||
}
|
||||
});
|
||||
uiHandler.sendMessage(msg);
|
||||
}
|
||||
location = updatedLocation;
|
||||
// Check with delay that gps location is not lost
|
||||
if (location != null && routingHelper.getLeftDistance() > 0) {
|
||||
|
@ -744,7 +759,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
@Override
|
||||
public void run() {
|
||||
Location lastKnown = getLastKnownLocation();
|
||||
if(lastKnown != null && lastKnown.getTime() - fixTime < LOST_LOCATION_CHECK_DELAY) {
|
||||
if (lastKnown != null && lastKnown.getTime() - fixTime < LOST_LOCATION_CHECK_DELAY / 2) {
|
||||
// false positive case, still strange how we got here with removeMessages
|
||||
return;
|
||||
}
|
||||
|
@ -799,8 +814,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
if (!mapLayers.getMapInfoLayer().getBackToLocation().isEnabled()) {
|
||||
mapLayers.getMapInfoLayer().getBackToLocation().setEnabled(true);
|
||||
}
|
||||
if (settings.AUTO_FOLLOW_ROUTE.get() > 0 && routingHelper.isFollowingMode()
|
||||
&& !uiHandler.hasMessages(AUTO_FOLLOW_MSG_ID)) {
|
||||
if (settings.AUTO_FOLLOW_ROUTE.get() > 0 && routingHelper.isFollowingMode() && !uiHandler.hasMessages(AUTO_FOLLOW_MSG_ID)) {
|
||||
backToLocationWithDelay(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,13 +392,13 @@ public class MapActivityActions implements DialogProvider {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void getDirections(final double lat, final double lon, boolean followEnabled){
|
||||
|
||||
protected void getDirections(final Location from, boolean followEnabled) {
|
||||
|
||||
final RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||
|
||||
Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
|
||||
|
||||
View view = mapActivity.getLayoutInflater().inflate(R.layout.calculate_route, null);
|
||||
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length];
|
||||
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
|
||||
|
@ -442,22 +442,22 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
DialogInterface.OnClickListener onlyShowCall = new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ApplicationMode mode = getAppMode(buttons, settings);
|
||||
if (!checkPointToNavigate()) {
|
||||
return;
|
||||
}
|
||||
Location location = new Location("map"); //$NON-NLS-1$
|
||||
location.setLatitude(lat);
|
||||
location.setLongitude(lon);
|
||||
if (from == null) {
|
||||
AccessibleToast.makeText(mapActivity, R.string.unknown_from_location, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
routingHelper.setAppMode(mode);
|
||||
settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get());
|
||||
settings.FOLLOW_THE_ROUTE.set(false);
|
||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||
routingHelper.setFollowingMode(false);
|
||||
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), location);
|
||||
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), from);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -467,6 +467,19 @@ public class MapActivityActions implements DialogProvider {
|
|||
if (!checkPointToNavigate()) {
|
||||
return;
|
||||
}
|
||||
boolean msg = true;
|
||||
Location current = from;
|
||||
if (!mapActivity.isPointAccurateForRouting(from)) {
|
||||
current = null;
|
||||
}
|
||||
Location lastKnownLocation = mapActivity.getLastKnownLocation();
|
||||
if (mapActivity.isPointAccurateForRouting(lastKnownLocation)) {
|
||||
current = lastKnownLocation;
|
||||
msg = false;
|
||||
}
|
||||
if (msg) {
|
||||
AccessibleToast.makeText(mapActivity, R.string.route_updated_loc_found, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
ApplicationMode mode = getAppMode(buttons, settings);
|
||||
// change global settings
|
||||
settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get());
|
||||
|
@ -476,18 +489,16 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.getMapView().refreshMap(true);
|
||||
}
|
||||
|
||||
Location location = getLocationToStartFrom(lat, lon);
|
||||
routingHelper.setAppMode(mode);
|
||||
settings.FOLLOW_THE_ROUTE.set(true);
|
||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||
routingHelper.setFollowingMode(true);
|
||||
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), location);
|
||||
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), current);
|
||||
dialog.dismiss();
|
||||
getMyApplication().showDialogInitializingCommandPlayer(mapActivity);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
DialogInterface.OnClickListener useGpxNavigation = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
@ -514,16 +525,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
return mapActivity.getMyApplication();
|
||||
}
|
||||
|
||||
private Location getLocationToStartFrom(final double lat, final double lon) {
|
||||
Location location = mapActivity.getLastKnownLocation();
|
||||
if(location == null){
|
||||
location = new Location("map"); //$NON-NLS-1$
|
||||
location.setLatitude(lat);
|
||||
location.setLongitude(lon);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
public void navigateUsingGPX(final ApplicationMode appMode) {
|
||||
final LatLon endForRouting = mapActivity.getPointToNavigate();
|
||||
final MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
|
@ -680,7 +681,6 @@ 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;
|
||||
Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
|
||||
adapter.registerItem(R.string.context_menu_item_navigate_point, R.drawable.list_view_set_destination);
|
||||
adapter.registerItem(R.string.context_menu_item_directions, R.drawable.list_view_directions_to_here);
|
||||
|
@ -691,10 +691,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
|
||||
|
||||
ListAdapter listadapter = new ArrayAdapter<String>(
|
||||
mapActivity,
|
||||
R.layout.layers_list_activity_item,
|
||||
R.id.title,
|
||||
ListAdapter listadapter = new ArrayAdapter<String>(mapActivity, R.layout.layers_list_activity_item, R.id.title,
|
||||
adapter.getItemNames()) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
@ -734,18 +731,18 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
||||
} else if (standardId == R.string.context_menu_item_directions) {
|
||||
Location loc = mapActivity.getLastKnownLocation();
|
||||
if (loc != null) {
|
||||
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
||||
getDirections(loc.getLatitude(), loc.getLongitude(), true);
|
||||
} else {
|
||||
AccessibleToast.makeText(mapActivity, R.string.unknown_from_location, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
// always enable and follow and let calculate it (GPS is not accessible in garage)
|
||||
getDirections(loc, true);
|
||||
} else if (standardId == R.string.context_menu_item_show_route) {
|
||||
if (checkPointToNavigate()) {
|
||||
getDirections(latitude, longitude, false);
|
||||
Location loc = new Location("map");
|
||||
loc.setLatitude(latitude);
|
||||
loc.setLongitude(longitude);
|
||||
getDirections(loc, true);
|
||||
}
|
||||
} else if (standardId == R.string.context_menu_item_share_location) {
|
||||
shareLocation(latitude, longitude, mapView.getZoom());
|
||||
shareLocation(latitude, longitude, mapActivity.getMapView().getZoom());
|
||||
} else if (standardId == R.string.context_menu_item_add_favorite) {
|
||||
addFavouritePoint(latitude, longitude);
|
||||
}
|
||||
|
@ -943,11 +940,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
aboutRoute();
|
||||
} else {
|
||||
Location loc = mapActivity.getLastKnownLocation();
|
||||
if (loc != null) {
|
||||
getDirections(loc.getLatitude(), loc.getLongitude(), true);
|
||||
} else {
|
||||
getDirections(mapView.getLatitude(), mapView.getLongitude(), true);
|
||||
}
|
||||
getDirections(loc, true);
|
||||
}
|
||||
return true;
|
||||
} else if (itemId == R.id.map_layers) {
|
||||
|
|
|
@ -143,10 +143,6 @@ public class RoutingHelper {
|
|||
return lastFixedLocation;
|
||||
}
|
||||
|
||||
|
||||
public boolean isRouterEnabled(){
|
||||
return finalLocation != null && lastFixedLocation != null;
|
||||
}
|
||||
public boolean isRouteCalculated(){
|
||||
return route.isCalculated();
|
||||
}
|
||||
|
|
|
@ -371,7 +371,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public boolean updateInfo() {
|
||||
int time = 0;
|
||||
if (routeLayer != null && routeLayer.getHelper().isRouterEnabled()) {
|
||||
if (routeLayer != null && routeLayer.getHelper().isRouteCalculated()) {
|
||||
boolean followingMode = routeLayer.getHelper().isFollowingMode();
|
||||
time = routeLayer.getHelper().getLeftTime();
|
||||
if (time != 0) {
|
||||
|
@ -432,7 +432,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
public boolean updateInfo() {
|
||||
if (map.getPointToNavigate() != null) {
|
||||
int d = 0;
|
||||
if (map.getRoutingHelper().isRouterEnabled()) {
|
||||
if (map.getRoutingHelper().isRouteCalculated()) {
|
||||
d = map.getRoutingHelper().getLeftDistance();
|
||||
}
|
||||
if (d == 0) {
|
||||
|
@ -508,7 +508,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public boolean updateInfo() {
|
||||
boolean visible = false;
|
||||
if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
|
||||
if (routeLayer != null && routingHelper.isRouteCalculated() && routingHelper.isFollowingMode()) {
|
||||
boolean uturnWhenPossible = routingHelper.makeUturnWhenPossible();
|
||||
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, false);
|
||||
if (!uturnWhenPossible) {
|
||||
|
@ -605,7 +605,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public boolean updateInfo() {
|
||||
boolean visible = false;
|
||||
if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
|
||||
if (routeLayer != null && routingHelper.isFollowingMode()) {
|
||||
AlarmInfo alarm = routingHelper.getMostImportantAlarm(view.getSettings().METRIC_SYSTEM.get());
|
||||
if(alarm != null) {
|
||||
if(alarm.getType() == AlarmInfo.SPEED_LIMIT) {
|
||||
|
@ -652,8 +652,9 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public boolean updateInfo() {
|
||||
boolean visible = false;
|
||||
if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
|
||||
makeUturnWhenPossible = routingHelper.makeUturnWhenPossible();
|
||||
if (routeLayer != null && routingHelper.isRouteCalculated() ) {
|
||||
boolean follow = routingHelper.isFollowingMode();
|
||||
makeUturnWhenPossible = routingHelper.makeUturnWhenPossible() && follow;
|
||||
if (makeUturnWhenPossible) {
|
||||
visible = true;
|
||||
turnImminent = 1;
|
||||
|
@ -661,23 +662,20 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform);
|
||||
invalidate();
|
||||
} else {
|
||||
|
||||
boolean showStraight = false;
|
||||
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
||||
// do not switch information for exits (where to keep left)
|
||||
// NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, false);
|
||||
// if (r != null) {
|
||||
// RouteDirectionInfo toShowWithoutSpeak = r.directionInfo;
|
||||
// if (r.imminent >= 0 && r.imminent < 2) {
|
||||
// // next turn is very close (show it)
|
||||
// } else {
|
||||
// r = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
||||
// if(calc1.directionInfo != toShowWithoutSpeak){
|
||||
// // show straight and grey because it is not the closest turn
|
||||
// showStraight = r.imminent == -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
NextDirectionInfo r = null;
|
||||
if(follow) {
|
||||
r = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
||||
} else {
|
||||
int di = map.getMapLayers().getRouteInfoLayer().getDirectionInfo();
|
||||
if (di >= 0 && map.getMapLayers().getRouteInfoLayer().isVisible()) {
|
||||
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
|
||||
r = new NextDirectionInfo();
|
||||
r.directionInfo = next;
|
||||
r.distanceTo = 0;
|
||||
r.imminent = 1;
|
||||
}
|
||||
}
|
||||
if (r != null && r.distanceTo > 0) {
|
||||
visible = true;
|
||||
if (r.directionInfo == null) {
|
||||
|
@ -878,7 +876,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
int locimminent = -1;
|
||||
int[] loclanes = null;
|
||||
if (routeLayer != null && routingHelper.isRouteCalculated()) {
|
||||
if (routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
|
||||
if (routingHelper.isFollowingMode()) {
|
||||
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
|
||||
if(r != null && r.directionInfo != null && r.directionInfo.getTurnType() != null) {
|
||||
loclanes = r.directionInfo.getTurnType().getLanes();
|
||||
|
|
Loading…
Reference in a new issue