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

View file

@ -9,14 +9,14 @@
<string name="about_version">Версія:</string>
<string name="shared_string_about">Пра праграму</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_downloadable">Можна спампаваць: %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_name">Даныя фрагменту: %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_expiration_time">Тэрмін дзеяння (у хвілінах)</string>
<string name="edit_tilesource_minzoom">Мінімальнае павелічэнне</string>
@ -2071,7 +2071,7 @@
<string name="osm_live_banner_desc">Атрымайце неабмежаваную колькасць спампоўванняў мапаў у дадатак да штотыднёвых, штодзённых і нават штогадзінных абнаўленняў.</string>
<string name="osmand_plus_banner_desc">Неабмежаваная колькасць спамоўванняў мапаў, абнаўленняў і ўбудова Wikipedia.</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_desc">Частка вашага ахвяравання накіроўваецца ўдзельнікам праекта OpenStreetMap. Кошт падпіскі застаецца тым жа самым.</string>
<string name="osm_live_subscription_desc">Падпіска дазваляе атрымліваць штогадзіныя, штодзённыя, штотыднёвыя абнаўленні і неабмежаваную колькасць спампоўванняў для ўсіх мапаў па ўсім свеце.</string>
@ -2481,7 +2481,7 @@
\n</string>
<string name="shared_string_install">Усталяваць</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="mapillary_image">Выява Mapillary</string>
<string name="distance_moving">Дыстанцыя выпраўленая</string>
@ -3093,7 +3093,7 @@
<string name="edit_profile_setup_subtitle">У кожнага профілю свае налады</string>
<string name="turn_screen_on_time_descr">Вызначце час, цягам якога экран не будзе выключацца.</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_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="turn_screen_on_info">Паказваць мапу падчас навігацыі на заблакаваным экране.</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="appearance">Выгляд</string>
<string name="map_look_descr">Выгляд мапы</string>
@ -3327,7 +3327,7 @@
<string name="map_during_navigation_info">Мапа падчас навігацыі</string>
<string name="map_during_navigation">Мапа падчас навігацыі</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="voice_announces_info">Галасавыя апавяшчэнні прайграюцца толькі падчас навігацыі.</string>
<string name="voice_announces_descr">Навігацыйныя інструкцыі і апавяшчэнні</string>
@ -3535,7 +3535,7 @@
<string name="reset_deafult_order">Аднавіць прадвызначаны парадак элементаў</string>
<string name="back_to_editing">Вярнуцца да рэдагавання</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="n_items_of_z">%1$s з %2$s</string>
<string name="download_slope_maps">Схілы</string>
@ -3564,7 +3564,7 @@
<string name="shared_string_divider">Падзяляльнік</string>
<string name="shared_string_hidden">Схавана</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="developer_plugin">Убудова для распрацоўшчыкаў</string>
<string name="replace_point_descr">Замяніць іншы пункт на гэты.</string>
@ -3596,8 +3596,8 @@
<string name="lang_an">Арагонская</string>
<string name="custom_color">Адвольны колер</string>
<string name="search_poi_types">Пошук тыпаў POI</string>
<string name="quick_action_switch_profile_descr">Абраныя профілі пераключаюцца націскам на кнопку \"Дзеянне\".</string>
<string name="profiles_for_action_not_found">Профіляў, абраных для гэтага дзеяння, не знойдзена.</string>
<string name="quick_action_switch_profile_descr">Пры націсканні на кнопку \"Дзеянні\" пераключаюцца абраныя профілі.</string>
<string name="profiles_for_action_not_found">Адпаведных профіляў не знойдзена.</string>
<string name="lang_zhyue">Кантонская</string>
<string name="lang_yo">Ёруба</string>
<string name="lang_uz">Узбекская</string>
@ -3620,4 +3620,28 @@
<string name="quick_action_show_hide_transport">Паказаць/схаваць грамадскі транспарт</string>
<string name="recalculate_route_in_deviation">Пералічыць маршрут у выпадку адхілення</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>

View file

@ -3611,7 +3611,7 @@
<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="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="select_track_file">Elekti dosieron de spuro</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_go_cart">Go-kart</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>

View file

@ -1116,7 +1116,7 @@
<string name="poi_tactile_paving_yes">van</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_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_services">Pihenőhely</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_motorcycle_repair">Motorkerékpár-szerelés</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_no">Nem automatizált</string>
<string name="poi_full_service_yes">Teljes kiszolgálás</string>
<string name="poi_brushless_yes">igen</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_public_bath">Közfürdő</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_vibration">Rezgé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>

View file

@ -3810,15 +3810,16 @@
<string name="speed_cameras_removed_descr">Questo dispositivo non ha autovelox.</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="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">Pulsanti del volume come zoom</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 volume come zoom</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="search_download_wikipedia_maps">Scarica mappe Wikimedia</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="app_mode_enduro_motorcycle">Moto enduro</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 Wikipedia</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 da enduro</string>
<string name="app_mode_motor_scooter">Moto scooter</string>
<string name="app_mode_wheelchair">Sedia a rotelle</string>
<string name="app_mode_go_cart">Go-kart</string>
<string name="osm_edit_closed_note">Chiudi la nota OSM</string>
<string name="app_mode_wheelchair_forward">Sedia a rotelle</string>
</resources>

View file

@ -3817,4 +3817,7 @@
<string name="poi_traffic_signals_vibration_no">Вібрація: вимкнено</string>
<string name="poi_traffic_signals_arrow">Стрілка</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>

View file

@ -3810,4 +3810,9 @@
<string name="search_download_wikipedia_maps">Завантажити мапи Вікіпедії</string>
<string name="plugin_wikipedia_description">Отримайте відомості про визначні місця у Вікіпедії. Це ваш кишеньковий посібник без мережі - просто ввімкніть втулок \"Вікіпедія\" і насолоджуйтесь статтями про об\'єкти навколо вас.</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>

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

View file

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

View file

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

View file

@ -26,6 +26,7 @@ import net.osmand.PlatformUtil;
import net.osmand.data.LatLon;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
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.settings.backend.ApplicationMode;
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.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.bottomsheets.BasePreferenceBottomSheet;
import net.osmand.plus.settings.fragments.ExportImportSettingsAdapter.Type;
@ -274,7 +280,7 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
private List<SettingsItem> prepareSettingsItemsForExport() {
List<SettingsItem> settingsItems = new ArrayList<>();
settingsItems.add(new SettingsHelper.ProfileSettingsItem(app, profile));
settingsItems.add(new ProfileSettingsItem(app, profile));
if (includeAdditionalData) {
settingsItems.addAll(prepareAdditionalSettingsItems());
}
@ -287,13 +293,12 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
List<ITileSource> tileSourceTemplates = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
for (Object object : adapter.getDataToOperate()) {
for (Object object : adapter.getData()) {
if (object instanceof QuickAction) {
quickActions.add((QuickAction) object);
} else if (object instanceof PoiUIFilter) {
poiUIFilters.add((PoiUIFilter) object);
} else if (object instanceof TileSourceManager.TileSourceTemplate
|| object instanceof SQLiteTileSource) {
} else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
tileSourceTemplates.add((ITileSource) object);
} else if (object instanceof File) {
try {
@ -306,16 +311,16 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
}
}
if (!quickActions.isEmpty()) {
settingsItems.add(new SettingsHelper.QuickActionsSettingsItem(app, quickActions));
settingsItems.add(new QuickActionsSettingsItem(app, quickActions));
}
if (!poiUIFilters.isEmpty()) {
settingsItems.add(new SettingsHelper.PoiUiFilterSettingsItem(app, poiUIFilters));
settingsItems.add(new PoiUiFiltersSettingsItem(app, poiUIFilters));
}
if (!tileSourceTemplates.isEmpty()) {
settingsItems.add(new SettingsHelper.MapSourcesSettingsItem(app, tileSourceTemplates));
settingsItems.add(new MapSourcesSettingsItem(app, tileSourceTemplates));
}
if (!avoidRoads.isEmpty()) {
settingsItems.add(new SettingsHelper.AvoidRoadsSettingsItem(app, avoidRoads));
settingsItems.add(new AvoidRoadsSettingsItem(app, avoidRoads));
}
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.plus.settings.fragments.ImportSettingsFragment.IMPORT_SETTINGS_TAG;
import static net.osmand.plus.settings.fragments.ImportSettingsFragment.getSettingsToOperate;
public class ImportCompleteFragment extends BaseOsmAndFragment {
public static final String TAG = ImportCompleteFragment.class.getSimpleName();
@ -111,7 +110,7 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
if (settingsItems != null) {
ImportedSettingsItemsAdapter adapter = new ImportedSettingsItemsAdapter(
app,
getSettingsToOperate(settingsItems, true),
ImportSettingsFragment.getSettingsToOperate(settingsItems, true),
nightMode,
new ImportedSettingsItemsAdapter.OnItemClickListener() {
@Override

View file

@ -28,12 +28,12 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
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.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
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.AvoidRoadsSettingsItem;
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.ImportType;
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.QuickActionsSettingsItem;
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.settings.fragments.ExportImportSettingsAdapter.Type;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
@ -218,7 +219,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
break;
}
case R.id.continue_button: {
if (adapter.getDataToOperate().isEmpty()) {
if (adapter.getData().isEmpty()) {
app.showShortToastMessage(getString(R.string.shared_string_nothing_selected));
} else {
importItems();
@ -244,7 +245,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
private void importItems() {
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) {
duplicateStartTime = System.currentTimeMillis();
settingsHelper.checkDuplicates(file, settingsItems, selectedItems, getDuplicatesListener());
@ -316,22 +317,75 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
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<ApplicationModeBean> appModeBeans = new ArrayList<>();
List<QuickAction> quickActions = new ArrayList<>();
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
List<ITileSource> tileSourceTemplates = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
for (Object object : dataToOperate) {
if (object instanceof ApplicationMode.ApplicationModeBean) {
settingsItems.add(new SettingsHelper.ProfileSettingsItem(app, (ApplicationMode.ApplicationModeBean) object));
}
if (object instanceof QuickAction) {
for (Object object : data) {
if (object instanceof ApplicationModeBean) {
appModeBeans.add((ApplicationModeBean) object);
} else if (object instanceof QuickAction) {
quickActions.add((QuickAction) object);
} else if (object instanceof PoiUIFilter) {
poiUIFilters.add((PoiUIFilter) object);
} else if (object instanceof TileSourceManager.TileSourceTemplate
|| object instanceof SQLiteTileSource) {
} else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
tileSourceTemplates.add((ITileSource) object);
} else if (object instanceof File) {
settingsItems.add(new FileSettingsItem(app, (File) object));
@ -339,69 +393,82 @@ public class ImportSettingsFragment extends BaseOsmAndFragment
avoidRoads.add((AvoidRoadInfo) object);
}
}
if (!appModeBeans.isEmpty()) {
for (ApplicationModeBean modeBean : appModeBeans) {
settingsItems.add(new ProfileSettingsItem(app, getBaseProfileSettingsItem(modeBean), modeBean));
}
}
if (!quickActions.isEmpty()) {
settingsItems.add(new QuickActionsSettingsItem(app, quickActions));
settingsItems.add(new QuickActionsSettingsItem(app, getBaseQuickActionsSettingsItem(), quickActions));
}
if (!poiUIFilters.isEmpty()) {
settingsItems.add(new SettingsHelper.PoiUiFilterSettingsItem(app, poiUIFilters));
settingsItems.add(new PoiUiFiltersSettingsItem(app, getBasePoiUiFiltersSettingsItem(), poiUIFilters));
}
if (!tileSourceTemplates.isEmpty()) {
settingsItems.add(new SettingsHelper.MapSourcesSettingsItem(app, tileSourceTemplates));
settingsItems.add(new MapSourcesSettingsItem(app, getBaseMapSourcesSettingsItem(), tileSourceTemplates));
}
if (!avoidRoads.isEmpty()) {
settingsItems.add(new SettingsHelper.AvoidRoadsSettingsItem(app, avoidRoads));
settingsItems.add(new AvoidRoadsSettingsItem(app, getBaseAvoidRoadsSettingsItem(), avoidRoads));
}
return settingsItems;
}
public static Map<Type, List<?>> getSettingsToOperate(List<SettingsItem> settingsItems, boolean importComplete) {
Map<Type, List<?>> settingsToOperate = new HashMap<>();
List<ApplicationMode.ApplicationModeBean> profiles = new ArrayList<>();
List<ApplicationModeBean> profiles = new ArrayList<>();
List<QuickAction> quickActions = new ArrayList<>();
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
List<ITileSource> tileSourceTemplates = new ArrayList<>();
List<File> routingFilesList = new ArrayList<>();
List<File> renderFilesList = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
for (SettingsItem item : settingsItems) {
if (item.getType().equals(SettingsItemType.PROFILE)) {
profiles.add(((ProfileSettingsItem) item).getModeBean());
} else if (item.getType().equals(SettingsItemType.QUICK_ACTIONS)) {
QuickActionsSettingsItem quickActionsItem = (QuickActionsSettingsItem) item;
if (importComplete) {
quickActions.addAll(quickActionsItem.getAppliedItems());
} else {
quickActions.addAll(quickActionsItem.getItems());
}
} else if (item.getType().equals(SettingsItemType.POI_UI_FILTERS)) {
PoiUiFilterSettingsItem poiUiFilterItem = (PoiUiFilterSettingsItem) item;
if (importComplete) {
poiUIFilters.addAll(poiUiFilterItem.getAppliedItems());
} else {
poiUIFilters.addAll(poiUiFilterItem.getItems());
}
} else if (item.getType().equals(SettingsItemType.MAP_SOURCES)) {
MapSourcesSettingsItem mapSourcesItem = (MapSourcesSettingsItem) item;
if (importComplete) {
tileSourceTemplates.addAll(mapSourcesItem.getAppliedItems());
} else {
tileSourceTemplates.addAll(mapSourcesItem.getItems());
}
} else if (item.getType().equals(SettingsItemType.FILE)) {
FileSettingsItem fileItem = (FileSettingsItem) item;
if (fileItem.getSubtype() == FileSubtype.RENDERING_STYLE) {
renderFilesList.add(fileItem.getFile());
} else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) {
routingFilesList.add(fileItem.getFile());
}
} else if (item.getType().equals(SettingsItemType.AVOID_ROADS)) {
AvoidRoadsSettingsItem avoidRoadsItem = (AvoidRoadsSettingsItem) item;
if (importComplete) {
avoidRoads.addAll(avoidRoadsItem.getAppliedItems());
} else {
avoidRoads.addAll(avoidRoadsItem.getItems());
}
switch (item.getType()) {
case PROFILE:
profiles.add(((ProfileSettingsItem) item).getModeBean());
break;
case FILE:
FileSettingsItem fileItem = (FileSettingsItem) item;
if (fileItem.getSubtype() == FileSubtype.RENDERING_STYLE) {
renderFilesList.add(fileItem.getFile());
} else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) {
routingFilesList.add(fileItem.getFile());
}
break;
case QUICK_ACTIONS:
QuickActionsSettingsItem quickActionsItem = (QuickActionsSettingsItem) item;
if (importComplete) {
quickActions.addAll(quickActionsItem.getAppliedItems());
} else {
quickActions.addAll(quickActionsItem.getItems());
}
break;
case POI_UI_FILTERS:
PoiUiFiltersSettingsItem poiUiFilterItem = (PoiUiFiltersSettingsItem) item;
if (importComplete) {
poiUIFilters.addAll(poiUiFilterItem.getAppliedItems());
} else {
poiUIFilters.addAll(poiUiFilterItem.getItems());
}
break;
case MAP_SOURCES:
MapSourcesSettingsItem mapSourcesItem = (MapSourcesSettingsItem) item;
if (importComplete) {
tileSourceTemplates.addAll(mapSourcesItem.getAppliedItems());
} else {
tileSourceTemplates.addAll(mapSourcesItem.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) {
float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get();
float left = x - roadWorkIcon.getWidth() / 2f * textScale;
float top = y - roadWorkIcon.getHeight() * textScale;
Rect destRect = getIconDestinationRect(left, top, roadWorkIcon.getWidth(), roadWorkIcon.getHeight(), textScale);
y -= roadWorkIcon.getHeight() / 2f * textScale;
Rect destRect = getIconDestinationRect(x, y, roadWorkIcon.getWidth(), roadWorkIcon.getHeight(), textScale);
canvas.drawBitmap(roadWorkIcon, null, destRect, active ? activePaint : paint);
}