Add big turn info
This commit is contained in:
parent
994e4e48fc
commit
c3c5d9d055
9 changed files with 233 additions and 221 deletions
|
@ -7,9 +7,9 @@
|
|||
android:background="@drawable/btn_left_round"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageButton
|
||||
<ImageView
|
||||
android:id="@+id/widget_top_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="@dimen/map_widget_image"
|
||||
android:layout_height="@dimen/map_widget_image"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_action_close_light"
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
<dimen name="osmo_header_height">56dp</dimen>
|
||||
<!-- map buttons -->
|
||||
<dimen name="map_trans_seek_size">80dp</dimen>
|
||||
<dimen name="map_widget_text_size">20sp</dimen>
|
||||
<dimen name="map_widget_text_size_small">14sp</dimen>
|
||||
<dimen name="map_widget_text_size">23sp</dimen>
|
||||
<dimen name="map_widget_text_size_small">15sp</dimen>
|
||||
<dimen name="map_widget_text_bottom_margin">1sp</dimen>
|
||||
<dimen name="map_button_text_size">18sp</dimen>
|
||||
<dimen name="map_route_buttons_width">60dp</dimen>
|
||||
|
|
|
@ -154,7 +154,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
setImageDrawable(monitoringBig);
|
||||
return true;
|
||||
}
|
||||
boolean visible = true;
|
||||
String txt = map.getString(R.string.monitoring_control_start);
|
||||
String subtxt = null;
|
||||
Drawable d = monitoringInactive;
|
||||
|
@ -203,7 +202,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
}, 500);
|
||||
}
|
||||
updateVisibility(visible);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -215,7 +215,6 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
|||
private Drawable blinkImg;
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
boolean visible = true;
|
||||
String txt = "OsMo";
|
||||
String subtxt = "";
|
||||
SessionInfo si = getService().getCurrentSessionInfo();
|
||||
|
@ -258,7 +257,6 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
|||
blink(big, small);
|
||||
}
|
||||
|
||||
updateVisibility(visible);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,10 @@ import net.osmand.plus.dialogs.ConfigureMapMenu;
|
|||
import net.osmand.plus.views.mapwidgets.BaseMapWidget;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
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.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
@ -96,17 +97,13 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
alarmControl = ric.createAlarmInfoControl(app, map);
|
||||
// register left stack
|
||||
// FIXME TODO LEFT STACK
|
||||
// RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
// NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(routingHelper, app, view.getSettings(), false);
|
||||
// mapInfoControls.registerSideWidget(bigInfoControl, R.drawable.widget_next_turn, R.drawable.widget_next_turn, R.string.map_widget_next_turn,"next_turn", true, 5);
|
||||
// NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(routingHelper, app, view.getSettings(),
|
||||
// paintSmallText, paintSmallSubText, true);
|
||||
// mapInfoControls.registerSideWidget(smallInfoControl, R.drawable.widget_next_turn, R.drawable.widget_next_turn, R.string.map_widget_next_turn_small, "next_turn_small", true,
|
||||
// 10);
|
||||
// NextTurnInfoWidget nextNextInfoControl = ric.createNextNextInfoControl(routingHelper, app, view.getSettings(),
|
||||
// paintSmallText, paintSmallSubText, true);
|
||||
// mapInfoControls.registerSideWidget(nextNextInfoControl, R.drawable.widget_next_turn, R.drawable.widget_next_turn, R.string.map_widget_next_next_turn, "next_next_turn",true, 15);
|
||||
NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(map, app, false);
|
||||
mapInfoControls.registerSideWidget(bigInfoControl, R.drawable.widget_next_turn, R.drawable.widget_next_turn, R.string.map_widget_next_turn,"next_turn", true, 5);
|
||||
NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(map, app, true);
|
||||
mapInfoControls.registerSideWidget(smallInfoControl, R.drawable.widget_next_turn, R.drawable.widget_next_turn, R.string.map_widget_next_turn_small, "next_turn_small", true,
|
||||
10);
|
||||
NextTurnInfoWidget nextNextInfoControl = ric.createNextNextInfoControl(map, app, true);
|
||||
mapInfoControls.registerSideWidget(nextNextInfoControl, R.drawable.widget_next_turn, R.drawable.widget_next_turn, R.string.map_widget_next_next_turn, "next_next_turn",true, 15);
|
||||
// right stack
|
||||
TextInfoWidget intermediateDist = ric.createIntermediateDistanceControl(map);
|
||||
registerSideWidget(intermediateDist, R.drawable.widget_intermediate, R.drawable.widget_intermediate, R.string.map_widget_intermediate_distance, "intermediate_distance", false, 3);
|
||||
|
|
|
@ -258,8 +258,10 @@ public class MapWidgetRegistry {
|
|||
public void addControls(MapInfoLayer mil, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||
cm.item(R.string.map_widget_right).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
addControls(mil, cm, right, mode);
|
||||
if(mode != ApplicationMode.DEFAULT) {
|
||||
cm.item(R.string.map_widget_left).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
addControls(mil, cm, left, mode);
|
||||
}
|
||||
cm.item(R.string.map_widget_appearance_rem).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
addControlsAppearance(mil, cm, mode);
|
||||
}
|
||||
|
|
|
@ -3,52 +3,116 @@ package net.osmand.plus.views.mapwidgets;
|
|||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.TurnPathHelper;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
|
||||
|
||||
public class NextTurnInfoWidget extends BaseMapWidget {
|
||||
public class NextTurnInfoWidget extends TextInfoWidget {
|
||||
|
||||
private final float scaleCoefficient;
|
||||
private float width;
|
||||
private float height ;
|
||||
private static final float miniCoeff = 2.5f;
|
||||
|
||||
protected double deviatedPath = 0;
|
||||
|
||||
protected Path pathForTurn = new Path();
|
||||
|
||||
protected TurnType turnType = null;
|
||||
protected String exitOut = null;
|
||||
protected int nextTurnDirection = 0;
|
||||
|
||||
|
||||
protected Paint textPaint;
|
||||
protected Paint subtextPaint;
|
||||
private Paint paintBlack;
|
||||
private Paint paintRouteDirection;
|
||||
|
||||
protected boolean deviatedFromRoute;
|
||||
protected int turnImminent;
|
||||
protected boolean horisontalMini;
|
||||
|
||||
public NextTurnInfoWidget(Context ctx, Paint textPaint, Paint subtextPaint, boolean horisontalMini,
|
||||
protected int deviatedPath = 0;
|
||||
protected int nextTurnDistance = 0;
|
||||
|
||||
private TurnDrawable turnDrawable;
|
||||
private OsmandApplication app;
|
||||
|
||||
|
||||
public NextTurnInfoWidget(Activity activity, OsmandApplication app, boolean horisontalMini,
|
||||
float scaleCoefficient) {
|
||||
super(ctx);
|
||||
this.textPaint = textPaint;
|
||||
this.subtextPaint = subtextPaint;
|
||||
this.scaleCoefficient = scaleCoefficient;
|
||||
super(activity);
|
||||
this.app = app;
|
||||
this.horisontalMini = horisontalMini;
|
||||
turnDrawable = new TurnDrawable(activity);
|
||||
if(horisontalMini) {
|
||||
setImageDrawable(turnDrawable);
|
||||
} else {
|
||||
setTopImageDrawable(turnDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
public TurnType getTurnType() {
|
||||
return turnDrawable.turnType;
|
||||
}
|
||||
|
||||
public void setTurnType(TurnType turnType) {
|
||||
if (!Algorithms.objectEquals(getTurnType(), turnType)) {
|
||||
turnDrawable.setTurnType(turnType);
|
||||
invalidateImageViews();
|
||||
}
|
||||
updateVisibility(turnType != null);
|
||||
}
|
||||
|
||||
public void setTurnImminent(int turnImminent, boolean deviatedFromRoute) {
|
||||
if(turnDrawable.turnImminent != turnImminent || turnDrawable.deviatedFromRoute != deviatedFromRoute) {
|
||||
turnDrawable.setTurnImminent(turnImminent, deviatedFromRoute);
|
||||
updateDistance();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDeviatePath(int deviatePath) {
|
||||
if (RouteInfoWidgetsFactory.distChanged(deviatePath, this.deviatedPath)) {
|
||||
this.deviatedPath = deviatePath;
|
||||
updateDistance();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTurnDistance(int nextTurnDistance) {
|
||||
if (RouteInfoWidgetsFactory.distChanged(nextTurnDistance, this.nextTurnDistance)) {
|
||||
this.nextTurnDistance = nextTurnDistance;
|
||||
updateDistance();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDistance() {
|
||||
int deviatePath = turnDrawable.deviatedFromRoute ? deviatedPath : nextTurnDistance;
|
||||
String ds = OsmAndFormatter.getFormattedDistance(deviatePath, app);
|
||||
int ls = ds.lastIndexOf(' ');
|
||||
if (ls == -1) {
|
||||
setText(ds, null);
|
||||
} else {
|
||||
setText(ds.substring(0, ls), ds.substring(ls + 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void setExitOut(int exit) {
|
||||
// TODO exit
|
||||
// if(turnDrawable.exitOut != exit) {
|
||||
// turnDrawable.e
|
||||
// }
|
||||
// TODO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class TurnDrawable extends Drawable {
|
||||
protected Paint paintBlack;
|
||||
protected Paint paintRouteDirection;
|
||||
protected Path pathForTurn = new Path();
|
||||
protected TurnType turnType = null;
|
||||
protected int turnImminent;
|
||||
protected boolean deviatedFromRoute;
|
||||
private Context ctx;
|
||||
|
||||
public TurnDrawable(Context ctx) {
|
||||
this.ctx = ctx;
|
||||
paintBlack = new Paint();
|
||||
paintBlack.setStyle(Style.STROKE);
|
||||
paintBlack.setColor(Color.BLACK);
|
||||
|
@ -57,100 +121,66 @@ public class NextTurnInfoWidget extends BaseMapWidget {
|
|||
|
||||
paintRouteDirection = new Paint();
|
||||
paintRouteDirection.setStyle(Style.FILL);
|
||||
paintRouteDirection.setColor(getResources().getColor(R.color.nav_arrow));
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow));
|
||||
paintRouteDirection.setAntiAlias(true);
|
||||
|
||||
pathTransform = new Matrix();
|
||||
updateHorisontalMini(horisontalMini);
|
||||
|
||||
}
|
||||
|
||||
protected void updateHorisontalMini(boolean horisontalMini) {
|
||||
this.horisontalMini = horisontalMini;
|
||||
if (horisontalMini) {
|
||||
pathTransform.postScale(scaleCoefficient / miniCoeff, scaleCoefficient / miniCoeff);
|
||||
width = 72 * scaleCoefficient / miniCoeff;
|
||||
height = 72 * scaleCoefficient / miniCoeff;
|
||||
} else {
|
||||
pathTransform.postScale(scaleCoefficient, scaleCoefficient);
|
||||
width = 72 * scaleCoefficient;
|
||||
height = 72 * scaleCoefficient;
|
||||
}
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
|
||||
protected Matrix pathTransform = new Matrix();
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int h = 0;
|
||||
int w = 0;
|
||||
if (!horisontalMini) {
|
||||
h = (int) (8 * scaleCoefficient + Math.max(textPaint.getTextSize(), subtextPaint.getTextSize()));
|
||||
} else {
|
||||
h = (int) (7 * scaleCoefficient);
|
||||
w = (int) textPaint.measureText(OsmAndFormatter.getFormattedDistance(nextTurnDirection, getClientContext()));
|
||||
}
|
||||
setWDimensions((int) width + w, (int) height + h);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
if (pathForTurn != null) {
|
||||
//if user deviates from route that we should draw grey arrow
|
||||
if (deviatedFromRoute){
|
||||
paintRouteDirection.setColor(getResources().getColor(R.color.nav_arrow_distant));
|
||||
} else if (turnImminent > 0) {
|
||||
paintRouteDirection.setColor(getResources().getColor(R.color.nav_arrow));
|
||||
} else if (turnImminent == 0) {
|
||||
paintRouteDirection.setColor(getResources().getColor(R.color.nav_arrow_imminent));
|
||||
} else {
|
||||
paintRouteDirection.setColor(getResources().getColor(R.color.nav_arrow_distant));
|
||||
Matrix m = new Matrix();
|
||||
m.setScale(bounds.width() / 72f, bounds.height() / 72f);
|
||||
pathForTurn.transform(m, pathForTurn);
|
||||
}
|
||||
// small indent
|
||||
canvas.translate(0, 3 * scaleCoefficient);
|
||||
}
|
||||
|
||||
public void setTurnImminent(int turnImminent, boolean deviatedFromRoute) {
|
||||
//if user deviates from route that we should draw grey arrow
|
||||
this.turnImminent = turnImminent;
|
||||
this.deviatedFromRoute = deviatedFromRoute;
|
||||
if (deviatedFromRoute){
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
|
||||
} else if (turnImminent > 0) {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow));
|
||||
} else if (turnImminent == 0) {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_imminent));
|
||||
} else {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
/// small indent
|
||||
// canvas.translate(0, 3 * scaleCoefficient);
|
||||
canvas.drawPath(pathForTurn, paintRouteDirection);
|
||||
canvas.drawPath(pathForTurn, paintBlack);
|
||||
if (exitOut != null && !horisontalMini && !deviatedFromRoute) {
|
||||
drawShadowText(canvas, exitOut, width / 2 - 7 * scaleCoefficient,
|
||||
height / 2 + textPaint.getTextSize() / 2 - 3 * scaleCoefficient, textPaint);
|
||||
}
|
||||
String text = OsmAndFormatter.getFormattedDistance(nextTurnDirection, getClientContext());
|
||||
String subtext = null;
|
||||
|
||||
if (deviatedFromRoute) {
|
||||
text = OsmAndFormatter.getFormattedDistance((float) deviatedPath, (OsmandApplication)getContext().getApplicationContext());
|
||||
}
|
||||
|
||||
int ls = text.lastIndexOf(' ');
|
||||
float st = 0;
|
||||
if (ls != -1) {
|
||||
subtext = text.substring(ls + 1);
|
||||
text = text.substring(0, ls);
|
||||
st = textPaint.measureText(subtext);
|
||||
}
|
||||
float mt = textPaint.measureText(text);
|
||||
if (!horisontalMini) {
|
||||
float startX = Math.max((getWWidth() - st - mt) / 2, 2 * scaleCoefficient);
|
||||
drawShadowText(canvas, text, startX, getWHeight() - 5 * scaleCoefficient, textPaint);
|
||||
if (subtext != null) {
|
||||
drawShadowText(canvas, subtext, startX + 2 * scaleCoefficient + mt, getWHeight() - 5 * scaleCoefficient, subtextPaint);
|
||||
}
|
||||
} else {
|
||||
drawShadowText(canvas, text, 72 * scaleCoefficient / miniCoeff + 2 * scaleCoefficient,
|
||||
height / 2 + 7 * scaleCoefficient, textPaint);
|
||||
if (subtext != null) {
|
||||
drawShadowText(canvas, subtext, 72 * scaleCoefficient / miniCoeff + mt
|
||||
+ 2 * scaleCoefficient, height / 2 + 7 * scaleCoefficient, subtextPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
return false;
|
||||
public void setAlpha(int alpha) {
|
||||
paintRouteDirection.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
paintRouteDirection.setColorFilter(cf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setTurnType(TurnType turnType) {
|
||||
this.turnType = turnType;
|
||||
if(turnType != null) {
|
||||
TurnPathHelper.calcTurnPath(pathForTurn, turnType, null);
|
||||
onBoundsChange(getBounds());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ import net.osmand.plus.views.TurnPathHelper;
|
|||
import net.osmand.plus.views.controls.MapRouteInfoControl;
|
||||
import net.osmand.router.RouteResultPreparation;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -53,59 +53,40 @@ public class RouteInfoWidgetsFactory {
|
|||
this.scaleCoefficient = scaleCoefficient;
|
||||
}
|
||||
|
||||
public NextTurnInfoWidget createNextInfoControl(final RoutingHelper routingHelper, final OsmandApplication ctx,
|
||||
final OsmandSettings settings, Paint textPaint, Paint subtextPaint, boolean horisontalMini) {
|
||||
final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(ctx, textPaint, subtextPaint, horisontalMini, scaleCoefficient) {
|
||||
public NextTurnInfoWidget createNextInfoControl(final Activity activity,
|
||||
final OsmandApplication app, boolean horisontalMini) {
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(activity, app, horisontalMini, scaleCoefficient) {
|
||||
NextDirectionInfo calc1 = new NextDirectionInfo();
|
||||
TurnType straight = TurnType.straight();
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
boolean visible = false;
|
||||
boolean followingMode = routingHelper.isFollowingMode() || ctx.getLocationProvider().getLocationSimulation().isRouteAnimating();
|
||||
boolean followingMode = routingHelper.isFollowingMode() || app.getLocationProvider().getLocationSimulation().isRouteAnimating();
|
||||
TurnType turnType = null;
|
||||
boolean deviatedFromRoute = false;
|
||||
int turnImminent = 0;
|
||||
int nextTurnDistance = 0;
|
||||
if (routingHelper != null && routingHelper.isRouteCalculated() && followingMode) {
|
||||
deviatedFromRoute = routingHelper.isDeviatedFromRoute() ;
|
||||
|
||||
if (deviatedFromRoute) {
|
||||
visible = true;
|
||||
turnImminent = 0;
|
||||
turnType = TurnType.valueOf(TurnType.OFFR, settings.DRIVING_REGION.get().leftHandDriving);
|
||||
TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform);
|
||||
deviatedPath = routingHelper.getRouteDeviation();
|
||||
invalidate();
|
||||
setDeviatePath((int) routingHelper.getRouteDeviation());
|
||||
} else {
|
||||
boolean showStraight = false;
|
||||
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
||||
if (r != null && r.distanceTo > 0) {
|
||||
visible = true;
|
||||
if (r.directionInfo == null) {
|
||||
if (turnType != null) {
|
||||
turnType = null;
|
||||
invalidate();
|
||||
}
|
||||
} else if (!Algorithms.objectEquals(turnType, showStraight ? straight : r.directionInfo.getTurnType())) {
|
||||
turnType = showStraight ? straight : r.directionInfo.getTurnType();
|
||||
TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform);
|
||||
if (turnType.getExitOut() > 0) {
|
||||
exitOut = turnType.getExitOut() + ""; //$NON-NLS-1$
|
||||
} else {
|
||||
exitOut = null;
|
||||
}
|
||||
requestLayout();
|
||||
invalidate();
|
||||
}
|
||||
if (distChanged(r.distanceTo, nextTurnDirection)) {
|
||||
invalidate();
|
||||
requestLayout();
|
||||
nextTurnDirection = r.distanceTo;
|
||||
}
|
||||
if (turnImminent != r.imminent) {
|
||||
if (r != null && r.distanceTo > 0 && r.directionInfo != null) {
|
||||
turnType = r.directionInfo.getTurnType();
|
||||
setExitOut(turnType.getExitOut());
|
||||
nextTurnDistance = r.distanceTo;
|
||||
turnImminent = r.imminent;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateVisibility(visible);
|
||||
setTurnType(turnType);
|
||||
setTurnImminent(turnImminent, deviatedFromRoute);
|
||||
setTurnDistance(nextTurnDistance);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -130,31 +111,31 @@ public class RouteInfoWidgetsFactory {
|
|||
// nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3;
|
||||
// nextTurnInfo.nextTurnDirection = 580;
|
||||
// TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, nextTurnInfo.turnType,nextTurnInfo.pathTransform);
|
||||
// showMiniMap = true;
|
||||
if(routingHelper.isRouteCalculated()) {
|
||||
routingHelper.getVoiceRouter().announceCurrentDirection(null);
|
||||
}
|
||||
nextTurnInfo.requestLayout();
|
||||
nextTurnInfo.invalidate();
|
||||
}
|
||||
});
|
||||
// initial state
|
||||
nextTurnInfo.setVisibility(View.GONE);
|
||||
return nextTurnInfo;
|
||||
}
|
||||
|
||||
public NextTurnInfoWidget createNextNextInfoControl(final RoutingHelper routingHelper, final OsmandApplication ctx,
|
||||
final OsmandSettings settings, Paint textPaint, Paint subtextPaint, boolean horisontalMini) {
|
||||
final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(ctx, textPaint, subtextPaint, horisontalMini, scaleCoefficient) {
|
||||
public NextTurnInfoWidget createNextNextInfoControl(final Activity activity,
|
||||
final OsmandApplication app, boolean horisontalMini) {
|
||||
final RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(activity, app, horisontalMini, scaleCoefficient) {
|
||||
NextDirectionInfo calc1 = new NextDirectionInfo();
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
boolean visible = false;
|
||||
boolean followingMode = routingHelper.isFollowingMode() || ctx.getLocationProvider().getLocationSimulation().isRouteAnimating();
|
||||
boolean followingMode = routingHelper.isFollowingMode() || app.getLocationProvider().getLocationSimulation().isRouteAnimating();
|
||||
TurnType turnType = null;
|
||||
boolean deviatedFromRoute = false;
|
||||
int turnImminent = 0;
|
||||
int nextTurnDistance = 0;
|
||||
if (routingHelper != null && routingHelper.isRouteCalculated() && followingMode) {
|
||||
boolean devitedFromRoute = routingHelper.isDeviatedFromRoute() ;
|
||||
deviatedFromRoute = routingHelper.isDeviatedFromRoute() ;
|
||||
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
||||
if (!devitedFromRoute) {
|
||||
if (!deviatedFromRoute) {
|
||||
if (r != null) {
|
||||
// next turn is very close (show next next with false to speak)
|
||||
// if (r.imminent >= 0 && r.imminent < 2) {
|
||||
|
@ -167,33 +148,15 @@ public class RouteInfoWidgetsFactory {
|
|||
// }
|
||||
}
|
||||
}
|
||||
if (r != null && r.distanceTo > 0) {
|
||||
visible = true;
|
||||
if (r == null || r.directionInfo == null) {
|
||||
if (turnType != null) {
|
||||
turnType = null;
|
||||
invalidate();
|
||||
}
|
||||
} else if (!Algorithms.objectEquals(turnType, r.directionInfo.getTurnType())) {
|
||||
if (r != null && r.distanceTo > 0&& r.directionInfo != null) {
|
||||
turnType = r.directionInfo.getTurnType();
|
||||
TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform);
|
||||
invalidate();
|
||||
requestLayout();
|
||||
}
|
||||
if (distChanged(r.distanceTo, nextTurnDirection)) {
|
||||
invalidate();
|
||||
requestLayout();
|
||||
nextTurnDirection = r.distanceTo;
|
||||
}
|
||||
int imminent = r.imminent;
|
||||
if (turnImminent != imminent) {
|
||||
turnImminent = imminent;
|
||||
invalidate();
|
||||
turnImminent = r.imminent;
|
||||
nextTurnDistance = r.distanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
updateVisibility(visible);
|
||||
|
||||
setTurnType(turnType);
|
||||
setTurnImminent(turnImminent, deviatedFromRoute);
|
||||
setTurnDistance(nextTurnDistance);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -221,10 +184,14 @@ public class RouteInfoWidgetsFactory {
|
|||
}
|
||||
});
|
||||
// initial state
|
||||
nextTurnInfo.setVisibility(View.GONE);
|
||||
return nextTurnInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public TextInfoWidget createTimeControl(final MapActivity map){
|
||||
final RoutingHelper routingHelper = map.getRoutingHelper();
|
||||
final Drawable time = map.getResources().getDrawable(R.drawable.widget_time);
|
||||
|
|
|
@ -17,11 +17,14 @@ public class TextInfoWidget {
|
|||
private ImageView imageView;
|
||||
private TextView textView;
|
||||
private TextView smallTextView;
|
||||
private ImageView topImageView;
|
||||
|
||||
private boolean explicitlyVisible;
|
||||
|
||||
|
||||
public TextInfoWidget(Activity activity) {
|
||||
view = activity.getLayoutInflater().inflate(R.layout.map_hud_widget, null);
|
||||
topImageView = (ImageView) view.findViewById(R.id.widget_top_icon);
|
||||
imageView = (ImageView) view.findViewById(R.id.widget_icon);
|
||||
textView = (TextView) view.findViewById(R.id.widget_text);
|
||||
smallTextView = (TextView) view.findViewById(R.id.widget_text_small);
|
||||
|
@ -41,6 +44,23 @@ public class TextInfoWidget {
|
|||
imageView.invalidate();
|
||||
}
|
||||
|
||||
public void setTopImageDrawable(Drawable imageDrawable) {
|
||||
if(imageDrawable != null) {
|
||||
topImageView.setImageDrawable(imageDrawable);
|
||||
topImageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
topImageView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
topImageView.invalidate();
|
||||
}
|
||||
|
||||
protected void invalidateImageViews() {
|
||||
topImageView.invalidate();
|
||||
imageView.invalidate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setContentDescription(CharSequence text) {
|
||||
if (contentTitle != null) {
|
||||
view.setContentDescription(contentTitle + " " + text); //$NON-NLS-1$
|
||||
|
|
Loading…
Reference in a new issue