Fix bug with speed, update route icons
This commit is contained in:
parent
6d9fc6106f
commit
620460266e
6 changed files with 92 additions and 49 deletions
|
@ -590,7 +590,8 @@ public class RoutingHelper {
|
|||
public static final String TSLR = "TSLR"; // turn slight right //$NON-NLS-1$
|
||||
public static final String TSHR = "TSHR"; // turn sharp right //$NON-NLS-1$
|
||||
public static final String TU = "TU"; // U-turn //$NON-NLS-1$
|
||||
public static String[] predefinedTypes = new String[] {C, TL, TSLL, TSHL, TR, TSLR, TSHR, TU};
|
||||
public static final String TRU = "TRU"; // Right U-turn //$NON-NLS-1$
|
||||
public static String[] predefinedTypes = new String[] {C, TL, TSLL, TSHL, TR, TSLR, TSHR, TU, TRU};
|
||||
|
||||
|
||||
public static TurnType valueOf(String s){
|
||||
|
|
|
@ -235,7 +235,7 @@ public class VoiceRouter {
|
|||
play.prepareTurn(tParam, dist).play();
|
||||
} else if(next.turnType.isRoundAbout()){
|
||||
play.prepareRoundAbout(dist).play();
|
||||
} else if(next.turnType.getValue().equals(TurnType.TU)){
|
||||
} else if(next.turnType.getValue().equals(TurnType.TU) || next.turnType.getValue().equals(TurnType.TRU)){
|
||||
play.prepareMakeUT(dist).play();
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ public class VoiceRouter {
|
|||
play.turn(tParam, dist);
|
||||
} else if (next.turnType.isRoundAbout()) {
|
||||
play.roundAbout(dist, next.turnType.getTurnAngle(), next.turnType.getExitOut());
|
||||
} else if (next.turnType.getValue().equals(TurnType.TU)) {
|
||||
} else if (next.turnType.getValue().equals(TurnType.TU) || next.turnType.getValue().equals(TurnType.TRU)) {
|
||||
play.makeUT(dist);
|
||||
} else {
|
||||
isPlay = false;
|
||||
|
@ -287,7 +287,7 @@ public class VoiceRouter {
|
|||
play.turn(tParam);
|
||||
} else if(next.turnType.isRoundAbout()){
|
||||
play.roundAbout(next.turnType.getTurnAngle(), next.turnType.getExitOut());
|
||||
} else if(next.turnType.getValue().equals(TurnType.TU)){
|
||||
} else if(next.turnType.getValue().equals(TurnType.TU) || next.turnType.getValue().equals(TurnType.TRU)){
|
||||
play.makeUT();
|
||||
// do not say it
|
||||
// } else if(next.turnType.getValue().equals(TurnType.C)){
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.osmand.osm.LatLon;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.routing.RoutingHelper.RouteDirectionInfo;
|
||||
import net.osmand.plus.routing.RoutingHelper.TurnType;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
@ -80,6 +81,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
paintText.setColor(Color.BLACK);
|
||||
paintText.setTextSize(23 * scaleCoefficient);
|
||||
paintText.setAntiAlias(true);
|
||||
paintText.setStrokeWidth(4);
|
||||
|
||||
paintSubText = new Paint();
|
||||
paintSubText.setStyle(Style.FILL_AND_STROKE);
|
||||
|
@ -423,7 +425,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
private NextTurnInfoControl createNextInfoControl() {
|
||||
NextTurnInfoControl nextTurnInfo = new NextTurnInfoControl(map, paintText, paintSubText) {
|
||||
final NextTurnInfoControl nextTurnInfo = new NextTurnInfoControl(map, paintText, paintSubText) {
|
||||
|
||||
@Override
|
||||
public boolean updateInfo() {
|
||||
|
@ -439,7 +441,10 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
invalidate();
|
||||
}
|
||||
} else if (!Algoritms.objectEquals(turnType, next.turnType)) {
|
||||
turnType = next.turnType;
|
||||
// TODO
|
||||
// if(turnType == null) {
|
||||
turnType = next.turnType;
|
||||
// }
|
||||
TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform);
|
||||
if (turnType.getExitOut() > 0) {
|
||||
exitOut = turnType.getExitOut() + ""; //$NON-NLS-1$
|
||||
|
@ -459,8 +464,17 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
};
|
||||
nextTurnInfo.setOnClickListener(new View.OnClickListener() {
|
||||
int i = 0;
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// i++;
|
||||
// if (i % (TurnType.predefinedTypes.length + 1) == TurnType.predefinedTypes.length ) {
|
||||
// nextTurnInfo.turnType = TurnType.valueOf("EXIT4");
|
||||
// } else {
|
||||
// nextTurnInfo.turnType = TurnType.valueOf(TurnType.predefinedTypes[i % (TurnType.predefinedTypes.length + 1)]);
|
||||
// }
|
||||
// nextTurnInfo.invalidate();
|
||||
// TODO
|
||||
showMiniMap = true;
|
||||
view.refreshMap();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ public class MapStackControl extends ViewGroup {
|
|||
List<MapInfoControl> stackViews = new ArrayList<MapInfoControl>();
|
||||
List<MapInfoControl> collapsedViews = new ArrayList<MapInfoControl>();
|
||||
ImageView expandView;
|
||||
private boolean isCollapsed = true;
|
||||
// by default opened
|
||||
private boolean isCollapsed = false;
|
||||
private boolean isCollapsible = true;
|
||||
|
||||
public MapStackControl(Context context) {
|
||||
|
@ -143,6 +144,12 @@ public class MapStackControl extends ViewGroup {
|
|||
}
|
||||
h += c.getMeasuredHeight();
|
||||
prevBot = c.getPaddingBottom();
|
||||
} else {
|
||||
if (h == 0) {
|
||||
// measure one of the figure if it is collapsed and no top elements
|
||||
c.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
|
||||
h += c.getPaddingTop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -150,6 +157,7 @@ public class MapStackControl extends ViewGroup {
|
|||
if (isCollapsible) {
|
||||
h -= prevBot;
|
||||
h += expandView.getDrawable().getMinimumHeight();
|
||||
w = Math.max(w, expandView.getDrawable().getMinimumWidth());
|
||||
}
|
||||
}
|
||||
setMeasuredDimension(w, h);
|
||||
|
@ -182,6 +190,9 @@ public class MapStackControl extends ViewGroup {
|
|||
}
|
||||
} else {
|
||||
c.layout(0, 0, 0, 0);
|
||||
if(y == 0){
|
||||
y += c.getPaddingTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import android.graphics.Path;
|
|||
public class NextTurnInfoControl extends MapInfoControl {
|
||||
|
||||
private float scaleCoefficient = MapInfoLayer.scaleCoefficient;
|
||||
private final float width = 96 * scaleCoefficient;
|
||||
private final float height = 96 * scaleCoefficient;
|
||||
private final float width = 72 * scaleCoefficient;
|
||||
private final float height = 75 * scaleCoefficient;
|
||||
|
||||
protected Path pathForTurn = new Path();
|
||||
|
||||
|
@ -36,10 +36,11 @@ public class NextTurnInfoControl extends MapInfoControl {
|
|||
paintBlack.setStyle(Style.STROKE);
|
||||
paintBlack.setColor(Color.BLACK);
|
||||
paintBlack.setAntiAlias(true);
|
||||
paintBlack.setStrokeWidth(2.5f);
|
||||
|
||||
paintRouteDirection = new Paint();
|
||||
paintRouteDirection.setStyle(Style.FILL_AND_STROKE);
|
||||
paintRouteDirection.setColor(Color.rgb(100, 0, 255));
|
||||
paintRouteDirection.setStyle(Style.FILL);
|
||||
paintRouteDirection.setColor(Color.rgb(250, 222, 35));
|
||||
paintRouteDirection.setAntiAlias(true);
|
||||
|
||||
pathTransform = new Matrix();
|
||||
|
@ -58,12 +59,13 @@ public class NextTurnInfoControl extends MapInfoControl {
|
|||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (pathForTurn != null) {
|
||||
// small indent
|
||||
canvas.translate(0, 3 * scaleCoefficient);
|
||||
canvas.drawPath(pathForTurn, paintRouteDirection);
|
||||
canvas.drawPath(pathForTurn, paintBlack);
|
||||
// TODO test
|
||||
if (exitOut != null) {
|
||||
canvas.drawText(exitOut, (getWWidth()) / 2 - 6 * scaleCoefficient, getWHeight() / 2 - 9
|
||||
* scaleCoefficient, paintBlack);
|
||||
drawShadowText(canvas, exitOut, (getWWidth()) / 2 - 6 * scaleCoefficient,
|
||||
getWHeight() / 2 - textPaint.getTextSize() / 2, textPaint);
|
||||
}
|
||||
String text = OsmAndFormatter.getFormattedDistance(nextTurnDirection, getContext());
|
||||
String subtext = null;
|
||||
|
@ -76,9 +78,9 @@ public class NextTurnInfoControl extends MapInfoControl {
|
|||
}
|
||||
float mt = textPaint.measureText(text);
|
||||
drawShadowText(canvas, text,
|
||||
(getWWidth() - st - mt) / 2 - scaleCoefficient, getWHeight() - 3 * scaleCoefficient, textPaint);
|
||||
(getWWidth() - st - mt) / 2 - scaleCoefficient, getWHeight() - 5 * scaleCoefficient, textPaint);
|
||||
if (subtext != null) {
|
||||
drawShadowText(canvas, subtext, (getWWidth() - st - mt) / 2 + 2 * scaleCoefficient + mt, getWHeight() - 3
|
||||
drawShadowText(canvas, subtext, (getWWidth() - st - mt) / 2 + 2 * scaleCoefficient + mt, getWHeight() - 5
|
||||
* scaleCoefficient, subtextPaint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,24 +16,25 @@ import android.util.FloatMath;
|
|||
public class TurnPathHelper {
|
||||
|
||||
// draw path 96x96
|
||||
// 64x64
|
||||
public static void calcTurnPath(Path pathForTurn, TurnType turnType, Matrix transform) {
|
||||
if(turnType == null){
|
||||
return;
|
||||
}
|
||||
pathForTurn.reset();
|
||||
int ha = 72;
|
||||
int wa = 72;
|
||||
|
||||
int c = 48;
|
||||
int w = 16;
|
||||
pathForTurn.moveTo(c, 94);
|
||||
float sarrowL = 30; // side of arrow
|
||||
int th = 12; // thickness
|
||||
pathForTurn.moveTo(wa / 2, ha - 1);
|
||||
float sarrowL = 23; // side of arrow ?
|
||||
float harrowL = (float) Math.sqrt(2) * sarrowL; // hypotenuse of arrow
|
||||
float spartArrowL = (float) ((sarrowL - w / Math.sqrt(2)) / 2);
|
||||
float hpartArrowL = (float) (harrowL - w) / 2;
|
||||
float spartArrowL = (float) ((sarrowL - th / Math.sqrt(2)) / 2);
|
||||
float hpartArrowL = (float) (harrowL - th) / 2;
|
||||
|
||||
if (TurnType.C.equals(turnType.getValue())) {
|
||||
int h = 65;
|
||||
|
||||
pathForTurn.rMoveTo(w / 2, 0);
|
||||
int h = (int) (ha - hpartArrowL - 18);
|
||||
pathForTurn.rMoveTo(th / 2, 0);
|
||||
pathForTurn.rLineTo(0, -h);
|
||||
pathForTurn.rLineTo(hpartArrowL, 0);
|
||||
pathForTurn.rLineTo(-harrowL / 2, -harrowL / 2); // center
|
||||
|
@ -42,25 +43,31 @@ public class TurnPathHelper {
|
|||
pathForTurn.rLineTo(0, h);
|
||||
} else if (TurnType.TR.equals(turnType.getValue())|| TurnType.TL.equals(turnType.getValue())) {
|
||||
int b = TurnType.TR.equals(turnType.getValue())? 1 : -1;
|
||||
int h = 36;
|
||||
float quadShiftX = 22;
|
||||
float quadShiftY = 22;
|
||||
|
||||
pathForTurn.rMoveTo(-b * 8, 0);
|
||||
int wl = 10; // width
|
||||
int h = (int) (ha - quadShiftY - harrowL + hpartArrowL - 5);
|
||||
int sl = wl + th / 2;
|
||||
|
||||
pathForTurn.rMoveTo(-b * sl, 0);
|
||||
pathForTurn.rLineTo(0, -h);
|
||||
pathForTurn.rQuadTo(0, -quadShiftY, b * quadShiftX, -quadShiftY);
|
||||
pathForTurn.rLineTo(b * wl, 0);
|
||||
|
||||
pathForTurn.rLineTo(0, hpartArrowL);
|
||||
pathForTurn.rLineTo(b * harrowL / 2, -harrowL / 2); // center
|
||||
pathForTurn.rLineTo(-b * harrowL / 2, -harrowL / 2);
|
||||
pathForTurn.rLineTo(0, hpartArrowL);
|
||||
pathForTurn.rQuadTo(-b * (quadShiftX + w), 0, -b * (quadShiftX + w), quadShiftY + w);
|
||||
|
||||
pathForTurn.rLineTo(-b * wl, 0);
|
||||
pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th), quadShiftY + th);
|
||||
pathForTurn.rLineTo(0, h);
|
||||
} else if (TurnType.TSLR.equals(turnType.getValue()) || TurnType.TSLL.equals(turnType.getValue())) {
|
||||
int b = TurnType.TSLR.equals(turnType.getValue()) ? 1 : -1;
|
||||
int h = 40;
|
||||
int h = 24;
|
||||
int quadShiftY = 22;
|
||||
float quadShiftX = (float) (quadShiftY / (1 + Math.sqrt(2)));
|
||||
float nQuadShiftX = (sarrowL - 2 * spartArrowL) - quadShiftX - w;
|
||||
float nQuadShiftX = (sarrowL - 2 * spartArrowL) - quadShiftX - th;
|
||||
float nQuadShifty = quadShiftY + (sarrowL - 2 * spartArrowL);
|
||||
|
||||
pathForTurn.rMoveTo(-b * 4, 0);
|
||||
|
@ -74,13 +81,14 @@ public class TurnPathHelper {
|
|||
pathForTurn.rLineTo(0, h);
|
||||
} else if (TurnType.TSHR.equals(turnType.getValue()) || TurnType.TSHL.equals(turnType.getValue())) {
|
||||
int b = TurnType.TSHR.equals(turnType.getValue()) ? 1 : -1;
|
||||
int h = 45;
|
||||
int h = 28;
|
||||
float quadShiftX = 22;
|
||||
int sh = 10;
|
||||
float quadShiftY = -(float) (quadShiftX / (1 + Math.sqrt(2)));
|
||||
float nQuadShiftX = -(sarrowL - 2 * spartArrowL) - quadShiftX - w;
|
||||
float nQuadShiftX = -(sarrowL - 2 * spartArrowL) - quadShiftX - th;
|
||||
float nQuadShiftY = -quadShiftY + (sarrowL - 2 * spartArrowL);
|
||||
|
||||
pathForTurn.rMoveTo(-b * 8, 0);
|
||||
pathForTurn.rMoveTo(-b * sh, 0);
|
||||
pathForTurn.rLineTo(0, -h);
|
||||
pathForTurn.rQuadTo(0, -(quadShiftX - quadShiftY), b * quadShiftX, quadShiftY);
|
||||
pathForTurn.rLineTo(-b * spartArrowL, spartArrowL);
|
||||
|
@ -89,21 +97,28 @@ public class TurnPathHelper {
|
|||
pathForTurn.rLineTo(-b * spartArrowL, spartArrowL);
|
||||
pathForTurn.rCubicTo(b * nQuadShiftX / 2, nQuadShiftX / 2, b * nQuadShiftX, nQuadShiftX / 2, b * nQuadShiftX, nQuadShiftY);
|
||||
pathForTurn.rLineTo(0, h);
|
||||
} else if(TurnType.TU.equals(turnType.getValue())) {
|
||||
int h = 54;
|
||||
float quadShiftX = 13;
|
||||
float quadShiftY = 13;
|
||||
} else if(TurnType.TU.equals(turnType.getValue()) || TurnType.TRU.equals(turnType.getValue())) {
|
||||
int h = 40;
|
||||
// right left
|
||||
int b = TurnType.TU.equals(turnType.getValue()) ? 1 : -1;
|
||||
float quadShiftX = 10; // 13
|
||||
float quadShiftY = 10; // 13
|
||||
int sm = 10;
|
||||
|
||||
pathForTurn.rMoveTo(28, 0);
|
||||
pathForTurn.rMoveTo(b * 28, 0);
|
||||
pathForTurn.rLineTo(0, -h);
|
||||
pathForTurn.rQuadTo(0, -(quadShiftY+w), -(quadShiftX+w), -(quadShiftY+w));
|
||||
pathForTurn.rQuadTo(-(quadShiftX+w), 0, -(quadShiftX+w), (quadShiftY+w));
|
||||
pathForTurn.rLineTo(-hpartArrowL, 0);
|
||||
pathForTurn.rLineTo(harrowL/2, harrowL/2); // center
|
||||
pathForTurn.rLineTo(harrowL/2, -harrowL/2);
|
||||
pathForTurn.rLineTo(-hpartArrowL, 0);
|
||||
pathForTurn.rQuadTo(0, -quadShiftX, quadShiftX, -quadShiftY);
|
||||
pathForTurn.rQuadTo(quadShiftX, 0, quadShiftX, quadShiftY);
|
||||
pathForTurn.rQuadTo(0, -(quadShiftY+th), -b * (quadShiftX+th), -(quadShiftY+th));
|
||||
pathForTurn.rQuadTo(-b * (quadShiftX+th), 0, -b * (quadShiftX+th), (quadShiftY+th));
|
||||
pathForTurn.rLineTo(0, sm);
|
||||
|
||||
pathForTurn.rLineTo(-b * hpartArrowL, 0);
|
||||
pathForTurn.rLineTo(b * harrowL/2, harrowL/2); // center
|
||||
pathForTurn.rLineTo(b * harrowL/2, -harrowL/2);
|
||||
pathForTurn.rLineTo(-b *hpartArrowL, 0);
|
||||
|
||||
pathForTurn.rLineTo(0, -sm);
|
||||
pathForTurn.rQuadTo(0, -quadShiftX, b *quadShiftX, -quadShiftY);
|
||||
pathForTurn.rQuadTo(b * quadShiftX, 0, b * quadShiftX, quadShiftY);
|
||||
pathForTurn.rLineTo(0, h);
|
||||
} else if (turnType != null && turnType.isRoundAbout()) {
|
||||
float t = turnType.getTurnAngle();
|
||||
|
@ -116,8 +131,8 @@ public class TurnPathHelper {
|
|||
if (sweepAngle < -360) {
|
||||
sweepAngle += 360;
|
||||
}
|
||||
float r1 = 32f;
|
||||
float r2 = 24f;
|
||||
float r1 = ha / 3f;
|
||||
float r2 = 18f;
|
||||
float angleToRot = 0.3f;
|
||||
|
||||
pathForTurn.moveTo(48, 48 + r1 + 8);
|
||||
|
|
Loading…
Reference in a new issue