From 5b136fdcdfa0c8ba7a136b38d0c0e10fc80d3bb0 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 20 Dec 2017 17:44:42 +0200 Subject: [PATCH] Make transport rects colored in bottom view --- .../plus/mapcontextmenu/MenuBuilder.java | 6 +++- .../TransportStopRouteAdapter.java | 36 +------------------ .../controllers/TransportStopController.java | 34 ++++++++++++++++++ 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 49fbd60af8..7a34fc3c43 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -7,6 +7,7 @@ import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.net.Uri; import android.os.AsyncTask; import android.support.annotation.NonNull; @@ -726,7 +727,10 @@ public class MenuBuilder { routeDesc.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); int drawableResId = r.type == null ? R.drawable.ic_action_polygom_dark : r.type.getResourceId(); ((ImageView) view.findViewById(R.id.route_type_icon)).setImageDrawable(getRowIcon(drawableResId)); - ((TextView) view.findViewById(R.id.route_ref)).setText(r.route.getRef()); + TextView refTextView = (TextView) view.findViewById(R.id.route_ref); + refTextView.setText(r.route.getRef()); + GradientDrawable refBg = (GradientDrawable) refTextView.getBackground(); + refBg.setColor(ContextCompat.getColor(parent.getContext(), r.getColor(!light))); view.setOnClickListener(listener); int typeResId; switch (r.type) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java index 3136684905..f5b66638b6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java @@ -42,7 +42,7 @@ public class TransportStopRouteAdapter extends ArrayAdapter TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text); transportStopRouteTextView.setText(transportStopRoute.route.getRef()); GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground(); - gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), getColor(transportStopRoute))); + gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), transportStopRoute.getColor(nightMode))); } convertView.setOnClickListener(new View.OnClickListener() { @@ -57,40 +57,6 @@ public class TransportStopRouteAdapter extends ArrayAdapter return convertView; } - private int getColor(TransportStopRoute route) { - int color; - switch (route.type) { - case BUS: - color = R.color.route_bus_color; - break; - case SHARE_TAXI: - color = R.color.route_share_taxi_color; - break; - case TROLLEYBUS: - color = R.color.route_trolleybus_color; - break; - case TRAM: - color = R.color.route_tram_color; - break; - case TRAIN: - color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light; - break; - case LIGHT_RAIL: - color = R.color.route_lightrail_color; - break; - case FUNICULAR: - color = R.color.route_funicular_color; - break; - case FERRY: - color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light; - break; - default: - color = R.color.nav_track; - break; - } - return color; - } - public interface OnClickListener { void onClick(int position); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index 30b50155d9..17ede9a1bf 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -264,5 +264,39 @@ public class TransportStopController extends MenuController { } return cp.getZoom(); } + + public int getColor(boolean nightMode) { + int color; + switch (type) { + case BUS: + color = R.color.route_bus_color; + break; + case SHARE_TAXI: + color = R.color.route_share_taxi_color; + break; + case TROLLEYBUS: + color = R.color.route_trolleybus_color; + break; + case TRAM: + color = R.color.route_tram_color; + break; + case TRAIN: + color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light; + break; + case LIGHT_RAIL: + color = R.color.route_lightrail_color; + break; + case FUNICULAR: + color = R.color.route_funicular_color; + break; + case FERRY: + color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light; + break; + default: + color = R.color.nav_track; + break; + } + return color; + } } }