This commit is contained in:
Weblate 2013-08-25 23:14:04 +02:00
commit 1f81661edf
55 changed files with 894 additions and 489 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@ mm_*.png
mx_*.png
*.class
.settings
.idea

View file

@ -1,7 +1,7 @@
### Credits to all major contributors/developers :
* Victor Shcherb - all parts of the project, originator
* Pavol Zibrita - first contributor & developer of some utilities
* Dusan Kazik - one of the first contributor
* Pavol Zibrita - first contributor and developer of some utilities
* Dusan Kazik - one of the first contributors
* Andre Van Atten - project supporter, active forum participant, one of the first users.
* Dr. Hardy Mueller - map appearance concept and base renderers, international consistency and testing, usability, app scoping, concepts, documentation, wiki, market research.
* Yvecai - main contributor to Contour Lines and Hillshade maps

View file

@ -1,4 +1,5 @@
bin
c-src
OsmAnd-core.jar
OsmAnd-core-android.jar
src/net/osmand/core/jni/*

View file

@ -16,9 +16,59 @@ elseif(CMAKE_TARGET_OS STREQUAL "linux")
)
endif()
file(GLOB_RECURSE core_includes "${OSMAND_ROOT}/core/include/*.h*")
file(GLOB_RECURSE core_headers "${OSMAND_ROOT}/core/src/*.h*")
file(GLOB_RECURSE core_sources "${OSMAND_ROOT}/core/src/*.c*")
file(GLOB_RECURSE core_headers_client "${OSMAND_ROOT}/core/client/*.h*")
file(GLOB_RECURSE core_sources_client "${OSMAND_ROOT}/core/client/*.c*")
file(GLOB core_swig "${OSMAND_ROOT}/core.swig")
file(GLOB_RECURSE core_swig_subfiles "${OSMAND_ROOT}/swig/*")
set(OsmAndJNI_generated_cpp
"${CMAKE_CURRENT_LIST_DIR}/c-src/swig.cpp"
)
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
add_custom_command(OUTPUT ${OsmAndJNI_generated_cpp}
COMMAND bash ARGS --login "${CMAKE_CURRENT_LIST_DIR}/generate-swig.sh"
DEPENDS
${core_includes}
${core_headers}
${core_sources}
${core_headers_client}
${core_sources_client}
${core_swig}
${core_swig_subfiles}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMENT "Generating sources...")
else()
add_custom_command(OUTPUT ${OsmAndJNI_generated_cpp}
COMMAND "${CMAKE_CURRENT_LIST_DIR}/generate-swig.sh"
DEPENDS
${core_includes}
${core_headers}
${core_sources}
${core_headers_client}
${core_sources_client}
${core_swig}
${core_swig_subfiles}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMENT "Generating sources...")
endif()
add_custom_target(OsmAndJNI_generate_swig
ALL
DEPENDS
${OsmAndJNI_generated_cpp}
SOURCES
${OsmAndJNI_generated_cpp}
)
set_source_files_properties(${OsmAndJNI_generated_cpp}
PROPERTIES
GENERATED TRUE
)
if(CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
add_library(OsmAndJNI SHARED
"c-src/swig.cpp"
${OsmAndJNI_generated_cpp}
)
target_compile_definitions(OsmAndJNI
PRIVATE
@ -29,6 +79,9 @@ if(CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
"$ENV{JAVA_HOME}/include"
${target_specific_private_includes}
)
add_dependencies(OsmAndJNI
OsmAndJNI_generate_swig
)
if(CMAKE_STATIC_LIBS_ALLOWED_ON_TARGET)
add_dependencies(OsmAndJNI

108
OsmAnd-java/OsmAnd-java.iml Normal file
View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="jar://$MODULE_DIR$/libs/bsh-core-2.0b4.jar!/" />
<libelement value="jar://$MODULE_DIR$/libs/bzip2-20090327.jar!/" />
<libelement value="jar://$MODULE_DIR$/libs/commons-logging-1.1.1.jar!/" />
<libelement value="jar://$MODULE_DIR$/libs/json-20090211.jar!/" />
<libelement value="jar://$MODULE_DIR$/libs/junidecode-0.1.jar!/" />
<libelement value="jar://$MODULE_DIR$/libs/kxml2-2.3.0.jar!/" />
<libelement value="jar://$MODULE_DIR$/libs/tuprolog.jar!/" />
<libelement value="jar://$MODULE_DIR$/libs/icu4j-49_1.jar!/" />
<libelement value="jar://$MODULE_DIR$/libs/gnu-trove-osmand.jar!/" />
<src_description expected_position="0">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
</src_description>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
<orderEntry type="module-library">
<library name="bsh-core-2.0b4.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/bsh-core-2.0b4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="bzip2-20090327.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/bzip2-20090327.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="commons-logging-1.1.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/commons-logging-1.1.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="json-20090211.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/json-20090211.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="junidecode-0.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/junidecode-0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="kxml2-2.3.0.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/kxml2-2.3.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="tuprolog.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/tuprolog.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="icu4j-49_1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/icu4j-49_1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="gnu-trove-osmand.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/libs/gnu-trove-osmand.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View file

@ -28,7 +28,6 @@ function compile {
"$ROOT_LOC/core/externals/configure.sh" ${OSMAND_ANDROID_EXTERNAL_DEPENDENCIES[*]}
"$ROOT_LOC/core/externals/build.sh" ${OSMAND_ANDROID_EXTERNAL_DEPENDENCIES[*]}
"$ROOT_LOC/tools/map-viewer/externals/configure.sh"
"$ROOT_LOC/android/OsmAnd-java/generate-swig.sh"
if [ ! -d "$ROOT_LOC/amd64-linux-gcc-release.makefile" ]; then
"$ROOT_LOC/build/amd64-linux-gcc.sh" release
fi

View file

@ -28,6 +28,12 @@ import net.osmand.router.RoutingConfiguration;
public class NativeLibrary {
protected final boolean newLibrary;
public NativeLibrary(boolean newLibrary) {
this.newLibrary = newLibrary;
}
public static class RenderingGenerationResult {
public RenderingGenerationResult(ByteBuffer bitmap) {
bitmapBuffer = bitmap;
@ -84,7 +90,7 @@ public class NativeLibrary {
}
/**
* @param searchResultHandle
* @param
* - must be null if there is no need to append to previous results returns native handle to results
*/
public NativeSearchResult searchObjectsForRendering(int sleft, int sright, int stop, int sbottom, int zoom,
@ -106,7 +112,12 @@ public class NativeLibrary {
}
public boolean initMapFile(String filePath) {
if(newLibrary) {
// TODO
return initBinaryMapFile(filePath);
} else {
return initBinaryMapFile(filePath);
}
}
public boolean initCacheMapFile(String filePath) {
@ -221,13 +232,10 @@ public class NativeLibrary {
*/
private static final Log log = PlatformUtil.getLog(NativeLibrary.class);
public static boolean loadAllLibs(String path) {
boolean b = true;
b &= load("Qt5Core", path);
b &= load("OsmAndCore", path);
b &= load("OsmAndCoreUtils", path);
b &= load("OsmAndJNI", path);
return b;
public static boolean loadNewLib(String path) {
return load("OsmAndJNI", path);
}
public static boolean loadOldLib(String path) {
@ -289,4 +297,5 @@ public class NativeLibrary {
} // fall through
return false;
}
}

View file

@ -2,9 +2,6 @@ package net.osmand.binary;
import java.io.IOException;
import java.util.Collections;
import net.osmand.NativeLibrary;
public class BinaryInspectorNative {
@ -18,10 +15,6 @@ public class BinaryInspectorNative {
}
args = new String[]{"-vmap", "-bbox=11.3,47.1,11.6,47", "/home/victor/projects/OsmAnd/data/osm-gen/Austria_2.obf"};
// test cases show info
NativeLibrary.loadAllLibs(null);
// StringVector vector = new StringVector();
// Collections.addAll(vector, args);
// ObfInspector.inspector(vector);
}
public static void printUsage(String warning) {

View file

@ -296,28 +296,4 @@ public class Algorithms {
return defaultValue;
}
private static java.text.DateFormat dateFormat;
private static java.text.DateFormat dateTimeFormat;
public static String formatDate(long t) {
return getDateFormat().format(new Date(t));
}
public static DateFormat getDateFormat() {
if(dateFormat == null) {
dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
}
return dateFormat;
}
public static DateFormat getDateTimeFormat() {
if (dateTimeFormat == null) {
dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault());
}
return dateTimeFormat;
}
public static String formatDateTime(long t) {
return getDateTimeFormat().format(new Date(t));
}
}

57
OsmAnd/OsmAnd.iml Normal file
View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager" forced_jdk="true">
<varelement var="file://$OSMAND_TRUNK$/OsmAnd-java/src" value="linksrc:use" />
<varelement var="file://$OSMAND_TRUNK$/OsmAnd-java/src" kind="linksrc:" value="use" />
<conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$OSMAND_TRUNK$/OsmAnd-java/src" expected_position="1" />
<src_folder value="file://$MODULE_DIR$/gen" expected_position="2" />
<src_folder value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" expected_position="3" />
<src_folder value="com.android.ide.eclipse.adt.LIBRARIES" expected_position="4" />
</src_description>
</component>
<component name="FacetManager">
<facet type="android" name="Android">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Android 4.1.2 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="com.android.ide.eclipse.adt.DEPENDENCIES" level="application" />
<orderEntry type="module" module-name="SherlockBar" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$OSMAND_TRUNK$/OsmAnd-java/OsmAnd-core-android.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$OSMAND_TRUNK$/OsmAnd-java/OsmAnd-core-android.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/libs" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$MODULE_DIR$/libs" />
</SOURCES>
<jarDirectory url="file://$MODULE_DIR$/libs" recursive="false" />
<jarDirectory url="file://$MODULE_DIR$/libs" recursive="false" type="SOURCES" />
</library>
</orderEntry>
</component>
</module>

View file

@ -22,4 +22,4 @@ if [ -z "$OSMAND_X86_ONLY" ] && [ -z "$OSMAND_ARM_ONLY" ] && [ -z "$OSMAND_ARMv5
fi
export BUILD_ONLY_OLD_LIB=1
"$SCRIPT_LOC/../../core/externals/configure.sh"
(cd "$SCRIPT_LOC" && "$ANDROID_NDK/ndk-build" -j`nproc`)
(cd "$SCRIPT_LOC" && "$ANDROID_NDK/ndk-build" -j1)

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="srtm_paid_version_msg">Overvej at købe Højdekurve udvidelsen (\'Contour lines\') på Google Play for at støtte den videre udvikling.</string>
<string name="av_def_action_video">Optag video</string>
<string name="av_def_action_audio">Optag audio</string>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="btn_add_tag">Προσθήκη Ετικέτας</string>
<string name="btn_advanced_mode">Λειτουργία για προχωρημένους…</string>
<string name="poi_filter_parking">Στάθμευση</string>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="live_monitoring_mode_off">Iniciar\n seguimiento en directo</string>
<string name="live_monitoring_mode_on">Parar\n seguimiento en directo</string>
<string name="layer_map_appearance">Configura pantalla</string>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="local_osm_changes_backup_failed">پشتیبان گیری از تغییرات OSM ناموفق بود</string>
<string name="plugin_distance_point_time">زمان</string>
<string name="plugin_distance_point_hdop">دقت</string>
@ -343,7 +343,7 @@
<string name="follow">دنبال کردن</string>
<string name="mark_final_location_first">لطفا ابتدا مقصد را انتخاب کنید</string>
<string name="get_directions">مسیرها</string>
<string name="show_gps_status">نشان دادن /'وضعیت GPS/'</string>
<string name="show_gps_status">نشان دادن /\'وضعیت GPS/\'</string>
<string name="opening_hours">ساعات باز بودن</string>
<string name="history">تاریخچه</string>
<string name="search_nothing_found">چیزی پیدا نشد</string>
@ -1370,9 +1370,9 @@ OsmAnd منبع باز است و فعالانه در حال توسعه است.
<string name="index_name_wiki">ویکی پدیای POIهای سراسر جهان</string>
<string name="tip_rotation_switching_t_v2">میتوانید چگونگی نمایش و چرخش نقشه را با کلیک کردن بر روی آیکون قطب نمای صفحه نمایش نقشه عوض کنید.
\n\nانتخابها عبارتند از:
\n\t* \'عدم چرخش (شمال به طرف بالا)\'- نقشه نمیچرخد. شمال همیشه به طرف بالا خواهد بود
\n\t* \'به طرف جهت حرکت\'- نقشه به طور مداوم هم جهت با مسیر حرکت خواهد بود
\n\t* \'به طرف قطب نما\'- نقشه به طور مداوم هم جهت با قطب نمای دستگاه خواهد بود
\n\t\*\'عدم چرخش (شمال به طرف بالا)\'- نقشه نمیچرخد. شمال همیشه به طرف بالا خواهد بود
\n\t\*\'به طرف جهت حرکت\'- نقشه به طور مداوم هم جهت با مسیر حرکت خواهد بود
\n\t\'به طرف قطب نما\'- نقشه به طور مداوم هم جهت با قطب نمای دستگاه خواهد بود
</string>
<string name="tip_day_night_mode_t_v2">ظاهر نقشه برای نقشه های بُرداری بین حالت روز(روشن) و شب(تیره) قابل تغییر میباشد. رنگهای شب برای رانندگی در شب امن تر و راحت تر هستند.
\n\nمیتوانیداز طریق \'منو\'-&gt;\'پیکربندی صفحه نمایش\'-&gt;\'نقشه روز/شب\' زمان تفییر روز/شب را تنظیم کنید.

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="offline_edition">Modifications hors ligne</string>
<string name="offline_edition_descr">Toujours utiliser l\'édition hors ligne</string>
<string name="tip_recent_changes_0_7_1_t">"Changements en 0.7.1 :
@ -1333,7 +1333,7 @@
<string name="speak_title">Annonces vocales…</string>
<string name="speak_cameras">Annoncer les radars</string>
<string name="speak_traffic_warnings">Annonce les alertes de trafic</string>
<string name="osb_author_or_password_not_specified">Merci de spécifier votre nom d'utilisateur et mot de passe OSM dans les paramètres</string>
<string name="osb_author_or_password_not_specified">Merci de spécifier votre nom d\'utilisateur et mot de passe OSM dans les paramètres</string>
<string name="clear_intermediate_points">Effacer les points intermédiaires</string>
<string name="keep_intermediate_points">Garder les points intermédiaires</string>
<string name="local_index_tile_data_name">Données de tuile : %1$s</string>

View file

@ -580,9 +580,9 @@
<string name="rotate_map_to_bearing">Usmerjenost zemljevida</string>
<string name="tip_rotation_switching_t_v2">Z večkratnim klikom na sliki kompasa lahko določite, kako se obrača zemljevid na zaslonu.
\n\nMožnosti so:
\n\t\* 'Brez obračanja (sever je gor)\': Zemljevid ne bo obračan. Sever bo vedno proti sthu zaslona.
\n\t\* 'V smeri gibanja\': Zemljevid bo stalno usmerjen z smerjo premikanja.
\n\t\* 'Po kompasu\': Zemljevid bo stalno usmerjen po kompasu naprave torej poravnan z okolico.
\n\t\* \'Brez obračanja (sever je gor)\': Zemljevid ne bo obračan. Sever bo vedno proti sthu zaslona.
\n\t\* \'V smeri gibanja\': Zemljevid bo stalno usmerjen z smerjo premikanja.
\n\t\* \'Po kompasu\': Zemljevid bo stalno usmerjen po kompasu naprave torej poravnan z okolico.
</string>
<string name="tip_update_index_t">Posodabljanje zemljevidov je pomembno za uporabljanje map, interesnih točk, iskanje naslovov in navigacijo brez povezave. OsmAnd nudi upravitelja prenosov s katerim lahko prenesete take zemljevide (in druge podatkovne datoteke) in preverite razpoložljive podatke.
\n\nZa prenos podatkov pojdite na \'Nastavitve\' → \'Upravljnje podatkov\' → \'Podatki za delo brez povezave\'.
@ -735,10 +735,10 @@
<string name="tip_day_night_mode_t_v2">Izgled zemljevida se lahko za vektorske karte menja med dnevnim (svetlejšim) in nočnim (temnejšim) videzom. Nočne barve so varnejše za nočno vožnjo.
\n\nPreklop med dnevnim in nočnim načinom lahko nastavljate v \'Meni\' → \'Nastavitev zaslona …\' → \'zemljevid dan/noč\'.
\n\nMožnosti so:
\n\t\* 'Sončni vzhod/zahod\': avtomatski način glede na položaj sonca (privzeto)
\n\t\* 'Dnevni\': vedno se uporablja dnevni način
\n\t\* 'Nočni\': vedno se uporablja nočni način
\n\t\* 'Svetlobni senzor\': izgled zemljevida nadzoruje svetlobno tipalo naprave (če je na voljo)
\n\t\* \'Sončni vzhod/zahod\': avtomatski način glede na položaj sonca (privzeto)
\n\t\* \'Dnevni\': vedno se uporablja dnevni način
\n\t\* \'Nočni\': vedno se uporablja nočni način
\n\t\* \'Svetlobni senzor\': izgled zemljevida nadzoruje svetlobno tipalo naprave (če je na voljo)
</string>
<string name="download_files_not_enough_space">Ni dovolj razpoložljivega prostora za prejem %1$s MB(prosto: %2$s).</string>
<string name="download_files_question_space">Razpoložljiv prostor je sedaj {2}MB! Ali želite prejeti {0} datotek(o) ({1}MB)?</string>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="screen_is_locked">För att låsa upp skärmen tryck på låsikonen</string>
<string name="ChooseCountry">Välj land</string>
<string name="choose_city">Välj stad</string>
@ -374,9 +374,9 @@ Aktuella data på enheten (%1$s ledigt):</string>
<string name="tip_rotation_switching">Kartorientering</string>
<string name="tip_rotation_switching_t_v2">Du kan växla mellan om och hur kartbilden roteras genom att upprepade gånger klicka på kartskärmens kompassikon.
\n\nAlternativen är:
\n\t*\ 'Norr uppåt (vrid inte kartan)\'- Kartan roteras inte. Norr är alltid uppåt.
\n\t*\ 'I rörelseriktningen\' - Kartan kommer att anpassas kontinuerligt efter din kurs.
\n\t*\ 'Efter kompassen\' - Kartan kommer att anpassas kontinuerligt till enhetens kompass.
\n\t*\ \'Norr uppåt (vrid inte kartan)\'- Kartan roteras inte. Norr är alltid uppåt.
\n\t*\ \'I rörelseriktningen\' - Kartan kommer att anpassas kontinuerligt efter din kurs.
\n\t*\ \'Efter kompassen\' - Kartan kommer att anpassas kontinuerligt till enhetens kompass.
</string>
<string name="binary_map_download_success">Hämtades utan problem.
\n\t\n\tFör användning aktivera \'Meny\' -&gt; \'Definiera vy\' -&gt; \'Kartkälla …\' -&gt; \'Offline vektorkartor\'.

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="rendering_attr_roadColors_description">選擇道路的色彩調配:</string>
<string name="rendering_attr_roadColors_name">道路的色彩調配</string>
<string name="map_widget_show_destination_arrow">顯示目的地方向</string>

View file

@ -12,12 +12,14 @@
\n\nAll rights belong to OsmAnd app.
\n\nCopyright (C) 2010-2013 OsmAnd Authors :
\n\tVictor Shcherb - all parts of the project, originator
\n\tV.S. - all parts of the project, originator
\n\tAlexey Pelykh - rendering and core parts
\n\tHardy Mueller - main parts of the project, mostly rendering, UI interaction design
\n\nCredits to all major Contributors/Developers :
\n\tVictor Shcherb - project lead
\n\tV.S. - project lead
\n\tPavol Zibrita - first contributor and developer of some utilities
\n\tDusan Kazik - one of the first contributors
\n\tAndre Van Atten - project supporter, active forum participant, one of the first users.
\n\tDr. Hardy Mueller - map appearance concept and base renderers, international consistency and testing, usability, app scoping, concepts, documentation, wiki, market research.
\n\tYvecai - main contributor to Contour Lines and Hillshade maps

View file

@ -1,7 +1,11 @@
package net.osmand;
import java.util.Date;
import android.content.Context;
import android.content.res.Configuration;
import android.text.format.DateFormat;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@ -32,4 +36,11 @@ public class AndroidUtils {
});
}
public static String formatDate(Context ctx, long time) {
return DateFormat.getDateFormat(ctx).format(new Date(time));
}
public static String formatTime(Context ctx, long time) {
return DateFormat.getTimeFormat(ctx).format(new Date(time));
}
}

View file

@ -1,11 +1,9 @@
package net.osmand.plus;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.preference.PreferenceScreen;
import net.osmand.IProgress;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibilityPlugin;
@ -17,7 +15,6 @@ import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin;
import net.osmand.plus.extrasettings.OsmandExtraSettings;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.osmodroid.OsMoDroidPlugin;
@ -25,12 +22,11 @@ import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.OsmandMapTileView;
import org.apache.commons.logging.Log;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.preference.PreferenceScreen;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public abstract class OsmandPlugin {
@ -68,7 +64,7 @@ public abstract class OsmandPlugin {
OsmandRasterMapsPlugin rasterMapsPlugin = new OsmandRasterMapsPlugin(app);
installedPlugins.add(rasterMapsPlugin);
installedPlugins.add(new OsmandMonitoringPlugin(app));
installedPlugins.add(new OsmandExtraSettings(app));
// installedPlugins.add(new OsmandExtraSettings(app));
installedPlugins.add(new AccessibilityPlugin(app));
if(!installPlugin(SRTM_PLUGIN_COMPONENT_PAID, SRTMPlugin.ID, app,
new SRTMPlugin(app, true))) {

View file

@ -109,9 +109,9 @@ public class PoiFilter {
public String getSearchArea(){
double val = distanceToSearchValues[distanceInd];
if(val >= 1){
return " < " + ((int) val)+ " " + application.getString(R.string.km); //$NON-NLS-1$//$NON-NLS-2$
return " < " + OsmAndFormatter.getFormattedDistance(((int)val * 1000), application); //$NON-NLS-1$//$NON-NLS-2$
} else {
return " < 500 " + application.getString(R.string.m); //$NON-NLS-1$
return " < " + OsmAndFormatter.getFormattedDistance(500, application); //$NON-NLS-1$
}
}

View file

@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import net.osmand.AndroidUtils;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.R;
import net.osmand.util.Algorithms;
@ -26,6 +27,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -131,7 +133,7 @@ public class ContributionVersionActivity extends OsmandListActivity {
AccessibleToast.makeText(
this,
MessageFormat.format(getString(R.string.build_installed), currentSelectedBuild.tag,
Algorithms.formatDate(currentSelectedBuild.date.getTime())), Toast.LENGTH_LONG).show();
AndroidUtils.formatDate(getMyApplication(), currentSelectedBuild.date.getTime())), Toast.LENGTH_LONG).show();
}
getMyApplication().getSettings().CONTRIBUTION_INSTALL_APP_DATE.set(dateFormat.format(d));
}
@ -195,7 +197,7 @@ public class ContributionVersionActivity extends OsmandListActivity {
final OsmAndBuild item = (OsmAndBuild) getListAdapter().getItem(position);
Builder builder = new AlertDialog.Builder(this);
builder.setMessage(MessageFormat.format(getString(R.string.install_selected_build), item.tag,
Algorithms.formatDate(item.date.getTime()), item.size));
AndroidUtils.formatDate(getMyApplication(), item.date.getTime()), item.size));
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
@Override
@ -248,7 +250,7 @@ public class ContributionVersionActivity extends OsmandListActivity {
TextView description = (TextView) row.findViewById(R.id.download_descr);
StringBuilder format = new StringBuilder();
format.append(Algorithms.formatDate(build.date.getTime()))/*.append(" : ").append(build.size).append(" MB")*/;
format.append(AndroidUtils.formatDate(getMyApplication(), build.date.getTime()))/*.append(" : ").append(build.size).append(" MB")*/;
description.setText(format.toString());
int color = getResources().getColor(R.color.color_unknown);

View file

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.ClientContext;
@ -28,10 +29,10 @@ import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.download.IndexItemCategory;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.util.Algorithms;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
@ -456,24 +457,24 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
private Map<String, String> listAlreadyDownloadedWithAlternatives() {
Map<String, String> files = new TreeMap<String, String>();
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR),IndexConstants.BINARY_MAP_INDEX_EXT, files);
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.MAPS_PATH),IndexConstants.BINARY_MAP_INDEX_EXT, files);
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.MAPS_PATH),IndexConstants.EXTRA_EXT, files);
listWithAlternatives(getMyApplication(), getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR),IndexConstants.BINARY_MAP_INDEX_EXT, files);
listWithAlternatives(getMyApplication(), getMyApplication().getAppPath(IndexConstants.MAPS_PATH),IndexConstants.BINARY_MAP_INDEX_EXT, files);
listWithAlternatives(getMyApplication(), getMyApplication().getAppPath(IndexConstants.MAPS_PATH),IndexConstants.EXTRA_EXT, files);
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR),IndexConstants.BINARY_MAP_INDEX_EXT, files);
listWithAlternatives(getMyApplication(), getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR),IndexConstants.BINARY_MAP_INDEX_EXT, files);
}
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR),"", files);
listWithAlternatives(getMyApplication(), getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR),"", files);
return files;
}
public static Map<String, String> listWithAlternatives(File file, final String ext,
public static Map<String, String> listWithAlternatives(final Context ctx, File file, final String ext,
final Map<String, String> files) {
if (file.isDirectory()) {
file.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
if (filename.endsWith(ext)) {
String date = Algorithms.formatDate(new File(dir, filename).lastModified());
String date = AndroidUtils.formatDate(ctx, new File(dir, filename).lastModified());
files.put(filename, date);
return true;
} else {

View file

@ -77,8 +77,6 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
private ContextMenuAdapter optionsMenuAdapter;
private ActionMode actionMode;
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {

View file

@ -1142,6 +1142,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
}
if(!routingHelper.isRouteBeingCalculated() || routingHelper.isRouteCalculated()) {
optionsMenuHelper.item(routingHelper.isRouteCalculated() ? R.string.show_route: R.string.get_directions)
.icons(R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light)
.listen(new OnContextMenuClick() {
@ -1157,6 +1158,7 @@ public class MapActivityActions implements DialogProvider {
}
}
}).reg();
}
if (getTargets().getPointToNavigate() != null) {
optionsMenuHelper.item(R.string.target_points).icons(R.drawable.ic_action_flage_dark, R.drawable.ic_action_flage_light)
.listen(new OnContextMenuClick() {

View file

@ -15,6 +15,10 @@ public abstract class OsmandListActivity extends SherlockListActivity {
protected void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
setActionBarSettings();
}
protected void setActionBarSettings() {
getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View file

@ -44,7 +44,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
private Preference applicationDir;
private ListPreference applicationModePreference;
private ListPreference drivingRegionPreference;
private ListPreference metricsAndConstantsPreference;
@Override
@ -211,7 +210,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId());
applicationModePreference.setOnPreferenceChangeListener(this);
drivingRegionPreference = (ListPreference) screen.findPreference(settings.DRIVING_REGION.getId());
metricsAndConstantsPreference = (ListPreference) screen.findPreference(settings.METRIC_SYSTEM.getId());
}

View file

@ -44,6 +44,7 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<B
if (result == null || result.isEmpty()) {
Toast.makeText(SearchBuildingByNameActivity.this,
R.string.no_buildings_found, Toast.LENGTH_LONG).show();
quitActivity(SearchStreet2ByNameActivity.class);
}
}
@ -112,10 +113,10 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<B
text = hno;
}
settings.setLastSearchedBuilding(text, loc);
finish();
quitActivity(null);
}
@Override
public boolean filterObject(Building obj, String filter){
if(super.filterObject(obj, filter)){

View file

@ -22,7 +22,13 @@ import net.osmand.plus.activities.OsmandListActivity;
import org.apache.commons.logging.Log;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.AsyncTask.Status;
@ -72,13 +78,20 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
private StyleSpan previousSpan;
private static final Log log = PlatformUtil.getLog(SearchByNameAbstractActivity.class);
protected void setActionBarSettings() {
// getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.search_activity);
getSupportActionBar().setIcon(R.drawable.tab_search_address_icon);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = ((OsmandApplication) getApplication()).getSettings();
setContentView(R.layout.search_by_name);
getSupportActionBar().setTitle(R.string.search_activity);
getSupportActionBar().setIcon(R.drawable.tab_search_address_icon);
initializeTask = getInitializeTask();
uiHandler = new UIUpdateHandler();
@ -440,4 +453,30 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
return row;
}
}
protected void quitActivity(Class<? extends Activity> next) {
finish();
if(next != null) {
Intent intent = new Intent(this, next);
startActivity(intent);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == 1) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
createMenuItem(menu, 1, R.string.default_buttons_ok,
R.drawable.ic_action_ok_light, R.drawable.ic_action_ok_dark ,
MenuItem.SHOW_AS_ACTION_ALWAYS);
return super.onCreateOptionsMenu(menu);
}
}

View file

@ -16,6 +16,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.util.MapUtils;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Message;
import android.view.Gravity;
@ -169,7 +170,7 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
if (region.getCityById(obj.getId(), obj.getName(region.useEnglishNames())) == null) {
region.addCityToPreloadedList((City) obj);
}
finish();
quitActivity(SearchStreetByNameActivity.class);
}
private final class CityComparator implements Comparator<City> {
@ -219,4 +220,5 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
}
}
}

View file

@ -9,6 +9,7 @@ import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.resources.RegionAddressRepository;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
@ -52,7 +53,8 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity<Reg
@Override
public void itemSelected(RegionAddressRepository obj) {
((OsmandApplication) getApplication()).getSettings().setLastSearchedRegion(obj.getName(), obj.getEstimatedRegionCenter());
finish();
quitActivity(SearchCityByNameActivity.class);
}
}

View file

@ -64,6 +64,6 @@ public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<St
@Override
public void itemSelected(Street obj) {
settings.setLastSearchedIntersectedStreet(obj.getName(region.useEnglishNames()), obj.getLocation());
finish();
quitActivity(null);
}
}

View file

@ -216,7 +216,11 @@ public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Str
settings.setLastSearchedCity(obj.getCity().getId(), obj.getCity().getName(), obj.getLocation());
}
settings.setLastSearchedStreet(obj.getName(region.useEnglishNames()), obj.getLocation());
finish();
// if(obj.getBuildings().size() == 0){
// quitActivity(null);
// } else {
quitActivity(SearchBuildingByNameActivity.class);
// }
}
}

View file

@ -15,6 +15,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.osmand.AndroidUtils;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.Location;
@ -275,19 +276,19 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public String getDescription(Context ctx) {
String nm = name == null ? "" : name;
if (isPhoto()) {
return ctx.getString(R.string.recording_photo_description, nm, Algorithms.formatDateTime(file.lastModified())).trim();
return ctx.getString(R.string.recording_photo_description, nm, AndroidUtils.formatTime(ctx, file.lastModified())).trim();
}
updateInternalDescription();
return ctx.getString(R.string.recording_description, nm, getDuration(ctx), Algorithms.formatDateTime(file.lastModified()))
return ctx.getString(R.string.recording_description, nm, getDuration(ctx), AndroidUtils.formatTime(ctx, file.lastModified()))
.trim();
}
public String getSmallDescription(Context ctx) {
String nm = name == null ? "" : name;
if (isPhoto()) {
return ctx.getString(R.string.recording_photo_description, nm, Algorithms.formatDateTime(file.lastModified())).trim();
return ctx.getString(R.string.recording_photo_description, nm, AndroidUtils.formatTime(ctx,file.lastModified())).trim();
}
return ctx.getString(R.string.recording_description, nm, "", Algorithms.formatDateTime(file.lastModified())).trim();
return ctx.getString(R.string.recording_description, nm, "", AndroidUtils.formatTime(ctx, file.lastModified())).trim();
}
private String getDuration(Context ctx) {
@ -878,17 +879,17 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
stopRecording(mapActivity);
SHOW_RECORDINGS.set(true);
indexFile(f);
indexFile(true, f);
mapActivity.getMapView().refreshMap();
updateWidgetIcon(recordControl);
}
});
}
public void indexFile(File f) {
public boolean indexSingleFile(File f) {
boolean oldFileExist = recordingByFileName.containsKey(f.getName());
if (oldFileExist) {
return;
return false;
}
Recording r = new Recording(f);
String encodeName = f.getName();
@ -917,6 +918,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
recordings.registerObject(r.lat, r.lon, r);
recordingByFileName.put(f.getName(), r);
return true;
}
@Override
@ -942,10 +944,18 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
File[] files = avPath.listFiles();
if (files != null) {
for (File f : files) {
indexFile(registerNew, f);
}
}
}
return null;
}
private void indexFile(boolean registerInGPX, File f) {
if (f.getName().endsWith(THREEGP_EXTENSION) || f.getName().endsWith(MPEG4_EXTENSION)
|| f.getName().endsWith(IMG_EXTENSION)) {
indexFile(f);
if (registerNew) {
boolean newFileIndexed = indexSingleFile(f);
if (newFileIndexed && registerInGPX) {
Recording rec = recordingByFileName.get(f.getName());
if (rec != null && app.getSettings().SAVE_TRACK_TO_GPX.get()
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
@ -961,10 +971,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
}
}
}
return null;
}
public DataTileManager<Recording> getRecordings() {
return recordings;
@ -1007,7 +1013,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
@Override
public void onMapActivityExternalResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 205) {
if (requestCode == 205 || requestCode == 105) {
indexingFiles(null, true, true);
}
}
@ -1208,7 +1214,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
indexingFiles(null, true, true);
indexFile(true, pictureFile);
dlg.dismiss();
// play sound after photo - sound file must be loaded at this time:
if (AV_PHOTO_PLAY_SOUND.get()) {

View file

@ -89,12 +89,12 @@ public class DownloadIndexesThread {
public void updateLoadedFiles() {
Map<String, String> indexActivatedFileNames = app.getResourceManager().getIndexFileNames();
DownloadIndexActivity.listWithAlternatives(app.getAppPath(""),
DownloadIndexActivity.listWithAlternatives(app, app.getAppPath(""),
IndexConstants.EXTRA_EXT, indexActivatedFileNames);
Map<String, String> indexFileNames = app.getResourceManager().getIndexFileNames();
DownloadIndexActivity.listWithAlternatives(app.getAppPath(""),
DownloadIndexActivity.listWithAlternatives(app, app.getAppPath(""),
IndexConstants.EXTRA_EXT, indexFileNames);
DownloadIndexActivity.listWithAlternatives(app.getAppPath(IndexConstants.TILES_INDEX_DIR),
DownloadIndexActivity.listWithAlternatives(app,app.getAppPath(IndexConstants.TILES_INDEX_DIR),
IndexConstants.SQLITE_EXT, indexFileNames);
app.getResourceManager().getBackupIndexes(indexFileNames);
this.indexFileNames = indexFileNames;

View file

@ -6,19 +6,18 @@ import java.io.InputStream;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.plus.ClientContext;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.Version;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser;
@ -30,6 +29,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
import android.text.format.DateFormat;
public class DownloadOsmandIndexesHelper {
private final static Log log = PlatformUtil.getLog(DownloadOsmandIndexesHelper.class);
@ -40,7 +40,7 @@ public class DownloadOsmandIndexesHelper {
PackageManager pm =ctx.getPackageManager();
AssetManager amanager = ctx.getAssets();
String versionUrlParam = Version.getVersionAsURLParam(((OsmandApplication) ctx.getApplicationContext()));
IndexFileList result = downloadIndexesListFromInternet(versionUrlParam);
IndexFileList result = downloadIndexesListFromInternet(ctx, versionUrlParam);
if (result == null) {
result = new IndexFileList();
} else {
@ -81,7 +81,7 @@ public class DownloadOsmandIndexesHelper {
try {
ApplicationInfo appInfo = pm.getApplicationInfo(OsmandApplication.class.getPackage().getName(), 0);
dateModified = new File(appInfo.sourceDir).lastModified();
date = Algorithms.formatDate(dateModified);
date = AndroidUtils.formatDate((Context) settings.getContext(), dateModified);
} catch (NameNotFoundException e) {
//do nothing...
}
@ -98,7 +98,7 @@ public class DownloadOsmandIndexesHelper {
if (item != null) {
File destFile = new File(voicePath, voice + File.separatorChar + "_config.p");
try {
Date d = Algorithms.getDateFormat().parse(item.getDate());
Date d = DateFormat.getDateFormat((Context) settings.getContext()).parse(item.getDate());
if (d.getTime() > dateModified) {
continue;
}
@ -130,7 +130,7 @@ public class DownloadOsmandIndexesHelper {
return null;
}
private static IndexFileList downloadIndexesListFromInternet(String versionAsUrl){
private static IndexFileList downloadIndexesListFromInternet(Context ctx, String versionAsUrl){
try {
IndexFileList result = new IndexFileList();
log.debug("Start loading list of index files"); //$NON-NLS-1$
@ -150,7 +150,7 @@ public class DownloadOsmandIndexesHelper {
String date = parser.getAttributeValue(null, "date"); //$NON-NLS-1$
String description = parser.getAttributeValue(null, "description"); //$NON-NLS-1$
String parts = parser.getAttributeValue(null, "parts"); //$NON-NLS-1$
date = reparseDate(date);
date = reparseDate(ctx, date);
IndexItem it = new IndexItem(name, description, date, size, parts);
it.setType(tp);
result.add(it);
@ -180,10 +180,10 @@ public class DownloadOsmandIndexesHelper {
}
}
private static String reparseDate(String date) {
private static String reparseDate(Context ctx, String date) {
try {
Date d = simpleDateFormat.parse(date);
return Algorithms.formatDate(d.getTime());
return AndroidUtils.formatDate(ctx, d.getTime());
} catch (ParseException e) {
return date;
}

View file

@ -10,6 +10,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.plus.ClientContext;
@ -19,6 +20,9 @@ import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import android.content.Context;
import android.text.format.DateFormat;
public class IndexItem implements Comparable<IndexItem> {
private static final Log log = PlatformUtil.getLog(IndexItem.class);
@ -193,7 +197,7 @@ public class IndexItem implements Comparable<IndexItem> {
entry.zipStream = zipStream;
entry.unzipFolder = unzipDir;
try {
Date d = Algorithms.getDateFormat().parse(date);
Date d = DateFormat.getDateFormat((Context) ctx).parse(date);
entry.dateModified = d.getTime();
} catch (ParseException e1) {
log.error("ParseException", e1);

View file

@ -5,6 +5,7 @@ import java.util.Arrays;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -43,91 +44,13 @@ public class OsmandExtraSettings extends OsmandPlugin {
public String getName() {
return app.getString(R.string.extra_settings);
}
@Override
public void registerLayers(final MapActivity activity) {
registerControls = true;
final OsmandMapTileView view = activity.getMapView();
final MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
final MapWidgetRegistry mapInfoControls = mapInfoLayer.getMapInfoControls();
final OsmandPreference<Float> textSizePref = view.getSettings().MAP_TEXT_SIZE;
final MapWidgetRegInfo textSize = mapInfoControls.registerAppearanceWidget(R.drawable.widget_text_size, R.string.map_text_size,
"text_size", textSizePref);
textSize.setStateChangeListener(new Runnable() {
@Override
public void run() {
final Float[] floatValues = new Float[] {0.6f, 0.8f, 1.0f, 1.2f, 1.5f, 1.75f, 2f};
String[] entries = new String[floatValues.length];
for (int i = 0; i < floatValues.length; i++) {
entries[i] = (int) (floatValues[i] * 100) +" %";
}
Builder b = new AlertDialog.Builder(view.getContext());
b.setTitle(R.string.map_text_size);
int i = Arrays.binarySearch(floatValues, textSizePref.get());
b.setSingleChoiceItems(entries, i, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
textSizePref.set(floatValues[which]);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
dialog.dismiss();
}
});
b.show();
}
});
final MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,
"showRuler", view.getSettings().SHOW_RULER);
showRuler.setStateChangeListener(new Runnable() {
@Override
public void run() {
view.getSettings().SHOW_RULER.set(!view.getSettings().SHOW_RULER.get());
view.refreshMap();
}
});
final MapWidgetRegInfo showDestinationArrow = mapInfoControls.registerAppearanceWidget(R.drawable.widget_show_destination_arrow, R.string.map_widget_show_destination_arrow,
"show_destination_arrow", view.getSettings().SHOW_DESTINATION_ARROW);
showDestinationArrow.setStateChangeListener(new Runnable() {
@Override
public void run() {
view.getSettings().SHOW_DESTINATION_ARROW.set(!view.getSettings().SHOW_DESTINATION_ARROW.get());
mapInfoLayer.recreateControls();
}
});
final MapWidgetRegInfo transparent = mapInfoControls.registerAppearanceWidget(R.drawable.widget_transparent_skin, R.string.map_widget_transparent,
"transparent", view.getSettings().TRANSPARENT_MAP_THEME);
transparent.setStateChangeListener(new Runnable() {
@Override
public void run() {
view.getSettings().TRANSPARENT_MAP_THEME.set(!view.getSettings().TRANSPARENT_MAP_THEME.get());
mapInfoLayer.recreateControls();
}
});
// final MapInfoControlRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map,
// "position_on_map", textSizePref);
// posMap.setStateChangeListener(new Runnable() {
// @Override
// public void run() {
// String[] entries = new String[] { activity.getString(R.string.position_on_map_center), activity.getString(R.string.position_on_map_bottom) };
// final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT };
// Builder b = new AlertDialog.Builder(view.getContext());
// int i = Arrays.binarySearch(vals, posPref.get());
// b.setSingleChoiceItems(entries, i, new OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// posPref.set(vals[which]);
// activity.updateApplicationModeSettings();
// view.refreshMap(true);
// dialog.dismiss();
// }
// });
// b.show();
// }
// });
}
@Override

View file

@ -18,12 +18,17 @@ public class NativeOsmandLibrary extends NativeLibrary {
private static NativeOsmandLibrary library;
private static Boolean isNativeSupported = null;
public NativeOsmandLibrary(boolean newLibrary) {
super(newLibrary);
}
public static NativeOsmandLibrary getLoadedLibrary(){
synchronized (NativeOsmandLibrary.class) {
return library;
}
}
public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage, ClientContext ctx) {
if (!isLoaded()) {
synchronized (NativeOsmandLibrary.class) {
@ -43,7 +48,7 @@ public class NativeOsmandLibrary extends NativeLibrary {
try {
loadNewCore(libCpuSuffix);
log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$
library = new NativeOsmandLibrary();
library = new NativeOsmandLibrary(true);
isNativeSupported = true;
} catch(Throwable e) {
log.error("Failed to load new native library", e); //$NON-NLS-1$
@ -51,7 +56,7 @@ public class NativeOsmandLibrary extends NativeLibrary {
if(!isNativeSupported) {
loadOldCore(libCpuSuffix);
log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$
library = new NativeOsmandLibrary();
library = new NativeOsmandLibrary(false);
log.debug("Initializing rendering rules storage..."); //$NON-NLS-1$
NativeOsmandLibrary.initRenderingRulesStorage(storage);
isNativeSupported = true;
@ -70,13 +75,13 @@ public class NativeOsmandLibrary extends NativeLibrary {
}
private static void loadNewCore(final String libCpuSuffix) {
System.loadLibrary("Qt5Core" + libCpuSuffix);
System.loadLibrary("Qt5Network" + libCpuSuffix);
System.loadLibrary("Qt5Concurrent" + libCpuSuffix);
System.loadLibrary("Qt5Sql" + libCpuSuffix);
System.loadLibrary("Qt5Xml" + libCpuSuffix);
System.loadLibrary("OsmAndCore" + libCpuSuffix);
System.loadLibrary("OsmAndCoreUtils" + libCpuSuffix);
// System.loadLibrary("Qt5Core" + libCpuSuffix);
// System.loadLibrary("Qt5Network" + libCpuSuffix);
// System.loadLibrary("Qt5Concurrent" + libCpuSuffix);
// System.loadLibrary("Qt5Sql" + libCpuSuffix);
// System.loadLibrary("Qt5Xml" + libCpuSuffix);
// System.loadLibrary("OsmAndCore" + libCpuSuffix);
// System.loadLibrary("OsmAndCoreUtils" + libCpuSuffix);
System.loadLibrary("OsmAndJNI" + libCpuSuffix);
}

View file

@ -315,14 +315,8 @@ public class OsmandRenderer {
// check bit b if it is set
if (((ind >> b) & 1) == 0) {
alreadyDrawnIcons[i] = ind | (1 << b);
if(rc.getDensityValue(1) != 1) {
float left = icon.x - rc.getDensityValue(ico.getWidth() / 2);
float top = icon.y - rc.getDensityValue(ico.getHeight() / 2);
cv.drawBitmap(ico, null, new RectF(left, top, left + rc.getDensityValue(ico.getWidth()), top
+ rc.getDensityValue(ico.getHeight())), paintIcon);
} else {
cv.drawBitmap(ico, icon.x - ico.getWidth() / 2, icon.y - ico.getHeight() / 2, paintIcon);
}
cv.drawBitmap(ico, icon.x - ico.getWidth() / 2,
icon.y - ico.getHeight() / 2, paintIcon);
}
}
}

View file

@ -38,8 +38,7 @@ public class RendererRegistry {
internalRenderers.put("Touring-view_(more-contrast-and-details)", "Touring-view_(more-contrast-and-details)" +".render.xml");
internalRenderers.put("High-contrast-roads", "High-contrast-roads" + ".render.xml");
internalRenderers.put("Winter-and-ski", "Winter-and-ski" + ".render.xml");
// internalRenderers.put("High-detail-topo", "High-detail-topo" + ".render.xml");
internalRenderers.put("High-detail-topo", "High-detail-topo-v2" + ".render.xml");
internalRenderers.put("Topo-map-assimilation", "Topo-map-assimilation" + ".render.xml");
}
public RenderingRulesStorage defaultRender() {

View file

@ -242,20 +242,13 @@ public class TextRenderer {
if (text.shieldRes != null) {
Bitmap ico = RenderingIcons.getIcon(context, text.shieldRes);
if (ico != null) {
if (rc.getDensityValue(1) != 1) {
float left = text.centerX - rc.getDensityValue(ico.getWidth() / 2) - 0.5f;
float top = text.centerY - rc.getDensityValue(ico.getHeight() / 2) - rc.getDensityValue(4.5f);
Rect rec = new Rect(0, 0, ico.getWidth(), ico.getHeight());
cv.drawBitmap(ico, rec,
new RectF(left, top, left + rc.getDensityValue(ico.getWidth()), top
+ rc.getDensityValue(ico.getHeight())), paintIcon);
} else {
float left = text.centerX - ico.getWidth() / 2 - 0.5f;
float top = text.centerY - ico.getHeight() / 2 - rc.getDensityValue(4.5f);
float left = text.centerX - ico.getWidth() / 2
- 0.5f;
float top = text.centerY - ico.getHeight() / 2
- rc.getDensityValue(4.5f);
cv.drawBitmap(ico, left, top, paintIcon);
}
}
}
drawWrappedText(cv, text, textSize);
}

View file

@ -18,6 +18,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import net.osmand.AndroidUtils;
import net.osmand.GeoidAltitudeCorrection;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
@ -427,7 +428,7 @@ public class ResourceManager {
conf = new File(f, "_ttsconfig.p");
}
if (conf.exists()) {
indexFileNames.put(f.getName(), Algorithms.formatDate(conf.lastModified())); //$NON-NLS-1$
indexFileNames.put(f.getName(), AndroidUtils.formatDate(context, conf.lastModified())); //$NON-NLS-1$
}
}
}
@ -619,7 +620,7 @@ public class ResourceManager {
if (dateCreated == 0) {
dateCreated = f.lastModified();
}
indexFileNames.put(f.getName(), Algorithms.formatDate(dateCreated)); //$NON-NLS-1$
indexFileNames.put(f.getName(), AndroidUtils.formatDate(context, dateCreated)); //$NON-NLS-1$
for (String rName : index.getRegionNames()) {
// skip duplicate names (don't make collision between getName() and name in the map)
// it can be dangerous to use one file to different indexes if it is multithreaded
@ -907,7 +908,7 @@ public class ResourceManager {
if (lf != null) {
for (File f : lf) {
if (f != null && f.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
map.put(f.getName(), Algorithms.formatDate(f.lastModified())); //$NON-NLS-1$
map.put(f.getName(), AndroidUtils.formatDate(context, f.lastModified())); //$NON-NLS-1$
}
}
}

View file

@ -246,8 +246,13 @@ public class RouteCalculationResult {
if(turn != null) {
RouteDirectionInfo info = new RouteDirectionInfo(s.getSegmentSpeed(), turn);
if(routeInd + 1< list.size()) {
RouteSegmentResult next = list.get(routeInd);
if (routeInd < list.size()) {
int lind = routeInd;
if(turn.isRoundAbout() && routeInd + 1 < list.size()) {
// take next name for roundabout (not roundabout name)
lind = routeInd + 1;
}
RouteSegmentResult next = list.get(lind);
info.setRef(next.getObject().getRef());
info.setStreetName(next.getObject().getName());
info.setDestinationName(next.getObject().getDestinationName());

View file

@ -27,17 +27,12 @@ import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.DataTileManager;
import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ClientContext;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.*;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.Route;
import net.osmand.plus.GPXUtilities.Track;
import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
import net.osmand.router.RoutePlannerFrontEnd;
@ -673,7 +668,7 @@ public class RouteProvider {
return new RouteCalculationResult(res, null, params.start, params.end, null, null, null, params.ctx, params.leftSide, true);
}
public GPXFile createOsmandRouterGPX(RouteCalculationResult srcRoute){
public GPXFile createOsmandRouterGPX(RouteCalculationResult srcRoute, TargetPointsHelper helper, ClientContext ctx){
int currentRoute = srcRoute.currentRoute;
List<Location> routeNodes = srcRoute.getImmutableLocations();
List<RouteDirectionInfo> directionInfo = srcRoute.getDirections();
@ -728,6 +723,20 @@ public class RouteProvider {
route.points.add(pt);
}
}
List<LatLon> ps = helper.getIntermediatePointsWithTarget();
List<String> psNames = helper.getIntermediatePointNamesWithTarget();
for(int k = 0; k < ps.size(); k++) {
WptPt pt = new WptPt();
pt.lat = ps.get(k).getLatitude();
pt.lon = ps.get(k).getLongitude();
if(k < psNames.size()) {
pt.name = psNames.get(k) +"";
pt.name = k == ps.size() - 1? ctx.getString(R.string.destination_point, pt.name ) :
ctx.getString(R.string.target_point, pt.name );
pt.desc = pt.name;
}
}
return gpx;
}

View file

@ -632,7 +632,7 @@ public class RoutingHelper {
} else if(name != null && name.length() > 0){
if(ref != null && ref.length() > 0) {
name = ref + " " + name;
}
} getCurrentSegmentResult
return name;
} else {
if(ref == null) {
@ -650,7 +650,7 @@ public class RoutingHelper {
String dn = n.directionInfo.getDestinationName();
return formatStreetName(nm, rf, dn);
}
RouteSegmentResult rs = route.getCurrentSegmentResult();
RouteSegmentResult rs = getCurrentSegmentResult();
if(rs != null) {
String nm = rs.getObject().getName();
String rf = rs.getObject().getRef();
@ -660,6 +660,10 @@ public class RoutingHelper {
return null;
}
public RouteSegmentResult getCurrentSegmentResult() {
return route.getCurrentSegmentResult();
}
public synchronized NextDirectionInfo getNextRouteDirectionInfoAfter(NextDirectionInfo previous, NextDirectionInfo to, boolean toSpeak){
NextDirectionInfo i = route.getNextRouteDirectionInfoAfter(previous, to, toSpeak);
if(i != null) {

View file

@ -9,6 +9,7 @@ import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.voice.AbstractPrologCommandPlayer;
import net.osmand.plus.voice.CommandBuilder;
import net.osmand.plus.voice.CommandPlayer;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.TurnType;
import net.osmand.util.Algorithms;
@ -271,6 +272,7 @@ public class VoiceRouter {
NextDirectionInfo nextInfo = router.getNextRouteDirectionInfo(new NextDirectionInfo(), true);
RouteSegmentResult currentSegment = router.getCurrentSegmentResult();
// after last turn say:
if (nextInfo == null || nextInfo.directionInfo == null || nextInfo.directionInfo.distance == 0) {
// if(currentStatus <= STATUS_UNKNOWN && currentDirection > 0){ This caused this prompt to be suppressed when coming back from a
@ -426,8 +428,7 @@ public class VoiceRouter {
}
// replace characters which may produce unwanted tts sounds:
if(res != null) {
res = res.replace('-', ' ');
res = res.replace(':', ' ');
res = getSpeakablePointName(res);
}
return res;
}
@ -437,6 +438,7 @@ public class VoiceRouter {
if(pn != null) {
pn = pn.replace('-', ' ');
pn = pn.replace(':', ' ');
pn = pn.replace("\u00df", "ss"); // helps non-German tts voices to pronounce German Strasse (=street)
}
return pn;
}

View file

@ -1,52 +1,11 @@
package net.osmand.plus.views;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.extrasettings.OsmandExtraSettings;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.mapwidgets.BaseMapWidget;
import net.osmand.plus.views.mapwidgets.ImageViewWidget;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget;
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.StackWidgetView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.plus.views.mapwidgets.UpdateableWidget;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.*;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.Gravity;
@ -54,20 +13,27 @@ import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.*;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.mapwidgets.*;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
import net.osmand.util.Algorithms;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.Set;
public class MapInfoLayer extends OsmandMapLayer {
@ -100,7 +66,7 @@ public class MapInfoLayer extends OsmandMapLayer {
private MonitoringInfoControl monitoringServices;
private String ADDITIONAL_VECTOR_RENDERING_CATEGORY;
@ -117,7 +83,6 @@ public class MapInfoLayer extends OsmandMapLayer {
scaleCoefficient *= 1.5f;
}
ADDITIONAL_VECTOR_RENDERING_CATEGORY = map.getString(R.string.map_widget_vector_attributes);
paintText = new Paint();
paintText.setStyle(Style.FILL_AND_STROKE);
paintText.setColor(Color.BLACK);
@ -250,150 +215,10 @@ public class MapInfoLayer extends OsmandMapLayer {
"street_name", MapWidgetRegistry.MAIN_CONTROL, all, 100);
// Register appearance widgets
registerAppearanceWidgets();
AppearanceWidgetsFactory.INSTANCE.registerAppearanceWidgets(map, this, mapInfoControls);
}
private void registerAppearanceWidgets() {
final MapWidgetRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(R.drawable.widget_rendering_style, R.string.map_widget_renderer,
"renderer", view.getSettings().RENDERER);
final OsmandApplication app = view.getApplication();
vectorRenderer.setStateChangeListener(new Runnable() {
@Override
public void run() {
Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.renderers);
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
int i = -1;
for(int j = 0; j< items.length; j++) {
if(items[j].equals(app.getRendererRegistry().getCurrentSelectedRenderer().getName())) {
i = j;
break;
}
}
bld.setSingleChoiceItems(items, i, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String renderer = items[which];
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
if (loaded != null) {
view.getSettings().RENDERER.set(renderer);
app.getRendererRegistry().setCurrentSelectedRender(loaded);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
} else {
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
}
createCustomRenderingProperties(loaded);
dialog.dismiss();
}
});
bld.show();
}
});
final MapWidgetRegInfo dayNight = mapInfoControls.registerAppearanceWidget(R.drawable.widget_day_night_mode, R.string.map_widget_day_night,
"dayNight", view.getSettings().DAYNIGHT_MODE);
dayNight.setStateChangeListener(new Runnable() {
@Override
public void run() {
Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.daynight);
final String[] items = new String[OsmandSettings.DayNightMode.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(map.getMyApplication());
}
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
bld.setSingleChoiceItems(items, i, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
dialog.dismiss();
}
});
bld.show();
}
});
final MapWidgetRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(R.drawable.widget_viewing_direction, R.string.map_widget_view_direction,
"viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
displayViewDirections.setStateChangeListener(new Runnable() {
@Override
public void run() {
view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
map.getMapViewTrackingUtilities().updateSettings();
}
});
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
if(renderer != null) {
createCustomRenderingProperties(renderer);
}
}
private void createCustomRenderingProperties(RenderingRulesStorage renderer) {
String categoryName = ADDITIONAL_VECTOR_RENDERING_CATEGORY;
mapInfoControls.removeApperanceWidgets(categoryName);
final OsmandApplication app = view.getApplication();
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
for (final RenderingRuleProperty p : customRules) {
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(), p.getName());
//test old descr as title
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(), p.getAttrName(), p.getName());
if(p.isBoolean()) {
final CommonPreference<Boolean> pref = view.getApplication().getSettings().getCustomRenderBooleanProperty(p.getAttrName());
int icon = 0;
try {
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
icon = f.getInt(null);
} catch(Exception e){
}
MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
w.setStateChangeListener(new Runnable() {
@Override
public void run() {
pref.set(!pref.get());
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
}
});
} else {
final CommonPreference<String> pref = view.getApplication().getSettings().getCustomRenderProperty(p.getAttrName());
int icon = 0;
try {
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
icon = f.getInt(null);
} catch(Exception e){
}
MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
w.setStateChangeListener(new Runnable() {
@Override
public void run() {
Builder b = new AlertDialog.Builder(view.getContext());
//test old descr as title
b.setTitle(propertyDescr);
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
b.setSingleChoiceItems(p.getPossibleValues(), i, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
pref.set(p.getPossibleValues()[which]);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
dialog.dismiss();
}
});
b.show();
}
});
}
}
}
public void recreateControls(){
rightStack.clearAllViews();
@ -482,9 +307,6 @@ public class MapInfoLayer extends OsmandMapLayer {
s.add(ms.getCategory());
}
}
if(OsmandPlugin.getEnabledPlugin(OsmandExtraSettings.class) == null){
s.remove(ADDITIONAL_VECTOR_RENDERING_CATEGORY);
}
return s;
}

View file

@ -0,0 +1,261 @@
package net.osmand.plus.views.mapwidgets;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.Toast;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class AppearanceWidgetsFactory {
public static AppearanceWidgetsFactory INSTANCE = new AppearanceWidgetsFactory();
private String ADDITIONAL_VECTOR_RENDERING_CATEGORY;
public static boolean EXTRA_SETTINGS = true;
public void registerAppearanceWidgets(final MapActivity map, final MapInfoLayer mapInfoLayer,
final MapWidgetRegistry mapInfoControls) {
final OsmandMapTileView view = map.getMapView();
final MapWidgetRegistry.MapWidgetRegInfo vectorRenderer = mapInfoControls.registerAppearanceWidget(R.drawable.widget_rendering_style, R.string.map_widget_renderer,
"renderer", view.getSettings().RENDERER);
final OsmandApplication app = view.getApplication();
vectorRenderer.setStateChangeListener(new Runnable() {
@Override
public void run() {
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.renderers);
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
int i = -1;
for(int j = 0; j< items.length; j++) {
if(items[j].equals(app.getRendererRegistry().getCurrentSelectedRenderer().getName())) {
i = j;
break;
}
}
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String renderer = items[which];
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
if (loaded != null) {
view.getSettings().RENDERER.set(renderer);
app.getRendererRegistry().setCurrentSelectedRender(loaded);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
} else {
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
}
if(EXTRA_SETTINGS) {
createCustomRenderingProperties(loaded, map, mapInfoLayer, mapInfoControls);
}
dialog.dismiss();
}
});
bld.show();
}
});
final MapWidgetRegistry.MapWidgetRegInfo dayNight = mapInfoControls.registerAppearanceWidget(R.drawable.widget_day_night_mode, R.string.map_widget_day_night,
"dayNight", view.getSettings().DAYNIGHT_MODE);
dayNight.setStateChangeListener(new Runnable() {
@Override
public void run() {
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.daynight);
final String[] items = new String[OsmandSettings.DayNightMode.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(map.getMyApplication());
}
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
dialog.dismiss();
}
});
bld.show();
}
});
final MapWidgetRegistry.MapWidgetRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(R.drawable.widget_viewing_direction, R.string.map_widget_view_direction,
"viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
displayViewDirections.setStateChangeListener(new Runnable() {
@Override
public void run() {
view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
map.getMapViewTrackingUtilities().updateSettings();
}
});
if (EXTRA_SETTINGS) {
// previous extra settings
final OsmandSettings.OsmandPreference<Float> textSizePref = view.getSettings().MAP_TEXT_SIZE;
final MapWidgetRegistry.MapWidgetRegInfo textSize = mapInfoControls.registerAppearanceWidget(R.drawable.widget_text_size, R.string.map_text_size,
"text_size", textSizePref);
textSize.setStateChangeListener(new Runnable() {
@Override
public void run() {
final Float[] floatValues = new Float[] {0.6f, 0.8f, 1.0f, 1.2f, 1.5f, 1.75f, 2f};
String[] entries = new String[floatValues.length];
for (int i = 0; i < floatValues.length; i++) {
entries[i] = (int) (floatValues[i] * 100) +" %";
}
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
b.setTitle(R.string.map_text_size);
int i = Arrays.binarySearch(floatValues, textSizePref.get());
b.setSingleChoiceItems(entries, i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
textSizePref.set(floatValues[which]);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
dialog.dismiss();
}
});
b.show();
}
});
final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,
"showRuler", view.getSettings().SHOW_RULER);
showRuler.setStateChangeListener(new Runnable() {
@Override
public void run() {
view.getSettings().SHOW_RULER.set(!view.getSettings().SHOW_RULER.get());
view.refreshMap();
}
});
final MapWidgetRegistry.MapWidgetRegInfo showDestinationArrow = mapInfoControls.registerAppearanceWidget(R.drawable.widget_show_destination_arrow, R.string.map_widget_show_destination_arrow,
"show_destination_arrow", view.getSettings().SHOW_DESTINATION_ARROW);
showDestinationArrow.setStateChangeListener(new Runnable() {
@Override
public void run() {
view.getSettings().SHOW_DESTINATION_ARROW.set(!view.getSettings().SHOW_DESTINATION_ARROW.get());
mapInfoLayer.recreateControls();
}
});
final MapWidgetRegistry.MapWidgetRegInfo transparent = mapInfoControls.registerAppearanceWidget(R.drawable.widget_transparent_skin, R.string.map_widget_transparent,
"transparent", view.getSettings().TRANSPARENT_MAP_THEME);
transparent.setStateChangeListener(new Runnable() {
@Override
public void run() {
view.getSettings().TRANSPARENT_MAP_THEME.set(!view.getSettings().TRANSPARENT_MAP_THEME.get());
mapInfoLayer.recreateControls();
}
});
// final OsmandSettings.OsmandPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP;
// final MapWidgetRegistry.MapWidgetRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map,
// "position_on_map", textSizePref);
// posMap.setStateChangeListener(new Runnable() {
// @Override
// public void run() {
// String[] entries = new String[] {map.getString(R.string.position_on_map_center), map.getString(R.string.position_on_map_bottom) };
// final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT };
// AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
// int i = Arrays.binarySearch(vals, posPref.get());
// b.setSingleChoiceItems(entries, i, new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// posPref.set(vals[which]);
// map.updateApplicationModeSettings();
// view.refreshMap(true);
// dialog.dismiss();
// }
// });
// b.show();
// }
// });
}
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
if(renderer != null && EXTRA_SETTINGS) {
createCustomRenderingProperties(renderer, map, mapInfoLayer, mapInfoControls);
}
}
private void createCustomRenderingProperties(RenderingRulesStorage renderer, final MapActivity map,
final MapInfoLayer mapInfoLayer, final MapWidgetRegistry mapInfoControls) {
final OsmandMapTileView view = map.getMapView();
if(ADDITIONAL_VECTOR_RENDERING_CATEGORY == null) {
ADDITIONAL_VECTOR_RENDERING_CATEGORY = map.getString(R.string.map_widget_vector_attributes);
}
String categoryName = ADDITIONAL_VECTOR_RENDERING_CATEGORY;
mapInfoControls.removeApperanceWidgets(categoryName);
final OsmandApplication app = view.getApplication();
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
for (final RenderingRuleProperty p : customRules) {
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(), p.getName());
//test old descr as title
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(), p.getAttrName(), p.getName());
if(p.isBoolean()) {
final OsmandSettings.CommonPreference<Boolean> pref = view.getApplication().getSettings().getCustomRenderBooleanProperty(p.getAttrName());
int icon = 0;
try {
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
icon = f.getInt(null);
} catch(Exception e){
}
MapWidgetRegistry.MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
w.setStateChangeListener(new Runnable() {
@Override
public void run() {
pref.set(!pref.get());
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
}
});
} else {
final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings().getCustomRenderProperty(p.getAttrName());
int icon = 0;
try {
Field f = R.drawable.class.getField("widget_" + p.getAttrName().toLowerCase());
icon = f.getInt(null);
} catch(Exception e){
}
MapWidgetRegistry.MapWidgetRegInfo w = mapInfoControls.registerAppearanceWidget(icon, propertyName, "rend_"+p.getAttrName(), pref, categoryName);
w.setStateChangeListener(new Runnable() {
@Override
public void run() {
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
//test old descr as title
b.setTitle(propertyDescr);
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
b.setSingleChoiceItems(p.getPossibleValues(), i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
pref.set(p.getPossibleValues()[which]);
app.getResourceManager().getRenderer().clearCache();
view.refreshMap(true);
dialog.dismiss();
}
});
b.show();
}
});
}
}
}
}

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager" forced_jdk="true">
<conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/gen" expected_position="1" />
<src_folder value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" expected_position="2" />
<src_folder value="com.android.ide.eclipse.adt.LIBRARIES" expected_position="3" />
</src_description>
</component>
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="LIBRARY_PROJECT" value="true" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Android 4.1.2 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="com.android.ide.eclipse.adt.DEPENDENCIES" level="application" />
</component>
</module>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager" forced_jdk="true">
<conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/gen" expected_position="1" />
<src_folder value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" expected_position="2" />
<src_folder value="com.android.ide.eclipse.adt.LIBRARIES" expected_position="3" />
</src_description>
</component>
<component name="FacetManager">
<facet type="android" name="Android">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Android 4.1.2 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="com.android.ide.eclipse.adt.DEPENDENCIES" level="application" />
</component>
</module>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager" forced_jdk="true">
<conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/gen" expected_position="1" />
<src_folder value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" expected_position="2" />
<src_folder value="com.android.ide.eclipse.adt.LIBRARIES" expected_position="3" />
</src_description>
</component>
<component name="FacetManager">
<facet type="android" name="Android">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Android 4.1.2 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="com.android.ide.eclipse.adt.DEPENDENCIES" level="application" />
</component>
</module>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager" forced_jdk="true">
<conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/gen" expected_position="1" />
<src_folder value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" expected_position="2" />
<src_folder value="com.android.ide.eclipse.adt.LIBRARIES" expected_position="3" />
</src_description>
</component>
<component name="FacetManager">
<facet type="android" name="Android">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Android 4.1.2 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="com.android.ide.eclipse.adt.DEPENDENCIES" level="application" />
</component>
</module>