From d567797a5f47a061dd703e22f96923ab9b475ead Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 20 Dec 2017 17:10:44 +0200 Subject: [PATCH] Change transport colors --- OsmAnd/res/values/colors.xml | 11 +++++ .../MapContextMenuFragment.java | 2 +- .../TransportStopRouteAdapter.java | 49 ++++++++++++++++++- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index dd9eae0d60..f435e29ea2 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -370,5 +370,16 @@ #ff8800 #d28521 #727272 + + #ff0000 + #f620cb + #920071 + #0000ff + #8c3f01 + #cb6e23 + #009100 + #3880a9 + #53A3BE + #185499 \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index ab48cf98a1..ea91eaf060 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -387,7 +387,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid); List transportStopRoutes = menu.getTransportStopRoutes(); if (transportStopRoutes != null && transportStopRoutes.size() > 0) { - TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes); + TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes, nightMode); transportStopRoutesGrid.setAdapter(adapter); transportStopRoutesGrid.setVisibility(View.VISIBLE); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java index fbc1da30a4..84a95d3d0d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java @@ -1,8 +1,10 @@ package net.osmand.plus.mapcontextmenu; import android.content.Context; +import android.graphics.drawable.GradientDrawable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -16,8 +18,11 @@ import java.util.List; public class TransportStopRouteAdapter extends ArrayAdapter { - public TransportStopRouteAdapter(@NonNull Context context, @NonNull List objects) { + private boolean nightMode; + + public TransportStopRouteAdapter(@NonNull Context context, @NonNull List objects, boolean nightMode) { super(context, 0, objects); + this.nightMode = nightMode; } @NonNull @@ -27,8 +32,48 @@ public class TransportStopRouteAdapter extends ArrayAdapter convertView = LayoutInflater.from(getContext()).inflate(R.layout.transport_stop_route_item, parent, false); } - ((TextView) convertView.findViewById(R.id.transport_stop_route_text)).setText(getItem(position).route.getRef()); + TransportStopRoute transportStopRoute = getItem(position); + if (transportStopRoute != null) { + 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))); + } 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; + } }