Display routes in bottom view
This commit is contained in:
parent
ebf26c79aa
commit
bb62e054e8
6 changed files with 135 additions and 23 deletions
60
OsmAnd/res/layout/ctx_menu_transport_route_layout.xml
Normal file
60
OsmAnd/res/layout/ctx_menu_transport_route_layout.xml
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/route_ref"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/transport_stop_route_bg"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="3"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:textSize="16sp"
|
||||
android:id="@+id/route_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="№5: Льва Толстого площа - Белицкая улица (25м)"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/route_type_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:src="@drawable/ic_action_polygom_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/route_type_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Метро "/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -2099,6 +2099,7 @@
|
|||
<string name="poi_route_monorail_ref">Monorail</string>
|
||||
<string name="poi_route_funicular_ref">Funicular</string>
|
||||
<string name="poi_route_ferry_ref">Ferry</string>
|
||||
<string name="poi_route_subway_ref">Subway</string>
|
||||
|
||||
<string name="poi_route_railway_ref">Route of a railroad</string>
|
||||
|
||||
|
|
|
@ -17,12 +17,14 @@ import android.text.TextUtils;
|
|||
import android.text.util.Linkify;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
|
@ -463,7 +465,6 @@ public class MenuBuilder {
|
|||
baseView.addView(ll);
|
||||
|
||||
// Icon
|
||||
boolean showIcon = false;
|
||||
if (icon != null) {
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
@ -479,7 +480,6 @@ public class MenuBuilder {
|
|||
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconView.setImageDrawable(icon);
|
||||
llIcon.addView(iconView);
|
||||
showIcon = true;
|
||||
}
|
||||
|
||||
// Text
|
||||
|
@ -489,7 +489,7 @@ public class MenuBuilder {
|
|||
|
||||
TextViewEx textView = new TextViewEx(view.getContext());
|
||||
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextParams.setMargins(showIcon ? 0 : dpToPx(16f), dpToPx(8f), 0, dpToPx(8f));
|
||||
llTextParams.setMargins(icon != null ? 0 : dpToPx(16f), dpToPx(8f), 0, dpToPx(8f));
|
||||
textView.setLayoutParams(llTextParams);
|
||||
textView.setTypeface(FontCache.getRobotoRegular(view.getContext()));
|
||||
textView.setTextSize(16);
|
||||
|
@ -687,6 +687,65 @@ public class MenuBuilder {
|
|||
);
|
||||
}
|
||||
|
||||
private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener) {
|
||||
if (!isFirstRow()) {
|
||||
buildRowDivider(parent, false);
|
||||
}
|
||||
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.ctx_menu_transport_route_layout, parent, false);
|
||||
TextView routeDesc = (TextView) view.findViewById(R.id.route_desc);
|
||||
routeDesc.setText(r.getDescription(getMapActivity().getMyApplication(), true));
|
||||
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());
|
||||
view.setOnClickListener(listener);
|
||||
int typeResId;
|
||||
switch (r.type) {
|
||||
case BUS:
|
||||
typeResId = R.string.poi_route_bus_ref;
|
||||
break;
|
||||
case TRAM:
|
||||
typeResId = R.string.poi_route_tram_ref;
|
||||
break;
|
||||
case FERRY:
|
||||
typeResId = R.string.poi_route_ferry_ref;
|
||||
break;
|
||||
case TRAIN:
|
||||
typeResId = R.string.poi_route_train_ref;
|
||||
break;
|
||||
case SHARE_TAXI:
|
||||
typeResId = R.string.poi_route_share_taxi_ref;
|
||||
break;
|
||||
case FUNICULAR:
|
||||
typeResId = R.string.poi_route_funicular_ref;
|
||||
break;
|
||||
case LIGHT_RAIL:
|
||||
typeResId = R.string.poi_route_light_rail_ref;
|
||||
break;
|
||||
case MONORAIL:
|
||||
typeResId = R.string.poi_route_monorail_ref;
|
||||
break;
|
||||
case TROLLEYBUS:
|
||||
typeResId = R.string.poi_route_trolleybus_ref;
|
||||
break;
|
||||
case RAILWAY:
|
||||
typeResId = R.string.poi_route_railway_ref;
|
||||
break;
|
||||
case SUBWAY:
|
||||
typeResId = R.string.poi_route_subway_ref;
|
||||
break;
|
||||
default:
|
||||
typeResId = R.string.poi_filter_public_transport;
|
||||
break;
|
||||
}
|
||||
((TextView) view.findViewById(R.id.route_type_text)).setText(typeResId);
|
||||
|
||||
parent.addView(view);
|
||||
|
||||
rowBuilt();
|
||||
}
|
||||
|
||||
private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed) {
|
||||
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, false);
|
||||
|
||||
|
@ -704,8 +763,7 @@ public class MenuBuilder {
|
|||
getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
|
||||
}
|
||||
};
|
||||
int drawableResId = r.type == null ? R.drawable.ic_action_polygom_dark : r.type.getResourceId();
|
||||
buildRow(view, drawableResId, r.getDescription(getMapActivity().getMyApplication(), true), 0, false, null, false, 0, false, listener);
|
||||
buildTransportRouteRow(view, r, listener);
|
||||
}
|
||||
|
||||
return new CollapsableView(view, collapsed);
|
||||
|
|
|
@ -230,7 +230,7 @@ public class AmenityMenuController extends MenuController {
|
|||
TransportStopController.TransportStopType type = TransportStopController.TransportStopType.findType(rs.getType());
|
||||
TransportStopRoute r = new TransportStopRoute();
|
||||
r.type = type;
|
||||
r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getEnName(true) : rs.getName());
|
||||
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
||||
r.route = rs;
|
||||
r.stop = s;
|
||||
r.distance = dist;
|
||||
|
|
|
@ -36,6 +36,11 @@ public class FavouritePointMenuController extends MenuController {
|
|||
leftTitleButtonController = markerMenuController.getLeftTitleButtonController();
|
||||
rightTitleButtonController = markerMenuController.getRightTitleButtonController();
|
||||
}
|
||||
if (getObject() instanceof TransportStop) {
|
||||
TransportStop stop = (TransportStop) getObject();
|
||||
TransportStopController transportStopController = new TransportStopController(getMapActivity(), pointDescription, stop);
|
||||
transportStopController.processTransportStop(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,12 +125,6 @@ public class FavouritePointMenuController extends MenuController {
|
|||
if (originObject instanceof Amenity) {
|
||||
Amenity amenity = (Amenity) originObject;
|
||||
AmenityMenuController.addPlainMenuItems(amenity, AmenityMenuController.getTypeStr(amenity), builder);
|
||||
} else if (originObject instanceof TransportStop) {
|
||||
TransportStop stop = (TransportStop) originObject;
|
||||
TransportStopController transportStopController =
|
||||
new TransportStopController(getMapActivity(), pointDescription, stop);
|
||||
transportStopController.addPlainMenuItems(builder, latLon);
|
||||
addMyLocationToPlainItems(latLon);
|
||||
}
|
||||
} else {
|
||||
addMyLocationToPlainItems(latLon);
|
||||
|
|
|
@ -82,14 +82,14 @@ public class TransportStopController extends MenuController {
|
|||
PointDescription pointDescription, TransportStop transportStop) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.transportStop = transportStop;
|
||||
processTransportStop();
|
||||
processTransportStop(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setObject(Object object) {
|
||||
if (object instanceof TransportStop) {
|
||||
this.transportStop = (TransportStop) object;
|
||||
processTransportStop();
|
||||
processTransportStop(builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,12 +127,6 @@ public class TransportStopController extends MenuController {
|
|||
return getPointDescription().getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
|
||||
addPlainMenuItems(builder, latLon);
|
||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||
}
|
||||
|
||||
public void addPlainMenuItems(MenuBuilder builder, final LatLon latLon) {
|
||||
for (final TransportStopRoute r : routes) {
|
||||
OnClickListener listener = new OnClickListener() {
|
||||
|
@ -158,7 +152,7 @@ public class TransportStopController extends MenuController {
|
|||
}
|
||||
}
|
||||
|
||||
private void processTransportStop() {
|
||||
public void processTransportStop(MenuBuilder builder) {
|
||||
routes.clear();
|
||||
List<TransportIndexRepository> reps = getMapActivity().getMyApplication()
|
||||
.getResourceManager().searchTransportRepositories(transportStop.getLocation().getLatitude(),
|
||||
|
@ -212,7 +206,7 @@ public class TransportStopController extends MenuController {
|
|||
topType = type;
|
||||
}
|
||||
r.type = type;
|
||||
r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getEnName(true) : rs.getName());
|
||||
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
||||
r.route = rs;
|
||||
r.refStop = refStop;
|
||||
r.stop = s;
|
||||
|
|
Loading…
Reference in a new issue