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="message_error_recheck_parameters">Error, recheck parameters</string>
|
||||
<string name="routing_engine_vehicle_type_car">Car</string>
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.onlinerouting;
|
|||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -28,9 +29,11 @@ public class OnlineRoutingEngine {
|
|||
public OnlineRoutingEngine(@NonNull String stringKey,
|
||||
@NonNull ServerType serverType,
|
||||
@NonNull String vehicleKey,
|
||||
Map<String, String> params) {
|
||||
@Nullable Map<String, String> params) {
|
||||
this(stringKey, serverType, vehicleKey);
|
||||
this.params = params;
|
||||
if (!Algorithms.isEmpty(params)) {
|
||||
this.params.putAll(params);
|
||||
}
|
||||
}
|
||||
|
||||
public OnlineRoutingEngine(@NonNull String stringKey,
|
||||
|
@ -96,8 +99,9 @@ public class OnlineRoutingEngine {
|
|||
}
|
||||
|
||||
public static OnlineRoutingEngine createNewEngine(@NonNull ServerType serverType,
|
||||
@NonNull String vehicleKey) {
|
||||
return new OnlineRoutingEngine(generateKey(), serverType, vehicleKey);
|
||||
@NonNull String vehicleKey,
|
||||
@Nullable Map<String, String> params) {
|
||||
return new OnlineRoutingEngine(generateKey(), serverType, vehicleKey, params);
|
||||
}
|
||||
|
||||
private static String generateKey() {
|
||||
|
|
|
@ -402,7 +402,7 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment {
|
|||
if (isEditingMode()) {
|
||||
engineToSave = new OnlineRoutingEngine(editedEngineKey, engine.serverType, engine.getVehicleKey());
|
||||
} else {
|
||||
engineToSave = OnlineRoutingEngine.createNewEngine(engine.serverType, engine.getVehicleKey());
|
||||
engineToSave = OnlineRoutingEngine.createNewEngine(engine.serverType, engine.getVehicleKey(), null);
|
||||
}
|
||||
|
||||
engineToSave.putParameter(EngineParameterType.CUSTOM_SERVER_URL, engine.customServerUrl);
|
||||
|
|
|
@ -91,7 +91,7 @@ public class OnlineRoutingHelper {
|
|||
JSONObject json = new JSONObject(jsonString);
|
||||
readFromJson(json, engines);
|
||||
} catch (JSONException e) {
|
||||
LOG.debug("Error when create a new JSONObject: " + e.toString());
|
||||
LOG.debug("Error when reading engines from JSON ", e);
|
||||
}
|
||||
}
|
||||
return engines;
|
||||
|
@ -99,17 +99,19 @@ public class OnlineRoutingHelper {
|
|||
|
||||
private void saveToSettings() {
|
||||
if (!Algorithms.isEmpty(cachedEngines)) {
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
if (writeToJson(json, cachedEngines)) {
|
||||
writeToJson(json, cachedEngines);
|
||||
settings.ONLINE_ROUTING_ENGINES.set(json.toString());
|
||||
} catch (JSONException e) {
|
||||
LOG.debug("Error when writing engines to JSON ", e);
|
||||
}
|
||||
} else {
|
||||
settings.ONLINE_ROUTING_ENGINES.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void readFromJson(JSONObject json, List<OnlineRoutingEngine> engines) {
|
||||
try {
|
||||
public static void readFromJson(JSONObject json, List<OnlineRoutingEngine> engines) throws JSONException {
|
||||
if (!json.has("items")) {
|
||||
return;
|
||||
}
|
||||
|
@ -126,17 +128,13 @@ public class OnlineRoutingHelper {
|
|||
HashMap<String, String> params = gson.fromJson(paramsString, type);
|
||||
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();
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<HashMap<String, String>>() {
|
||||
}.getType();
|
||||
try {
|
||||
for (OnlineRoutingEngine engine : engines) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("key", engine.getStringKey());
|
||||
|
@ -146,10 +144,5 @@ public class OnlineRoutingHelper {
|
|||
jsonArray.put(jsonObject);
|
||||
}
|
||||
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),
|
||||
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),
|
||||
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
|
||||
private final int titleId;
|
||||
|
@ -59,6 +60,6 @@ public enum ExportSettingsType {
|
|||
|
||||
public boolean isResourcesCategory() {
|
||||
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.mapmarkers.CoordinateInputFormats.Format;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersMode;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||
import net.osmand.plus.profiles.LocationIcon;
|
||||
import net.osmand.plus.profiles.NavigationIcon;
|
||||
import net.osmand.plus.profiles.ProfileIconColors;
|
||||
|
@ -1016,7 +1015,7 @@ public class OsmandSettings {
|
|||
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();
|
||||
|
||||
|
|
|
@ -92,11 +92,6 @@ public class AvoidRoadsSettingsItem extends CollectionSettingsItem<AvoidRoadInfo
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShowDuplicates() {
|
||||
return false;
|
||||
|
|
|
@ -72,6 +72,11 @@ public abstract class CollectionSettingsItem<T> extends SettingsItem {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract boolean isDuplicate(@NonNull T item);
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -109,11 +109,6 @@ public class FavoritesSettingsItem extends CollectionSettingsItem<FavoriteGroup>
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FavoriteGroup renameItem(@NonNull FavoriteGroup item) {
|
||||
|
|
|
@ -103,11 +103,6 @@ public class HistoryMarkersSettingsItem extends CollectionSettingsItem<MapMarker
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MapMarker renameItem(@NonNull MapMarker item) {
|
||||
|
|
|
@ -130,11 +130,6 @@ public class MapSourcesSettingsItem extends CollectionSettingsItem<ITileSource>
|
|||
return "map_sources";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||
try {
|
||||
|
|
|
@ -103,11 +103,6 @@ public class MarkersSettingsItem extends CollectionSettingsItem<MapMarker> {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShowDuplicates() {
|
||||
return false;
|
||||
|
|
|
@ -106,11 +106,6 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem<OsmNotesPoint>
|
|||
return ctx.getString(R.string.osm_notes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShowDuplicates() {
|
||||
return false;
|
||||
|
|
|
@ -105,11 +105,6 @@ public class PoiUiFiltersSettingsItem extends CollectionSettingsItem<PoiUIFilter
|
|||
return "poi_ui_filters";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||
try {
|
||||
|
|
|
@ -89,11 +89,6 @@ public class QuickActionsSettingsItem extends CollectionSettingsItem<QuickAction
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
|
@ -148,11 +148,6 @@ public class SearchHistorySettingsItem extends CollectionSettingsItem<HistoryEnt
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldReadOnCollecting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
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.mapmarkers.MapMarker;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||
|
@ -624,6 +625,10 @@ public class SettingsHelper {
|
|||
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<>();
|
||||
Set<String> tileSourceNames = app.getSettings().getTileSourceEntries(true).keySet();
|
||||
for (String name : tileSourceNames) {
|
||||
|
@ -701,6 +706,7 @@ public class SettingsHelper {
|
|||
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
||||
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||
|
||||
for (Object object : data) {
|
||||
if (object instanceof QuickAction) {
|
||||
|
@ -741,6 +747,8 @@ public class SettingsHelper {
|
|||
historyEntries.add((HistoryEntry) object);
|
||||
} else if (object instanceof GlobalSettingsItem) {
|
||||
settingsItems.add((GlobalSettingsItem) object);
|
||||
} else if (object instanceof OnlineRoutingEngine) {
|
||||
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||
}
|
||||
}
|
||||
if (!quickActions.isEmpty()) {
|
||||
|
@ -793,6 +801,9 @@ public class SettingsHelper {
|
|||
if (!historyEntries.isEmpty()) {
|
||||
settingsItems.add(new SearchHistorySettingsItem(app, historyEntries));
|
||||
}
|
||||
if (!onlineRoutingEngines.isEmpty()) {
|
||||
settingsItems.add(new OnlineRoutingSettingsItem(app, onlineRoutingEngines));
|
||||
}
|
||||
return settingsItems;
|
||||
}
|
||||
|
||||
|
@ -848,6 +859,7 @@ public class SettingsHelper {
|
|||
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
||||
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||
|
||||
for (SettingsItem item : settingsItems) {
|
||||
switch (item.getType()) {
|
||||
|
@ -942,6 +954,10 @@ public class SettingsHelper {
|
|||
case GPX:
|
||||
tracksFilesList.add((GpxSettingsItem) item);
|
||||
break;
|
||||
case ONLINE_ROUTING_ENGINES:
|
||||
OnlineRoutingSettingsItem onlineRoutingSettingsItem = (OnlineRoutingSettingsItem) item;
|
||||
onlineRoutingEngines.addAll(onlineRoutingSettingsItem.getItems());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1004,6 +1020,9 @@ public class SettingsHelper {
|
|||
if (!historyEntries.isEmpty()) {
|
||||
settingsToOperate.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
|
||||
}
|
||||
if (!onlineRoutingEngines.isEmpty()) {
|
||||
settingsToOperate.put(ExportSettingsType.ONLINE_ROUTING_ENGINES, onlineRoutingEngines);
|
||||
}
|
||||
return settingsToOperate;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,5 +19,6 @@ public enum SettingsItemType {
|
|||
FAVOURITES,
|
||||
ACTIVE_MARKERS,
|
||||
HISTORY_MARKERS,
|
||||
SEARCH_HISTORY
|
||||
SEARCH_HISTORY,
|
||||
ONLINE_ROUTING_ENGINES
|
||||
}
|
|
@ -146,6 +146,9 @@ class SettingsItemsFactory {
|
|||
case GPX:
|
||||
item = new GpxSettingsItem(app, json);
|
||||
break;
|
||||
case ONLINE_ROUTING_ENGINES:
|
||||
item = new OnlineRoutingSettingsItem(app, json);
|
||||
break;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.plus.helpers.FileNameTranslationHelper;
|
|||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.mapmarkers.MapMarker;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.profiles.ProfileIconColors;
|
||||
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));
|
||||
} else if (currentItem instanceof HistoryEntry) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import net.osmand.plus.helpers.FileNameTranslationHelper;
|
|||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||
|
@ -362,6 +363,10 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
HistoryEntry historyEntry = (HistoryEntry) object;
|
||||
builder.setTitle(historyEntry.getName().getName());
|
||||
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.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
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.backup.SettingsHelper;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -150,12 +152,11 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
|||
dismissFragment();
|
||||
fm.popBackStack(DRAWER_SETTINGS_ID + ".new", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
switch (type) {
|
||||
case CUSTOM_ROUTING:
|
||||
case GLOBAL:
|
||||
case PROFILE:
|
||||
BaseSettingsFragment.showInstance(
|
||||
requireActivity(),
|
||||
BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS
|
||||
);
|
||||
case CUSTOM_ROUTING:
|
||||
case ONLINE_ROUTING_ENGINES:
|
||||
BaseSettingsFragment.showInstance(requireActivity(), SettingsScreenType.MAIN_SETTINGS);
|
||||
break;
|
||||
case QUICK_ACTIONS:
|
||||
fm.beginTransaction()
|
||||
|
@ -190,19 +191,13 @@ public class ImportCompleteFragment extends BaseOsmAndFragment {
|
|||
case AVOID_ROADS:
|
||||
new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||
break;
|
||||
case TRACKS:
|
||||
case OSM_NOTES:
|
||||
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:
|
||||
Intent favoritesActivity = new Intent(activity, app.getAppCustomization().getFavoritesActivity());
|
||||
favoritesActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
app.getSettings().FAVORITES_TAB.set(FavoritesActivity.FAV_TAB);
|
||||
startActivity(favoritesActivity);
|
||||
case MULTIMEDIA_NOTES:
|
||||
int tabId = getFavoritesTabId(type);
|
||||
openFavouritesActivity(activity, tabId);
|
||||
break;
|
||||
case SEARCH_HISTORY:
|
||||
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
|
||||
public int getStatusBarColorId() {
|
||||
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.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.mapmarkers.MapMarker;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
|
@ -205,6 +206,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
|||
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||
List<MapMarker> mapMarkersGroups = new ArrayList<>();
|
||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||
|
||||
for (Object object : duplicatesList) {
|
||||
if (object instanceof ApplicationMode.ApplicationModeBean) {
|
||||
|
@ -250,6 +252,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
} else if (object instanceof HistoryEntry) {
|
||||
historyEntries.add((HistoryEntry) object);
|
||||
} else if (object instanceof OnlineRoutingEngine) {
|
||||
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||
}
|
||||
}
|
||||
if (!profiles.isEmpty()) {
|
||||
|
@ -320,6 +324,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
|
|||
duplicates.add(getString(R.string.markers_history));
|
||||
duplicates.addAll(mapMarkersGroups);
|
||||
}
|
||||
if (!onlineRoutingEngines.isEmpty()) {
|
||||
duplicates.add(getString(R.string.online_routing_engines));
|
||||
duplicates.addAll(onlineRoutingEngines);
|
||||
}
|
||||
return duplicates;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
|||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.mapmarkers.MapMarker;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingEngine;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||
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.MapSourcesSettingsItem;
|
||||
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.OsmNotesSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem;
|
||||
|
@ -347,6 +349,7 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
|||
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
||||
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||
for (Object object : data) {
|
||||
if (object instanceof ApplicationModeBean) {
|
||||
appModeBeans.add((ApplicationModeBean) object);
|
||||
|
@ -384,6 +387,8 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
|||
}
|
||||
} else if (object instanceof HistoryEntry) {
|
||||
historyEntries.add((HistoryEntry) object);
|
||||
} else if (object instanceof OnlineRoutingEngine) {
|
||||
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||
}
|
||||
}
|
||||
if (!appModeBeans.isEmpty()) {
|
||||
|
@ -435,6 +440,10 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
|||
SearchHistorySettingsItem baseItem = getBaseItem(SettingsItemType.SEARCH_HISTORY, SearchHistorySettingsItem.class);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import net.osmand.plus.UiUtilities;
|
|||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -154,6 +153,10 @@ public class ImportedSettingsItemsAdapter extends
|
|||
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_history, activeColorRes));
|
||||
holder.title.setText(R.string.shared_string_search_history);
|
||||
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