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());
|
boolean tr = TurnType.TR.equals(t.getValue());
|
||||||
if(tl || tr) {
|
if(tl || tr) {
|
||||||
TurnType tnext = getTurnInfo(result, i + 1, leftside);
|
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()) ) {
|
if(tl && TurnType.TL.equals(tnext.getValue()) ) {
|
||||||
next = i + 2;
|
next = i + 2;
|
||||||
t = TurnType.valueOf(TurnType.TU, true);
|
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).
|
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
|
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_hours">Hours</string>
|
||||||
<string name="osmand_parking_minutes">Minutes</string>
|
<string name="osmand_parking_minutes">Minutes</string>
|
||||||
<string name="osmand_parking_position_description_add_time">The car was parked at:</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_MSG_ID = 7;
|
||||||
private static final int SHOW_POSITION_DELAY = 2500;
|
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 AUTO_FOLLOW_MSG_ID = 8;
|
||||||
private static final int LOST_LOCATION_MSG_ID = 10;
|
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_MSG_ID = 28;
|
||||||
private static final int LONG_KEYPRESS_DELAY = 500;
|
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){
|
public void setLocation(Location location) {
|
||||||
if(Log.isLoggable(LogUtil.TAG, Log.DEBUG)){
|
if (Log.isLoggable(LogUtil.TAG, Log.DEBUG)) {
|
||||||
Log.d(LogUtil.TAG, "Location changed " + location.getProvider()); //$NON-NLS-1$
|
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()
|
// use because there is a bug on some devices with location.getTime()
|
||||||
long locationTime = System.currentTimeMillis();
|
long locationTime = System.currentTimeMillis();
|
||||||
// write only with 50 meters accuracy
|
// write only with 50 meters accuracy
|
||||||
|
@ -718,33 +722,44 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
location.getSpeed(), location.getAccuracy(), locationTime, settings);
|
location.getSpeed(), location.getAccuracy(), locationTime, settings);
|
||||||
}
|
}
|
||||||
// live monitoring is aware of accuracy (it would be good to create an option)
|
// 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(),
|
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
|
// only for emulator
|
||||||
updateSpeedBearingEmulator(location);
|
updateSpeedBearingEmulator(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean enableSensorNavigation = routingHelper.isFollowingMode() && settings.USE_COMPASS_IN_NAVIGATION.get() ?
|
boolean enableSensorNavigation = routingHelper.isFollowingMode() && settings.USE_COMPASS_IN_NAVIGATION.get() ? location == null
|
||||||
location == null || !location.hasBearing() : false;
|
|| !location.hasBearing() : false;
|
||||||
registerUnregisterSensor(location, enableSensorNavigation);
|
registerUnregisterSensor(location, enableSensorNavigation);
|
||||||
|
|
||||||
if(routingHelper.isFollowingMode()){
|
if (routingHelper.isFollowingMode()) {
|
||||||
if(location == null || !location.hasAccuracy() || location.getAccuracy() < ACCURACY_FOR_GPX_AND_ROUTING) {
|
if (location == null || !location.hasAccuracy() || location.getAccuracy() < ACCURACY_FOR_GPX_AND_ROUTING) {
|
||||||
// Update routing position and get location for sticking mode
|
// Update routing position and get location for sticking mode
|
||||||
Location updatedLocation = routingHelper.setCurrentLocation(location);
|
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;
|
location = updatedLocation;
|
||||||
// Check with delay that gps location is not lost
|
// 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();
|
final long fixTime = location.getTime();
|
||||||
Message msg = Message.obtain(uiHandler, new Runnable() {
|
Message msg = Message.obtain(uiHandler, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Location lastKnown = getLastKnownLocation();
|
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
|
// false positive case, still strange how we got here with removeMessages
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -761,22 +776,22 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
}
|
}
|
||||||
mapLayers.getLocationLayer().setLastKnownLocation(location);
|
mapLayers.getLocationLayer().setLastKnownLocation(location);
|
||||||
navigationInfo.setLocation(location);
|
navigationInfo.setLocation(location);
|
||||||
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (isMapLinkedToLocation()) {
|
if (isMapLinkedToLocation()) {
|
||||||
if(settings.AUTO_ZOOM_MAP.get() && location.hasSpeed()){
|
if (settings.AUTO_ZOOM_MAP.get() && location.hasSpeed()) {
|
||||||
float zdelta = defineZoomFromSpeed(location.getSpeed());
|
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)
|
// prevent ui hysteresis (check time interval for autozoom)
|
||||||
if(zdelta >= 2) {
|
if (zdelta >= 2) {
|
||||||
// decrease a bit
|
// decrease a bit
|
||||||
zdelta -= 3 * OsmandMapTileView.ZOOM_DELTA_1;
|
zdelta -= 3 * OsmandMapTileView.ZOOM_DELTA_1;
|
||||||
} else if(zdelta <= -2){
|
} else if (zdelta <= -2) {
|
||||||
// decrease a bit
|
// decrease a bit
|
||||||
zdelta += 3 * OsmandMapTileView.ZOOM_DELTA_1;
|
zdelta += 3 * OsmandMapTileView.ZOOM_DELTA_1;
|
||||||
}
|
}
|
||||||
if(now - lastTimeAutoZooming > 4500){
|
if (now - lastTimeAutoZooming > 4500) {
|
||||||
lastTimeAutoZooming = now;
|
lastTimeAutoZooming = now;
|
||||||
mapView.setZoom(mapView.getFloatZoom() + zdelta);
|
mapView.setZoom(mapView.getFloatZoom() + zdelta);
|
||||||
// mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false);
|
// mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false);
|
||||||
|
@ -786,7 +801,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
int currentMapRotation = settings.ROTATE_MAP.get();
|
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||||
if (location.hasBearing() && currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
|
if (location.hasBearing() && currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
|
||||||
mapView.setRotate(-location.getBearing());
|
mapView.setRotate(-location.getBearing());
|
||||||
} else if(!location.hasBearing() && routingHelper.isFollowingMode()
|
} else if (!location.hasBearing() && routingHelper.isFollowingMode()
|
||||||
&& currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
|
&& currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
|
||||||
if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -previousSensorValue)) > 15
|
if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -previousSensorValue)) > 15
|
||||||
&& now - lastTimeSensorRotation > 1500) {
|
&& now - lastTimeSensorRotation > 1500) {
|
||||||
|
@ -796,20 +811,19 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
}
|
}
|
||||||
mapView.setLatLon(location.getLatitude(), location.getLongitude());
|
mapView.setLatLon(location.getLatitude(), location.getLongitude());
|
||||||
} else {
|
} else {
|
||||||
if(!mapLayers.getMapInfoLayer().getBackToLocation().isEnabled()){
|
if (!mapLayers.getMapInfoLayer().getBackToLocation().isEnabled()) {
|
||||||
mapLayers.getMapInfoLayer().getBackToLocation().setEnabled(true);
|
mapLayers.getMapInfoLayer().getBackToLocation().setEnabled(true);
|
||||||
}
|
}
|
||||||
if (settings.AUTO_FOLLOW_ROUTE.get() > 0 && routingHelper.isFollowingMode()
|
if (settings.AUTO_FOLLOW_ROUTE.get() > 0 && routingHelper.isFollowingMode() && !uiHandler.hasMessages(AUTO_FOLLOW_MSG_ID)) {
|
||||||
&& !uiHandler.hasMessages(AUTO_FOLLOW_MSG_ID)) {
|
|
||||||
backToLocationWithDelay(1);
|
backToLocationWithDelay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(mapLayers.getMapInfoLayer().getBackToLocation().isEnabled()){
|
if (mapLayers.getMapInfoLayer().getBackToLocation().isEnabled()) {
|
||||||
mapLayers.getMapInfoLayer().getBackToLocation().setEnabled(false);
|
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();
|
mapView.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -392,31 +392,31 @@ public class MapActivityActions implements DialogProvider {
|
||||||
return true;
|
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();
|
|
||||||
|
final RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||||
Builder builder = new AlertDialog.Builder(mapActivity);
|
|
||||||
|
Builder builder = new AlertDialog.Builder(mapActivity);
|
||||||
|
|
||||||
View view = mapActivity.getLayoutInflater().inflate(R.layout.calculate_route, null);
|
View view = mapActivity.getLayoutInflater().inflate(R.layout.calculate_route, null);
|
||||||
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length];
|
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length];
|
||||||
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
|
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
|
||||||
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
|
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
|
||||||
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
|
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
|
||||||
ApplicationMode appMode = settings.getApplicationMode();
|
ApplicationMode appMode = settings.getApplicationMode();
|
||||||
for (int i = 0; i < buttons.length; i++) {
|
for (int i = 0; i < buttons.length; i++) {
|
||||||
if(buttons[i] != null){
|
if (buttons[i] != null) {
|
||||||
final int ind = i;
|
final int ind = i;
|
||||||
ToggleButton b = buttons[i];
|
ToggleButton b = buttons[i];
|
||||||
b.setChecked(appMode == ApplicationMode.values()[i]);
|
b.setChecked(appMode == ApplicationMode.values()[i]);
|
||||||
b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
|
b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if(isChecked){
|
if (isChecked) {
|
||||||
for (int j = 0; j < buttons.length; j++) {
|
for (int j = 0; j < buttons.length; j++) {
|
||||||
if (buttons[j] != null) {
|
if (buttons[j] != null) {
|
||||||
if(buttons[j].isChecked() != (ind == j)){
|
if (buttons[j].isChecked() != (ind == j)) {
|
||||||
buttons[j].setChecked(ind == j);
|
buttons[j].setChecked(ind == j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,79 +426,90 @@ public class MapActivityActions implements DialogProvider {
|
||||||
boolean revert = true;
|
boolean revert = true;
|
||||||
for (int j = 0; j < buttons.length; j++) {
|
for (int j = 0; j < buttons.length; j++) {
|
||||||
if (buttons[j] != null) {
|
if (buttons[j] != null) {
|
||||||
if(buttons[j].isChecked()){
|
if (buttons[j].isChecked()) {
|
||||||
revert = false;
|
revert = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (revert){
|
if (revert) {
|
||||||
buttons[ind].setChecked(true);
|
buttons[ind].setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogInterface.OnClickListener onlyShowCall = new DialogInterface.OnClickListener(){
|
|
||||||
|
|
||||||
|
DialogInterface.OnClickListener onlyShowCall = new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
ApplicationMode mode = getAppMode(buttons, settings);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Location location = new Location("map"); //$NON-NLS-1$
|
|
||||||
location.setLatitude(lat);
|
|
||||||
location.setLongitude(lon);
|
|
||||||
routingHelper.setAppMode(mode);
|
routingHelper.setAppMode(mode);
|
||||||
settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get());
|
settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get());
|
||||||
settings.FOLLOW_THE_ROUTE.set(false);
|
settings.FOLLOW_THE_ROUTE.set(false);
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||||
routingHelper.setFollowingMode(false);
|
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
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if(!checkPointToNavigate()){
|
if (!checkPointToNavigate()) {
|
||||||
return;
|
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);
|
ApplicationMode mode = getAppMode(buttons, settings);
|
||||||
// change global settings
|
// change global settings
|
||||||
settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get());
|
settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get());
|
||||||
boolean changed = settings.APPLICATION_MODE.set(mode);
|
boolean changed = settings.APPLICATION_MODE.set(mode);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
mapActivity.updateApplicationModeSettings();
|
mapActivity.updateApplicationModeSettings();
|
||||||
mapActivity.getMapView().refreshMap(true);
|
mapActivity.getMapView().refreshMap(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = getLocationToStartFrom(lat, lon);
|
|
||||||
routingHelper.setAppMode(mode);
|
routingHelper.setAppMode(mode);
|
||||||
settings.FOLLOW_THE_ROUTE.set(true);
|
settings.FOLLOW_THE_ROUTE.set(true);
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||||
routingHelper.setFollowingMode(true);
|
routingHelper.setFollowingMode(true);
|
||||||
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), location);
|
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), current);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
getMyApplication().showDialogInitializingCommandPlayer(mapActivity);
|
getMyApplication().showDialogInitializingCommandPlayer(mapActivity);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DialogInterface.OnClickListener useGpxNavigation = new DialogInterface.OnClickListener() {
|
||||||
DialogInterface.OnClickListener useGpxNavigation = new DialogInterface.OnClickListener(){
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
ApplicationMode mode = getAppMode(buttons, settings);
|
ApplicationMode mode = getAppMode(buttons, settings);
|
||||||
navigateUsingGPX(mode);
|
navigateUsingGPX(mode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
builder.setView(view);
|
builder.setView(view);
|
||||||
builder.setTitle(R.string.get_directions);
|
builder.setTitle(R.string.get_directions);
|
||||||
if (followEnabled) {
|
if (followEnabled) {
|
||||||
builder.setPositiveButton(R.string.follow, followCall);
|
builder.setPositiveButton(R.string.follow, followCall);
|
||||||
builder.setNeutralButton(R.string.gpx_navigation, useGpxNavigation);
|
builder.setNeutralButton(R.string.gpx_navigation, useGpxNavigation);
|
||||||
builder.setNegativeButton(R.string.only_show, onlyShowCall);
|
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.setPositiveButton(R.string.show_gpx_route, onlyShowCall);
|
||||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||||
}
|
}
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected OsmandApplication getMyApplication() {
|
protected OsmandApplication getMyApplication() {
|
||||||
return mapActivity.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) {
|
public void navigateUsingGPX(final ApplicationMode appMode) {
|
||||||
final LatLon endForRouting = mapActivity.getPointToNavigate();
|
final LatLon endForRouting = mapActivity.getPointToNavigate();
|
||||||
final MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
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) {
|
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);
|
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_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_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_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_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_share_location, R.drawable.list_view_share_location);
|
||||||
adapter.registerItem(R.string.context_menu_item_add_favorite, R.drawable.list_activities_favorites);
|
adapter.registerItem(R.string.context_menu_item_add_favorite, R.drawable.list_activities_favorites);
|
||||||
|
|
||||||
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
|
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
|
ListAdapter listadapter = new ArrayAdapter<String>(mapActivity, R.layout.layers_list_activity_item, R.id.title,
|
||||||
if(adapter.getImageId(position) != 0) {
|
adapter.getItemNames()) {
|
||||||
tv.setCompoundDrawablesWithIntrinsicBounds(adapter.getImageId(position), 0, 0, 0);
|
@Override
|
||||||
} else {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.list_activities_transparent, 0, 0, 0);
|
// 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));
|
// Put the image on the TextView
|
||||||
ch.setVisibility(View.GONE);
|
if (adapter.getImageId(position) != 0) {
|
||||||
return v;
|
tv.setCompoundDrawablesWithIntrinsicBounds(adapter.getImageId(position), 0, 0, 0);
|
||||||
}
|
} else {
|
||||||
};
|
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.list_activities_transparent, 0, 0, 0);
|
||||||
|
}
|
||||||
builder.setAdapter(listadapter, new DialogInterface.OnClickListener() {
|
|
||||||
|
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
|
||||||
|
ch.setVisibility(View.GONE);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
builder.setAdapter(listadapter, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int standardId = adapter.getItemId(which );
|
int standardId = adapter.getItemId(which);
|
||||||
OnContextMenuClick click = adapter.getClickAdapter(which);
|
OnContextMenuClick click = adapter.getClickAdapter(which);
|
||||||
if(click != null) {
|
if (click != null) {
|
||||||
click.onContextMenuClick(standardId, which, false, dialog);
|
click.onContextMenuClick(standardId, which, false, dialog);
|
||||||
} else if (standardId == R.string.context_menu_item_search) {
|
} else if (standardId == R.string.context_menu_item_search) {
|
||||||
Intent intent = new Intent(mapActivity, OsmandIntents.getSearchActivity());
|
Intent intent = new Intent(mapActivity, OsmandIntents.getSearchActivity());
|
||||||
|
@ -734,21 +731,21 @@ public class MapActivityActions implements DialogProvider {
|
||||||
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
||||||
} else if (standardId == R.string.context_menu_item_directions) {
|
} else if (standardId == R.string.context_menu_item_directions) {
|
||||||
Location loc = mapActivity.getLastKnownLocation();
|
Location loc = mapActivity.getLastKnownLocation();
|
||||||
if (loc != null) {
|
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
||||||
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
// always enable and follow and let calculate it (GPS is not accessible in garage)
|
||||||
getDirections(loc.getLatitude(), loc.getLongitude(), true);
|
getDirections(loc, true);
|
||||||
} else {
|
|
||||||
AccessibleToast.makeText(mapActivity, R.string.unknown_from_location, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
} else if (standardId == R.string.context_menu_item_show_route) {
|
} else if (standardId == R.string.context_menu_item_show_route) {
|
||||||
if(checkPointToNavigate()) {
|
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) {
|
} 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) {
|
} else if (standardId == R.string.context_menu_item_add_favorite) {
|
||||||
addFavouritePoint(latitude, longitude);
|
addFavouritePoint(latitude, longitude);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
@ -943,11 +940,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
aboutRoute();
|
aboutRoute();
|
||||||
} else {
|
} else {
|
||||||
Location loc = mapActivity.getLastKnownLocation();
|
Location loc = mapActivity.getLastKnownLocation();
|
||||||
if (loc != null) {
|
getDirections(loc, true);
|
||||||
getDirections(loc.getLatitude(), loc.getLongitude(), true);
|
|
||||||
} else {
|
|
||||||
getDirections(mapView.getLatitude(), mapView.getLongitude(), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.map_layers) {
|
} else if (itemId == R.id.map_layers) {
|
||||||
|
|
|
@ -143,10 +143,6 @@ public class RoutingHelper {
|
||||||
return lastFixedLocation;
|
return lastFixedLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isRouterEnabled(){
|
|
||||||
return finalLocation != null && lastFixedLocation != null;
|
|
||||||
}
|
|
||||||
public boolean isRouteCalculated(){
|
public boolean isRouteCalculated(){
|
||||||
return route.isCalculated();
|
return route.isCalculated();
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,7 +371,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public boolean updateInfo() {
|
public boolean updateInfo() {
|
||||||
int time = 0;
|
int time = 0;
|
||||||
if (routeLayer != null && routeLayer.getHelper().isRouterEnabled()) {
|
if (routeLayer != null && routeLayer.getHelper().isRouteCalculated()) {
|
||||||
boolean followingMode = routeLayer.getHelper().isFollowingMode();
|
boolean followingMode = routeLayer.getHelper().isFollowingMode();
|
||||||
time = routeLayer.getHelper().getLeftTime();
|
time = routeLayer.getHelper().getLeftTime();
|
||||||
if (time != 0) {
|
if (time != 0) {
|
||||||
|
@ -432,7 +432,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
public boolean updateInfo() {
|
public boolean updateInfo() {
|
||||||
if (map.getPointToNavigate() != null) {
|
if (map.getPointToNavigate() != null) {
|
||||||
int d = 0;
|
int d = 0;
|
||||||
if (map.getRoutingHelper().isRouterEnabled()) {
|
if (map.getRoutingHelper().isRouteCalculated()) {
|
||||||
d = map.getRoutingHelper().getLeftDistance();
|
d = map.getRoutingHelper().getLeftDistance();
|
||||||
}
|
}
|
||||||
if (d == 0) {
|
if (d == 0) {
|
||||||
|
@ -508,7 +508,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public boolean updateInfo() {
|
public boolean updateInfo() {
|
||||||
boolean visible = false;
|
boolean visible = false;
|
||||||
if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
|
if (routeLayer != null && routingHelper.isRouteCalculated() && routingHelper.isFollowingMode()) {
|
||||||
boolean uturnWhenPossible = routingHelper.makeUturnWhenPossible();
|
boolean uturnWhenPossible = routingHelper.makeUturnWhenPossible();
|
||||||
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, false);
|
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, false);
|
||||||
if (!uturnWhenPossible) {
|
if (!uturnWhenPossible) {
|
||||||
|
@ -605,7 +605,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public boolean updateInfo() {
|
public boolean updateInfo() {
|
||||||
boolean visible = false;
|
boolean visible = false;
|
||||||
if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
|
if (routeLayer != null && routingHelper.isFollowingMode()) {
|
||||||
AlarmInfo alarm = routingHelper.getMostImportantAlarm(view.getSettings().METRIC_SYSTEM.get());
|
AlarmInfo alarm = routingHelper.getMostImportantAlarm(view.getSettings().METRIC_SYSTEM.get());
|
||||||
if(alarm != null) {
|
if(alarm != null) {
|
||||||
if(alarm.getType() == AlarmInfo.SPEED_LIMIT) {
|
if(alarm.getType() == AlarmInfo.SPEED_LIMIT) {
|
||||||
|
@ -652,8 +652,9 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public boolean updateInfo() {
|
public boolean updateInfo() {
|
||||||
boolean visible = false;
|
boolean visible = false;
|
||||||
if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
|
if (routeLayer != null && routingHelper.isRouteCalculated() ) {
|
||||||
makeUturnWhenPossible = routingHelper.makeUturnWhenPossible();
|
boolean follow = routingHelper.isFollowingMode();
|
||||||
|
makeUturnWhenPossible = routingHelper.makeUturnWhenPossible() && follow;
|
||||||
if (makeUturnWhenPossible) {
|
if (makeUturnWhenPossible) {
|
||||||
visible = true;
|
visible = true;
|
||||||
turnImminent = 1;
|
turnImminent = 1;
|
||||||
|
@ -661,23 +662,20 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform);
|
TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform);
|
||||||
invalidate();
|
invalidate();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
boolean showStraight = false;
|
boolean showStraight = false;
|
||||||
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
NextDirectionInfo r = null;
|
||||||
// do not switch information for exits (where to keep left)
|
if(follow) {
|
||||||
// NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, false);
|
r = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
||||||
// if (r != null) {
|
} else {
|
||||||
// RouteDirectionInfo toShowWithoutSpeak = r.directionInfo;
|
int di = map.getMapLayers().getRouteInfoLayer().getDirectionInfo();
|
||||||
// if (r.imminent >= 0 && r.imminent < 2) {
|
if (di >= 0 && map.getMapLayers().getRouteInfoLayer().isVisible()) {
|
||||||
// // next turn is very close (show it)
|
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
|
||||||
// } else {
|
r = new NextDirectionInfo();
|
||||||
// r = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
r.directionInfo = next;
|
||||||
// if(calc1.directionInfo != toShowWithoutSpeak){
|
r.distanceTo = 0;
|
||||||
// // show straight and grey because it is not the closest turn
|
r.imminent = 1;
|
||||||
// showStraight = r.imminent == -1;
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if (r != null && r.distanceTo > 0) {
|
if (r != null && r.distanceTo > 0) {
|
||||||
visible = true;
|
visible = true;
|
||||||
if (r.directionInfo == null) {
|
if (r.directionInfo == null) {
|
||||||
|
@ -878,7 +876,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
int locimminent = -1;
|
int locimminent = -1;
|
||||||
int[] loclanes = null;
|
int[] loclanes = null;
|
||||||
if (routeLayer != null && routingHelper.isRouteCalculated()) {
|
if (routeLayer != null && routingHelper.isRouteCalculated()) {
|
||||||
if (routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
|
if (routingHelper.isFollowingMode()) {
|
||||||
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
|
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
|
||||||
if(r != null && r.directionInfo != null && r.directionInfo.getTurnType() != null) {
|
if(r != null && r.directionInfo != null && r.directionInfo.getTurnType() != null) {
|
||||||
loclanes = r.directionInfo.getTurnType().getLanes();
|
loclanes = r.directionInfo.getTurnType().getLanes();
|
||||||
|
|
Loading…
Reference in a new issue