diff --git a/OsmAnd/res/layout/route_directions_card.xml b/OsmAnd/res/layout/route_directions_card.xml
new file mode 100644
index 0000000000..09e313bd02
--- /dev/null
+++ b/OsmAnd/res/layout/route_directions_card.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/route_info_header.xml b/OsmAnd/res/layout/route_info_header.xml
index 5ddd977456..7fa1246257 100644
--- a/OsmAnd/res/layout/route_info_header.xml
+++ b/OsmAnd/res/layout/route_info_header.xml
@@ -121,6 +121,7 @@
+ android:visibility="visible"/>
items = itemGroups.get(group);
if (ch.isChecked()) {
- if (groupPosition == 0) {
+ if (groupPosition == 0 && groups.size() > 1) {
setTrackPointsSelection(true);
} else {
setGroupSelection(items, groupPosition, true);
@@ -1027,7 +1030,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
}
private void setTrackPointsSelection(boolean select) {
- if (groups.size() > 1) {
+ if (!groups.isEmpty()) {
setGroupSelection(null, 0, select);
for (int i = 1; i < groups.size(); i++) {
GpxDisplayGroup g = groups.get(i);
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
index a5920d7492..6566d5350e 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
@@ -109,6 +109,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
public static int directionInfo = -1;
public static boolean chooseRoutesVisible = false;
+ public static boolean waypointsVisible = false;
+
private boolean routeCalculationInProgress;
private boolean selectFromMapTouch;
@@ -1350,7 +1352,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null && mapActivity.getMyApplication().getTargetPointsHelper().checkPointToNavigateShort()) {
- WaypointsFragment.showInstance(mapActivity);
+ hide();
+ WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager(), getCurrentMenuState());
}
}
});
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java
index ae8570a471..7bb0acdaa3 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java
@@ -469,6 +469,8 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerButtons), nightMode,
R.color.divider_light, R.color.divider_dark);
+ AndroidUtils.setBackground(ctx, view.findViewById(R.id.controls_divider), nightMode,
+ R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.app_modes_options_container), nightMode,
R.drawable.route_info_trans_gradient_light, R.drawable.route_info_trans_gradient_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.app_modes_fold_container), nightMode,
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java
index f16d1cda7a..6917af8ada 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java
@@ -1,8 +1,6 @@
package net.osmand.plus.routepreparationmenu;
import android.content.Context;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
@@ -11,7 +9,6 @@ import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
-import android.support.v7.view.ContextThemeWrapper;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
@@ -65,6 +62,7 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard;
import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard.PublicTransportCardListener;
+import net.osmand.plus.routepreparationmenu.cards.RouteDirectionsCard;
import net.osmand.plus.routepreparationmenu.cards.RouteInfoCard;
import net.osmand.plus.routepreparationmenu.cards.RouteStatisticCard;
import net.osmand.plus.routing.RouteCalculationResult;
@@ -72,7 +70,6 @@ import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.TransportRoutingHelper;
import net.osmand.plus.transport.TransportStopRoute;
-import net.osmand.plus.views.TurnPathHelper;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import net.osmand.render.RenderingRuleSearchRequest;
@@ -255,81 +252,40 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
transportCard = null;
makeGpx();
createRouteStatisticCards(cardsContainer);
- createRouteDirections(cardsContainer);
+ createRouteDirectionsCard(cardsContainer);
}
}
}
}
- private void createRouteDirections(LinearLayout cardsContainer) {
- OsmandApplication app = requireMyApplication();
- TextViewEx routeDirectionsTitle = new TextViewEx(app);
- routeDirectionsTitle.setTextColor(getMainFontColor());
- routeDirectionsTitle.setTextSize(15);
- routeDirectionsTitle.setGravity(Gravity.CENTER_VERTICAL);
- routeDirectionsTitle.setPadding(dpToPx(16), dpToPx(16), dpToPx(16), dpToPx(16));
- routeDirectionsTitle.setText(R.string.step_by_step);
- routeDirectionsTitle.setTypeface(FontCache.getRobotoMedium(app));
- cardsContainer.addView(routeDirectionsTitle);
-
- List routeDirections = app.getRoutingHelper().getRouteDirections();
- for (int i = 0; i < routeDirections.size(); i++) {
- RouteDirectionInfo routeDirectionInfo = routeDirections.get(i);
- OnClickListener onClickListener = createRouteDirectionInfoViewClickListener(i, routeDirectionInfo);
- View view = getRouteDirectionView(i, routeDirectionInfo, routeDirections, onClickListener);
- cardsContainer.addView(view);
- }
- }
-
- private OnClickListener createRouteDirectionInfoViewClickListener(final int directionInfoIndex, final RouteDirectionInfo routeDirectionInfo) {
- return new OnClickListener() {
- @Override
- public void onClick(View view) {
- OsmandApplication app = requireMyApplication();
- Location loc = app.getRoutingHelper().getLocationFromRouteDirection(routeDirectionInfo);
- if (loc != null) {
- MapRouteInfoMenu.directionInfo = directionInfoIndex;
- OsmandSettings settings = app.getSettings();
- settings.setMapLocationToShow(loc.getLatitude(), loc.getLongitude(),
- Math.max(13, settings.getLastKnownMapZoom()),
- new PointDescription(PointDescription.POINT_TYPE_MARKER,
- routeDirectionInfo.getDescriptionRoutePart() + " " + getTimeDescription(app, routeDirectionInfo)),
- false, null);
- MapActivity.launchMapActivityMoveToTop(getActivity());
- dismiss();
- }
- }
- };
- }
-
private void createRouteStatisticCards(LinearLayout cardsContainer) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
OsmandApplication app = mapActivity.getMyApplication();
+ RouteStatisticCard statisticCard = new RouteStatisticCard(mapActivity, gpx, new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ InterceptorLinearLayout mainView = getMainView();
+ if (mainView != null) {
+ mainView.requestDisallowInterceptTouchEvent(true);
+ }
+ return false;
+ }
+ }, new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ openDetails();
+ }
+ });
+ statisticCard.setTransparentBackground(true);
+ menuCards.add(statisticCard);
+ cardsContainer.addView(statisticCard.build(mapActivity));
+ buildRowDivider(cardsContainer, false);
+ slopeDataSet = statisticCard.getSlopeDataSet();
+ elevationDataSet = statisticCard.getElevationDataSet();
if (gpx.hasAltitude) {
- RouteStatisticCard statisticCard = new RouteStatisticCard(mapActivity, gpx, new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- InterceptorLinearLayout mainView = getMainView();
- if (mainView != null) {
- mainView.requestDisallowInterceptTouchEvent(true);
- }
- return false;
- }
- }, new OnClickListener() {
- @Override
- public void onClick(View v) {
- openDetails();
- }
- });
- statisticCard.setTransparentBackground(true);
- menuCards.add(statisticCard);
- cardsContainer.addView(statisticCard.build(mapActivity));
- buildRowDivider(cardsContainer, false);
- slopeDataSet = statisticCard.getSlopeDataSet();
- elevationDataSet = statisticCard.getElevationDataSet();
List route = app.getRoutingHelper().getRoute().getOriginalRoute();
if (route != null) {
RenderingRulesStorage currentRenderer = app.getRendererRegistry().getCurrentSelectedRenderer();
@@ -360,6 +316,19 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
}
+ private void createRouteDirectionsCard(LinearLayout cardsContainer) {
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity == null) {
+ return;
+ }
+ RouteDirectionsCard directionsCard = new RouteDirectionsCard(mapActivity);
+ directionsCard.setTransparentBackground(true);
+ directionsCard.setListener(this);
+ menuCards.add(directionsCard);
+ cardsContainer.addView(directionsCard.build(mapActivity));
+ buildRowDivider(cardsContainer, false);
+ }
+
private void createRouteCard(LinearLayout cardsContainer, RouteInfoCard routeInfoCard) {
OsmandApplication app = requireMyApplication();
menuCards.add(routeInfoCard);
@@ -374,7 +343,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
private void buildSegmentItem(View view, final TransportRouteResultSegment segment,
- final TransportRouteResultSegment nextSegment, int[] startTime, double walkSpeed, double boardingTime) {
+ final TransportRouteResultSegment nextSegment, int[] startTime, double walkSpeed, double boardingTime) {
OsmandApplication app = requireMyApplication();
TransportRoute transportRoute = segment.route;
List stops = segment.getTravelStops();
@@ -1483,6 +1452,30 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
}
+ private void showDirectionsInfo(int directionInfoIndex) {
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity == null) {
+ return;
+ }
+ RoutingHelper helper = mapActivity.getRoutingHelper();
+ List routeDirections = helper.getRouteDirections();
+ if (routeDirections.size() > directionInfoIndex) {
+ RouteDirectionInfo routeDirectionInfo = routeDirections.get(directionInfoIndex);
+ Location loc = helper.getLocationFromRouteDirection(routeDirectionInfo);
+ if (loc != null) {
+ MapRouteInfoMenu.directionInfo = directionInfoIndex;
+ OsmandSettings settings = mapActivity.getMyApplication().getSettings();
+ settings.setMapLocationToShow(loc.getLatitude(), loc.getLongitude(),
+ Math.max(13, settings.getLastKnownMapZoom()),
+ new PointDescription(PointDescription.POINT_TYPE_MARKER,
+ routeDirectionInfo.getDescriptionRoutePart() + " " + getTimeDescription(mapActivity.getMyApplication(), routeDirectionInfo)),
+ false, null);
+ MapActivity.launchMapActivityMoveToTop(mapActivity);
+ dismiss();
+ }
+ }
+ }
+
@Override
public void onPublicTransportCardBadgePressed(@NonNull PublicTransportCard card, @NonNull TransportRouteResultSegment segment) {
showRouteSegmentOnMap(segment);
@@ -1512,6 +1505,8 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) {
if (card instanceof PublicTransportCard && buttonIndex == 0) {
openMenuFullScreen();
+ } else if (card instanceof RouteDirectionsCard && buttonIndex >= 0) {
+ showDirectionsInfo(buttonIndex);
}
}
@@ -1525,48 +1520,6 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
}
- public View getRouteDirectionView(int position, RouteDirectionInfo model, List directionsInfo, OnClickListener onClickListener) {
- MapActivity mapActivity = getMapActivity();
- if (mapActivity == null) {
- return null;
- }
- OsmandApplication app = mapActivity.getMyApplication();
- ContextThemeWrapper context = new ContextThemeWrapper(mapActivity, isNightMode() ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme);
- View row = LayoutInflater.from(context).inflate(R.layout.route_info_list_item, null);
-
- TextView label = (TextView) row.findViewById(R.id.description);
- TextView distanceLabel = (TextView) row.findViewById(R.id.distance);
- TextView timeLabel = (TextView) row.findViewById(R.id.time);
- TextView cumulativeDistanceLabel = (TextView) row.findViewById(R.id.cumulative_distance);
- TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
- ImageView icon = (ImageView) row.findViewById(R.id.direction);
- row.findViewById(R.id.divider).setVisibility(position == directionsInfo.size() - 1 ? View.INVISIBLE : View.VISIBLE);
-
- TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(getResources(), true);
- drawable.setColorFilter(new PorterDuffColorFilter(getActiveColor(), PorterDuff.Mode.SRC_ATOP));
- drawable.setRouteType(model.getTurnType());
- icon.setImageDrawable(drawable);
-
- label.setText(model.getDescriptionRoutePart());
- if (model.distance > 0) {
- distanceLabel.setText(OsmAndFormatter.getFormattedDistance(model.distance, app));
- timeLabel.setText(getTimeDescription(app, model));
- row.setContentDescription(label.getText() + " " + timeLabel.getText());
- } else {
- if (Algorithms.isEmpty(label.getText().toString())) {
- label.setText(getString((position != directionsInfo.size() - 1) ? R.string.arrived_at_intermediate_point : R.string.arrived_at_destination));
- }
- distanceLabel.setText("");
- timeLabel.setText("");
- row.setContentDescription("");
- }
- CumulativeInfo cumulativeInfo = getRouteDirectionCumulativeInfo(position, directionsInfo);
- cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(cumulativeInfo.distance, app));
- cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time, app.accessibilityEnabled()));
- row.setOnClickListener(onClickListener);
- return row;
- }
-
public static CumulativeInfo getRouteDirectionCumulativeInfo(int position, List routeDirections) {
CumulativeInfo cumulativeInfo = new CumulativeInfo();
if (position >= routeDirections.size()) {
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java
index 3d1fb1ac8d..b25f63e347 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java
@@ -1,6 +1,5 @@
package net.osmand.plus.routepreparationmenu;
-import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
@@ -59,17 +58,13 @@ import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.helpers.WaypointDialogHelper.showOnMap;
+import static net.osmand.plus.routepreparationmenu.ChooseRouteFragment.ROUTE_INFO_STATE_KEY;
public class WaypointsFragment extends BaseOsmAndFragment implements ObservableScrollViewCallbacks,
DynamicListViewCallbacks, WaypointDialogHelper.WaypointDialogHelperCallback {
public static final String TAG = "WaypointsFragment";
- private OsmandApplication app;
-
- private MapActivity mapActivity;
- private WaypointDialogHelper waypointDialogHelper;
-
private View view;
private View mainView;
private DynamicListView listView;
@@ -88,26 +83,24 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
private boolean nightMode;
private boolean wasDrawerDisabled;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- app = getMyApplication();
- mapActivity = (MapActivity) getActivity();
- }
+ private int routeInfoMenuState = -1;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
+ MapActivity mapActivity = (MapActivity) requireActivity();
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
- waypointDialogHelper = mapActivity.getDashboard().getWaypointDialogHelper();
view = inflater.inflate(R.layout.route_waypoints_fragment, parent, false);
if (view == null) {
return null;
}
- AndroidUtils.addStatusBarPadding21v(app, view);
-
+ AndroidUtils.addStatusBarPadding21v(mapActivity, view);
+ Bundle args = getArguments();
+ if (args != null) {
+ routeInfoMenuState = args.getInt(ROUTE_INFO_STATE_KEY, -1);
+ }
mainView = view.findViewById(R.id.main_view);
listView = (DynamicListView) view.findViewById(R.id.dash_list_view);
@@ -147,9 +140,12 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
if (hasActivePoints) {
- TargetOptionsBottomSheetDialogFragment fragment = new TargetOptionsBottomSheetDialogFragment();
- fragment.setUsedOnMap(true);
- fragment.show(mapActivity.getSupportFragmentManager(), TargetOptionsBottomSheetDialogFragment.TAG);
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity != null) {
+ TargetOptionsBottomSheetDialogFragment fragment = new TargetOptionsBottomSheetDialogFragment();
+ fragment.setUsedOnMap(true);
+ fragment.show(mapActivity.getSupportFragmentManager(), TargetOptionsBottomSheetDialogFragment.TAG);
+ }
}
}
});
@@ -225,29 +221,34 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
@Override
public String getTitle() {
- List