Fix bug with missing speed cam & traffic bump

This commit is contained in:
vshcherb 2013-10-20 01:51:11 +02:00
parent 21ee3508d3
commit e8ad7769d6
6 changed files with 76 additions and 35 deletions

View file

@ -27,12 +27,19 @@ import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.DataTileManager;
import net.osmand.data.LatLon;
import net.osmand.plus.*;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ClientContext;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.Route;
import net.osmand.plus.GPXUtilities.Track;
import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.Version;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
import net.osmand.router.RoutePlannerFrontEnd;

View file

@ -71,8 +71,6 @@ public class RoutingHelper {
// private ProgressBar progress;
// private Handler progressHandler;
public boolean makeUturnWhenPossible() {
return makeUturnWhenPossible;
}
@ -637,9 +635,22 @@ public class RoutingHelper {
}
}
protected boolean isDistanceLess(float currentSpeed, double dist, double etalon, double defSpeed){
if(dist < etalon || ((dist / currentSpeed) < (etalon / defSpeed))){
return true;
}
return false;
}
public synchronized String getCurrentName(){
NextDirectionInfo n = getNextRouteDirectionInfo(new NextDirectionInfo(), false);
if((n.imminent == 0 || n.imminent == 1) && (n.directionInfo != null)) {
Location l = lastFixedLocation;
float speed = 0;
if(l != null && l.hasSpeed()) {
speed = l.getSpeed();
}
if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() &&
voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f)) {
String nm = n.directionInfo.getStreetName();
String rf = n.directionInfo.getRef();
String dn = n.directionInfo.getDestinationName();

View file

@ -4,7 +4,6 @@ package net.osmand.plus.routing;
import net.osmand.Location;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ClientContext;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.voice.AbstractPrologCommandPlayer;
import net.osmand.plus.voice.CommandBuilder;
@ -133,6 +132,9 @@ public class VoiceRouter {
}
protected boolean isDistanceLess(float currentSpeed, double dist, double etalon){
if(currentSpeed <= 0) {
currentSpeed = DEFAULT_SPEED;
}
if(dist < etalon || ((dist / currentSpeed) < (etalon / DEFAULT_SPEED))){
return true;
}

View file

@ -165,11 +165,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
description = view.getContext().getString(R.string.point_on_map,
latLon.getLatitude(), latLon.getLongitude());
}
if(description.indexOf('\n') == -1) {
textView.setText(description);
if(textView.getLineCount() == 1) {
// make 2 line description
description +="\n ";
textView.setText(description);
}
textView.setText(description);
} else {
textView.setText(""); //$NON-NLS-1$
}

View file

@ -1,38 +1,59 @@
package net.osmand.plus.views;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.graphics.*;
import android.graphics.Paint.Style;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.*;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout.LayoutParams;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.*;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.mapwidgets.*;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
import net.osmand.util.Algorithms;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.Set;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.mapwidgets.AppearanceWidgetsFactory;
import net.osmand.plus.views.mapwidgets.BaseMapWidget;
import net.osmand.plus.views.mapwidgets.ImageViewWidget;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget;
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.StackWidgetView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.plus.views.mapwidgets.UpdateableWidget;
import net.osmand.util.Algorithms;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.TextView;
public class MapInfoLayer extends OsmandMapLayer {
public static float scaleCoefficient = 1;

View file

@ -10,7 +10,6 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DrivingRegion;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
@ -656,7 +655,7 @@ public class RouteInfoWidgetsFactory {
} else if(alarm.getType() == AlarmInfo.STOP) {
// text = "STOP";
}
visible = text != null && text.length() > 0;
visible = (text != null && text.length() > 0) || locimgId != 0;
if (visible) {
if (alarm.getType() == AlarmInfo.SPEED_CAMERA) {
visible = cams;