road lanes in turn-by-turn & exit info in land

This commit is contained in:
Dmitriy Ruban 2019-12-12 18:49:07 +02:00
parent 6f86ec6e0a
commit 1f116ce9cc
5 changed files with 123 additions and 62 deletions

View file

@ -335,43 +335,86 @@
android:background="@drawable/btn_round"
android:minHeight="@dimen/map_address_height">
<FrameLayout
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/map_exit_ref"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
>
android:background="@drawable/bg_topbar_shield_exit_ref"
android:gravity="center"
android:minWidth="@dimen/map_widget_height"
android:textColor="@color/color_white"
android:textSize="@dimen/map_widget_text_size"
android:visibility="gone"
tools:text="8"
tools:visibility="visible" />
<ImageView
android:id="@+id/map_turn_icon"
android:layout_width="@dimen/map_widget_height"
android:layout_height="@dimen/map_widget_height"
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_address_text_shadow"
android:importantForAccessibility="no"
android:id="@+id/map_exit_shield_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
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"
android:textSize="@dimen/map_widget_text_size"
tools:text="Long Street Name">
</TextView>
tools:background="@drawable/h_white_pillow_4_road_shield"
tools:text="S108" />
<TextView
android:id="@+id/map_address_text"
<FrameLayout
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">
</TextView>
android:layout_height="wrap_content">
<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" />
</FrameLayout>
<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>
</LinearLayout>
<LinearLayout
android:id="@+id/waypoint_info_bar"

View file

@ -78,19 +78,36 @@
tools:text="@string/app_version"/>
</LinearLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/content_padding_half"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="@dimen/content_padding_half"
android:layout_weight="1"
android:textSize="@dimen/default_desc_text_size"
android:textColor="?android:textColorPrimary"
tools:text="Head Dmytrivska Street"
android:text=""/>
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text=""
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_desc_text_size"
tools:text="Head Dmytrivska Street" />
<ImageView
android:id="@+id/lanes"
android:layout_width="match_parent"
android:layout_height="18dp"
android:layout_marginTop="2dp"
android:scaleType="fitStart"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>

View file

@ -17,6 +17,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routepreparationmenu.RouteDetailsFragment;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.views.TurnPathHelper;
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory;
import net.osmand.util.Algorithms;
import java.util.List;
@ -67,13 +68,25 @@ public class RouteDirectionsCard extends BaseCard {
TextView timeLabel = (TextView) row.findViewById(R.id.time);
TextView cumulativeDistanceLabel = (TextView) row.findViewById(R.id.cumulative_distance);
TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
ImageView icon = (ImageView) row.findViewById(R.id.direction);
ImageView directionIcon = (ImageView) row.findViewById(R.id.direction);
ImageView lanesIcon = (ImageView) row.findViewById(R.id.lanes);
row.findViewById(R.id.divider).setVisibility(directionInfoIndex == directionsInfo.size() - 1 ? View.INVISIBLE : View.VISIBLE);
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(mapActivity.getResources(), true);
drawable.setColorFilter(new PorterDuffColorFilter(getActiveColor(), PorterDuff.Mode.SRC_ATOP));
drawable.setRouteType(model.getTurnType());
icon.setImageDrawable(drawable);
directionIcon.setImageDrawable(drawable);
int[] lanes = model.getTurnType().getLanes();
if (lanes != null){
RouteInfoWidgetsFactory.LanesDrawable lanesDrawable = new RouteInfoWidgetsFactory.LanesDrawable(mapActivity,1);
lanesDrawable.lanes = lanes;
lanesDrawable.isTurnByTurn = true;
lanesDrawable.isNightMode = nightMode;
lanesDrawable.updateBounds();
lanesIcon.setImageDrawable(lanesDrawable);
lanesIcon.setVisibility(View.VISIBLE);
}
label.setText(model.getDescriptionRoutePart());
if (model.distance > 0) {

View file

@ -335,25 +335,6 @@ public class RouteCalculationResult {
String shieldName = next.getObject().getDestinationRef(next.isForwardDirection());
exitInfo.setShieldName(shieldName);
RenderingRulesStorage currentRenderer = ctx.getRendererRegistry().getCurrentSelectedRenderer();
MapRenderRepositories maps = ctx.getResourceManager().getRenderer();
RenderingRuleSearchRequest request = maps.getSearchRequestWithAppliedCustomRules(currentRenderer, false);
request.setInitialTagValueZoom("highway", "secondary", 21, null);
request.setIntFilter(request.ALL.R_TEXT_LENGTH, shieldName.length());
request.setStringFilter(request.ALL.R_NAME_TAG, "road_ref_1");
request.setStringFilter(request.ALL.R_ADDITIONAL, "road_shield_shape_1=pillow");
// request.setStringFilter(request.ALL.R_ADDITIONAL, "pillow");
String shieldId = null;
if (request.search(RenderingRulesStorage.TEXT_RULES) && request.getFloatPropertyValue(request.ALL.R_TEXT_SIZE) > 0) {
if (request.isSpecified(request.ALL.R_TEXT_SHIELD)) {
shieldId = request.getStringPropertyValue(request.ALL.R_TEXT_SHIELD);
}
if (request.isSpecified(request.ALL.R_ICON)) {
shieldId = request.getStringPropertyValue(request.ALL.R_ICON);
}
ctx.showShortToastMessage(" textShield " + shieldId);
}
// Search for nearest shield properties
for (int j = lind; j < list.size(); j++) {
RouteSegmentResult segment = list.get(j);

View file

@ -875,9 +875,11 @@ public class RouteInfoWidgetsFactory {
}
private static class LanesDrawable extends Drawable {
int[] lanes = null;
public static class LanesDrawable extends Drawable {
public int[] lanes = null;
boolean imminent = false;
public boolean isTurnByTurn = false;
public boolean isNightMode = false;
private Context ctx;
private Paint paintBlack;
private Paint paintRouteDirection;
@ -892,7 +894,7 @@ public class RouteInfoWidgetsFactory {
private int imgMinDelta;
private int imgMargin;
LanesDrawable(MapActivity ctx, float scaleCoefficent) {
public LanesDrawable(MapActivity ctx, float scaleCoefficent) {
this.ctx = ctx;
OsmandSettings settings = ctx.getMyApplication().getSettings();
leftSide = settings.DRIVING_REGION.get().leftHandDriving;
@ -916,7 +918,7 @@ public class RouteInfoWidgetsFactory {
paintSecondTurn.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
}
void updateBounds() {
public void updateBounds() {
float w = 0;
float h = 0;
float delta = imgMinDelta;
@ -1031,8 +1033,13 @@ public class RouteInfoWidgetsFactory {
// canvas.translate((int) (16 * scaleCoefficient), 0);
for (int i = 0; i < lanes.length; i++) {
if ((lanes[i] & 1) == 1) {
paintRouteDirection.setColor(imminent ? ctx.getResources().getColor(R.color.nav_arrow_imminent) :
ctx.getResources().getColor(R.color.nav_arrow));
if (isTurnByTurn){
paintRouteDirection.setColor(isNightMode ? ctx.getResources().getColor(R.color.active_color_primary_dark) :
ctx.getResources().getColor(R.color.active_color_primary_light));
} else {
paintRouteDirection.setColor(imminent ? ctx.getResources().getColor(R.color.nav_arrow_imminent) :
ctx.getResources().getColor(R.color.nav_arrow));
}
} else {
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
}