From 241233315c6f461831f483a76327f3c6d2bd5eb8 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 1 Mar 2019 18:39:19 +0200 Subject: [PATCH 1/7] Add addressLookupRequest and fix night mode colors and fix statistic legends sorting --- .../net/osmand/router/RouteStatistics.java | 78 +++++------ OsmAnd/res/layout/route_info_card.xml | 3 +- OsmAnd/res/layout/route_info_header.xml | 10 +- .../route_info_menu_control_buttons.xml | 132 ++++++++---------- OsmAnd/res/layout/route_info_statistic.xml | 2 + OsmAnd/res/layout/transport_route_card.xml | 8 +- .../ShowRouteInfoDialogFragment.java | 93 ++++++------ .../net/osmand/plus/helpers/GpxUiHelper.java | 6 +- .../MapRouteInfoMenuFragment.java | 2 - .../WaypointsFragment.java | 3 - .../routepreparationmenu/cards/BaseCard.java | 3 - .../cards/HistoryCard.java | 6 - .../cards/HomeWorkCard.java | 7 - .../cards/PreviousRouteCard.java | 9 +- .../cards/PublicTransportCard.java | 35 ++--- .../cards/RouteInfoCard.java | 26 ++-- .../cards/RouteStatisticCard.java | 18 +-- .../cards/SimpleRouteCard.java | 13 +- .../cards/TracksCard.java | 4 - 19 files changed, 187 insertions(+), 271 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteStatistics.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteStatistics.java index 9876e46ed5..bacd94d9f9 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteStatistics.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteStatistics.java @@ -113,102 +113,96 @@ public class RouteStatistics { public abstract String getColorName(E attribute); } - private static class RouteSurfaceStatisticComputer extends RouteStatisticComputer { + private static class RouteSurfaceStatisticComputer extends RouteStatisticComputer { public RouteSurfaceStatisticComputer(List 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 { + private static class RouteSmoothnessStatisticComputer extends RouteStatisticComputer { public RouteSmoothnessStatisticComputer(List 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 { + private static class RouteClassStatisticComputer extends RouteStatisticComputer { public RouteClassStatisticComputer(List 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 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 surfaces = new TreeSet<>(); final String colorAttrName; diff --git a/OsmAnd/res/layout/route_info_card.xml b/OsmAnd/res/layout/route_info_card.xml index 36ffde51ba..94e1735f4d 100644 --- a/OsmAnd/res/layout/route_info_card.xml +++ b/OsmAnd/res/layout/route_info_card.xml @@ -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"> @@ -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 @@ @@ -216,7 +214,6 @@ + android:layout_height="48dp" + android:orientation="horizontal"> - + - - - + android:background="?attr/selectableItemBackground" + android:ellipsize="end" + android:gravity="center" + android:letterSpacing="@dimen/text_button_letter_spacing" + android:maxLines="1" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:text="@string/shared_string_cancel" + android:textSize="@dimen/text_button_text_size" + osmand:typeface="@string/font_roboto_medium" + tools:ignore="UnusedAttribute" /> - + - + - + android:layout_gravity="bottom" + android:max="100" + android:visibility="gone" + tools:progress="60" + tools:progressDrawable="?attr/size_progress_bar" /> - + - + - - - - - + \ No newline at end of file diff --git a/OsmAnd/res/layout/route_info_statistic.xml b/OsmAnd/res/layout/route_info_statistic.xml index e71f073e5a..075385104e 100644 --- a/OsmAnd/res/layout/route_info_statistic.xml +++ b/OsmAnd/res/layout/route_info_statistic.xml @@ -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" /> + android:paddingTop="@dimen/content_padding" + android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"> @@ -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" /> diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index 1d37a7e6fd..38d01e2057 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -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; @@ -172,6 +173,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,12 +192,11 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { dismiss(); } }); + toolbar.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.bg_color_dark : R.color.bg_color_light)); buildMenuButtons(); - 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 routes = routingHelper.getTransportRoutingHelper().getRoutes(); @@ -207,16 +216,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { } 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); @@ -467,7 +468,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { private void createRouteStatisticCards(LinearLayout cardsContainer) { MapActivity mapActivity = getMapActivity(); - if(mapActivity==null){ + if (mapActivity == null) { return; } if (gpx.hasAltitude) { @@ -590,7 +591,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 +605,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 +632,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 +682,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 +723,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 +760,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 +798,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 +818,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); } @@ -1076,6 +1058,21 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { ((LinearLayout) view).addView(baseItemView); } + + protected void acquireStreetName(LatLon latLon, final String currentAddress, final TextView locationTv, final LinearLayout container) { + GeocodingLookupService.AddressLookupRequest addressLookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() { + @Override + public void geocodingDone(String address) { + if (!TextUtils.isEmpty(address) && !address.equals(currentAddress)) { + locationTv.setText(address); + container.setMinimumHeight(dpToPx(80)); + } + } + }, 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 +1183,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); @@ -1227,8 +1224,9 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { buildDescriptionView(secondaryText, llText, 8); buildTitleView(title, llText); - if (!TextUtils.isEmpty(locationText)) { - buildDescriptionView(locationText, llText, 4); + if (location != null) { + TextView locDescr = (TextView) buildDescriptionView(null, llText, 4); + acquireStreetName(location, title.toString(), locDescr, llText); } if (!TextUtils.isEmpty(timeText)) { @@ -1333,7 +1331,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { container.addView(titleView); } - private void buildDescriptionView(Spannable description, LinearLayout container, int paddingTop) { + private View buildDescriptionView(Spannable description, LinearLayout container, int paddingTop) { 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); @@ -1343,6 +1341,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { AndroidUtils.setTextSecondaryColor(app, textViewDescription, nightMode); textViewDescription.setText(description); container.addView(textViewDescription); + return textViewDescription; } private LinearLayout buildTextContainerView() { diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 4fc6583056..717b515d06 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -1198,7 +1198,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 { @@ -1235,6 +1236,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(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index 01b860991a..d0b93df2a3 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java index 3594c3b60c..6fdecf2b7e 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java @@ -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)); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java index 44201e7f88..2486d17b56 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HistoryCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HistoryCard.java index b70c21c501..c59833df79 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HistoryCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HistoryCard.java @@ -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.helpers.SearchHistoryHelper.HistoryEntry; @@ -124,8 +122,4 @@ public class HistoryCard extends BaseCard { ((TextView) view.findViewById(R.id.gpx_card_title)).setText(R.string.shared_string_history); } - - @Override - protected void applyDayNightMode() { - } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HomeWorkCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HomeWorkCard.java index a6a6e1e23a..e7fa7d2558 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HomeWorkCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HomeWorkCard.java @@ -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()); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java index d3000af3ee..0423f3a6cf 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java @@ -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() { - } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PublicTransportCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PublicTransportCard.java index 9ab50066ae..e6883be710 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PublicTransportCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PublicTransportCard.java @@ -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 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() { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteInfoCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteInfoCard.java index 790faa7973..66ac6dd943 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteInfoCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteInfoCard.java @@ -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 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); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java index 1e2aacd29d..c27d3ad54b 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java @@ -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; } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/SimpleRouteCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/SimpleRouteCard.java index 79e9d69f4b..d773743e7f 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/SimpleRouteCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/SimpleRouteCard.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java index d6d46f3810..f842ef007d 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java @@ -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() { - } } From bfb309041d8e59f1c238263bfb346729ef74a751 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 1 Mar 2019 19:13:22 +0200 Subject: [PATCH 2/7] fix possible npe --- .../osmand/plus/activities/ShowRouteInfoDialogFragment.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index 38d01e2057..ae44fedc68 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -1063,7 +1063,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { GeocodingLookupService.AddressLookupRequest addressLookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() { @Override public void geocodingDone(String address) { - if (!TextUtils.isEmpty(address) && !address.equals(currentAddress)) { + if (!TextUtils.isEmpty(address) && !address.equals(currentAddress) + && locationTv != null && container != null) { locationTv.setText(address); container.setMinimumHeight(dpToPx(80)); } @@ -2196,4 +2197,4 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { } } } -} \ No newline at end of file +} From 82045c95e00a33576ed459879b6721f775af1678 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 4 Mar 2019 13:44:22 +0200 Subject: [PATCH 3/7] Fix several bugs and improve ui --- OsmAnd/res/layout/plan_route_info.xml | 9 ++- .../res/layout/route_waypoints_fragment.xml | 2 +- .../ShowRouteInfoDialogFragment.java | 75 +++++++++++-------- .../base/MenuBottomSheetDialogFragment.java | 4 +- .../ShowAlongTheRouteBottomSheet.java | 2 +- .../WaypointsFragment.java | 10 ++- 6 files changed, 61 insertions(+), 41 deletions(-) diff --git a/OsmAnd/res/layout/plan_route_info.xml b/OsmAnd/res/layout/plan_route_info.xml index e0e17a4ea9..c2b927037e 100644 --- a/OsmAnd/res/layout/plan_route_info.xml +++ b/OsmAnd/res/layout/plan_route_info.xml @@ -123,8 +123,9 @@ diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index 38d01e2057..5d723c1f05 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -150,6 +150,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { private int zoomButtonsHeight; private int routeId; + private String destinationStreetStr = ""; private OsmandApplication app; private RoutingHelper routingHelper; @@ -195,25 +196,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { toolbar.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.bg_color_dark : R.color.bg_color_light)); buildMenuButtons(); + updateCards(); - LinearLayout cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container); - - if (routeId != -1) { - List 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); minHalfY = viewHeight - (int) (viewHeight * .75f); @@ -428,6 +412,30 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { return view; } + private void updateCards() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null && view != null) { + LinearLayout cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container); + cardsContainer.removeAllViews(); + if (routeId != -1) { + List 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); @@ -574,7 +582,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); @@ -855,7 +863,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); @@ -950,7 +958,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); @@ -1032,7 +1040,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); @@ -1059,13 +1067,13 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { } - protected void acquireStreetName(LatLon latLon, final String currentAddress, final TextView locationTv, final LinearLayout container) { + protected void acquireStreetName(LatLon latLon) { GeocodingLookupService.AddressLookupRequest addressLookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() { @Override public void geocodingDone(String address) { - if (!TextUtils.isEmpty(address) && !address.equals(currentAddress)) { - locationTv.setText(address); - container.setMinimumHeight(dpToPx(80)); + if (!TextUtils.isEmpty(address)) { + destinationStreetStr = address; + updateCards(); } } }, null); @@ -1221,12 +1229,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 (location != null) { - TextView locDescr = (TextView) buildDescriptionView(null, llText, 4); - acquireStreetName(location, title.toString(), locDescr, llText); + if (!TextUtils.isEmpty(destinationStreetStr)) { + if (!title.toString().equals(destinationStreetStr)) { + buildDescriptionView(new SpannableString(destinationStreetStr), llText, 4, 4); + } + } else { + acquireStreetName(location); + } } if (!TextUtils.isEmpty(timeText)) { @@ -1331,10 +1344,10 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { container.addView(titleView); } - private View buildDescriptionView(Spannable description, LinearLayout container, int paddingTop) { + private View 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); diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 590c383ea2..bc12728b5a 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -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)); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java index c7d1a597cb..3aef796c58 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java @@ -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(); } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java index 6fdecf2b7e..64e4238e7f 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java @@ -590,10 +590,12 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS } private void updateTitle() { - 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); + 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() { From 24a035dfb4bdf2e8415ecf77001234025b9fb862 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 4 Mar 2019 13:47:37 +0200 Subject: [PATCH 4/7] Rename updateDestinationStreetName --- .../osmand/plus/activities/ShowRouteInfoDialogFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index 5d723c1f05..c26421420f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -1067,7 +1067,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { } - protected void acquireStreetName(LatLon latLon) { + protected void updateDestinationStreetName(LatLon latLon) { GeocodingLookupService.AddressLookupRequest addressLookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() { @Override public void geocodingDone(String address) { @@ -1238,7 +1238,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { buildDescriptionView(new SpannableString(destinationStreetStr), llText, 4, 4); } } else { - acquireStreetName(location); + updateDestinationStreetName(location); } } From c87bd1f60aff58a990620a371b7285fc979d48cc Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 4 Mar 2019 13:57:49 +0200 Subject: [PATCH 5/7] Remove unnecessary changes --- .../osmand/plus/activities/ShowRouteInfoDialogFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index c26421420f..b9017bb07e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -1344,7 +1344,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { container.addView(titleView); } - private View buildDescriptionView(Spannable description, LinearLayout container, int paddingTop, int paddingBottom) { + 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, dpToPx(paddingBottom)); @@ -1354,7 +1354,6 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { AndroidUtils.setTextSecondaryColor(app, textViewDescription, nightMode); textViewDescription.setText(description); container.addView(textViewDescription); - return textViewDescription; } private LinearLayout buildTextContainerView() { From 7b86c16cf8c92e45c4a6187833f0927c5632f5aa Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 4 Mar 2019 14:15:16 +0200 Subject: [PATCH 6/7] Fix nightMode for add point dialog --- .../net/osmand/plus/activities/ShowRouteInfoDialogFragment.java | 1 + .../net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java | 1 - .../plus/routepreparationmenu/cards/RouteStatisticCard.java | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index b9017bb07e..3186dee3cc 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -1620,6 +1620,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)); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 4f219a0dc0..a8a2b8d8c6 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -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); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java index c27d3ad54b..1f8d902d86 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java @@ -129,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) { From 15be7a331675fcc39cc8eeb35e063db04b985fef Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 4 Mar 2019 15:09:00 +0200 Subject: [PATCH 7/7] Add weakReference check for ShowRouteInfoDialogFragment --- .../activities/ShowRouteInfoDialogFragment.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index 3186dee3cc..b2c22fe3f2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -106,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; @@ -151,6 +152,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { private int routeId; private String destinationStreetStr = ""; + private boolean paused; private OsmandApplication app; private RoutingHelper routingHelper; @@ -414,7 +416,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { private void updateCards() { MapActivity mapActivity = getMapActivity(); - if (mapActivity != null && view != null) { + if (mapActivity != null) { LinearLayout cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container); cardsContainer.removeAllViews(); if (routeId != -1) { @@ -1068,12 +1070,14 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { protected void updateDestinationStreetName(LatLon latLon) { + final WeakReference fragmentRef = new WeakReference<>(ShowRouteInfoDialogFragment.this); GeocodingLookupService.AddressLookupRequest addressLookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() { @Override public void geocodingDone(String address) { - if (!TextUtils.isEmpty(address)) { - destinationStreetStr = address; - updateCards(); + ShowRouteInfoDialogFragment fragment = fragmentRef.get(); + if (!TextUtils.isEmpty(address) && fragment != null && !fragment.paused) { + fragment.destinationStreetStr = address; + fragment.updateCards(); } } }, null); @@ -1874,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); @@ -1892,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) {