Merge branch 'master' into track_appearance

This commit is contained in:
Vitaliy 2020-07-16 13:50:13 +03:00
commit 4b4100cf0d
16 changed files with 344 additions and 170 deletions

View file

@ -1,12 +1,15 @@
package net.osmand.binary; package net.osmand.binary;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import net.osmand.util.TransliterationHelper; import net.osmand.util.TransliterationHelper;
import org.apache.commons.logging.Log;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Arrays; import java.util.Arrays;
@ -34,7 +37,7 @@ public class RouteDataObject {
public int[] nameIds; public int[] nameIds;
// mixed array [0, height, cumulative_distance height, cumulative_distance, height, ...] - length is length(points)*2 // mixed array [0, height, cumulative_distance height, cumulative_distance, height, ...] - length is length(points)*2
public float[] heightDistanceArray = null; public float[] heightDistanceArray = null;
private static final Log LOG = PlatformUtil.getLog(RouteDataObject.class);
public RouteDataObject(RouteRegion region) { public RouteDataObject(RouteRegion region) {
this.region = region; this.region = region;
} }
@ -56,6 +59,7 @@ public class RouteDataObject {
this.pointsY = copy.pointsY; this.pointsY = copy.pointsY;
this.types = copy.types; this.types = copy.types;
this.names = copy.names; this.names = copy.names;
this.nameIds = copy.nameIds;
this.restrictions = copy.restrictions; this.restrictions = copy.restrictions;
this.restrictionsVia = copy.restrictionsVia; this.restrictionsVia = copy.restrictionsVia;
this.pointTypes = copy.pointTypes; this.pointTypes = copy.pointTypes;
@ -426,12 +430,19 @@ public class RouteDataObject {
int[] opointsX = pointsX; int[] opointsX = pointsX;
int[] opointsY = pointsY; int[] opointsY = pointsY;
int[][] opointTypes = pointTypes; int[][] opointTypes = pointTypes;
String[][] opointNames = pointNames;
int[][] opointNameTypes = pointNameTypes;
pointsX = new int[pointsX.length + 1]; pointsX = new int[pointsX.length + 1];
pointsY = new int[pointsY.length + 1]; pointsY = new int[pointsY.length + 1];
boolean insTypes = this.pointTypes != null && this.pointTypes.length > pos; boolean insTypes = this.pointTypes != null && this.pointTypes.length > pos;
boolean insNames = this.pointNames != null && this.pointNames.length > pos;
if (insTypes) { if (insTypes) {
pointTypes = new int[opointTypes.length + 1][]; pointTypes = new int[opointTypes.length + 1][];
} }
if (insNames) {
pointNames = new String[opointNames.length + 1][];
pointNameTypes = new int[opointNameTypes.length +1][];
}
int i = 0; int i = 0;
for (; i < pos; i++) { for (; i < pos; i++) {
pointsX[i] = opointsX[i]; pointsX[i] = opointsX[i];
@ -439,18 +450,32 @@ public class RouteDataObject {
if (insTypes) { if (insTypes) {
pointTypes[i] = opointTypes[i]; pointTypes[i] = opointTypes[i];
} }
if (insNames) {
pointNames[i] = opointNames[i];
pointNameTypes[i] = opointNameTypes[i];
}
} }
pointsX[i] = x31; pointsX[i] = x31;
pointsY[i] = y31; pointsY[i] = y31;
if (insTypes) { if (insTypes) {
pointTypes[i] = null; pointTypes[i] = null;
} }
if (insNames) {
pointNames[i] = null;
pointNameTypes[i] = null;
}
for (i = i + 1; i < pointsX.length; i++) { for (i = i + 1; i < pointsX.length; i++) {
pointsX[i] = opointsX[i - 1]; pointsX[i] = opointsX[i - 1];
pointsY[i] = opointsY[i - 1]; pointsY[i] = opointsY[i - 1];
if (insTypes && i < pointTypes.length) { if (insTypes && i < pointTypes.length) {
pointTypes[i] = opointTypes[i - 1]; pointTypes[i] = opointTypes[i - 1];
} }
if (insNames && i < pointNames.length) {
pointNames[i] = opointNames[i - 1];
}
if (insNames && i < pointNameTypes.length) {
pointNameTypes[i] = opointNameTypes[i - 1];
}
} }
} }

View file

@ -3638,4 +3638,12 @@
<string name="poi_bath_open_air">На адкрытым паветры</string> <string name="poi_bath_open_air">На адкрытым паветры</string>
<string name="poi_volcano_type">Тып</string> <string name="poi_volcano_type">Тып</string>
<string name="poi_volcano_status">Статус</string> <string name="poi_volcano_status">Статус</string>
<string name="poi_motor_vehicle_yes">Даступна для механічнага транспартнага сродку: так</string>
<string name="poi_motor_vehicle_no">Даступна для механічнага транспартнага сродку: не</string>
<string name="poi_motor_vehicle_private">Даступна для механічнага транспартнага сродку: прыватны доступ</string>
<string name="poi_traffic_signals_arrow">Стрэлка</string>
<string name="poi_traffic_signals_vibration">Вібрацыя</string>
<string name="poi_fire_hydrant_pressure_filter">Ціск</string>
<string name="poi_video_telephone">Відэа</string>
<string name="poi_sms">SMS</string>
</resources> </resources>

View file

@ -9,14 +9,14 @@
<string name="about_version">Версія:</string> <string name="about_version">Версія:</string>
<string name="shared_string_about">Пра праграму</string> <string name="shared_string_about">Пра праграму</string>
<string name="about_settings_descr">Версія, ліцэнзіі, удзельнікі праекта</string> <string name="about_settings_descr">Версія, ліцэнзіі, удзельнікі праекта</string>
<string name="local_index_tile_data_zooms">Спампаваныя маштабы: %1$s</string> <string name="local_index_tile_data_zooms">Спампаваныя ўзроўні маштабавання: %1$s</string>
<string name="local_index_tile_data_expire">Тэрмін дзеяння (у хвілінах): %1$s</string> <string name="local_index_tile_data_expire">Тэрмін дзеяння (у хвілінах): %1$s</string>
<string name="local_index_tile_data_downloadable">Можна спампаваць: %1$s</string> <string name="local_index_tile_data_downloadable">Можна спампаваць: %1$s</string>
<string name="local_index_tile_data_maxzoom">Максімальнае павелічэнне: %1$s</string> <string name="local_index_tile_data_maxzoom">Максімальнае павелічэнне: %1$s</string>
<string name="local_index_tile_data_minzoom">Мінімальнае павелічэнне: %1$s</string> <string name="local_index_tile_data_minzoom">Мінімальнае павелічэнне: %1$s</string>
<string name="local_index_tile_data_name">Даныя фрагменту: %1$s</string> <string name="local_index_tile_data_name">Даныя фрагменту: %1$s</string>
<string name="edit_tilesource_successfully">Крыніца фрагментаў мапы «%1$s» захаваная</string> <string name="edit_tilesource_successfully">Крыніца фрагментаў мапы «%1$s» захаваная</string>
<string name="edit_tilesource_elliptic_tile">Эліптычны меркатар</string> <string name="edit_tilesource_elliptic_tile">Эліптычная праекцыя меркатара</string>
<string name="edit_tilesource_maxzoom">Максімальнае павелічэнне</string> <string name="edit_tilesource_maxzoom">Максімальнае павелічэнне</string>
<string name="edit_tilesource_expiration_time">Тэрмін дзеяння (у хвілінах)</string> <string name="edit_tilesource_expiration_time">Тэрмін дзеяння (у хвілінах)</string>
<string name="edit_tilesource_minzoom">Мінімальнае павелічэнне</string> <string name="edit_tilesource_minzoom">Мінімальнае павелічэнне</string>
@ -2071,7 +2071,7 @@
<string name="osm_live_banner_desc">Атрымайце неабмежаваную колькасць спампоўванняў мапаў у дадатак да штотыднёвых, штодзённых і нават штогадзінных абнаўленняў.</string> <string name="osm_live_banner_desc">Атрымайце неабмежаваную колькасць спампоўванняў мапаў у дадатак да штотыднёвых, штодзённых і нават штогадзінных абнаўленняў.</string>
<string name="osmand_plus_banner_desc">Неабмежаваная колькасць спамоўванняў мапаў, абнаўленняў і ўбудова Wikipedia.</string> <string name="osmand_plus_banner_desc">Неабмежаваная колькасць спамоўванняў мапаў, абнаўленняў і ўбудова Wikipedia.</string>
<string name="si_mi_meters">Мілі/метры</string> <string name="si_mi_meters">Мілі/метры</string>
<string name="osm_live_payment_desc">Плата за падпіску спаганяецца штомесяц. Скасаваць яе на Google Play можна у любы момант.</string> <string name="osm_live_payment_desc">Плата за падпіску спаганяецца за абраны перыяд. Скасаваць яе на Google Play можна у любы момант.</string>
<string name="donation_to_osm">Ахвяраванне супольнасці OpenStreetMap</string> <string name="donation_to_osm">Ахвяраванне супольнасці OpenStreetMap</string>
<string name="donation_to_osm_desc">Частка вашага ахвяравання накіроўваецца ўдзельнікам праекта OpenStreetMap. Кошт падпіскі застаецца тым жа самым.</string> <string name="donation_to_osm_desc">Частка вашага ахвяравання накіроўваецца ўдзельнікам праекта OpenStreetMap. Кошт падпіскі застаецца тым жа самым.</string>
<string name="osm_live_subscription_desc">Падпіска дазваляе атрымліваць штогадзіныя, штодзённыя, штотыднёвыя абнаўленні і неабмежаваную колькасць спампоўванняў для ўсіх мапаў па ўсім свеце.</string> <string name="osm_live_subscription_desc">Падпіска дазваляе атрымліваць штогадзіныя, штодзённыя, штотыднёвыя абнаўленні і неабмежаваную колькасць спампоўванняў для ўсіх мапаў па ўсім свеце.</string>
@ -2481,7 +2481,7 @@
\n</string> \n</string>
<string name="shared_string_install">Усталяваць</string> <string name="shared_string_install">Усталяваць</string>
<string name="improve_coverage_mapillary">Палепшыць фотапакрыццё Mapillary</string> <string name="improve_coverage_mapillary">Палепшыць фотапакрыццё Mapillary</string>
<string name="improve_coverage_install_mapillary_desc">Усталяваць Mapillary, каб дадаць адзін альбо некалькі фотаздымкаў да гэтага месца на мапе.</string> <string name="improve_coverage_install_mapillary_desc">Усталюйце Mapillary, каб дадаць фотаздымкі гэтага месца.</string>
<string name="open_mapillary">Адкрыць Mapillary</string> <string name="open_mapillary">Адкрыць Mapillary</string>
<string name="mapillary_image">Выява Mapillary</string> <string name="mapillary_image">Выява Mapillary</string>
<string name="distance_moving">Дыстанцыя выпраўленая</string> <string name="distance_moving">Дыстанцыя выпраўленая</string>
@ -3093,7 +3093,7 @@
<string name="edit_profile_setup_subtitle">У кожнага профілю свае налады</string> <string name="edit_profile_setup_subtitle">У кожнага профілю свае налады</string>
<string name="turn_screen_on_time_descr">Вызначце час, цягам якога экран не будзе выключацца.</string> <string name="turn_screen_on_time_descr">Вызначце час, цягам якога экран не будзе выключацца.</string>
<string name="turn_screen_on_sensor">Выкарыстоўваць датчык адлегласці</string> <string name="turn_screen_on_sensor">Выкарыстоўваць датчык адлегласці</string>
<string name="turn_screen_on_sensor_descr">Правядзіце рукой па верхняй частцы экрана, каб уключыць яго падчас навігацыі.</string> <string name="turn_screen_on_sensor_descr">Уключаць экран правёўшы па яму рукой.</string>
<string name="rendering_attr_winter_road_name">Зімовая дарога</string> <string name="rendering_attr_winter_road_name">Зімовая дарога</string>
<string name="rendering_attr_ice_road_name">Ледзяная дарога</string> <string name="rendering_attr_ice_road_name">Ледзяная дарога</string>
<string name="routeInfo_winter_ice_road_name">Зімовыя і ледзяныя дарогі</string> <string name="routeInfo_winter_ice_road_name">Зімовыя і ледзяныя дарогі</string>
@ -3307,7 +3307,7 @@
<string name="app_mode_pickup_truck">Пікап</string> <string name="app_mode_pickup_truck">Пікап</string>
<string name="turn_screen_on_info">Паказваць мапу падчас навігацыі на заблакаваным экране.</string> <string name="turn_screen_on_info">Паказваць мапу падчас навігацыі на заблакаваным экране.</string>
<string name="route_parameters_info">Налады пабудовы маршруту абранага профілю \"%1$s\".</string> <string name="route_parameters_info">Налады пабудовы маршруту абранага профілю \"%1$s\".</string>
<string name="wake_time">Час абуджэння</string> <string name="wake_time">Час працы пасля абуджэння</string>
<string name="units_and_formats">Адзінкі вымярэння і фарматы</string> <string name="units_and_formats">Адзінкі вымярэння і фарматы</string>
<string name="appearance">Выгляд</string> <string name="appearance">Выгляд</string>
<string name="map_look_descr">Выгляд мапы</string> <string name="map_look_descr">Выгляд мапы</string>
@ -3327,7 +3327,7 @@
<string name="map_during_navigation_info">Мапа падчас навігацыі</string> <string name="map_during_navigation_info">Мапа падчас навігацыі</string>
<string name="map_during_navigation">Мапа падчас навігацыі</string> <string name="map_during_navigation">Мапа падчас навігацыі</string>
<string name="shared_string_other">Іншае</string> <string name="shared_string_other">Іншае</string>
<string name="vehicle_parameters_descr">Вага, вышыня, хуткасць</string> <string name="vehicle_parameters_descr">Вага, вышыня, даўжыня, хуткасць</string>
<string name="vehicle_parameters">Параметры аўтамабіля</string> <string name="vehicle_parameters">Параметры аўтамабіля</string>
<string name="voice_announces_info">Галасавыя апавяшчэнні прайграюцца толькі падчас навігацыі.</string> <string name="voice_announces_info">Галасавыя апавяшчэнні прайграюцца толькі падчас навігацыі.</string>
<string name="voice_announces_descr">Навігацыйныя інструкцыі і апавяшчэнні</string> <string name="voice_announces_descr">Навігацыйныя інструкцыі і апавяшчэнні</string>
@ -3535,7 +3535,7 @@
<string name="reset_deafult_order">Аднавіць прадвызначаны парадак элементаў</string> <string name="reset_deafult_order">Аднавіць прадвызначаны парадак элементаў</string>
<string name="back_to_editing">Вярнуцца да рэдагавання</string> <string name="back_to_editing">Вярнуцца да рэдагавання</string>
<string name="quick_action_transport_show">Паказаць грамадскі транспарт</string> <string name="quick_action_transport_show">Паказаць грамадскі транспарт</string>
<string name="quick_action_transport_descr">Кнопка, каб паказаць ці схаваць грамадскі транспарт на мапе.</string> <string name="quick_action_transport_descr">Кнопка для паказу ці хавання грамадскага транспарту на мапе.</string>
<string name="shared_string_add_profile">Дадаць профіль</string> <string name="shared_string_add_profile">Дадаць профіль</string>
<string name="n_items_of_z">%1$s з %2$s</string> <string name="n_items_of_z">%1$s з %2$s</string>
<string name="download_slope_maps">Схілы</string> <string name="download_slope_maps">Схілы</string>
@ -3564,7 +3564,7 @@
<string name="shared_string_divider">Падзяляльнік</string> <string name="shared_string_divider">Падзяляльнік</string>
<string name="shared_string_hidden">Схавана</string> <string name="shared_string_hidden">Схавана</string>
<string name="reset_items_descr">Калі схаваць налады, то яны скінуцца да зыходнага стану.</string> <string name="reset_items_descr">Калі схаваць налады, то яны скінуцца да зыходнага стану.</string>
<string name="main_actions_descr">\"Асноўныя дзеянні\" змяшчаюць толькі 4 кнопкі.</string> <string name="main_actions_descr">Толькі 4 кнопкі.</string>
<string name="main_actions">Асноўныя дзеянні</string> <string name="main_actions">Асноўныя дзеянні</string>
<string name="developer_plugin">Убудова для распрацоўшчыкаў</string> <string name="developer_plugin">Убудова для распрацоўшчыкаў</string>
<string name="replace_point_descr">Замяніць іншы пункт на гэты.</string> <string name="replace_point_descr">Замяніць іншы пункт на гэты.</string>
@ -3596,8 +3596,8 @@
<string name="lang_an">Арагонская</string> <string name="lang_an">Арагонская</string>
<string name="custom_color">Адвольны колер</string> <string name="custom_color">Адвольны колер</string>
<string name="search_poi_types">Пошук тыпаў POI</string> <string name="search_poi_types">Пошук тыпаў POI</string>
<string name="quick_action_switch_profile_descr">Абраныя профілі пераключаюцца націскам на кнопку \"Дзеянне\".</string> <string name="quick_action_switch_profile_descr">Пры націсканні на кнопку \"Дзеянні\" пераключаюцца абраныя профілі.</string>
<string name="profiles_for_action_not_found">Профіляў, абраных для гэтага дзеяння, не знойдзена.</string> <string name="profiles_for_action_not_found">Адпаведных профіляў не знойдзена.</string>
<string name="lang_zhyue">Кантонская</string> <string name="lang_zhyue">Кантонская</string>
<string name="lang_yo">Ёруба</string> <string name="lang_yo">Ёруба</string>
<string name="lang_uz">Узбекская</string> <string name="lang_uz">Узбекская</string>
@ -3620,4 +3620,28 @@
<string name="quick_action_show_hide_transport">Паказаць/схаваць грамадскі транспарт</string> <string name="quick_action_show_hide_transport">Паказаць/схаваць грамадскі транспарт</string>
<string name="recalculate_route_in_deviation">Пералічыць маршрут у выпадку адхілення</string> <string name="recalculate_route_in_deviation">Пералічыць маршрут у выпадку адхілення</string>
<string name="shared_string_uninstall">Выдаліць</string> <string name="shared_string_uninstall">Выдаліць</string>
<string name="vessel_width_limit_description">Вызначце шырыню судна, каб пазбягаць вузкіх мастоў</string>
<string name="quick_action_showhide_mapillary_title">Паказаць/схаваць Mapillary</string>
<string name="quick_action_mapillary_hide">Схаваць Mapillary</string>
<string name="quick_action_mapillary_show">Паказаць Mapillary</string>
<string name="quick_action_showhide_mapillary_descr">Пераключальнік для паказу альбо хавання пласта Mapillary.</string>
<string name="routing_attr_length_description">Пазначце даўжыню транспартнага сродку, дазволеную для руху па маршрутах.</string>
<string name="routing_attr_length_name">Ліміт даўжыні</string>
<string name="shared_string_bearing">Арыентацыя</string>
<string name="item_deleted">Выдалена: %1$s</string>
<string name="speed_cameras_restart_descr">Перазапуск патрабуецца для поўнага выдалення даных камер кантролю хуткасці.</string>
<string name="use_volume_buttons_as_zoom_descr">Кіраванне ўзроўнем маштабавання мапы пры дапамозе кнопак рэгулявання гучнасці.</string>
<string name="plugin_wikipedia_description">Інфармацыя пра славутасці з Вікіпедыі. Гэта ваш кішэнны даведнік - уключыце ўбудову вікіпедыі і чытайце артыкулы пра аб’екты вакол вас.</string>
<string name="app_mode_enduro_motorcycle">Матацыкл Эндура</string>
<string name="app_mode_motor_scooter">Мотаролер</string>
<string name="shared_string_uninstall_and_restart">Выдаліць і перазапусціць</string>
<string name="speed_cameras_removed_descr">На гэтай прыладзе няма камер кантролю хуткасці.</string>
<string name="app_mode_inline_skates">Ролікі</string>
<string name="quick_action_remove_next_destination">Выдаліць наступны пункт прызначэння</string>
<string name="use_volume_buttons_as_zoom">Маштабаванне кнопкамі гучнасці</string>
<string name="please_provide_point_name_error">Калі ласка, дайце пункту назву</string>
<string name="quick_action_remove_next_destination_descr">Бягучы пункт прызначэння маршруту будзе выдалены. Калі гэта канцавы пункт прызначэння, то навігацыя спыніцца.</string>
<string name="search_download_wikipedia_maps">Спампаваць мапы Вікіпедыі</string>
<string name="app_mode_wheelchair">Інвалідны вазок</string>
<string name="osm_edit_closed_note">Закрытая нататка OSM</string>
</resources> </resources>

View file

@ -3611,7 +3611,7 @@
<string name="replace_point_descr">Anstataŭigi alian punkton per tiu ĉi.</string> <string name="replace_point_descr">Anstataŭigi alian punkton per tiu ĉi.</string>
<string name="changes_applied_to_profile">Aplikis ŝanĝojn al la profilo “%1$s”.</string> <string name="changes_applied_to_profile">Aplikis ŝanĝojn al la profilo “%1$s”.</string>
<string name="settings_item_read_error">Ne povas legi el “%1$s”.</string> <string name="settings_item_read_error">Ne povas legi el “%1$s”.</string>
<string name="settings_item_write_error">Ne povas skribi al “%1%s”.</string> <string name="settings_item_write_error">Ne povas skribi al “%1$s”.</string>
<string name="settings_item_import_error">Ne povas enporti el “%1$s”.</string> <string name="settings_item_import_error">Ne povas enporti el “%1$s”.</string>
<string name="select_track_file">Elekti dosieron de spuro</string> <string name="select_track_file">Elekti dosieron de spuro</string>
<string name="shared_string_languages">Lingvoj</string> <string name="shared_string_languages">Lingvoj</string>

View file

@ -3824,4 +3824,5 @@
<string name="app_mode_wheelchair">Silla de ruedas</string> <string name="app_mode_wheelchair">Silla de ruedas</string>
<string name="app_mode_go_cart">Go-kart</string> <string name="app_mode_go_cart">Go-kart</string>
<string name="osm_edit_closed_note">Nota de OSM cerrada</string> <string name="osm_edit_closed_note">Nota de OSM cerrada</string>
<string name="app_mode_wheelchair_forward">Silla de ruedas (hacia adelante)</string>
</resources> </resources>

View file

@ -1116,7 +1116,7 @@
<string name="poi_tactile_paving_yes">van</string> <string name="poi_tactile_paving_yes">van</string>
<string name="poi_tactile_paving_no">Vakvezető burkolat nincs</string> <string name="poi_tactile_paving_no">Vakvezető burkolat nincs</string>
<string name="poi_traffic_signals_sound_yes">van</string> <string name="poi_traffic_signals_sound_yes">van</string>
<string name="poi_traffic_signals_sound_no">nincs</string> <string name="poi_traffic_signals_sound_no">Hang nincs</string>
<string name="poi_traffic_signals_sound_walk">Csak amikor zöld</string> <string name="poi_traffic_signals_sound_walk">Csak amikor zöld</string>
<string name="poi_services">Pihenőhely</string> <string name="poi_services">Pihenőhely</string>
<string name="poi_mini_roundabout">Mini körforgalom</string> <string name="poi_mini_roundabout">Mini körforgalom</string>
@ -1198,13 +1198,13 @@
<string name="poi_service_electrical">Elektromosautó-szerelés</string> <string name="poi_service_electrical">Elektromosautó-szerelés</string>
<string name="poi_motorcycle_repair">Motorkerékpár-szerelés</string> <string name="poi_motorcycle_repair">Motorkerékpár-szerelés</string>
<string name="poi_self_service_yes">igen</string> <string name="poi_self_service_yes">igen</string>
<string name="poi_self_service_no">Nem önkiszolgáló</string> <string name="poi_self_service_no">Nem</string>
<string name="poi_automated_yes">igen</string> <string name="poi_automated_yes">igen</string>
<string name="poi_automated_no">Nem automatizált</string> <string name="poi_automated_no">Nem automatizált</string>
<string name="poi_full_service_yes">Teljes kiszolgálás</string> <string name="poi_full_service_yes">Teljes kiszolgálás</string>
<string name="poi_brushless_yes">igen</string> <string name="poi_brushless_yes">igen</string>
<string name="poi_brushless_no">Kefés</string> <string name="poi_brushless_no">Kefés</string>
<string name="poi_car_wash_no">Autómosó nincs</string> <string name="poi_car_wash_no">Nincs</string>
<string name="poi_aeroway_fuel">Repülőgépüzemanyag-töltő állomás</string> <string name="poi_aeroway_fuel">Repülőgépüzemanyag-töltő állomás</string>
<string name="poi_public_bath">Közfürdő</string> <string name="poi_public_bath">Közfürdő</string>
<string name="poi_male_yes">Férfi</string> <string name="poi_male_yes">Férfi</string>
@ -3792,4 +3792,15 @@
<string name="poi_traffic_signals_arrow">Nyíl</string> <string name="poi_traffic_signals_arrow">Nyíl</string>
<string name="poi_traffic_signals_vibration">Rezgés</string> <string name="poi_traffic_signals_vibration">Rezgés</string>
<string name="poi_fire_hydrant_pressure_filter">Nyomás</string> <string name="poi_fire_hydrant_pressure_filter">Nyomás</string>
<string name="poi_seamark_obstruction">Akadály</string>
<string name="poi_piste_ref">Pálya azonosítószám</string>
<string name="poi_bowling_alley">Bowling központ</string>
<string name="poi_shop_security">Biztonsági szaküzlet</string>
<string name="poi_mountain_rescue">Hegyimentő</string>
<string name="poi_traffic_signals_arrow_yes">Igen</string>
<string name="poi_traffic_signals_vibration_yes">Igen</string>
<string name="poi_traffic_signals_vibration_no">Rezgés nincs</string>
<string name="poi_give_box">Adomány doboz</string>
<string name="poi_borough">Kerület</string>
<string name="poi_city_block">Háztömb</string>
</resources> </resources>

View file

@ -3810,15 +3810,16 @@
<string name="speed_cameras_removed_descr">Questo dispositivo non ha autovelox.</string> <string name="speed_cameras_removed_descr">Questo dispositivo non ha autovelox.</string>
<string name="app_mode_inline_skates">Pattini in linea</string> <string name="app_mode_inline_skates">Pattini in linea</string>
<string name="quick_action_remove_next_destination">Cancella il prossimo punto di destinazione</string> <string name="quick_action_remove_next_destination">Cancella il prossimo punto di destinazione</string>
<string name="use_volume_buttons_as_zoom_descr">Abilita il controllo del zoom della mappa con i pulsanti del volume del dispositivo.</string> <string name="use_volume_buttons_as_zoom_descr">Abilita per controllare il livello di zoom della mappa con i pulsanti del volume del dispositivo.</string>
<string name="use_volume_buttons_as_zoom">Pulsanti del volume come zoom</string> <string name="use_volume_buttons_as_zoom">Pulsanti volume come zoom</string>
<string name="please_provide_point_name_error">Per favore indica un nome per il punto</string> <string name="please_provide_point_name_error">Per favore indica un nome per il punto</string>
<string name="quick_action_remove_next_destination_descr">Il punto di destinazione nel percorso attuale verrà cancellato. Se sarà la Destinazione la navigazione si arresterà.</string> <string name="quick_action_remove_next_destination_descr">Il punto di destinazione corrente sul percorso verrà eliminato. Se sarà la Destinazione, la navigazione verrà interrotta.</string>
<string name="search_download_wikipedia_maps">Scarica mappe Wikimedia</string> <string name="search_download_wikipedia_maps">Scarica mappe Wikipedia</string>
<string name="plugin_wikipedia_description">Ottieni informazioni sui punti di interesse da Wikipedia. È la tua guida tascabile offline - semplicemente abilita il componente aggiuntivo Wikipedia e goditi gli articoli sui punti d\'interesse vicino a te.</string> <string name="plugin_wikipedia_description">Ottieni informazioni sui punti di interesse da Wikipedia. È la tua guida tascabile offline - basta abilitare il plugin Wikipedia e goderti gli articoli sugli oggetti intorno a te.</string>
<string name="app_mode_enduro_motorcycle">Moto enduro</string> <string name="app_mode_enduro_motorcycle">Moto da enduro</string>
<string name="app_mode_motor_scooter">Moto scooter</string> <string name="app_mode_motor_scooter">Moto scooter</string>
<string name="app_mode_wheelchair">Sedia a rotelle</string> <string name="app_mode_wheelchair">Sedia a rotelle</string>
<string name="app_mode_go_cart">Go-kart</string> <string name="app_mode_go_cart">Go-kart</string>
<string name="osm_edit_closed_note">Chiudi la nota OSM</string> <string name="osm_edit_closed_note">Chiudi la nota OSM</string>
<string name="app_mode_wheelchair_forward">Sedia a rotelle</string>
</resources> </resources>

View file

@ -3817,4 +3817,7 @@
<string name="poi_traffic_signals_vibration_no">Вібрація: вимкнено</string> <string name="poi_traffic_signals_vibration_no">Вібрація: вимкнено</string>
<string name="poi_traffic_signals_arrow">Стрілка</string> <string name="poi_traffic_signals_arrow">Стрілка</string>
<string name="poi_traffic_signals_vibration">Вібрація</string> <string name="poi_traffic_signals_vibration">Вібрація</string>
<string name="poi_city_block">Міський квартал</string>
<string name="poi_borough">Район</string>
<string name="poi_give_box">Подарункова коробка</string>
</resources> </resources>

View file

@ -3810,4 +3810,9 @@
<string name="search_download_wikipedia_maps">Завантажити мапи Вікіпедії</string> <string name="search_download_wikipedia_maps">Завантажити мапи Вікіпедії</string>
<string name="plugin_wikipedia_description">Отримайте відомості про визначні місця у Вікіпедії. Це ваш кишеньковий посібник без мережі - просто ввімкніть втулок \"Вікіпедія\" і насолоджуйтесь статтями про об\'єкти навколо вас.</string> <string name="plugin_wikipedia_description">Отримайте відомості про визначні місця у Вікіпедії. Це ваш кишеньковий посібник без мережі - просто ввімкніть втулок \"Вікіпедія\" і насолоджуйтесь статтями про об\'єкти навколо вас.</string>
<string name="app_mode_motor_scooter">Моторолер</string> <string name="app_mode_motor_scooter">Моторолер</string>
<string name="app_mode_enduro_motorcycle">легкий мотоцикл</string>
<string name="app_mode_wheelchair">Інвалідне крісло</string>
<string name="app_mode_wheelchair_forward">Інвалідне крісло попереду</string>
<string name="app_mode_go_cart">у мапу</string>
<string name="osm_edit_closed_note">Закрита нотатка OSM</string>
</resources> </resources>

View file

@ -22,7 +22,7 @@ import net.osmand.plus.settings.backend.SettingsHelper;
import net.osmand.plus.settings.backend.SettingsHelper.AvoidRoadsSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.AvoidRoadsSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.MapSourcesSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.MapSourcesSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.PluginSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.PluginSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.PoiUiFilterSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.PoiUiFiltersSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.ProfileSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.ProfileSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.QuickActionsSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.QuickActionsSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.SettingsCollectListener; import net.osmand.plus.settings.backend.SettingsHelper.SettingsCollectListener;
@ -305,9 +305,9 @@ public class CustomOsmandPlugin extends OsmandPlugin {
Algorithms.removeAllFiles(dir); Algorithms.removeAllFiles(dir);
} }
} }
} else if (item instanceof PoiUiFilterSettingsItem) { } else if (item instanceof PoiUiFiltersSettingsItem) {
PoiUiFilterSettingsItem poiUiFilterSettingsItem = (PoiUiFilterSettingsItem) item; PoiUiFiltersSettingsItem poiUiFiltersSettingsItem = (PoiUiFiltersSettingsItem) item;
List<PoiUIFilter> poiUIFilters = poiUiFilterSettingsItem.getItems(); List<PoiUIFilter> poiUIFilters = poiUiFiltersSettingsItem.getItems();
for (PoiUIFilter filter : poiUIFilters) { for (PoiUIFilter filter : poiUIFilters) {
app.getPoiFilters().removePoiFilter(filter); app.getPoiFilters().removePoiFilter(filter);
} }

View file

@ -126,7 +126,7 @@ public class SettingsHelper {
void onSettingsExportFinished(@NonNull File file, boolean succeed); void onSettingsExportFinished(@NonNull File file, boolean succeed);
} }
public SettingsHelper(OsmandApplication app) { public SettingsHelper(@NonNull OsmandApplication app) {
this.app = app; this.app = app;
} }
@ -149,18 +149,27 @@ public class SettingsHelper {
protected OsmandApplication app; protected OsmandApplication app;
private String pluginId; protected String pluginId;
private String fileName; protected String fileName;
boolean shouldReplace = false; boolean shouldReplace = false;
protected List<String> warnings; protected List<String> warnings;
SettingsItem(OsmandApplication app) { SettingsItem(@NonNull OsmandApplication app) {
this.app = app; this.app = app;
init(); init();
} }
SettingsItem(@NonNull OsmandApplication app, @Nullable SettingsItem baseItem) {
this.app = app;
if (baseItem != null) {
this.pluginId = baseItem.pluginId;
this.fileName = baseItem.fileName;
}
init();
}
SettingsItem(OsmandApplication app, @NonNull JSONObject json) throws JSONException { SettingsItem(OsmandApplication app, @NonNull JSONObject json) throws JSONException {
this.app = app; this.app = app;
init(); init();
@ -203,10 +212,6 @@ public class SettingsHelper {
return fileName; return fileName;
} }
public void setFileName(String fileName) {
this.fileName = fileName;
}
public boolean applyFileName(@NonNull String fileName) { public boolean applyFileName(@NonNull String fileName) {
String n = getFileName(); String n = getFileName();
return n != null && n.endsWith(fileName); return n != null && n.endsWith(fileName);
@ -281,13 +286,13 @@ public class SettingsHelper {
} }
@Nullable @Nullable
abstract SettingsItemReader getReader(); abstract SettingsItemReader<? extends SettingsItem> getReader();
@Nullable @Nullable
abstract SettingsItemWriter getWriter(); abstract SettingsItemWriter<? extends SettingsItem> getWriter();
@NonNull @NonNull
SettingsItemReader getJsonReader() { SettingsItemReader<? extends SettingsItem> getJsonReader() {
return new SettingsItemReader<SettingsItem>(this) { return new SettingsItemReader<SettingsItem>(this) {
@Override @Override
public void readFromStream(@NonNull InputStream inputStream) throws IOException, IllegalArgumentException { public void readFromStream(@NonNull InputStream inputStream) throws IOException, IllegalArgumentException {
@ -315,7 +320,7 @@ public class SettingsHelper {
} }
@NonNull @NonNull
SettingsItemWriter getJsonWriter() { SettingsItemWriter<? extends SettingsItem> getJsonWriter() {
return new SettingsItemWriter<SettingsItem>(this) { return new SettingsItemWriter<SettingsItem>(this) {
@Override @Override
public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException {
@ -445,13 +450,13 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return null; return null;
} }
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return null; return null;
} }
} }
@ -555,13 +560,13 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return null; return null;
} }
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return null; return null;
} }
} }
@ -638,13 +643,13 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return null; return null;
} }
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return null; return null;
} }
} }
@ -664,12 +669,12 @@ public class SettingsHelper {
duplicateItems = new ArrayList<>(); duplicateItems = new ArrayList<>();
} }
CollectionSettingsItem(OsmandApplication app, @NonNull List<T> items) { CollectionSettingsItem(@NonNull OsmandApplication app, @Nullable CollectionSettingsItem<T> baseItem, @NonNull List<T> items) {
super(app); super(app, baseItem);
this.items = items; this.items = items;
} }
CollectionSettingsItem(OsmandApplication app, @NonNull JSONObject json) throws JSONException { CollectionSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
super(app, json); super(app, json);
} }
@ -747,6 +752,11 @@ public class SettingsHelper {
this.settings = settings; this.settings = settings;
} }
protected OsmandSettingsItem(@NonNull OsmandSettings settings, @Nullable OsmandSettingsItem baseItem) {
super(settings.getContext(), baseItem);
this.settings = settings;
}
protected OsmandSettingsItem(@NonNull SettingsItemType type, @NonNull OsmandSettings settings, @NonNull JSONObject json) throws JSONException { protected OsmandSettingsItem(@NonNull SettingsItemType type, @NonNull OsmandSettings settings, @NonNull JSONObject json) throws JSONException {
super(settings.getContext(), json); super(settings.getContext(), json);
this.settings = settings; this.settings = settings;
@ -885,7 +895,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return new OsmandSettingsItemReader(this, getSettings()) { return new OsmandSettingsItemReader(this, getSettings()) {
@Override @Override
protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException { protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
@ -896,7 +906,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return new OsmandSettingsItemWriter(this, getSettings()) { return new OsmandSettingsItemWriter(this, getSettings()) {
@Override @Override
protected void writePreferenceToJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException { protected void writePreferenceToJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
@ -920,8 +930,8 @@ public class SettingsHelper {
this.appMode = appMode; this.appMode = appMode;
} }
public ProfileSettingsItem(@NonNull OsmandApplication app, @NonNull ApplicationModeBean modeBean) { public ProfileSettingsItem(@NonNull OsmandApplication app, @Nullable ProfileSettingsItem baseItem, @NonNull ApplicationModeBean modeBean) {
super(app.getSettings()); super(app.getSettings(), baseItem);
this.modeBean = modeBean; this.modeBean = modeBean;
builder = ApplicationMode.fromModeBean(app, modeBean); builder = ApplicationMode.fromModeBean(app, modeBean);
appMode = builder.getApplicationMode(); appMode = builder.getApplicationMode();
@ -1059,7 +1069,7 @@ public class SettingsHelper {
if (additionalPrefsJson != null) { if (additionalPrefsJson != null) {
updatePluginResPrefs(); updatePluginResPrefs();
SettingsItemReader reader = getReader(); SettingsItemReader<? extends SettingsItem> reader = getReader();
if (reader instanceof OsmandSettingsItemReader) { if (reader instanceof OsmandSettingsItemReader) {
((OsmandSettingsItemReader) reader).readPreferencesFromJson(additionalPrefsJson); ((OsmandSettingsItemReader) reader).readPreferencesFromJson(additionalPrefsJson);
} }
@ -1116,7 +1126,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return new OsmandSettingsItemReader(this, getSettings()) { return new OsmandSettingsItemReader(this, getSettings()) {
@Override @Override
protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException { protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
@ -1129,7 +1139,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return new OsmandSettingsItemWriter(this, getSettings()) { return new OsmandSettingsItemWriter(this, getSettings()) {
@Override @Override
protected void writePreferenceToJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException { protected void writePreferenceToJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
@ -1182,7 +1192,7 @@ public class SettingsHelper {
public StreamSettingsItem(@NonNull OsmandApplication app, @NonNull String name) { public StreamSettingsItem(@NonNull OsmandApplication app, @NonNull String name) {
super(app); super(app);
this.name = name; this.name = name;
setFileName(name); this.fileName = name;
} }
StreamSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { StreamSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
@ -1193,7 +1203,7 @@ public class SettingsHelper {
super(app); super(app);
this.inputStream = inputStream; this.inputStream = inputStream;
this.name = name; this.name = name;
setFileName(name); this.fileName = name;
} }
@Nullable @Nullable
@ -1231,7 +1241,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
public SettingsItemWriter getWriter() { public SettingsItemWriter<? extends SettingsItem> getWriter() {
return new StreamSettingsItemWriter(this); return new StreamSettingsItemWriter(this);
} }
} }
@ -1282,7 +1292,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return new StreamSettingsItemReader(this) { return new StreamSettingsItemReader(this) {
@Override @Override
public void readFromStream(@NonNull InputStream inputStream) throws IOException, IllegalArgumentException { public void readFromStream(@NonNull InputStream inputStream) throws IOException, IllegalArgumentException {
@ -1301,7 +1311,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
public SettingsItemWriter getWriter() { public SettingsItemWriter<? extends SettingsItem> getWriter() {
setInputStream(new ByteArrayInputStream(data)); setInputStream(new ByteArrayInputStream(data));
return super.getWriter(); return super.getWriter();
} }
@ -1370,6 +1380,7 @@ public class SettingsHelper {
return UNKNOWN; return UNKNOWN;
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return subtypeName; return subtypeName;
@ -1480,7 +1491,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return new StreamSettingsItemReader(this) { return new StreamSettingsItemReader(this) {
@Override @Override
public void readFromStream(@NonNull InputStream inputStream) throws IOException, IllegalArgumentException { public void readFromStream(@NonNull InputStream inputStream) throws IOException, IllegalArgumentException {
@ -1509,7 +1520,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
public SettingsItemWriter getWriter() { public SettingsItemWriter<? extends SettingsItem> getWriter() {
try { try {
setInputStream(new FileInputStream(file)); setInputStream(new FileInputStream(file));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
@ -1527,7 +1538,7 @@ public class SettingsHelper {
shouldReplace = true; shouldReplace = true;
String fileName = getFileName(); String fileName = getFileName();
if (!Algorithms.isEmpty(fileName) && !fileName.endsWith(File.separator)) { if (!Algorithms.isEmpty(fileName) && !fileName.endsWith(File.separator)) {
setFileName(fileName + File.separator); this.fileName = fileName + File.separator;
} }
} }
@ -1575,7 +1586,7 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
public SettingsItemWriter getWriter() { public SettingsItemWriter<? extends SettingsItem> getWriter() {
return null; return null;
} }
} }
@ -1585,7 +1596,11 @@ public class SettingsHelper {
private QuickActionRegistry actionRegistry; private QuickActionRegistry actionRegistry;
public QuickActionsSettingsItem(@NonNull OsmandApplication app, @NonNull List<QuickAction> items) { public QuickActionsSettingsItem(@NonNull OsmandApplication app, @NonNull List<QuickAction> items) {
super(app, items); super(app, null, items);
}
public QuickActionsSettingsItem(@NonNull OsmandApplication app, @Nullable QuickActionsSettingsItem baseItem, @NonNull List<QuickAction> items) {
super(app, baseItem, items);
} }
QuickActionsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { QuickActionsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
@ -1725,24 +1740,28 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return getJsonReader(); return getJsonReader();
} }
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return null; return null;
} }
} }
public static class PoiUiFilterSettingsItem extends CollectionSettingsItem<PoiUIFilter> { public static class PoiUiFiltersSettingsItem extends CollectionSettingsItem<PoiUIFilter> {
public PoiUiFilterSettingsItem(@NonNull OsmandApplication app, @NonNull List<PoiUIFilter> items) { public PoiUiFiltersSettingsItem(@NonNull OsmandApplication app, @NonNull List<PoiUIFilter> items) {
super(app, items); super(app, null, items);
} }
PoiUiFilterSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { public PoiUiFiltersSettingsItem(@NonNull OsmandApplication app, @Nullable PoiUiFiltersSettingsItem baseItem, @NonNull List<PoiUIFilter> items) {
super(app, baseItem, items);
}
PoiUiFiltersSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
super(app, json); super(app, json);
} }
@ -1873,13 +1892,13 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return getJsonReader(); return getJsonReader();
} }
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return null; return null;
} }
} }
@ -1889,7 +1908,11 @@ public class SettingsHelper {
private List<String> existingItemsNames; private List<String> existingItemsNames;
public MapSourcesSettingsItem(@NonNull OsmandApplication app, @NonNull List<ITileSource> items) { public MapSourcesSettingsItem(@NonNull OsmandApplication app, @NonNull List<ITileSource> items) {
super(app, items); super(app, null, items);
}
public MapSourcesSettingsItem(@NonNull OsmandApplication app, @Nullable MapSourcesSettingsItem baseItem, @NonNull List<ITileSource> items) {
super(app, baseItem, items);
} }
MapSourcesSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { MapSourcesSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
@ -2085,13 +2108,13 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return getJsonReader(); return getJsonReader();
} }
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return null; return null;
} }
} }
@ -2102,7 +2125,11 @@ public class SettingsHelper {
private AvoidSpecificRoads specificRoads; private AvoidSpecificRoads specificRoads;
public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull List<AvoidRoadInfo> items) { public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull List<AvoidRoadInfo> items) {
super(app, items); super(app, null, items);
}
public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @Nullable AvoidRoadsSettingsItem baseItem, @NonNull List<AvoidRoadInfo> items) {
super(app, baseItem, items);
} }
AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
@ -2240,13 +2267,13 @@ public class SettingsHelper {
@Nullable @Nullable
@Override @Override
SettingsItemReader getReader() { SettingsItemReader<? extends SettingsItem> getReader() {
return getJsonReader(); return getJsonReader();
} }
@Nullable @Nullable
@Override @Override
SettingsItemWriter getWriter() { SettingsItemWriter<? extends SettingsItem> getWriter() {
return null; return null;
} }
} }
@ -2256,7 +2283,7 @@ public class SettingsHelper {
private OsmandApplication app; private OsmandApplication app;
private List<SettingsItem> items = new ArrayList<>(); private List<SettingsItem> items = new ArrayList<>();
SettingsItemsFactory(OsmandApplication app, String jsonStr) throws IllegalArgumentException, JSONException { SettingsItemsFactory(@NonNull OsmandApplication app, String jsonStr) throws IllegalArgumentException, JSONException {
this.app = app; this.app = app;
collectItems(new JSONObject(jsonStr)); collectItems(new JSONObject(jsonStr));
} }
@ -2346,7 +2373,7 @@ public class SettingsHelper {
item = new QuickActionsSettingsItem(app, json); item = new QuickActionsSettingsItem(app, json);
break; break;
case POI_UI_FILTERS: case POI_UI_FILTERS:
item = new PoiUiFilterSettingsItem(app, json); item = new PoiUiFiltersSettingsItem(app, json);
break; break;
case MAP_SOURCES: case MAP_SOURCES:
item = new MapSourcesSettingsItem(app, json); item = new MapSourcesSettingsItem(app, json);
@ -2410,7 +2437,7 @@ public class SettingsHelper {
private void writeItemFiles(ZipOutputStream zos) throws IOException { private void writeItemFiles(ZipOutputStream zos) throws IOException {
for (SettingsItem item : items.values()) { for (SettingsItem item : items.values()) {
SettingsItemWriter writer = item.getWriter(); SettingsItemWriter<? extends SettingsItem> writer = item.getWriter();
if (writer != null) { if (writer != null) {
String fileName = item.getFileName(); String fileName = item.getFileName();
if (Algorithms.isEmpty(fileName)) { if (Algorithms.isEmpty(fileName)) {
@ -2520,7 +2547,7 @@ public class SettingsHelper {
if (item != null && collecting && item.shouldReadOnCollecting() if (item != null && collecting && item.shouldReadOnCollecting()
|| item != null && !collecting && !item.shouldReadOnCollecting()) { || item != null && !collecting && !item.shouldReadOnCollecting()) {
try { try {
SettingsItemReader reader = item.getReader(); SettingsItemReader<? extends SettingsItem> reader = item.getReader();
if (reader != null) { if (reader != null) {
reader.readFromStream(ois); reader.readFromStream(ois);
} }
@ -2699,8 +2726,8 @@ public class SettingsHelper {
if (item.exists()) { if (item.exists()) {
duplicateItems.add(((ProfileSettingsItem) item).getModeBean()); duplicateItems.add(((ProfileSettingsItem) item).getModeBean());
} }
} else if (item instanceof CollectionSettingsItem) { } else if (item instanceof CollectionSettingsItem<?>) {
List duplicates = ((CollectionSettingsItem) item).processDuplicateItems(); List<?> duplicates = ((CollectionSettingsItem<?>) item).processDuplicateItems();
if (!duplicates.isEmpty()) { if (!duplicates.isEmpty()) {
duplicateItems.addAll(duplicates); duplicateItems.addAll(duplicates);
} }

View file

@ -49,7 +49,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
private static final Log LOG = PlatformUtil.getLog(ExportImportSettingsAdapter.class.getName()); private static final Log LOG = PlatformUtil.getLog(ExportImportSettingsAdapter.class.getName());
private OsmandApplication app; private OsmandApplication app;
private UiUtilities uiUtilities; private UiUtilities uiUtilities;
private List<? super Object> dataToOperate; private List<? super Object> data;
private Map<Type, List<?>> itemsMap; private Map<Type, List<?>> itemsMap;
private List<Type> itemsTypes; private List<Type> itemsTypes;
private boolean nightMode; private boolean nightMode;
@ -63,8 +63,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
this.importState = importState; this.importState = importState;
this.itemsMap = new HashMap<>(); this.itemsMap = new HashMap<>();
this.itemsTypes = new ArrayList<>(); this.itemsTypes = new ArrayList<>();
this.dataToOperate = new ArrayList<>(); this.data = new ArrayList<>();
dataToOperate = new ArrayList<>();
uiUtilities = app.getUIUtilities(); uiUtilities = app.getUIUtilities();
activeColorRes = nightMode activeColorRes = nightMode
? R.color.icon_color_active_dark ? R.color.icon_color_active_dark
@ -102,12 +101,12 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
final List<?> listItems = itemsMap.get(type); final List<?> listItems = itemsMap.get(type);
subTextTv.setText(getSelectedItemsAmount(listItems)); subTextTv.setText(getSelectedItemsAmount(listItems));
if (dataToOperate.containsAll(listItems)) { if (data.containsAll(listItems)) {
checkBox.setState(CHECKED); checkBox.setState(CHECKED);
} else { } else {
boolean contains = false; boolean contains = false;
for (Object object : listItems) { for (Object object : listItems) {
if (dataToOperate.contains(object)) { if (data.contains(object)) {
contains = true; contains = true;
break; break;
} }
@ -122,12 +121,12 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
checkBox.performClick(); checkBox.performClick();
if (checkBox.getState() == CHECKED) { if (checkBox.getState() == CHECKED) {
for (Object object : listItems) { for (Object object : listItems) {
if (!dataToOperate.contains(object)) { if (!data.contains(object)) {
dataToOperate.add(object); data.add(object);
} }
} }
} else { } else {
dataToOperate.removeAll(listItems); data.removeAll(listItems);
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }
@ -146,7 +145,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
final Object currentItem = itemsMap.get(itemsTypes.get(groupPosition)).get(childPosition); final Object currentItem = itemsMap.get(itemsTypes.get(groupPosition)).get(childPosition);
boolean isLastGroup = groupPosition == getGroupCount() - 1; boolean isLastGroup = groupPosition == getGroupCount() - 1;
boolean itemSelected = dataToOperate.contains(currentItem); boolean itemSelected = data.contains(currentItem);
final Type type = itemsTypes.get(groupPosition); final Type type = itemsTypes.get(groupPosition);
TextView title = child.findViewById(R.id.title_tv); TextView title = child.findViewById(R.id.title_tv);
@ -166,10 +165,10 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
child.setOnClickListener(new View.OnClickListener() { child.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (dataToOperate.contains(currentItem)) { if (data.contains(currentItem)) {
dataToOperate.remove(currentItem); data.remove(currentItem);
} else { } else {
dataToOperate.add(currentItem); data.add(currentItem);
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }
@ -293,7 +292,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
private String getSelectedItemsAmount(List<?> listItems) { private String getSelectedItemsAmount(List<?> listItems) {
int amount = 0; int amount = 0;
for (Object item : listItems) { for (Object item : listItems) {
if (dataToOperate.contains(item)) { if (data.contains(item)) {
amount++; amount++;
} }
} }
@ -343,17 +342,17 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
} }
public void selectAll(boolean selectAll) { public void selectAll(boolean selectAll) {
dataToOperate.clear(); data.clear();
if (selectAll) { if (selectAll) {
for (List<?> values : itemsMap.values()) { for (List<?> values : itemsMap.values()) {
dataToOperate.addAll(values); data.addAll(values);
} }
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }
List<? super Object> getDataToOperate() { List<? super Object> getData() {
return this.dataToOperate; return this.data;
} }
public enum Type { public enum Type {

View file

@ -26,6 +26,7 @@ import net.osmand.PlatformUtil;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.map.ITileSource; import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.SQLiteTileSource;
@ -40,7 +41,12 @@ import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionRegistry; import net.osmand.plus.quickaction.QuickActionRegistry;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.SettingsHelper; import net.osmand.plus.settings.backend.SettingsHelper;
import net.osmand.plus.settings.backend.SettingsHelper.AvoidRoadsSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.FileSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.FileSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.MapSourcesSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.PoiUiFiltersSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.ProfileSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.QuickActionsSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.SettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.SettingsItem;
import net.osmand.plus.settings.bottomsheets.BasePreferenceBottomSheet; import net.osmand.plus.settings.bottomsheets.BasePreferenceBottomSheet;
import net.osmand.plus.settings.fragments.ExportImportSettingsAdapter.Type; import net.osmand.plus.settings.fragments.ExportImportSettingsAdapter.Type;
@ -274,7 +280,7 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
private List<SettingsItem> prepareSettingsItemsForExport() { private List<SettingsItem> prepareSettingsItemsForExport() {
List<SettingsItem> settingsItems = new ArrayList<>(); List<SettingsItem> settingsItems = new ArrayList<>();
settingsItems.add(new SettingsHelper.ProfileSettingsItem(app, profile)); settingsItems.add(new ProfileSettingsItem(app, profile));
if (includeAdditionalData) { if (includeAdditionalData) {
settingsItems.addAll(prepareAdditionalSettingsItems()); settingsItems.addAll(prepareAdditionalSettingsItems());
} }
@ -287,13 +293,12 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
List<PoiUIFilter> poiUIFilters = new ArrayList<>(); List<PoiUIFilter> poiUIFilters = new ArrayList<>();
List<ITileSource> tileSourceTemplates = new ArrayList<>(); List<ITileSource> tileSourceTemplates = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>(); List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
for (Object object : adapter.getDataToOperate()) { for (Object object : adapter.getData()) {
if (object instanceof QuickAction) { if (object instanceof QuickAction) {
quickActions.add((QuickAction) object); quickActions.add((QuickAction) object);
} else if (object instanceof PoiUIFilter) { } else if (object instanceof PoiUIFilter) {
poiUIFilters.add((PoiUIFilter) object); poiUIFilters.add((PoiUIFilter) object);
} else if (object instanceof TileSourceManager.TileSourceTemplate } else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
|| object instanceof SQLiteTileSource) {
tileSourceTemplates.add((ITileSource) object); tileSourceTemplates.add((ITileSource) object);
} else if (object instanceof File) { } else if (object instanceof File) {
try { try {
@ -306,16 +311,16 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
} }
} }
if (!quickActions.isEmpty()) { if (!quickActions.isEmpty()) {
settingsItems.add(new SettingsHelper.QuickActionsSettingsItem(app, quickActions)); settingsItems.add(new QuickActionsSettingsItem(app, quickActions));
} }
if (!poiUIFilters.isEmpty()) { if (!poiUIFilters.isEmpty()) {
settingsItems.add(new SettingsHelper.PoiUiFilterSettingsItem(app, poiUIFilters)); settingsItems.add(new PoiUiFiltersSettingsItem(app, poiUIFilters));
} }
if (!tileSourceTemplates.isEmpty()) { if (!tileSourceTemplates.isEmpty()) {
settingsItems.add(new SettingsHelper.MapSourcesSettingsItem(app, tileSourceTemplates)); settingsItems.add(new MapSourcesSettingsItem(app, tileSourceTemplates));
} }
if (!avoidRoads.isEmpty()) { if (!avoidRoads.isEmpty()) {
settingsItems.add(new SettingsHelper.AvoidRoadsSettingsItem(app, avoidRoads)); settingsItems.add(new AvoidRoadsSettingsItem(app, avoidRoads));
} }
return settingsItems; return settingsItems;
} }

View file

@ -36,7 +36,6 @@ import java.util.List;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.settings.fragments.ImportSettingsFragment.IMPORT_SETTINGS_TAG; import static net.osmand.plus.settings.fragments.ImportSettingsFragment.IMPORT_SETTINGS_TAG;
import static net.osmand.plus.settings.fragments.ImportSettingsFragment.getSettingsToOperate;
public class ImportCompleteFragment extends BaseOsmAndFragment { public class ImportCompleteFragment extends BaseOsmAndFragment {
public static final String TAG = ImportCompleteFragment.class.getSimpleName(); public static final String TAG = ImportCompleteFragment.class.getSimpleName();
@ -111,7 +110,7 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
if (settingsItems != null) { if (settingsItems != null) {
ImportedSettingsItemsAdapter adapter = new ImportedSettingsItemsAdapter( ImportedSettingsItemsAdapter adapter = new ImportedSettingsItemsAdapter(
app, app,
getSettingsToOperate(settingsItems, true), ImportSettingsFragment.getSettingsToOperate(settingsItems, true),
nightMode, nightMode,
new ImportedSettingsItemsAdapter.OnItemClickListener() { new ImportedSettingsItemsAdapter.OnItemClickListener() {
@Override @Override

View file

@ -28,12 +28,12 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.map.ITileSource; import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.plus.settings.backend.SettingsHelper; import net.osmand.plus.settings.backend.SettingsHelper;
import net.osmand.plus.settings.backend.SettingsHelper.AvoidRoadsSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.AvoidRoadsSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.FileSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.FileSettingsItem;
@ -41,7 +41,7 @@ import net.osmand.plus.settings.backend.SettingsHelper.FileSettingsItem.FileSubt
import net.osmand.plus.settings.backend.SettingsHelper.ImportAsyncTask; import net.osmand.plus.settings.backend.SettingsHelper.ImportAsyncTask;
import net.osmand.plus.settings.backend.SettingsHelper.ImportType; import net.osmand.plus.settings.backend.SettingsHelper.ImportType;
import net.osmand.plus.settings.backend.SettingsHelper.MapSourcesSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.MapSourcesSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.PoiUiFilterSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.PoiUiFiltersSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.ProfileSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.ProfileSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.QuickActionsSettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.QuickActionsSettingsItem;
import net.osmand.plus.settings.backend.SettingsHelper.SettingsItem; import net.osmand.plus.settings.backend.SettingsHelper.SettingsItem;
@ -54,6 +54,7 @@ import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.settings.fragments.ExportImportSettingsAdapter.Type; import net.osmand.plus.settings.fragments.ExportImportSettingsAdapter.Type;
import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -218,7 +219,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
break; break;
} }
case R.id.continue_button: { case R.id.continue_button: {
if (adapter.getDataToOperate().isEmpty()) { if (adapter.getData().isEmpty()) {
app.showShortToastMessage(getString(R.string.shared_string_nothing_selected)); app.showShortToastMessage(getString(R.string.shared_string_nothing_selected));
} else { } else {
importItems(); importItems();
@ -244,7 +245,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
private void importItems() { private void importItems() {
updateUi(R.string.shared_string_preparing, R.string.checking_for_duplicate_description); updateUi(R.string.shared_string_preparing, R.string.checking_for_duplicate_description);
List<SettingsItem> selectedItems = getSettingsItemsFromData(adapter.getDataToOperate()); List<SettingsItem> selectedItems = getSettingsItemsFromData(adapter.getData());
if (file != null && settingsItems != null) { if (file != null && settingsItems != null) {
duplicateStartTime = System.currentTimeMillis(); duplicateStartTime = System.currentTimeMillis();
settingsHelper.checkDuplicates(file, settingsItems, selectedItems, getDuplicatesListener()); settingsHelper.checkDuplicates(file, settingsItems, selectedItems, getDuplicatesListener());
@ -316,22 +317,75 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
this.settingsItems = settingsItems; this.settingsItems = settingsItems;
} }
private List<SettingsItem> getSettingsItemsFromData(List<Object> dataToOperate) { @Nullable
private ProfileSettingsItem getBaseProfileSettingsItem(ApplicationModeBean modeBean) {
for (SettingsItem settingsItem : settingsItems) {
if (settingsItem.getType() == SettingsItemType.PROFILE) {
ProfileSettingsItem profileItem = (ProfileSettingsItem) settingsItem;
ApplicationModeBean bean = profileItem.getModeBean();
if (Algorithms.objectEquals(bean.stringKey, modeBean.stringKey) && Algorithms.objectEquals(bean.userProfileName, modeBean.userProfileName)) {
return profileItem;
}
}
}
return null;
}
@Nullable
private QuickActionsSettingsItem getBaseQuickActionsSettingsItem() {
for (SettingsItem settingsItem : settingsItems) {
if (settingsItem.getType() == SettingsItemType.QUICK_ACTIONS) {
return (QuickActionsSettingsItem) settingsItem;
}
}
return null;
}
@Nullable
private PoiUiFiltersSettingsItem getBasePoiUiFiltersSettingsItem() {
for (SettingsItem settingsItem : settingsItems) {
if (settingsItem.getType() == SettingsItemType.POI_UI_FILTERS) {
return (PoiUiFiltersSettingsItem) settingsItem;
}
}
return null;
}
@Nullable
private MapSourcesSettingsItem getBaseMapSourcesSettingsItem() {
for (SettingsItem settingsItem : settingsItems) {
if (settingsItem.getType() == SettingsItemType.MAP_SOURCES) {
return (MapSourcesSettingsItem) settingsItem;
}
}
return null;
}
@Nullable
private AvoidRoadsSettingsItem getBaseAvoidRoadsSettingsItem() {
for (SettingsItem settingsItem : settingsItems) {
if (settingsItem.getType() == SettingsItemType.AVOID_ROADS) {
return (AvoidRoadsSettingsItem) settingsItem;
}
}
return null;
}
private List<SettingsItem> getSettingsItemsFromData(List<?> data) {
List<SettingsItem> settingsItems = new ArrayList<>(); List<SettingsItem> settingsItems = new ArrayList<>();
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
List<QuickAction> quickActions = new ArrayList<>(); List<QuickAction> quickActions = new ArrayList<>();
List<PoiUIFilter> poiUIFilters = new ArrayList<>(); List<PoiUIFilter> poiUIFilters = new ArrayList<>();
List<ITileSource> tileSourceTemplates = new ArrayList<>(); List<ITileSource> tileSourceTemplates = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>(); List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
for (Object object : dataToOperate) { for (Object object : data) {
if (object instanceof ApplicationMode.ApplicationModeBean) { if (object instanceof ApplicationModeBean) {
settingsItems.add(new SettingsHelper.ProfileSettingsItem(app, (ApplicationMode.ApplicationModeBean) object)); appModeBeans.add((ApplicationModeBean) object);
} } else if (object instanceof QuickAction) {
if (object instanceof QuickAction) {
quickActions.add((QuickAction) object); quickActions.add((QuickAction) object);
} else if (object instanceof PoiUIFilter) { } else if (object instanceof PoiUIFilter) {
poiUIFilters.add((PoiUIFilter) object); poiUIFilters.add((PoiUIFilter) object);
} else if (object instanceof TileSourceManager.TileSourceTemplate } else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
|| object instanceof SQLiteTileSource) {
tileSourceTemplates.add((ITileSource) object); tileSourceTemplates.add((ITileSource) object);
} else if (object instanceof File) { } else if (object instanceof File) {
settingsItems.add(new FileSettingsItem(app, (File) object)); settingsItems.add(new FileSettingsItem(app, (File) object));
@ -339,69 +393,82 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
avoidRoads.add((AvoidRoadInfo) object); avoidRoads.add((AvoidRoadInfo) object);
} }
} }
if (!appModeBeans.isEmpty()) {
for (ApplicationModeBean modeBean : appModeBeans) {
settingsItems.add(new ProfileSettingsItem(app, getBaseProfileSettingsItem(modeBean), modeBean));
}
}
if (!quickActions.isEmpty()) { if (!quickActions.isEmpty()) {
settingsItems.add(new QuickActionsSettingsItem(app, quickActions)); settingsItems.add(new QuickActionsSettingsItem(app, getBaseQuickActionsSettingsItem(), quickActions));
} }
if (!poiUIFilters.isEmpty()) { if (!poiUIFilters.isEmpty()) {
settingsItems.add(new SettingsHelper.PoiUiFilterSettingsItem(app, poiUIFilters)); settingsItems.add(new PoiUiFiltersSettingsItem(app, getBasePoiUiFiltersSettingsItem(), poiUIFilters));
} }
if (!tileSourceTemplates.isEmpty()) { if (!tileSourceTemplates.isEmpty()) {
settingsItems.add(new SettingsHelper.MapSourcesSettingsItem(app, tileSourceTemplates)); settingsItems.add(new MapSourcesSettingsItem(app, getBaseMapSourcesSettingsItem(), tileSourceTemplates));
} }
if (!avoidRoads.isEmpty()) { if (!avoidRoads.isEmpty()) {
settingsItems.add(new SettingsHelper.AvoidRoadsSettingsItem(app, avoidRoads)); settingsItems.add(new AvoidRoadsSettingsItem(app, getBaseAvoidRoadsSettingsItem(), avoidRoads));
} }
return settingsItems; return settingsItems;
} }
public static Map<Type, List<?>> getSettingsToOperate(List<SettingsItem> settingsItems, boolean importComplete) { public static Map<Type, List<?>> getSettingsToOperate(List<SettingsItem> settingsItems, boolean importComplete) {
Map<Type, List<?>> settingsToOperate = new HashMap<>(); Map<Type, List<?>> settingsToOperate = new HashMap<>();
List<ApplicationMode.ApplicationModeBean> profiles = new ArrayList<>(); List<ApplicationModeBean> profiles = new ArrayList<>();
List<QuickAction> quickActions = new ArrayList<>(); List<QuickAction> quickActions = new ArrayList<>();
List<PoiUIFilter> poiUIFilters = new ArrayList<>(); List<PoiUIFilter> poiUIFilters = new ArrayList<>();
List<ITileSource> tileSourceTemplates = new ArrayList<>(); List<ITileSource> tileSourceTemplates = new ArrayList<>();
List<File> routingFilesList = new ArrayList<>(); List<File> routingFilesList = new ArrayList<>();
List<File> renderFilesList = new ArrayList<>(); List<File> renderFilesList = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>(); List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
for (SettingsItem item : settingsItems) { for (SettingsItem item : settingsItems) {
if (item.getType().equals(SettingsItemType.PROFILE)) { switch (item.getType()) {
profiles.add(((ProfileSettingsItem) item).getModeBean()); case PROFILE:
} else if (item.getType().equals(SettingsItemType.QUICK_ACTIONS)) { profiles.add(((ProfileSettingsItem) item).getModeBean());
QuickActionsSettingsItem quickActionsItem = (QuickActionsSettingsItem) item; break;
if (importComplete) { case FILE:
quickActions.addAll(quickActionsItem.getAppliedItems()); FileSettingsItem fileItem = (FileSettingsItem) item;
} else { if (fileItem.getSubtype() == FileSubtype.RENDERING_STYLE) {
quickActions.addAll(quickActionsItem.getItems()); renderFilesList.add(fileItem.getFile());
} } else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) {
} else if (item.getType().equals(SettingsItemType.POI_UI_FILTERS)) { routingFilesList.add(fileItem.getFile());
PoiUiFilterSettingsItem poiUiFilterItem = (PoiUiFilterSettingsItem) item; }
if (importComplete) { break;
poiUIFilters.addAll(poiUiFilterItem.getAppliedItems()); case QUICK_ACTIONS:
} else { QuickActionsSettingsItem quickActionsItem = (QuickActionsSettingsItem) item;
poiUIFilters.addAll(poiUiFilterItem.getItems()); if (importComplete) {
} quickActions.addAll(quickActionsItem.getAppliedItems());
} else if (item.getType().equals(SettingsItemType.MAP_SOURCES)) { } else {
MapSourcesSettingsItem mapSourcesItem = (MapSourcesSettingsItem) item; quickActions.addAll(quickActionsItem.getItems());
if (importComplete) { }
tileSourceTemplates.addAll(mapSourcesItem.getAppliedItems()); break;
} else { case POI_UI_FILTERS:
tileSourceTemplates.addAll(mapSourcesItem.getItems()); PoiUiFiltersSettingsItem poiUiFilterItem = (PoiUiFiltersSettingsItem) item;
} if (importComplete) {
} else if (item.getType().equals(SettingsItemType.FILE)) { poiUIFilters.addAll(poiUiFilterItem.getAppliedItems());
FileSettingsItem fileItem = (FileSettingsItem) item; } else {
if (fileItem.getSubtype() == FileSubtype.RENDERING_STYLE) { poiUIFilters.addAll(poiUiFilterItem.getItems());
renderFilesList.add(fileItem.getFile()); }
} else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) { break;
routingFilesList.add(fileItem.getFile()); case MAP_SOURCES:
} MapSourcesSettingsItem mapSourcesItem = (MapSourcesSettingsItem) item;
} else if (item.getType().equals(SettingsItemType.AVOID_ROADS)) { if (importComplete) {
AvoidRoadsSettingsItem avoidRoadsItem = (AvoidRoadsSettingsItem) item; tileSourceTemplates.addAll(mapSourcesItem.getAppliedItems());
if (importComplete) { } else {
avoidRoads.addAll(avoidRoadsItem.getAppliedItems()); tileSourceTemplates.addAll(mapSourcesItem.getItems());
} else { }
avoidRoads.addAll(avoidRoadsItem.getItems()); break;
} case AVOID_ROADS:
AvoidRoadsSettingsItem avoidRoadsItem = (AvoidRoadsSettingsItem) item;
if (importComplete) {
avoidRoads.addAll(avoidRoadsItem.getAppliedItems());
} else {
avoidRoads.addAll(avoidRoadsItem.getItems());
}
break;
default:
break;
} }
} }

View file

@ -92,9 +92,8 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
private void drawPoint(Canvas canvas, float x, float y, boolean active) { private void drawPoint(Canvas canvas, float x, float y, boolean active) {
float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get();
float left = x - roadWorkIcon.getWidth() / 2f * textScale; y -= roadWorkIcon.getHeight() / 2f * textScale;
float top = y - roadWorkIcon.getHeight() * textScale; Rect destRect = getIconDestinationRect(x, y, roadWorkIcon.getWidth(), roadWorkIcon.getHeight(), textScale);
Rect destRect = getIconDestinationRect(left, top, roadWorkIcon.getWidth(), roadWorkIcon.getHeight(), textScale);
canvas.drawBitmap(roadWorkIcon, null, destRect, active ? activePaint : paint); canvas.drawBitmap(roadWorkIcon, null, destRect, active ? activePaint : paint);
} }