Merge pull request #6597 from osmandapp/RouteInfoDetails

Add addressLookupRequest and improve ui
This commit is contained in:
Alexey 2019-03-04 16:10:04 +03:00 committed by GitHub
commit 10bcd8f8e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 248 additions and 308 deletions

View file

@ -113,102 +113,96 @@ public class RouteStatistics {
public abstract String getColorName(E attribute);
}
private static class RouteSurfaceStatisticComputer extends RouteStatisticComputer<String> {
private static class RouteSurfaceStatisticComputer extends RouteStatisticComputer<RoadSurface> {
public RouteSurfaceStatisticComputer(List<RouteSegmentResult> route) {
super(route, StatisticType.SURFACE);
}
@Override
public String getAttribute(RouteSegmentResult segment) {
public RoadSurface getAttribute(RouteSegmentResult segment) {
String segmentSurface = segment.getSurface();
if (segmentSurface == null) {
return RoadSurface.UNDEFINED.name().toLowerCase();
return RoadSurface.UNDEFINED;
}
for (RoadSurface roadSurface : RoadSurface.values()) {
if (roadSurface.contains(segmentSurface)) {
return roadSurface.name().toLowerCase();
return roadSurface;
}
}
return RoadSurface.UNDEFINED.name().toLowerCase();
return RoadSurface.UNDEFINED;
}
@Override
public String getColorAttrName(String attribute) {
RoadSurface roadSurface = RoadSurface.valueOf(attribute.toUpperCase());
return roadSurface.getColorAttrName();
public String getColorAttrName(RoadSurface attribute) {
return attribute.getColorAttrName();
}
@Override
public String getColorName(String attribute) {
RoadSurface roadSurface = RoadSurface.valueOf(attribute.toUpperCase());
return roadSurface.getColorName();
public String getColorName(RoadSurface attribute) {
return attribute.getColorName();
}
}
private static class RouteSmoothnessStatisticComputer extends RouteStatisticComputer<String> {
private static class RouteSmoothnessStatisticComputer extends RouteStatisticComputer<RoadSmoothness> {
public RouteSmoothnessStatisticComputer(List<RouteSegmentResult> route) {
super(route, StatisticType.SMOOTHNESS);
}
@Override
public String getAttribute(RouteSegmentResult segment) {
public RoadSmoothness getAttribute(RouteSegmentResult segment) {
String segmentSmoothness = segment.getSmoothness();
if (segmentSmoothness == null) {
return RoadSmoothness.UNDEFINED.name().toLowerCase();
return RoadSmoothness.UNDEFINED;
}
for (RoadSmoothness roadSmoothness : RoadSmoothness.values()) {
if (roadSmoothness.contains(segmentSmoothness)) {
return roadSmoothness.name().toLowerCase();
return roadSmoothness;
}
}
return RoadSmoothness.UNDEFINED.name().toLowerCase();
return RoadSmoothness.UNDEFINED;
}
@Override
public String getColorAttrName(String attribute) {
RoadSmoothness roadSmoothness = RoadSmoothness.valueOf(attribute.toUpperCase());
return roadSmoothness.getColorAttrName();
public String getColorAttrName(RoadSmoothness attribute) {
return attribute.getColorAttrName();
}
@Override
public String getColorName(String attribute) {
RoadSmoothness roadSmoothness = RoadSmoothness.valueOf(attribute.toUpperCase());
return roadSmoothness.getColorName();
public String getColorName(RoadSmoothness attribute) {
return attribute.getColorName();
}
}
private static class RouteClassStatisticComputer extends RouteStatisticComputer<String> {
private static class RouteClassStatisticComputer extends RouteStatisticComputer<RoadClass> {
public RouteClassStatisticComputer(List<RouteSegmentResult> route) {
super(route, StatisticType.CLASS);
}
@Override
public String getAttribute(RouteSegmentResult segment) {
public RoadClass getAttribute(RouteSegmentResult segment) {
String segmentClass = segment.getHighway();
if (segmentClass == null) {
return RoadClass.UNDEFINED.name().toLowerCase();
return RoadClass.UNDEFINED;
}
for (RoadClass roadClass : RoadClass.values()) {
if (roadClass.contains(segmentClass)) {
return roadClass.name().toLowerCase();
return roadClass;
}
}
return RoadClass.UNDEFINED.name().toLowerCase();
return RoadClass.UNDEFINED;
}
@Override
public String getColorAttrName(String attribute) {
RoadClass roadClass = RoadClass.valueOf(attribute.toUpperCase());
return roadClass.getColorAttrName();
public String getColorAttrName(RoadClass attribute) {
return attribute.getColorAttrName();
}
@Override
public String getColorName(String attribute) {
RoadClass roadClass = RoadClass.valueOf(attribute.toUpperCase());
return roadClass.getColorName();
public String getColorName(RoadClass attribute) {
return attribute.getColorName();
}
}
@ -516,13 +510,11 @@ public class RouteStatistics {
}
public enum RoadSurface {
UNDEFINED(null, "#e8e8e8", "undefined"),
PAVED(null, "#a7cdf8", "paved"),
UNPAVED(null, "#cc9900", "unpaved"),
ASPHALT(null, "#6f687e", "asphalt"),
CONCRETE(null, "#a7cdf8", "concrete"),
UNPAVED(null, "#cc9900", "unpaved"),
PAVED(null, "#a7cdf8", "paved"),
COMPACTED(null, "#cbcbe8", "compacted"),
GRAVEL(null, "#cbcbe8", "gravel"),
FINE_GRAVEL(null, "#cbcbe8", "fine_gravel"),
PAVING_STONES(null, "#a7cdf8", "paving_stones"),
SETT(null, "#a7cdf8", "sett"),
@ -530,15 +522,17 @@ public class RouteStatistics {
PEBBLESTONE("#a7cdf8", "pebblestone"),
STONE(null, "#a7cdf8", "stone"),
METAL(null, "#a7cdf8", "metal"),
GROUND(null, "#cc9900", "ground", "mud"),
WOOD(null, "#a7cdf8", "wood"),
GRASS_PAVER(null, "#a7bef8", "grass_paver"),
WOOD(null, "#a7cdf8", "wood"),
GRAVEL(null, "#cbcbe8", "gravel"),
GROUND(null, "#cc9900", "ground", "mud"),
CLAY(null, "#cc9900", "clay"),
GRASS(null, "#1fbe1f", "grass"),
SAND(null, "#ffd700", "sand"),
SALT(null, "#7eded8", "salt"),
SNOW(null, "#9feeef", "snow"),
ICE(null, "#9feeef", "ice"),
CLAY(null, "#cc9900", "clay");
UNDEFINED(null, "#e8e8e8", "undefined");
final Set<String> surfaces = new TreeSet<>();
final String colorAttrName;
@ -564,7 +558,6 @@ public class RouteStatistics {
}
public enum RoadSmoothness {
UNDEFINED("redColor", null, "undefined"),
EXCELLENT("orangeColor", null, "excellent"),
GOOD("brownColor", null, "good"),
INTERMEDIATE("darkyellowColor", null, "intermediate"),
@ -572,7 +565,8 @@ public class RouteStatistics {
VERY_BAD("lightgreenColor", null, "very_bad"),
HORRIBLE("greenColor", null, "horrible"),
VERY_HORRIBLE("lightblueColor", null, "very_horrible"),
IMPASSABLE("blueColor", null, "impassable");
IMPASSABLE("blueColor", null, "impassable"),
UNDEFINED("redColor", null, "undefined");
final Set<String> surfaces = new TreeSet<>();
final String colorAttrName;

View file

@ -123,8 +123,9 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="@dimen/route_info_list_item_height"
android:orientation="vertical">
<TextView
@ -235,8 +236,9 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="@dimen/route_info_list_item_height"
android:orientation="vertical">
<TextView
@ -349,8 +351,9 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="@dimen/route_info_list_item_height"
android:orientation="vertical">
<TextView

View file

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:background="?attr/route_info_bg"
android:orientation="vertical">
<FrameLayout
@ -22,6 +22,7 @@
android:maxLines="1"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_button_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:ignore="UnusedAttribute"

View file

@ -4,12 +4,12 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/route_info_bg"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_color"
android:baselineAligned="false"
android:orientation="horizontal"
android:paddingTop="8dp"
@ -40,7 +40,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:textColor="?attr/routeParameterTitleColor"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="26 km" />
@ -83,7 +83,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:textColor="?attr/routeParameterTitleColor"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="20 min" />
@ -106,7 +106,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_color"
android:orientation="vertical">
<com.github.mikephil.charting.charts.LineChart
@ -120,7 +119,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_color"
android:baselineAligned="false"
android:orientation="horizontal"
android:paddingBottom="4dp">
@ -216,7 +214,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_color"
android:baselineAligned="false"
android:orientation="horizontal"
android:paddingTop="4dp"
@ -257,7 +254,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_color"
android:baselineAligned="false"
android:orientation="horizontal"
android:paddingTop="4dp"

View file

@ -2,20 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:id="@+id/dividerControlButtons"
android:layout_width="match_parent"
android:layout_height="1dp"
android:focusable="false" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:baselineAligned="false"
android:orientation="horizontal">
<FrameLayout
@ -85,6 +73,4 @@
</FrameLayout>
</LinearLayout>
</LinearLayout>

View file

@ -11,12 +11,14 @@
android:id="@+id/dividerToDropDown"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"
android:focusable="false" />
<LinearLayout
android:id="@+id/RouteInfoControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/route_info_bg"
android:orientation="vertical">
<LinearLayout

View file

@ -188,7 +188,7 @@
<include
layout="@layout/route_info_menu_control_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/route_info_list_item_height"
android:layout_gravity="bottom" />
</LinearLayout>

View file

@ -20,16 +20,18 @@
android:id="@+id/top_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"
android:focusable="false" />
<LinearLayout
android:id="@+id/routes_info_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/route_info_bg"
android:orientation="vertical"
android:paddingLeft="@dimen/route_info_buttons_padding_top_bottom"
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"
android:paddingTop="@dimen/content_padding">
android:paddingTop="@dimen/content_padding"
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom">
<net.osmand.plus.widgets.FlowLayout
android:id="@+id/routes_badges"
@ -49,6 +51,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="6dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/route_from" />
@ -57,6 +60,7 @@
android:id="@+id/way_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/route_from" />

View file

@ -64,6 +64,7 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.TransportRoute;
import net.osmand.data.TransportStop;
import net.osmand.plus.GeocodingLookupService;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.LockableScrollView;
@ -105,6 +106,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -149,6 +151,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
private int zoomButtonsHeight;
private int routeId;
private String destinationStreetStr = "";
private boolean paused;
private OsmandApplication app;
private RoutingHelper routingHelper;
@ -172,6 +176,15 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
if (args != null) {
routeId = args.getInt(ROUTE_ID_KEY);
}
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
topShadowMargin = AndroidUtils.dpToPx(mapActivity, 9f);
shadowHeight = AndroidUtils.dpToPx(mapActivity, SHADOW_HEIGHT_TOP_DP);
topScreenPosY = addStatusBarHeightIfNeeded(-shadowHeight);
mainView = view.findViewById(R.id.main_view);
nightMode = app.getDaynightHelper().isNightModeForMapControls();
currentMenuState = getInitialMenuState();
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(app.getUIUtilities().getThemedIcon(R.drawable.ic_arrow_back));
@ -182,41 +195,15 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
dismiss();
}
});
toolbar.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.bg_color_dark : R.color.bg_color_light));
buildMenuButtons();
updateCards();
currentMenuState = getInitialMenuState();
LinearLayout cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container);
AndroidUtils.setBackground(app, cardsContainer, nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark);
if (routeId != -1) {
List<TransportRoutePlanner.TransportRouteResult> routes = routingHelper.getTransportRoutingHelper().getRoutes();
if (routes != null && routes.size() > routeId) {
TransportRoutePlanner.TransportRouteResult routeResult = routingHelper.getTransportRoutingHelper().getRoutes().get(routeId);
PublicTransportCard card = new PublicTransportCard(mapActivity, routeResult, routeId);
menuCards.add(card);
cardsContainer.addView(card.build(mapActivity));
buildRowDivider(cardsContainer, false);
buildTransportRouteRow(cardsContainer, routeResult, null, true);
buildRowDivider(cardsContainer, false);
}
} else {
makeGpx();
createRouteStatisticCards(cardsContainer);
createRouteDirections(cardsContainer);
}
processScreenHeight(container);
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
topShadowMargin = AndroidUtils.dpToPx(mapActivity, 9f);
shadowHeight = AndroidUtils.dpToPx(mapActivity, SHADOW_HEIGHT_TOP_DP);
topScreenPosY = addStatusBarHeightIfNeeded(-shadowHeight);
minHalfY = viewHeight - (int) (viewHeight * .75f);
mainView = view.findViewById(R.id.main_view);
nightMode = app.getDaynightHelper().isNightModeForMapControls();
// Zoom buttons
zoomButtonsView = view.findViewById(R.id.map_hud_controls);
ImageButton zoomInButtonView = (ImageButton) view.findViewById(R.id.map_zoom_in_button);
@ -427,6 +414,30 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
return view;
}
private void updateCards() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
LinearLayout cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container);
cardsContainer.removeAllViews();
if (routeId != -1) {
List<TransportRoutePlanner.TransportRouteResult> routes = routingHelper.getTransportRoutingHelper().getRoutes();
if (routes != null && routes.size() > routeId) {
TransportRoutePlanner.TransportRouteResult routeResult = routingHelper.getTransportRoutingHelper().getRoutes().get(routeId);
PublicTransportCard card = new PublicTransportCard(mapActivity, routeResult, routeId);
menuCards.add(card);
cardsContainer.addView(card.build(mapActivity));
buildRowDivider(cardsContainer, false);
buildTransportRouteRow(cardsContainer, routeResult, null, true);
buildRowDivider(cardsContainer, false);
}
} else {
makeGpx();
createRouteStatisticCards(cardsContainer);
createRouteDirections(cardsContainer);
}
}
}
private void createRouteDirections(LinearLayout cardsContainer) {
TextViewEx routeDirectionsTitle = new TextViewEx(app);
AndroidUtils.setTextPrimaryColor(app, routeDirectionsTitle, nightMode);
@ -467,7 +478,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
private void createRouteStatisticCards(LinearLayout cardsContainer) {
MapActivity mapActivity = getMapActivity();
if(mapActivity==null){
if (mapActivity == null) {
return;
}
if (gpx.hasAltitude) {
@ -573,7 +584,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
ImageView routeLine = new ImageView(view.getContext());
FrameLayout.LayoutParams routeLineParams = new FrameLayout.LayoutParams(dpToPx(8f), ViewGroup.LayoutParams.MATCH_PARENT);
routeLineParams.gravity = Gravity.START;
routeLineParams.setMargins(dpToPx(24), dpToPx(14), dpToPx(22), dpToPx(28));
routeLineParams.setMargins(dpToPx(24), dpToPx(14), dpToPx(22), dpToPx(36));
routeLine.setLayoutParams(routeLineParams);
int bgColor = transportStopRoute.getColor(app, nightMode);
routeLine.setBackgroundColor(bgColor);
@ -590,7 +601,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
String timeText = OsmAndFormatter.getFormattedTime(startTime, false);
SpannableString secondaryText = new SpannableString(getString(R.string.sit_on_the_stop) + ":");
secondaryText.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.primary_text_light)), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
secondaryText.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
SpannableString title = new SpannableString(startStop.getName());
title.setSpan(new CustomTypefaceSpan(typeface), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
@ -604,12 +615,12 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
}
SpannableStringBuilder spannable = new SpannableStringBuilder("~");
int startIndex = spannable.length();
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.secondary_text_light)), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.append(OsmAndFormatter.getFormattedDuration(segment.getArrivalTime(), app));
spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
startIndex = spannable.length();
spannable.append("");
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.secondary_text_light)), startIndex, startIndex + 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, startIndex + 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
startIndex = spannable.length();
if (stops.size() > 2) {
spannable.append(String.valueOf(stops.size())).append(" ").append(getString(R.string.transport_stops));
@ -631,7 +642,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
secondaryText.setSpan(new CustomTypefaceSpan(typeface), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
int spaceIndex = secondaryText.toString().indexOf(" ");
if (spaceIndex != -1) {
secondaryText.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.primary_text_light)), 0, spaceIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
secondaryText.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), 0, spaceIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
title = new SpannableString(endStop.getName());
title.setSpan(new CustomTypefaceSpan(typeface), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
@ -681,7 +692,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
int startIndex = spannable.length();
spannable.append(OsmAndFormatter.getFormattedDuration((int) walkTime, app)).append(" ");
spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.primary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.append(getString(R.string.on_foot)).append(" ").append(", ").append(OsmAndFormatter.getFormattedDistance((float) segment.walkDist, app));
buildWalkRow(parent, spannable, listener, null);
@ -722,12 +733,12 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
Typeface typeface = FontCache.getRobotoMedium(app);
SpannableStringBuilder title = new SpannableStringBuilder("~");
int startIndex = title.length();
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.secondary_text_light)), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
title.append(OsmAndFormatter.getFormattedDuration((int) walkTime, app)).append(" ");
title.setSpan(new CustomTypefaceSpan(typeface), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
startIndex = title.length();
title.append(getString(R.string.on_foot)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) finishWalkDist, app));
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.secondary_text_light)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return title;
}
@ -759,13 +770,13 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
long walkTime = (long) getWalkTime(segment.walkDist, walkSpeed);
SpannableStringBuilder title = new SpannableStringBuilder(Algorithms.capitalizeFirstLetter(getString(R.string.on_foot)));
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.secondary_text_light)), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
int startIndex = title.length();
title.append(" ").append(OsmAndFormatter.getFormattedDuration((int) walkTime, app));
title.setSpan(new CustomTypefaceSpan(FontCache.getRobotoMedium(app)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
startIndex = title.length();
title.append(", ").append(OsmAndFormatter.getFormattedDistance((float) segment.walkDist, app));
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.secondary_text_light)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
buildWalkRow(infoContainer, title, listener, imagesContainer);
buildRowDivider(infoContainer, true);
@ -797,13 +808,13 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
long walkTime = (long) getWalkTime(segment.walkDist, walkSpeed);
SpannableStringBuilder spannable = new SpannableStringBuilder("~");
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.secondary_text_light)), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
int startIndex = spannable.length();
spannable.append(OsmAndFormatter.getFormattedDuration((int) walkTime, app)).append(" ");
spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
startIndex = spannable.length();
spannable.append(getString(R.string.on_foot)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) segment.walkDist, app));
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.secondary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
buildWalkRow(infoContainer, spannable, listener, imagesContainer);
buildRowDivider(infoContainer, true);
@ -817,32 +828,13 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
SpannableString secondaryText = new SpannableString(getString(R.string.route_descr_destination) + ":");
secondaryText.setSpan(new CustomTypefaceSpan(typeface), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
secondaryText.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.primary_text_light)), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
secondaryText.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
SpannableStringBuilder locationStr = new SpannableStringBuilder();
String loc = getPointName(destination);
if (!loc.equals(name)) {
locationStr.append(loc);
}
buildDestinationRow(infoContainer, timeStr, title, secondaryText, locationStr, listener, imagesContainer);
buildDestinationRow(infoContainer, timeStr, title, secondaryText, destination.point, listener, imagesContainer);
((ViewGroup) view).addView(baseItemView);
}
private String getPointName(TargetPointsHelper.TargetPoint targetPoint) {
String name = "";
if (targetPoint != null) {
PointDescription description = targetPoint.getOriginalPointDescription();
if (description != null && !Algorithms.isEmpty(description.getName()) &&
!description.getName().equals(getString(R.string.no_address_found))) {
name = description.getName();
} else {
name = PointDescription.getLocationName(app, targetPoint.point.getLatitude(), targetPoint.point.getLongitude(), true).replace('\n', ' ');
}
}
return name;
}
private int getActiveColor() {
return ContextCompat.getColor(app, !nightMode ? R.color.ctx_menu_bottom_view_url_color_light : R.color.ctx_menu_bottom_view_url_color_dark);
}
@ -873,7 +865,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
ll.addView(llText);
if (!TextUtils.isEmpty(secondaryText)) {
buildDescriptionView(secondaryText, llText, 8);
buildDescriptionView(secondaryText, llText, 8, 0);
}
buildTitleView(title, llText);
@ -968,7 +960,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
ll.addView(llText);
if (!TextUtils.isEmpty(secondaryText)) {
buildDescriptionView(secondaryText, llText, 8);
buildDescriptionView(secondaryText, llText, 8, 0);
}
buildTitleView(title, llText);
@ -1050,7 +1042,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
ll.addView(llText);
if (!TextUtils.isEmpty(secondaryText)) {
buildDescriptionView(secondaryText, llText, 8);
buildDescriptionView(secondaryText, llText, 8, 0);
}
buildTitleView(title, llText);
@ -1076,6 +1068,23 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
((LinearLayout) view).addView(baseItemView);
}
protected void updateDestinationStreetName(LatLon latLon) {
final WeakReference<ShowRouteInfoDialogFragment> fragmentRef = new WeakReference<>(ShowRouteInfoDialogFragment.this);
GeocodingLookupService.AddressLookupRequest addressLookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
ShowRouteInfoDialogFragment fragment = fragmentRef.get();
if (!TextUtils.isEmpty(address) && fragment != null && !fragment.paused) {
fragment.destinationStreetStr = address;
fragment.updateCards();
}
}
}, null);
app.getGeocodingLookupService().lookupAddress(addressLookupRequest);
}
public void buildWalkRow(final View view, final Spannable title, View.OnClickListener onClickListener, LinearLayout imagesContainer) {
FrameLayout baseItemView = new FrameLayout(view.getContext());
FrameLayout.LayoutParams baseViewLayoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
@ -1186,7 +1195,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
}
public void buildDestinationRow(final View view, String timeText, final Spannable title, Spannable secondaryText,
Spannable locationText, View.OnClickListener onClickListener, LinearLayout imagesContainer) {
LatLon location, View.OnClickListener onClickListener, LinearLayout imagesContainer) {
FrameLayout baseItemView = new FrameLayout(view.getContext());
FrameLayout.LayoutParams baseViewLayoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
baseItemView.setLayoutParams(baseViewLayoutParams);
@ -1224,11 +1233,17 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
LinearLayout llText = buildTextContainerView();
ll.addView(llText);
buildDescriptionView(secondaryText, llText, 8);
buildDescriptionView(secondaryText, llText, 8, 0);
buildTitleView(title, llText);
if (!TextUtils.isEmpty(locationText)) {
buildDescriptionView(locationText, llText, 4);
if (location != null) {
if (!TextUtils.isEmpty(destinationStreetStr)) {
if (!title.toString().equals(destinationStreetStr)) {
buildDescriptionView(new SpannableString(destinationStreetStr), llText, 4, 4);
}
} else {
updateDestinationStreetName(location);
}
}
if (!TextUtils.isEmpty(timeText)) {
@ -1333,10 +1348,10 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
container.addView(titleView);
}
private void buildDescriptionView(Spannable description, LinearLayout container, int paddingTop) {
private void buildDescriptionView(Spannable description, LinearLayout container, int paddingTop, int paddingBottom) {
TextViewEx textViewDescription = new TextViewEx(view.getContext());
LinearLayout.LayoutParams descriptionParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
descriptionParams.setMargins(0, dpToPx(paddingTop), 0, 0);
descriptionParams.setMargins(0, dpToPx(paddingTop), 0, dpToPx(paddingBottom));
textViewDescription.setLayoutParams(descriptionParams);
textViewDescription.setTypeface(FontCache.getRobotoRegular(view.getContext()));
textViewDescription.setTextSize(14);
@ -1609,6 +1624,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
icon.setImageDrawable(drawable);
label.setText(model.getDescriptionRoutePart());
AndroidUtils.setTextPrimaryColor(app, label, nightMode);
if (model.distance > 0) {
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(model.distance, app));
timeLabel.setText(getTimeDescription(model));
@ -1862,7 +1878,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
@Override
public void onResume() {
super.onResume();
paused = false;
ViewParent parent = view.getParent();
if (parent != null && containerLayoutListener != null) {
((View) parent).addOnLayoutChangeListener(containerLayoutListener);
@ -1880,6 +1896,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
@Override
public void onPause() {
super.onPause();
paused = true;
if (view != null) {
ViewParent parent = view.getParent();
if (parent != null && containerLayoutListener != null) {

View file

@ -174,7 +174,9 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
protected void setupHeightAndBackground(final View mainView) {
final Activity activity = getActivity();
if (activity == null) {
return;
}
final int screenHeight = AndroidUtils.getScreenHeight(activity);
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
final int contentHeight = getContentHeight(screenHeight - statusBarHeight - AndroidUtils.getNavBarHeight(activity));

View file

@ -1216,7 +1216,8 @@ public class GpxUiHelper {
return values;
}
public static void setupHorizontalGPXChart(HorizontalBarChart chart, int yLabelsCount, float topOffset, float bottomOffset, boolean useGesturesAndScale) {
public static void setupHorizontalGPXChart(OsmandApplication app, HorizontalBarChart chart, int yLabelsCount,
float topOffset, float bottomOffset, boolean useGesturesAndScale, boolean nightMode) {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
chart.setHardwareAccelerationEnabled(false);
} else {
@ -1253,6 +1254,9 @@ public class GpxUiHelper {
yr.setDrawGridLines(false);
yr.setAxisMinimum(0f);
yl.setTextColor(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light));
yr.setTextColor(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light));
chart.setFitBars(true);
Legend l = chart.getLegend();

View file

@ -1357,7 +1357,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, pointType.name());
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
fragment.setArguments(args);
fragment.setUsedOnMap(false);
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
}

View file

@ -932,8 +932,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
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,
R.drawable.route_info_trans_gradient_left_light, R.drawable.route_info_trans_gradient_left_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.dividerControlButtons), nightMode,
R.color.divider_light, R.color.divider_dark);
int color = ContextCompat.getColor(ctx, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);

View file

@ -546,7 +546,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
@Override
protected void onPostExecute(Void aVoid) {
ShowAlongTheRouteBottomSheet fragment = fragmentRef.get();
if (fragment != null) {
if (fragment != null && fragment.isAdded()) {
fragment.updateAdapter();
}
}

View file

@ -428,9 +428,6 @@ 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.dividerControlButtons), nightMode,
R.color.divider_light, R.color.divider_dark);
((TextView) view.findViewById(R.id.cancel_button_descr)).setTextColor(
ContextCompat.getColor(mapActivity, nightMode ? R.color.active_buttons_and_links_dark : R.color.route_info_cancel_button_color_light));
@ -593,11 +590,13 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
private void updateTitle() {
if (isAdded()) {
final TextViewEx title = (TextViewEx) view.findViewById(R.id.title);
int pointsSize = app.getTargetPointsHelper().getAllPoints().size();
String text = getString(R.string.shared_string_waypoints) + ": " + (pointsSize != 0 ? pointsSize : 1);
title.setText(text);
}
}
private void applyPointsChanges() {
app.runInUIThread(new Runnable() {

View file

@ -46,7 +46,6 @@ public abstract class BaseCard {
public void update() {
if (view != null) {
updateContent();
applyDayNightMode();
}
}
@ -83,8 +82,6 @@ public abstract class BaseCard {
return app;
}
protected abstract void applyDayNightMode();
@ColorInt
protected int getResolvedColor(@ColorRes int colorId) {
return ContextCompat.getColor(app, colorId);

View file

@ -9,8 +9,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.PointDescription;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchHistoryFragment;
@ -128,8 +126,4 @@ public class HistoryCard extends BaseCard {
((TextView) view.findViewById(R.id.gpx_card_title)).setText(R.string.shared_string_history);
}
@Override
protected void applyDayNightMode() {
}
}

View file

@ -1,12 +1,9 @@
package net.osmand.plus.routepreparationmenu.cards;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.widget.AppCompatImageView;
import android.view.View;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
@ -77,10 +74,6 @@ public class HomeWorkCard extends BaseCard {
});
}
@Override
protected void applyDayNightMode() {
}
private void openAddPointDialog(MapActivity mapActivity, boolean home) {
Bundle args = new Bundle();
args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, home ? PointType.HOME.name() : PointType.WORK.name());

View file

@ -1,11 +1,8 @@
package net.osmand.plus.routepreparationmenu.cards;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.AppCompatImageView;
import android.view.View;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.PointDescription;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
@ -26,7 +23,7 @@ public class PreviousRouteCard extends BaseCard {
@Override
protected void updateContent() {
final TargetPointsHelper targetPointsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
final TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
TextView startTitle = (TextView) view.findViewById(R.id.start_title);
TextView destinationTitle = (TextView) view.findViewById(R.id.destination_title);
@ -74,8 +71,4 @@ public class PreviousRouteCard extends BaseCard {
}
return name;
}
@Override
protected void applyDayNightMode() {
}
}

View file

@ -52,8 +52,6 @@ public class PublicTransportCard extends BaseCard {
@Override
protected void updateContent() {
view.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
List<TransportRouteResultSegment> segments = routeResult.getSegments();
createRouteBadges(segments);
@ -71,26 +69,6 @@ public class PublicTransportCard extends BaseCard {
ShowRouteInfoDialogFragment.showInstance(mapActivity, routeId);
}
});
view.findViewById(R.id.bottom_shadow).setVisibility(showBottomShadow ? View.VISIBLE : View.GONE);
view.findViewById(R.id.card_divider).setVisibility(showTopShadow ? View.VISIBLE : View.GONE);
view.findViewById(R.id.top_divider).setVisibility(!showTopShadow ? View.VISIBLE : View.GONE);
}
public int getRouteId() {
return routeId;
}
public void setSecondButtonVisible(boolean secondButtonVisible) {
this.secondButtonVisible = secondButtonVisible;
}
@Override
protected void applyDayNightMode() {
TextView fromLine = (TextView) view.findViewById(R.id.from_line);
TextView wayLine = (TextView) view.findViewById(R.id.way_line);
AndroidUtils.setTextSecondaryColor(app, fromLine, nightMode);
AndroidUtils.setTextSecondaryColor(app, wayLine, nightMode);
FrameLayout detailsButton = (FrameLayout) view.findViewById(R.id.details_button);
TextView detailsButtonDescr = (TextView) view.findViewById(R.id.details_button_descr);
@ -117,10 +95,17 @@ public class PublicTransportCard extends BaseCard {
} else {
showButton.setVisibility(View.GONE);
}
view.findViewById(R.id.bottom_shadow).setVisibility(showBottomShadow ? View.VISIBLE : View.GONE);
view.findViewById(R.id.card_divider).setVisibility(showTopShadow ? View.VISIBLE : View.GONE);
view.findViewById(R.id.top_divider).setVisibility(!showTopShadow ? View.VISIBLE : View.GONE);
}
AndroidUtils.setBackground(app, view, nightMode, R.color.activity_background_light, R.color.activity_background_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.top_divider), nightMode, R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.routes_info_container), nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark);
public int getRouteId() {
return routeId;
}
public void setSecondButtonVisible(boolean secondButtonVisible) {
this.secondButtonVisible = secondButtonVisible;
}
private SpannableString getFirstLineDescrSpan() {

View file

@ -22,17 +22,19 @@ import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.router.RouteStatistics;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class RouteInfoCard extends BaseCard {
private MapActivity mapActivity;
private RouteStatistics.Statistics routeStatistics;
private GPXUtilities.GPXTrackAnalysis analysis;
public RouteInfoCard(MapActivity mapActivity, RouteStatistics.Statistics routeStatistics, GPXUtilities.GPXTrackAnalysis analysis) {
super(mapActivity);
this.mapActivity = mapActivity;
this.routeStatistics = routeStatistics;
this.analysis = analysis;
}
@ -44,28 +46,22 @@ public class RouteInfoCard extends BaseCard {
@Override
protected void updateContent() {
updateTitle();
updateHeader();
final HorizontalBarChart chart = (HorizontalBarChart) view.findViewById(R.id.chart);
GpxUiHelper.setupHorizontalGPXChart(chart, 5, 10, 10, true);
GpxUiHelper.setupHorizontalGPXChart(app, chart, 5, 10, 10, true, nightMode);
BarData barData = GpxUiHelper.buildStatisticChart(app, chart, routeStatistics, analysis, true, nightMode);
chart.setData(barData);
LinearLayout container = view.findViewById(R.id.route_items);
attachLegend(container, routeStatistics);
}
@Override
protected void applyDayNightMode() {
view.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
private void updateHeader() {
TextView title = (TextView) view.findViewById(R.id.info_type_title);
TextView details = (TextView) view.findViewById(R.id.info_type_details);
details.setTextColor(ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
TextView title = (TextView) view.findViewById(R.id.info_type_title);
AndroidUtils.setTextPrimaryColor(app, title, nightMode);
}
private void updateTitle() {
TextView title = (TextView) view.findViewById(R.id.info_type_title);
String name = getInfoType();
title.setText(name);
details.setTextColor(ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
AndroidUtils.setTextPrimaryColor(app, title, nightMode);
}
private String getInfoType() {
@ -88,7 +84,7 @@ public class RouteInfoCard extends BaseCard {
RouteStatistics.RouteSegmentAttribute<E> segment = partition.get(key);
int color = GpxUiHelper.getColorFromRouteSegmentAttribute(app, segment, nightMode);
Drawable circle = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color);
Spannable text = getSpanLegend(key.toString(), segment);
Spannable text = getSpanLegend(key.toString().toLowerCase(), segment);
TextView legend = new TextView(app);
AndroidUtils.setTextPrimaryColor(app, legend, nightMode);

View file

@ -16,7 +16,6 @@ import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
import com.github.mikephil.charting.listener.ChartTouchListener;
import com.github.mikephil.charting.listener.OnChartGestureListener;
import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper;
@ -32,7 +31,6 @@ import java.util.List;
public class RouteStatisticCard extends BaseCard {
private MapActivity mapActivity;
private GPXFile gpx;
private GpxSelectionHelper.GpxDisplayItem gpxItem;
private GpxUiHelper.OrderedLineDataSet slopeDataSet;
@ -41,7 +39,6 @@ public class RouteStatisticCard extends BaseCard {
public RouteStatisticCard(MapActivity mapActivity, GPXFile gpx, View.OnTouchListener onTouchListener) {
super(mapActivity);
this.mapActivity = mapActivity;
this.gpx = gpx;
this.onTouchListener = onTouchListener;
makeGpxDisplayItem();
@ -54,11 +51,8 @@ public class RouteStatisticCard extends BaseCard {
@Override
protected void updateContent() {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
view.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
OsmandApplication app = getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper();
((ImageView) view.findViewById(R.id.distance_icon)).setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_route_distance));
((ImageView) view.findViewById(R.id.time_icon)).setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_time_span));
@ -68,12 +62,11 @@ public class RouteStatisticCard extends BaseCard {
int hours = time / (60 * 60);
int minutes = (time / 60) % 60;
TextView distanceTv = (TextView) view.findViewById(R.id.distance);
AndroidUtils.setTextSecondaryColor(app, distanceTv, nightMode);
String text = OsmAndFormatter.getFormattedDistance(dist, app);
SpannableStringBuilder distanceStr = new SpannableStringBuilder(text);
int spaceIndex = text.indexOf(" ");
if (spaceIndex != -1) {
distanceStr.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.primary_text_light)), 0, spaceIndex, 0);
distanceStr.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), 0, spaceIndex, 0);
}
distanceTv.setText(distanceStr);
SpannableStringBuilder timeStr = new SpannableStringBuilder();
@ -85,10 +78,9 @@ public class RouteStatisticCard extends BaseCard {
}
spaceIndex = timeStr.toString().lastIndexOf(" ");
if (spaceIndex != -1) {
timeStr.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.primary_text_light)), 0, spaceIndex, 0);
timeStr.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), 0, spaceIndex, 0);
}
TextView timeTv = (TextView) view.findViewById(R.id.time);
AndroidUtils.setTextSecondaryColor(app, timeTv, nightMode);
timeTv.setText(timeStr);
TextView arriveTimeTv = (TextView) view.findViewById(R.id.time_desc);
@ -116,10 +108,6 @@ public class RouteStatisticCard extends BaseCard {
((ImageView) view.findViewById(R.id.ascent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_ascent));
}
@Override
protected void applyDayNightMode() {
}
public GpxUiHelper.OrderedLineDataSet getSlopeDataSet() {
return slopeDataSet;
}
@ -141,7 +129,7 @@ public class RouteStatisticCard extends BaseCard {
private void buildHeader(GPXUtilities.GPXTrackAnalysis analysis) {
final LineChart mChart = (LineChart) view.findViewById(R.id.chart);
GpxUiHelper.setupGPXChart(app, mChart, 4);
GpxUiHelper.setupGPXChart(mChart, 4, 24f, 16f, !nightMode, true);
mChart.setOnTouchListener(onTouchListener);
if (analysis.hasElevationData) {

View file

@ -19,14 +19,11 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.ShowRouteInfoDialogFragment;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.directionInfo;
public class SimpleRouteCard extends BaseCard {
private MapActivity mapActivity;
@ -47,8 +44,6 @@ public class SimpleRouteCard extends BaseCard {
protected void updateContent() {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
view.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
view.findViewById(R.id.dividerToDropDown).setVisibility(View.VISIBLE);
view.findViewById(R.id.route_info_details_card).setVisibility(View.VISIBLE);
@ -103,11 +98,7 @@ public class SimpleRouteCard extends BaseCard {
}
});
buildHeader(view);
}
@Override
protected void applyDayNightMode() {
view.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
FrameLayout detailsButton = view.findViewById(R.id.details_button);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, detailsButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
@ -122,6 +113,8 @@ public class SimpleRouteCard extends BaseCard {
AndroidUtils.setBackground(app, view.findViewById(R.id.RouteInfoControls), nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark);
((TextView) view.findViewById(R.id.details_button_descr)).setTextColor(color);
buildHeader(view);
}
private void buildHeader(View headerView) {

View file

@ -137,8 +137,4 @@ public class TracksCard extends BaseCard {
((TextView) view.findViewById(R.id.gpx_card_title)).setText(
String.format("%s — %d", app.getString(R.string.tracks_on_map), list.size()));
}
@Override
protected void applyDayNightMode() {
}
}