diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml
index 5fe1ee1efe..31af04c1a5 100644
--- a/OsmAnd/res/layout/map_context_menu_fragment.xml
+++ b/OsmAnd/res/layout/map_context_menu_fragment.xml
@@ -72,53 +72,73 @@
-
+ android:paddingRight="@dimen/context_menu_padding_margin_default">
-
+
+ android:visibility="gone"
+ osmand:typeface="@string/font_roboto_medium" />
-
+ android:layout_marginBottom="@dimen/context_menu_direction_margin"
+ android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
+ android:gravity="top"
+ android:orientation="horizontal"
+ android:paddingTop="3dp">
+
+
+
+
+
+
+
+ There is more transport on this stop.
Please give OsmAnd permission for location to continue.
Thank you for feedback
Node or way cannot be found.
diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java
index e2a4a94acf..092f87b225 100644
--- a/OsmAnd/src/net/osmand/AndroidUtils.java
+++ b/OsmAnd/src/net/osmand/AndroidUtils.java
@@ -344,6 +344,13 @@ public class AndroidUtils {
: ctx.getResources().getColor(R.color.secondary_text_light));
}
+
+ public static int getTextWidth(float textSize, String text) {
+ Paint paint = new Paint();
+ paint.setTextSize(textSize);
+ return (int) paint.measureText(text);
+ }
+
public static int dpToPx(Context ctx, float dp) {
Resources r = ctx.getResources();
return (int) TypedValue.applyDimension(
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index 33416d5aad..20baed7472 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -9,6 +9,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
@@ -79,8 +80,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
public static final int ZOOM_IN_STANDARD = 17;
public static final int CURRENT_Y_UNDEFINED = Integer.MAX_VALUE;
-
- private static final int MAX_TRANSPORT_ROUTES_BADGES = 6;
+
+ private static final String TRANSPORT_BADGE_MORE_ITEM = "...";
private View view;
private InterceptorLinearLayout mainView;
@@ -92,6 +93,13 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private View topButtonContainer;
private LockableScrollView menuScrollView;
+ private LinearLayout nearbyRoutesLayout;
+ private LinearLayout routesBadgesContainer;
+ private GridView localTransportStopRoutesGrid;
+ private GridView nearbyTransportStopRoutesGrid;
+ private TextView nearbyRoutesWithinTv;
+ private TextView localRoutesMoreTv;
+
private View zoomButtonsView;
private ImageButton zoomInButtonView;
private ImageButton zoomOutButtonView;
@@ -136,6 +144,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int screenOrientation;
private boolean created;
+
+ private boolean transportBadgesCreated;
private UpdateLocationViewCache updateLocationViewCache;
@@ -495,32 +505,19 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
zoomButtonsView.setVisibility(View.GONE);
}
- GridView localTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
- 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 nearbyRoutesLayout = (LinearLayout) view.findViewById(R.id.nearby_routes);
+ localTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
+ nearbyTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_nearby_routes_grid);
+ nearbyRoutesWithinTv = (TextView) view.findViewById(R.id.nearby_routes_within_text_view);
+ localRoutesMoreTv = (TextView) view.findViewById(R.id.local_routes_more_text_view);
+ nearbyRoutesLayout = (LinearLayout) view.findViewById(R.id.nearby_routes);
+ routesBadgesContainer = (LinearLayout) view.findViewById(R.id.transport_badges_container);
- List localTransportStopRoutes = menu.getLocalTransportStopRoutes();
- List nearbyTransportStopRoutes = menu.getNearbyTransportStopRoutes();
if (nightMode) {
- nearbRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_bottom_view_secondary_text_color_dark));
+ nearbyRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_bottom_view_secondary_text_color_dark));
+ localRoutesMoreTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_bottom_view_secondary_text_color_dark));
} else {
- nearbRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_nearby_routes_text_color_dark));
- }
- if (localTransportStopRoutes != null && localTransportStopRoutes.size() > 0) {
- localTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(localTransportStopRoutes));
- localTransportStopRoutesGrid.setVisibility(View.VISIBLE);
- } else {
- localTransportStopRoutesGrid.setVisibility(View.GONE);
- }
- if (nearbyTransportStopRoutes != null && nearbyTransportStopRoutes.size() > 0) {
- String nearInDistance = getMyApplication().getString(R.string.transport_nearby_routes) + " "
- + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS, getMyApplication()) +":";
- nearbRoutesWithinTv.setText(nearInDistance);
- nearbyTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(nearbyTransportStopRoutes));
- nearbyTransportStopRoutesGrid.setVisibility(View.VISIBLE);
- } else {
- nearbyRoutesLayout.setVisibility(View.GONE);
+ nearbyRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_nearby_routes_text_color_dark));
+ localRoutesMoreTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_nearby_routes_text_color_dark));
}
View buttonsBottomBorder = view.findViewById(R.id.buttons_bottom_border);
@@ -631,6 +628,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
@Override
public void onLayoutChange(View view, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ if (!transportBadgesCreated) {
+ createTransportBadges();
+ }
if (forceUpdateLayout || bottom != oldBottom) {
forceUpdateLayout = false;
processScreenHeight(view.getParent());
@@ -643,20 +643,35 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
return view;
}
- private TransportStopRouteAdapter createTransportStopRouteAdapter(List routes) {
- final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), filterTransportRoutes(routes), nightMode);
+ private TransportStopRouteAdapter createTransportStopRouteAdapter(List routes, boolean needMoreItem) {
+ List