Change transport colors
This commit is contained in:
parent
812ca26679
commit
d567797a5f
3 changed files with 59 additions and 3 deletions
|
@ -370,5 +370,16 @@
|
||||||
<color name="route_info_checked_mode_icon_color_light">#ff8800</color>
|
<color name="route_info_checked_mode_icon_color_light">#ff8800</color>
|
||||||
<color name="route_info_checked_mode_icon_color_dark">#d28521</color>
|
<color name="route_info_checked_mode_icon_color_dark">#d28521</color>
|
||||||
<color name="route_info_unchecked_mode_icon_color">#727272</color>
|
<color name="route_info_unchecked_mode_icon_color">#727272</color>
|
||||||
|
|
||||||
|
<color name="route_bus_color">#ff0000</color>
|
||||||
|
<color name="route_share_taxi_color">#f620cb</color>
|
||||||
|
<color name="route_trolleybus_color">#920071</color>
|
||||||
|
<color name="route_tram_color">#0000ff</color>
|
||||||
|
<color name="route_train_color_light">#8c3f01</color>
|
||||||
|
<color name="route_train_color_dark">#cb6e23</color>
|
||||||
|
<color name="route_lightrail_color">#009100</color>
|
||||||
|
<color name="route_funicular_color">#3880a9</color>
|
||||||
|
<color name="route_ferry_color_light">#53A3BE</color>
|
||||||
|
<color name="route_ferry_color_dark">#185499</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -387,7 +387,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
|
GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
|
||||||
List<TransportStopRoute> transportStopRoutes = menu.getTransportStopRoutes();
|
List<TransportStopRoute> transportStopRoutes = menu.getTransportStopRoutes();
|
||||||
if (transportStopRoutes != null && transportStopRoutes.size() > 0) {
|
if (transportStopRoutes != null && transportStopRoutes.size() > 0) {
|
||||||
TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes);
|
TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes, nightMode);
|
||||||
transportStopRoutesGrid.setAdapter(adapter);
|
transportStopRoutesGrid.setAdapter(adapter);
|
||||||
transportStopRoutesGrid.setVisibility(View.VISIBLE);
|
transportStopRoutesGrid.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package net.osmand.plus.mapcontextmenu;
|
package net.osmand.plus.mapcontextmenu;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -16,8 +18,11 @@ import java.util.List;
|
||||||
|
|
||||||
public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute> {
|
public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute> {
|
||||||
|
|
||||||
public TransportStopRouteAdapter(@NonNull Context context, @NonNull List<TransportStopRoute> objects) {
|
private boolean nightMode;
|
||||||
|
|
||||||
|
public TransportStopRouteAdapter(@NonNull Context context, @NonNull List<TransportStopRoute> objects, boolean nightMode) {
|
||||||
super(context, 0, objects);
|
super(context, 0, objects);
|
||||||
|
this.nightMode = nightMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -27,8 +32,48 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
|
||||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.transport_stop_route_item, parent, false);
|
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;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue