Create routeDirectionsCard and fix waypointsFragment replacing route menu fragment

This commit is contained in:
Chumva 2019-04-08 13:00:41 +03:00
parent 170655ec32
commit a6337a1c3e
12 changed files with 279 additions and 155 deletions

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:id="@+id/route_directions_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_and_list_background_basic"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/directions_card_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/content_padding"
android:text="@string/step_by_step"
android:textColor="?attr/main_font_color_basic"
android:textSize="@dimen/text_button_text_size"
osmand:typeface="@string/font_roboto_medium" />
<LinearLayout
android:id="@+id/items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>

View file

@ -121,6 +121,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/altitude_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
@ -220,6 +221,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/slope_info_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
@ -264,6 +266,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/slope_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"

View file

@ -36,7 +36,7 @@
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/divider_color_basic"
android:visibility="gone"/>
android:visibility="visible"/>
<FrameLayout
android:id="@+id/start_button"

View file

@ -1606,6 +1606,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return trackDetailsMenu;
}
public void hideContextAndRouteInfoMenus() {
mapContextMenu.hideMenues();
mapRouteInfoMenu.hide();
}
public void openDrawer() {
mapActions.updateDrawerMenu();
boolean animate = !settings.DO_NOT_USE_ANIMATIONS.get();

View file

@ -889,7 +889,8 @@ public class MapActivityActions implements DialogProvider {
}
public void openIntermediatePointsDialog() {
WaypointsFragment.showInstance(mapActivity);
mapActivity.hideContextAndRouteInfoMenus();
WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager());
}
public void openRoutePreferencesDialog() {

View file

@ -1350,7 +1350,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(), MenuState.HEADER_ONLY);
}
}
});

View file

@ -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,

View file

@ -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<RouteDirectionInfo> 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<RouteSegmentResult> 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<TransportStop> 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<RouteDirectionInfo> 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<RouteDirectionInfo> 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<RouteDirectionInfo> routeDirections) {
CumulativeInfo cumulativeInfo = new CumulativeInfo();
if (position >= routeDirections.size()) {

View file

@ -41,6 +41,7 @@ import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.base.ContextMenuFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointDialogHelper.TargetOptionsBottomSheetDialogFragment;
@ -59,6 +60,8 @@ import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.helpers.WaypointDialogHelper.showOnMap;
import static net.osmand.plus.routepreparationmenu.ChooseRouteFragment.INITIAL_MENU_STATE_KEY;
import static net.osmand.plus.routepreparationmenu.ChooseRouteFragment.ROUTE_INFO_STATE_KEY;
public class WaypointsFragment extends BaseOsmAndFragment implements ObservableScrollViewCallbacks,
DynamicListViewCallbacks, WaypointDialogHelper.WaypointDialogHelperCallback {
@ -88,6 +91,8 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
private boolean nightMode;
private boolean wasDrawerDisabled;
private int routeInfoMenuState = -1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -107,7 +112,10 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
return null;
}
AndroidUtils.addStatusBarPadding21v(app, 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);
@ -434,6 +442,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
AndroidUtils.setBackground(app, clearButtonDescr, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
AndroidUtils.setBackground(app, view.findViewById(R.id.cancel_button), nightMode, R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.controls_divider), nightMode, R.color.divider_light, R.color.divider_dark);
((TextView) view.findViewById(R.id.cancel_button_descr)).setTextColor(colorActive);
((TextView) view.findViewById(R.id.start_button_descr)).setText(getText(R.string.shared_string_apply));
@ -864,15 +873,21 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
}
public static boolean showInstance(final MapActivity mapActivity) {
try {
mapActivity.getContextMenu().hideMenues();
public static boolean showInstance(FragmentManager fragmentManager) {
return WaypointsFragment.showInstance(fragmentManager, -1, ContextMenuFragment.MenuState.HEADER_ONLY);
}
public static boolean showInstance(FragmentManager fragmentManager, int routeInfoState, int initialMenuState) {
try {
WaypointsFragment fragment = new WaypointsFragment();
mapActivity.getSupportFragmentManager()
.beginTransaction()
Bundle args = new Bundle();
args.putInt(ROUTE_INFO_STATE_KEY, routeInfoState);
args.putInt(INITIAL_MENU_STATE_KEY, initialMenuState);
fragment.setArguments(args);
fragmentManager.beginTransaction()
.add(R.id.routeMenuContainer, fragment, TAG)
.addToBackStack(TAG)
.commitAllowingStateLoss();
return true;
@ -883,14 +898,16 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
private void dismiss() {
FragmentActivity activity = getActivity();
if (activity != null) {
try {
activity.getSupportFragmentManager().popBackStack(TAG,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
} catch (Exception e) {
//
try {
MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
if (routeInfoMenuState != -1) {
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(routeInfoMenuState);
}
}
} catch (Exception e) {
//
}
}
}

View file

@ -0,0 +1,105 @@
package net.osmand.plus.routepreparationmenu.cards;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.support.annotation.NonNull;
import android.support.v7.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routepreparationmenu.RouteDetailsFragment;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.views.TurnPathHelper;
import net.osmand.util.Algorithms;
import java.util.List;
public class RouteDirectionsCard extends BaseCard {
public RouteDirectionsCard(@NonNull MapActivity mapActivity) {
super(mapActivity);
}
@Override
public int getCardLayoutId() {
return R.layout.route_directions_card;
}
@Override
protected void updateContent() {
LinearLayout root = (LinearLayout) view.findViewById(R.id.items);
root.removeAllViews();
createRouteDirections(root);
}
private void createRouteDirections(LinearLayout cardsContainer) {
List<RouteDirectionInfo> routeDirections = app.getRoutingHelper().getRouteDirections();
for (int i = 0; i < routeDirections.size(); i++) {
RouteDirectionInfo routeDirectionInfo = routeDirections.get(i);
View view = getRouteDirectionView(i, routeDirectionInfo, routeDirections);
cardsContainer.addView(view);
}
}
private static String getTimeDescription(OsmandApplication app, RouteDirectionInfo model) {
final int timeInSeconds = model.getExpectedTime();
return Algorithms.formatDuration(timeInSeconds, app.accessibilityEnabled());
}
private View getRouteDirectionView(final int directionInfoIndex, RouteDirectionInfo model, List<RouteDirectionInfo> directionsInfo) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return null;
}
OsmandApplication app = mapActivity.getMyApplication();
ContextThemeWrapper context = new ContextThemeWrapper(mapActivity, nightMode ? 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(directionInfoIndex == directionsInfo.size() - 1 ? View.INVISIBLE : View.VISIBLE);
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(mapActivity.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(mapActivity.getString((directionInfoIndex != directionsInfo.size() - 1) ? R.string.arrived_at_intermediate_point : R.string.arrived_at_destination));
}
distanceLabel.setText("");
timeLabel.setText("");
row.setContentDescription("");
}
RouteDetailsFragment.CumulativeInfo cumulativeInfo = RouteDetailsFragment.getRouteDirectionCumulativeInfo(directionInfoIndex, directionsInfo);
cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(cumulativeInfo.distance, app));
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time, app.accessibilityEnabled()));
row.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CardListener listener = getListener();
if (listener != null) {
listener.onCardButtonPressed(RouteDirectionsCard.this, directionInfoIndex);
}
}
});
return row;
}
}

View file

@ -100,40 +100,49 @@ public class RouteStatisticCard extends BaseCard {
String arriveStr = app.getString(R.string.arrive_at_time, OsmAndFormatter.getFormattedTime(time, true));
arriveTimeTv.setText(arriveStr);
GPXTrackAnalysis analysis = gpx.getAnalysis(0);
buildHeader(analysis);
((TextView) view.findViewById(R.id.average_text)).setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
((TextView) view.findViewById(R.id.range_text)).setText(min + " - " + max);
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
((TextView) view.findViewById(R.id.descent_text)).setText(desc);
((TextView) view.findViewById(R.id.ascent_text)).setText(asc);
((ImageView) view.findViewById(R.id.average_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_average));
((ImageView) view.findViewById(R.id.range_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_average));
((ImageView) view.findViewById(R.id.descent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_descent));
((ImageView) view.findViewById(R.id.ascent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_ascent));
buildSlopeInfo();
if (isTransparentBackground()) {
view.setBackgroundDrawable(null);
}
}
FrameLayout analyseButton = (FrameLayout) view.findViewById(R.id.analyse_button);
TextView analyseButtonDescr = (TextView) view.findViewById(R.id.analyse_button_descr);
private void buildSlopeInfo() {
GPXTrackAnalysis analysis = gpx.getAnalysis(0);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, analyseButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, analyseButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, analyseButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
buildHeader(analysis);
if (analysis.hasElevationData) {
((TextView) view.findViewById(R.id.average_text)).setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
((TextView) view.findViewById(R.id.range_text)).setText(min + " - " + max);
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
((TextView) view.findViewById(R.id.descent_text)).setText(desc);
((TextView) view.findViewById(R.id.ascent_text)).setText(asc);
((ImageView) view.findViewById(R.id.average_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_average));
((ImageView) view.findViewById(R.id.range_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_average));
((ImageView) view.findViewById(R.id.descent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_descent));
((ImageView) view.findViewById(R.id.ascent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_ascent));
TextView analyseButtonDescr = (TextView) view.findViewById(R.id.analyse_button_descr);
FrameLayout analyseButton = (FrameLayout) view.findViewById(R.id.analyse_button);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, analyseButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, analyseButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, analyseButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
analyseButton.setOnClickListener(onAnalyseClickListener);
}
analyseButton.setOnClickListener(onAnalyseClickListener);
view.findViewById(R.id.altitude_container).setVisibility(analysis.hasElevationData ? View.VISIBLE : View.GONE);
view.findViewById(R.id.slope_info_divider).setVisibility(analysis.hasElevationData ? View.VISIBLE : View.GONE);
view.findViewById(R.id.slope_container).setVisibility(analysis.hasElevationData ? View.VISIBLE : View.GONE);
view.findViewById(R.id.buttons_container).setVisibility(analysis.hasElevationData ? View.VISIBLE : View.GONE);
}
@Nullable

View file

@ -1003,7 +1003,8 @@ public class MapInfoWidgetsFactory {
all.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
WaypointsFragment.showInstance(map);
map.hideContextAndRouteInfoMenus();
WaypointsFragment.showInstance(map.getSupportFragmentManager());
}
});
remove.setOnClickListener(new OnClickListener() {