Code clean up:

This commit is contained in:
Victor Shcherb 2021-01-01 21:59:12 +01:00
parent 3a3b734e58
commit 494c7bc706
4 changed files with 8 additions and 28 deletions

View file

@ -519,10 +519,6 @@ public abstract class OsmandPlugin {
}
}
public boolean destinationReached() {
return true;
}
protected void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, MapActivity mapActivity) {
}
@ -781,17 +777,6 @@ public abstract class OsmandPlugin {
}
}
public static boolean onDestinationReached() {
boolean b = true;
for (OsmandPlugin plugin : getEnabledPlugins()) {
if (!plugin.destinationReached()) {
b = false;
}
}
return b;
}
public static void createLayers(OsmandMapTileView mapView, MapActivity activity) {
for (OsmandPlugin plugin : getEnabledPlugins()) {
plugin.registerLayers(activity);

View file

@ -51,10 +51,9 @@ public class RoutingHelper {
private static final float POS_TOLERANCE_DEVIATION_MULTIPLIER = 2;
// This should be correlated with RoutingHelper.updateCurrentRouteStatus ( when processed turn now is not announced)
private static final int DEFAULT_GPS_TOLERANCE = 12;
// TODO make private
public static int GPS_TOLERANCE = DEFAULT_GPS_TOLERANCE;
public static float ARRIVAL_DISTANCE_FACTOR = 1;
public static final int DEFAULT_GPS_TOLERANCE = 12;
private static int GPS_TOLERANCE = DEFAULT_GPS_TOLERANCE;
private static float ARRIVAL_DISTANCE_FACTOR = 1;
private List<WeakReference<IRouteInformationListener>> listeners = new LinkedList<>();
private List<WeakReference<IRoutingDataUpdateListener>> updateListeners = new LinkedList<>();
@ -306,7 +305,6 @@ public class RoutingHelper {
public void setAppMode(ApplicationMode mode) {
this.mode = mode;
ARRIVAL_DISTANCE_FACTOR = Math.max(settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(mode), 0.1f);
GPS_TOLERANCE = (int) (DEFAULT_GPS_TOLERANCE * ARRIVAL_DISTANCE_FACTOR);
voiceRouter.updateAppMode();
}
@ -569,7 +567,7 @@ public class RoutingHelper {
// 2. check if intermediate found
if (route.getIntermediatePointsToPass() > 0
&& route.getDistanceToNextIntermediate(lastFixedLocation) < getArrivalDistance(mode, settings) * 2f && !isRoutePlanningMode) {
&& route.getDistanceToNextIntermediate(lastFixedLocation) < getArrivalDistance(mode, settings) && !isRoutePlanningMode) {
showMessage(app.getString(R.string.arrived_at_intermediate_point));
route.passIntermediatePoint();
TargetPointsHelper targets = app.getTargetPointsHelper();
@ -610,8 +608,7 @@ public class RoutingHelper {
if (isFollowingMode) {
voiceRouter.arrivedDestinationPoint(description);
}
boolean onDestinationReached = OsmandPlugin.onDestinationReached();
onDestinationReached &= app.getAppCustomization().onDestinationReached();
boolean onDestinationReached = true;
if (onDestinationReached) {
clearCurrentRoute(null, null);
setRoutePlanningMode(false);
@ -678,7 +675,7 @@ public class RoutingHelper {
// return ((float)settings.getApplicationMode().getArrivalDistance()) * settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(m);
// GPS_TOLERANCE - 12 m
// 5 seconds: car - 80 m @ 50 kmh, bicycle - 45 m @ 25 km/h, bicycle - 25 m @ 10 km/h, pedestrian - 18 m @ 4 km/h,
return RoutingHelper.GPS_TOLERANCE + defaultSpeed * 5 * RoutingHelper.ARRIVAL_DISTANCE_FACTOR;
return (DEFAULT_GPS_TOLERANCE + defaultSpeed * 5) * RoutingHelper.ARRIVAL_DISTANCE_FACTOR;
}
private static float getPosTolerance(float accuracy) {

View file

@ -230,7 +230,8 @@ public class VoiceRouter {
// 1 kmh - 1 m, 4 kmh - 4 m (pedestrian), 10 kmh - 10 m (bicycle), 50 kmh - 50 m (car)
// TURN_NOW_DISTANCE = (int) (DEFAULT_SPEED * 3.6); // 3.6 sec
// 50 kmh - 48 m (car), 10 kmh - 20 m, 4 kmh - 15 m, 1 kmh - 12 m
TURN_NOW_DISTANCE = (int) (RoutingHelper.GPS_TOLERANCE + DEFAULT_SPEED * 2.5 * RoutingHelper.ARRIVAL_DISTANCE_FACTOR); // 3.6 sec
float factor = Math.max(settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(appMode), 0.1f);
TURN_NOW_DISTANCE = (int) ((RoutingHelper.DEFAULT_GPS_TOLERANCE + DEFAULT_SPEED * 2.5) * factor); // 3.6 sec
TURN_NOW_SPEED = TURN_NOW_DISTANCE / TURN_NOW_TIME;
}

View file

@ -227,9 +227,6 @@ public class OsmAndAppCustomization {
return true;
}
public boolean onDestinationReached() {
return true;
}
@Nullable
public Bitmap getNavDrawerLogo() {