Compare commits

...

26 commits
master ... r2.1

Author SHA1 Message Date
Victor Shcherb
6d9567fd98 Fix UI memory leak on rotate / Merge with master special tests will be needed of this branch
Conflicts:
	OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
	OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java
	OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java
2015-07-07 15:04:37 +03:00
Victor Shcherb
5e2b0b013d Fix crash & change app theme
Conflicts:
	OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java
	OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java
2015-07-07 15:02:53 +03:00
Victor Shcherb
5b1aff575d Fix bug with reset 2015-07-03 12:30:54 +03:00
Victor Shcherb
004a44b073 Fix issue with select all 2015-07-02 20:16:30 +02:00
Victor Shcherb
3aa35b1381 Fix crash with space 2015-07-02 17:41:22 +02:00
vshcherb
5c7e67fd01 Merge pull request #1406 from mariyan-borisov/r2.1
Fixed format strings in r2.1 branch
2015-06-28 23:48:55 +02:00
Mariyan Borisov
1b8c4fd64e Fixed format strings 2015-06-26 14:29:52 +03:00
Victor Shcherb
c45b9e6615 Fix issue with roundabouts 2015-06-20 22:09:55 +02:00
Victor Shcherb
0d4e7982ab Merge branch 'r2.1' of github.com:osmandapp/Osmand into r2.1 2015-06-19 10:13:56 +02:00
Victor Shcherb
a022c67dc8 Improve lang code 2015-06-19 10:13:45 +02:00
xmd5a2
55fdd3b003 Update strings 2015-06-19 11:00:04 +03:00
Victor Shcherb
9d4923cc2e Update action arrows 2015-06-19 09:22:15 +02:00
Victor Shcherb
4335926c8b Fix wiki issues 2015-06-19 01:09:19 +02:00
Victor Shcherb
caa20dcb3b Proper update time 2015-06-19 00:47:23 +02:00
Victor Shcherb
9794de3c58 Merge branch 'r2.1' of github.com:osmandapp/Osmand into r2.1 2015-06-18 23:56:21 +02:00
Victor Shcherb
e90c2ea5f7 Fix gpx layer
Conflicts:
	OsmAnd/res/values/strings.xml
2015-06-18 23:56:08 +02:00
xmd5a2
427561e1c9 Remove nonworking UI languages (zh_) 2015-06-18 10:51:57 +03:00
Victor Shcherb
2bb7f051a2 Fix gpx layer 2015-06-18 00:44:52 +02:00
xmd5a2
ea3845fe70 Update phrases 2015-06-17 11:12:57 +03:00
xmd5a
89a6360bc0 Add languages 2015-06-16 21:28:43 +03:00
Victor Shcherb
3e0f95b2d8 Add localization to road section, navigation, TTS, etc (using configure map setting -> locale) 2015-06-16 01:04:05 +02:00
Victor Shcherb
635170def2 Fix wiki poi selector 2015-06-16 00:03:27 +02:00
Victor Shcherb
7f9c8395a6 Fix wiki names 2015-06-15 21:32:54 +02:00
Victor Shcherb
429581facf Update poi wiki 2015-06-15 10:42:17 +02:00
Victor Shcherb
ad7c8b35b5 Fix archive wiki 2015-06-14 20:57:04 +02:00
Victor Shcherb
2957968fcc Fix downnload activity archive 2015-06-14 20:51:55 +02:00
49 changed files with 461 additions and 300 deletions

View file

@ -1,5 +1,7 @@
package net.osmand;
import java.util.Locale;
/**
@ -23,7 +25,7 @@ public class CollatorStringMatcher implements StringMatcher {
public CollatorStringMatcher(String part, StringMatcherMode mode) {
this.collator = OsmAndCollator.primaryCollator();
this.part = part;
this.part = part.toLowerCase(Locale.getDefault());
this.mode = mode;
}
@ -94,8 +96,9 @@ public class CollatorStringMatcher implements StringMatcher {
* @param theStart
* @return true if searchIn starts with token
*/
public static boolean cstartsWith(Collator collator, String searchIn, String theStart,
public static boolean cstartsWith(Collator collator, String searchInParam, String theStart,
boolean checkBeginning, boolean checkSpaces) {
String searchIn = searchInParam.toLowerCase(Locale.getDefault());
int startLength = theStart.length();
int searchInLength = searchIn.length();
if (startLength == 0) {

View file

@ -74,7 +74,7 @@ public class BinaryInspector {
"-zoom=16",
// "-bbox=1.74,51.17,1.75,51.16",
// "-vstats",
// "/Users/victorshcherb/osmand/maps/Netherlands_europe_2.obf"
// "/Users/victorshcherb/osmand/maps/srtm/Netherlands_europe_2.srtm.obf"
// "/Users/victorshcherb/osmand/maps/World_basemap_2.obf"
});

View file

@ -61,6 +61,27 @@ public class RouteDataObject {
return null;
}
public String getName(String lang){
if(names != null ) {
if(Algorithms.isEmpty(lang)) {
return names.get(region.nameTypeRule);
}
int[] kt = names.keys();
for(int i = 0 ; i < kt.length; i++) {
int k = kt[i];
if(region.routeEncodingRules.size() > k) {
if(("name:"+lang).equals(region.routeEncodingRules.get(k).getTag())) {
return names.get(k);
}
}
}
return names.get(region.nameTypeRule);
}
return null;
}
public TIntObjectHashMap<String> getNames() {
return names;
}
@ -76,8 +97,21 @@ public class RouteDataObject {
return null;
}
public String getDestinationName(){
public String getDestinationName(String lang){
if(names != null) {
if(Algorithms.isEmpty(lang)) {
return names.get(region.destinationTypeRule);
}
int[] kt = names.keys();
for(int i = 0 ; i < kt.length; i++) {
int k = kt[i];
if(region.routeEncodingRules.size() > k) {
if(("destination:"+lang).equals(region.routeEncodingRules.get(k).getTag())) {
return names.get(k);
}
}
}
return names.get(region.destinationTypeRule);
}
return null;

View file

@ -157,24 +157,27 @@ public class Amenity extends MapObject {
setAdditionalInfo(PHONE, phone);
}
public String getNameSelected(String lang) {
public String getContentSelected(String tag, String lang, String defLang) {
if (lang != null) {
String translateName;
if (lang.equals("en")) {
translateName = getEnName();
} else {
translateName = getAdditionalInfo("name:" + lang);
}
String translateName = getAdditionalInfo(tag + ":" + lang);
if (!Algorithms.isEmpty(translateName)) {
return lang;
}
}
String plainName = getAdditionalInfo(tag);
if (!Algorithms.isEmpty(plainName)) {
return defLang;
}
String enName = getAdditionalInfo(tag + ":en");
if (!Algorithms.isEmpty(enName)) {
return enName;
}
for (String nm : getAdditionalInfo().keySet()) {
if (nm.startsWith("name:")) {
return nm.substring("name:".length());
}
}
return "";
return defLang;
}
public String getName(String lang) {

View file

@ -1173,7 +1173,6 @@ OsmAnd هو المصدر المفتوح و التي يجري تطويرها بن
<string name="local_index_items_deleted">حُذف %1$d عنصرًا من %2$d بنجاح.</string>
<string name="local_index_items_restored">نُشّط %1$d عنصرًا من %2$d بنجاح.</string>
<string name="local_index_no_items_to_do">لا عناصر لـ %1$s</string>
<string name="local_index_action_do">كنت على وشك أن٪ 1 $ و٪ 2 $ بنود ق). المتابعة؟</string>
<string name="local_index_descr_title">إدارة ملفات الخرائط</string>
<string name="local_index_mi_restore">فعّل</string>
<string name="local_index_mi_backup">عطّل</string>

View file

@ -1845,7 +1845,7 @@ OsmAnd е с отворен код и активно да се развива.
<string name="current_route">Текущ маршрут</string>
<string name="mark_to_delete">Изберете за изтриване</string>
<string name="osmo_grop_name_length_alert">Името на групата трябва да бъде най-малко от 3 символа!</string>
<string name="local_osm_changes_upload_all_confirm">Ще да качите %1$ d промени към OSM. Сигурни ли сте?</string>
<string name="local_osm_changes_upload_all_confirm">Ще да качите %1$d промени към OSM. Сигурни ли сте?</string>
<string name="confirmation_to_clear_history">Искате ли да изчистите хронологията?</string>
<string name="delay_to_start_navigation">Стартиране на навигацията след…</string>
<string name="shared_string_go">Старт</string>
@ -1909,7 +1909,7 @@ OsmAnd е с отворен код и активно да се развива.
<string name="online_map">Онлайн карта</string>
<string name="roads_only">Само пътища</string>
<string name="rendering_attr_pisteRoutes_name">Ски писти</string>
<string name="free">"Свободни %1$ s "</string>
<string name="free">"Свободни %1$s "</string>
<string name="device_memory">Памет на устройството</string>
<string name="parking_place">Паркинг място</string>
<string name="remove_the_tag">ПРЕМАХНИ ЕТИКЕТА</string>
@ -1964,7 +1964,7 @@ OsmAnd е с отворен код и активно да се развива.
<string name="coordinates">Координати</string>
<string name="anonymous_user_hint">"Анонимен потребител не може да:\n-създава групи;\n-синхронизира групи и устройства със сървъра;\n-управлява групи и устройства в частен режим."</string>
<string name="anonymous_user">Анонимен потребител</string>
<string name="logged_as">Влезли сте като %1$ s</string>
<string name="logged_as">Влезли сте като %1$s</string>
<string name="print_route">Печат на маршрут</string>
<string name="enable_proxy_title">Разреши HTTP прокси</string>
<string name="enable_proxy_descr">Конфигуриране на HTTP прокси за всички мрежови заявки</string>
@ -1996,7 +1996,7 @@ OsmAnd е с отворен код и активно да се развива.
<string name="gpx_selection_route_points">%1$s
\nТочки %2$s</string>
<string name="speed_limit_exceed_message">Изберете толеранса на ограничението на скоростта, над което ще получите гласово предупреждение.</string>
<string name="fav_point_emoticons_message">Името на точката е променено на %1$ s с цел правилното записване на низ с емотикони във файл.</string>
<string name="fav_point_emoticons_message">Името на точката е променено на %1$s с цел правилното записване на низ с емотикони във файл.</string>
<string name="osmo_gpx_track_downloaded">OsMo следата %1$s е изтеглена.</string>
<string name="no_index_file_to_download">Списъкът за сваляне не е намерен, моля проверете Вашата интернет връзка.</string>
<string name="gpx_selection_points">%1$s

View file

@ -2265,5 +2265,5 @@
<string name="local_indexes_cat_wiki">위키백과</string>
<string name="shared_string_show_details">세부 정보 보기</string>
<string name="osm_edit_context_menu_delete">OSM 편집을 삭제</string>
<string name="local_recordings_delete_all_confirm">%1$ 노트를 삭제 하려고 합니다. 확실한가요?</string>
<string name="local_recordings_delete_all_confirm">%1$d 노트를 삭제 하려고 합니다. 확실한가요?</string>
</resources>

View file

@ -2037,7 +2037,7 @@
<string name="local_indexes_cat_wiki">Vikipedija</string>
<string name="shared_string_show_details">Rodyti detales</string>
<string name="osm_edit_context_menu_delete">Ištrinti OSM taisymus</string>
<string name="local_recordings_delete_all_confirm">Ketinate ištrinti %1$ d pastabas. Ar tikrai to norite?</string>
<string name="local_recordings_delete_all_confirm">Ketinate ištrinti %1$d pastabas. Ar tikrai to norite?</string>
<string name="download_wikipedia_maps">Vikipedija</string>
<string name="disable_recording_once_app_killed_descrp">Bus pristabdytas GPX įrašymas, jei programa bus išjungta (per Pastarosios programos). (OsmAnd Miego režimo piktograma dings iš Android pranešimų juostos.)</string>
</resources>

View file

@ -264,7 +264,7 @@
<string name="logged_as">Conectado como %1$s</string>
<string name="speed_limit_exceed">Tolerância do limite de velocidade</string>
<string name="speed_limit_exceed_message">Selecione a margem de tolerância de limite de velocidade, acima do qual você receberá um aviso de voz.</string>
<string name="fav_point_emoticons_message">O nome do favorito foi modificado para %1$ s para facilitar a salvar corretamente a seqüência de caracteres com emoticons para um arquivo.</string>
<string name="fav_point_emoticons_message">O nome do favorito foi modificado para %1$s para facilitar a salvar corretamente a seqüência de caracteres com emoticons para um arquivo.</string>
<string name="speak_title">Anunciar…</string>
<string name="show_pedestrian_warnings">Faixas de pedestre</string>
<string name="routing_attr_no_new_routing_description">Não use as regras de roteamento introduzidas na v1.9</string>

View file

@ -41,7 +41,7 @@
<string name="poi_military">Military</string>
<string name="poi_osmwiki">Wikipedia</string>
<string name="poi_user_defined_other">User defined</string>
<string name="poi_palaeontological_site">Palaeontological site</string>
<string name="poi_bakery">Bakery</string>
@ -480,7 +480,7 @@
<string name="poi_zoo">Zoo</string>
<string name="poi_aquarium">Aquarium</string>
<string name="poi_theme_park">Theme park</string>
<string name="poi_attraction">Tourist attraction</string>
<string name="poi_general_tourist_attraction_yes">General tourist attraction</string>
<string name="poi_attraction_amusement_ride">Amusement ride</string>
@ -523,7 +523,7 @@
<string name="poi_internet_access_wired">Internet access: wired</string>
<string name="poi_internet_access_public">Internet access: public</string>
<string name="poi_internet_access_service">Internet access: service</string>
<string name="poi_monastery">Monastery</string>
<string name="poi_historic_monastery">Historic monastery</string>
<string name="poi_wayside_cross">Wayside cross</string>
@ -781,4 +781,53 @@
<string name="poi_military_range">Military range</string>
<string name="poi_military_naval_base">Military naval base</string>
<string name="poi_military_nuclear_explosion_site">Nuclear explosion site</string>
<string name="poi_wiki_place">Wikipedia</string>
<string name="poi_wiki_lang_en">English wiki</string>
<string name="poi_wiki_lang_ar">Arabic wiki</string>
<string name="poi_wiki_lang_be">Belarusian wiki</string>
<string name="poi_wiki_lang_bg">Bulgarian wiki</string>
<string name="poi_wiki_lang_ca">Catalan wiki</string>
<string name="poi_wiki_lang_ceb">Cebuano wiki</string>
<string name="poi_wiki_lang_cs">Czech wiki</string>
<string name="poi_wiki_lang_da">Danish wiki</string>
<string name="poi_wiki_lang_de">German wiki</string>
<string name="poi_wiki_lang_el">Greek wiki</string>
<string name="poi_wiki_lang_et">Estonian wiki</string>
<string name="poi_wiki_lang_es">Spanish wiki</string>
<string name="poi_wiki_lang_fi">Finnish wiki</string>
<string name="poi_wiki_lang_fr">French wiki</string>
<string name="poi_wiki_lang_gl">Galician wiki</string>
<string name="poi_wiki_lang_he">Hebrew wiki</string>
<string name="poi_wiki_lang_hi">Hindi wiki</string>
<string name="poi_wiki_lang_hr">Croatian wiki</string>
<string name="poi_wiki_lang_ht">Haitian wiki</string>
<string name="poi_wiki_lang_hu">Hungarian wiki</string>
<string name="poi_wiki_lang_id">Indonesian wiki</string>
<string name="poi_wiki_lang_it">Italian wiki</string>
<string name="poi_wiki_lang_ja">Japanese wiki</string>
<string name="poi_wiki_lang_ko">Korean wiki</string>
<string name="poi_wiki_lang_lt">Lithuanian wiki</string>
<string name="poi_wiki_lang_lv">Latvian wiki</string>
<string name="poi_wiki_lang_ms">Malay wiki</string>
<string name="poi_wiki_lang_new">Newar wiki</string>
<string name="poi_wiki_lang_nl">Dutch wiki</string>
<string name="poi_wiki_lang_nn">Norwegian Nynorsk wiki</string>
<string name="poi_wiki_lang_no">Norwegian wiki</string>
<string name="poi_wiki_lang_pl">Polish wiki</string>
<string name="poi_wiki_lang_pt">Portuguese wiki</string>
<string name="poi_wiki_lang_ro">Romanian wiki</string>
<string name="poi_wiki_lang_ru">Russian wiki</string>
<string name="poi_wiki_lang_sk">Slovak wiki</string>
<string name="poi_wiki_lang_sl">Slovene wiki</string>
<string name="poi_wiki_lang_sr">Serbian wiki</string>
<string name="poi_wiki_lang_sv">Swedish wiki</string>
<string name="poi_wiki_lang_sw">Swahili wiki</string>
<string name="poi_wiki_lang_te">Telugu wiki</string>
<string name="poi_wiki_lang_th">Thai wiki</string>
<string name="poi_wiki_lang_tr">Turkish wiki</string>
<string name="poi_wiki_lang_uk">Ukrainian wiki</string>
<string name="poi_wiki_lang_vi">Vietnamese wiki</string>
<string name="poi_wiki_lang_vo">Volapük wiki</string>
<string name="poi_wiki_lang_zh">Chinese wiki</string>
</resources>

View file

@ -9,6 +9,38 @@
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="light_theme">Light</string>
<string name="dark_theme">Dark</string>
<string name="lang_pms">Piedmontese</string>
<string name="lang_bn">Bengali</string>
<string name="lang_tl">Tagalog</string>
<string name="lang_sh">Serbo-Croatian</string>
<string name="lang_az">Azeri</string>
<string name="lang_br">Breton</string>
<string name="lang_sq">Albanian</string>
<string name="lang_is">Icelandic</string>
<string name="lang_bpy">Bishnupriya</string>
<string name="lang_nv">Navajo</string>
<string name="lang_ga">Irish</string>
<string name="lang_la">Latin</string>
<string name="lang_ku">Kurdish</string>
<string name="lang_ta">Tamil</string>
<string name="lang_ml">Malayalam</string>
<string name="lang_lb">Luxembourgish</string>
<string name="lang_os">Ossetian</string>
<string name="lang_eo">Esperanto</string>
<string name="lang_es_ar">Argentinean Spanish</string>
<string name="lang_nb">Norwegian Bokmål</string>
<string name="lang_vo">Volapuk</string>
<string name="lang_th">Thai</string>
<string name="lang_te">Telugu</string>
<string name="lang_nn">Norwegian (Nynorsk)</string>
<string name="lang_new">Newar / Nepal Bhasa</string>
<string name="lang_ms">Malaysian</string>
<string name="lang_ht">Haitian</string>
<string name="lang_gl">Galician</string>
<string name="lang_et">Estonian</string>
<string name="lang_ceb">Cebuano</string>
<string name="archive_wikipedia_data">You have old incompatible wikipedia data downloaded. Do you want to archive it?</string>
<string name="download_wikipedia_files">Do you want to download additional Wikipedia data (%1$s MB) ?</string>
<string name="gps_network_not_enabled">Location service is not enabled. Do you want to turn it on?</string>

View file

@ -14,11 +14,6 @@ public class AccessibilityPlugin extends OsmandPlugin {
this.app = app;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
@Override
public String getId() {
return ID;

View file

@ -267,9 +267,7 @@ public class AppInitializer implements IProgress {
app.favorites = startupInit(new FavouritesDbHelper(app), FavouritesDbHelper.class);
app.waypointHelper = startupInit(new WaypointHelper(app), WaypointHelper.class);
app.regions = startupInit(new OsmandRegions(), OsmandRegions.class);
String lang = osmandSettings.PREFERRED_LOCALE.get();
String clang = "".equals(lang) ? new Locale(lang).getLanguage() : lang;
app.regions.setLocale(clang);
app.regions.setLocale(app.getLanguage());
app.poiFilters = startupInit(new PoiFiltersHelper(app), PoiFiltersHelper.class);
app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class);
app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);

View file

@ -78,7 +78,6 @@ public class OsmandApplication extends Application {
Handler uiHandler;
NavigationService navigationService;
private Locale preferredLocale = null;
// start variables
ResourceManager resourceManager;
@ -101,6 +100,7 @@ public class OsmandApplication extends Application {
RoutingConfiguration.Builder defaultRoutingConfig;
private Locale preferredLocale = null;
private Locale defaultLocale;
private File externalStorageDirectory;
@ -131,11 +131,11 @@ public class OsmandApplication extends Application {
osmandSettings = appCustomization.getOsmandSettings();
externalStorageDirectory = osmandSettings.getExternalStorageDirectory();
checkPreferredLocale();
appInitializer.onCreateApplication();
// if(!osmandSettings.FOLLOW_THE_ROUTE.get()) {
// targetPointsHelper.clearPointToNavigate(false);
// }
checkPreferredLocale();
startApplication();
System.out.println("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
timeToStart = System.currentTimeMillis();
@ -623,6 +623,19 @@ public class OsmandApplication extends Application {
}
}
public String getLanguage() {
String lang = "";
if (preferredLocale != null) {
lang = preferredLocale.getLanguage();
} else {
lang = Locale.getDefault().getLanguage();
}
if (lang != null && lang.length() > 2) {
lang = lang.substring(0, 2).toLowerCase();
}
return lang;
}
public RoutingConfiguration.Builder getDefaultRoutingConfig() {
if(defaultRoutingConfig == null) {
defaultRoutingConfig = appInitializer.getLazyDefaultRoutingConfig();

View file

@ -64,9 +64,10 @@ public abstract class OsmandPlugin {
/**
* Initialize plugin runs just after creation
* @param activity TODO
*/
public abstract boolean init(OsmandApplication app, Activity activity);
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
public void setActive(boolean active) {
this.active = active;

View file

@ -3,6 +3,7 @@ package net.osmand.plus;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@ -67,22 +68,28 @@ public class OsmandSettings {
}
private abstract class PreferenceWithListener<T> implements OsmandPreference<T> {
private List<StateChangedListener<T>> l = null;
private List<WeakReference<StateChangedListener<T>>> l = null;
@Override
public void addListener(StateChangedListener<T> listener) {
if(l == null) {
l = new LinkedList<StateChangedListener<T>>();
l = new LinkedList<WeakReference<StateChangedListener<T>>>();
}
if(!l.contains(listener)) {
l.add(listener);
if(!l.contains(new WeakReference<StateChangedListener<T>>(listener))) {
l.add(new WeakReference<StateChangedListener<T>>(listener));
}
}
public void fireEvent(T value){
if (l != null) {
for (StateChangedListener<T> t : l) {
t.stateChanged(value);
Iterator<WeakReference<StateChangedListener<T>>> it = l.iterator();
while(it.hasNext()) {
StateChangedListener<T> t = it.next().get();
if(t == null) {
it.remove();
} else {
t.stateChanged(value);
}
}
}
}
@ -90,7 +97,13 @@ public class OsmandSettings {
@Override
public void removeListener(StateChangedListener<T> listener) {
if(l != null) {
l.remove(listener);
Iterator<WeakReference<StateChangedListener<T>>> it = l.iterator();
while(it.hasNext()) {
StateChangedListener<T> t = it.next().get();
if(t == listener) {
it.remove();
}
}
}
}
}
@ -359,7 +372,11 @@ public class OsmandSettings {
@Override
public void resetToDefault(){
set(getDefaultValue());
T o = defaultValue;
if(defaultValues != null && defaultValues.containsKey(currentMode)){
o = defaultValues.get(currentMode);
}
set(o);
}
@Override

View file

@ -197,7 +197,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
helper.editPoiFilter(filter);
ListView lv = this.getListView();
AmenityAdapter la = this.getListAdapter();
la.notifyDataSetInvalidated();
la.notifyDataSetChanged();
return lv;
}
@ -207,6 +207,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
for (int i = 0; i < count; i++) {
selectAllFromCategory(adapter.getItem(i));
}
adapter.notifyDataSetChanged();
}
private void deselectAll(){
@ -278,6 +279,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
filter.setTypeToAccept(model, false);
helper.editPoiFilter(filter);
}
notifyDataSetChanged();
}
});
}

View file

@ -19,6 +19,7 @@ import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask;
import net.osmand.plus.voice.MediaCommandPlayerImpl;
import net.osmand.plus.voice.TTSCommandPlayerImpl;
import net.osmand.util.Algorithms;
import android.content.Context;
import android.os.Build;
@ -39,19 +40,11 @@ public class LocalIndexHelper {
}
public String getInstalledDateEdition(long t, TimeZone timeZone){
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
if(timeZone != null) {
dateFormat.setTimeZone(timeZone);
}
return app.getString(R.string.local_index_installed) + " : " + dateFormat.format(new Date(t));
return app.getString(R.string.local_index_installed) + ": " + app.getResourceManager().getDateFormat().format(new Date(t));
}
public String getInstalledDate(long t, TimeZone timeZone){
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
if(timeZone != null) {
dateFormat.setTimeZone(timeZone);
}
return dateFormat.format(new Date(t));
return app.getResourceManager().getDateFormat().format(new Date(t));
}
public void updateDescription(LocalIndexInfo info){
@ -63,6 +56,10 @@ public class LocalIndexHelper {
} else {
info.setDescription(getInstalledDate(f));
}
} else if(info.getType() == LocalIndexType.WIKI_DATA){
info.setDescription(getInstalledDate(f));
} else if(info.getType() == LocalIndexType.SRTM_DATA){
info.setDescription(app.getString(R.string.download_srtm_maps));
} else if(info.getType() == LocalIndexType.VOICE_DATA){
info.setDescription(getInstalledDate(f));
} else if(info.getType() == LocalIndexType.TTS_VOICE_DATA){

View file

@ -194,12 +194,10 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
"ru",
"sc",
"sr",
"zh_CN",
"sk",
"sl",
"es",
"sv",
"zh_TW",
"tr",
"uk",
"vi",
@ -243,12 +241,10 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
getString(R.string.lang_ru),
getString(R.string.lang_sc),
getString(R.string.lang_sr) + incompleteSuffix,
getString(R.string.lang_zh_CN) + incompleteSuffix,
getString(R.string.lang_sk),
getString(R.string.lang_sl),
getString(R.string.lang_es),
getString(R.string.lang_sv),
getString(R.string.lang_zh_TW),
getString(R.string.lang_tr),
getString(R.string.lang_uk),
getString(R.string.lang_vi) + incompleteSuffix,
@ -382,7 +378,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
registerListPreference(
settings.OSMAND_THEME, misc,
new String[] { "Dark", "Light" }, new Integer[] { OsmandSettings.OSMAND_DARK_THEME,
new String[] { getString(R.string.dark_theme), getString(R.string.light_theme) }, new Integer[] { OsmandSettings.OSMAND_DARK_THEME,
OsmandSettings.OSMAND_LIGHT_THEME});
misc.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr));
@ -450,8 +446,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
return true;
}
private void warnAboutChangingStorage(final String newValue) {
String newDir = newValue != null ? newValue.trim() : newValue;
if(!newDir.replace('/', ' ').trim().

View file

@ -345,7 +345,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
@Override
public boolean onMenuItemClick(MenuItem item) {
PoiUIFilter custom = getMyApplication().getPoiFilters().getCustomPOIFilter();
custom.updateTypesToAccept(f);
custom.replaceWithPoiFilter(f);
showEditActivity(custom);
return true;
}
@ -410,7 +410,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
this.filter.setFilterByName(null);
}
} else {
this.filter.updateTypesToAccept(custom);
this.filter.replaceWithPoiFilter(custom);
}
filter.clearPreviousZoom();
// run query again

View file

@ -194,6 +194,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
} else {
custom.setFilterByName(null);
}
custom.clearFilter();
custom.updateTypesToAccept(((AbstractPoiType) item));
showFilterActivity(custom.getFilterId());
}

View file

@ -4,16 +4,11 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import android.app.Activity;
import android.content.Intent;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
public class OsmandDevelopmentPlugin extends OsmandPlugin {
private static final String ID = "osmand.development";
@ -25,10 +20,6 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
//ApplicationMode.regWidget("fps", new ApplicationMode[0]);
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
@Override
public String getId() {

View file

@ -397,22 +397,24 @@ public class ConfigureMapMenu {
}
}
static String[] mapNamesIds = new String[] { "", "en", "ar", "be", "ca", "cs", "da", "de", "el", "es", "fi", "fr", "he", "hi",
"hr", "hu", "it", "ja", "ko", "lt", "lv", "nl", "pl", "ro", "ru", "sk", "sl", "sv", "sw", "zh" };
static String[] mapNamesIds = new String[] { "", "en", "ar", "be", "bg", "ca", "ceb", "cs", "da", "de", "el", "et", "es", "fi", "fr", "gl", "he", "hi",
"hr", "ht", "hu", "id", "it", "ja", "ko", "lt", "lv", "ms", "new", "nl", "nn", "no", "pl", "pt", "ro", "ru", "sk", "sl", "sr", "sv", "sw", "te", "th", "tr", "uk", "vi", "vo", "zh" };
private String[] getMapNamesValues(Context ctx) {
return new String[] { ctx.getString(R.string.local_map_names), ctx.getString(R.string.lang_en),
ctx.getString(R.string.lang_ar),
ctx.getString(R.string.lang_be), ctx.getString(R.string.lang_ca), ctx.getString(R.string.lang_cs),
ctx.getString(R.string.lang_da), ctx.getString(R.string.lang_de), ctx.getString(R.string.lang_el),
ctx.getString(R.string.lang_es), ctx.getString(R.string.lang_fi), ctx.getString(R.string.lang_fr),
ctx.getString(R.string.lang_be), ctx.getString(R.string.lang_bg), ctx.getString(R.string.lang_ca), ctx.getString(R.string.lang_ceb), ctx.getString(R.string.lang_cs),
ctx.getString(R.string.lang_da), ctx.getString(R.string.lang_de), ctx.getString(R.string.lang_el), ctx.getString(R.string.lang_et),
ctx.getString(R.string.lang_es), ctx.getString(R.string.lang_fi), ctx.getString(R.string.lang_fr), ctx.getString(R.string.lang_gl),
ctx.getString(R.string.lang_he), ctx.getString(R.string.lang_hi), ctx.getString(R.string.lang_hr),
ctx.getString(R.string.lang_hu), ctx.getString(R.string.lang_it), ctx.getString(R.string.lang_ja),
ctx.getString(R.string.lang_ht), ctx.getString(R.string.lang_hu), ctx.getString(R.string.lang_id), ctx.getString(R.string.lang_it), ctx.getString(R.string.lang_ja),
ctx.getString(R.string.lang_ko), ctx.getString(R.string.lang_lt),
ctx.getString(R.string.lang_lv), ctx.getString(R.string.lang_nl),
ctx.getString(R.string.lang_pl), ctx.getString(R.string.lang_ro), ctx.getString(R.string.lang_ru),
ctx.getString(R.string.lang_sk), ctx.getString(R.string.lang_sl), ctx.getString(R.string.lang_sv),
ctx.getString(R.string.lang_sw), ctx.getString(R.string.lang_zh) };
ctx.getString(R.string.lang_lv), ctx.getString(R.string.lang_ms), ctx.getString(R.string.lang_new), ctx.getString(R.string.lang_nl), ctx.getString(R.string.lang_nn),
ctx.getString(R.string.lang_no),
ctx.getString(R.string.lang_pl), ctx.getString(R.string.lang_pt), ctx.getString(R.string.lang_ro), ctx.getString(R.string.lang_ru),
ctx.getString(R.string.lang_sk), ctx.getString(R.string.lang_sl), ctx.getString(R.string.lang_sr), ctx.getString(R.string.lang_sv),
ctx.getString(R.string.lang_sw), ctx.getString(R.string.lang_te), ctx.getString(R.string.lang_th), ctx.getString(R.string.lang_tr), ctx.getString(R.string.lang_uk),
ctx.getString(R.string.lang_vi), ctx.getString(R.string.lang_vo), ctx.getString(R.string.lang_zh) };
}
private void createProperties(List<RenderingRuleProperty> customRules, final int strId, String cat,

View file

@ -97,8 +97,25 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if(isActive()) {
if(!mapView.isLayerVisible(distanceCalculatorLayer)) {
activity.getMapView().addLayer(distanceCalculatorLayer, 4.5f);
}
if(distanceControl == null) {
registerWidget(activity);
}
} else {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if(distanceCalculatorLayer != null) {
activity.getMapView().removeLayer(distanceCalculatorLayer);
}
if (mapInfoLayer != null && distanceControl != null ) {
mapInfoLayer.removeSideWidget(distanceControl);
mapInfoLayer.recreateControls();
distanceControl = null;
}
}
}
@Override

View file

@ -31,6 +31,7 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.ListFragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
@ -378,9 +379,12 @@ public class DownloadActivity extends BaseDownloadActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
for(String w : wiki) {
File fl = new File(w);
File nf = new File(fl.getParentFile() +"/" + IndexConstants.BACKUP_INDEX_DIR, fl.getName());
fl.renameTo(nf);
File fl = getMyApplication().getAppPath(w);
File nf = new File(fl.getParentFile(), IndexConstants.BACKUP_INDEX_DIR + "/"+fl.getName());
boolean res = fl.renameTo(nf);
if(!res) {
System.err.println("Renaming from " + fl.getAbsolutePath() + " to " + nf.getAbsolutePath() + " failed");
}
}
}
});

View file

@ -1,7 +1,6 @@
package net.osmand.plus.download;
import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT;
import static net.osmand.IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
import java.io.File;
import java.io.IOException;

View file

@ -19,7 +19,6 @@ public class DownloadEntry {
public String assetName;
public DownloadActivityType type;
public DownloadEntry attachedEntry;
public IndexItem item;
public DownloadEntry(IndexItem item) {

View file

@ -3,6 +3,7 @@ package net.osmand.plus.download;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -24,6 +25,7 @@ import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.DownloadFileHelper.DownloadFileShowWarning;
import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem;
import net.osmand.plus.helpers.DatabaseHelper;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.util.Algorithms;
@ -375,9 +377,6 @@ public class DownloadIndexesThread {
} else {
res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
}
if (res && de.attachedEntry != null) {
return downloadFile(de.attachedEntry, filesToReindex, forceWifi);
}
return res;
}
@ -593,8 +592,28 @@ public class DownloadIndexesThread {
outdated = true;
} else {
long itemSize = item.getContentSize();
File file = new File(item.getType().getDownloadFolder(app, item), sfName);
long oldItemSize = file.length();
long oldItemSize = 0;
if(item.getType() == DownloadActivityType.VOICE_FILE) {
if(item instanceof AssetIndexItem) {
File file = new File(((AssetIndexItem) item).getDestFile());
oldItemSize = file.length();
} else {
File fl = new File(item.getType().getDownloadFolder(app, item), sfName +"/_config.p");
if (fl.exists()) {
oldItemSize = fl.length();
try {
InputStream is = ctx.getAssets().open("voice/" + sfName + "/config.p");
if (is != null) {
itemSize = is.available();
is.close();
}
} catch (IOException e) {
}
}
}
}
if (itemSize != oldItemSize){
outdated = true;
}

View file

@ -328,19 +328,22 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
}
private String getMapDescription(IndexItem item){
String typeName = getTypeName(item.getType().getResource());
String typeName = getTypeName(item, item.getType().getResource());
String date = item.getDate(format);
String size = item.getSizeDescription(getActivity());
return typeName + " " + date + " " + size;
}
private String getTypeName(int resId){
private String getTypeName(IndexItem item, int resId){
Activity activity = getActivity();
if (resId == R.string.download_regular_maps){
return activity.getString(R.string.shared_string_map);
} else if (resId == R.string.voices){
return activity.getString(R.string.ttsvoice);
} else if (resId == R.string.download_wikipedia_maps){
return activity.getString(R.string.download_wikipedia_item);
} else if (resId == R.string.voices) {
return item.getTargetFileName().contains("tts") ? activity.getString(R.string.ttsvoice) : activity
.getString(R.string.voice);
} else if (resId == R.string.download_roads_only_maps){
return activity.getString(R.string.roads_only);
} else if (resId == R.string.download_srtm_maps){

View file

@ -96,7 +96,8 @@ public class AvoidSpecificRoads {
protected String getText(RouteDataObject obj) {
return RoutingHelper.formatStreetName(obj.getName(), obj.getRef(), obj.getDestinationName());
return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get()),
obj.getRef(), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get()));
}
public void showDialog(final MapActivity mapActivity) {

View file

@ -55,6 +55,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
liveMonitoringHelper = new LiveMonitoringHelper(app);
final List<ApplicationMode> am = ApplicationMode.allPossibleValues();
ApplicationMode.regWidget("monitoring", am.toArray(new ApplicationMode[am.size()]));
settings = app.getSettings();
}
@Override
@ -72,12 +73,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
return R.drawable.trip_recording;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
settings = app.getSettings();
return true;
}
@Override
public String getId() {
return ID;
@ -95,6 +90,10 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
@Override
public void registerLayers(MapActivity activity) {
registerWidget(activity);
}
private void registerWidget(MapActivity activity) {
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
monitoringControl = createMonitoringControl(activity);
@ -105,8 +104,17 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if(monitoringControl == null) {
registerLayers(activity);
if (isActive()) {
if (monitoringControl == null) {
registerWidget(activity);
}
} else {
if (monitoringControl != null) {
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
layer.removeSideWidget(monitoringControl);
layer.recreateControls();
monitoringControl = null;
}
}
}

View file

@ -63,12 +63,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
public OsmEditingPlugin(OsmandApplication app) {
this.app = app;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
settings = app.getSettings();
return true;
}
private OsmBugsLayer osmBugsLayer;

View file

@ -30,6 +30,7 @@ import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
import net.osmand.plus.osmo.OsMoService.SessionInfo;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.util.Algorithms;
@ -169,21 +170,49 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
super.registerMapContextMenuActions(mapActivity, latitude, longitude, adapter, selectedObj);
}
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if(isActive()) {
if(olayer == null) {
registerLayers(activity);
}
if(osmoControl == null) {
registerSideWidget(activity);
}
} else {
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
if (layer != null && osmoControl != null) {
layer.removeSideWidget(osmoControl);
osmoControl = null;
layer.recreateControls();
}
if(olayer != null) {
activity.getMapView().removeLayer(olayer);
olayer = null;
}
}
}
@Override
public void registerLayers(MapActivity activity) {
super.registerLayers(activity);
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
osmoControl = createOsMoControl(activity);
layer.registerSideWidget(osmoControl,
R.drawable.ic_osmo_dark, R.string.osmo_control, "osmo_control", false, 18);
layer.recreateControls();
registerSideWidget(activity);
if(olayer != null) {
activity.getMapView().removeLayer(olayer);
}
olayer = new OsMoPositionLayer(activity, this);
activity.getMapView().addLayer(olayer, 5.5f);
}
private void registerSideWidget(MapActivity activity) {
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
if (layer != null) {
osmoControl = createOsMoControl(activity);
layer.registerSideWidget(osmoControl, R.drawable.ic_osmo_dark, R.string.osmo_control, "osmo_control",
false, 18);
layer.recreateControls();
}
}
@Override
public void mapActivityPause(MapActivity activity) {

View file

@ -144,12 +144,6 @@ public class ParkingPositionPlugin extends OsmandPlugin {
return true;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
@Override
public String getId() {
return ID;

View file

@ -449,9 +449,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
public void updateTypesToAccept(AbstractPoiType pt) {
acceptedTypes.clear();
pt.putTypes(acceptedTypes);
poiAdditionals.clear();
if (pt instanceof PoiType && ((PoiType) pt).isAdditional() && ((PoiType) pt).getParentType() != null) {
fillPoiAdditionals(((PoiType) pt).getParentType());
} else {
@ -488,7 +486,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
}
}
public void updateTypesToAccept(PoiUIFilter f) {
public void replaceWithPoiFilter(PoiUIFilter f) {
acceptedTypes.clear();
acceptedTypes.putAll(f.acceptedTypes);
poiAdditionals.clear();

View file

@ -50,12 +50,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
public OsmandRasterMapsPlugin(OsmandApplication app) {
this.app = app;
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
settings = app.getSettings();
return true;
}
@Override

View file

@ -731,24 +731,23 @@ public class MapRenderRepositories {
Bitmap reuse = prevBmp;
this.prevBmp = this.bmp;
this.prevBmpLocation = this.bmpLocation;
if (reuse != null && reuse.getWidth() == currentRenderingContext.width && reuse.getHeight() == currentRenderingContext.height) {
// necessary for transparent, otherwise 2 times smaller
Config cfg = transparent ? Config.ARGB_8888 : Config.RGB_565;
if (reuse != null && reuse.getWidth() == currentRenderingContext.width && reuse.getHeight() == currentRenderingContext.height &&
cfg == reuse.getConfig()) {
bmp = reuse;
bmp.eraseColor(currentRenderingContext.defaultColor);
} else {
if(reuse != null){
log.warn(String.format("Create new image ? %d != %d (w) %d != %d (h) ", currentRenderingContext.width, reuse.getWidth(), currentRenderingContext.height, reuse.getHeight()));
}
if(transparent) {
// necessary
bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.ARGB_8888);
} else {
// better picture ?
bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.ARGB_8888);
bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, cfg);
if(reuse != null) {
reuse.recycle();
}
}
this.bmp = bmp;
this.bmpLocation = tileRect;
if(nativeLib != null) {
renderer.generateNewBitmapNative(currentRenderingContext, nativeLib, cNativeObjects, bmp, renderingReq, notifyList);
} else {

View file

@ -190,11 +190,6 @@ public class RoutePointsPlugin extends OsmandPlugin {
return app.getString(R.string.route_plugin_name);
}
@Override
public boolean init(OsmandApplication app, Activity activity) {
return true;
}
private void registerWidget(MapActivity activity) {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if (mapInfoLayer != null) {

View file

@ -10,6 +10,7 @@ import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.TurnType;
@ -85,7 +86,7 @@ public class RouteCalculationResult {
}
public RouteCalculationResult(List<RouteSegmentResult> list, Location start, LatLon end, List<LatLon> intermediates,
Context ctx, boolean leftSide, float routingTime, List<LocationPoint> waypoints) {
OsmandApplication ctx, boolean leftSide, float routingTime, List<LocationPoint> waypoints) {
this.routingTime = routingTime;
if(waypoints != null) {
this.locationPoints.addAll(waypoints);
@ -207,7 +208,7 @@ public class RouteCalculationResult {
* PREPARATION
*/
private static List<RouteSegmentResult> convertVectorResult(List<RouteDirectionInfo> directions, List<Location> locations, List<RouteSegmentResult> list,
List<AlarmInfo> alarms, Context ctx) {
List<AlarmInfo> alarms, OsmandApplication ctx) {
float prevDirectionTime = 0;
float prevDirectionDistance = 0;
List<RouteSegmentResult> segmentsToPopulate = new ArrayList<RouteSegmentResult>();
@ -254,8 +255,8 @@ public class RouteCalculationResult {
}
RouteSegmentResult next = list.get(lind);
info.setRef(next.getObject().getRef());
info.setStreetName(next.getObject().getName());
info.setDestinationName(next.getObject().getDestinationName());
info.setStreetName(next.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get()));
info.setDestinationName(next.getObject().getDestinationName(ctx.getSettings().MAP_PREFERRED_LOCALE.get()));
}
String description = toString(turn, ctx) + " " + RoutingHelper.formatStreetName(info.getStreetName(),

View file

@ -693,9 +693,9 @@ public class RoutingHelper {
}
RouteSegmentResult rs = getCurrentSegmentResult();
if(rs != null) {
String nm = rs.getObject().getName();
String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get());
String rf = rs.getObject().getRef();
String dn = rs.getObject().getDestinationName();
String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get());
return formatStreetName(nm, rf, dn);
}
return null;

View file

@ -555,10 +555,11 @@ public class VoiceRouter {
getTermString(getSpeakablePointName(i.getDestinationName())) });
Term current = empty;
if (currentSegment != null) {
RouteDataObject obj = currentSegment.getObject();
current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef())),
getTermString(getSpeakablePointName(obj.getName())),
getTermString(getSpeakablePointName(obj.getDestinationName())) });
getTermString(getSpeakablePointName(obj.getName(settings.MAP_PREFERRED_LOCALE.get()))),
getTermString(getSpeakablePointName(obj.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()))) });
}
Struct voice = new Struct("voice", next, current );
return voice;

View file

@ -29,6 +29,7 @@ public class SRTMPlugin extends OsmandPlugin {
public SRTMPlugin(OsmandApplication app) {
this.app = app;
HILLSHADE = app.getSettings().registerBooleanPreference("hillshade_layer", true);
}
@Override
@ -54,7 +55,6 @@ public class SRTMPlugin extends OsmandPlugin {
@Override
public boolean init(final OsmandApplication app, Activity activity) {
HILLSHADE = app.getSettings().registerBooleanPreference("hillshade_layer", true);
OsmandSettings settings = app.getSettings();
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
if(pref.get().equals("")) {

View file

@ -1,62 +0,0 @@
package net.osmand.plus.touringview;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.render.RendererRegistry;
import android.app.Activity;
public class TouringViewPlugin extends OsmandPlugin {
public static final String ID = "touringView.plugin";
public static final String COMPONENT = "net.osmand.touringviewPlugin";
private static String previousRenderer = RendererRegistry.DEFAULT_RENDER;
private OsmandApplication app;
public TouringViewPlugin(OsmandApplication app) {
this.app = app;
}
@Override
public String getDescription() {
return app.getString(net.osmand.plus.R.string.plugin_touringview_descr);
}
@Override
public int getAssetResourceName() {
return R.drawable.touring_map_view;
}
@Override
public String getName() {
return app.getString(net.osmand.plus.R.string.plugin_touringview_name);
}
@Override
public boolean init(final OsmandApplication app, final Activity activity) {
if(activity != null) {
// called from UI
previousRenderer = app.getSettings().RENDERER.get();
app.getSettings().RENDERER.set(RendererRegistry.TOURING_VIEW);
}
return true;
}
@Override
public void disable(OsmandApplication app) {
super.disable(app);
if(app.getSettings().RENDERER.get().equals(RendererRegistry.TOURING_VIEW)) {
app.getSettings().RENDERER.set(previousRenderer);
}
}
@Override
public String getId() {
return ID;
}
@Override
public Class<? extends Activity> getSettingsActivity() {
return null;
}
}

View file

@ -52,7 +52,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private int cachedHash;
private int cachedColor;
private Path path;
private static final int startZoom = 7;
@ -92,7 +91,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
paint_1.setAntiAlias(true);
path = new Path();
paintBmp = new Paint();
paintBmp.setAntiAlias(true);
@ -302,35 +300,35 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private void drawSegments(Canvas canvas, RotatedTileBox tileBox, List<TrkSegment> points) {
final QuadRect latLonBounds = tileBox.getLatLonBounds();
for (TrkSegment l : points) {
path.rewind();
int startIndex = -1;
int endIndex = -1;
int prevCross = 0;
boolean intersect = false;
double shift = 0;
for (int i = 0; i < l.points.size(); i++) {
WptPt ls = l.points.get(i);
int cross = 0;
cross |= (ls.lon < latLonBounds.left - 0.1 ? 1 : 0);
cross |= (ls.lon > latLonBounds.right + 0.1 ? 2 : 0);
cross |= (ls.lat > latLonBounds.top + 0.1 ? 4 : 0);
cross |= (ls.lat < latLonBounds.bottom - 0.1 ? 8 : 0);
cross |= (ls.lon < latLonBounds.left - shift ? 1 : 0);
cross |= (ls.lon > latLonBounds.right + shift ? 2 : 0);
cross |= (ls.lat > latLonBounds.top + shift ? 4 : 0);
cross |= (ls.lat < latLonBounds.bottom - shift ? 8 : 0);
if (i > 0) {
if ((prevCross & cross) == 0) {
if (prevCross != 0 || !intersect) {
if (startIndex > 0) {
if (endIndex == i - 1 && startIndex != -1) {
// continue previous line
} else {
// start new segment
if (startIndex >= 0) {
drawSegment(canvas, tileBox, l, startIndex, endIndex);
}
startIndex = i - 1;
}
endIndex = i;
intersect = true;
}
}
prevCross = cross;
}
if (startIndex != -1) {
drawSegment(canvas, tileBox, l, startIndex, l.points.size() - 1);
drawSegment(canvas, tileBox, l, startIndex, endIndex);
}
}
}
@ -345,7 +343,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
TIntArrayList tx = new TIntArrayList();
TIntArrayList ty = new TIntArrayList();
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
Path path = new Path();
for (int i = startIndex; i <= endIndex; i++) {
WptPt p = l.points.get(i);
int x = (int) tb.getPixXFromLatLon(p.lat, p.lon);

View file

@ -82,6 +82,10 @@ public class MapInfoLayer extends OsmandMapLayer {
updateReg(calculateTextState(), reg);
}
public void removeSideWidget(TextInfoWidget widget) {
mapInfoControls.removeSideWidgetInternal(widget);
}
public void registerAllControls(){
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
@ -299,6 +303,8 @@ public class MapInfoLayer extends OsmandMapLayer {
return defValue;
}

View file

@ -23,9 +23,7 @@ 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.download.DownloadActivity;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.osmo.OsMoService;
import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.render.RenderingIcons;
@ -34,21 +32,18 @@ import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
import net.osmand.util.Algorithms;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnCancelListener;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.drawable.Drawable;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.PopupMenu;
@ -64,7 +59,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
@ -343,9 +337,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
public static void showDescriptionDialog(Context ctx, OsmandApplication app, Amenity a) {
String lang = app.getSettings().MAP_PREFERRED_LOCALE.get();
if (a.getType().isWiki()) {
// First choice to display wiki article in should be the selected OsmAnd locale (not the map display language)
//showWiki(ctx, app, a, lang);
showWiki(ctx, app, a, app.getSettings().PREFERRED_LOCALE.get());
String preferredLang = lang;
if(Algorithms.isEmpty(preferredLang)) {
preferredLang = app.getLanguage();
}
showWiki(ctx, app, a, preferredLang);
} else {
String d = OsmAndFormatter.getAmenityDescriptionContent(app, a, false);
SpannableString spannable = new SpannableString(d);
@ -388,7 +384,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
topBar.setBackgroundColor(ctx.getResources().getColor(getResIdFromAttribute(ctx, R.attr.pstsTabBackground)));
topBar.setTitleTextColor(ctx.getResources().getColor(getResIdFromAttribute(ctx, R.attr.pstsTextColor)));
String lng = a.getNameSelected(lang);
String lng = a.getContentSelected("content", lang, "en");
if(Algorithms.isEmpty(lng)) {
lng = "en";
}
@ -496,7 +492,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) {
return new PointDescription(PointDescription.POINT_TYPE_POI, ((Amenity) o).getName());
return new PointDescription(PointDescription.POINT_TYPE_POI, ((Amenity) o).getName(
view.getSettings().MAP_PREFERRED_LOCALE.get()));
}
return null;
}
@ -526,7 +523,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public String getText(Amenity o) {
return o.getName(view.getSettings().usingEnglishNames());
return o.getName(view.getSettings().MAP_PREFERRED_LOCALE.get());
}
@Override

View file

@ -197,6 +197,7 @@ public class RouteLayer extends OsmandMapLayer {
for (int i = 0; i < actionPoints.size(); i++) {
Location o = actionPoints.get(i);
if (o == null) {
first = true;
canvas.drawPath(pth, actionPaint);
double angleRad = Math.atan2(y - py, x - px);
double angle = (angleRad * 180 / Math.PI) + 90f;
@ -212,7 +213,6 @@ public class RouteLayer extends OsmandMapLayer {
matrix.postRotate((float) angle, actionArrow.getWidth() / 2, 0);
matrix.postTranslate(px + pdx - actionArrow.getWidth() / 2, py + pdy);
canvas.drawBitmap(actionArrow, matrix, paintIconAction);
first = true;
} else {
px = x;
py = y;
@ -375,77 +375,91 @@ public class RouteLayer extends OsmandMapLayer {
double actionDist = 0;
Location previousAction = null;
actionPoints.clear();
int prevPoint = -2;
for (int i = 0; i < routeNodes.size(); i++) {
Location ls = routeNodes.get(i);
int prevFinishPoint = -1;
for (int routePoint = 0; routePoint < routeNodes.size(); routePoint++) {
Location loc = routeNodes.get(routePoint);
if(nf != null) {
int pnt = nf.routeEndPointOffset == 0 ? nf.routePointOffset : nf.routeEndPointOffset;
if(pnt < i + cd ) {
if(pnt < routePoint + cd ) {
nf = null;
}
}
while (nf == null && it.hasNext()) {
nf = it.next();
int pnt = nf.routeEndPointOffset == 0 ? nf.routePointOffset : nf.routeEndPointOffset;
if (pnt < i + cd) {
if (pnt < routePoint + cd) {
nf = null;
}
}
boolean action = nf != null && (nf.routePointOffset == i + cd ||
(nf.routePointOffset <= i + cd && i + cd <= nf.routeEndPointOffset));
boolean action = nf != null && (nf.routePointOffset == routePoint + cd ||
(nf.routePointOffset <= routePoint + cd && routePoint + cd <= nf.routeEndPointOffset));
if(!action && previousAction == null) {
// no need to check
continue;
}
boolean visible = leftLongitude <= ls.getLongitude() && ls.getLongitude() <= rightLongitude && bottomLatitude <= ls.getLatitude()
&& ls.getLatitude() <= topLatitude;
if(!action) {
if(previousAction != null) {
float loc = ls.distanceTo(previousAction);
actionDist += loc;
if(actionDist >= DISTANCE_ACTION) {
actionPoints.add(calculateProjection(1 - (actionDist - DISTANCE_ACTION) / loc, previousAction, ls));
prevPoint = i;
actionPoints.add(null);
previousAction = null;
actionDist = 0;
} else {
actionPoints.add(ls);
previousAction = ls;
}
boolean visible = leftLongitude <= loc.getLongitude() && loc.getLongitude() <= rightLongitude && bottomLatitude <= loc.getLatitude()
&& loc.getLatitude() <= topLatitude;
if(action && !visible && previousAction == null) {
continue;
}
if (!action) {
// previousAction != null
float dist = loc.distanceTo(previousAction);
actionDist += dist;
if (actionDist >= DISTANCE_ACTION) {
actionPoints.add(calculateProjection(1 - (actionDist - DISTANCE_ACTION) / dist, previousAction, loc));
actionPoints.add(null);
prevFinishPoint = routePoint;
previousAction = null;
actionDist = 0;
} else {
actionPoints.add(loc);
previousAction = loc;
}
} else {
// action point
if(visible) {
int ind = actionPoints.size();
actionPoints.add(ls);
if (previousAction == null) {
Location lp = ls;
double dist = 0;
for (int k = i - 1; k >= -1; k--) {
Location l = k == -1 ? lastProjection : routeNodes.get(k);
float loc = lp.distanceTo(l);
dist += loc;
if (dist >= DISTANCE_ACTION) {
if(loc > 1) {
actionPoints.add(ind, calculateProjection(1 - (dist - DISTANCE_ACTION) / loc, lp, l));
}
break;
} else {
if(prevPoint == k) {
actionPoints.remove(actionPoints.size() - 1);
actionPoints.remove(actionPoints.size() - 1);
prevPoint = -2;
ind = actionPoints.size();
}
actionPoints.add(ind, l);
lp = l;
}
}
}
previousAction = ls;
actionDist = 0;
if (previousAction == null) {
addPreviousToActionPoints(lastProjection, routeNodes, DISTANCE_ACTION,
prevFinishPoint, routePoint, loc);
}
actionPoints.add(loc);
previousAction = loc;
prevFinishPoint = -1;
actionDist = 0;
}
}
if(previousAction != null) {
actionPoints.add(null);
}
}
private void addPreviousToActionPoints(Location lastProjection, List<Location> routeNodes, double DISTANCE_ACTION,
int prevFinishPoint, int routePoint, Location loc) {
// put some points in front
int ind = actionPoints.size();
Location lprevious = loc;
double dist = 0;
for (int k = routePoint - 1; k >= -1; k--) {
Location l = k == -1 ? lastProjection : routeNodes.get(k);
float locDist = lprevious.distanceTo(l);
dist += locDist;
if (dist >= DISTANCE_ACTION) {
if (locDist > 1) {
actionPoints.add(ind,
calculateProjection(1 - (dist - DISTANCE_ACTION) / locDist, lprevious, l));
}
break;
} else {
actionPoints.add(ind, l);
lprevious = l;
}
if (prevFinishPoint == k) {
if (ind >= 2) {
actionPoints.remove(ind - 2);
actionPoints.remove(ind - 2);
}
break;
}
}
}

View file

@ -258,7 +258,8 @@ public class MapInfoWidgetsFactory {
settings.SHOW_STREET_NAME.get()) {
RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
if(rt != null) {
text = RoutingHelper.formatStreetName(rt.getName(), rt.getRef(), rt.getDestinationName());
text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()));
}
if(text == null) {
text = "";

View file

@ -1,6 +1,7 @@
package net.osmand.plus.views.mapwidgets;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
@ -89,6 +90,24 @@ public class MapWidgetRegistry {
}
}
}
public void removeSideWidgetInternal(TextInfoWidget widget) {
Iterator<MapWidgetRegInfo> it = left.iterator();
while (it.hasNext()) {
if (it.next().widget == widget) {
it.remove();
}
}
it = right.iterator();
while (it.hasNext()) {
if (it.next().widget == widget) {
it.remove();
}
}
}
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, int drawableMenu,
int messageId, String key, boolean left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
@ -246,7 +265,7 @@ public class MapWidgetRegistry {
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
pref.set(!pref.get());
map.updateApplicationModeSettings();
a.notifyDataSetInvalidated();
a.notifyDataSetChanged();;
return false;
}
};