shields in top bar
This commit is contained in:
parent
b14c41ddd0
commit
3ce2f41d9e
9 changed files with 190 additions and 183 deletions
|
@ -5,10 +5,6 @@ public class ExitInfo {
|
|||
|
||||
private String ref;
|
||||
|
||||
private String shieldName;
|
||||
|
||||
private String shieldIconName;
|
||||
|
||||
private String exitStreetName;
|
||||
|
||||
public String getRef() {
|
||||
|
@ -19,14 +15,6 @@ public class ExitInfo {
|
|||
this.ref = ref;
|
||||
}
|
||||
|
||||
public String getShieldName() {
|
||||
return shieldName;
|
||||
}
|
||||
|
||||
public void setShieldName(String shieldName) {
|
||||
this.shieldName = shieldName;
|
||||
}
|
||||
|
||||
public String getExitStreetName() {
|
||||
return exitStreetName;
|
||||
}
|
||||
|
@ -34,12 +22,4 @@ public class ExitInfo {
|
|||
public void setExitStreetName(String exitStreetName) {
|
||||
this.exitStreetName = exitStreetName;
|
||||
}
|
||||
|
||||
public String getShieldIconName() {
|
||||
return shieldIconName;
|
||||
}
|
||||
|
||||
public void setShieldIconName(String shieldIconName) {
|
||||
this.shieldIconName = shieldIconName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -364,22 +364,12 @@
|
|||
android:scaleType="fitCenter"
|
||||
tools:src="@drawable/map_turn_right_small" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/map_exit_shield_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:padding="@dimen/content_padding_half"
|
||||
android:textColor="@color/color_black"
|
||||
tools:background="@drawable/h_white_pillow_4_road_shield"
|
||||
tools:text="S108" />
|
||||
<ImageView
|
||||
android:id="@+id/map_shield_icon"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitCenter"
|
||||
tools:src="@drawable/h_white_pillow_2_road_shield" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -412,8 +402,6 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -126,11 +126,11 @@
|
|||
android:id="@+id/map_exit_ref"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/map_widget_text_size"
|
||||
android:background="@drawable/bg_topbar_shield_exit_ref"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/map_widget_height"
|
||||
android:background="@drawable/bg_topbar_shield_exit_ref"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/map_widget_text_size"
|
||||
android:visibility="gone"
|
||||
tools:text="8"
|
||||
tools:visibility="visible" />
|
||||
|
@ -142,55 +142,43 @@
|
|||
android:scaleType="fitCenter"
|
||||
tools:src="@drawable/map_turn_right_small" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/map_shield_icon"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitCenter"
|
||||
tools:src="@drawable/h_white_pillow_2_road_shield" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/map_exit_shield_name"
|
||||
android:id="@+id/map_address_text_shadow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:padding="@dimen/content_padding_half"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="end"
|
||||
android:importantForAccessibility="no"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/color_black"
|
||||
tools:background="@drawable/h_white_pillow_4_road_shield"
|
||||
tools:text="S108" />
|
||||
android:textSize="@dimen/map_widget_text_size"
|
||||
tools:text="Long Street Name" />
|
||||
|
||||
<FrameLayout
|
||||
<TextView
|
||||
android:id="@+id/map_address_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/color_black"
|
||||
android:textSize="@dimen/map_widget_text_size"
|
||||
tools:text="Long Street Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/map_address_text_shadow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="end"
|
||||
android:importantForAccessibility="no"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/color_black"
|
||||
android:textSize="@dimen/map_widget_text_size"
|
||||
tools:text="Long Street Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/map_address_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/color_black"
|
||||
android:textSize="@dimen/map_widget_text_size"
|
||||
tools:text="Long Street Name" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class TextRenderer {
|
|||
private Typeface italicTypeface;
|
||||
private Typeface boldTypeface;
|
||||
|
||||
static class TextDrawInfo {
|
||||
public static class TextDrawInfo {
|
||||
|
||||
public TextDrawInfo(String text) {
|
||||
this.text = text;
|
||||
|
@ -288,7 +288,7 @@ public class TextRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void drawShieldIcon(RenderingContext rc, Canvas cv, TextDrawInfo text, String sr) {
|
||||
public void drawShieldIcon(RenderingContext rc, Canvas cv, TextDrawInfo text, String sr) {
|
||||
if (sr != null) {
|
||||
float coef = rc.getDensityValue(rc.screenDensityRatio * rc.textScale);
|
||||
Bitmap ico = RenderingIcons.getIcon(context, sr, true);
|
||||
|
@ -308,7 +308,7 @@ public class TextRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void drawWrappedText(Canvas cv, TextDrawInfo text, float textSize) {
|
||||
public void drawWrappedText(Canvas cv, TextDrawInfo text, float textSize) {
|
||||
if (text.textWrap == 0) {
|
||||
// set maximum for all text
|
||||
text.textWrap = 40;
|
||||
|
|
|
@ -322,37 +322,35 @@ public class RouteCalculationResult {
|
|||
info.routeEndPointOffset = roundAboutEnd;
|
||||
}
|
||||
RouteSegmentResult next = list.get(lind);
|
||||
info.setRef(next.getObject().getRef(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), next.isForwardDirection()));
|
||||
String ref = next.getObject().getRef(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), next.isForwardDirection());
|
||||
info.setRef(ref);
|
||||
info.setStreetName(next.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get()));
|
||||
info.setDestinationName(next.getObject().getDestinationName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), next.isForwardDirection()));
|
||||
|
||||
// Search for nearest shield properties
|
||||
for (int j = lind; j < list.size(); j++) {
|
||||
RouteSegmentResult segment = list.get(j);
|
||||
String segmentRef = segment.getObject().getRef("", false,
|
||||
segment.isForwardDirection());
|
||||
// if it's the same road
|
||||
if (segmentRef != null && segmentRef.equals(ref)) {
|
||||
String shieldColor = segment.getObject().getShieldColor();
|
||||
String shieldShape = segment.getObject().getShieldShape();
|
||||
if (shieldColor != null || shieldShape != null) {
|
||||
info.setShieldColor(shieldColor != null ? shieldColor : "white");
|
||||
info.setShieldShape(shieldShape != null ? shieldShape : "square");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (s.getObject().isExitPoint() && next.getObject().isMotorWayLink()) {
|
||||
ExitInfo exitInfo = new ExitInfo();
|
||||
exitInfo.setRef(next.getObject().getExitRef());
|
||||
exitInfo.setExitStreetName(next.getObject().getExitName());
|
||||
String shieldName = next.getObject().getDestinationRef(next.isForwardDirection());
|
||||
exitInfo.setShieldName(shieldName);
|
||||
|
||||
// Search for nearest shield properties
|
||||
for (int j = lind; j < list.size(); j++) {
|
||||
RouteSegmentResult segment = list.get(j);
|
||||
String segmentRef = segment.getObject().getRef("", false, segment.isForwardDirection());
|
||||
// if it's the same road
|
||||
if (segmentRef != null && segmentRef.equals(shieldName)) {
|
||||
String shieldColor = segment.getObject().getShieldColor();
|
||||
String shieldShape = segment.getObject().getShieldShape();
|
||||
if (shieldColor != null || shieldShape != null) {
|
||||
exitInfo.setShieldIconName((shieldColor != null ? shieldColor : "white")
|
||||
+ "_"
|
||||
+ (shieldShape != null ? shieldShape : "square")
|
||||
+ "_"
|
||||
+ shieldName.length() + "_" + "road_shield");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
info.setExitInfo(exitInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,10 @@ public class RouteDirectionInfo {
|
|||
|
||||
private String destinationName;
|
||||
|
||||
private String shieldColor;
|
||||
|
||||
private String shieldShape;
|
||||
|
||||
@Nullable
|
||||
private ExitInfo exitInfo;
|
||||
|
||||
|
@ -121,4 +125,20 @@ public class RouteDirectionInfo {
|
|||
public void setExitInfo(@Nullable ExitInfo exitInfo) {
|
||||
this.exitInfo = exitInfo;
|
||||
}
|
||||
|
||||
public String getShieldColor() {
|
||||
return shieldColor;
|
||||
}
|
||||
|
||||
public void setShieldColor(String shieldColor) {
|
||||
this.shieldColor = shieldColor;
|
||||
}
|
||||
|
||||
public String getShieldShape() {
|
||||
return shieldShape;
|
||||
}
|
||||
|
||||
public void setShieldShape(String shieldShape) {
|
||||
this.shieldShape = shieldShape;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -825,8 +825,7 @@ public class RoutingHelper {
|
|||
// return false;
|
||||
// }
|
||||
|
||||
public synchronized String getCurrentName(TurnType[] next){
|
||||
NextDirectionInfo n = getNextRouteDirectionInfo(new NextDirectionInfo(), true);
|
||||
public synchronized String getCurrentName(TurnType[] next, NextDirectionInfo n) {
|
||||
Location l = lastFixedLocation;
|
||||
float speed = 0;
|
||||
if(l != null && l.hasSpeed()) {
|
||||
|
@ -835,12 +834,12 @@ public class RoutingHelper {
|
|||
if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() &&
|
||||
voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f, 0f)) {
|
||||
String nm = n.directionInfo.getStreetName();
|
||||
String rf = n.directionInfo.getRef();
|
||||
// String rf = n.directionInfo.getRef();
|
||||
String dn = n.directionInfo.getDestinationName();
|
||||
if(next != null) {
|
||||
next[0] = n.directionInfo.getTurnType();
|
||||
}
|
||||
return formatStreetName(nm, rf, dn, "»");
|
||||
return formatStreetName(nm, null, dn, "»");
|
||||
}
|
||||
RouteSegmentResult rs = getCurrentSegmentResult();
|
||||
if(rs != null) {
|
||||
|
@ -864,10 +863,10 @@ public class RoutingHelper {
|
|||
|
||||
private String getRouteSegmentStreetName(RouteSegmentResult rs) {
|
||||
String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get());
|
||||
String rf = rs.getObject().getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
||||
// String rf = rs.getObject().getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
||||
String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get(),
|
||||
settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
||||
return formatStreetName(nm, rf, dn, "»");
|
||||
return formatStreetName(nm, null, dn, "»");
|
||||
}
|
||||
|
||||
public RouteSegmentResult getCurrentSegmentResult() {
|
||||
|
|
|
@ -626,7 +626,7 @@ public class VoiceRouter {
|
|||
return new StreetName(result);
|
||||
}
|
||||
|
||||
private StreetName getSpeakableExitName(ExitInfo exitInfo, boolean includeDest) {
|
||||
private StreetName getSpeakableExitName(RouteDirectionInfo routeInfo, ExitInfo exitInfo, boolean includeDest) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
if (exitInfo == null || !router.getSettings().SPEAK_STREET_NAMES.get()) {
|
||||
return new StreetName(result);
|
||||
|
@ -634,7 +634,7 @@ public class VoiceRouter {
|
|||
if (player != null && player.supportsStructuredStreetNames()) {
|
||||
result.put(TO_REF, getNonNullString(getSpeakablePointName(exitInfo.getRef())));
|
||||
result.put(TO_STREET_NAME, getNonNullString(getSpeakablePointName(exitInfo.getExitStreetName())));
|
||||
result.put(TO_DEST, includeDest ? getNonNullString(getSpeakablePointName(exitInfo.getShieldName())) : "");
|
||||
result.put(TO_DEST, includeDest ? getNonNullString(getSpeakablePointName(routeInfo.getRef())) : "");
|
||||
} else {
|
||||
result.put(TO_REF, getNonNullString(getSpeakablePointName(exitInfo.getRef())));
|
||||
result.put(TO_STREET_NAME, getNonNullString(getSpeakablePointName(exitInfo.getExitStreetName())));
|
||||
|
@ -698,7 +698,7 @@ public class VoiceRouter {
|
|||
String lang = player.getLanguage();
|
||||
if (tParam != null) {
|
||||
if (exitInfo != null && (lang.startsWith("en") || lang.startsWith("ru"))) {
|
||||
p.takeExit(tParam, dist, getSpeakableExitName(exitInfo, true));
|
||||
p.takeExit(tParam, dist, getSpeakableExitName(next, exitInfo, true));
|
||||
} else {
|
||||
p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true));
|
||||
}
|
||||
|
@ -772,7 +772,7 @@ public class VoiceRouter {
|
|||
String lang = player.getLanguage();
|
||||
if (tParam != null) {
|
||||
if (exitInfo != null && (lang.startsWith("en") || lang.startsWith("ru"))) {
|
||||
p.takeExit(tParam, getSpeakableExitName(exitInfo, !suppressDest));
|
||||
p.takeExit(tParam, getSpeakableExitName(next, exitInfo, !suppressDest));
|
||||
} else {
|
||||
p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@ import android.annotation.SuppressLint;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorInt;
|
||||
|
@ -50,6 +53,8 @@ import net.osmand.plus.helpers.WaypointDialogHelper;
|
|||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.render.OsmandRenderer;
|
||||
import net.osmand.plus.render.TextRenderer;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.routepreparationmenu.ShowAlongTheRouteBottomSheet;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
|
@ -60,6 +65,8 @@ import net.osmand.plus.views.OsmandMapTileView;
|
|||
import net.osmand.plus.views.RulerControlLayer;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable;
|
||||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.router.ExitInfo;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -904,7 +911,7 @@ public class MapInfoWidgetsFactory {
|
|||
private TextView addressText;
|
||||
private TextView addressTextShadow;
|
||||
private TextView exitRefText;
|
||||
private TextView exitShield;
|
||||
private ImageView shieldIcon;
|
||||
private ImageView turnIcon;
|
||||
private OsmAndLocationProvider locationProvider;
|
||||
private WaypointHelper waypointHelper;
|
||||
|
@ -921,7 +928,7 @@ public class MapInfoWidgetsFactory {
|
|||
addressTextShadow = (TextView) map.findViewById(R.id.map_address_text_shadow);
|
||||
waypointInfoBar = map.findViewById(R.id.waypoint_info_bar);
|
||||
exitRefText = map.findViewById(R.id.map_exit_ref);
|
||||
exitShield = map.findViewById(R.id.map_exit_shield_name);
|
||||
shieldIcon = map.findViewById(R.id.map_shield_icon);
|
||||
turnIcon = map.findViewById(R.id.map_turn_icon);
|
||||
this.routingHelper = app.getRoutingHelper();
|
||||
locationProvider = app.getLocationProvider();
|
||||
|
@ -960,6 +967,7 @@ public class MapInfoWidgetsFactory {
|
|||
|
||||
public boolean updateInfo(DrawSettings d) {
|
||||
String text = null;
|
||||
String ref = null;
|
||||
TurnType[] type = new TurnType[1];
|
||||
boolean showNextTurn = false;
|
||||
boolean showMarker = this.showMarker;
|
||||
|
@ -967,31 +975,39 @@ public class MapInfoWidgetsFactory {
|
|||
ExitInfo exitInfo = null;
|
||||
|
||||
if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
|
||||
RouteCalculationResult.NextDirectionInfo nextDirectionInfo =
|
||||
routingHelper.getNextRouteDirectionInfo(new RouteCalculationResult.NextDirectionInfo(), false);
|
||||
if (nextDirectionInfo != null) {
|
||||
RouteDirectionInfo directionInfo = nextDirectionInfo.directionInfo;
|
||||
if (directionInfo != null && directionInfo.getExitInfo() != null) {
|
||||
exitInfo = directionInfo.getExitInfo();
|
||||
showExitInfo = true;
|
||||
} else {
|
||||
showExitInfo = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (routingHelper.isFollowingMode()) {
|
||||
if (settings.SHOW_STREET_NAME.get()) {
|
||||
text = routingHelper.getCurrentName(type);
|
||||
if (showExitInfo) {
|
||||
text = exitInfo.getExitStreetName();
|
||||
}
|
||||
if (text == null) {
|
||||
text = "";
|
||||
RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(
|
||||
new RouteCalculationResult.NextDirectionInfo(), true);
|
||||
|
||||
if (nextDirInfo != null) {
|
||||
RouteDirectionInfo directionInfo = nextDirInfo.directionInfo;
|
||||
|
||||
if (directionInfo != null && directionInfo.getExitInfo() != null) {
|
||||
exitInfo = directionInfo.getExitInfo();
|
||||
showExitInfo = true;
|
||||
} else {
|
||||
if (type[0] == null) {
|
||||
showMarker = true;
|
||||
showExitInfo = false;
|
||||
}
|
||||
|
||||
if (settings.SHOW_STREET_NAME.get()) {
|
||||
text = routingHelper.getCurrentName(type, nextDirInfo);
|
||||
if (showExitInfo) {
|
||||
text = exitInfo.getExitStreetName();
|
||||
}
|
||||
if (text == null) {
|
||||
text = "";
|
||||
} else {
|
||||
turnDrawable.setColor(R.color.nav_arrow);
|
||||
if (type[0] == null) {
|
||||
showMarker = true;
|
||||
} else {
|
||||
ref = directionInfo != null ? directionInfo.getRef() : null;
|
||||
if (ref != null) {
|
||||
setShield(shieldIcon, assembleShieldString(directionInfo.getShieldColor(),
|
||||
directionInfo.getShieldShape(), ref.length()), ref);
|
||||
}
|
||||
turnDrawable.setColor(R.color.nav_arrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1003,13 +1019,19 @@ public class MapInfoWidgetsFactory {
|
|||
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
|
||||
type[0] = next.getTurnType();
|
||||
turnDrawable.setColor(R.color.nav_arrow_distant);
|
||||
text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName(), "»");
|
||||
text = RoutingHelper.formatStreetName(next.getStreetName(), null, next.getDestinationName(), "»");
|
||||
ref = next.getRef();
|
||||
// if (next.distance > 0) {
|
||||
// text += " " + OsmAndFormatter.getFormattedDistance(next.distance, map.getMyApplication());
|
||||
// }
|
||||
if (text == null) {
|
||||
text = "";
|
||||
}
|
||||
if (ref != null) {
|
||||
setShield(shieldIcon, assembleShieldString(next.getShieldColor(),
|
||||
next.getShieldShape(),
|
||||
ref.length()), ref);
|
||||
}
|
||||
} else {
|
||||
text = null;
|
||||
}
|
||||
|
@ -1019,12 +1041,18 @@ public class MapInfoWidgetsFactory {
|
|||
RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
|
||||
if (rt != null) {
|
||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
ref = rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation));
|
||||
text = RoutingHelper.formatStreetName(
|
||||
rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()),
|
||||
rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||
null,
|
||||
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||
"»");
|
||||
}
|
||||
if (ref != null) {
|
||||
setShield(shieldIcon, assembleShieldString(rt.getShieldColor(),
|
||||
rt.getShieldShape(),
|
||||
ref.length()), ref);
|
||||
}
|
||||
if (text == null) {
|
||||
text = "";
|
||||
} else {
|
||||
|
@ -1055,53 +1083,27 @@ public class MapInfoWidgetsFactory {
|
|||
AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0);
|
||||
boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker;
|
||||
this.showMarker = showMarker;
|
||||
if (!showExitInfo) {
|
||||
int h = addressText.getHeight() / 4 * 3;
|
||||
if (h != turnDrawable.getBounds().bottom) {
|
||||
turnDrawable.setBounds(0, 0, h, h);
|
||||
}
|
||||
}
|
||||
if (showExitInfo) {
|
||||
addressTextShadow.setCompoundDrawables(null, null, null, null);
|
||||
addressText.setCompoundDrawables(null, null, null, null);
|
||||
turnIcon.setImageDrawable(turnDrawable);
|
||||
AndroidUiHelper.updateVisibility(turnIcon, true);
|
||||
String ref = exitInfo.getRef();
|
||||
if (!Algorithms.isEmpty(ref)){
|
||||
exitRefText.setText(ref);
|
||||
String exitRef = exitInfo.getRef();
|
||||
if (!Algorithms.isEmpty(exitRef)) {
|
||||
exitRefText.setText(exitRef);
|
||||
AndroidUiHelper.updateVisibility(exitRefText, true);
|
||||
}
|
||||
String shieldName = exitInfo.getShieldName();
|
||||
if (!Algorithms.isEmpty(shieldName)){
|
||||
exitShield.setText(shieldName);
|
||||
AndroidUiHelper.updateVisibility(exitShield, true);
|
||||
if (exitInfo.getShieldIconName() != null) {
|
||||
MapRenderRepositories mapRenderRepo = map.getMyApplication().getResourceManager().getRenderer();
|
||||
Drawable shield = mapRenderRepo.getRenderer().getShieldDrawable(exitInfo.getShieldIconName());
|
||||
exitShield.setBackgroundDrawable(shield);
|
||||
}
|
||||
}
|
||||
} else if (update) {
|
||||
if (type[0] != null) {
|
||||
addressTextShadow.setCompoundDrawables(turnDrawable, null, null, null);
|
||||
addressTextShadow.setCompoundDrawablePadding(4);
|
||||
addressText.setCompoundDrawables(turnDrawable, null, null, null);
|
||||
addressText.setCompoundDrawablePadding(4);
|
||||
AndroidUiHelper.updateVisibility(turnIcon, false);
|
||||
} else {
|
||||
AndroidUiHelper.updateVisibility(exitRefText, false);
|
||||
AndroidUiHelper.updateVisibility(exitShield, false);
|
||||
}
|
||||
} else {
|
||||
AndroidUiHelper.updateVisibility(exitRefText, false);
|
||||
}
|
||||
if (update) {
|
||||
if (type[0] != null) {
|
||||
turnIcon.setImageDrawable(turnDrawable);
|
||||
AndroidUiHelper.updateVisibility(turnIcon, true);
|
||||
} else if (showMarker) {
|
||||
Drawable marker = map.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance);
|
||||
addressTextShadow.setCompoundDrawablesWithIntrinsicBounds(marker, null, null, null);
|
||||
addressTextShadow.setCompoundDrawablePadding(4);
|
||||
addressText.setCompoundDrawablesWithIntrinsicBounds(marker, null, null, null);
|
||||
addressText.setCompoundDrawablePadding(4);
|
||||
AndroidUiHelper.updateVisibility(turnIcon, false);
|
||||
AndroidUiHelper.updateVisibility(exitShield, false);
|
||||
AndroidUiHelper.updateVisibility(exitRefText, false);
|
||||
turnIcon.setImageDrawable(marker);
|
||||
AndroidUiHelper.updateVisibility(turnIcon, true);
|
||||
} else {
|
||||
addressTextShadow.setCompoundDrawables(null, null, null, null);
|
||||
addressText.setCompoundDrawables(null, null, null, null);
|
||||
AndroidUiHelper.updateVisibility(turnIcon, false);
|
||||
}
|
||||
}
|
||||
if (!text.equals(addressText.getText().toString())) {
|
||||
|
@ -1113,6 +1115,38 @@ public class MapInfoWidgetsFactory {
|
|||
return false;
|
||||
}
|
||||
|
||||
private void setShield(ImageView view, String shield, String ref) {
|
||||
Context context = topBar.getContext();
|
||||
Bitmap bitmap = Bitmap.createBitmap(100, 50, Bitmap.Config.ARGB_4444);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
|
||||
MapRenderRepositories mapRenderRepo = map.getMyApplication().getResourceManager().getRenderer();
|
||||
OsmandApplication app = ((OsmandApplication) context.getApplicationContext());
|
||||
RenderingRulesStorage storage = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
boolean nightMode = app.getDaynightHelper().isNightMode();
|
||||
RenderingRuleSearchRequest renderingReq =
|
||||
mapRenderRepo.getSearchRequestWithAppliedCustomRules(storage, nightMode);
|
||||
|
||||
renderingReq.setInitialTagValueZoom("highway", "secondary", 15, null);
|
||||
// renderingReq.setIntFilter(renderingReq.ALL.R_TEXT_LENGTH, ref.length());
|
||||
// renderingReq.setStringFilter(renderingReq.ALL.R_NAME_TAG, tagName);
|
||||
|
||||
OsmandRenderer.RenderingContext rc = new OsmandRenderer.RenderingContext(context);
|
||||
TextRenderer textRenderer = new TextRenderer(context);
|
||||
TextRenderer.TextDrawInfo text = new TextRenderer.TextDrawInfo(ref);
|
||||
text.fillProperties(rc,renderingReq , 50, 25);
|
||||
textRenderer.drawShieldIcon(rc, canvas, text, shield);
|
||||
textRenderer.drawWrappedText(canvas, text, (float) 20);
|
||||
|
||||
BitmapDrawable shieldDrawable = new BitmapDrawable(context.getResources(), bitmap);
|
||||
view.setImageDrawable(shieldDrawable);
|
||||
}
|
||||
|
||||
private String assembleShieldString(String color, String shape, int length) {
|
||||
return (color != null ? color : "white") + "_"
|
||||
+ (shape != null ? shape : "square") + "_" + length + "_" + "road_shield";
|
||||
}
|
||||
|
||||
public boolean updateWaypoint() {
|
||||
final LocationPointWrapper pnt = waypointHelper.getMostImportantLocationPoint(null);
|
||||
boolean changed = this.lastPoint != pnt;
|
||||
|
|
Loading…
Reference in a new issue