diff --git a/.gitignore b/.gitignore index 42a3c52c3d..21388f996e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ mm_*.png mx_*.png *.class .settings +.idea diff --git a/CREDITS.md b/CREDITS.md index a7f8217e0c..5667c609ca 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -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 diff --git a/OsmAnd-java/.gitignore b/OsmAnd-java/.gitignore index 7c771eb8cc..5be8d80c05 100644 --- a/OsmAnd-java/.gitignore +++ b/OsmAnd-java/.gitignore @@ -1,4 +1,5 @@ bin c-src OsmAnd-core.jar +OsmAnd-core-android.jar src/net/osmand/core/jni/* diff --git a/OsmAnd-java/CMakeLists.txt b/OsmAnd-java/CMakeLists.txt index 7369c2bca7..256784ad70 100644 --- a/OsmAnd-java/CMakeLists.txt +++ b/OsmAnd-java/CMakeLists.txt @@ -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 diff --git a/OsmAnd-java/OsmAnd-java.iml b/OsmAnd-java/OsmAnd-java.iml new file mode 100644 index 0000000000..d1b986860d --- /dev/null +++ b/OsmAnd-java/OsmAnd-java.iml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd-java/collect_libs.sh b/OsmAnd-java/collect_libs.sh index 210b8e1ae6..8caa2aac4f 100755 --- a/OsmAnd-java/collect_libs.sh +++ b/OsmAnd-java/collect_libs.sh @@ -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 diff --git a/OsmAnd-java/src/net/osmand/NativeLibrary.java b/OsmAnd-java/src/net/osmand/NativeLibrary.java index e9e2531083..c9629fa970 100644 --- a/OsmAnd-java/src/net/osmand/NativeLibrary.java +++ b/OsmAnd-java/src/net/osmand/NativeLibrary.java @@ -28,7 +28,13 @@ import net.osmand.router.RoutingConfiguration; public class NativeLibrary { - public static class RenderingGenerationResult { + 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) { - return initBinaryMapFile(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; } + } diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryInspectorNative.java b/OsmAnd-java/src/net/osmand/binary/BinaryInspectorNative.java index 5fdd613fcc..cc9710b53c 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryInspectorNative.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryInspectorNative.java @@ -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) { diff --git a/OsmAnd-java/src/net/osmand/util/Algorithms.java b/OsmAnd-java/src/net/osmand/util/Algorithms.java index faae29c8fb..8aa83b16d5 100644 --- a/OsmAnd-java/src/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/net/osmand/util/Algorithms.java @@ -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)); - } - } diff --git a/OsmAnd/OsmAnd.iml b/OsmAnd/OsmAnd.iml new file mode 100644 index 0000000000..d3c5532245 --- /dev/null +++ b/OsmAnd/OsmAnd.iml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/old-ndk-build.sh b/OsmAnd/old-ndk-build.sh index 52ef0b18eb..878a3ab6b9 100755 --- a/OsmAnd/old-ndk-build.sh +++ b/OsmAnd/old-ndk-build.sh @@ -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) diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index dae5eded0d..d9869c3e20 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -1,4 +1,4 @@ - + Overvej at købe Højdekurve udvidelsen (\'Contour lines\') på Google Play for at støtte den videre udvikling. Optag video Optag audio diff --git a/OsmAnd/res/values-el/strings.xml b/OsmAnd/res/values-el/strings.xml index 6ff978b9cc..835c6b2c5b 100644 --- a/OsmAnd/res/values-el/strings.xml +++ b/OsmAnd/res/values-el/strings.xml @@ -1,4 +1,4 @@ - + Προσθήκη Ετικέτας Λειτουργία για προχωρημένους… Στάθμευση diff --git a/OsmAnd/res/values-es/strings.xml b/OsmAnd/res/values-es/strings.xml index 90b4f72e37..6c69624e4a 100644 --- a/OsmAnd/res/values-es/strings.xml +++ b/OsmAnd/res/values-es/strings.xml @@ -1,4 +1,4 @@ - + Iniciar\n seguimiento en directo Parar\n seguimiento en directo Configura pantalla diff --git a/OsmAnd/res/values-fa/strings.xml b/OsmAnd/res/values-fa/strings.xml index 613f00649f..16ca11691b 100644 --- a/OsmAnd/res/values-fa/strings.xml +++ b/OsmAnd/res/values-fa/strings.xml @@ -1,4 +1,4 @@ - + پشتیبان گیری از تغییرات OSM ناموفق بود زمان دقت @@ -343,7 +343,7 @@ دنبال کردن لطفا ابتدا مقصد را انتخاب کنید مسیرها - نشان دادن /'وضعیت GPS/' + نشان دادن /\'وضعیت GPS/\' ساعات باز بودن تاریخچه چیزی پیدا نشد @@ -1370,9 +1370,9 @@ OsmAnd منبع باز است و فعالانه در حال توسعه است. ویکی پدیای POIهای سراسر جهان میتوانید چگونگی نمایش و چرخش نقشه را با کلیک کردن بر روی آیکون قطب نمای صفحه نمایش نقشه عوض کنید. \n\nانتخابها عبارتند از: - \n\t* \'عدم چرخش (شمال به طرف بالا)\'- نقشه نمیچرخد. شمال همیشه به طرف بالا خواهد بود - \n\t* \'به طرف جهت حرکت\'- نقشه به طور مداوم هم جهت با مسیر حرکت خواهد بود - \n\t* \'به طرف قطب نما\'- نقشه به طور مداوم هم جهت با قطب نمای دستگاه خواهد بود + \n\t\*\'عدم چرخش (شمال به طرف بالا)\'- نقشه نمیچرخد. شمال همیشه به طرف بالا خواهد بود + \n\t\*\'به طرف جهت حرکت\'- نقشه به طور مداوم هم جهت با مسیر حرکت خواهد بود + \n\t\'به طرف قطب نما\'- نقشه به طور مداوم هم جهت با قطب نمای دستگاه خواهد بود ظاهر نقشه برای نقشه های بُرداری بین حالت روز(روشن) و شب(تیره) قابل تغییر میباشد. رنگهای شب برای رانندگی در شب امن تر و راحت تر هستند. \n\nمیتوانیداز طریق \'منو\'->\'پیکربندی صفحه نمایش\'->\'نقشه روز/شب\' زمان تفییر روز/شب را تنظیم کنید. diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index c6ef1afa2e..a1ce9a9b6b 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -1,4 +1,4 @@ - + Modifications hors ligne Toujours utiliser l\'édition hors ligne "Changements en 0.7.1 : @@ -1333,7 +1333,7 @@ Annonces vocales… Annoncer les radars Annonce les alertes de trafic - Merci de spécifier votre nom d'utilisateur et mot de passe OSM dans les paramètres + Merci de spécifier votre nom d\'utilisateur et mot de passe OSM dans les paramètres Effacer les points intermédiaires Garder les points intermédiaires Données de tuile : %1$s diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml index f65bc7e797..66d92ca1ed 100644 --- a/OsmAnd/res/values-sl/strings.xml +++ b/OsmAnd/res/values-sl/strings.xml @@ -580,9 +580,9 @@ Usmerjenost zemljevida 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. 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 @@ 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) Ni dovolj razpoložljivega prostora za prejem %1$s MB(prosto: %2$s). Razpoložljiv prostor je sedaj {2}MB! Ali želite prejeti {0} datotek(o) ({1}MB)? diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index be0c884031..9b84738f3d 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -1,4 +1,4 @@ - + För att låsa upp skärmen tryck på låsikonen Välj land Välj stad @@ -374,9 +374,9 @@ Aktuella data på enheten (%1$s ledigt): Kartorientering 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. Hämtades utan problem. \n\t\n\tFör användning aktivera \'Meny\' -> \'Definiera vy\' -> \'Kartkälla …\' -> \'Offline vektorkartor\'. diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 868a961572..b60be3c761 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -1,4 +1,4 @@ - + 選擇道路的色彩調配: 道路的色彩調配 顯示目的地方向 diff --git a/OsmAnd/res/values/no_translate.xml b/OsmAnd/res/values/no_translate.xml index 81250cbd39..d20503441c 100644 --- a/OsmAnd/res/values/no_translate.xml +++ b/OsmAnd/res/values/no_translate.xml @@ -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 diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 5c60a11966..5ab04e5637 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -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)); + } } diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index d0f608013f..beea75ca2e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -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))) { diff --git a/OsmAnd/src/net/osmand/plus/PoiFilter.java b/OsmAnd/src/net/osmand/plus/PoiFilter.java index e6bb8894bb..e5f110868b 100644 --- a/OsmAnd/src/net/osmand/plus/PoiFilter.java +++ b/OsmAnd/src/net/osmand/plus/PoiFilter.java @@ -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$ } } diff --git a/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java b/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java index b6dbfff1f5..d40ee71739 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java index 030b3c7c12..618b47850e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java @@ -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 listAlreadyDownloadedWithAlternatives() { Map files = new TreeMap(); - 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 listWithAlternatives(File file, final String ext, + public static Map listWithAlternatives(final Context ctx, File file, final String ext, final Map 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 { diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java index ba7b835fc0..bc119d9e0b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java @@ -77,8 +77,6 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { private ContextMenuAdapter optionsMenuAdapter; private ActionMode actionMode; - - @SuppressWarnings("unchecked") @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 7e74b2d08d..b8dbe7f90a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -1142,7 +1142,8 @@ public class MapActivityActions implements DialogProvider { } }).reg(); } - optionsMenuHelper.item(routingHelper.isRouteCalculated() ? R.string.show_route: R.string.get_directions) + 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() { @Override @@ -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() { diff --git a/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java b/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java index a80476a42f..b7a19802c6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index f94311cfea..0c402bd3ea 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -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()); } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java index 3b18c23005..3b4aa13351 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java @@ -44,6 +44,7 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity 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 extends OsmandListActivity return row; } } + + protected void quitActivity(Class 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); + } } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java index 478d6315b7..4f430769b6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java @@ -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 if (region.getCityById(obj.getId(), obj.getName(region.useEnglishNames())) == null) { region.addCityToPreloadedList((City) obj); } - finish(); + quitActivity(SearchStreetByNameActivity.class); } private final class CityComparator implements Comparator { @@ -218,5 +219,6 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity return c1? 1 : -1; } } + } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java index 8931d12d25..f11898fd7e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java @@ -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 getRecordings() { + private void indexFile(boolean registerInGPX, File f) { + if (f.getName().endsWith(THREEGP_EXTENSION) || f.getName().endsWith(MPEG4_EXTENSION) + || f.getName().endsWith(IMG_EXTENSION)) { + 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) { + String name = f.getName(); + SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper(); + + savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), name); + if (app.getSettings().SHOW_CURRENT_GPX_TRACK.get()) { + app.getFavorites().addFavoritePointToGPXFile(new FavouritePoint(rec.lat, rec.lon, name, "")); + } + } + } + + } + } + + public DataTileManager 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()) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 072fd1adb6..318468ae8c 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -89,12 +89,12 @@ public class DownloadIndexesThread { public void updateLoadedFiles() { Map indexActivatedFileNames = app.getResourceManager().getIndexFileNames(); - DownloadIndexActivity.listWithAlternatives(app.getAppPath(""), + DownloadIndexActivity.listWithAlternatives(app, app.getAppPath(""), IndexConstants.EXTRA_EXT, indexActivatedFileNames); Map 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; diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java index 037d820911..0d1a07031a 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java @@ -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; } diff --git a/OsmAnd/src/net/osmand/plus/download/IndexItem.java b/OsmAnd/src/net/osmand/plus/download/IndexItem.java index 4c168ab6be..93513329a9 100644 --- a/OsmAnd/src/net/osmand/plus/download/IndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/IndexItem.java @@ -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 { private static final Log log = PlatformUtil.getLog(IndexItem.class); @@ -193,7 +197,7 @@ public class IndexItem implements Comparable { 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); diff --git a/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java b/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java index bb16c85a00..137ddd4f94 100644 --- a/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java +++ b/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java @@ -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 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 diff --git a/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java b/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java index d0116a41d1..ab7ad31577 100644 --- a/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java +++ b/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java @@ -17,14 +17,19 @@ public class NativeOsmandLibrary extends NativeLibrary { private static NativeOsmandLibrary library; private static Boolean isNativeSupported = null; - - public static NativeOsmandLibrary getLoadedLibrary(){ + + public NativeOsmandLibrary(boolean newLibrary) { + super(newLibrary); + } + + public static NativeOsmandLibrary getLoadedLibrary(){ synchronized (NativeOsmandLibrary.class) { return library; } } - public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage, ClientContext ctx) { + + public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage, ClientContext ctx) { if (!isLoaded()) { synchronized (NativeOsmandLibrary.class) { if (!isLoaded()) { @@ -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); } @@ -103,7 +108,7 @@ public class NativeOsmandLibrary extends NativeLibrary { public RenderingGenerationResult generateRendering(RenderingContext rc, NativeSearchResult searchResultHandler, Bitmap bitmap, boolean isTransparent, RenderingRuleSearchRequest render) { if (searchResultHandler == null) { - log.error("Error searchresult = null"); //$NON-NLS-1$ + log.error("Error search result = null"); //$NON-NLS-1$ return new RenderingGenerationResult(null); } diff --git a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java index c9d7cc9485..58ce233b67 100644 --- a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java @@ -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); } } } diff --git a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java index a9b6ad51cf..b754230f4e 100644 --- a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java +++ b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java @@ -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() { diff --git a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java index 884e3f70e4..52d2594ac7 100644 --- a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java @@ -242,18 +242,11 @@ 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); - cv.drawBitmap(ico, left, top, paintIcon); - } + 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); } } diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index 50e484d1f8..e0a182aa08 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -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$ } } } diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index e0bd9a659d..b4341fc08e 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -246,14 +246,19 @@ public class RouteCalculationResult { if(turn != null) { RouteDirectionInfo info = new RouteDirectionInfo(s.getSegmentSpeed(), turn); - if(routeInd + 1< list.size()) { - RouteSegmentResult next = list.get(routeInd); - info.setRef(next.getObject().getRef()); - info.setStreetName(next.getObject().getName()); - info.setDestinationName(next.getObject().getDestinationName()); - } - - String description = toString(turn, ctx) + " " + RoutingHelper.formatStreetName(info.getStreetName(), + 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()); + } + + String description = toString(turn, ctx) + " " + RoutingHelper.formatStreetName(info.getStreetName(), info.getRef(), info.getDestinationName()); info.setDescriptionRoute(description); info.routePointOffset = prevLocationSize; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 3ab0e3a1d6..29c86908ca 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -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 routeNodes = srcRoute.getImmutableLocations(); List directionInfo = srcRoute.getDirections(); @@ -728,7 +723,21 @@ public class RouteProvider { route.points.add(pt); } } - return gpx; + List ps = helper.getIntermediatePointsWithTarget(); + List 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; } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index fdac7d8e68..10fc8a63e6 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -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(); @@ -659,8 +659,12 @@ public class RoutingHelper { } return null; } - - public synchronized NextDirectionInfo getNextRouteDirectionInfoAfter(NextDirectionInfo previous, NextDirectionInfo to, boolean toSpeak){ + + 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) { i.imminent = voiceRouter.calculateImminent(i.distanceTo, null); diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index def1eafe29..fd40a13f1b 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -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,7 +272,8 @@ public class VoiceRouter { NextDirectionInfo nextInfo = router.getNextRouteDirectionInfo(new NextDirectionInfo(), true); - // after last turn say: + 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 if (repeat || currentStatus <= STATUS_UNKNOWN) { @@ -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; } diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index b248a7b2db..54dd9232da 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -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 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 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 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 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(); @@ -408,7 +233,7 @@ public class MapInfoLayer extends OsmandMapLayer { mapInfoControls.populateStatusBar(statusBar); updateColorShadowsOfText(null); } - + public void createControls() { // 1. Create view groups and controls statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top)); @@ -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; } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java new file mode 100644 index 0000000000..f88de1d92a --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java @@ -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 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 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 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 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 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 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(); + } + }); + } + } + } +} diff --git a/SherlockBar/SherlockBar.iml b/SherlockBar/SherlockBar.iml new file mode 100644 index 0000000000..839e8cb99a --- /dev/null +++ b/SherlockBar/SherlockBar.iml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/OsmAnd-AddressPlugin/OsmAnd-AddressPlugin.iml b/plugins/OsmAnd-AddressPlugin/OsmAnd-AddressPlugin.iml new file mode 100644 index 0000000000..4d1bed3008 --- /dev/null +++ b/plugins/OsmAnd-AddressPlugin/OsmAnd-AddressPlugin.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Osmand-ParkingPlugin/Osmand-ParkingPlugin.iml b/plugins/Osmand-ParkingPlugin/Osmand-ParkingPlugin.iml new file mode 100644 index 0000000000..66a878fcb5 --- /dev/null +++ b/plugins/Osmand-ParkingPlugin/Osmand-ParkingPlugin.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Osmand-SRTMPlugin/Osmand-SRTMPlugin.iml b/plugins/Osmand-SRTMPlugin/Osmand-SRTMPlugin.iml new file mode 100644 index 0000000000..4d1bed3008 --- /dev/null +++ b/plugins/Osmand-SRTMPlugin/Osmand-SRTMPlugin.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +