From 04a4b4c2b6dbbe042800ecb76f4a1b3ebae7d708 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 16 May 2018 13:32:50 +0300 Subject: [PATCH] add arrow for transport routes and improve ui --- .../res/layout/map_context_menu_fragment.xml | 5 +++-- OsmAnd/res/values/colors.xml | 2 ++ .../plus/mapcontextmenu/MenuBuilder.java | 20 ++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 0926de4354..e5adeca112 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -83,8 +83,7 @@ android:paddingLeft="@dimen/context_menu_padding_margin_default" android:paddingRight="@dimen/context_menu_padding_margin_default" android:paddingTop="@dimen/context_menu_transport_padding_top" - android:verticalSpacing="@dimen/context_menu_transport_grid_spacing" - android:visibility="gone"/> + android:verticalSpacing="@dimen/context_menu_transport_grid_spacing"/> #666666 #727272 #a6a6a6 + #b3b3b3 + #4d4d4d #ffffff #17191a diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 5884302e1f..de3145093e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -15,7 +15,11 @@ import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.support.v7.view.ContextThemeWrapper; import android.text.ClipboardManager; +import android.text.Spannable; +import android.text.SpannableString; import android.text.TextUtils; +import android.text.style.DynamicDrawableSpan; +import android.text.style.ImageSpan; import android.text.util.Linkify; import android.util.TypedValue; import android.view.Gravity; @@ -824,7 +828,21 @@ public class MenuBuilder { titleView.setLayoutParams(titleParams); titleView.setTextSize(16); titleView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); - titleView.setText(route.getDescription(getMapActivity().getMyApplication(), true)); + String desc = route.getDescription(getMapActivity().getMyApplication(), true); + + if (desc.contains("=>") || desc.contains(" - ")) { + Drawable arrow = app.getIconsCache().getIcon(R.drawable.ic_arrow_right_16, light ? R.color.ctx_menu_route_icon_color_light : R.color.ctx_menu_route_icon_color_dark); + Float ascent = titleView.getPaint().getFontMetrics().ascent; + int h = (int) -ascent; + arrow.setBounds(0, 0, h, h); + SpannableString stringWithImage = new SpannableString(desc); + int i = desc.indexOf("=>"); + int d = desc.indexOf(" - "); + stringWithImage.setSpan(new ImageSpan(arrow, DynamicDrawableSpan.ALIGN_BASELINE), i == -1 ? d : i, i == -1 ? d + 3 : i + 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + titleView.setText(stringWithImage); + } else { + titleView.setText(desc); + } infoView.addView(titleView); LinearLayout typeView = new LinearLayout(view.getContext());