From 30e4753c5e8d3c15f2db9c3074afc6389622345e Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 16 Aug 2016 23:08:15 +0200 Subject: [PATCH] Indicate current road --- .../osmand/plus/activities/MapActivity.java | 158 +++++++++--------- .../osmand/plus/helpers/DiscountHelper.java | 17 +- .../plus/mapcontextmenu/MapContextMenu.java | 30 ++-- .../plus/mapcontextmenu/MenuController.java | 20 +-- .../osmand/plus/routing/RoutingHelper.java | 16 -- .../search/QuickSearchDialogFragment.java | 86 +++++----- .../net/osmand/plus/views/MapInfoLayer.java | 23 ++- .../mapwidgets/MapInfoWidgetsFactory.java | 30 ++-- .../views/mapwidgets/NextTurnInfoWidget.java | 13 +- 9 files changed, 195 insertions(+), 198 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 37a729c99c..2620babe34 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1,5 +1,83 @@ package net.osmand.plus.activities; +import java.io.File; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import net.osmand.Location; +import net.osmand.PlatformUtil; +import net.osmand.StateChangedListener; +import net.osmand.ValueHolder; +import net.osmand.access.AccessibilityPlugin; +import net.osmand.access.MapAccessibilityActions; +import net.osmand.core.android.AtlasMapRendererView; +import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; +import net.osmand.data.QuadPoint; +import net.osmand.data.RotatedTileBox; +import net.osmand.map.MapTileDownloader.DownloadRequest; +import net.osmand.map.MapTileDownloader.IMapDownloaderCallback; +import net.osmand.plus.AppInitializer; +import net.osmand.plus.AppInitializer.AppInitializeListener; +import net.osmand.plus.AppInitializer.InitEvents; +import net.osmand.plus.ApplicationMode; +import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; +import net.osmand.plus.OsmAndConstants; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.TargetPointsHelper; +import net.osmand.plus.TargetPointsHelper.TargetPoint; +import net.osmand.plus.activities.search.SearchActivity; +import net.osmand.plus.base.FailSafeFuntions; +import net.osmand.plus.base.MapViewTrackingUtilities; +import net.osmand.plus.dashboard.DashboardOnMap; +import net.osmand.plus.dialogs.ErrorBottomSheetDialog; +import net.osmand.plus.dialogs.RateUsBottomSheetDialog; +import net.osmand.plus.dialogs.WhatsNewDialogFragment; +import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; +import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment; +import net.osmand.plus.firstusage.FirstUsageWelcomeFragment; +import net.osmand.plus.firstusage.FirstUsageWizardFragment; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.helpers.DiscountHelper; +import net.osmand.plus.helpers.ExternalApiHelper; +import net.osmand.plus.helpers.GpxImportHelper; +import net.osmand.plus.helpers.WakeLockHelper; +import net.osmand.plus.mapcontextmenu.MapContextMenu; +import net.osmand.plus.mapcontextmenu.MapContextMenuFragment; +import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu; +import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; +import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment; +import net.osmand.plus.render.RendererRegistry; +import net.osmand.plus.resources.ResourceManager; +import net.osmand.plus.routing.RoutingHelper; +import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; +import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback; +import net.osmand.plus.search.QuickSearchDialogFragment; +import net.osmand.plus.views.AnimateDraggingMapThread; +import net.osmand.plus.views.MapControlsLayer; +import net.osmand.plus.views.MapInfoLayer; +import net.osmand.plus.views.OsmAndMapLayersView; +import net.osmand.plus.views.OsmAndMapSurfaceView; +import net.osmand.plus.views.OsmandMapLayer; +import net.osmand.plus.views.OsmandMapTileView; +import net.osmand.plus.views.corenative.NativeCoreContext; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; +import net.osmand.render.RenderingRulesStorage; +import net.osmand.util.Algorithms; + +import org.apache.commons.logging.Log; + import android.Manifest; import android.app.Activity; import android.app.AlarmManager; @@ -37,86 +115,6 @@ import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; -import net.osmand.IndexConstants; -import net.osmand.Location; -import net.osmand.PlatformUtil; -import net.osmand.StateChangedListener; -import net.osmand.ValueHolder; -import net.osmand.access.AccessibilityPlugin; -import net.osmand.access.MapAccessibilityActions; -import net.osmand.core.android.AtlasMapRendererView; -import net.osmand.data.LatLon; -import net.osmand.data.PointDescription; -import net.osmand.data.QuadPoint; -import net.osmand.data.RotatedTileBox; -import net.osmand.map.MapTileDownloader.DownloadRequest; -import net.osmand.map.MapTileDownloader.IMapDownloaderCallback; -import net.osmand.plus.AppInitializer; -import net.osmand.plus.AppInitializer.AppInitializeListener; -import net.osmand.plus.AppInitializer.InitEvents; -import net.osmand.plus.ApplicationMode; -import net.osmand.plus.firstusage.FirstUsageWelcomeFragment; -import net.osmand.plus.MapMarkersHelper.MapMarker; -import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; -import net.osmand.plus.OsmAndConstants; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.TargetPointsHelper; -import net.osmand.plus.TargetPointsHelper.TargetPoint; -import net.osmand.plus.activities.search.SearchActivity; -import net.osmand.plus.base.FailSafeFuntions; -import net.osmand.plus.base.MapViewTrackingUtilities; -import net.osmand.plus.dashboard.DashboardOnMap; -import net.osmand.plus.dialogs.ErrorBottomSheetDialog; -import net.osmand.plus.dialogs.RateUsBottomSheetDialog; -import net.osmand.plus.dialogs.WhatsNewDialogFragment; -import net.osmand.plus.download.DownloadActivity; -import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; -import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment; -import net.osmand.plus.firstusage.FirstUsageWizardFragment; -import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.helpers.DiscountHelper; -import net.osmand.plus.helpers.ExternalApiHelper; -import net.osmand.plus.helpers.GpxImportHelper; -import net.osmand.plus.helpers.WakeLockHelper; -import net.osmand.plus.mapcontextmenu.MapContextMenu; -import net.osmand.plus.mapcontextmenu.MapContextMenuFragment; -import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu; -import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; -import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment; -import net.osmand.plus.render.RendererRegistry; -import net.osmand.plus.resources.ResourceManager; -import net.osmand.plus.routing.RoutingHelper; -import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; -import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback; -import net.osmand.plus.search.QuickSearchDialogFragment; -import net.osmand.plus.views.AnimateDraggingMapThread; -import net.osmand.plus.views.MapControlsLayer; -import net.osmand.plus.views.MapInfoLayer; -import net.osmand.plus.views.OsmAndMapLayersView; -import net.osmand.plus.views.OsmAndMapSurfaceView; -import net.osmand.plus.views.OsmandMapLayer; -import net.osmand.plus.views.OsmandMapTileView; -import net.osmand.plus.views.corenative.NativeCoreContext; -import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; -import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController.TopToolbarControllerType; -import net.osmand.render.RenderingRulesStorage; -import net.osmand.util.Algorithms; - -import org.apache.commons.logging.Log; - -import java.io.File; -import java.io.FileFilter; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class MapActivity extends OsmandActionBarActivity implements DownloadEvents, ActivityCompat.OnRequestPermissionsResultCallback, IRouteInformationListener, MapMarkerChangedListener { diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java index 66c5080f54..92f15c0d48 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java @@ -1,11 +1,7 @@ package net.osmand.plus.helpers; -import android.annotation.SuppressLint; -import android.content.Intent; -import android.net.Uri; -import android.os.AsyncTask; -import android.util.Log; -import android.view.View; +import java.text.SimpleDateFormat; +import java.util.Date; import net.osmand.AndroidNetworkUtils; import net.osmand.plus.OsmandApplication; @@ -14,12 +10,17 @@ import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.util.Algorithms; import org.json.JSONObject; -import java.text.SimpleDateFormat; -import java.util.Date; +import android.annotation.SuppressLint; +import android.content.Intent; +import android.net.Uri; +import android.os.AsyncTask; +import android.util.Log; +import android.view.View; public class DiscountHelper { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 6d2189ce1d..d237462fbc 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -1,15 +1,8 @@ package net.osmand.plus.mapcontextmenu; -import android.app.Dialog; -import android.app.ProgressDialog; -import android.content.DialogInterface; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AlertDialog.Builder; -import android.view.View; -import android.widget.LinearLayout; +import java.lang.ref.WeakReference; +import java.util.LinkedList; +import java.util.List; import net.osmand.CallbackWithObject; import net.osmand.StateChangedListener; @@ -46,14 +39,19 @@ import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.ContextMenuLayer; import net.osmand.plus.views.OsmandMapLayer; -import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; -import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController.TopToolbarControllerType; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.util.MapUtils; - -import java.lang.ref.WeakReference; -import java.util.LinkedList; -import java.util.List; +import android.app.Dialog; +import android.app.ProgressDialog; +import android.content.DialogInterface; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v7.app.AlertDialog; +import android.support.v7.app.AlertDialog.Builder; +import android.view.View; +import android.widget.LinearLayout; public class MapContextMenu extends MenuTitleController implements StateChangedListener, MapMarkerChangedListener, TargetPointChangedListener { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 8adb7da565..3da20de9f6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -1,10 +1,9 @@ package net.osmand.plus.mapcontextmenu; -import android.graphics.drawable.Drawable; -import android.support.annotation.NonNull; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.LinearLayout; +import java.io.IOException; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import net.osmand.IndexConstants; import net.osmand.binary.BinaryMapDataObject; @@ -55,13 +54,14 @@ import net.osmand.plus.parkingpoint.ParkingPositionMenuController; import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; - -import java.io.IOException; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; +import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.LinearLayout; public abstract class MenuController extends BaseMenuController { diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index ecfaa54875..1f5586972a 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -737,22 +737,6 @@ public class RoutingHelper { } return formattedStreetName; -// if(destination != null && destination.length() > 0){ -// if(ref != null && ref.length() > 0) { -// destination = ref + " " + destination; -// } -// return destination; -// } else if(name != null && name.length() > 0){ -// if(ref != null && ref.length() > 0) { -// name = ref + " " + name; -// } -// return name; -// } else { -// if(ref == null) { -// return ""; -// } -// return ref; -// } } // protected boolean isDistanceLess(float currentSpeed, double dist, double etalon, float defSpeed){ diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index b22e6d7d04..2f6271164f 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -1,5 +1,48 @@ package net.osmand.plus.search; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import net.osmand.AndroidUtils; +import net.osmand.Location; +import net.osmand.ResultMatcher; +import net.osmand.data.City; +import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; +import net.osmand.osm.AbstractPoiType; +import net.osmand.plus.AppInitializer; +import net.osmand.plus.AppInitializer.AppInitializeListener; +import net.osmand.plus.GPXUtilities; +import net.osmand.plus.GPXUtilities.GPXFile; +import net.osmand.plus.GPXUtilities.WptPt; +import net.osmand.plus.LockableViewPager; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; +import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode; +import net.osmand.plus.helpers.SearchHistoryHelper; +import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; +import net.osmand.plus.poi.PoiUIFilter; +import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; +import net.osmand.search.SearchUICore; +import net.osmand.search.SearchUICore.SearchResultCollection; +import net.osmand.search.core.ObjectType; +import net.osmand.search.core.SearchCoreAPI; +import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI; +import net.osmand.search.core.SearchPhrase; +import net.osmand.search.core.SearchResult; +import net.osmand.search.core.SearchSettings; +import net.osmand.search.core.SearchWord; +import net.osmand.util.Algorithms; +import net.osmand.util.MapUtils; import android.annotation.SuppressLint; import android.app.Dialog; import android.content.DialogInterface; @@ -34,49 +77,6 @@ import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; -import net.osmand.AndroidUtils; -import net.osmand.Location; -import net.osmand.ResultMatcher; -import net.osmand.data.City; -import net.osmand.data.LatLon; -import net.osmand.data.PointDescription; -import net.osmand.osm.AbstractPoiType; -import net.osmand.plus.AppInitializer; -import net.osmand.plus.AppInitializer.AppInitializeListener; -import net.osmand.plus.GPXUtilities; -import net.osmand.plus.GPXUtilities.GPXFile; -import net.osmand.plus.GPXUtilities.WptPt; -import net.osmand.plus.LockableViewPager; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; -import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode; -import net.osmand.plus.helpers.SearchHistoryHelper; -import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; -import net.osmand.plus.poi.PoiUIFilter; -import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI; -import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; -import net.osmand.search.SearchUICore; -import net.osmand.search.SearchUICore.SearchResultCollection; -import net.osmand.search.core.ObjectType; -import net.osmand.search.core.SearchCoreAPI; -import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI; -import net.osmand.search.core.SearchPhrase; -import net.osmand.search.core.SearchResult; -import net.osmand.search.core.SearchSettings; -import net.osmand.search.core.SearchWord; -import net.osmand.util.Algorithms; -import net.osmand.util.MapUtils; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - public class QuickSearchDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener { public static final String TAG = "QuickSearchDialogFragment"; diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index e42e41cefb..ab38b57c48 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -1,14 +1,7 @@ package net.osmand.plus.views; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.support.v4.content.ContextCompat; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.ImageButton; -import android.widget.LinearLayout; +import java.lang.reflect.Field; import net.osmand.data.RotatedTileBox; import net.osmand.plus.OsmandApplication; @@ -17,10 +10,10 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; -import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController.TopToolbarControllerType; -import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; +import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView; import net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapWidgetRegistry; import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo; @@ -33,8 +26,14 @@ import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.LanesControl; import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.RulerWidget; import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.TimeControlWidgetState; import net.osmand.plus.views.mapwidgets.TextInfoWidget; - -import java.lang.reflect.Field; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.support.v4.content.ContextCompat; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.ImageButton; +import android.widget.LinearLayout; public class MapInfoLayer extends OsmandMapLayer { private final MapActivity map; diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index b6169e20fe..672d758ba3 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -12,7 +12,6 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; - import net.osmand.Location; import net.osmand.ValueHolder; import net.osmand.binary.RouteDataObject; @@ -36,7 +35,6 @@ import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; -import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController.TopToolbarControllerType; import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable; import net.osmand.router.TurnType; @@ -44,6 +42,11 @@ import java.util.Iterator; import java.util.LinkedList; public class MapInfoWidgetsFactory { + public enum TopToolbarControllerType { + QUICK_SEARCH, + CONTEXT_MENU, + DISCOUNT, + } public TextInfoWidget createAltitudeControl(final MapActivity map) { final TextInfoWidget altitudeControl = new TextInfoWidget(map) { @@ -200,11 +203,6 @@ public class MapInfoWidgetsFactory { OnClickListener onTitleClickListener; OnClickListener onCloseButtonClickListener; - public enum TopToolbarControllerType { - QUICK_SEARCH, - CONTEXT_MENU, - DISCOUNT, - } public TopToolbarController(TopToolbarControllerType type) { this.type = type; @@ -549,6 +547,13 @@ public class MapInfoWidgetsFactory { text = routingHelper.getCurrentName(type); if (text == null) { text = ""; + } else { + if(type[0] == null){ + type[0] = TurnType.valueOf(TurnType.C, false); + turnDrawable.setColor(R.color.color_myloc_distance); + } else { + turnDrawable.setColor(R.color.nav_arrow); + } } } } else { @@ -558,7 +563,8 @@ public class MapInfoWidgetsFactory { showNextTurn = true; RouteDirectionInfo next = routingHelper.getRouteDirections().get(di); type[0] = next.getTurnType(); - text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName(), ">"); + turnDrawable.setColor(R.color.nav_arrow_distant); + text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName(), "»"); // if (next.distance > 0) { // text += " " + OsmAndFormatter.getFormattedDistance(next.distance, map.getMyApplication()); // } @@ -573,12 +579,13 @@ public class MapInfoWidgetsFactory { RouteDataObject rt = locationProvider.getLastKnownRouteSegment(); if (rt != null) { text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()), - rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), ">"); + rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), "»"); } if (text == null) { text = ""; } else { - text = "+ " + text; + type[0] = TurnType.valueOf(TurnType.C, false); + turnDrawable.setColor(R.color.color_myloc_distance); } } if (map.isTopToolbarActive()) { @@ -595,6 +602,7 @@ public class MapInfoWidgetsFactory { updateVisibility(addressText, true); updateVisibility(addressTextShadow, shadowRad > 0); boolean update = turnDrawable.setTurnType(type[0]); + int h = addressText.getHeight() / 4 * 3; if (h != turnDrawable.getBounds().bottom) { @@ -611,7 +619,7 @@ public class MapInfoWidgetsFactory { addressText.setCompoundDrawables(null, null, null, null); } } - if (!text.equals(addressText.getText().toString()) && !text.equals("+ " + addressText.getText().toString())) { + if (!text.equals(addressText.getText().toString())) { if (!text.equals("")) { topBar.setContentDescription(text); } else { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/NextTurnInfoWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/NextTurnInfoWidget.java index e7a37fba1a..41e9e78c97 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/NextTurnInfoWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/NextTurnInfoWidget.java @@ -21,6 +21,7 @@ import android.graphics.Path; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.support.annotation.ColorRes; import android.text.TextPaint; @@ -127,6 +128,7 @@ public class NextTurnInfoWidget extends TextInfoWidget { private boolean mini; private PointF centerText; private TextPaint textPaint; + private int clr; public TurnDrawable(Context ctx, boolean mini) { this.ctx = ctx; @@ -141,9 +143,16 @@ public class NextTurnInfoWidget extends TextInfoWidget { paintRouteDirection = new Paint(); paintRouteDirection.setStyle(Style.FILL); - paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow)); paintRouteDirection.setAntiAlias(true); - + setColor(R.color.nav_arrow); + } + + @ColorRes + public void setColor(int clr) { + if(clr != this.clr) { + this.clr = clr; + paintRouteDirection.setColor(ctx.getResources().getColor(clr)); + } } @Override