From 9ab5f67b0b9ef45d0a005cc52ed53766031fb0ed Mon Sep 17 00:00:00 2001 From: chumv Date: Sat, 22 Feb 2025 20:24:50 +0200 Subject: [PATCH 1/2] Move TargetPoint to separate file --- .../osmand/plus/OsmAndLocationProvider.java | 4 +- .../osmand/plus/activities/MapActivity.java | 4 +- .../osmand/plus/auto/NavigationSession.java | 4 +- .../src/net/osmand/plus/auto/TripHelper.java | 2 +- .../plus/auto/screens/SearchScreen.java | 6 +- .../plus/dashboard/DashWaypointsFragment.java | 2 +- .../AddWaypointBottomSheetDialogFragment.java | 2 +- .../plus/helpers/LocationPointWrapper.java | 1 - .../plus/helpers/RestoreNavigationHelper.java | 1 - .../net/osmand/plus/helpers/TargetPoint.java | 127 ++++++++++++ .../plus/helpers/TargetPointsHelper.java | 189 ++++-------------- .../plus/helpers/WaypointDialogHelper.java | 1 - .../osmand/plus/helpers/WaypointHelper.java | 1 - .../plus/mapcontextmenu/MapContextMenu.java | 2 +- .../plus/mapcontextmenu/MenuController.java | 2 +- .../TargetPointMenuController.java | 2 +- .../other/DestinationReachedFragment.java | 5 +- .../plus/mapmarkers/PlanRouteFragment.java | 2 +- .../notifications/NavigationNotification.java | 2 +- .../plugins/accessibility/NavigationInfo.java | 6 +- .../AddPointBottomSheetDialog.java | 2 +- .../CalculateMissingMapsOnlineTask.java | 9 +- .../routepreparationmenu/EmissionHelper.java | 4 +- .../MapRouteInfoMenu.java | 16 +- .../RouteDetailsFragment.java | 8 +- .../RoutingOptionsHelper.java | 10 +- .../SortTargetPointsTask.java | 6 +- .../WaypointsDialogController.java | 2 +- .../WaypointsFragment.java | 4 +- .../cards/PreviousRouteCard.java | 4 +- .../osmand/plus/routing/RouteProvider.java | 2 +- .../osmand/plus/routing/RoutingHelper.java | 4 +- .../plus/routing/RoutingHelperUtils.java | 6 +- .../settings/fragments/HistoryAdapter.java | 4 +- .../NavigationHistorySettingsFragment.java | 2 +- .../src/net/osmand/plus/views/MapActions.java | 7 +- .../src/net/osmand/plus/views/OsmandMap.java | 8 +- .../plus/views/layers/MapMarkersLayer.java | 5 +- .../views/layers/PointNavigationLayer.java | 6 +- .../mapwidgets/widgets/BearingWidget.java | 4 +- .../widgets/DistanceToPointWidget.java | 6 +- .../routeinfo/RouteInfoCalculator.java | 6 +- 42 files changed, 252 insertions(+), 238 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/helpers/TargetPoint.java diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index a2dc032d6ae..cc83957204a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -41,7 +41,7 @@ import net.osmand.plus.helpers.CurrentPositionHelper; import net.osmand.plus.helpers.LocationCallback; import net.osmand.plus.helpers.LocationServiceHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.plugins.PluginsHelper; import net.osmand.plus.plugins.accessibility.NavigationInfo; import net.osmand.plus.routing.RoutingHelper; @@ -732,7 +732,7 @@ public NavigationInfo getNavigationInfo() { } public String getNavigationHint(TargetPoint point) { - String hint = navigationInfo.getDirectionString(point == null ? null : point.point, getHeading()); + String hint = navigationInfo.getDirectionString(point == null ? null : point.getLatLon(), getHeading()); if (hint == null) hint = app.getString(R.string.no_info); return hint; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 8c717111bb9..f281b3fbd4d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -73,7 +73,7 @@ import net.osmand.plus.firstusage.FirstUsageWizardFragment; import net.osmand.plus.helpers.*; import net.osmand.plus.helpers.LockHelper.LockUIAdapter; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.importfiles.ImportHelper; import net.osmand.plus.importfiles.ui.ImportGpxBottomSheetDialogFragment; import net.osmand.plus.keyevent.KeyEventHelper; @@ -637,7 +637,7 @@ protected void onResume() { TargetPointsHelper targets = app.getTargetPointsHelper(); RoutingHelper routingHelper = app.getRoutingHelper(); if (routingHelper.isFollowingMode() - && (!Algorithms.objectEquals(targets.getPointToNavigate().point, routingHelper.getFinalLocation()) || !Algorithms + && (!Algorithms.objectEquals(targets.getPointToNavigate().getLatLon(), routingHelper.getFinalLocation()) || !Algorithms .objectEquals(targets.getIntermediatePointsLatLonNavigation(), routingHelper.getIntermediatePoints()))) { targets.updateRouteAndRefresh(true); } diff --git a/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java b/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java index cf655eb9549..53e2d46e902 100644 --- a/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java +++ b/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java @@ -12,12 +12,10 @@ import android.content.res.Configuration; import android.net.Uri; import android.util.Log; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.car.app.CarContext; -import androidx.car.app.CarToast; import androidx.car.app.Screen; import androidx.car.app.ScreenManager; import androidx.car.app.Session; @@ -54,7 +52,7 @@ import net.osmand.plus.helpers.LocationServiceHelper; import net.osmand.plus.helpers.RestoreNavigationHelper; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.inapp.InAppPurchaseUtils; import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper; diff --git a/OsmAnd/src/net/osmand/plus/auto/TripHelper.java b/OsmAnd/src/net/osmand/plus/auto/TripHelper.java index 83030ff540f..e99401c16e8 100644 --- a/OsmAnd/src/net/osmand/plus/auto/TripHelper.java +++ b/OsmAnd/src/net/osmand/plus/auto/TripHelper.java @@ -21,7 +21,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.routing.NextDirectionInfo; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.data.AnnounceTimeDistances; diff --git a/OsmAnd/src/net/osmand/plus/auto/screens/SearchScreen.java b/OsmAnd/src/net/osmand/plus/auto/screens/SearchScreen.java index 927a555ae47..cd44fb2b541 100644 --- a/OsmAnd/src/net/osmand/plus/auto/screens/SearchScreen.java +++ b/OsmAnd/src/net/osmand/plus/auto/screens/SearchScreen.java @@ -26,7 +26,7 @@ import net.osmand.plus.auto.SearchHelper.SearchHelperListener; import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.routing.RoutingHelper; @@ -301,8 +301,8 @@ private String getPointName(TargetPoint targetPoint) { !description.getName().equals(app.getString(R.string.no_address_found))) { name = description.getName(); } else { - name = PointDescription.getLocationName(app, targetPoint.point.getLatitude(), - targetPoint.point.getLongitude(), true).replace('\n', ' '); + name = PointDescription.getLocationName(app, targetPoint.getLatLon().getLatitude(), + targetPoint.getLatLon().getLongitude(), true).replace('\n', ' '); } } return name; diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java index 0054ab6f9be..ef590a8a151 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java @@ -17,7 +17,7 @@ import net.osmand.plus.R; import net.osmand.plus.dashboard.tools.DashFragmentData.DefaultShouldShow; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.utils.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.tools.DashFragmentData; diff --git a/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java index 1b6084c567b..9f04b453905 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java @@ -16,7 +16,7 @@ import net.osmand.plus.utils.ColorUtilities; import net.osmand.plus.R; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; diff --git a/OsmAnd/src/net/osmand/plus/helpers/LocationPointWrapper.java b/OsmAnd/src/net/osmand/plus/helpers/LocationPointWrapper.java index f7722650b74..4c30893acfe 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/LocationPointWrapper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/LocationPointWrapper.java @@ -13,7 +13,6 @@ import net.osmand.data.WptLocationPoint; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.routing.AlarmInfo; import net.osmand.plus.settings.enums.DrivingRegion; diff --git a/OsmAnd/src/net/osmand/plus/helpers/RestoreNavigationHelper.java b/OsmAnd/src/net/osmand/plus/helpers/RestoreNavigationHelper.java index 3ae843c1999..cf2998e4fb6 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/RestoreNavigationHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/RestoreNavigationHelper.java @@ -12,7 +12,6 @@ import net.osmand.plus.shared.SharedUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; import net.osmand.plus.measurementtool.GpxApproximationParams; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; diff --git a/OsmAnd/src/net/osmand/plus/helpers/TargetPoint.java b/OsmAnd/src/net/osmand/plus/helpers/TargetPoint.java new file mode 100644 index 00000000000..112cd5fadc2 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/TargetPoint.java @@ -0,0 +1,127 @@ +package net.osmand.plus.helpers; + +import static net.osmand.data.PointDescription.POINT_TYPE_TARGET; + +import android.annotation.SuppressLint; +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.data.LatLon; +import net.osmand.data.LocationPoint; +import net.osmand.data.PointDescription; +import net.osmand.plus.R; + +public class TargetPoint implements LocationPoint { + + private final LatLon latLon; + private final PointDescription pointDescription; + + public int index; + public boolean intermediate; + public boolean start; + + public TargetPoint(@NonNull LatLon latLon, @Nullable PointDescription name) { + this.latLon = latLon; + this.pointDescription = name; + } + + public TargetPoint(@NonNull LatLon latLon, @Nullable PointDescription name, int index) { + this.latLon = latLon; + this.pointDescription = name; + this.index = index; + this.intermediate = true; + } + + @NonNull + public LatLon getLatLon() { + return latLon; + } + + @Nullable + public PointDescription getOriginalPointDescription() { + return pointDescription; + } + + @SuppressLint("StringFormatInvalid") + public PointDescription getPointDescription(@NonNull Context ctx) { + String name = getOnlyName(); + if (intermediate) { + String type = (index + 1) + ". " + ctx.getString(R.string.intermediate_point, ""); + return new PointDescription(POINT_TYPE_TARGET, type, name); + } else { + String type = ctx.getString(R.string.destination_point, ""); + return new PointDescription(POINT_TYPE_TARGET, type, name); + } + } + + @NonNull + public String getOnlyName() { + return pointDescription == null ? "" : pointDescription.getName(); + } + + public boolean isSearchingAddress(@NonNull Context ctx) { + return pointDescription != null && pointDescription.isSearchingAddress(ctx); + } + + public double getLatitude() { + return latLon.getLatitude(); + } + + public double getLongitude() { + return latLon.getLongitude(); + } + + @Override + public int getColor() { + return 0; + } + + @Override + public boolean isVisible() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + TargetPoint targetPoint = (TargetPoint) o; + + if (start != targetPoint.start) return false; + if (intermediate != targetPoint.intermediate) return false; + if (index != targetPoint.index) return false; + return latLon.equals(targetPoint.latLon); + + } + + @Override + public int hashCode() { + int result = latLon.hashCode(); + result = 31 * result + index; + result = 31 * result + (start ? 10 : 20); + result = 31 * result + (intermediate ? 100 : 200); + return result; + } + + @Nullable + public static TargetPoint create(@Nullable LatLon point, @Nullable PointDescription name) { + if (point != null) { + return new TargetPoint(point, name); + } + return null; + } + + @Nullable + public static TargetPoint createStartPoint(@Nullable LatLon point, + @Nullable PointDescription name) { + if (point != null) { + TargetPoint target = new TargetPoint(point, name); + target.start = true; + return target; + } + return null; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/helpers/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/helpers/TargetPointsHelper.java index 6911d27b5f2..439b94183db 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/TargetPointsHelper.java @@ -1,16 +1,12 @@ package net.osmand.plus.helpers; -import android.annotation.SuppressLint; -import android.content.Context; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import net.osmand.Location; import net.osmand.StateChangedListener; import net.osmand.data.LatLon; -import net.osmand.data.LocationPoint; import net.osmand.data.PointDescription; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult; @@ -52,108 +48,7 @@ public interface TargetPointChangedListener { void onTargetPointChanged(TargetPoint targetPoint); } - public static class TargetPoint implements LocationPoint { - public LatLon point; - private final PointDescription pointDescription; - public int index; - public boolean intermediate; - public boolean start; - - public TargetPoint(LatLon point, PointDescription name) { - this.point = point; - this.pointDescription = name; - } - - public TargetPoint(LatLon point, PointDescription name, int index) { - this.point = point; - this.pointDescription = name; - this.index = index; - this.intermediate = true; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TargetPoint targetPoint = (TargetPoint) o; - - if (start != targetPoint.start) return false; - if (intermediate != targetPoint.intermediate) return false; - if (index != targetPoint.index) return false; - return point.equals(targetPoint.point); - - } - - @Override - public int hashCode() { - int result = point.hashCode(); - result = 31 * result + index; - result = 31 * result + (start ? 10 : 20); - result = 31 * result + (intermediate ? 100 : 200); - return result; - } - - @SuppressLint("StringFormatInvalid") - public PointDescription getPointDescription(@NonNull Context ctx) { - if (!intermediate) { - return new PointDescription(PointDescription.POINT_TYPE_TARGET, ctx.getString(R.string.destination_point, ""), - getOnlyName()); - } else { - return new PointDescription(PointDescription.POINT_TYPE_TARGET, (index + 1) + ". " + ctx.getString(R.string.intermediate_point, ""), - getOnlyName()); - } - } - - public PointDescription getOriginalPointDescription() { - return pointDescription; - } - - public String getOnlyName() { - return pointDescription == null ? "" : pointDescription.getName(); - } - - public boolean isSearchingAddress(Context ctx) { - return pointDescription != null && pointDescription.isSearchingAddress(ctx); - } - - public static TargetPoint create(LatLon point, PointDescription name) { - if(point != null) { - return new TargetPoint(point, name); - } - return null; - } - - public static TargetPoint createStartPoint(LatLon point, PointDescription name) { - if (point != null) { - TargetPoint target = new TargetPoint(point, name); - target.start = true; - return target; - } - return null; - } - - public double getLatitude() { - return point.getLatitude(); - } - - public double getLongitude() { - return point.getLongitude(); - } - - @Override - public int getColor() { - return 0; - } - - @Override - public boolean isVisible() { - return false; - } - - } - - public TargetPointsHelper(@NonNull OsmandApplication ctx){ + public TargetPointsHelper(@NonNull OsmandApplication ctx) { this.ctx = ctx; this.settings = ctx.getSettings(); this.routingHelper = ctx.getRoutingHelper(); @@ -203,16 +98,16 @@ private void readMyLocationPointFromSettings() { } private void lookupAddressForIntermediatePoint(TargetPoint targetPoint) { - if (targetPoint != null && targetPoint.pointDescription.isSearchingAddress(ctx)) { - cancelPointAddressRequests(targetPoint.point); - AddressLookupRequest lookupRequest = new AddressLookupRequest(targetPoint.point, new OnAddressLookupResult() { + if (targetPoint != null && targetPoint.getOriginalPointDescription().isSearchingAddress(ctx)) { + cancelPointAddressRequests(targetPoint.getLatLon()); + AddressLookupRequest lookupRequest = new AddressLookupRequest(targetPoint.getLatLon(), new OnAddressLookupResult() { @Override public void geocodingDone(String address) { for (TargetPoint p : intermediatePoints) { - if (p.point.equals(targetPoint.point)) { - p.pointDescription.setName(address); - settings.updateIntermediatePoint(p.point.getLatitude(), p.point.getLongitude(), - p.pointDescription); + if (p.getLatLon().equals(targetPoint.getLatLon())) { + p.getOriginalPointDescription().setName(address); + settings.updateIntermediatePoint(p.getLatLon().getLatitude(), p.getLatLon().getLongitude(), + p.getOriginalPointDescription()); updateRouteAndRefresh(false); updateTargetPoint(p); break; @@ -226,16 +121,16 @@ public void geocodingDone(String address) { private void lookupAddressForStartPoint() { if (pointToStart != null && pointToStart.isSearchingAddress(ctx) - && (startPointRequest == null || !startPointRequest.getLatLon().equals(pointToStart.point))) { + && (startPointRequest == null || !startPointRequest.getLatLon().equals(pointToStart.getLatLon()))) { cancelStartPointAddressRequest(); - startPointRequest = new AddressLookupRequest(pointToStart.point, new OnAddressLookupResult() { + startPointRequest = new AddressLookupRequest(pointToStart.getLatLon(), new OnAddressLookupResult() { @Override public void geocodingDone(String address) { startPointRequest = null; if (pointToStart != null) { - pointToStart.pointDescription.setName(address); - settings.setPointToStart(pointToStart.point.getLatitude(), pointToStart.point.getLongitude(), - pointToStart.pointDescription); + pointToStart.getOriginalPointDescription().setName(address); + settings.setPointToStart(pointToStart.getLatLon().getLatitude(), pointToStart.getLatLon().getLongitude(), + pointToStart.getOriginalPointDescription()); updateRouteAndRefresh(false); updateTargetPoint(pointToStart); } @@ -247,16 +142,16 @@ public void geocodingDone(String address) { private void lookupAddressForPointToNavigate() { if (pointToNavigate != null && pointToNavigate.isSearchingAddress(ctx) - && (targetPointRequest == null || !targetPointRequest.getLatLon().equals(pointToNavigate.point))) { + && (targetPointRequest == null || !targetPointRequest.getLatLon().equals(pointToNavigate.getLatLon()))) { cancelTargetPointAddressRequest(); - targetPointRequest = new AddressLookupRequest(pointToNavigate.point, new OnAddressLookupResult() { + targetPointRequest = new AddressLookupRequest(pointToNavigate.getLatLon(), new OnAddressLookupResult() { @Override public void geocodingDone(String address) { targetPointRequest = null; if (pointToNavigate != null) { - pointToNavigate.pointDescription.setName(address); - settings.setPointToNavigate(pointToNavigate.point.getLatitude(), pointToNavigate.point.getLongitude(), - pointToNavigate.pointDescription); + pointToNavigate.getOriginalPointDescription().setName(address); + settings.setPointToNavigate(pointToNavigate.getLatLon().getLatitude(), pointToNavigate.getLatLon().getLongitude(), + pointToNavigate.getOriginalPointDescription()); updateRouteAndRefresh(false); updateTargetPoint(pointToNavigate); } @@ -268,16 +163,16 @@ public void geocodingDone(String address) { private void lookupAddressForMyLocationPoint() { if (myLocationToStart != null && myLocationToStart.isSearchingAddress(ctx) - && (myLocationPointRequest == null || !myLocationPointRequest.getLatLon().equals(myLocationToStart.point))) { + && (myLocationPointRequest == null || !myLocationPointRequest.getLatLon().equals(myLocationToStart.getLatLon()))) { cancelMyLocationPointAddressRequest(); - myLocationPointRequest = new AddressLookupRequest(myLocationToStart.point, new OnAddressLookupResult() { + myLocationPointRequest = new AddressLookupRequest(myLocationToStart.getLatLon(), new OnAddressLookupResult() { @Override public void geocodingDone(String address) { myLocationPointRequest = null; if (myLocationToStart != null) { - myLocationToStart.pointDescription.setName(address); - settings.setMyLocationToStart(myLocationToStart.point.getLatitude(), myLocationToStart.point.getLongitude(), - myLocationToStart.pointDescription); + myLocationToStart.getOriginalPointDescription().setName(address); + settings.setMyLocationToStart(myLocationToStart.getLatLon().getLatitude(), myLocationToStart.getLatLon().getLongitude(), + myLocationToStart.getOriginalPointDescription()); updateRouteAndRefresh(false); updateTargetPoint(myLocationToStart); } @@ -291,7 +186,7 @@ public void geocodingDone(String address) { public TargetPoint getPointToNavigate() { return pointToNavigate; } - + public TargetPoint getPointToStart() { return pointToStart; } @@ -320,7 +215,7 @@ public boolean isBackupPointsAvailable() { public List getIntermediatePoints() { return intermediatePoints; } - + public List getIntermediatePointsNavigation() { List intermediatePoints = new ArrayList<>(); if (settings.USE_INTERMEDIATE_POINTS_NAVIGATION.get()) { @@ -328,20 +223,20 @@ public List getIntermediatePointsNavigation() { } return intermediatePoints; } - + public List getIntermediatePointsLatLon() { List intermediatePointsLatLon = new ArrayList<>(); for (TargetPoint t : this.intermediatePoints) { - intermediatePointsLatLon.add(t.point); + intermediatePointsLatLon.add(t.getLatLon()); } return intermediatePointsLatLon; } - + public List getIntermediatePointsLatLonNavigation() { List intermediatePointsLatLon = new ArrayList<>(); if (settings.USE_INTERMEDIATE_POINTS_NAVIGATION.get()) { for (TargetPoint t : this.intermediatePoints) { - intermediatePointsLatLon.add(t.point); + intermediatePointsLatLon.add(t.getLatLon()); } } return intermediatePointsLatLon; @@ -415,11 +310,11 @@ public void removeAllWayPoints(boolean updateRoute, boolean clearBackup){ public void makeWayPointDestination(boolean updateRoute, int index){ TargetPoint targetPoint = intermediatePoints.remove(index); cancelTargetPointAddressRequest(); - cancelPointAddressRequests(targetPoint.point); + cancelPointAddressRequests(targetPoint.getLatLon()); pointToNavigate = targetPoint; settings.setPointToNavigate(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), - pointToNavigate.pointDescription); + pointToNavigate.getOriginalPointDescription()); pointToNavigate.intermediate = false; settings.deleteIntermediatePoint(index); @@ -438,13 +333,13 @@ public void removeWayPoint(boolean updateRoute, int index) { pointToNavigate = intermediatePoints.remove(sz - 1); pointToNavigate.intermediate = false; settings.setPointToNavigate(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), - pointToNavigate.pointDescription); + pointToNavigate.getOriginalPointDescription()); lookupAddressForPointToNavigate(); } } else if (sz > index) { settings.deleteIntermediatePoint(index); TargetPoint targetPoint = intermediatePoints.remove(index); - cancelPointAddressRequests(targetPoint.point); + cancelPointAddressRequests(targetPoint.getLatLon()); int ind = 0; for(TargetPoint tp : intermediatePoints) { tp.index = ind++; @@ -493,7 +388,7 @@ private Location wrap(LatLon l) { loc.setLongitude(l.getLongitude()); return loc; } - + private Location wrap(TargetPoint l) { if(l == null) { return null; @@ -575,12 +470,12 @@ public void reorderAllTargetPoints(List point, boolean updateRoute) ArrayList names = new ArrayList<>(subList.size()); ArrayList ls = new ArrayList<>(subList.size()); for (int i = 0; i < subList.size(); i++) { - names.add(PointDescription.serializeToString(subList.get(i).pointDescription)); - ls.add(subList.get(i).point); + names.add(PointDescription.serializeToString(subList.get(i).getOriginalPointDescription())); + ls.add(subList.get(i).getLatLon()); } settings.saveIntermediatePoints(ls, names); TargetPoint p = point.get(point.size() - 1); - settings.setPointToNavigate(p.getLatitude(), p.getLongitude(), p.pointDescription); + settings.setPointToNavigate(p.getLatitude(), p.getLongitude(), p.getOriginalPointDescription()); } else { settings.clearIntermediatePoints(); } @@ -594,8 +489,8 @@ public void reorderIntermediatePoints(List points, boolean updateRo ArrayList names = new ArrayList<>(points.size()); ArrayList ls = new ArrayList<>(points.size()); for (int i = 0; i < points.size(); i++) { - names.add(PointDescription.serializeToString(points.get(i).pointDescription)); - ls.add(points.get(i).point); + names.add(PointDescription.serializeToString(points.get(i).getOriginalPointDescription())); + ls.add(points.get(i).getLatLon()); } settings.saveIntermediatePoints(ls, names); } else { @@ -615,11 +510,11 @@ public boolean hasTooLongDistanceToNavigate() { && settings.getCustomRoutingBooleanProperty("height_obstacles", false).getModeValue(routingHelper.getAppMode())) { dist = 50000; } List list = getIntermediatePointsWithTarget(); if(!list.isEmpty()) { - if(current != null && MapUtils.getDistance(list.get(0).point, current.getLatitude(), current.getLongitude()) > dist) { + if(current != null && MapUtils.getDistance(list.get(0).getLatLon(), current.getLatitude(), current.getLongitude()) > dist) { return true; } for(int i = 1; i < list.size(); i++) { - if(MapUtils.getDistance(list.get(i-1).point, list.get(i).point) > dist) { + if(MapUtils.getDistance(list.get(i - 1).getLatLon(), list.get(i).getLatLon()) > dist) { return true; } } @@ -648,7 +543,7 @@ public void navigateToPoint(LatLon point, boolean updateRoute, int intermediate, if(intermediate > intermediatePoints.size()) { TargetPoint pn = getPointToNavigate(); if(pn != null) { - settings.insertIntermediatePoint(pn.getLatitude(), pn.getLongitude(), pn.pointDescription, + settings.insertIntermediatePoint(pn.getLatitude(), pn.getLongitude(), pn.getOriginalPointDescription(), intermediatePoints.size()); } } diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 7d67c26ed87..9f1881b486a 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -22,7 +22,6 @@ import net.osmand.plus.utils.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.views.controls.StableArrayAdapter; import net.osmand.util.Algorithms; diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index d88c50dc5b1..df9fcc3a0d1 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -24,7 +24,6 @@ import net.osmand.data.Amenity.AmenityRoutePoint; import net.osmand.data.LocationPoint; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.routing.AlarmInfo; import net.osmand.plus.routing.AlarmInfoType; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index d74a3bef1b7..e7d84a48766 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -23,7 +23,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.helpers.TargetPointsHelper.TargetPointChangedListener; import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener; import net.osmand.plus.mapcontextmenu.MenuController.MenuState; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 2d105200022..319e9b22237 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -37,7 +37,7 @@ import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.download.IndexItem; import net.osmand.plus.helpers.SearchHistoryHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapseExpandListener; import net.osmand.plus.mapcontextmenu.controllers.*; import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java index 14c4ece797f..54ad002ff0d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java @@ -8,7 +8,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedFragment.java index 9b0345fe723..7b8b70a7364 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedFragment.java @@ -16,14 +16,13 @@ import androidx.fragment.app.FragmentManager; import net.osmand.data.LatLon; -import net.osmand.map.WorldRegion; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.auto.NavigationSession; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.poi.PoiUIFilter; @@ -34,8 +33,6 @@ import net.osmand.plus.utils.AndroidUtils; import net.osmand.plus.utils.UiUtilities; -import java.util.List; - public class DestinationReachedFragment extends Fragment implements RouteCalculationProgressListener { public static final String TAG = DestinationReachedFragment.class.getSimpleName(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index e94ad50b7f0..943b2cb8466 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -40,7 +40,7 @@ import net.osmand.plus.helpers.MapDisplayPositionManager; import net.osmand.plus.helpers.MapDisplayPositionManager.IMapDisplayPositionProvider; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.mapmarkers.PlanRouteOptionsBottomSheetDialogFragment.PlanRouteOptionsFragmentListener; import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback; import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter; diff --git a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java index 2bc3f6424d2..16bbfcad56c 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java @@ -33,7 +33,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.auto.NavigationCarAppService; import net.osmand.plus.auto.NavigationSession; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.NextDirectionInfo; import net.osmand.plus.routing.RouteDirectionInfo; diff --git a/OsmAnd/src/net/osmand/plus/plugins/accessibility/NavigationInfo.java b/OsmAnd/src/net/osmand/plus/plugins/accessibility/NavigationInfo.java index 0ee9a4755bf..f01c8ab208d 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/accessibility/NavigationInfo.java +++ b/OsmAnd/src/net/osmand/plus/plugins/accessibility/NavigationInfo.java @@ -17,7 +17,7 @@ import net.osmand.plus.plugins.PluginsHelper; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.routing.NextDirectionInfo; import net.osmand.plus.routing.RoutingHelper; @@ -327,7 +327,7 @@ public synchronized void updateCompassValue(float heading) { } } else { TargetPoint target = app.getTargetPointsHelper().getPointToNavigate(); - updateTargetDirection((target != null) ? target.point : null, heading); + updateTargetDirection((target != null) ? target.getLatLon() : null, heading); } } @@ -336,7 +336,7 @@ public void show(TargetPoint point, Float heading, Context ctx) { List attributes = new ArrayList(); String item; - item = getDirectionString(point == null ? null : point.point, heading); + item = getDirectionString(point == null ? null : point.getLatLon(), heading); if (item != null) attributes.add(item); item = getSpeedString(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java index bf99cced8f0..b7eefa0e35e 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java @@ -41,7 +41,7 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.MapMarkerDialogHelper; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.mapcontextmenu.other.SelectFavouriteToGoBottomSheet; import net.osmand.plus.mapmarkers.MapMarker; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/CalculateMissingMapsOnlineTask.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/CalculateMissingMapsOnlineTask.java index 69713aa5f6b..8471e91a31a 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/CalculateMissingMapsOnlineTask.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/CalculateMissingMapsOnlineTask.java @@ -9,6 +9,7 @@ import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.helpers.TargetPointsHelper; import net.osmand.plus.onlinerouting.OnlineRoutingHelper; import net.osmand.plus.routing.RouteCalculationResult; @@ -59,16 +60,16 @@ protected Void doInBackground(Void... voids) { List routePoints = previousResult.getMissingMapsPoints(); TargetPointsHelper pointsHelper = app.getTargetPointsHelper(); - TargetPointsHelper.TargetPoint start = pointsHelper.getPointToStart(); - TargetPointsHelper.TargetPoint end = pointsHelper.getPointToNavigate(); + TargetPoint start = pointsHelper.getPointToStart(); + TargetPoint end = pointsHelper.getPointToNavigate(); Location lastKnownLocation = app.getLocationProvider().getLastStaleKnownLocation(); if ((start != null || lastKnownLocation != null) && end != null) { - LatLon startPoint = start != null ? start.point + LatLon startPoint = start != null ? start.getLatLon() : new LatLon(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()); routePoints = CollectionUtils.asOneList( Collections.singletonList(startPoint), pointsHelper.getIntermediatePointsLatLon(), - Collections.singletonList(end.point) + Collections.singletonList(end.getLatLon()) ); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/EmissionHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/EmissionHelper.java index ade76bd1ff1..c28a3bc6041 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/EmissionHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/EmissionHelper.java @@ -17,7 +17,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.resources.DetectRegionTask; import net.osmand.plus.routing.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; @@ -156,6 +156,6 @@ private LatLon getLatLon() { if (targetPoint == null) { targetPoint = targetPointsHelper.getMyLocationToStart(); } - return targetPoint != null ? targetPoint.point : null; + return targetPoint != null ? targetPoint.getLatLon() : null; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index f354950714b..d809632c862 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -70,7 +70,7 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenuFragment; @@ -2217,12 +2217,12 @@ public String generateViaDescription() { } TargetPoint p = points.get(i); String description = p.getOnlyName(); - via.append(getRoutePointDescription(p.point, description)); + via.append(getRoutePointDescription(p.getLatLon(), description)); boolean needAddress = new PointDescription(PointDescription.POINT_TYPE_LOCATION, description).isSearchingAddress(mapActivity) - && !intermediateRequestsLatLon.contains(p.point); + && !intermediateRequestsLatLon.contains(p.getLatLon()); if (needAddress) { - AddressLookupRequest lookupRequest = new AddressLookupRequest(p.point, address -> updateMenu(), null); - intermediateRequestsLatLon.add(p.point); + AddressLookupRequest lookupRequest = new AddressLookupRequest(p.getLatLon(), address -> updateMenu(), null); + intermediateRequestsLatLon.add(p.getLatLon()); app.getGeocodingLookupService().lookupAddress(lookupRequest); } } @@ -2259,7 +2259,7 @@ private void setupFromText(View view) { name = start.getOnlyName().length() > 0 ? start.getOnlyName() : (mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude())); - LatLon latLon = start.point; + LatLon latLon = start.getLatLon(); PointDescription pointDescription = start.getOriginalPointDescription(); boolean needAddress = pointDescription != null && pointDescription.isSearchingAddress(mapActivity); cancelStartPointAddressRequest(); @@ -2293,13 +2293,13 @@ private void setupToText(View view) { TargetPointsHelper targets = app.getTargetPointsHelper(); TargetPoint finish = targets.getPointToNavigate(); if (finish != null) { - toText.setText(getRoutePointDescription(finish.point, finish.getOnlyName())); + toText.setText(getRoutePointDescription(finish.getLatLon(), finish.getOnlyName())); PointDescription pointDescription = finish.getOriginalPointDescription(); boolean needAddress = pointDescription != null && pointDescription.isSearchingAddress(mapActivity); cancelTargetPointAddressRequest(); if (needAddress) { - targetPointRequest = new AddressLookupRequest(finish.point, address -> { + targetPointRequest = new AddressLookupRequest(finish.getLatLon(), address -> { targetPointRequest = null; updateMenu(); }, null); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java index 76d2161cd24..64b890fc1ad 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java @@ -44,7 +44,7 @@ import net.osmand.plus.charts.GPXDataSetType; import net.osmand.plus.charts.OrderedLineDataSet; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.mapcontextmenu.CollapsableView; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu; import net.osmand.plus.measurementtool.MeasurementToolFragment; @@ -614,7 +614,7 @@ private void buildStartItem(@NonNull View view, TargetPoint start, int[] startTi buildStartRow(infoContainer, icon, text, startTitle, imagesContainer, new OnClickListener() { @Override public void onClick(View v) { - showLocationOnMap(start != null ? start.point : null); + showLocationOnMap(start != null ? start.getLatLon() : null); } }); addWalkRouteIcon(imagesContainer); @@ -730,7 +730,7 @@ private void buildDestinationItem(@NonNull View view, TargetPoint destination, i addWalkRouteIcon(imagesContainer); String timeStr = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0] + walkTime); - String name = getRoutePointDescription(destination.point, destination.getOnlyName()); + String name = getRoutePointDescription(destination.getLatLon(), destination.getOnlyName()); SpannableString title = new SpannableString(name); title.setSpan(new CustomTypefaceSpan(typeface), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); title.setSpan(new ForegroundColorSpan(getActiveColor()), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -739,7 +739,7 @@ private void buildDestinationItem(@NonNull View view, TargetPoint destination, i secondaryText.setSpan(new CustomTypefaceSpan(typeface), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); secondaryText.setSpan(new ForegroundColorSpan(getMainFontColor()), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - buildDestinationRow(infoContainer, timeStr, title, secondaryText, destination.point, imagesContainer, v -> showLocationOnMap(destination.point)); + buildDestinationRow(infoContainer, timeStr, title, secondaryText, destination.getLatLon(), imagesContainer, v -> showLocationOnMap(destination.getLatLon())); ((ViewGroup) view).addView(baseItemView); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java index 5e380d22489..8ccccfabc8a 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java @@ -29,7 +29,7 @@ import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.routepreparationmenu.data.PermanentAppModeOptions; import net.osmand.plus.routepreparationmenu.data.RouteMenuAppModes; import net.osmand.plus.routepreparationmenu.data.parameters.*; @@ -233,8 +233,8 @@ private void updateGpxRoutingParameter(OtherLocalRoutingParameter gpxParam) { TargetPoint pointToNavigate = tg.getPointToNavigate(); if (rp.getFile().hasRoute()) { LatLon firstLatLon = new LatLon(firstLoc.getLatitude(), firstLoc.getLongitude()); - LatLon endLocation = pointToStart != null ? pointToStart.point : new LatLon(lastLoc.getLatitude(), lastLoc.getLongitude()); - LatLon startLocation = pointToNavigate != null ? pointToNavigate.point : firstLatLon; + LatLon endLocation = pointToStart != null ? pointToStart.getLatLon() : new LatLon(lastLoc.getLatitude(), lastLoc.getLongitude()); + LatLon startLocation = pointToNavigate != null ? pointToNavigate.getLatLon() : firstLatLon; tg.navigateToPoint(endLocation, false, -1); if (pointToStart != null) { tg.setStartPoint(startLocation, false, null); @@ -243,12 +243,12 @@ private void updateGpxRoutingParameter(OtherLocalRoutingParameter gpxParam) { } else { boolean update = false; if (pointToNavigate == null - || MapUtils.getDistance(pointToNavigate.point, new LatLon(firstLoc.getLatitude(), firstLoc.getLongitude())) < 10) { + || MapUtils.getDistance(pointToNavigate.getLatLon(), new LatLon(firstLoc.getLatitude(), firstLoc.getLongitude())) < 10) { tg.navigateToPoint(new LatLon(lastLoc.getLatitude(), lastLoc.getLongitude()), false, -1); update = true; } if (pointToStart != null - && MapUtils.getDistance(pointToStart.point, + && MapUtils.getDistance(pointToStart.getLatLon(), new LatLon(lastLoc.getLatitude(), lastLoc.getLongitude())) < 10) { tg.setStartPoint(new LatLon(firstLoc.getLatitude(), firstLoc.getLongitude()), false, null); update = true; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/SortTargetPointsTask.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/SortTargetPointsTask.java index f464433cb0f..bd5286e8015 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/SortTargetPointsTask.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/SortTargetPointsTask.java @@ -13,7 +13,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.utils.AndroidUtils; @@ -68,10 +68,10 @@ protected int[] doInBackground(Void[] params) { TargetPoint end = lt.remove(lt.size() - 1); ArrayList al = new ArrayList<>(); for (TargetPoint p : lt) { - al.add(p.point); + al.add(p.getLatLon()); } try { - return new TspAnt().readGraph(al, start.point, end.point).solve(); + return new TspAnt().readGraph(al, start.getLatLon(), end.getLatLon()).solve(); } catch (Exception e) { return null; } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsDialogController.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsDialogController.java index 174d3d657b3..7dded2b9573 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsDialogController.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsDialogController.java @@ -17,7 +17,7 @@ import net.osmand.plus.helpers.LocationPointWrapper; import net.osmand.plus.helpers.MapRouteCalculationProgressListener; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.views.OsmandMapTileView; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java index f9ad05adf12..48330d85057 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java @@ -37,7 +37,7 @@ import net.osmand.plus.base.dialog.interfaces.dialog.IContextDialog; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.LocationPointWrapper; @@ -438,7 +438,7 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) { TargetPoint t = (TargetPoint) w.point; if (t.getOriginalPointDescription() != null && t.getOriginalPointDescription().isSearchingAddress(ctx)) { - AddressLookupRequest lookupRequest = new AddressLookupRequest(t.point, address -> reloadListAdapter(listAdapter), null); + AddressLookupRequest lookupRequest = new AddressLookupRequest(t.getLatLon(), address -> reloadListAdapter(listAdapter), null); ctx.getMyApplication().getGeocodingLookupService().lookupAddress(lookupRequest); } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java index 12821133a45..97e8e0e0f29 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java @@ -10,7 +10,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.activities.MapActivity; import net.osmand.util.Algorithms; @@ -64,7 +64,7 @@ public static String getPointName(@NonNull OsmandApplication app, @Nullable Targ !description.getName().equals(app.getString(R.string.no_address_found))) { name = description.getName(); } else { - name = PointDescription.getLocationName(app, point.point.getLatitude(), point.point.getLongitude(), true) + name = PointDescription.getLocationName(app, point.getLatLon().getLatitude(), point.getLatLon().getLongitude(), true) .replace('\n', ' '); } } diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 8f000c87783..bfbcbe1e334 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -23,7 +23,7 @@ import net.osmand.plus.avoidroads.AvoidRoadsHelper; import net.osmand.plus.avoidroads.DirectionPointsHelper; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.measurementtool.GpxApproximationHelper; import net.osmand.plus.measurementtool.GpxApproximationParams; import net.osmand.plus.onlinerouting.OnlineRoutingHelper; diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 8f45c87c3e2..1e89c28eb29 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -14,7 +14,7 @@ import net.osmand.plus.R; import net.osmand.plus.auto.NavigationSession; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.plus.plugins.PluginsHelper; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; @@ -534,7 +534,7 @@ private boolean updateCurrentRouteStatus(Location currentLocation, double posTol List ll = targets.getIntermediatePointsNavigation(); int ind = -1; for (int i = 0; i < ll.size(); i++) { - if (ll.get(i).point != null && MapUtils.getDistance(ll.get(i).point, rm) < 5) { + if (ll.get(i).getLatLon() != null && MapUtils.getDistance(ll.get(i).getLatLon(), rm) < 5) { name = ll.get(i).getOnlyName(); ind = i; break; diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelperUtils.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelperUtils.java index 2f05967963c..2c66129c812 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelperUtils.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelperUtils.java @@ -7,7 +7,7 @@ import net.osmand.data.LatLon; import net.osmand.data.QuadRect; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.helpers.TargetPointsHelper; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.router.GeneralRouter; @@ -96,8 +96,8 @@ public static QuadRect getRouteRect(@NonNull OsmandApplication app, @NonNull Rou for (Location l : list) { MapUtils.insetLatLonRect(rect, l.getLatitude(), l.getLongitude()); } - List targetPoints = app.getTargetPointsHelper().getIntermediatePointsWithTarget(); - for (TargetPointsHelper.TargetPoint l : targetPoints) { + List targetPoints = app.getTargetPointsHelper().getIntermediatePointsWithTarget(); + for (TargetPoint l : targetPoints) { MapUtils.insetLatLonRect(rect, l.getLatitude(), l.getLongitude()); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/HistoryAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/HistoryAdapter.java index a0c7bc94067..396c37bd819 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/HistoryAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/HistoryAdapter.java @@ -19,7 +19,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.routepreparationmenu.cards.PreviousRouteCard; import net.osmand.plus.search.dialogs.QuickSearchListAdapter; @@ -148,7 +148,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi int colorId = selected ? activeColorId : defaultColorId; viewHolder.title.setText(PreviousRouteCard.getPointName(app, targetPoint)); viewHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_marker_dark, colorId)); - updateCompassVisibility(viewHolder.compassView, targetPoint.point); + updateCompassVisibility(viewHolder.compassView, targetPoint.getLatLon()); } else if (holder instanceof MarkerViewHolder) { MapMarker mapMarker = (MapMarker) getItem(position); int colorId = selected ? MapMarker.getColorId(mapMarker.colorIndex) : defaultColorId; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationHistorySettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationHistorySettingsFragment.java index 117fec51f81..06a9c3c43ba 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationHistorySettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationHistorySettingsFragment.java @@ -19,7 +19,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.search.ShareHistoryAsyncTask; import net.osmand.plus.settings.enums.HistorySource; import net.osmand.plus.utils.AndroidUtils; diff --git a/OsmAnd/src/net/osmand/plus/views/MapActions.java b/OsmAnd/src/net/osmand/plus/views/MapActions.java index ca7ac30bd2d..80c14ebf11b 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapActions.java +++ b/OsmAnd/src/net/osmand/plus/views/MapActions.java @@ -25,6 +25,7 @@ import net.osmand.plus.base.ContextMenuFragment.MenuState; import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.dialogs.DirectionsDialogs; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.helpers.TargetPointsHelper; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapmarkers.MarkersPlanRouteContext; @@ -309,7 +310,7 @@ private void onNavigationClick() { MapActivity.clearPrevActivityIntent(); if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { - TargetPointsHelper.TargetPoint start = targetHelper.getPointToStart(); + TargetPoint start = targetHelper.getPointToStart(); if (start != null) { LatLon latLon = new LatLon(start.getLatitude(), start.getLongitude()); activity.getMapActions().enterRoutePlanningMode(latLon, start.getOriginalPointDescription()); @@ -398,9 +399,9 @@ private void startRoutePlanningWithDestination(LatLon latLon, PointDescription p if (!hasPointToStart) { mapActions.enterRoutePlanningModeGivenGpx(null, null, null, true, true, HEADER_ONLY); } else { - TargetPointsHelper.TargetPoint start = targets.getPointToStart(); + TargetPoint start = targets.getPointToStart(); if (start != null) { - mapActions.enterRoutePlanningModeGivenGpx(null, start.point, start.getOriginalPointDescription(), true, true, HEADER_ONLY); + mapActions.enterRoutePlanningModeGivenGpx(null, start.getLatLon(), start.getOriginalPointDescription(), true, true, HEADER_ONLY); } else { mapActions.enterRoutePlanningModeGivenGpx(null, null, null, true, true, HEADER_ONLY); } diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMap.java b/OsmAnd/src/net/osmand/plus/views/OsmandMap.java index c204ee0bc5b..979002df177 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMap.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMap.java @@ -13,7 +13,7 @@ import net.osmand.plus.auto.NavigationSession; import net.osmand.plus.auto.SurfaceRenderer; import net.osmand.plus.base.MapViewTrackingUtilities; -import net.osmand.plus.helpers.TargetPointsHelper; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.utils.AndroidUtils; @@ -177,14 +177,14 @@ public void fitCurrentRouteToMap(boolean portrait, int leftBottomPaddingPx) { top = Math.max(top, l.getLatitude()); bottom = Math.min(bottom, l.getLatitude()); } - List targetPoints = app.getTargetPointsHelper().getIntermediatePointsWithTarget(); + List targetPoints = app.getTargetPointsHelper().getIntermediatePointsWithTarget(); if (rh.getRoute().hasMissingMaps()) { - TargetPointsHelper.TargetPoint pointToStart = app.getTargetPointsHelper().getPointToStart(); + TargetPoint pointToStart = app.getTargetPointsHelper().getPointToStart(); if (pointToStart != null) { targetPoints.add(pointToStart); } } - for (TargetPointsHelper.TargetPoint l : targetPoints) { + for (TargetPoint l : targetPoints) { left = Math.min(left, l.getLongitude()); right = Math.max(right, l.getLongitude()); top = Math.max(top, l.getLatitude()); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java index 85504a5d3ac..05c530c3d92 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java @@ -15,7 +15,6 @@ import android.os.Message; import android.text.TextPaint; import android.text.TextUtils; -import android.util.Log; import android.util.Pair; import android.view.GestureDetector; import android.view.MotionEvent; @@ -48,7 +47,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MapViewTrackingUtilities; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.render.OsmandDashPathEffect; @@ -546,7 +545,7 @@ public boolean containsLatLon(RotatedTileBox tb, double lat, double lon, double public boolean overlappedByWaypoint(MapMarker marker) { List targetPoints = getApplication().getTargetPointsHelper().getAllPoints(); for (TargetPoint t : targetPoints) { - if (t.point.equals(marker.point)) { + if (t.getLatLon().equals(marker.point)) { return true; } } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java index 5606b61da76..11b1f21ff24 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java @@ -27,7 +27,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.utils.NativeUtilities; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; @@ -286,7 +286,7 @@ public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List points = app.getTargetPointsHelper().getIntermediatePointsWithTarget(); if (!Algorithms.isEmpty(points)) { - destLatLon = points.get(0).point; + destLatLon = points.get(0).getLatLon(); } List markers = app.getMapMarkersHelper().getMapMarkers(); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/DistanceToPointWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/DistanceToPointWidget.java index d49490dfa31..9078a53a583 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/DistanceToPointWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/DistanceToPointWidget.java @@ -12,7 +12,7 @@ import net.osmand.data.LatLon; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.utils.OsmAndFormatter; import net.osmand.plus.utils.FormattedValue; import net.osmand.plus.utils.OsmAndFormatterParams; @@ -96,7 +96,7 @@ public DistanceToDestinationWidget(@NonNull MapActivity mapActivity, @Nullable S @Override public LatLon getPointToNavigate() { TargetPoint targetPoint = mapActivity.getPointToNavigate(); - return targetPoint == null ? null : targetPoint.point; + return targetPoint == null ? null : targetPoint.getLatLon(); } @Override @@ -128,7 +128,7 @@ protected void onClick(OsmandMapTileView view) { @Override public LatLon getPointToNavigate() { TargetPoint targetPoint = targetPointsHelper.getFirstIntermediatePoint(); - return targetPoint == null ? null : targetPoint.point; + return targetPoint == null ? null : targetPoint.getLatLon(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/routeinfo/RouteInfoCalculator.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/routeinfo/RouteInfoCalculator.java index 8fc45c3cbee..d7a3048b02a 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/routeinfo/RouteInfoCalculator.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/routeinfo/RouteInfoCalculator.java @@ -9,7 +9,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.TargetPointsHelper; -import net.osmand.plus.helpers.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.TargetPoint; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.OsmandMapTileView; @@ -41,7 +41,7 @@ public List calculateRouteInformation() { if (destinationInfos.size() < POINTS_LIMIT) { TargetPoint finalDestination = mapActivity.getPointToNavigate(); if (finalDestination != null) { - int distance = getDistanceToDestination(finalDestination.point); + int distance = getDistanceToDestination(finalDestination.getLatLon()); int leftTime = getEstimatedTimeToDestination(); if (isPointNotPassed(distance, leftTime)) { destinationInfos.add(createDestinationInfo(distance, leftTime)); @@ -58,7 +58,7 @@ private List collectNotPassedIntermediatePoints() { TargetPoint intermediate; int intermediatePointIndex = 0; while ((intermediate = targetPointsHelper.getIntermediatePoint(intermediatePointIndex)) != null) { - int distance = getDistanceToIntermediate(intermediate.point, intermediatePointIndex); + int distance = getDistanceToIntermediate(intermediate.getLatLon(), intermediatePointIndex); int estimatedTime = getEstimatedTimeToIntermediate(intermediatePointIndex); if (isPointNotPassed(distance, estimatedTime)) { From 108dcae617a2889b93713064423448c05fe9b8a6 Mon Sep 17 00:00:00 2001 From: chumv Date: Sat, 22 Feb 2025 21:02:41 +0200 Subject: [PATCH 2/2] Fix #21098 --- .../src/net/osmand/data/PointDescription.java | 10 ++--- .../plus/auto/screens/RoutePreviewScreen.java | 24 +++++++---- .../net/osmand/plus/helpers/TargetPoint.java | 9 ++++ .../MapRouteInfoMenu.java | 41 ++++++------------- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/OsmAnd/src/net/osmand/data/PointDescription.java b/OsmAnd/src/net/osmand/data/PointDescription.java index ab2c4127950..eda6cd585d8 100644 --- a/OsmAnd/src/net/osmand/data/PointDescription.java +++ b/OsmAnd/src/net/osmand/data/PointDescription.java @@ -16,6 +16,7 @@ import net.osmand.plus.plugins.PluginsHelper; import net.osmand.plus.plugins.osmedit.OsmEditingPlugin; import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.utils.AndroidUtils; import net.osmand.plus.utils.OsmAndFormatter; import net.osmand.util.Algorithms; @@ -248,11 +249,10 @@ public static Map getLocationData(MapActivity ctx, double lat, return results; } - public static String getLocationNamePlain(Context ctx, double lat, double lon) { - OsmandSettings st = ((OsmandApplication) ctx.getApplicationContext()).getSettings(); - int f = st.COORDINATES_FORMAT.get(); - return OsmAndFormatter.getFormattedCoordinates(lat, lon, f); - + public static String getLocationNamePlain(@NonNull Context ctx, double lat, double lon) { + OsmandApplication app = AndroidUtils.getApp(ctx); + int format = app.getSettings().COORDINATES_FORMAT.get(); + return OsmAndFormatter.getFormattedCoordinates(lat, lon, format); } public static String getLocationOlcName(double lat, double lon) { diff --git a/OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java b/OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java index dd740ef0162..7e925a35de5 100644 --- a/OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java +++ b/OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java @@ -21,7 +21,10 @@ import net.osmand.PlatformUtil; +import net.osmand.data.PointDescription; import net.osmand.plus.auto.TripUtils; +import net.osmand.plus.helpers.TargetPoint; +import net.osmand.plus.helpers.TargetPointsHelper; import net.osmand.plus.shared.SharedUtil; import net.osmand.StateChangedListener; import net.osmand.data.QuadRect; @@ -122,12 +125,14 @@ private void buildRouteByGivenGpx(@NonNull GpxFile gpxFile) { private void updateRoute(boolean newRoute) { OsmandApplication app = getApp(); - RoutingHelper rh = app.getRoutingHelper(); + RoutingHelper routingHelper = app.getRoutingHelper(); + TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); + Distance distance = null; int leftTimeSec = 0; - if (newRoute && rh.isRoutePlanningMode()) { - distance = TripUtils.getDistance(app, rh.getLeftDistance()); - leftTimeSec = rh.getLeftTime(); + if (newRoute && routingHelper.isRoutePlanningMode()) { + distance = TripUtils.getDistance(app, routingHelper.getLeftDistance()); + leftTimeSec = routingHelper.getLeftTime(); } if (distance != null && leftTimeSec > 0) { List routeRows = new ArrayList<>(); @@ -135,9 +140,14 @@ private void updateRoute(boolean newRoute) { description.setSpan(DistanceSpan.create(distance), 0, 1, 0); description.setSpan(DurationSpan.create(leftTimeSec), 4, 5, 0); - String name = QuickSearchListItem.getName(app, searchResult); - String typeName = QuickSearchListItem.getTypeName(app, searchResult); - String title = Algorithms.isEmpty(name) ? typeName : name; + TargetPoint finish = targetPointsHelper.getPointToNavigate(); + String title = finish != null ? finish.getRoutePointDescription(app) : null; + + if (Algorithms.isEmpty(title)) { + String name = QuickSearchListItem.getName(app, searchResult); + String typeName = QuickSearchListItem.getTypeName(app, searchResult); + title = Algorithms.isEmpty(name) ? typeName : name; + } routeRows.add(new Row.Builder().setTitle(title).addText(description).build()); this.routeRows = routeRows; calculating = app.getRoutingHelper().isRouteBeingCalculated(); diff --git a/OsmAnd/src/net/osmand/plus/helpers/TargetPoint.java b/OsmAnd/src/net/osmand/plus/helpers/TargetPoint.java index 112cd5fadc2..eeaf22c5b37 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/TargetPoint.java +++ b/OsmAnd/src/net/osmand/plus/helpers/TargetPoint.java @@ -12,6 +12,7 @@ import net.osmand.data.LocationPoint; import net.osmand.data.PointDescription; import net.osmand.plus.R; +import net.osmand.util.Algorithms; public class TargetPoint implements LocationPoint { @@ -56,6 +57,14 @@ public PointDescription getPointDescription(@NonNull Context ctx) { } } + public String getRoutePointDescription(@NonNull Context ctx) { + String name = getOnlyName(); + if (!Algorithms.isEmpty(name)) { + return name.replace(':', ' '); + } + return PointDescription.getLocationNamePlain(ctx, latLon.getLatitude(), latLon.getLongitude()); + } + @NonNull public String getOnlyName() { return pointDescription == null ? "" : pointDescription.getName(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index d809632c862..a337cfd9936 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -3,6 +3,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.NAVIGATION_APP_MODES_OPTIONS_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.NAVIGATION_OPTIONS_MENU_ID; +import static net.osmand.data.PointDescription.POINT_TYPE_LOCATION; import static net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.MapRouteMenuType.ROUTE_DETAILS; import static net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.MapRouteMenuType.ROUTE_INFO; @@ -2215,14 +2216,16 @@ public String generateViaDescription() { if (i > 0) { via.append(" "); } - TargetPoint p = points.get(i); - String description = p.getOnlyName(); - via.append(getRoutePointDescription(p.getLatLon(), description)); - boolean needAddress = new PointDescription(PointDescription.POINT_TYPE_LOCATION, description).isSearchingAddress(mapActivity) - && !intermediateRequestsLatLon.contains(p.getLatLon()); + TargetPoint point = points.get(i); + String description = point.getOnlyName(); + via.append(point.getRoutePointDescription(mapActivity)); + boolean needAddress = new PointDescription(POINT_TYPE_LOCATION, description) + .isSearchingAddress(mapActivity) + && !intermediateRequestsLatLon.contains(point.getLatLon()); if (needAddress) { - AddressLookupRequest lookupRequest = new AddressLookupRequest(p.getLatLon(), address -> updateMenu(), null); - intermediateRequestsLatLon.add(p.getLatLon()); + AddressLookupRequest lookupRequest = new AddressLookupRequest(point.getLatLon(), + address -> updateMenu(), null); + intermediateRequestsLatLon.add(point.getLatLon()); app.getGeocodingLookupService().lookupAddress(lookupRequest); } } @@ -2231,25 +2234,6 @@ public String generateViaDescription() { return ""; } - public String getRoutePointDescription(double lat, double lon) { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - return PointDescription.getLocationNamePlain(mapActivity, lat, lon); - } - return ""; - } - - public String getRoutePointDescription(LatLon l, String d) { - if (d != null && d.length() > 0) { - return d.replace(':', ' '); - } - MapActivity mapActivity = getMapActivity(); - if (l != null && mapActivity != null) { - return getRoutePointDescription(l.getLatitude(), l.getLongitude()); - } - return ""; - } - private void setupFromText(View view) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { @@ -2257,7 +2241,8 @@ private void setupFromText(View view) { String name = null; if (start != null) { name = start.getOnlyName().length() > 0 ? start.getOnlyName() : - (mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude())); + (mapActivity.getString(R.string.route_descr_map_location) + " " + + PointDescription.getLocationNamePlain(mapActivity, start.getLatitude(), start.getLongitude())); LatLon latLon = start.getLatLon(); PointDescription pointDescription = start.getOriginalPointDescription(); @@ -2293,7 +2278,7 @@ private void setupToText(View view) { TargetPointsHelper targets = app.getTargetPointsHelper(); TargetPoint finish = targets.getPointToNavigate(); if (finish != null) { - toText.setText(getRoutePointDescription(finish.getLatLon(), finish.getOnlyName())); + toText.setText(finish.getRoutePointDescription(mapActivity)); PointDescription pointDescription = finish.getOriginalPointDescription(); boolean needAddress = pointDescription != null && pointDescription.isSearchingAddress(mapActivity);