add arrow for transport routes and improve ui

This commit is contained in:
Chumva 2018-05-16 13:32:50 +03:00
parent 5e49d95b18
commit 04a4b4c2b6
3 changed files with 24 additions and 3 deletions

View file

@ -83,8 +83,7 @@
android:paddingLeft="@dimen/context_menu_padding_margin_default" android:paddingLeft="@dimen/context_menu_padding_margin_default"
android:paddingRight="@dimen/context_menu_padding_margin_default" android:paddingRight="@dimen/context_menu_padding_margin_default"
android:paddingTop="@dimen/context_menu_transport_padding_top" android:paddingTop="@dimen/context_menu_transport_padding_top"
android:verticalSpacing="@dimen/context_menu_transport_grid_spacing" android:verticalSpacing="@dimen/context_menu_transport_grid_spacing"/>
android:visibility="gone"/>
<LinearLayout <LinearLayout
android:id="@+id/nearby_routes" android:id="@+id/nearby_routes"
@ -99,6 +98,7 @@
android:paddingTop="3dp"> android:paddingTop="3dp">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:layout_gravity="center_vertical"
android:id="@+id/nearby_routes_within_text_view" android:id="@+id/nearby_routes_within_text_view"
style="@style/TextAppearance.ContextMenuSubtitle" style="@style/TextAppearance.ContextMenuSubtitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -109,6 +109,7 @@
osmand:typeface="@string/font_roboto_medium" /> osmand:typeface="@string/font_roboto_medium" />
<GridView <GridView
android:layout_gravity="center_vertical"
android:id="@+id/transport_stop_nearby_routes_grid" android:id="@+id/transport_stop_nearby_routes_grid"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -380,6 +380,8 @@
<color name="ctx_menu_controller_disabled_text_color_dark">#666666</color> <color name="ctx_menu_controller_disabled_text_color_dark">#666666</color>
<color name="ctx_menu_collapse_icon_color_light">#727272</color> <color name="ctx_menu_collapse_icon_color_light">#727272</color>
<color name="ctx_menu_collapse_icon_color_dark">#a6a6a6</color> <color name="ctx_menu_collapse_icon_color_dark">#a6a6a6</color>
<color name="ctx_menu_route_icon_color_light">#b3b3b3</color>
<color name="ctx_menu_route_icon_color_dark">#4d4d4d</color>
<color name="route_info_bg_light">#ffffff</color> <color name="route_info_bg_light">#ffffff</color>
<color name="route_info_bg_dark">#17191a</color> <color name="route_info_bg_dark">#17191a</color>

View file

@ -15,7 +15,11 @@ import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.DynamicDrawableSpan;
import android.text.style.ImageSpan;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
@ -824,7 +828,21 @@ public class MenuBuilder {
titleView.setLayoutParams(titleParams); titleView.setLayoutParams(titleParams);
titleView.setTextSize(16); 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.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); infoView.addView(titleView);
LinearLayout typeView = new LinearLayout(view.getContext()); LinearLayout typeView = new LinearLayout(view.getContext());