added two methods for getting routes and refactored strings with osmandFormattedDistance
This commit is contained in:
parent
c339303e49
commit
3146aeabe1
4 changed files with 57 additions and 42 deletions
|
@ -9,8 +9,8 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="transport_nearby_routes_within">Routes within 150 meters</string>
|
||||
<string name="transport_nearby_routes">NEAR IN 150 M:</string>
|
||||
<string name="transport_nearby_routes_within">Routes within</string>
|
||||
<string name="transport_nearby_routes">NEAR IN</string>
|
||||
<string name="enter_the_file_name">Enter the file name.</string>
|
||||
<string name="make_as_start_point">Make as Start Point</string>
|
||||
<string name="shared_string_current">Current</string>
|
||||
|
|
|
@ -40,6 +40,7 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.LockableScrollView;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -493,32 +494,23 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
GridView nearbyTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_nearby_routes_grid);
|
||||
TextView nearbRoutesWithinTv = (TextView) view.findViewById(R.id.nearby_routes_within_text_view);
|
||||
LinearLayout nearbyRoutesLayoutToHide = (LinearLayout) view.findViewById(R.id.nearby_routes);
|
||||
List<TransportStopRoute> allTransportStopRoutes = menu.getTransportStopRoutes();
|
||||
List<TransportStopRoute> localTransportStopRoutes = new ArrayList<>();
|
||||
List<TransportStopRoute> nearbyTransportStopRoutes = new ArrayList<>();
|
||||
|
||||
if (allTransportStopRoutes != null && allTransportStopRoutes.size() > 0) {
|
||||
for (TransportStopRoute route : allTransportStopRoutes) {
|
||||
boolean isCurrentRouteNearby = route.refStop != null && !route.refStop.getName().equals(route.stop.getName());
|
||||
if (isCurrentRouteNearby) {
|
||||
nearbyTransportStopRoutes.add(route);
|
||||
} else {
|
||||
localTransportStopRoutes.add(route);
|
||||
}
|
||||
}
|
||||
List<TransportStopRoute> localTransportStopRoutes = menu.getMenuController().getLocalTransportStopRoutes();
|
||||
List<TransportStopRoute> nearbyTransportStopRoutes = menu.getMenuController().getNearbyTransportStopRoutes();
|
||||
|
||||
if (localTransportStopRoutes.size() > 0) {
|
||||
localTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(localTransportStopRoutes));
|
||||
localTransportStopRoutesGrid.setVisibility(View.VISIBLE);
|
||||
|
||||
if (nearbyTransportStopRoutes.size() > 0) {
|
||||
nearbRoutesWithinTv.setText(R.string.transport_nearby_routes);
|
||||
nearbyTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(nearbyTransportStopRoutes));
|
||||
nearbyTransportStopRoutesGrid.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
nearbyTransportStopRoutesGrid.setVisibility(View.GONE);
|
||||
nearbyRoutesLayoutToHide.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
localTransportStopRoutesGrid.setVisibility(View.GONE);
|
||||
}
|
||||
if (nearbyTransportStopRoutes.size() > 0) {
|
||||
String nearInDistance = getMyApplication().getString(R.string.transport_nearby_routes) + " "
|
||||
+ OsmAndFormatter.getFormattedDistance(150, getMyApplication());
|
||||
nearbRoutesWithinTv.setText(nearInDistance);
|
||||
nearbyTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(nearbyTransportStopRoutes));
|
||||
nearbyTransportStopRoutesGrid.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
nearbyRoutesLayoutToHide.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
|
|||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
|
@ -313,9 +314,10 @@ public class MenuBuilder {
|
|||
buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false, false),
|
||||
false, 0, false, null, true);
|
||||
|
||||
CollapsableView collapsableView= getCollapsableTransportStopRoutesView(view.getContext(), false, true);
|
||||
if (collapsableView!= null) {
|
||||
buildRow(view, 0, null, app.getString(R.string.transport_nearby_routes_within), 0, true, collapsableView,
|
||||
CollapsableView collapsableView = getCollapsableTransportStopRoutesView(view.getContext(), false, true);
|
||||
if (collapsableView != null) {
|
||||
String routesWithingDistance = app.getString(R.string.transport_nearby_routes_within) + " " + OsmAndFormatter.getFormattedDistance(150, app);
|
||||
buildRow(view, 0, null, routesWithingDistance, 0, true, collapsableView,
|
||||
false, 0, false, null, true);
|
||||
}
|
||||
}
|
||||
|
@ -843,22 +845,12 @@ public class MenuBuilder {
|
|||
|
||||
private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed, boolean isNearbyRoutes) {
|
||||
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, false);
|
||||
List<TransportStopRoute> localTransportStopRoutes = new ArrayList<>();
|
||||
List<TransportStopRoute> nearbyTransportStopRoutes = new ArrayList<>();
|
||||
if (routes != null && routes.size() > 0) {
|
||||
for (TransportStopRoute route : routes) {
|
||||
boolean isCurrentRouteNearby = route.refStop != null && !route.refStop.getName().equals(route.stop.getName());
|
||||
if (isCurrentRouteNearby) {
|
||||
nearbyTransportStopRoutes.add(route);
|
||||
} else {
|
||||
localTransportStopRoutes.add(route);
|
||||
}
|
||||
}
|
||||
if (!isNearbyRoutes) {
|
||||
buildTransportRouteRows(view, localTransportStopRoutes);
|
||||
} else {
|
||||
buildTransportRouteRows(view, nearbyTransportStopRoutes);
|
||||
}
|
||||
List<TransportStopRoute> localTransportStopRoutes = mapContextMenu.getMenuController().getLocalTransportStopRoutes();
|
||||
List<TransportStopRoute> nearbyTransportStopRoutes = mapContextMenu.getMenuController().getNearbyTransportStopRoutes();
|
||||
if (!isNearbyRoutes) {
|
||||
buildTransportRouteRows(view, localTransportStopRoutes);
|
||||
} else {
|
||||
buildTransportRouteRows(view, nearbyTransportStopRoutes);
|
||||
}
|
||||
if (isNearbyRoutes && nearbyTransportStopRoutes.isEmpty()) {
|
||||
return null;
|
||||
|
|
|
@ -79,6 +79,7 @@ import net.osmand.util.MapUtils;
|
|||
import net.osmand.util.OpeningHoursParser.OpeningHours;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -522,6 +523,36 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<TransportStopRoute> getLocalTransportStopRoutes() {
|
||||
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
||||
if (allRoutes != null) {
|
||||
List<TransportStopRoute> res = new ArrayList<>();
|
||||
for (TransportStopRoute route : allRoutes) {
|
||||
boolean isCurrentRouteNearby = route.refStop != null && !route.refStop.getName().equals(route.stop.getName());
|
||||
if (!isCurrentRouteNearby) {
|
||||
res.add(route);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<TransportStopRoute> getNearbyTransportStopRoutes() {
|
||||
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
||||
if (allRoutes != null) {
|
||||
List<TransportStopRoute> res = new ArrayList<>();
|
||||
for (TransportStopRoute route : allRoutes) {
|
||||
boolean isCurrentRouteNearby = route.refStop != null && !route.refStop.getName().equals(route.stop.getName());
|
||||
if (isCurrentRouteNearby) {
|
||||
res.add(route);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void share(LatLon latLon, String title, String address) {
|
||||
ShareMenu.show(latLon, title, address, getMapActivity());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue