Merge pull request #10543 from osmandapp/online_routing_osf
Online routing export and import
This commit is contained in:
commit
30a3d0d8d2
27 changed files with 282 additions and 121 deletions
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<string name="online_routing_engines">Online routing engines</string>
|
||||||
|
<string name="online_routing_engine">Online routing engine</string>
|
||||||
<string name="copy_address">Copy address</string>
|
<string name="copy_address">Copy address</string>
|
||||||
<string name="message_error_recheck_parameters">Error, recheck parameters</string>
|
<string name="message_error_recheck_parameters">Error, recheck parameters</string>
|
||||||
<string name="routing_engine_vehicle_type_car">Car</string>
|
<string name="routing_engine_vehicle_type_car">Car</string>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.onlinerouting;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -28,9 +29,11 @@ public class OnlineRoutingEngine {
|
||||||
public OnlineRoutingEngine(@NonNull String stringKey,
|
public OnlineRoutingEngine(@NonNull String stringKey,
|
||||||
@NonNull ServerType serverType,
|
@NonNull ServerType serverType,
|
||||||
@NonNull String vehicleKey,
|
@NonNull String vehicleKey,
|
||||||
Map<String, String> params) {
|
@Nullable Map<String, String> params) {
|
||||||
this(stringKey, serverType, vehicleKey);
|
this(stringKey, serverType, vehicleKey);
|
||||||
this.params = params;
|
if (!Algorithms.isEmpty(params)) {
|
||||||
|
this.params.putAll(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnlineRoutingEngine(@NonNull String stringKey,
|
public OnlineRoutingEngine(@NonNull String stringKey,
|
||||||
|
@ -96,8 +99,9 @@ public class OnlineRoutingEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OnlineRoutingEngine createNewEngine(@NonNull ServerType serverType,
|
public static OnlineRoutingEngine createNewEngine(@NonNull ServerType serverType,
|
||||||
@NonNull String vehicleKey) {
|
@NonNull String vehicleKey,
|
||||||
return new OnlineRoutingEngine(generateKey(), serverType, vehicleKey);
|
@Nullable Map<String, String> params) {
|
||||||
|
return new OnlineRoutingEngine(generateKey(), serverType, vehicleKey, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateKey() {
|
private static String generateKey() {
|
||||||
|
|
|
@ -402,7 +402,7 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment {
|
||||||
if (isEditingMode()) {
|
if (isEditingMode()) {
|
||||||
engineToSave = new OnlineRoutingEngine(editedEngineKey, engine.serverType, engine.getVehicleKey());
|
engineToSave = new OnlineRoutingEngine(editedEngineKey, engine.serverType, engine.getVehicleKey());
|
||||||
} else {
|
} else {
|
||||||
engineToSave = OnlineRoutingEngine.createNewEngine(engine.serverType, engine.getVehicleKey());
|
engineToSave = OnlineRoutingEngine.createNewEngine(engine.serverType, engine.getVehicleKey(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
engineToSave.putParameter(EngineParameterType.CUSTOM_SERVER_URL, engine.customServerUrl);
|
engineToSave.putParameter(EngineParameterType.CUSTOM_SERVER_URL, engine.customServerUrl);
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class OnlineRoutingHelper {
|
||||||
JSONObject json = new JSONObject(jsonString);
|
JSONObject json = new JSONObject(jsonString);
|
||||||
readFromJson(json, engines);
|
readFromJson(json, engines);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
LOG.debug("Error when create a new JSONObject: " + e.toString());
|
LOG.debug("Error when reading engines from JSON ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return engines;
|
return engines;
|
||||||
|
@ -99,17 +99,19 @@ public class OnlineRoutingHelper {
|
||||||
|
|
||||||
private void saveToSettings() {
|
private void saveToSettings() {
|
||||||
if (!Algorithms.isEmpty(cachedEngines)) {
|
if (!Algorithms.isEmpty(cachedEngines)) {
|
||||||
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
if (writeToJson(json, cachedEngines)) {
|
writeToJson(json, cachedEngines);
|
||||||
settings.ONLINE_ROUTING_ENGINES.set(json.toString());
|
settings.ONLINE_ROUTING_ENGINES.set(json.toString());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
LOG.debug("Error when writing engines to JSON ", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settings.ONLINE_ROUTING_ENGINES.set(null);
|
settings.ONLINE_ROUTING_ENGINES.set(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void readFromJson(JSONObject json, List<OnlineRoutingEngine> engines) {
|
public static void readFromJson(JSONObject json, List<OnlineRoutingEngine> engines) throws JSONException {
|
||||||
try {
|
|
||||||
if (!json.has("items")) {
|
if (!json.has("items")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -126,17 +128,13 @@ public class OnlineRoutingHelper {
|
||||||
HashMap<String, String> params = gson.fromJson(paramsString, type);
|
HashMap<String, String> params = gson.fromJson(paramsString, type);
|
||||||
engines.add(new OnlineRoutingEngine(key, serverType, vehicleKey, params));
|
engines.add(new OnlineRoutingEngine(key, serverType, vehicleKey, params));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
|
||||||
LOG.debug("Error when reading engines from JSON: " + e.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean writeToJson(JSONObject json, List<OnlineRoutingEngine> engines) {
|
public static void writeToJson(JSONObject json, List<OnlineRoutingEngine> engines) throws JSONException {
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
Type type = new TypeToken<HashMap<String, String>>() {
|
Type type = new TypeToken<HashMap<String, String>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
try {
|
|
||||||
for (OnlineRoutingEngine engine : engines) {
|
for (OnlineRoutingEngine engine : engines) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("key", engine.getStringKey());
|
jsonObject.put("key", engine.getStringKey());
|
||||||
|
@ -146,10 +144,5 @@ public class OnlineRoutingHelper {
|
||||||
jsonArray.put(jsonObject);
|
jsonArray.put(jsonObject);
|
||||||
}
|
}
|
||||||
json.put("items", jsonArray);
|
json.put("items", jsonArray);
|
||||||
return true;
|
|
||||||
} catch (JSONException e) {
|
|
||||||
LOG.debug("Error when writing engines to JSON: " + e.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ public enum ExportSettingsType {
|
||||||
MAP_SOURCES(R.string.quick_action_map_source_title, R.drawable.ic_map),
|
MAP_SOURCES(R.string.quick_action_map_source_title, R.drawable.ic_map),
|
||||||
OFFLINE_MAPS(R.string.shared_string_maps, R.drawable.ic_map),
|
OFFLINE_MAPS(R.string.shared_string_maps, R.drawable.ic_map),
|
||||||
TTS_VOICE(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up),
|
TTS_VOICE(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up),
|
||||||
VOICE(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up);
|
VOICE(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up),
|
||||||
|
ONLINE_ROUTING_ENGINES(R.string.online_routing_engines, R.drawable.ic_world_globe_dark);
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
private final int titleId;
|
private final int titleId;
|
||||||
|
@ -59,6 +60,6 @@ public enum ExportSettingsType {
|
||||||
|
|
||||||
public boolean isResourcesCategory() {
|
public boolean isResourcesCategory() {
|
||||||
return this == CUSTOM_RENDER_STYLE || this == CUSTOM_ROUTING || this == MAP_SOURCES
|
return this == CUSTOM_RENDER_STYLE || this == CUSTOM_ROUTING || this == MAP_SOURCES
|
||||||
|| this == OFFLINE_MAPS || this == VOICE || this == TTS_VOICE;
|
|| this == OFFLINE_MAPS || this == VOICE || this == TTS_VOICE || this == ONLINE_ROUTING_ENGINES;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -48,7 +48,6 @@ import net.osmand.plus.helpers.enums.TracksSortByMode;
|
||||||
import net.osmand.plus.mapillary.MapillaryPlugin;
|
import net.osmand.plus.mapillary.MapillaryPlugin;
|
||||||
import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format;
|
import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersMode;
|
import net.osmand.plus.mapmarkers.MapMarkersMode;
|
||||||
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
|
||||||
import net.osmand.plus.profiles.LocationIcon;
|
import net.osmand.plus.profiles.LocationIcon;
|
||||||
import net.osmand.plus.profiles.NavigationIcon;
|
import net.osmand.plus.profiles.NavigationIcon;
|
||||||
import net.osmand.plus.profiles.ProfileIconColors;
|
import net.osmand.plus.profiles.ProfileIconColors;
|
||||||
|
@ -1016,7 +1015,7 @@ public class OsmandSettings {
|
||||||
ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.AIRCRAFT, RouteService.STRAIGHT);
|
ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.AIRCRAFT, RouteService.STRAIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CommonPreference<String> ONLINE_ROUTING_ENGINES = new StringPreference(this, "online_routing_engines", null);
|
public final CommonPreference<String> ONLINE_ROUTING_ENGINES = new StringPreference(this, "online_routing_engines", null).makeGlobal();
|
||||||
|
|
||||||
public final CommonPreference<NavigationIcon> NAVIGATION_ICON = new EnumStringPreference<>(this, "navigation_icon", NavigationIcon.DEFAULT, NavigationIcon.values()).makeProfile().cache();
|
public final CommonPreference<NavigationIcon> NAVIGATION_ICON = new EnumStringPreference<>(this, "navigation_icon", NavigationIcon.DEFAULT, NavigationIcon.values()).makeProfile().cache();
|
||||||
|
|
||||||
|
|
|
@ -92,11 +92,6 @@ public class AvoidRoadsSettingsItem extends CollectionSettingsItem<AvoidRoadInfo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldShowDuplicates() {
|
public boolean shouldShowDuplicates() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -72,6 +72,11 @@ public abstract class CollectionSettingsItem<T> extends SettingsItem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldReadOnCollecting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean isDuplicate(@NonNull T item);
|
public abstract boolean isDuplicate(@NonNull T item);
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
@ -109,11 +109,6 @@ public class FavoritesSettingsItem extends CollectionSettingsItem<FavoriteGroup>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public FavoriteGroup renameItem(@NonNull FavoriteGroup item) {
|
public FavoriteGroup renameItem(@NonNull FavoriteGroup item) {
|
||||||
|
|
|
@ -103,11 +103,6 @@ public class HistoryMarkersSettingsItem extends CollectionSettingsItem<MapMarker
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public MapMarker renameItem(@NonNull MapMarker item) {
|
public MapMarker renameItem(@NonNull MapMarker item) {
|
||||||
|
|
|
@ -130,11 +130,6 @@ public class MapSourcesSettingsItem extends CollectionSettingsItem<ITileSource>
|
||||||
return "map_sources";
|
return "map_sources";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -103,11 +103,6 @@ public class MarkersSettingsItem extends CollectionSettingsItem<MapMarker> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public MapMarker renameItem(@NonNull MapMarker item) {
|
public MapMarker renameItem(@NonNull MapMarker item) {
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
package net.osmand.plus.settings.backend.backup;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||||
|
import net.osmand.plus.onlinerouting.OnlineRoutingEngine.EngineParameterType;
|
||||||
|
import net.osmand.plus.onlinerouting.OnlineRoutingHelper;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OnlineRoutingSettingsItem extends CollectionSettingsItem<OnlineRoutingEngine> {
|
||||||
|
|
||||||
|
private OnlineRoutingHelper onlineRoutingHelper;
|
||||||
|
|
||||||
|
public OnlineRoutingSettingsItem(@NonNull OsmandApplication app, @NonNull List<OnlineRoutingEngine> items) {
|
||||||
|
super(app, null, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnlineRoutingSettingsItem(@NonNull OsmandApplication app, @Nullable OnlineRoutingSettingsItem baseItem, @NonNull List<OnlineRoutingEngine> items) {
|
||||||
|
super(app, baseItem, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnlineRoutingSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
|
||||||
|
super(app, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
super.init();
|
||||||
|
onlineRoutingHelper = app.getOnlineRoutingHelper();
|
||||||
|
existingItems = new ArrayList<>(onlineRoutingHelper.getEngines());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public SettingsItemType getType() {
|
||||||
|
return SettingsItemType.ONLINE_ROUTING_ENGINES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "online_routing_engines";
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getPublicName(@NonNull Context ctx) {
|
||||||
|
return ctx.getString(R.string.online_routing_engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
List<OnlineRoutingEngine> newItems = getNewItems();
|
||||||
|
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
|
||||||
|
appliedItems = new ArrayList<>(newItems);
|
||||||
|
|
||||||
|
for (OnlineRoutingEngine duplicate : duplicateItems) {
|
||||||
|
if (shouldReplace) {
|
||||||
|
onlineRoutingHelper.deleteEngine(duplicate.getStringKey());
|
||||||
|
}
|
||||||
|
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
|
||||||
|
}
|
||||||
|
for (OnlineRoutingEngine engine : appliedItems) {
|
||||||
|
onlineRoutingHelper.saveEngine(engine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDuplicate(@NonNull OnlineRoutingEngine routingEngine) {
|
||||||
|
for (OnlineRoutingEngine engine : existingItems) {
|
||||||
|
if (engine.getStringKey().equals(routingEngine.getStringKey())
|
||||||
|
|| engine.getName(app).equals(routingEngine.getName(app))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public OnlineRoutingEngine renameItem(@NonNull OnlineRoutingEngine item) {
|
||||||
|
int number = 0;
|
||||||
|
while (true) {
|
||||||
|
number++;
|
||||||
|
OnlineRoutingEngine renamedItem = OnlineRoutingEngine.createNewEngine(item.getServerType(), item.getVehicleKey(), item.getParams());
|
||||||
|
renamedItem.putParameter(EngineParameterType.CUSTOM_NAME, renamedItem.getName(app) + "_" + number);
|
||||||
|
if (!isDuplicate(renamedItem)) {
|
||||||
|
return renamedItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||||
|
try {
|
||||||
|
OnlineRoutingHelper.readFromJson(json, items);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));
|
||||||
|
throw new IllegalArgumentException("Json parse error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void writeItemsToJson(@NonNull JSONObject json) {
|
||||||
|
if (!items.isEmpty()) {
|
||||||
|
try {
|
||||||
|
OnlineRoutingHelper.writeToJson(json, items);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
|
||||||
|
SettingsHelper.LOG.error("Failed write to json", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
SettingsItemReader<? extends SettingsItem> getReader() {
|
||||||
|
return getJsonReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
SettingsItemWriter<? extends SettingsItem> getWriter() {
|
||||||
|
return getJsonWriter();
|
||||||
|
}
|
||||||
|
}
|
|
@ -113,11 +113,6 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem<OpenstreetmapPo
|
||||||
return ctx.getString(R.string.osm_edits);
|
return ctx.getString(R.string.osm_edits);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldShowDuplicates() {
|
public boolean shouldShowDuplicates() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -106,11 +106,6 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem<OsmNotesPoint>
|
||||||
return ctx.getString(R.string.osm_notes);
|
return ctx.getString(R.string.osm_notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldShowDuplicates() {
|
public boolean shouldShowDuplicates() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -105,11 +105,6 @@ public class PoiUiFiltersSettingsItem extends CollectionSettingsItem<PoiUIFilter
|
||||||
return "poi_ui_filters";
|
return "poi_ui_filters";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -89,11 +89,6 @@ public class QuickActionsSettingsItem extends CollectionSettingsItem<QuickAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -148,11 +148,6 @@ public class SearchHistorySettingsItem extends CollectionSettingsItem<HistoryEnt
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldReadOnCollecting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public HistoryEntry renameItem(@NonNull HistoryEntry item) {
|
public HistoryEntry renameItem(@NonNull HistoryEntry item) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.mapmarkers.MapMarker;
|
import net.osmand.plus.mapmarkers.MapMarker;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||||
|
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
|
@ -624,6 +625,10 @@ public class SettingsHelper {
|
||||||
resourcesItems.put(ExportSettingsType.CUSTOM_ROUTING, Arrays.asList(fl));
|
resourcesItems.put(ExportSettingsType.CUSTOM_ROUTING, Arrays.asList(fl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<OnlineRoutingEngine> onlineRoutingEngines = app.getOnlineRoutingHelper().getEngines();
|
||||||
|
if (!Algorithms.isEmpty(onlineRoutingEngines)) {
|
||||||
|
resourcesItems.put(ExportSettingsType.ONLINE_ROUTING_ENGINES, onlineRoutingEngines);
|
||||||
|
}
|
||||||
List<ITileSource> iTileSources = new ArrayList<>();
|
List<ITileSource> iTileSources = new ArrayList<>();
|
||||||
Set<String> tileSourceNames = app.getSettings().getTileSourceEntries(true).keySet();
|
Set<String> tileSourceNames = app.getSettings().getTileSourceEntries(true).keySet();
|
||||||
for (String name : tileSourceNames) {
|
for (String name : tileSourceNames) {
|
||||||
|
@ -701,6 +706,7 @@ public class SettingsHelper {
|
||||||
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
||||||
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
||||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||||
|
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||||
|
|
||||||
for (Object object : data) {
|
for (Object object : data) {
|
||||||
if (object instanceof QuickAction) {
|
if (object instanceof QuickAction) {
|
||||||
|
@ -741,6 +747,8 @@ public class SettingsHelper {
|
||||||
historyEntries.add((HistoryEntry) object);
|
historyEntries.add((HistoryEntry) object);
|
||||||
} else if (object instanceof GlobalSettingsItem) {
|
} else if (object instanceof GlobalSettingsItem) {
|
||||||
settingsItems.add((GlobalSettingsItem) object);
|
settingsItems.add((GlobalSettingsItem) object);
|
||||||
|
} else if (object instanceof OnlineRoutingEngine) {
|
||||||
|
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!quickActions.isEmpty()) {
|
if (!quickActions.isEmpty()) {
|
||||||
|
@ -793,6 +801,9 @@ public class SettingsHelper {
|
||||||
if (!historyEntries.isEmpty()) {
|
if (!historyEntries.isEmpty()) {
|
||||||
settingsItems.add(new SearchHistorySettingsItem(app, historyEntries));
|
settingsItems.add(new SearchHistorySettingsItem(app, historyEntries));
|
||||||
}
|
}
|
||||||
|
if (!onlineRoutingEngines.isEmpty()) {
|
||||||
|
settingsItems.add(new OnlineRoutingSettingsItem(app, onlineRoutingEngines));
|
||||||
|
}
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,6 +859,7 @@ public class SettingsHelper {
|
||||||
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
||||||
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
||||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||||
|
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||||
|
|
||||||
for (SettingsItem item : settingsItems) {
|
for (SettingsItem item : settingsItems) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
|
@ -942,6 +954,10 @@ public class SettingsHelper {
|
||||||
case GPX:
|
case GPX:
|
||||||
tracksFilesList.add((GpxSettingsItem) item);
|
tracksFilesList.add((GpxSettingsItem) item);
|
||||||
break;
|
break;
|
||||||
|
case ONLINE_ROUTING_ENGINES:
|
||||||
|
OnlineRoutingSettingsItem onlineRoutingSettingsItem = (OnlineRoutingSettingsItem) item;
|
||||||
|
onlineRoutingEngines.addAll(onlineRoutingSettingsItem.getItems());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1004,6 +1020,9 @@ public class SettingsHelper {
|
||||||
if (!historyEntries.isEmpty()) {
|
if (!historyEntries.isEmpty()) {
|
||||||
settingsToOperate.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
|
settingsToOperate.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
|
||||||
}
|
}
|
||||||
|
if (!onlineRoutingEngines.isEmpty()) {
|
||||||
|
settingsToOperate.put(ExportSettingsType.ONLINE_ROUTING_ENGINES, onlineRoutingEngines);
|
||||||
|
}
|
||||||
return settingsToOperate;
|
return settingsToOperate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,5 +19,6 @@ public enum SettingsItemType {
|
||||||
FAVOURITES,
|
FAVOURITES,
|
||||||
ACTIVE_MARKERS,
|
ACTIVE_MARKERS,
|
||||||
HISTORY_MARKERS,
|
HISTORY_MARKERS,
|
||||||
SEARCH_HISTORY
|
SEARCH_HISTORY,
|
||||||
|
ONLINE_ROUTING_ENGINES
|
||||||
}
|
}
|
|
@ -146,6 +146,9 @@ class SettingsItemsFactory {
|
||||||
case GPX:
|
case GPX:
|
||||||
item = new GpxSettingsItem(app, json);
|
item = new GpxSettingsItem(app, json);
|
||||||
break;
|
break;
|
||||||
|
case ONLINE_ROUTING_ENGINES:
|
||||||
|
item = new OnlineRoutingSettingsItem(app, json);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.mapmarkers.MapMarker;
|
import net.osmand.plus.mapmarkers.MapMarker;
|
||||||
|
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.profiles.ProfileIconColors;
|
import net.osmand.plus.profiles.ProfileIconColors;
|
||||||
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
|
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
|
||||||
|
@ -163,6 +164,9 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
|
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
|
||||||
} else if (currentItem instanceof HistoryEntry) {
|
} else if (currentItem instanceof HistoryEntry) {
|
||||||
itemHolder.title.setText(((HistoryEntry) currentItem).getName().getName());
|
itemHolder.title.setText(((HistoryEntry) currentItem).getName().getName());
|
||||||
|
} else if (currentItem instanceof OnlineRoutingEngine) {
|
||||||
|
itemHolder.title.setText(((OnlineRoutingEngine) currentItem).getName(app));
|
||||||
|
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_world_globe_dark, activeColorRes));
|
||||||
}
|
}
|
||||||
itemHolder.divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
|
itemHolder.divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||||
|
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
|
@ -362,6 +363,10 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
HistoryEntry historyEntry = (HistoryEntry) object;
|
HistoryEntry historyEntry = (HistoryEntry) object;
|
||||||
builder.setTitle(historyEntry.getName().getName());
|
builder.setTitle(historyEntry.getName().getName());
|
||||||
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes));
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes));
|
||||||
|
} else if (object instanceof OnlineRoutingEngine) {
|
||||||
|
OnlineRoutingEngine onlineRoutingEngine = (OnlineRoutingEngine) object;
|
||||||
|
builder.setTitle(onlineRoutingEngine.getName(app));
|
||||||
|
builder.setIcon(uiUtilities.getIcon(R.drawable.ic_world_globe_dark, activeColorRes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||||
import net.osmand.plus.dialogs.SelectMapStyleBottomSheetDialogFragment;
|
import net.osmand.plus.dialogs.SelectMapStyleBottomSheetDialogFragment;
|
||||||
|
@ -36,6 +37,7 @@ import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||||
|
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -150,12 +152,11 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
dismissFragment();
|
dismissFragment();
|
||||||
fm.popBackStack(DRAWER_SETTINGS_ID + ".new", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
fm.popBackStack(DRAWER_SETTINGS_ID + ".new", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CUSTOM_ROUTING:
|
case GLOBAL:
|
||||||
case PROFILE:
|
case PROFILE:
|
||||||
BaseSettingsFragment.showInstance(
|
case CUSTOM_ROUTING:
|
||||||
requireActivity(),
|
case ONLINE_ROUTING_ENGINES:
|
||||||
BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS
|
BaseSettingsFragment.showInstance(requireActivity(), SettingsScreenType.MAIN_SETTINGS);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case QUICK_ACTIONS:
|
case QUICK_ACTIONS:
|
||||||
fm.beginTransaction()
|
fm.beginTransaction()
|
||||||
|
@ -190,19 +191,13 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
case AVOID_ROADS:
|
case AVOID_ROADS:
|
||||||
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||||
break;
|
break;
|
||||||
|
case TRACKS:
|
||||||
case OSM_NOTES:
|
case OSM_NOTES:
|
||||||
case OSM_EDITS:
|
case OSM_EDITS:
|
||||||
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
|
||||||
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
|
|
||||||
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
app.getSettings().FAVORITES_TAB.set(OsmEditingPlugin.OSM_EDIT_TAB);
|
|
||||||
startActivity(favorites);
|
|
||||||
break;
|
|
||||||
case FAVORITES:
|
case FAVORITES:
|
||||||
Intent favoritesActivity = new Intent(activity, app.getAppCustomization().getFavoritesActivity());
|
case MULTIMEDIA_NOTES:
|
||||||
favoritesActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
int tabId = getFavoritesTabId(type);
|
||||||
app.getSettings().FAVORITES_TAB.set(FavoritesActivity.FAV_TAB);
|
openFavouritesActivity(activity, tabId);
|
||||||
startActivity(favoritesActivity);
|
|
||||||
break;
|
break;
|
||||||
case SEARCH_HISTORY:
|
case SEARCH_HISTORY:
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
|
@ -221,6 +216,29 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openFavouritesActivity(Activity activity, int tabType) {
|
||||||
|
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
||||||
|
Intent favoritesActivity = new Intent(activity, appCustomization.getFavoritesActivity());
|
||||||
|
favoritesActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
app.getSettings().FAVORITES_TAB.set(tabType);
|
||||||
|
startActivity(favoritesActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getFavoritesTabId(ExportSettingsType type) {
|
||||||
|
switch (type) {
|
||||||
|
case OSM_NOTES:
|
||||||
|
case OSM_EDITS:
|
||||||
|
return OsmEditingPlugin.OSM_EDIT_TAB;
|
||||||
|
case MULTIMEDIA_NOTES:
|
||||||
|
return AudioVideoNotesPlugin.NOTES_TAB;
|
||||||
|
case TRACKS:
|
||||||
|
return FavoritesActivity.GPX_TAB;
|
||||||
|
case FAVORITES:
|
||||||
|
default:
|
||||||
|
return FavoritesActivity.FAV_TAB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatusBarColorId() {
|
public int getStatusBarColorId() {
|
||||||
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
|
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
|
||||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.mapmarkers.MapMarker;
|
import net.osmand.plus.mapmarkers.MapMarker;
|
||||||
|
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
@ -205,6 +206,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
||||||
List<MapMarker> mapMarkers = new ArrayList<>();
|
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||||
List<MapMarker> mapMarkersGroups = new ArrayList<>();
|
List<MapMarker> mapMarkersGroups = new ArrayList<>();
|
||||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||||
|
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||||
|
|
||||||
for (Object object : duplicatesList) {
|
for (Object object : duplicatesList) {
|
||||||
if (object instanceof ApplicationMode.ApplicationModeBean) {
|
if (object instanceof ApplicationMode.ApplicationModeBean) {
|
||||||
|
@ -250,6 +252,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
} else if (object instanceof HistoryEntry) {
|
} else if (object instanceof HistoryEntry) {
|
||||||
historyEntries.add((HistoryEntry) object);
|
historyEntries.add((HistoryEntry) object);
|
||||||
|
} else if (object instanceof OnlineRoutingEngine) {
|
||||||
|
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!profiles.isEmpty()) {
|
if (!profiles.isEmpty()) {
|
||||||
|
@ -320,6 +324,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
||||||
duplicates.add(getString(R.string.markers_history));
|
duplicates.add(getString(R.string.markers_history));
|
||||||
duplicates.addAll(mapMarkersGroups);
|
duplicates.addAll(mapMarkersGroups);
|
||||||
}
|
}
|
||||||
|
if (!onlineRoutingEngines.isEmpty()) {
|
||||||
|
duplicates.add(getString(R.string.online_routing_engines));
|
||||||
|
duplicates.addAll(onlineRoutingEngines);
|
||||||
|
}
|
||||||
return duplicates;
|
return duplicates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.mapmarkers.MapMarker;
|
import net.osmand.plus.mapmarkers.MapMarker;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||||
|
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
@ -50,6 +51,7 @@ import net.osmand.plus.settings.backend.backup.GpxSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.HistoryMarkersSettingsItem;
|
import net.osmand.plus.settings.backend.backup.HistoryMarkersSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem;
|
import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.MarkersSettingsItem;
|
import net.osmand.plus.settings.backend.backup.MarkersSettingsItem;
|
||||||
|
import net.osmand.plus.settings.backend.backup.OnlineRoutingSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem;
|
import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem;
|
import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem;
|
||||||
import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem;
|
import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem;
|
||||||
|
@ -347,6 +349,7 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
||||||
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
||||||
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
||||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||||
|
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||||
for (Object object : data) {
|
for (Object object : data) {
|
||||||
if (object instanceof ApplicationModeBean) {
|
if (object instanceof ApplicationModeBean) {
|
||||||
appModeBeans.add((ApplicationModeBean) object);
|
appModeBeans.add((ApplicationModeBean) object);
|
||||||
|
@ -384,6 +387,8 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
||||||
}
|
}
|
||||||
} else if (object instanceof HistoryEntry) {
|
} else if (object instanceof HistoryEntry) {
|
||||||
historyEntries.add((HistoryEntry) object);
|
historyEntries.add((HistoryEntry) object);
|
||||||
|
} else if (object instanceof OnlineRoutingEngine) {
|
||||||
|
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!appModeBeans.isEmpty()) {
|
if (!appModeBeans.isEmpty()) {
|
||||||
|
@ -435,6 +440,10 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
||||||
SearchHistorySettingsItem baseItem = getBaseItem(SettingsItemType.SEARCH_HISTORY, SearchHistorySettingsItem.class);
|
SearchHistorySettingsItem baseItem = getBaseItem(SettingsItemType.SEARCH_HISTORY, SearchHistorySettingsItem.class);
|
||||||
settingsItems.add(new SearchHistorySettingsItem(app, baseItem, historyEntries));
|
settingsItems.add(new SearchHistorySettingsItem(app, baseItem, historyEntries));
|
||||||
}
|
}
|
||||||
|
if (!onlineRoutingEngines.isEmpty()) {
|
||||||
|
OnlineRoutingSettingsItem baseItem = getBaseItem(SettingsItemType.ONLINE_ROUTING_ENGINES, OnlineRoutingSettingsItem.class);
|
||||||
|
settingsItems.add(new OnlineRoutingSettingsItem(app, baseItem, onlineRoutingEngines));
|
||||||
|
}
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -154,6 +153,10 @@ public class ImportedSettingsItemsAdapter extends
|
||||||
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_history, activeColorRes));
|
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_history, activeColorRes));
|
||||||
holder.title.setText(R.string.shared_string_search_history);
|
holder.title.setText(R.string.shared_string_search_history);
|
||||||
break;
|
break;
|
||||||
|
case ONLINE_ROUTING_ENGINES:
|
||||||
|
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_world_globe_dark, activeColorRes));
|
||||||
|
holder.title.setText(R.string.online_routing_engines);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue