Add point to destination

This commit is contained in:
Victor Shcherb 2013-07-14 17:30:04 +02:00
parent 4e7c5cd427
commit 2bc189d1e3
35 changed files with 186 additions and 101 deletions

View file

@ -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" >
</Spinner>
</LinearLayout>
<TextView
android:id="@+id/TextView"
android:id="@+id/ViaView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:gravity="left"
android:textSize="18sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="@string/route_to"
android:textSize="18sp" >
</TextView>
<Spinner
android:id="@+id/ToSpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textSize="18sp" >
</Spinner>
</LinearLayout>
<CheckBox
android:id="@+id/OptimalCheckox"

View file

@ -584,7 +584,7 @@
<string name="layer_map">Kaartbron…</string>
<string name="menu_layers">Definieer uitsig</string>
<string name="context_menu_item_search_poi">Soek interessante plek</string>
<string name="context_menu_item_show_route">Wys roete van hier af</string>
<string name="use_trackball_descr">Gebruik die trekbal om die kaart te skuif</string>
<string name="use_trackball">Gebruik die trekbal</string>
<string name="background_service_wait_int_descr">Stel maksimum wagtyd vir agtergrond ligging-vasstelling</string>

View file

@ -1209,7 +1209,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="layer_map">Крыніца мапы…</string>
<string name="menu_layers">Вызначыць выгляд</string>
<string name="context_menu_item_search_poi">Search POI</string>
<string name="context_menu_item_show_route">Паказаць шлях адсюль</string>
<string name="use_trackball_descr">Use trackball to move map</string>
<string name="use_trackball">Use trackball</string>
<string name="background_service_wait_int_descr">Set maximum waiting time for each background position fix</string>

View file

@ -605,7 +605,7 @@
<string name="layer_route">Ruta</string>
<string name="layer_favorites">Preferits</string>
<string name="menu_layers">Defineix la visualització</string>
<string name="context_menu_item_show_route">Mostra la ruta des d\'aquí</string>
<string name="use_trackball_descr">Utilitzeu el ratolí de bola per moure el mapa</string>
<string name="use_trackball">Utilitza el ratolí de bola</string>
<string name="process_navigation_service">Servei de navegació de l\'OsmAnd</string>

View file

@ -534,7 +534,7 @@
<string name="layer_map">Zdroj map…</string>
<string name="menu_layers">Mapová data</string>
<string name="context_menu_item_search_poi">Hledat POI</string>
<string name="context_menu_item_show_route">Cestovat odsud</string>
<string name="use_trackball_descr">Použít trackball k posouvání mapy</string>
<string name="use_trackball">Použít trackball</string>
<string name="background_service_wait_int_descr">Vyberte čekací dobu pro určení polohy</string>

View file

@ -1133,7 +1133,7 @@ Afghanistan, Albanien, Algeriet, Andorra, Angola, Anguilla, Antigua og Barbuda,
<string name="layer_map">Vælg kortkilde…</string>
<string name="menu_layers">Definer visning</string>
<string name="context_menu_item_search_poi">Søg interessepunkt</string>
<string name="context_menu_item_show_route">Vis rute herfra</string>
<string name="use_trackball_descr">Brug trackball for at flytte kortet</string>
<string name="use_trackball">Brug trackball</string>
<string name="background_service_wait_int_descr">Indstil maksimal ventetid mellem hver positionssøgning i baggrunden</string>

View file

@ -721,7 +721,7 @@
<string name="layer_map">Kartenquelle…</string>
<string name="menu_layers">Darstellung</string>
<string name="context_menu_item_search_poi">Suche POI</string>
<string name="context_menu_item_show_route">Zeige Route von hier</string>
<string name="use_trackball_descr">Trackball für Kartenbewegung benutzen</string>
<string name="use_trackball">Trackball verwenden</string>
<string name="background_service_wait_int_descr">Maximale Suchzeit für jede Hintergrund-Standortbestimmung</string>

View file

@ -769,7 +769,7 @@
<string name="layer_map">Πηγή χάρτη …</string>
<string name="menu_layers">Ορισμός εμφάνισης</string>
<string name="context_menu_item_search_poi">Αναζήτηση ΣΕ</string>
<string name="context_menu_item_show_route">Εμφάνιση διαδρομής από εδώ</string>
<string name="use_trackball_descr">Χρήση του trackball για μετακίνηση του χάρτη</string>
<string name="use_trackball">Χρήση του trackball</string>
<string name="background_service_wait_int_descr">Ορίστε το μέγιστο χρόνο αναμονής για κάθε εύρεση θέσης στο παρασκήνιο</string>

View file

@ -440,7 +440,7 @@
<string name="layer_map">Fuente de mapas…</string>
<string name="menu_layers">Definir vista</string>
<string name="context_menu_item_search_poi">Buscar PDI</string>
<string name="context_menu_item_show_route">Mostrar ruta desde aquí</string>
<string name="use_trackball_descr">Usa trackball para mover el mapa</string>
<string name="use_trackball">Usar trackball</string>
<string name="background_service_wait_int_descr">Fijar el tiempo de espera máximo para determinar la posición en cada lectura del servicio de fondo</string>

View file

@ -527,7 +527,7 @@
<string name="int_seconds">sekuntia</string>
<string name="int_min">min.</string>
<string name="where_am_i">Missä olen?</string>
<string name="context_menu_item_show_route">Näytä reitti täältä</string>
<string name="poi_context_menu_delete">Poista KP</string>
<string name="rotate_map_compass_opt">Kompassi</string>
<string name="rotate_map_bearing_opt">Liikkumissuuntaan</string>

View file

@ -466,7 +466,7 @@
<string name="layer_map">Source de la carte…</string>
<string name="menu_layers">Couches</string>
<string name="context_menu_item_search_poi">Chercher un Point d\'Intérêt</string>
<string name="context_menu_item_show_route">Partir depuis ce point</string>
<string name="use_trackball_descr">Utiliser le pointeur pour se déplacer sur la carte</string>
<string name="use_trackball">Utiliser le pointeur</string>
<string name="background_service_wait_int_descr">Configurer le délai d\'attente pour déterminer l\'emplacement</string>

View file

@ -800,7 +800,7 @@
<string name="layer_map">מקור המפה…</string>
<string name="menu_layers">הגדרת תצוגה</string>
<string name="context_menu_item_search_poi">חיפוש נ״ע</string>
<string name="context_menu_item_show_route">הצגת מסלול מכאן</string>
<string name="use_trackball_descr">יש להשתמש בכדור מעקב כדי להזיז את המפה</string>
<string name="where_am_i">איפה אני?</string>
<string name="update_poi_success">נתוני הנ״ע עודכנו בהצלחה ({0} נטענו)</string>

View file

@ -459,7 +459,7 @@
<string name="context_menu_item_search_poi">Traži POI</string>
<string name="layer_transport">Postaje javnog prijevoza</string>
<string name="layer_poi">POI...</string>
<string name="context_menu_item_show_route">Prikaži rutu odavde</string>
<string name="layer_transport_route">Putovi javnoga prijevoza</string>
<string name="layer_route">Ruta</string>
<string name="layer_favorites">Favoriti</string>

View file

@ -484,7 +484,7 @@
<string name="layer_map">Térképforrás…</string>
<string name="menu_layers">Rétegek</string>
<string name="context_menu_item_search_poi">POI keresése</string>
<string name="context_menu_item_show_route">Mutasd az utat innen</string>
<string name="use_trackball_descr">Trackball használata a térkép mozgatásához</string>
<string name="use_trackball">Trackball használata</string>
<string name="background_service_wait_int_descr">Maximális várakozási idő minden sikeres helymeghatározásra</string>

View file

@ -446,7 +446,7 @@
<string name="layer_map">Sorgente mappa…</string>
<string name="menu_layers">Definisci la vista</string>
<string name="context_menu_item_search_poi">Cerca PDI</string>
<string name="context_menu_item_show_route">Visualizza il percorso da qui</string>
<string name="use_trackball_descr">Utilizza la trackball per muovere la mappa</string>
<string name="use_trackball">Usa la trackball</string>
<string name="background_service_wait_int_descr">Scegli l\'intervallo di tempo per determinare la posizione</string>

View file

@ -365,7 +365,7 @@ MB)をダウンロードしますか?</string>
<string name="menu_layers">ビュー定義</string>
<string name="context_menu_item_search_poi">POIを検索</string>
<string name="context_menu_item_show_route">ルート開始位置</string>
<string name="use_trackball_descr">トラックボールを使用してマップを動かす</string>
<string name="use_trackball">トラックボールを使用</string>
<string name="background_service_wait_int_descr">位置修正用の待ち時間をセット</string>

View file

@ -529,7 +529,7 @@
<string name="layer_map">რუკის წყარო…</string>
<string name="menu_layers">ხედის აღწერა</string>
<string name="context_menu_item_search_poi">POI-ის ძებნა</string>
<string name="context_menu_item_show_route">გზების ჩვენება მოცემული წერტილიდან</string>
<string name="use_trackball_descr">რუკის სამოძრაოდ გამოიყენეთ ტრეკბოლი</string>
<string name="use_trackball">გამოიყენეთ ტრეკბოლი</string>
<string name="background_service_wait_int_descr">გთხოვთ დააყენოთ ფონური პოზიცირების ჩასასწორებელი მაქსიმალური დრო</string>

View file

@ -579,7 +579,7 @@
<string name="menu_layers">뷰 정의</string>
<string name="context_menu_item_search_poi">POI 검색</string>
<string name="context_menu_item_show_route">시작지점으로</string>
<string name="use_trackball_descr">맵을 이동하는 데 트랙볼을 사용합니다</string>
<string name="use_trackball">트랙볼 사용</string>
<string name="background_service_wait_int_descr">위치를 찾는 대기 시간을 선택합니다</string>

View file

@ -649,7 +649,7 @@
<string name="layer_map">Žemėlapių šaltiniai…</string>
<string name="menu_layers">Nustatyti vaizdą</string>
<string name="context_menu_item_search_poi">Ieškoti LV</string>
<string name="context_menu_item_show_route">Rodyti maršrutą nuo čia</string>
<string name="use_trackball_descr">Naudoti manipuliatoriaus rutulį žemėlapiui pastumti</string>
<string name="use_trackball">Naudoti manipuliatoriaus rutulį</string>
<string name="background_service_wait_int_descr">Nustatyti didžiausią laukimo laiką kiekvienam foniniam vietos nustatymui</string>

View file

@ -495,7 +495,7 @@
<string name="layer_map">Kartes avots…</string>
<string name="menu_layers">Definēt skatu</string>
<string name="context_menu_item_search_poi">Meklēt POI</string>
<string name="context_menu_item_show_route">Rādīt ceļu no šejienes</string>
<string name="use_trackball_descr">Lietojiet trackball lai pārvietotu karti</string>
<string name="use_trackball">Lietot trackball</string>
<string name="background_service_wait_int_descr">"Uzstādiet maksimālo gaidīšanas laiku katram fona pozīcijas labojumam"</string>

View file

@ -190,7 +190,7 @@
<string name="layer_favorites">आवडती ठिकाणे</string>
<string name="layer_map">नकाशाचा स्त्रोत…</string>
<string name="context_menu_item_search_poi">पिओआय शोधा</string>
<string name="context_menu_item_show_route">इथून रस्ता दाखवा</string>
<string name="where_am_i">मी कुठे आहे?</string>
<string name="network_provider">नेटवर्क</string>
<string name="gps_provider">जीपीइस</string>

View file

@ -453,7 +453,7 @@
<string name="layer_map">Kartkilde…</string>
<string name="menu_layers">Vis</string>
<string name="context_menu_item_search_poi">Søk interessepunkt</string>
<string name="context_menu_item_show_route">Vis rute herfra</string>
<string name="where_am_i">Hvor er jeg?</string>
<string name="process_navigation_service">OsmAnd navigeringstjeneste</string>
<string name="network_provider">Nettverk</string>

View file

@ -551,7 +551,7 @@
<string name="layer_map">Kaartbron…</string>
<string name="menu_layers">Definieer beeld</string>
<string name="context_menu_item_search_poi">Zoek interessepunt</string>
<string name="context_menu_item_show_route">Toon route vanaf hier</string>
<string name="use_trackball_descr">Gebruik trackball om de kaart te verschuiven</string>
<string name="use_trackball">Gebruik trackball</string>
<string name="background_service_wait_int_descr">Maximum wachttijd voor elke achtergrond positiebepaling</string>

View file

@ -350,7 +350,7 @@
<string name="layer_map">Źródło mapy…</string>
<string name="menu_layers">Zdefiniuj widok</string>
<string name="context_menu_item_search_poi">Szukaj POI</string>
<string name="context_menu_item_show_route">Pokaż trasę z tego miejsca</string>
<string name="use_trackball_descr">Użyj trackballa do przesuwania mapy</string>
<string name="use_trackball">Używaj trackballa</string>
<string name="background_service_wait_int_descr">Czas oczekiwania na poprawną pozycję GPS</string>

View file

@ -132,7 +132,7 @@
<string name="layer_map">Fonte dos mapas…</string>
<string name="menu_layers">Definir exibição</string>
<string name="context_menu_item_search_poi">Encontre um Ponto de Interesse</string>
<string name="context_menu_item_show_route">Exibir rota a partir daqui</string>
<string name="use_trackball_descr">Utilize o cursor para mover o mapa</string>
<string name="use_trackball">Use o cursor</string>
<string name="background_service_wait_int_descr">Definir o tempo limite para determinar a localização</string>

View file

@ -806,7 +806,7 @@
<string name="layer_map">Sursă hartă…</string>
<string name="menu_layers">Straturi</string>
<string name="context_menu_item_search_poi">Caută POI</string>
<string name="context_menu_item_show_route">Calculează ruta începând de aici</string>
<string name="use_trackball_descr">Folosește trackball pentru mișcare hartă</string>
<string name="use_trackball">Folosește trackball</string>
<string name="background_service_wait_int_descr">Alege timpul maxim de așteptare pentru fiecare localizare exactă a poziției în fundal</string>

View file

@ -504,7 +504,7 @@
<string name="layer_map">Источник карты…</string>
<string name="menu_layers">Слои</string>
<string name="context_menu_item_search_poi">Искать POI</string>
<string name="context_menu_item_show_route">Маршрут отсюда</string>
<string name="use_trackball_descr">Использовать трекбол, чтобы перемещать карту</string>
<string name="use_trackball">Использовать трекбол</string>
<string name="background_service_wait_int_descr">Выберите максимальное время поиска позиции сервиса</string>

View file

@ -640,7 +640,7 @@
<string name="layer_map">Zdroj mapy…</string>
<string name="menu_layers">Zobrazenie</string>
<string name="context_menu_item_search_poi">Hľadať bod záujmu (POI)</string>
<string name="context_menu_item_show_route">Zobraziť trasu odtiaľto</string>
<string name="use_trackball_descr">Použitie trackballu na pohyb po mape</string>
<string name="use_trackball">Použiť trackball</string>
<string name="background_service_wait_int_descr">Nastaví max. čakaciu dobu pre každú ustálenú pozíciu na pozadí</string>

View file

@ -530,7 +530,7 @@
<string name="download_roads_only_item">Le ceste</string>
<string name="download_regular_maps">Običajni zemljevidi</string>
<string name="download_link_and_local_description">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):</string>
<string name="context_menu_item_show_route">Prikaži pot od tu</string>
<string name="local_index_mi_restore">Vklopi</string>
<string name="local_index_mi_backup">Izklopi</string>
<string name="local_index_mi_delete">Briši</string>

View file

@ -706,7 +706,7 @@
<string name="layer_map">Kartkälla…</string>
<string name="menu_layers">Definiera vy</string>
<string name="context_menu_item_search_poi">Sök POI</string>
<string name="context_menu_item_show_route">Visa rutt härifrån</string>
<string name="use_trackball_descr">Använd styrkulan för att flytta kartan</string>
<string name="use_trackball">Använd styrkula</string>
<string name="background_service_wait_int_descr">Ange maximal väntetid för varje positionsbestämning i bakgrunden</string>

View file

@ -569,7 +569,7 @@
<string name="layer_map">Джерело мапи…</string>
<string name="menu_layers">Мапа</string>
<string name="context_menu_item_search_poi">Шукати POI</string>
<string name="context_menu_item_show_route">Маршрут звідси</string>
<string name="use_trackball_descr">Використовувати трекбол для руху мапи</string>
<string name="use_trackball">Використовувати трекбол</string>
<string name="background_service_wait_int_descr">Виберіть максимальний час для пошуку позиції</string>

View file

@ -740,7 +740,7 @@
<string name="layer_map">地圖來源…</string>
<string name="menu_layers">定義檢視</string>
<string name="context_menu_item_search_poi">查尋興趣點</string>
<string name="context_menu_item_show_route">由此顯示導航路徑</string>
<string name="use_trackball_descr">使用軌跡球移動地圖</string>
<string name="use_trackball">使用軌跡球</string>
<string name="background_service_wait_int_descr">設定背景定位等待時間</string>

View file

@ -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
-->
<string name="route_descr_to">To: %1$s</string>
<string name="route_descr_to_via">Via: %1$s\nTo: %2$s</string>
<string name="context_menu_item_directions_to">Directions To</string>
<string name="context_menu_item_directions_from">Directions From</string>
<string name="route_descr_map_location">Map: </string>
<string name="route_descr_lat_lon">Lat %1$.3f, lon %2$.3f</string>
<string name="route_descr_current_location">Current position</string>
<string name="route_descr_destination"></string>
<string name="route_to">To:</string>
<string name="route_via">Via:</string>
<string name="route_from">From:</string>
<string name="speak_warnings_title">Announce alarms&#8230;</string>
<string name="speak_warnings_descr">Configure traffic warnings (forced stops, speed bumps), speed camera warnings, speed limits</string>
@ -224,8 +230,6 @@
</string>
<string name="map_widget_max_speed">Speed limit</string>
<string name="monitoring_control_start">GPX</string>
<string name="route_descr_lat_lon">Lat %1$.3f, lon %2$.3f</string>
<string name="route_descr_current_location">Current position</string>
<string name="no_buildings_found">No buildings found.</string>
<string name="incremental_search_city">Search city incrementally</string>
<string name="search_villages_and_postcodes">Search villages/postcode</string>
@ -1227,7 +1231,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="layer_map">Map source&#8230;</string>
<string name="menu_layers">Define view</string>
<string name="context_menu_item_search_poi">Search POI</string>
<string name="context_menu_item_show_route">Show route from here</string>
<string name="use_trackball_descr">Use trackball to move map</string>
<string name="use_trackball">Use trackball</string>
<string name="background_service_wait_int_descr">Set maximum waiting time for each background position fix</string>

View file

@ -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);

View file

@ -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<String> 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<String> 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<LatLon> toList = new ArrayList<LatLon>();
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<String> fromAdapter = new ArrayAdapter<String>(view.getContext(),
android.R.layout.simple_spinner_item,
new ArrayList<String>(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<String> fromActions = new ArrayList<String>();
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<String> fromAdapter = new ArrayAdapter<String>(view.getContext(),
android.R.layout.simple_spinner_item,
fromActions
);
fromSpinner.setAdapter(fromAdapter);
return fromSpinner;
}
private Spinner setupToSpinner(final Location mapView, View view, List<LatLon> locs, DirectionDialogStyle style) {
final TargetPointsHelper targets = getTargets();
ArrayList<String> toActions = new ArrayList<String>();
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<String> toAdapter = new ArrayAdapter<String>(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();