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;
|
||||
|
@ -703,12 +703,16 @@ 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)){
|
||||
public void setLocation(Location location) {
|
||||
if (Log.isLoggable(LogUtil.TAG, Log.DEBUG)) {
|
||||
Log.d(LogUtil.TAG, "Location changed " + location.getProvider()); //$NON-NLS-1$
|
||||
}
|
||||
if(location != null ) {
|
||||
if (location != null) {
|
||||
// use because there is a bug on some devices with location.getTime()
|
||||
long locationTime = System.currentTimeMillis();
|
||||
// write only with 50 meters accuracy
|
||||
|
@ -718,33 +722,44 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
location.getSpeed(), location.getAccuracy(), locationTime, settings);
|
||||
}
|
||||
// live monitoring is aware of accuracy (it would be good to create an option)
|
||||
if(settings.LIVE_MONITORING.get()){
|
||||
if (settings.LIVE_MONITORING.get()) {
|
||||
liveMonitoringHelper.insertData(location.getLatitude(), location.getLongitude(), location.getAltitude(),
|
||||
location.getSpeed(), location.getAccuracy(), location.getTime(), settings);
|
||||
location.getSpeed(), location.getAccuracy(), location.getTime(), settings);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// only for emulator
|
||||
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
|
||||
|
||||
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){
|
||||
if (location != null && routingHelper.getLeftDistance() > 0) {
|
||||
final long fixTime = location.getTime();
|
||||
Message msg = Message.obtain(uiHandler, new Runnable() {
|
||||
@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;
|
||||
}
|
||||
|
@ -761,22 +776,22 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
}
|
||||
mapLayers.getLocationLayer().setLastKnownLocation(location);
|
||||
navigationInfo.setLocation(location);
|
||||
|
||||
|
||||
if (location != null) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (isMapLinkedToLocation()) {
|
||||
if(settings.AUTO_ZOOM_MAP.get() && location.hasSpeed()){
|
||||
if (settings.AUTO_ZOOM_MAP.get() && location.hasSpeed()) {
|
||||
float zdelta = defineZoomFromSpeed(location.getSpeed());
|
||||
if(Math.abs(zdelta) >= OsmandMapTileView.ZOOM_DELTA_1){
|
||||
if (Math.abs(zdelta) >= OsmandMapTileView.ZOOM_DELTA_1) {
|
||||
// prevent ui hysteresis (check time interval for autozoom)
|
||||
if(zdelta >= 2) {
|
||||
if (zdelta >= 2) {
|
||||
// decrease a bit
|
||||
zdelta -= 3 * OsmandMapTileView.ZOOM_DELTA_1;
|
||||
} else if(zdelta <= -2){
|
||||
} else if (zdelta <= -2) {
|
||||
// decrease a bit
|
||||
zdelta += 3 * OsmandMapTileView.ZOOM_DELTA_1;
|
||||
}
|
||||
if(now - lastTimeAutoZooming > 4500){
|
||||
if (now - lastTimeAutoZooming > 4500) {
|
||||
lastTimeAutoZooming = now;
|
||||
mapView.setZoom(mapView.getFloatZoom() + zdelta);
|
||||
// mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false);
|
||||
|
@ -786,7 +801,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||
if (location.hasBearing() && currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
|
||||
mapView.setRotate(-location.getBearing());
|
||||
} else if(!location.hasBearing() && routingHelper.isFollowingMode()
|
||||
} else if (!location.hasBearing() && routingHelper.isFollowingMode()
|
||||
&& currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
|
||||
if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -previousSensorValue)) > 15
|
||||
&& now - lastTimeSensorRotation > 1500) {
|
||||
|
@ -796,20 +811,19 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
}
|
||||
mapView.setLatLon(location.getLatitude(), location.getLongitude());
|
||||
} else {
|
||||
if(!mapLayers.getMapInfoLayer().getBackToLocation().isEnabled()){
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(mapLayers.getMapInfoLayer().getBackToLocation().isEnabled()){
|
||||
if (mapLayers.getMapInfoLayer().getBackToLocation().isEnabled()) {
|
||||
mapLayers.getMapInfoLayer().getBackToLocation().setEnabled(false);
|
||||
}
|
||||
}
|
||||
// When location is changed we need to refresh map in order to show movement!
|
||||
// When location is changed we need to refresh map in order to show movement!
|
||||
mapView.refreshMap();
|
||||
}
|
||||
|
||||
|
|
|
@ -392,31 +392,31 @@ public class MapActivityActions implements DialogProvider {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void getDirections(final double lat, final double lon, 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);
|
||||
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
|
||||
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
|
||||
ApplicationMode appMode = settings.getApplicationMode();
|
||||
|
||||
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);
|
||||
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
|
||||
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
|
||||
ApplicationMode appMode = settings.getApplicationMode();
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
if(buttons[i] != null){
|
||||
final int ind = i;
|
||||
ToggleButton b = buttons[i];
|
||||
b.setChecked(appMode == ApplicationMode.values()[i]);
|
||||
b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
|
||||
if (buttons[i] != null) {
|
||||
final int ind = i;
|
||||
ToggleButton b = buttons[i];
|
||||
b.setChecked(appMode == ApplicationMode.values()[i]);
|
||||
b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if(isChecked){
|
||||
if (isChecked) {
|
||||
for (int j = 0; j < buttons.length; j++) {
|
||||
if (buttons[j] != null) {
|
||||
if(buttons[j].isChecked() != (ind == j)){
|
||||
if (buttons[j].isChecked() != (ind == j)) {
|
||||
buttons[j].setChecked(ind == j);
|
||||
}
|
||||
}
|
||||
|
@ -426,79 +426,90 @@ public class MapActivityActions implements DialogProvider {
|
|||
boolean revert = true;
|
||||
for (int j = 0; j < buttons.length; j++) {
|
||||
if (buttons[j] != null) {
|
||||
if(buttons[j].isChecked()){
|
||||
if (buttons[j].isChecked()) {
|
||||
revert = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (revert){
|
||||
if (revert) {
|
||||
buttons[ind].setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
DialogInterface.OnClickListener onlyShowCall = new DialogInterface.OnClickListener(){
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
DialogInterface.OnClickListener onlyShowCall = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ApplicationMode mode = getAppMode(buttons, settings);
|
||||
if(!checkPointToNavigate()){
|
||||
if (!checkPointToNavigate()) {
|
||||
return;
|
||||
}
|
||||
if (from == null) {
|
||||
AccessibleToast.makeText(mapActivity, R.string.unknown_from_location, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Location location = new Location("map"); //$NON-NLS-1$
|
||||
location.setLatitude(lat);
|
||||
location.setLongitude(lon);
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
DialogInterface.OnClickListener followCall = new DialogInterface.OnClickListener(){
|
||||
};
|
||||
|
||||
DialogInterface.OnClickListener followCall = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if(!checkPointToNavigate()){
|
||||
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());
|
||||
boolean changed = settings.APPLICATION_MODE.set(mode);
|
||||
if (changed) {
|
||||
mapActivity.updateApplicationModeSettings();
|
||||
mapActivity.updateApplicationModeSettings();
|
||||
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(){
|
||||
};
|
||||
|
||||
DialogInterface.OnClickListener useGpxNavigation = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ApplicationMode mode = getAppMode(buttons, settings);
|
||||
navigateUsingGPX(mode);
|
||||
}
|
||||
};
|
||||
|
||||
builder.setView(view);
|
||||
builder.setTitle(R.string.get_directions);
|
||||
if (followEnabled) {
|
||||
|
||||
builder.setView(view);
|
||||
builder.setTitle(R.string.get_directions);
|
||||
if (followEnabled) {
|
||||
builder.setPositiveButton(R.string.follow, followCall);
|
||||
builder.setNeutralButton(R.string.gpx_navigation, useGpxNavigation);
|
||||
builder.setNegativeButton(R.string.only_show, onlyShowCall);
|
||||
|
@ -507,23 +518,13 @@ public class MapActivityActions implements DialogProvider {
|
|||
builder.setPositiveButton(R.string.show_gpx_route, onlyShowCall);
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
}
|
||||
builder.show();
|
||||
}
|
||||
builder.show();
|
||||
}
|
||||
|
||||
protected OsmandApplication getMyApplication() {
|
||||
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();
|
||||
|
@ -678,51 +679,47 @@ 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;
|
||||
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);
|
||||
adapter.registerItem(R.string.context_menu_item_show_route, R.drawable.list_view_show_route_from_here);
|
||||
adapter.registerItem(R.string.context_menu_item_search, R.drawable.list_view_search_near_here);
|
||||
adapter.registerItem(R.string.context_menu_item_share_location, R.drawable.list_view_share_location);
|
||||
adapter.registerItem(R.string.context_menu_item_add_favorite, R.drawable.list_activities_favorites);
|
||||
|
||||
|
||||
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
|
||||
|
||||
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) {
|
||||
//User super class to create the View
|
||||
View v = super.getView(position, convertView, parent);
|
||||
TextView tv = (TextView)v.findViewById(R.id.title);
|
||||
tv.setText(adapter.getItemName(position));
|
||||
|
||||
//Put the image on the TextView
|
||||
if(adapter.getImageId(position) != 0) {
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(adapter.getImageId(position), 0, 0, 0);
|
||||
} else {
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.list_activities_transparent, 0, 0, 0);
|
||||
}
|
||||
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) {
|
||||
// User super class to create the View
|
||||
View v = super.getView(position, convertView, parent);
|
||||
TextView tv = (TextView) v.findViewById(R.id.title);
|
||||
tv.setText(adapter.getItemName(position));
|
||||
|
||||
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
|
||||
ch.setVisibility(View.GONE);
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
builder.setAdapter(listadapter, new DialogInterface.OnClickListener() {
|
||||
// Put the image on the TextView
|
||||
if (adapter.getImageId(position) != 0) {
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(adapter.getImageId(position), 0, 0, 0);
|
||||
} else {
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.list_activities_transparent, 0, 0, 0);
|
||||
}
|
||||
|
||||
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
|
||||
ch.setVisibility(View.GONE);
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
builder.setAdapter(listadapter, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int standardId = adapter.getItemId(which );
|
||||
int standardId = adapter.getItemId(which);
|
||||
OnContextMenuClick click = adapter.getClickAdapter(which);
|
||||
if(click != null) {
|
||||
if (click != null) {
|
||||
click.onContextMenuClick(standardId, which, false, dialog);
|
||||
} else if (standardId == R.string.context_menu_item_search) {
|
||||
Intent intent = new Intent(mapActivity, OsmandIntents.getSearchActivity());
|
||||
|
@ -734,21 +731,21 @@ 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();
|
||||
}
|
||||
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
||||
// 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);
|
||||
if (checkPointToNavigate()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
|
@ -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