From 2bc189d1e34a18d48c7658c9183f1ce6774077db Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 14 Jul 2013 17:30:04 +0200 Subject: [PATCH] Add point to destination --- OsmAnd/res/layout/calculate_route.xml | 27 ++- OsmAnd/res/values-af/strings.xml | 2 +- OsmAnd/res/values-be/strings.xml | 2 +- OsmAnd/res/values-ca/strings.xml | 2 +- OsmAnd/res/values-cs/strings.xml | 2 +- OsmAnd/res/values-da/strings.xml | 2 +- OsmAnd/res/values-de/strings.xml | 2 +- OsmAnd/res/values-el/strings.xml | 2 +- OsmAnd/res/values-es/strings.xml | 2 +- OsmAnd/res/values-fi/strings.xml | 2 +- OsmAnd/res/values-fr/strings.xml | 2 +- OsmAnd/res/values-he/strings.xml | 2 +- OsmAnd/res/values-hr/strings.xml | 2 +- OsmAnd/res/values-hu/strings.xml | 2 +- OsmAnd/res/values-it/strings.xml | 2 +- OsmAnd/res/values-ja/strings.xml | 2 +- OsmAnd/res/values-ka/strings.xml | 2 +- OsmAnd/res/values-ko/strings.xml | 2 +- OsmAnd/res/values-lt/strings.xml | 2 +- OsmAnd/res/values-lv/strings.xml | 2 +- OsmAnd/res/values-mr/strings.xml | 2 +- OsmAnd/res/values-nb/strings.xml | 2 +- OsmAnd/res/values-nl/strings.xml | 2 +- OsmAnd/res/values-pl/strings.xml | 2 +- OsmAnd/res/values-pt/strings.xml | 2 +- OsmAnd/res/values-ro/strings.xml | 2 +- OsmAnd/res/values-ru/strings.xml | 2 +- OsmAnd/res/values-sk/strings.xml | 2 +- OsmAnd/res/values-sl/strings.xml | 2 +- OsmAnd/res/values-sv/strings.xml | 2 +- OsmAnd/res/values-uk/strings.xml | 2 +- OsmAnd/res/values-zh-rTW/strings.xml | 2 +- OsmAnd/res/values/strings.xml | 13 +- .../osmand/plus/activities/MapActivity.java | 8 +- .../plus/activities/MapActivityActions.java | 177 ++++++++++++------ 35 files changed, 186 insertions(+), 101 deletions(-) diff --git a/OsmAnd/res/layout/calculate_route.xml b/OsmAnd/res/layout/calculate_route.xml index 5109791bcc..33a5ceb040 100644 --- a/OsmAnd/res/layout/calculate_route.xml +++ b/OsmAnd/res/layout/calculate_route.xml @@ -71,17 +71,40 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" - android:layout_marginRight="5dp" > + android:layout_marginRight="5dp" + android:textSize="18sp" > + + + + + + + + + Kaartbron… Definieer uitsig Soek interessante plek - Wys roete van hier af + Gebruik die trekbal om die kaart te skuif Gebruik die trekbal Stel maksimum wagtyd vir agtergrond ligging-vasstelling diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index e33143400d..059c8aff77 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -1209,7 +1209,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Крыніца мапы… Вызначыць выгляд Search POI - Паказаць шлях адсюль + Use trackball to move map Use trackball Set maximum waiting time for each background position fix diff --git a/OsmAnd/res/values-ca/strings.xml b/OsmAnd/res/values-ca/strings.xml index 1775bf2ea0..f543b42360 100644 --- a/OsmAnd/res/values-ca/strings.xml +++ b/OsmAnd/res/values-ca/strings.xml @@ -605,7 +605,7 @@ Ruta Preferits Defineix la visualització -Mostra la ruta des d\'aquí + Utilitzeu el ratolí de bola per moure el mapa Utilitza el ratolí de bola Servei de navegació de l\'OsmAnd diff --git a/OsmAnd/res/values-cs/strings.xml b/OsmAnd/res/values-cs/strings.xml index a36b3abd3c..cc4ceceb41 100644 --- a/OsmAnd/res/values-cs/strings.xml +++ b/OsmAnd/res/values-cs/strings.xml @@ -534,7 +534,7 @@ Zdroj map… Mapová data Hledat POI - Cestovat odsud + Použít trackball k posouvání mapy Použít trackball Vyberte čekací dobu pro určení polohy diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index 9d9c45a02f..e6c6535a3d 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -1133,7 +1133,7 @@ Afghanistan, Albanien, Algeriet, Andorra, Angola, Anguilla, Antigua og Barbuda, Vælg kortkilde… Definer visning Søg interessepunkt - Vis rute herfra + Brug trackball for at flytte kortet Brug trackball Indstil maksimal ventetid mellem hver positionssøgning i baggrunden diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index c9b75ac0dd..4c11dd4e07 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -721,7 +721,7 @@ Kartenquelle… Darstellung Suche POI - Zeige Route von hier + Trackball für Kartenbewegung benutzen Trackball verwenden Maximale Suchzeit für jede Hintergrund-Standortbestimmung diff --git a/OsmAnd/res/values-el/strings.xml b/OsmAnd/res/values-el/strings.xml index bba6c9ae1a..35754fe7f2 100644 --- a/OsmAnd/res/values-el/strings.xml +++ b/OsmAnd/res/values-el/strings.xml @@ -769,7 +769,7 @@ Πηγή χάρτη … Ορισμός εμφάνισης Αναζήτηση ΣΕ - Εμφάνιση διαδρομής από εδώ + Χρήση του trackball για μετακίνηση του χάρτη Χρήση του trackball Ορίστε το μέγιστο χρόνο αναμονής για κάθε εύρεση θέσης στο παρασκήνιο diff --git a/OsmAnd/res/values-es/strings.xml b/OsmAnd/res/values-es/strings.xml index ad127fc87c..947336ce9e 100644 --- a/OsmAnd/res/values-es/strings.xml +++ b/OsmAnd/res/values-es/strings.xml @@ -440,7 +440,7 @@ Fuente de mapas… Definir vista Buscar PDI - Mostrar ruta desde aquí + Usa trackball para mover el mapa Usar trackball Fijar el tiempo de espera máximo para determinar la posición en cada lectura del servicio de fondo diff --git a/OsmAnd/res/values-fi/strings.xml b/OsmAnd/res/values-fi/strings.xml index a58aa79aea..c7e250db30 100644 --- a/OsmAnd/res/values-fi/strings.xml +++ b/OsmAnd/res/values-fi/strings.xml @@ -527,7 +527,7 @@ sekuntia min. Missä olen? - Näytä reitti täältä + Poista KP Kompassi Liikkumissuuntaan diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 7f95ce802d..71c7c3fac6 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -466,7 +466,7 @@ Source de la carte… Couches Chercher un Point d\'Intérêt - Partir depuis ce point + Utiliser le pointeur pour se déplacer sur la carte Utiliser le pointeur Configurer le délai d\'attente pour déterminer l\'emplacement diff --git a/OsmAnd/res/values-he/strings.xml b/OsmAnd/res/values-he/strings.xml index 8cb046758f..4c695e9cb5 100644 --- a/OsmAnd/res/values-he/strings.xml +++ b/OsmAnd/res/values-he/strings.xml @@ -800,7 +800,7 @@ מקור המפה… הגדרת תצוגה חיפוש נ״ע - הצגת מסלול מכאן + יש להשתמש בכדור מעקב כדי להזיז את המפה איפה אני? נתוני הנ״ע עודכנו בהצלחה ({0} נטענו) diff --git a/OsmAnd/res/values-hr/strings.xml b/OsmAnd/res/values-hr/strings.xml index 7c10ce672a..05cc3eab1b 100644 --- a/OsmAnd/res/values-hr/strings.xml +++ b/OsmAnd/res/values-hr/strings.xml @@ -459,7 +459,7 @@ Traži POI Postaje javnog prijevoza POI... - Prikaži rutu odavde + Putovi javnoga prijevoza Ruta Favoriti diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 3c5e132e8b..da5b566236 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -484,7 +484,7 @@ Térképforrás… Rétegek POI keresése - Mutasd az utat innen + Trackball használata a térkép mozgatásához Trackball használata Maximális várakozási idő minden sikeres helymeghatározásra diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index a7de13d7a2..9258980ab0 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -446,7 +446,7 @@ Sorgente mappa… Definisci la vista Cerca PDI - Visualizza il percorso da qui + Utilizza la trackball per muovere la mappa Usa la trackball Scegli l\'intervallo di tempo per determinare la posizione diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index 6a646bac56..3a308fc50a 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -365,7 +365,7 @@ MB)をダウンロードしますか? ビュー定義 POIを検索 - ルート開始位置 + トラックボールを使用してマップを動かす トラックボールを使用 位置修正用の待ち時間をセット diff --git a/OsmAnd/res/values-ka/strings.xml b/OsmAnd/res/values-ka/strings.xml index 633030a9e9..a858fec140 100644 --- a/OsmAnd/res/values-ka/strings.xml +++ b/OsmAnd/res/values-ka/strings.xml @@ -529,7 +529,7 @@ რუკის წყარო… ხედის აღწერა POI-ის ძებნა - გზების ჩვენება მოცემული წერტილიდან + რუკის სამოძრაოდ გამოიყენეთ ტრეკბოლი გამოიყენეთ ტრეკბოლი გთხოვთ დააყენოთ ფონური პოზიცირების ჩასასწორებელი მაქსიმალური დრო diff --git a/OsmAnd/res/values-ko/strings.xml b/OsmAnd/res/values-ko/strings.xml index ca999b81a3..428ada25aa 100644 --- a/OsmAnd/res/values-ko/strings.xml +++ b/OsmAnd/res/values-ko/strings.xml @@ -579,7 +579,7 @@ 뷰 정의 POI 검색 - 시작지점으로 + 맵을 이동하는 데 트랙볼을 사용합니다 트랙볼 사용 위치를 찾는 대기 시간을 선택합니다 diff --git a/OsmAnd/res/values-lt/strings.xml b/OsmAnd/res/values-lt/strings.xml index 3a6a5ce2b1..ed1f701dec 100644 --- a/OsmAnd/res/values-lt/strings.xml +++ b/OsmAnd/res/values-lt/strings.xml @@ -649,7 +649,7 @@ Žemėlapių šaltiniai… Nustatyti vaizdą Ieškoti LV - Rodyti maršrutą nuo čia + Naudoti manipuliatoriaus rutulį žemėlapiui pastumti Naudoti manipuliatoriaus rutulį Nustatyti didžiausią laukimo laiką kiekvienam foniniam vietos nustatymui diff --git a/OsmAnd/res/values-lv/strings.xml b/OsmAnd/res/values-lv/strings.xml index a97f02db6c..94041d5f2e 100644 --- a/OsmAnd/res/values-lv/strings.xml +++ b/OsmAnd/res/values-lv/strings.xml @@ -495,7 +495,7 @@ Kartes avots… Definēt skatu Meklēt POI - Rādīt ceļu no šejienes + Lietojiet trackball lai pārvietotu karti Lietot trackball "Uzstādiet maksimālo gaidīšanas laiku katram fona pozīcijas labojumam" diff --git a/OsmAnd/res/values-mr/strings.xml b/OsmAnd/res/values-mr/strings.xml index 9d8524c796..5f76fb6f6f 100644 --- a/OsmAnd/res/values-mr/strings.xml +++ b/OsmAnd/res/values-mr/strings.xml @@ -190,7 +190,7 @@ आवडती ठिकाणे नकाशाचा स्त्रोत… पिओआय शोधा - इथून रस्ता दाखवा + मी कुठे आहे? नेटवर्क जीपीइस diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index 11fce4ade2..bd46245791 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -453,7 +453,7 @@ Kartkilde… Vis Søk interessepunkt - Vis rute herfra + Hvor er jeg? OsmAnd navigeringstjeneste Nettverk diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index f7caa85160..ddfc73b6d8 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -551,7 +551,7 @@ Kaartbron… Definieer beeld Zoek interessepunt - Toon route vanaf hier + Gebruik trackball om de kaart te verschuiven Gebruik trackball Maximum wachttijd voor elke achtergrond positiebepaling diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml index 2b057e9a8d..5199f93ac8 100644 --- a/OsmAnd/res/values-pl/strings.xml +++ b/OsmAnd/res/values-pl/strings.xml @@ -350,7 +350,7 @@ Źródło mapy… Zdefiniuj widok Szukaj POI - Pokaż trasę z tego miejsca + Użyj trackballa do przesuwania mapy Używaj trackballa Czas oczekiwania na poprawną pozycję GPS diff --git a/OsmAnd/res/values-pt/strings.xml b/OsmAnd/res/values-pt/strings.xml index d5921e7158..1e7944115d 100644 --- a/OsmAnd/res/values-pt/strings.xml +++ b/OsmAnd/res/values-pt/strings.xml @@ -132,7 +132,7 @@ Fonte dos mapas… Definir exibição Encontre um Ponto de Interesse - Exibir rota a partir daqui + Utilize o cursor para mover o mapa Use o cursor Definir o tempo limite para determinar a localização diff --git a/OsmAnd/res/values-ro/strings.xml b/OsmAnd/res/values-ro/strings.xml index 790ab0f20e..748c30493c 100644 --- a/OsmAnd/res/values-ro/strings.xml +++ b/OsmAnd/res/values-ro/strings.xml @@ -806,7 +806,7 @@ Sursă hartă… Straturi Caută POI - Calculează ruta începând de aici + Folosește trackball pentru mișcare hartă Folosește trackball Alege timpul maxim de așteptare pentru fiecare localizare exactă a poziției în fundal diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index cc5564965f..fdd4177a57 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -504,7 +504,7 @@ Источник карты… Слои Искать POI - Маршрут отсюда + Использовать трекбол, чтобы перемещать карту Использовать трекбол Выберите максимальное время поиска позиции сервиса diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index cbd9afe22f..91dda16cea 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -640,7 +640,7 @@ Zdroj mapy… Zobrazenie Hľadať bod záujmu (POI) - Zobraziť trasu odtiaľto + Použitie trackballu na pohyb po mape Použiť trackball Nastaví max. čakaciu dobu pre každú ustálenú pozíciu na pozadí diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml index d7537d2694..0590f21def 100644 --- a/OsmAnd/res/values-sl/strings.xml +++ b/OsmAnd/res/values-sl/strings.xml @@ -530,7 +530,7 @@ Le ceste Običajni zemljevidi Kliknite tu za prenos oz. posodobitev podatkov.\nKliknite na katerokoli element za prikaz podrobnosti, pritisnite in držite za izklop ali brisanje. Količina prostora na napravi (%1$s prosto): - Prikaži pot od tu + Vklopi Izklopi Briši diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index fdcd77aec0..2e796bd83b 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -706,7 +706,7 @@ Kartkälla… Definiera vy Sök POI - Visa rutt härifrån + Använd styrkulan för att flytta kartan Använd styrkula Ange maximal väntetid för varje positionsbestämning i bakgrunden diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 303067584a..df820fd1eb 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -569,7 +569,7 @@ Джерело мапи… Мапа Шукати POI - Маршрут звідси + Використовувати трекбол для руху мапи Використовувати трекбол Виберіть максимальний час для пошуку позиції diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 712de7b13b..c41269fb01 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -740,7 +740,7 @@ 地圖來源… 定義檢視 查尋興趣點 - 由此顯示導航路徑 + 使用軌跡球移動地圖 使用軌跡球 設定背景定位等待時間 diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 67a0a0307d..82e7906681 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,8 +9,14 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> - To: %1$s - Via: %1$s\nTo: %2$s + Directions To + Directions From + Map: + Lat %1$.3f, lon %2$.3f + Current position + + To: + Via: From: Announce alarms… Configure traffic warnings (forced stops, speed bumps), speed camera warnings, speed limits @@ -224,8 +230,6 @@ Speed limit GPX - Lat %1$.3f, lon %2$.3f - Current position No buildings found. Search city incrementally Search villages/postcode @@ -1227,7 +1231,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Map source… Define view Search POI - Show route from here Use trackball to move map Use trackball Set maximum waiting time for each background position fix diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index d0da31688b..29b6c9d50c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -6,6 +6,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import net.osmand.Location; import net.osmand.StateChangedListener; import net.osmand.access.AccessibilityPlugin; import net.osmand.access.AccessibleActivity; @@ -23,6 +24,7 @@ import net.osmand.plus.PoiFilter; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.Version; +import net.osmand.plus.activities.MapActivityActions.DirectionDialogStyle; import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.base.FailSafeFuntions; import net.osmand.plus.base.MapViewTrackingUtilities; @@ -36,7 +38,6 @@ import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; -import android.app.AlertDialog; import android.app.Dialog; import android.app.Notification; import android.app.NotificationManager; @@ -300,7 +301,10 @@ public class MapActivity extends AccessibleActivity { Object toShow = settings.getAndClearObjectToShow(); if(settings.isRouteToPointNavigateAndClear()){ // always enable and follow and let calculate it (GPS is not accessible in garage) - mapActions.getDirections(null, null, false); + Location loc = new Location("map"); + loc.setLatitude(mapView.getLatitude()); + loc.setLongitude(mapView.getLongitude()); + mapActions.getDirections(loc, DirectionDialogStyle.create()); } if(mapLabelToShow != null && latLonToShow != null){ mapLayers.getContextMenuLayer().setSelectedObject(toShow); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index c92ff4441b..f7d1aedb25 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -427,33 +427,40 @@ public class MapActivityActions implements DialogProvider { return ""; } - public String generateRouteDescription(Location fromOrCurrent, LatLon to) { + public String generateViaDescription() { TargetPointsHelper targets = getTargets(); - String tos; - if(to == null) { - tos = getRoutePointDescription(targets.getPointToNavigate(), - targets.getPointNavigateDescription()); - } else { - tos = getRoutePointDescription(to, ""); + String via = ""; + List names = targets.getIntermediatePointNames(); + if (names.size() == 0) { + return via; + } + for (int i = 0; i < names.size(); i++) { + via += "\n - " + getRoutePointDescription(targets.getIntermediatePoints().get(i), names.get(i)); + } + return mapActivity.getString(R.string.route_via) + via; + } + + public static class DirectionDialogStyle { + public boolean gpxRouteEnabled; + public boolean routeToMapPoint; + + public static DirectionDialogStyle create() { + return new DirectionDialogStyle(); + } + public DirectionDialogStyle gpxRouteEnabled() { + gpxRouteEnabled = true; + return this; } - int sz = targets.getIntermediatePoints().size(); - if(sz == 0) { - return mapActivity.getString(R.string.route_descr_to, tos); - } else { - String via = ""; - List names = targets.getIntermediatePointNames(); - for (int i = 0; i < sz ; i++) { - via += "\n - " + getRoutePointDescription(targets.getIntermediatePoints().get(i), - names.get(i)); - } - return mapActivity.getString(R.string.route_descr_to_via, via, tos); + public DirectionDialogStyle routeToMapPoint() { + routeToMapPoint = true; + return this; } } - public void getDirections(final Location fromOrCurrent, final LatLon to, boolean gpxRouteEnabled) { - + public void getDirections(final Location mapView, DirectionDialogStyle style) { + final Location current = getLastKnownLocation(); Builder builder = new AlertDialog.Builder(mapActivity); final TargetPointsHelper targets = getTargets(); @@ -468,19 +475,19 @@ public class MapActivityActions implements DialogProvider { buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton); buttons[ApplicationMode.PEDESTRIAN.ordinal()].setButtonDrawable(R.drawable.ic_pedestrian); - TextView tv = ((TextView) view.findViewById(R.id.TextView)); - tv.setText(generateRouteDescription(fromOrCurrent, to)); - String from = mapActivity.getString(R.string.route_descr_current_location); - if (fromOrCurrent != null && fromOrCurrent.getProvider().equals("map")) { - from = getRoutePointDescription(fromOrCurrent.getLatitude(), - fromOrCurrent.getLongitude()); + final Spinner fromSpinner = setupFromSpinner(mapView, view); + final List toList = new ArrayList(); + final Spinner toSpinner = setupToSpinner(mapView, view, toList, style); + + + String via = generateViaDescription(); + if(via.length() == 0){ + ((TextView) view.findViewById(R.id.ViaView)).setVisibility(View.GONE); + } else { + ((TextView) view.findViewById(R.id.ViaView)).setVisibility(View.VISIBLE); + ((TextView) view.findViewById(R.id.ViaView)).setText(via); } - Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner)); - ArrayAdapter fromAdapter = new ArrayAdapter(view.getContext(), - android.R.layout.simple_spinner_item, - new ArrayList(Arrays.asList(new String[]{from})) - ); - fromSpinner.setAdapter(fromAdapter); + ApplicationMode appMode = settings.getApplicationMode(); if(appMode == ApplicationMode.DEFAULT) { appMode = ApplicationMode.CAR; @@ -529,13 +536,14 @@ public class MapActivityActions implements DialogProvider { DialogInterface.OnClickListener onlyShowCall = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (to != null) { - targets.navigateToPoint(to, false, -1); + LatLon tos = toList.get(toSpinner.getSelectedItemPosition()); + if ( tos != null && tos != targets.getPointToNavigate()) { + targets.navigateToPoint(tos, false, -1); } if (!targets.checkPointToNavigate(getMyApplication())) { return; } - Location from = fromOrCurrent; + Location from = fromSpinner.getSelectedItemPosition() == 0 ? current : mapView; if (from == null) { from = getLastKnownLocation(); } @@ -557,24 +565,21 @@ public class MapActivityActions implements DialogProvider { DialogInterface.OnClickListener followCall = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if(to != null) { - targets.navigateToPoint(to, false, -1); + LatLon tos = toList.get(toSpinner.getSelectedItemPosition()); + if ( tos != null && tos != targets.getPointToNavigate()) { + targets.navigateToPoint(tos, false, -1); } if (!targets.checkPointToNavigate(getMyApplication())) { return; } boolean msg = true; - Location current = fromOrCurrent; - if(current == null) { - current = getLastKnownLocation(); - } - - if (!OsmAndLocationProvider.isPointAccurateForRouting(current)) { - current = null; - } Location lastKnownLocation = getLastKnownLocation(); + Location from = fromSpinner.getSelectedItemPosition() == 0 ? current : mapView; + if(from == null) { + from = lastKnownLocation; + } if (OsmAndLocationProvider.isPointAccurateForRouting(lastKnownLocation)) { - current = lastKnownLocation; + from = lastKnownLocation; msg = false; } if (msg) { @@ -584,15 +589,16 @@ public class MapActivityActions implements DialogProvider { settings.OPTIMAL_ROUTE_MODE.setModeValue(mode, !nonoptimal.isChecked()); dialog.dismiss(); mapActivity.followRoute(mode, targets.getPointToNavigate(), targets.getIntermediatePoints(), - current, null); + from, null); } }; DialogInterface.OnClickListener useGpxNavigation = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if(to != null) { - targets.navigateToPoint(to, false, -1); + LatLon tos = toList.get(toSpinner.getSelectedItemPosition()); + if ( tos != null && tos != targets.getPointToNavigate()) { + targets.navigateToPoint(tos, false, -1); } ApplicationMode mode = getAppMode(buttons, settings); navigateUsingGPX(mode); @@ -603,13 +609,58 @@ public class MapActivityActions implements DialogProvider { builder.setTitle(R.string.get_directions); builder.setPositiveButton(R.string.follow, followCall); builder.setNeutralButton(R.string.only_show, onlyShowCall); - if (gpxRouteEnabled) { + if (style.gpxRouteEnabled) { builder.setNegativeButton(R.string.gpx_navigation, useGpxNavigation); } else { builder.setNegativeButton(R.string.no_route, null); } builder.show(); } + + private Spinner setupFromSpinner(final Location mapView, View view) { + String currentLocation = mapActivity.getString(R.string.route_descr_current_location); + ArrayList fromActions = new ArrayList(); + fromActions.add(currentLocation); + if(mapView != null) { + String mapLocation = mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(mapView.getLatitude(), + mapView.getLongitude()); + fromActions.add(mapLocation); + } + final Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner)); + ArrayAdapter fromAdapter = new ArrayAdapter(view.getContext(), + android.R.layout.simple_spinner_item, + fromActions + ); + fromSpinner.setAdapter(fromAdapter); + return fromSpinner; + } + + private Spinner setupToSpinner(final Location mapView, View view, List locs, DirectionDialogStyle style) { + final TargetPointsHelper targets = getTargets(); + ArrayList toActions = new ArrayList(); + if (targets.getPointToNavigate() != null) { + toActions.add(mapActivity.getString(R.string.route_descr_destination) + " " + + getRoutePointDescription(targets.getPointToNavigate(), targets.getPointNavigateDescription())); + locs.add(targets.getPointToNavigate()); + } + if(mapView != null) { + String mapLocation = mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(mapView.getLatitude(), + mapView.getLongitude()); + toActions.add(mapLocation); + locs.add(new LatLon(mapView.getLatitude(), mapView.getLongitude())); + } + if(style.routeToMapPoint) { + Collections.reverse(locs); + Collections.reverse(toActions); + } + final Spinner toSpinner = ((Spinner) view.findViewById(R.id.ToSpinner)); + ArrayAdapter toAdapter = new ArrayAdapter(view.getContext(), + android.R.layout.simple_spinner_item, + toActions + ); + toSpinner.setAdapter(toAdapter); + return toSpinner; + } protected Location getLastKnownLocation() { return getMyApplication().getLocationProvider().getLastKnownLocation(); @@ -764,7 +815,7 @@ public class MapActivityActions implements DialogProvider { public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) { final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter; - adapter.item(R.string.get_directions).icons( + adapter.item(R.string.context_menu_item_directions_to).icons( R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light).reg(); final TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); final OsmandSettings settings = getMyApplication().getSettings(); @@ -776,7 +827,7 @@ public class MapActivityActions implements DialogProvider { adapter.item(R.string.context_menu_item_destination_point).icons(R.drawable.ic_action_flag_dark, R.drawable.ic_action_flag_light).reg(); } - adapter.item(R.string.context_menu_item_show_route).icons(R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light).reg(); + adapter.item(R.string.context_menu_item_directions_from).icons(R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light).reg(); adapter.item(R.string.context_menu_item_search).icons(R.drawable.ic_action_search_dark, R.drawable.ic_action_search_light).reg(); adapter.item(R.string.context_menu_item_share_location).icons( @@ -810,20 +861,21 @@ public class MapActivityActions implements DialogProvider { intent.putExtra(SearchActivity.SEARCH_LON, longitude); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); mapActivity.startActivity(intent); - } else if (standardId == R.string.get_directions) { - //getMyApplication().getTargetPointsHelper().navigateToPoint(new LatLon(latitude, longitude), true, -1); - settings.setPointToNavigate(latitude, longitude, false, mapActivity.getResources().getString(R.string.point_on_map, latitude, longitude)); - targets.updatePointsFromSettings(); - // always enable and follow and let calculate it (GPS is not accessible in garage) + } else if (standardId == R.string.context_menu_item_directions_to) { if(!routingHelper.isRouteBeingCalculated() && !routingHelper.isRouteCalculated() ) { - getDirections(null, new LatLon(latitude, longitude), true); + Location loc = new Location("map"); + loc.setLatitude(latitude); + loc.setLongitude(longitude); + getDirections(loc, DirectionDialogStyle.create().gpxRouteEnabled().routeToMapPoint()); + } else { + targets.navigateToPoint(new LatLon(latitude, longitude), true, -1); } - } else if (standardId == R.string.context_menu_item_show_route) { + } else if (standardId == R.string.context_menu_item_directions_from) { if (targets.checkPointToNavigate(getMyApplication())) { Location loc = new Location("map"); loc.setLatitude(latitude); loc.setLongitude(longitude); - getDirections(loc, null, true); + getDirections(loc, DirectionDialogStyle.create().gpxRouteEnabled()); } } else if (standardId == R.string.context_menu_item_intermediate_point) { // Issue 1929: Consistently show IntermediatePointDialog, without subsequent Directions screen @@ -1012,7 +1064,10 @@ public class MapActivityActions implements DialogProvider { if (routingHelper.isRouteCalculated()) { aboutRoute(); } else { - getDirections(null, null, true); + Location loc = new Location("map"); + loc.setLatitude(mapView.getLatitude()); + loc.setLongitude(mapView.getLongitude()); + getDirections(loc, DirectionDialogStyle.create().gpxRouteEnabled()); } } }).reg();