From dbfb379cc8a07a1f72f44535c80c6e80deb7d6a1 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 25 Jun 2020 22:21:19 +0300 Subject: [PATCH 001/551] Gpx width per file --- .../main/java/net/osmand/GPXUtilities.java | 12 + OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 8 +- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 60 ++- OsmAnd/src/net/osmand/plus/GpxDbHelper.java | 6 + .../net/osmand/plus/GpxSelectionHelper.java | 10 + .../osmand/plus/dialogs/ConfigureMapMenu.java | 411 +----------------- .../plus/dialogs/GpxAppearanceAdapter.java | 214 +++++++++ .../plus/dialogs/MapLayerMenuListener.java | 229 ++++++++++ .../net/osmand/plus/helpers/GpxUiHelper.java | 12 +- .../TrackActivityFragmentAdapter.java | 136 +++--- .../src/net/osmand/plus/views/GPXLayer.java | 40 +- 11 files changed, 654 insertions(+), 484 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java create mode 100644 OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 6eb20d0f15..4b266588b8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -148,6 +148,18 @@ public class GPXUtilities { getExtensionsToWrite().remove("color"); } + public String getWidth(String defWidth) { + String widthValue = null; + if (extensions != null) { + widthValue = extensions.get("width"); + } + return widthValue != null ? widthValue : defWidth; + } + + public void setWidth(String width) { + getExtensionsToWrite().put("width", width); + } + public Map getExtensionsToWrite() { if (extensions == null) { extensions = new LinkedHashMap<>(); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 582d6972ee..96686c9956 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -43,6 +43,7 @@ import net.osmand.data.PointDescription; import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.InitEvents; +import net.osmand.plus.dialogs.GpxAppearanceAdapter; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuItem; @@ -60,7 +61,6 @@ import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.settings.backend.SettingsHelper; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; -import net.osmand.plus.dialogs.ConfigureMapMenu; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ExternalApiHelper; import net.osmand.plus.mapcontextmenu.MapContextMenu; @@ -1146,7 +1146,7 @@ public class OsmandAidlApi { @SuppressLint("StaticFieldLeak") private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) { - final int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor( + final int col = GpxAppearanceAdapter.parseTrackColor( app.getRendererRegistry().getCurrentSelectedRenderer(), color); if (!destinationExists) { GpxDataItem gpxDataItem = new GpxDataItem(destination, col); @@ -1390,7 +1390,7 @@ public class OsmandAidlApi { int color = dataItem.getColor(); String colorName = ""; if (color != 0) { - colorName = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color); + colorName = GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color); } net.osmand.aidlapi.gpx.AGpxFileDetails details = null; GPXTrackAnalysis analysis = dataItem.getAnalysis(); @@ -1431,7 +1431,7 @@ public class OsmandAidlApi { if (file.getName().equals(gpxFileName)) { int color = dataItem.getColor(); if (color != 0) { - return ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color); + return GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color); } } } diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index 94b1a993b6..c1f1e220de 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -15,8 +15,9 @@ import java.util.List; public class GPXDatabase { + private static final int DB_VERSION = 11; private static final String DB_NAME = "gpx_database"; - private static final int DB_VERSION = 10; + private static final String GPX_TABLE_NAME = "gpxTable"; private static final String GPX_COL_NAME = "fileName"; private static final String GPX_COL_DIR = "fileDir"; @@ -56,6 +57,8 @@ public class GPXDatabase { private static final String GPX_COL_JOIN_SEGMENTS = "joinSegments"; + private static final String GPX_COL_WIDTH = "width"; + public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1; public static final int GPX_SPLIT_TYPE_DISTANCE = 1; public static final int GPX_SPLIT_TYPE_TIME = 2; @@ -89,7 +92,8 @@ public class GPXDatabase { GPX_COL_API_IMPORTED + " int, " + // 1 = true, 0 = false GPX_COL_WPT_CATEGORY_NAMES + " TEXT, " + GPX_COL_SHOW_AS_MARKERS + " int, " + // 1 = true, 0 = false - GPX_COL_JOIN_SEGMENTS + " int);"; // 1 = true, 0 = false + GPX_COL_JOIN_SEGMENTS + " int, " + // 1 = true, 0 = false + GPX_COL_WIDTH + " TEXT);"; private static final String GPX_TABLE_SELECT = "SELECT " + GPX_COL_NAME + ", " + @@ -117,7 +121,8 @@ public class GPXDatabase { GPX_COL_API_IMPORTED + ", " + GPX_COL_WPT_CATEGORY_NAMES + ", " + GPX_COL_SHOW_AS_MARKERS + ", " + - GPX_COL_JOIN_SEGMENTS + + GPX_COL_JOIN_SEGMENTS + ", " + + GPX_COL_WIDTH + " FROM " + GPX_TABLE_NAME; private static final String GPX_TABLE_UPDATE_ANALYSIS = "UPDATE " + @@ -144,12 +149,14 @@ public class GPXDatabase { private OsmandApplication context; public static class GpxDataItem { + private File file; private GPXTrackAnalysis analysis; + private String width; private int color; - private long fileLastModifiedTime; private int splitType; private double splitInterval; + private long fileLastModifiedTime; private boolean apiImported; private boolean showAsMarkers; private boolean joinSegments; @@ -177,6 +184,14 @@ public class GPXDatabase { return color; } + public String getWidth() { + return width; + } + + public void setWidth(String width) { + this.width = width; + } + public long getFileLastModifiedTime() { return fileLastModifiedTime; } @@ -341,6 +356,9 @@ public class GPXDatabase { " SET " + GPX_COL_JOIN_SEGMENTS + " = ? " + "WHERE " + GPX_COL_JOIN_SEGMENTS + " IS NULL", new Object[]{0}); } + if (oldVersion < 11) { + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_WIDTH + " TEXT"); + } db.execSQL("CREATE INDEX IF NOT EXISTS " + GPX_INDEX_NAME_DIR + " ON " + GPX_TABLE_NAME + " (" + GPX_COL_NAME + ", " + GPX_COL_DIR + ");"); } @@ -391,8 +409,7 @@ public class GPXDatabase { try { String fileName = getFileName(item.file); String fileDir = getFileDir(item.file); - db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + - GPX_COL_COLOR + " = ? " + + db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_COLOR + " = ? " + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", new Object[] { (color == 0 ? "" : Algorithms.colorToString(color)), fileName, fileDir }); item.color = color; @@ -404,6 +421,24 @@ public class GPXDatabase { return false; } + public boolean updateWidth(GpxDataItem item, String width) { + SQLiteConnection db = openConnection(false); + if (db != null){ + try { + String fileName = getFileName(item.file); + String fileDir = getFileDir(item.file); + db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_WIDTH + " = ? " + + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", + new Object[] { width, fileName, fileDir }); + item.width = width; + } finally { + db.close(); + } + return true; + } + return false; + } + public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) { SQLiteConnection db = openConnection(false); if (db != null) { @@ -518,12 +553,12 @@ public class GPXDatabase { } if (a != null) { db.execSQL( - "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[] {fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime, a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown, a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints, color, item.file.lastModified(), item.splitType, item.splitInterval, item.apiImported ? 1 : 0, - Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0}); + Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, item.width}); } else { db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" + GPX_COL_NAME + ", " + @@ -534,9 +569,10 @@ public class GPXDatabase { GPX_COL_SPLIT_INTERVAL + ", " + GPX_COL_API_IMPORTED + ", " + GPX_COL_SHOW_AS_MARKERS + ", " + - GPX_COL_JOIN_SEGMENTS + - ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", - new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0}); + GPX_COL_JOIN_SEGMENTS + ", " + + GPX_COL_WIDTH + + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, item.width}); } } @@ -617,6 +653,7 @@ public class GPXDatabase { String wptCategoryNames = query.getString(23); boolean showAsMarkers = query.getInt(24) == 1; boolean joinSegments = query.getInt(25) == 1; + String width = query.getString(26); GPXTrackAnalysis a = new GPXTrackAnalysis(); a.totalDistance = totalDistance; @@ -658,6 +695,7 @@ public class GPXDatabase { item.apiImported = apiImported; item.showAsMarkers = showAsMarkers; item.joinSegments = joinSegments; + item.width = width; return item; } diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index 41f19a020b..6221e91f6f 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -77,6 +77,12 @@ public class GpxDbHelper { return res; } + public boolean updateWidth(GpxDataItem item, String width) { + boolean res = db.updateWidth(item, width); + putToCache(item); + return res; + } + public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) { boolean res = db.updateShowAsMarkers(item, showAsMarkers); putToCache(item); diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index f750056bd3..00a626ae6d 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -51,6 +51,7 @@ public class GpxSelectionHelper { private static final String BACKUP = "backup"; private static final String BACKUPMODIFIEDTIME = "backupTime"; private static final String COLOR = "color"; + private static final String WIDTH = "width"; private static final String SELECTED_BY_USER = "selected_by_user"; private OsmandApplication app; @@ -515,6 +516,9 @@ public class GpxSelectionHelper { int clr = Algorithms.parseColor(obj.getString(COLOR)); gpx.setColor(clr); } + if (obj.has(WIDTH)) { + gpx.setWidth(obj.getString(WIDTH)); + } if (gpx.error != null) { save = true; } else if (obj.has(BACKUP)) { @@ -554,6 +558,9 @@ public class GpxSelectionHelper { if (s.gpxFile.getColor(0) != 0) { obj.put(COLOR, Algorithms.colorToString(s.gpxFile.getColor(0))); } + if (s.gpxFile.getWidth(null) != null) { + obj.put(WIDTH, s.gpxFile.getWidth(null)); + } } obj.put(SELECTED_BY_USER, s.selectedByUser); } catch (JSONException e) { @@ -606,6 +613,9 @@ public class GpxSelectionHelper { if (dataItem.getColor() != 0) { gpx.setColor(dataItem.getColor()); } + if (dataItem.getWidth() != null) { + gpx.setWidth(dataItem.getWidth()); + } sf.setJoinSegments(dataItem.isJoinSegments()); } sf.setGpxFile(gpx, app); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index f6399cfa7d..46221ce063 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -2,9 +2,7 @@ package net.osmand.plus.dialogs; import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; import android.os.Build; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; @@ -25,8 +23,6 @@ import androidx.appcompat.widget.SwitchCompat; import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; -import net.osmand.CallbackWithObject; -import net.osmand.GPXUtilities; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.core.android.MapRendererContext; @@ -35,20 +31,14 @@ import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; import net.osmand.plus.ContextMenuItem; import net.osmand.plus.DialogListItemAdapter; -import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.MapActivityLayers; -import net.osmand.plus.activities.PluginActivity; import net.osmand.plus.activities.SettingsActivity; -import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.inapp.InAppPurchaseHelper; -import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.poi.PoiUIFilter; -import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; @@ -58,7 +48,6 @@ import net.osmand.plus.transport.TransportLinesMenu; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.corenative.NativeCoreContext; import net.osmand.plus.wikipedia.WikipediaPoiMenu; -import net.osmand.render.RenderingRule; import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleStorageProperties; import net.osmand.render.RenderingRulesStorage; @@ -67,7 +56,6 @@ import net.osmand.util.SunriseSunset; import org.apache.commons.logging.Log; -import java.io.File; import java.text.DateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -101,7 +89,6 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.ROUTES_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.SHOW_CATEGORY_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.TEXT_SIZE_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.TRANSPORT_ID; -import static net.osmand.aidlapi.OsmAndCustomizationConstants.WIKIPEDIA_ID; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_DENSITY_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR; @@ -181,188 +168,13 @@ public class ConfigureMapMenu { return customRules; } - private final class LayerMenuListener extends OnRowItemClick { - private MapActivity ma; - private ContextMenuAdapter cm; - - private LayerMenuListener(MapActivity ma, ContextMenuAdapter cm) { - this.ma = ma; - this.cm = cm; - } - - private List getAlreadySelectedGpx() { - GpxSelectionHelper selectedGpxHelper = ma.getMyApplication().getSelectedGpxHelper(); - List selectedGpxFiles = selectedGpxHelper.getSelectedGPXFiles(); - - List files = new ArrayList<>(); - for (GpxSelectionHelper.SelectedGpxFile file : selectedGpxFiles) { - files.add(file.getGpxFile().path); - } - if (selectedGpxFiles.isEmpty()) { - Map fls = selectedGpxHelper.getSelectedGpxFilesBackUp(); - for(Map.Entry f : fls.entrySet()) { - if(!Algorithms.isEmpty(f.getKey().path)) { - File file = new File(f.getKey().path); - if(file.exists() && !file.isDirectory()) { - files.add(f.getKey().path); - } - } - } - } - - return files; - } - - @Override - public boolean onRowItemClick(final ArrayAdapter adapter, View view, int itemId, int pos) { - if (itemId == R.string.layer_poi) { - showPoiFilterDialog(adapter, adapter.getItem(pos)); - return false; - } else if (itemId == R.string.layer_gpx_layer && cm.getItem(pos).getSelected()) { - showGpxSelectionDialog(adapter, adapter.getItem(pos)); - return false; - } else if (itemId == R.string.rendering_category_transport) { - final ContextMenuItem item = adapter.getItem(pos); - TransportLinesMenu.showTransportsDialog(ma, new CallbackWithObject() { - @Override - public boolean processResult(Boolean result) { - if (item != null) { - item.setSelected(result); - item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); - adapter.notifyDataSetChanged(); - } - return true; - } - }); - boolean selected = TransportLinesMenu.isShowLines(ma.getMyApplication()); - if (!selected && item != null) { - item.setSelected(true); - item.setColorRes(R.color.osmand_orange); - adapter.notifyDataSetChanged(); - } - return false; - } else { - CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item); - if (btn != null && btn.getVisibility() == View.VISIBLE) { - btn.setChecked(!btn.isChecked()); - cm.getItem(pos).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); - adapter.notifyDataSetChanged(); - return false; - } else { - return onContextMenuClick(adapter, itemId, pos, false, null); - } - } - } - - @Override - public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, - final int pos, boolean isChecked, int[] viewCoordinates) { - final OsmandSettings settings = ma.getMyApplication().getSettings(); - final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters(); - final ContextMenuItem item = cm.getItem(pos); - if (item.getSelected() != null) { - item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); - } - if (itemId == R.string.layer_poi) { - PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter(); - poiFiltersHelper.clearSelectedPoiFilters(wiki); - if (isChecked) { - showPoiFilterDialog(adapter, adapter.getItem(pos)); - } else { - adapter.getItem(pos).setDescription( - poiFiltersHelper.getSelectedPoiFiltersName(wiki)); - } - } else if (itemId == R.string.layer_amenity_label) { - settings.SHOW_POI_LABEL.set(isChecked); - } else if (itemId == R.string.shared_string_favorites) { - settings.SHOW_FAVORITES.set(isChecked); - } else if (itemId == R.string.layer_gpx_layer) { - final GpxSelectionHelper selectedGpxHelper = ma.getMyApplication().getSelectedGpxHelper(); - if (selectedGpxHelper.isShowingAnyGpxFiles()) { - selectedGpxHelper.clearAllGpxFilesToShow(true); - adapter.getItem(pos).setDescription(selectedGpxHelper.getGpxDescription()); - } else { - showGpxSelectionDialog(adapter, adapter.getItem(pos)); - } - } else if (itemId == R.string.rendering_category_transport) { - boolean selected = TransportLinesMenu.isShowLines(ma.getMyApplication()); - TransportLinesMenu.toggleTransportLines(ma, !selected, new CallbackWithObject() { - @Override - public boolean processResult(Boolean result) { - item.setSelected(result); - item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); - adapter.notifyDataSetChanged(); - return true; - } - }); - } else if (itemId == R.string.map_markers) { - settings.SHOW_MAP_MARKERS.set(isChecked); - } else if (itemId == R.string.layer_map) { - if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) { - Intent intent = new Intent(ma, PluginActivity.class); - intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, OsmandRasterMapsPlugin.ID); - ma.startActivity(intent); - } else { - ContextMenuItem it = adapter.getItem(pos); - ma.getMapLayers().selectMapLayer(ma.getMapView(), it, adapter); - } - } - adapter.notifyDataSetChanged(); - ma.getMapLayers().updateLayers(ma.getMapView()); - ma.getMapView().refreshMap(); - return false; - } - - private void showGpxSelectionDialog(final ArrayAdapter adapter, - final ContextMenuItem item) { - AlertDialog dialog = ma.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(), - ma.getMapView()); - dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - OsmandApplication app = ma.getMyApplication(); - boolean selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles(); - item.setSelected(selected); - item.setDescription(app.getSelectedGpxHelper().getGpxDescription()); - item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); - adapter.notifyDataSetChanged(); - } - }); - } - - protected void showPoiFilterDialog(final ArrayAdapter adapter, - final ContextMenuItem item) { - final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters(); - final PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter(); - MapActivityLayers.DismissListener dismissListener = - new MapActivityLayers.DismissListener() { - @Override - public void dismiss() { - PoiFiltersHelper pf = ma.getMyApplication().getPoiFilters(); - boolean selected = pf.isShowingAnyPoi(wiki); - item.setSelected(selected); - item.setDescription(pf.getSelectedPoiFiltersName(wiki)); - item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); - adapter.notifyDataSetChanged(); - } - }; - if (poiFiltersHelper.isShowingAnyPoi(wiki)) { - ma.getMapLayers().showMultichoicePoiFilterDialog(ma.getMapView(), - dismissListener); - } else { - ma.getMapLayers().showSingleChoicePoiFilterDialog(ma.getMapView(), - dismissListener); - } - } - } - private void createLayersItems(List customRules, ContextMenuAdapter adapter, final MapActivity activity, final int themeRes, final boolean nightMode) { final OsmandApplication app = activity.getMyApplication(); final OsmandSettings settings = app.getSettings(); final int selectedProfileColorRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode); final int selectedProfileColor = ContextCompat.getColor(app, selectedProfileColorRes); - LayerMenuListener l = new LayerMenuListener(activity, adapter); + MapLayerMenuListener l = new MapLayerMenuListener(activity, adapter); adapter.addItem(new ContextMenuItem.ItemBuilder() .setId(SHOW_CATEGORY_ID) .setTitleId(R.string.shared_string_show, activity) @@ -1299,230 +1111,35 @@ public class ConfigureMapMenu { } } - private class StringSpinnerArrayAdapter extends ArrayAdapter { + private static class StringSpinnerArrayAdapter extends ArrayAdapter { private boolean nightMode; public StringSpinnerArrayAdapter(Context context, boolean nightMode) { super(context, android.R.layout.simple_spinner_item); setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - OsmandApplication app = (OsmandApplication )getContext().getApplicationContext(); this.nightMode = nightMode; } - @Override - public View getView(int position, View convertView, ViewGroup parent) { - TextView label = (TextView) super.getView(position, convertView, parent); - - String text = getItem(position); - label.setText(text); - label.setTextColor(nightMode ? - ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_dark) : ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_light)); - return label; - } - - @Override - public View getDropDownView(int position, View convertView, ViewGroup parent) { - TextView label = (TextView) super.getDropDownView(position, convertView, parent); - - String text = getItem(position); - label.setText(text); - label.setTextColor(nightMode ? - ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_dark) : ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_light)); - - return label; - } - } - - public static class GpxAppearanceAdapter extends ArrayAdapter { - - private OsmandApplication app; - private int currentColor; - private GpxAppearanceAdapterType adapterType = GpxAppearanceAdapterType.TRACK_WIDTH_COLOR; - - public enum GpxAppearanceAdapterType { - TRACK_WIDTH, - TRACK_COLOR, - TRACK_WIDTH_COLOR - } - - public GpxAppearanceAdapter(Context context, String currentColorValue, GpxAppearanceAdapterType adapterType) { - super(context, R.layout.rendering_prop_menu_item); - this.app = (OsmandApplication) getContext().getApplicationContext(); - this.adapterType = adapterType; - RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); - this.currentColor = parseTrackColor(renderer, currentColorValue); - init(); - } - - public GpxAppearanceAdapter(Context context, int currentColor, GpxAppearanceAdapterType adapterType) { - super(context, R.layout.rendering_prop_menu_item); - this.app = (OsmandApplication) getContext().getApplicationContext(); - this.adapterType = adapterType; - this.currentColor = currentColor; - init(); - } - - public void init() { - RenderingRuleProperty trackWidthProp = null; - RenderingRuleProperty trackColorProp = null; - RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); - if (renderer != null) { - if (adapterType == GpxAppearanceAdapterType.TRACK_WIDTH || adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) { - trackWidthProp = renderer.PROPS.getCustomRule(CURRENT_TRACK_WIDTH_ATTR); - } - if (adapterType == GpxAppearanceAdapterType.TRACK_COLOR || adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) { - trackColorProp = renderer.PROPS.getCustomRule(CURRENT_TRACK_COLOR_ATTR); - } - } - - if (trackWidthProp != null) { - AppearanceListItem item = new AppearanceListItem(CURRENT_TRACK_WIDTH_ATTR, "", - SettingsActivity.getStringPropertyValue(getContext(), trackWidthProp.getDefaultValueDescription())); - add(item); - for (int j = 0; j < trackWidthProp.getPossibleValues().length; j++) { - item = new AppearanceListItem(CURRENT_TRACK_WIDTH_ATTR, - trackWidthProp.getPossibleValues()[j], - SettingsActivity.getStringPropertyValue(getContext(), trackWidthProp.getPossibleValues()[j])); - add(item); - } - item.setLastItem(true); - } - if (trackColorProp != null) { - AppearanceListItem item = new AppearanceListItem(CURRENT_TRACK_COLOR_ATTR, "", - SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getDefaultValueDescription()), - parseTrackColor(renderer, "")); - add(item); - for (int j = 0; j < trackColorProp.getPossibleValues().length; j++) { - item = new AppearanceListItem(CURRENT_TRACK_COLOR_ATTR, - trackColorProp.getPossibleValues()[j], - SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getPossibleValues()[j]), - parseTrackColor(renderer, trackColorProp.getPossibleValues()[j])); - add(item); - } - item.setLastItem(true); - } - } - - public static int parseTrackColor(RenderingRulesStorage renderer, String colorName) { - int defaultColor = -1; - RenderingRule gpxRule = null; - if (renderer != null) { - gpxRule = renderer.getRenderingAttributeRule("gpx"); - } - if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) { - List rules = gpxRule.getIfElseChildren().get(0).getIfElseChildren(); - for (RenderingRule r : rules) { - String cName = r.getStringPropertyValue(CURRENT_TRACK_COLOR_ATTR); - if (!Algorithms.isEmpty(cName) && cName.equals(colorName)) { - return r.getIntPropertyValue(COLOR_ATTR); - } - if (cName == null && defaultColor == -1) { - defaultColor = r.getIntPropertyValue(COLOR_ATTR); - } - } - } - return defaultColor; - } - - public static String parseTrackColorName(RenderingRulesStorage renderer, int color) { - RenderingRule gpxRule = null; - if (renderer != null) { - gpxRule = renderer.getRenderingAttributeRule("gpx"); - } - if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) { - List rules = gpxRule.getIfElseChildren().get(0).getIfElseChildren(); - for (RenderingRule r : rules) { - String cName = r.getStringPropertyValue(CURRENT_TRACK_COLOR_ATTR); - if (!Algorithms.isEmpty(cName) && color == r.getIntPropertyValue(COLOR_ATTR)) { - return cName; - } - } - } - return Algorithms.colorToString(color); - } - @NonNull @Override public View getView(int position, View convertView, @NonNull ViewGroup parent) { - AppearanceListItem item = getItem(position); - View v = convertView; - if (v == null) { - v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null); - } - if (item != null) { - TextView textView = (TextView) v.findViewById(R.id.text1); - textView.setText(item.localizedValue); - if (item.attrName == CURRENT_TRACK_WIDTH_ATTR) { - int iconId; - if (item.value.equals("bold")) { - iconId = R.drawable.ic_action_gpx_width_bold; - } else if (item.value.equals("medium")) { - iconId = R.drawable.ic_action_gpx_width_medium; - } else { - iconId = R.drawable.ic_action_gpx_width_thin; - } - textView.setCompoundDrawablesWithIntrinsicBounds(null, null, - app.getUIUtilities().getPaintedIcon(iconId, currentColor), null); - } else { - if (item.color == -1) { - textView.setCompoundDrawablesWithIntrinsicBounds(null, null, - app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null); - } else { - textView.setCompoundDrawablesWithIntrinsicBounds(null, null, - app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, item.color), null); - } - } - textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f)); - v.findViewById(R.id.divider).setVisibility(item.lastItem - && position < getCount() - 1 ? View.VISIBLE : View.GONE); - } - return v; - } - } - - public static class AppearanceListItem { - private String attrName; - private String value; - private String localizedValue; - private int color; - private boolean lastItem; - - public AppearanceListItem(String attrName, String value, String localizedValue) { - this.attrName = attrName; - this.value = value; - this.localizedValue = localizedValue; + TextView label = (TextView) super.getView(position, convertView, parent); + setupLabel(label, getItem(position)); + return label; } - public AppearanceListItem(String attrName, String value, String localizedValue, int color) { - this.attrName = attrName; - this.value = value; - this.localizedValue = localizedValue; - this.color = color; + @Override + public View getDropDownView(int position, View convertView, @NonNull ViewGroup parent) { + TextView label = (TextView) super.getDropDownView(position, convertView, parent); + setupLabel(label, getItem(position)); + return label; } - public String getAttrName() { - return attrName; - } - - public String getValue() { - return value; - } - - public String getLocalizedValue() { - return localizedValue; - } - - public int getColor() { - return color; - } - - public boolean isLastItem() { - return lastItem; - } - - public void setLastItem(boolean lastItem) { - this.lastItem = lastItem; + private void setupLabel(TextView label, String text) { + int colorId = nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light; + label.setText(text); + label.setTextColor(ContextCompat.getColorStateList(getContext(), colorId)); } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java b/OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java new file mode 100644 index 0000000000..048461da55 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java @@ -0,0 +1,214 @@ +package net.osmand.plus.dialogs; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import net.osmand.AndroidUtils; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.SettingsActivity; +import net.osmand.render.RenderingRule; +import net.osmand.render.RenderingRuleProperty; +import net.osmand.render.RenderingRulesStorage; +import net.osmand.util.Algorithms; + +import java.util.List; + +public class GpxAppearanceAdapter extends ArrayAdapter { + + private OsmandApplication app; + private GpxAppearanceAdapterType adapterType; + private int currentColor; + + public enum GpxAppearanceAdapterType { + TRACK_WIDTH, + TRACK_COLOR, + TRACK_WIDTH_COLOR + } + + public GpxAppearanceAdapter(Context context, String currentColorValue, GpxAppearanceAdapterType adapterType) { + super(context, R.layout.rendering_prop_menu_item); + this.app = (OsmandApplication) context.getApplicationContext(); + this.adapterType = adapterType; + RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); + this.currentColor = parseTrackColor(renderer, currentColorValue); + init(); + } + + public GpxAppearanceAdapter(Context context, int currentColor, GpxAppearanceAdapterType adapterType) { + super(context, R.layout.rendering_prop_menu_item); + this.app = (OsmandApplication) context.getApplicationContext(); + this.adapterType = adapterType; + this.currentColor = currentColor; + init(); + } + + @NonNull + @Override + public View getView(int position, View convertView, @NonNull ViewGroup parent) { + AppearanceListItem item = getItem(position); + View v = convertView; + if (v == null) { + v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null); + } + if (item != null) { + TextView textView = (TextView) v.findViewById(R.id.text1); + textView.setText(item.localizedValue); + if (ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR.equals(item.attrName)) { + int iconId; + if ("bold".equals(item.value)) { + iconId = R.drawable.ic_action_gpx_width_bold; + } else if ("medium".equals(item.value)) { + iconId = R.drawable.ic_action_gpx_width_medium; + } else { + iconId = R.drawable.ic_action_gpx_width_thin; + } + textView.setCompoundDrawablesWithIntrinsicBounds(null, null, + app.getUIUtilities().getPaintedIcon(iconId, currentColor), null); + } else { + if (item.color == -1) { + textView.setCompoundDrawablesWithIntrinsicBounds(null, null, + app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null); + } else { + textView.setCompoundDrawablesWithIntrinsicBounds(null, null, + app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, item.color), null); + } + } + textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f)); + v.findViewById(R.id.divider).setVisibility(item.lastItem + && position < getCount() - 1 ? View.VISIBLE : View.GONE); + } + return v; + } + + public void init() { + RenderingRuleProperty trackWidthProp = null; + RenderingRuleProperty trackColorProp = null; + RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); + if (renderer != null) { + if (adapterType == GpxAppearanceAdapterType.TRACK_WIDTH || adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) { + trackWidthProp = renderer.PROPS.getCustomRule(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR); + } + if (adapterType == GpxAppearanceAdapterType.TRACK_COLOR || adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) { + trackColorProp = renderer.PROPS.getCustomRule(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR); + } + } + + if (trackWidthProp != null) { + AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR, "", + SettingsActivity.getStringPropertyValue(getContext(), trackWidthProp.getDefaultValueDescription())); + add(item); + for (int j = 0; j < trackWidthProp.getPossibleValues().length; j++) { + item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR, + trackWidthProp.getPossibleValues()[j], + SettingsActivity.getStringPropertyValue(getContext(), trackWidthProp.getPossibleValues()[j])); + add(item); + } + item.setLastItem(true); + } + if (trackColorProp != null) { + AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR, "", + SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getDefaultValueDescription()), + parseTrackColor(renderer, "")); + add(item); + for (int j = 0; j < trackColorProp.getPossibleValues().length; j++) { + item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR, + trackColorProp.getPossibleValues()[j], + SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getPossibleValues()[j]), + parseTrackColor(renderer, trackColorProp.getPossibleValues()[j])); + add(item); + } + item.setLastItem(true); + } + } + + public static int parseTrackColor(RenderingRulesStorage renderer, String colorName) { + int defaultColor = -1; + RenderingRule gpxRule = null; + if (renderer != null) { + gpxRule = renderer.getRenderingAttributeRule("gpx"); + } + if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) { + List rules = gpxRule.getIfElseChildren().get(0).getIfElseChildren(); + for (RenderingRule r : rules) { + String cName = r.getStringPropertyValue(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR); + if (!Algorithms.isEmpty(cName) && cName.equals(colorName)) { + return r.getIntPropertyValue(ConfigureMapMenu.COLOR_ATTR); + } + if (cName == null && defaultColor == -1) { + defaultColor = r.getIntPropertyValue(ConfigureMapMenu.COLOR_ATTR); + } + } + } + return defaultColor; + } + + public static String parseTrackColorName(RenderingRulesStorage renderer, int color) { + RenderingRule gpxRule = null; + if (renderer != null) { + gpxRule = renderer.getRenderingAttributeRule("gpx"); + } + if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) { + List rules = gpxRule.getIfElseChildren().get(0).getIfElseChildren(); + for (RenderingRule r : rules) { + String cName = r.getStringPropertyValue(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR); + if (!Algorithms.isEmpty(cName) && color == r.getIntPropertyValue(ConfigureMapMenu.COLOR_ATTR)) { + return cName; + } + } + } + return Algorithms.colorToString(color); + } + + public static class AppearanceListItem { + + private String attrName; + private String value; + private String localizedValue; + private int color; + private boolean lastItem; + + public AppearanceListItem(String attrName, String value, String localizedValue) { + this.attrName = attrName; + this.value = value; + this.localizedValue = localizedValue; + } + + public AppearanceListItem(String attrName, String value, String localizedValue, int color) { + this.attrName = attrName; + this.value = value; + this.localizedValue = localizedValue; + this.color = color; + } + + public String getAttrName() { + return attrName; + } + + public String getValue() { + return value; + } + + public String getLocalizedValue() { + return localizedValue; + } + + public int getColor() { + return color; + } + + public boolean isLastItem() { + return lastItem; + } + + public void setLastItem(boolean lastItem) { + this.lastItem = lastItem; + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java b/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java new file mode 100644 index 0000000000..d369ac0ea2 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java @@ -0,0 +1,229 @@ +package net.osmand.plus.dialogs; + +import android.content.DialogInterface; +import android.content.Intent; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.CompoundButton; + +import androidx.appcompat.app.AlertDialog; + +import net.osmand.AndroidUtils; +import net.osmand.CallbackWithObject; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; +import net.osmand.plus.ContextMenuItem; +import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.MapActivityLayers; +import net.osmand.plus.activities.PluginActivity; +import net.osmand.plus.dashboard.DashboardOnMap; +import net.osmand.plus.poi.PoiFiltersHelper; +import net.osmand.plus.poi.PoiUIFilter; +import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.transport.TransportLinesMenu; +import net.osmand.plus.wikipedia.WikipediaPoiMenu; +import net.osmand.util.Algorithms; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +final class MapLayerMenuListener extends OnRowItemClick { + + private MapActivity mapActivity; + private ContextMenuAdapter menuAdapter; + + MapLayerMenuListener(MapActivity mapActivity, ContextMenuAdapter menuAdapter) { + this.mapActivity = mapActivity; + this.menuAdapter = menuAdapter; + } + + private List getAlreadySelectedGpx() { + GpxSelectionHelper selectedGpxHelper = mapActivity.getMyApplication().getSelectedGpxHelper(); + List selectedGpxFiles = selectedGpxHelper.getSelectedGPXFiles(); + + List files = new ArrayList<>(); + for (SelectedGpxFile file : selectedGpxFiles) { + files.add(file.getGpxFile().path); + } + if (selectedGpxFiles.isEmpty()) { + Map fls = selectedGpxHelper.getSelectedGpxFilesBackUp(); + for (Map.Entry f : fls.entrySet()) { + if (!Algorithms.isEmpty(f.getKey().path)) { + File file = new File(f.getKey().path); + if (file.exists() && !file.isDirectory()) { + files.add(f.getKey().path); + } + } + } + } + + return files; + } + + @Override + public boolean onRowItemClick(final ArrayAdapter adapter, View view, int itemId, int pos) { + if (itemId == R.string.layer_poi) { + showPoiFilterDialog(adapter, adapter.getItem(pos)); + return false; + } else if (itemId == R.string.layer_gpx_layer && menuAdapter.getItem(pos).getSelected()) { + showGpxSelectionDialog(adapter, adapter.getItem(pos)); + return false; + } else if (itemId == R.string.shared_string_wikipedia) { + mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.WIKIPEDIA, + AndroidUtils.getCenterViewCoordinates(view)); + return false; + } else if (itemId == R.string.rendering_category_transport) { + final ContextMenuItem item = adapter.getItem(pos); + TransportLinesMenu.showTransportsDialog(mapActivity, new CallbackWithObject() { + @Override + public boolean processResult(Boolean result) { + if (item != null) { + item.setSelected(result); + item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.notifyDataSetChanged(); + } + return true; + } + }); + boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication()); + if (!selected && item != null) { + item.setSelected(true); + item.setColorRes(R.color.osmand_orange); + adapter.notifyDataSetChanged(); + } + return false; + } else { + CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item); + if (btn != null && btn.getVisibility() == View.VISIBLE) { + btn.setChecked(!btn.isChecked()); + menuAdapter.getItem(pos).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.notifyDataSetChanged(); + return false; + } else { + return onContextMenuClick(adapter, itemId, pos, false, null); + } + } + } + + @Override + public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, + final int pos, boolean isChecked, int[] viewCoordinates) { + final OsmandSettings settings = mapActivity.getMyApplication().getSettings(); + final PoiFiltersHelper poiFiltersHelper = mapActivity.getMyApplication().getPoiFilters(); + final ContextMenuItem item = menuAdapter.getItem(pos); + if (item.getSelected() != null) { + item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + } + if (itemId == R.string.layer_poi) { + PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter(); + poiFiltersHelper.clearSelectedPoiFilters(wiki); + if (isChecked) { + showPoiFilterDialog(adapter, adapter.getItem(pos)); + } else { + adapter.getItem(pos).setDescription( + poiFiltersHelper.getSelectedPoiFiltersName(wiki)); + } + } else if (itemId == R.string.layer_amenity_label) { + settings.SHOW_POI_LABEL.set(isChecked); + } else if (itemId == R.string.shared_string_favorites) { + settings.SHOW_FAVORITES.set(isChecked); + } else if (itemId == R.string.layer_gpx_layer) { + final GpxSelectionHelper selectedGpxHelper = mapActivity.getMyApplication().getSelectedGpxHelper(); + if (selectedGpxHelper.isShowingAnyGpxFiles()) { + selectedGpxHelper.clearAllGpxFilesToShow(true); + adapter.getItem(pos).setDescription(selectedGpxHelper.getGpxDescription()); + } else { + showGpxSelectionDialog(adapter, adapter.getItem(pos)); + } + } else if (itemId == R.string.shared_string_wikipedia) { + WikipediaPoiMenu.toggleWikipediaPoi(mapActivity, isChecked, new CallbackWithObject() { + @Override + public boolean processResult(Boolean selected) { + item.setSelected(selected); + item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setDescription(selected ? + WikipediaPoiMenu.getLanguagesSummary(mapActivity.getMyApplication()) : null); + adapter.notifyDataSetChanged(); + return true; + } + }); + } else if (itemId == R.string.rendering_category_transport) { + boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication()); + TransportLinesMenu.toggleTransportLines(mapActivity, !selected, new CallbackWithObject() { + @Override + public boolean processResult(Boolean result) { + item.setSelected(result); + item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.notifyDataSetChanged(); + return true; + } + }); + } else if (itemId == R.string.map_markers) { + settings.SHOW_MAP_MARKERS.set(isChecked); + } else if (itemId == R.string.layer_map) { + if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) { + Intent intent = new Intent(mapActivity, PluginActivity.class); + intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, OsmandRasterMapsPlugin.ID); + mapActivity.startActivity(intent); + } else { + ContextMenuItem it = adapter.getItem(pos); + mapActivity.getMapLayers().selectMapLayer(mapActivity.getMapView(), it, adapter); + } + } + adapter.notifyDataSetChanged(); + mapActivity.getMapLayers().updateLayers(mapActivity.getMapView()); + mapActivity.getMapView().refreshMap(); + return false; + } + + private void showGpxSelectionDialog(final ArrayAdapter adapter, + final ContextMenuItem item) { + AlertDialog dialog = mapActivity.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(), + mapActivity.getMapView()); + dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + OsmandApplication app = mapActivity.getMyApplication(); + boolean selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles(); + item.setSelected(selected); + item.setDescription(app.getSelectedGpxHelper().getGpxDescription()); + item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.notifyDataSetChanged(); + } + }); + } + + protected void showPoiFilterDialog(final ArrayAdapter adapter, + final ContextMenuItem item) { + final PoiFiltersHelper poiFiltersHelper = mapActivity.getMyApplication().getPoiFilters(); + final PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter(); + MapActivityLayers.DismissListener dismissListener = + new MapActivityLayers.DismissListener() { + @Override + public void dismiss() { + PoiFiltersHelper pf = mapActivity.getMyApplication().getPoiFilters(); + boolean selected = pf.isShowingAnyPoi(wiki); + item.setSelected(selected); + item.setDescription(pf.getSelectedPoiFiltersName(wiki)); + item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.notifyDataSetChanged(); + } + }; + if (poiFiltersHelper.isShowingAnyPoi(wiki)) { + mapActivity.getMapLayers().showMultichoicePoiFilterDialog(mapActivity.getMapView(), + dismissListener); + } else { + mapActivity.getMapLayers().showSingleChoicePoiFilterDialog(mapActivity.getMapView(), + dismissListener); + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 356f8c9870..c3dc6c2ae6 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -80,7 +80,6 @@ import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; @@ -90,10 +89,11 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.PluginActivity; import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.dialogs.ConfigureMapMenu; -import net.osmand.plus.dialogs.ConfigureMapMenu.AppearanceListItem; -import net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter; +import net.osmand.plus.dialogs.GpxAppearanceAdapter; +import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.routing.RouteCalculationResult; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRulesStorage; import net.osmand.router.RouteStatisticsHelper; @@ -540,9 +540,9 @@ public class GpxUiHelper { public void onItemClick(AdapterView parent, View view, int position, long id) { AppearanceListItem item = gpxApprAdapter.getItem(position); if (item != null) { - if (item.getAttrName() == CURRENT_TRACK_WIDTH_ATTR) { + if (CURRENT_TRACK_WIDTH_ATTR.equals(item.getAttrName())) { gpxAppearanceParams.put(CURRENT_TRACK_WIDTH_ATTR, item.getValue()); - } else if (item.getAttrName() == CURRENT_TRACK_COLOR_ATTR) { + } else if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) { gpxAppearanceParams.put(CURRENT_TRACK_COLOR_ATTR, item.getValue()); } } @@ -592,7 +592,7 @@ public class GpxUiHelper { } dialog.dismiss(); loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX, - s.toArray(new String[s.size()])); + s.toArray(new String[0])); } }); builder.setNegativeButton(R.string.shared_string_cancel, null); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java index 25d9d7450a..61820c3f55 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java @@ -1,5 +1,6 @@ package net.osmand.plus.myplaces; +import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; @@ -14,8 +15,10 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.AbsListView; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ImageView; +import android.widget.ListAdapter; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; @@ -49,19 +52,23 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TrackActivity; -import net.osmand.plus.dialogs.ConfigureMapMenu; +import net.osmand.plus.dialogs.GpxAppearanceAdapter; +import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; +import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType; import net.osmand.plus.measurementtool.NewGpxData; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.WikivoyageUtils; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.render.RenderingRulesStorage; +import net.osmand.util.Algorithms; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -71,6 +78,7 @@ import java.util.Map; import gnu.trove.list.array.TIntArrayList; import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR; +import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR; public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { @@ -356,50 +364,27 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { @Override public void onClick(View v) { TrackActivity activity = getTrackActivity(); - if (activity != null) { - colorListPopupWindow = new ListPopupWindow(activity); - colorListPopupWindow.setAnchorView(colorView); - colorListPopupWindow.setContentWidth(AndroidUtils.dpToPx(app, 200f)); - colorListPopupWindow.setModal(true); - colorListPopupWindow.setDropDownGravity(Gravity.RIGHT | Gravity.TOP); - colorListPopupWindow.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); - colorListPopupWindow.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); - GPXFile gpxFile = getGpx(); - final ConfigureMapMenu.GpxAppearanceAdapter gpxApprAdapter = new ConfigureMapMenu.GpxAppearanceAdapter(activity, - gpxFile.getColor(0), ConfigureMapMenu.GpxAppearanceAdapter.GpxAppearanceAdapterType.TRACK_COLOR); - colorListPopupWindow.setAdapter(gpxApprAdapter); - colorListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { + final GPXFile gpxFile = getGpx(); + if (activity != null && gpxFile != null) { + final GpxAppearanceAdapter appearanceAdapter = new GpxAppearanceAdapter(activity, + gpxFile.getColor(0), GpxAppearanceAdapterType.TRACK_WIDTH_COLOR); + OnItemClickListener itemClickListener = new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - ConfigureMapMenu.AppearanceListItem item = gpxApprAdapter.getItem(position); + AppearanceListItem item = appearanceAdapter.getItem(position); if (item != null) { if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) { - GPXFile gpx = getGpx(); - int clr = item.getColor(); - if (vis.isChecked()) { - if (gpx != null) { - SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, vis.isChecked(), false); - if (clr != 0 && sf.getModifiableGpxFile() != null) { - sf.getModifiableGpxFile().setColor(clr); - if (getGpxDataItem() != null) { - app.getGpxDbHelper().updateColor(getGpxDataItem(), clr); - } - } - } - } else if (getGpxDataItem() != null) { - app.getGpxDbHelper().updateColor(getGpxDataItem(), clr); - } - if (gpx != null && gpx.showCurrentTrack) { - app.getSettings().CURRENT_TRACK_COLOR.set(clr); - } - refreshTrackBitmap(); + setGpxColor(item, gpxFile); + } else if (CURRENT_TRACK_WIDTH_ATTR.equals(item.getAttrName())) { + setGpxWidth(item, gpxFile); } } colorListPopupWindow.dismiss(); updateColorView(colorView); } - }); + }; + colorListPopupWindow = createPopupWindow(activity, splitIntervalView, appearanceAdapter, itemClickListener); colorListPopupWindow.show(); } } @@ -415,16 +400,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { public void onClick(View v) { TrackActivity activity = getTrackActivity(); if (activity != null) { - splitListPopupWindow = new ListPopupWindow(activity); - splitListPopupWindow.setAnchorView(splitIntervalView); - splitListPopupWindow.setContentWidth(AndroidUtils.dpToPx(app, 200f)); - splitListPopupWindow.setModal(true); - splitListPopupWindow.setDropDownGravity(Gravity.RIGHT | Gravity.TOP); - splitListPopupWindow.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); - splitListPopupWindow.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); - splitListPopupWindow.setAdapter(new ArrayAdapter<>(activity, - R.layout.popup_list_text_item, options)); - splitListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { + ListAdapter adapter = new ArrayAdapter<>(activity, R.layout.popup_list_text_item, options); + OnItemClickListener itemClickListener = new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { @@ -433,7 +410,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { splitListPopupWindow.dismiss(); updateSplitIntervalView(splitIntervalView); } - }); + }; + splitListPopupWindow = createPopupWindow(activity, splitIntervalView, adapter, itemClickListener); splitListPopupWindow.show(); } } @@ -451,6 +429,55 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { } } + private void setGpxColor(AppearanceListItem item, GPXFile gpxFile) { + int color = item.getColor(); + if (vis.isChecked()) { + SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, vis.isChecked(), false); + if (color != 0 && sf.getModifiableGpxFile() != null) { + sf.getModifiableGpxFile().setColor(color); + if (getGpxDataItem() != null) { + app.getGpxDbHelper().updateColor(getGpxDataItem(), color); + } + } + } else if (getGpxDataItem() != null) { + app.getGpxDbHelper().updateColor(getGpxDataItem(), color); + } + if (gpxFile.showCurrentTrack) { + app.getSettings().CURRENT_TRACK_COLOR.set(color); + } + refreshTrackBitmap(); + } + + private void setGpxWidth(AppearanceListItem item, GPXFile gpxFile) { + String width = item.getValue(); + if (vis.isChecked()) { + SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, vis.isChecked(), false); + if (!Algorithms.isEmpty(width) && sf.getModifiableGpxFile() != null) { + sf.getModifiableGpxFile().setWidth(width); + if (getGpxDataItem() != null) { + app.getGpxDbHelper().updateWidth(getGpxDataItem(), width); + } + } + } else if (getGpxDataItem() != null) { + app.getGpxDbHelper().updateWidth(getGpxDataItem(), width); + } + refreshTrackBitmap(); + } + + private ListPopupWindow createPopupWindow(Activity activity, View anchorView, ListAdapter adapter, OnItemClickListener itemClickListener) { + ListPopupWindow popupWindow = new ListPopupWindow(activity); + popupWindow.setAnchorView(anchorView); + popupWindow.setContentWidth(AndroidUtils.dpToPx(app, 200f)); + popupWindow.setModal(true); + popupWindow.setDropDownGravity(Gravity.RIGHT | Gravity.TOP); + popupWindow.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); + popupWindow.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); + popupWindow.setAdapter(adapter); + popupWindow.setOnItemClickListener(itemClickListener); + + return popupWindow; + } + @Nullable private View getDescriptionCardView(Context context) { GPXFile gpx = getGpx(); @@ -729,7 +756,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { text.setText(options.get(selectedSplitInterval)); } } - + private int getSelectedSplitInterval() { if (getGpxDataItem() == null) { return 0; @@ -737,14 +764,14 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { int splitType = getGpxDataItem().getSplitType(); double splitInterval = getGpxDataItem().getSplitInterval(); int position = 0; - + if (splitType == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) { position = distanceSplit.indexOf(splitInterval); } else if (splitType == GPXDatabase.GPX_SPLIT_TYPE_TIME) { position = timeSplit.indexOf((int) splitInterval); } - - return position > 0 ? position : 0; + + return Math.max(position, 0); } private void updateColorView(View colorView) { @@ -759,10 +786,9 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { } } if (color == 0) { - final RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); - final OsmandSettings.CommonPreference prefColor - = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR); - color = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor(renderer, prefColor.get()); + RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); + CommonPreference prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR); + color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColor.get()); } if (color == 0) { colorImageView.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle)); diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index fdc9ab950e..4adc2ef5ff 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -26,6 +26,7 @@ import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; import net.osmand.Location; +import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; @@ -55,6 +56,8 @@ import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; +import org.apache.commons.logging.Log; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -67,6 +70,7 @@ import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR; public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IMoveObjectProvider, MapTextProvider { + private static final Log log = PlatformUtil.getLog(GPXLayer.class); private static final double TOUCH_RADIUS_MULTIPLIER = 1.5; private static final int START_ZOOM = 7; @@ -81,6 +85,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private boolean isPaint_1; private int cachedHash; private int cachedColor; + private Map cachedWidth = new HashMap<>(); private Paint paintIcon; private int currentTrackColor; @@ -220,29 +225,30 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } - private int updatePaints(int color, boolean routePoints, boolean currentTrack, DrawSettings nightMode, RotatedTileBox tileBox) { + private int updatePaints(int color, String width, boolean routePoints, boolean currentTrack, DrawSettings nightMode, RotatedTileBox tileBox) { RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); final boolean isNight = nightMode != null && nightMode.isNightMode(); - int hsh = calculateHash(rrs, routePoints, isNight, tileBox.getMapDensity(), tileBox.getZoom(), - currentTrackColorPref.get(), currentTrackWidthPref.get()); + int hsh = calculateHash(rrs, cachedWidth, routePoints, isNight, tileBox.getMapDensity(), tileBox.getZoom(), + currentTrackColorPref.get(), currentTrackWidthPref.get()); + String widthKey = width; if (hsh != cachedHash) { + log.debug("updatePaints new HASH " + width); cachedHash = hsh; cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track); if (rrs != null) { RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, isNight); - CommonPreference p = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR); - if (p != null && p.isSet()) { + if (currentTrackColorPref != null && currentTrackColorPref.isSet()) { RenderingRuleProperty ctColor = rrs.PROPS.get(CURRENT_TRACK_COLOR_ATTR); if (ctColor != null) { - req.setStringFilter(ctColor, p.get()); + req.setStringFilter(ctColor, currentTrackColorPref.get()); } } - CommonPreference p2 = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR); - if (p2 != null && p2.isSet()) { + if (currentTrackWidthPref != null && currentTrackWidthPref.isSet()) { RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); if (ctWidth != null) { - req.setStringFilter(ctWidth, p2.get()); + widthKey = width == null ? currentTrackWidthPref.get() : width; + req.setStringFilter(ctWidth, widthKey); } } String additional = ""; @@ -261,6 +267,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); rc.setDensityValue((float) tileBox.getMapDensity()); cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR); + + float widthF = rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH); + cachedWidth.put(widthKey, widthF); + osmandRenderer.updatePaint(req, paint, 0, false, rc); isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); isPaint_1 = osmandRenderer.updatePaint(req, paint_1, -1, false, rc); @@ -279,6 +289,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } } paint.setColor(color == 0 ? cachedColor : color); + Float strikeWidth = cachedWidth.get(widthKey); + if (strikeWidth != null) { + paint.setStrokeWidth(strikeWidth); + } return cachedColor; } @@ -536,6 +550,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM RotatedTileBox tileBox, DrawSettings settings) { List segments = selectedGpxFile.getPointsToDisplay(); for (TrkSegment ts : segments) { + String width = selectedGpxFile.getGpxFile().getWidth(null); + if (!cachedWidth.containsKey(width)) { + cachedWidth.put(width, null); + } int color = selectedGpxFile.getGpxFile().getColor(0); if (currentTrack) { color = currentTrackColor; @@ -550,8 +568,8 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM ts.renderer = new Renderable.StandardTrack(ts.points, 17.2); } } - updatePaints(color, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox); - if(ts.renderer instanceof Renderable.RenderableSegment) { + updatePaints(color, width, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox); + if (ts.renderer instanceof Renderable.RenderableSegment) { ((Renderable.RenderableSegment) ts.renderer).drawSegment(view.getZoom(), paint, canvas, tileBox); } } From ddd66a9f84dce160f8e5fa1875b25cba5ea9d851 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 26 Jun 2020 11:09:33 +0300 Subject: [PATCH 002/551] Fix track width draw cache --- .../TrackActivityFragmentAdapter.java | 3 +- .../src/net/osmand/plus/views/GPXLayer.java | 116 ++++++++---------- 2 files changed, 50 insertions(+), 69 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java index 61820c3f55..0304618a7c 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java @@ -68,7 +68,6 @@ import net.osmand.plus.wikivoyage.WikivoyageUtils; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.render.RenderingRulesStorage; -import net.osmand.util.Algorithms; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -452,7 +451,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { String width = item.getValue(); if (vis.isChecked()) { SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, vis.isChecked(), false); - if (!Algorithms.isEmpty(width) && sf.getModifiableGpxFile() != null) { + if (width != null && sf.getModifiableGpxFile() != null) { sf.getModifiableGpxFile().setWidth(width); if (getGpxDataItem() != null) { app.getGpxDbHelper().updateWidth(getGpxDataItem(), width); diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 4adc2ef5ff..8646c6effb 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -2,7 +2,6 @@ package net.osmand.plus.views; import android.graphics.Canvas; import android.graphics.Color; -import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.Paint.Align; import android.graphics.Paint.Style; @@ -26,7 +25,6 @@ import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; import net.osmand.Location; -import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; @@ -56,8 +54,6 @@ import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; -import org.apache.commons.logging.Log; - import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -70,22 +66,16 @@ import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR; public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IMoveObjectProvider, MapTextProvider { - private static final Log log = PlatformUtil.getLog(GPXLayer.class); private static final double TOUCH_RADIUS_MULTIPLIER = 1.5; private static final int START_ZOOM = 7; private OsmandMapTileView view; private Paint paint; - private Paint paint2; - private boolean isPaint2; private Paint shadowPaint; - private boolean isShadowPaint; - private Paint paint_1; - private boolean isPaint_1; private int cachedHash; private int cachedColor; - private Map cachedWidth = new HashMap<>(); + private Map cachedTrackWidth = new HashMap<>(); private Paint paintIcon; private int currentTrackColor; @@ -94,7 +84,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private GpxSelectionHelper selectedGpxHelper; private MapMarkersHelper mapMarkersHelper; - private Paint paintBmp; private List cache = new ArrayList<>(); private Map pointFileMap = new HashMap<>(); private MapTextLayer textLayer; @@ -139,26 +128,14 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM paint = new Paint(); paint.setStyle(Style.STROKE); paint.setAntiAlias(true); - paint2 = new Paint(); - paint2.setStyle(Style.STROKE); - paint2.setAntiAlias(true); shadowPaint = new Paint(); shadowPaint.setStyle(Style.STROKE); shadowPaint.setAntiAlias(true); - paint_1 = new Paint(); - paint_1.setStyle(Style.STROKE); - paint_1.setAntiAlias(true); - - paintBmp = new Paint(); - paintBmp.setAntiAlias(true); - paintBmp.setFilterBitmap(true); - paintBmp.setDither(true); paintTextIcon = new Paint(); paintTextIcon.setTextSize(10 * view.getDensity()); paintTextIcon.setTextAlign(Align.CENTER); paintTextIcon.setFakeBoldText(true); -// paintTextIcon.setColor(Color.WHITE); paintTextIcon.setAntiAlias(true); textLayer = view.getLayerByClass(MapTextLayer.class); @@ -169,17 +146,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM paintOuterRect = new Paint(); paintOuterRect.setStyle(Style.STROKE); paintOuterRect.setAntiAlias(true); -// paintOuterRect.setColor(Color.WHITE); paintOuterRect.setStrokeWidth(3); paintOuterRect.setAlpha(255); paintGridCircle = new Paint(); paintGridCircle.setStyle(Style.FILL_AND_STROKE); paintGridCircle.setAntiAlias(true); - paintGridOuterCircle = new Paint(); - paintGridOuterCircle.setStyle(Style.FILL_AND_STROKE); - paintGridOuterCircle.setAntiAlias(true); - paintGridOuterCircle.setColor(Color.WHITE); - paintGridOuterCircle.setAlpha(204); + paintGridOuterCircle = new Paint(); + paintGridOuterCircle.setStyle(Style.FILL_AND_STROKE); + paintGridOuterCircle.setAntiAlias(true); + paintGridOuterCircle.setColor(Color.WHITE); + paintGridOuterCircle.setAlpha(204); paintIcon = new Paint(); selectedPoint = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), R.drawable.map_location_default); @@ -225,19 +201,17 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } - private int updatePaints(int color, String width, boolean routePoints, boolean currentTrack, DrawSettings nightMode, RotatedTileBox tileBox) { + private int updatePaints(int color, String width, boolean routePoints, boolean currentTrack, DrawSettings drawSettings, RotatedTileBox tileBox) { RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); - final boolean isNight = nightMode != null && nightMode.isNightMode(); - int hsh = calculateHash(rrs, cachedWidth, routePoints, isNight, tileBox.getMapDensity(), tileBox.getZoom(), + boolean nightMode = drawSettings != null && drawSettings.isNightMode(); + int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(), currentTrackColorPref.get(), currentTrackWidthPref.get()); - String widthKey = width; - if (hsh != cachedHash) { - log.debug("updatePaints new HASH " + width); - cachedHash = hsh; + if (hash != cachedHash) { + cachedHash = hash; cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track); if (rrs != null) { RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); - req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, isNight); + req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); if (currentTrackColorPref != null && currentTrackColorPref.isSet()) { RenderingRuleProperty ctColor = rrs.PROPS.get(CURRENT_TRACK_COLOR_ATTR); if (ctColor != null) { @@ -247,8 +221,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM if (currentTrackWidthPref != null && currentTrackWidthPref.isSet()) { RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); if (ctWidth != null) { - widthKey = width == null ? currentTrackWidthPref.get() : width; - req.setStringFilter(ctWidth, widthKey); + req.setStringFilter(ctWidth, currentTrackWidthPref.get()); } } String additional = ""; @@ -267,20 +240,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); rc.setDensityValue((float) tileBox.getMapDensity()); cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR); - - float widthF = rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH); - cachedWidth.put(widthKey, widthF); - osmandRenderer.updatePaint(req, paint, 0, false, rc); - isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); - isPaint_1 = osmandRenderer.updatePaint(req, paint_1, -1, false, rc); - isShadowPaint = req.isSpecified(rrs.PROPS.R_SHADOW_RADIUS); - if (isShadowPaint) { - ColorFilter cf = new PorterDuffColorFilter(req.getIntPropertyValue(rrs.PROPS.R_SHADOW_COLOR), - Mode.SRC_IN); - shadowPaint.setColorFilter(cf); - shadowPaint.setStrokeWidth(paint.getStrokeWidth() + 2 - * rc.getComplexValue(req, rrs.PROPS.R_SHADOW_RADIUS)); + + if (req.isSpecified(rrs.PROPS.R_SHADOW_RADIUS)) { + int shadowColor = req.getIntPropertyValue(rrs.PROPS.R_SHADOW_COLOR); + float shadowRadius = rc.getComplexValue(req, rrs.PROPS.R_SHADOW_RADIUS); + shadowPaint.setColorFilter(new PorterDuffColorFilter(shadowColor, Mode.SRC_IN)); + shadowPaint.setStrokeWidth(paint.getStrokeWidth() + 2 * shadowRadius); + } + for (String key : cachedTrackWidth.keySet()) { + searchTrackWidth(key, rrs, req, rc); } } else { System.err.println("Rendering attribute gpx is not found !"); @@ -289,19 +258,30 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } } paint.setColor(color == 0 ? cachedColor : color); - Float strikeWidth = cachedWidth.get(widthKey); + Float strikeWidth = cachedTrackWidth.get(width); if (strikeWidth != null) { paint.setStrokeWidth(strikeWidth); } return cachedColor; } + private void searchTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) { + RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); + if (ctWidth != null) { + req.setStringFilter(ctWidth, widthKey); + } + if (req.searchRenderingAttribute("gpx")) { + float widthF = rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH); + cachedTrackWidth.put(widthKey, widthF); + } + } + private int calculateHash(Object... o) { return Arrays.hashCode(o); } private void drawSelectedFilesSplits(Canvas canvas, RotatedTileBox tileBox, List selectedGPXFiles, - DrawSettings settings) { + DrawSettings settings) { if (tileBox.getZoom() >= START_ZOOM) { // request to load for (SelectedGpxFile g : selectedGPXFiles) { @@ -368,11 +348,11 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM paintTextIcon.getTextBounds(nm, 0, nm.length(), bounds); int nmWidth = bounds.width(); int nmHeight = bounds.height(); - RectF rect = new RectF(x - nmWidth / 2 - 2 * (float) Math.ceil(tileBox.getDensity()), - y + nmHeight / 2 + 3 * (float) Math.ceil(tileBox.getDensity()), - x + nmWidth / 2 + 3 * (float) Math.ceil(tileBox.getDensity()), - y - nmHeight / 2 - 2 * (float) Math.ceil(tileBox.getDensity())); - canvas.drawRoundRect(rect, 0, 0, paintInnerRect); + RectF rect = new RectF(x - nmWidth / 2 - 2 * (float) Math.ceil(tileBox.getDensity()), + y + nmHeight / 2 + 3 * (float) Math.ceil(tileBox.getDensity()), + x + nmWidth / 2 + 3 * (float) Math.ceil(tileBox.getDensity()), + y - nmHeight / 2 - 2 * (float) Math.ceil(tileBox.getDensity())); + canvas.drawRoundRect(rect, 0, 0, paintInnerRect); canvas.drawRoundRect(rect, 0, 0, paintOuterRect); // canvas.drawRect(rect, paintInnerRect); // canvas.drawRect(rect, paintOuterRect); @@ -477,7 +457,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM trackChartPoints.setSegmentColor(color); } paintGridCircle.setColor(color); - paintGridCircle.setAlpha(255); + paintGridCircle.setAlpha(255); QuadRect latLonBounds = tileBox.getLatLonBounds(); float r = 3 * tileBox.getDensity(); List xAxisPoints = trackChartPoints.getXAxisPoints(); @@ -531,8 +511,13 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox, - List selectedGPXFiles, DrawSettings settings) { - + List selectedGPXFiles, DrawSettings settings) { + for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) { + String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get()); + if (!cachedTrackWidth.containsKey(width)) { + cachedTrackWidth.put(width, null); + } + } SelectedGpxFile currentTrack = null; for (SelectedGpxFile g : selectedGPXFiles) { if (g.isShowCurrentTrack()) { @@ -550,10 +535,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM RotatedTileBox tileBox, DrawSettings settings) { List segments = selectedGpxFile.getPointsToDisplay(); for (TrkSegment ts : segments) { - String width = selectedGpxFile.getGpxFile().getWidth(null); - if (!cachedWidth.containsKey(width)) { - cachedWidth.put(width, null); - } + String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get()); int color = selectedGpxFile.getGpxFile().getColor(0); if (currentTrack) { color = currentTrackColor; From 5dc3a5a484d313bee354d5621b4b6f6b048fd816 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 26 Jun 2020 18:44:49 +0300 Subject: [PATCH 003/551] Add support for custom gpx width --- .../src/net/osmand/plus/views/GPXLayer.java | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 8646c6effb..68e31dc4ca 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -20,11 +20,13 @@ import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; +import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; import net.osmand.Location; +import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; @@ -54,6 +56,8 @@ import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; +import org.apache.commons.logging.Log; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -66,6 +70,8 @@ import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR; public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IMoveObjectProvider, MapTextProvider { + private static final Log log = PlatformUtil.getLog(GPXLayer.class); + private static final double TOUCH_RADIUS_MULTIPLIER = 1.5; private static final int START_ZOOM = 7; @@ -73,10 +79,11 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private Paint paint; private Paint shadowPaint; + private Paint paintIcon; private int cachedHash; private int cachedColor; + private float defaultTrackWidth; private Map cachedTrackWidth = new HashMap<>(); - private Paint paintIcon; private int currentTrackColor; private LayerDrawable selectedPoint; @@ -209,6 +216,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM if (hash != cachedHash) { cachedHash = hash; cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track); + defaultTrackWidth = 7 * view.getDensity(); if (rrs != null) { RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); @@ -252,8 +260,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM searchTrackWidth(key, rrs, req, rc); } } else { - System.err.println("Rendering attribute gpx is not found !"); - paint.setStrokeWidth(7 * view.getDensity()); + log.error("Rendering attribute gpx is not found !"); + for (String key : cachedTrackWidth.keySet()) { + cachedTrackWidth.put(key, defaultTrackWidth); + } } } } @@ -266,13 +276,24 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } private void searchTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) { - RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); - if (ctWidth != null) { - req.setStringFilter(ctWidth, widthKey); - } - if (req.searchRenderingAttribute("gpx")) { - float widthF = rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH); - cachedTrackWidth.put(widthKey, widthF); + if (!Algorithms.isEmpty(widthKey) && Algorithms.isInt(widthKey)) { + try { + int widthDp = Integer.parseInt(widthKey); + float widthF = AndroidUtils.dpToPx(view.getApplication(), widthDp); + cachedTrackWidth.put(widthKey, widthF); + } catch (NumberFormatException e) { + log.error(e.getMessage(), e); + cachedTrackWidth.put(widthKey, defaultTrackWidth); + } + } else { + RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); + if (ctWidth != null) { + req.setStringFilter(ctWidth, widthKey); + } + if (req.searchRenderingAttribute("gpx")) { + float widthF = rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH); + cachedTrackWidth.put(widthKey, widthF); + } } } From 08a8281a8ce84c34162f6bb6a9a310394b42778e Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 3 Jul 2020 14:10:20 +0300 Subject: [PATCH 004/551] Add show arrows and show start finish gpx params --- .../main/java/net/osmand/GPXUtilities.java | 24 +++++ OsmAnd/src/net/osmand/plus/GPXDatabase.java | 90 +++++++++++++++++-- OsmAnd/src/net/osmand/plus/GpxDbHelper.java | 20 ++++- .../net/osmand/plus/GpxSelectionHelper.java | 14 +++ 4 files changed, 138 insertions(+), 10 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 4b266588b8..ef54ed7edb 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -160,6 +160,30 @@ public class GPXUtilities { getExtensionsToWrite().put("width", width); } + public boolean isShowArrows() { + String showArrows = null; + if (extensions != null) { + showArrows = extensions.get("showArrows"); + } + return Boolean.parseBoolean(showArrows); + } + + public void setShowArrows(boolean showArrows) { + getExtensionsToWrite().put("showArrows", String.valueOf(showArrows)); + } + + public boolean isShowStartFinish() { + String showStartFinish = null; + if (extensions != null) { + showStartFinish = extensions.get("showStartFinish"); + } + return Boolean.parseBoolean(showStartFinish); + } + + public void setShowStartFinish(boolean showStartFinish) { + getExtensionsToWrite().put("showStartFinish", String.valueOf(showStartFinish)); + } + public Map getExtensionsToWrite() { if (extensions == null) { extensions = new LinkedHashMap<>(); diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index c1f1e220de..1595e2b3b5 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -57,6 +57,10 @@ public class GPXDatabase { private static final String GPX_COL_JOIN_SEGMENTS = "joinSegments"; + private static final String GPX_COL_SHOW_ARROWS = "showArrows"; + + private static final String GPX_COL_SHOW_START_FINISH = "showStartFinish"; + private static final String GPX_COL_WIDTH = "width"; public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1; @@ -93,6 +97,8 @@ public class GPXDatabase { GPX_COL_WPT_CATEGORY_NAMES + " TEXT, " + GPX_COL_SHOW_AS_MARKERS + " int, " + // 1 = true, 0 = false GPX_COL_JOIN_SEGMENTS + " int, " + // 1 = true, 0 = false + GPX_COL_SHOW_ARROWS + " int, " + // 1 = true, 0 = false + GPX_COL_SHOW_START_FINISH + " int, " + // 1 = true, 0 = false GPX_COL_WIDTH + " TEXT);"; private static final String GPX_TABLE_SELECT = "SELECT " + @@ -122,6 +128,8 @@ public class GPXDatabase { GPX_COL_WPT_CATEGORY_NAMES + ", " + GPX_COL_SHOW_AS_MARKERS + ", " + GPX_COL_JOIN_SEGMENTS + ", " + + GPX_COL_SHOW_ARROWS + ", " + + GPX_COL_SHOW_START_FINISH + ", " + GPX_COL_WIDTH + " FROM " + GPX_TABLE_NAME; @@ -160,6 +168,8 @@ public class GPXDatabase { private boolean apiImported; private boolean showAsMarkers; private boolean joinSegments; + private boolean showArrows; + private boolean showStartFinish; public GpxDataItem(File file, GPXTrackAnalysis analysis) { this.file = file; @@ -228,6 +238,22 @@ public class GPXDatabase { this.joinSegments = joinSegments; } + public boolean isShowArrows() { + return showArrows; + } + + public void setShowArrows(boolean showArrows) { + this.showArrows = showArrows; + } + + public boolean isShowStartFinish() { + return showStartFinish; + } + + public void setShowStartFinish(boolean showStartFinish) { + this.showStartFinish = showStartFinish; + } + @Override public int hashCode() { return file != null ? file.hashCode() : 0; @@ -357,7 +383,14 @@ public class GPXDatabase { "WHERE " + GPX_COL_JOIN_SEGMENTS + " IS NULL", new Object[]{0}); } if (oldVersion < 11) { + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SHOW_ARROWS + " int"); + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SHOW_START_FINISH + " int"); db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_WIDTH + " TEXT"); + + db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " + + "WHERE " + GPX_COL_SHOW_ARROWS + " IS NULL", new Object[]{0}); + db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " + + "WHERE " + GPX_COL_SHOW_START_FINISH + " IS NULL", new Object[]{0}); } db.execSQL("CREATE INDEX IF NOT EXISTS " + GPX_INDEX_NAME_DIR + " ON " + GPX_TABLE_NAME + " (" + GPX_COL_NAME + ", " + GPX_COL_DIR + ");"); } @@ -421,15 +454,51 @@ public class GPXDatabase { return false; } + public boolean updateShowArrows(GpxDataItem item, boolean showArrows) { + SQLiteConnection db = openConnection(false); + if (db != null) { + try { + String fileName = getFileName(item.file); + String fileDir = getFileDir(item.file); + db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " + + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", + new Object[] {showArrows ? 1 : 0, fileName, fileDir}); + item.setShowArrows(showArrows); + } finally { + db.close(); + } + return true; + } + return false; + } + + public boolean updateShowStartFinish(GpxDataItem item, boolean showStartFinish) { + SQLiteConnection db = openConnection(false); + if (db != null) { + try { + String fileName = getFileName(item.file); + String fileDir = getFileDir(item.file); + db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " + + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", + new Object[] {showStartFinish ? 1 : 0, fileName, fileDir}); + item.setShowStartFinish(showStartFinish); + } finally { + db.close(); + } + return true; + } + return false; + } + public boolean updateWidth(GpxDataItem item, String width) { SQLiteConnection db = openConnection(false); - if (db != null){ + if (db != null) { try { String fileName = getFileName(item.file); String fileDir = getFileDir(item.file); db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_WIDTH + " = ? " + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", - new Object[] { width, fileName, fileDir }); + new Object[] {width, fileName, fileDir}); item.width = width; } finally { db.close(); @@ -553,12 +622,13 @@ public class GPXDatabase { } if (a != null) { db.execSQL( - "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[] {fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime, a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown, a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints, color, item.file.lastModified(), item.splitType, item.splitInterval, item.apiImported ? 1 : 0, - Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, item.width}); + Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0, + item.joinSegments ? 1 : 0, item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width}); } else { db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" + GPX_COL_NAME + ", " + @@ -570,9 +640,13 @@ public class GPXDatabase { GPX_COL_API_IMPORTED + ", " + GPX_COL_SHOW_AS_MARKERS + ", " + GPX_COL_JOIN_SEGMENTS + ", " + + GPX_COL_SHOW_ARROWS + ", " + + GPX_COL_SHOW_START_FINISH + ", " + GPX_COL_WIDTH + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, item.width}); + new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, + item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, + item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width}); } } @@ -653,7 +727,9 @@ public class GPXDatabase { String wptCategoryNames = query.getString(23); boolean showAsMarkers = query.getInt(24) == 1; boolean joinSegments = query.getInt(25) == 1; - String width = query.getString(26); + boolean showArrows = query.getInt(26) == 1; + boolean showStartFinish = query.getInt(27) == 1; + String width = query.getString(28); GPXTrackAnalysis a = new GPXTrackAnalysis(); a.totalDistance = totalDistance; @@ -695,6 +771,8 @@ public class GPXDatabase { item.apiImported = apiImported; item.showAsMarkers = showAsMarkers; item.joinSegments = joinSegments; + item.showArrows = showArrows; + item.showStartFinish = showStartFinish; item.width = width; return item; } diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index 6221e91f6f..c929348297 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -77,14 +77,26 @@ public class GpxDbHelper { return res; } - public boolean updateWidth(GpxDataItem item, String width) { - boolean res = db.updateWidth(item, width); + public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) { + boolean res = db.updateShowAsMarkers(item, showAsMarkers); putToCache(item); return res; } - public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) { - boolean res = db.updateShowAsMarkers(item, showAsMarkers); + public boolean updateShowArrows(GpxDataItem item, boolean showArrows) { + boolean res = db.updateShowArrows(item, showArrows); + putToCache(item); + return res; + } + + public boolean updateShowStartFinish(GpxDataItem item, boolean showStartFinish) { + boolean res = db.updateShowStartFinish(item, showStartFinish); + putToCache(item); + return res; + } + + public boolean updateWidth(GpxDataItem item, String width) { + boolean res = db.updateWidth(item, width); putToCache(item); return res; } diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 00a626ae6d..31f4755803 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -53,6 +53,8 @@ public class GpxSelectionHelper { private static final String COLOR = "color"; private static final String WIDTH = "width"; private static final String SELECTED_BY_USER = "selected_by_user"; + private static final String SHOW_ARROWS = "showArrows"; + private static final String SHOW_START_FINISH = "showStartFinish"; private OsmandApplication app; @NonNull @@ -516,6 +518,14 @@ public class GpxSelectionHelper { int clr = Algorithms.parseColor(obj.getString(COLOR)); gpx.setColor(clr); } + if (obj.has(SHOW_ARROWS)) { + boolean showArrows = obj.optBoolean(SHOW_ARROWS, false); + gpx.setShowArrows(showArrows); + } + if (obj.has(SHOW_START_FINISH)) { + boolean showStartFinish = obj.optBoolean(SHOW_START_FINISH, false); + gpx.setShowStartFinish(showStartFinish); + } if (obj.has(WIDTH)) { gpx.setWidth(obj.getString(WIDTH)); } @@ -561,6 +571,8 @@ public class GpxSelectionHelper { if (s.gpxFile.getWidth(null) != null) { obj.put(WIDTH, s.gpxFile.getWidth(null)); } + obj.put(SHOW_ARROWS, s.gpxFile.isShowArrows()); + obj.put(SHOW_START_FINISH, s.gpxFile.isShowStartFinish()); } obj.put(SELECTED_BY_USER, s.selectedByUser); } catch (JSONException e) { @@ -616,6 +628,8 @@ public class GpxSelectionHelper { if (dataItem.getWidth() != null) { gpx.setWidth(dataItem.getWidth()); } + gpx.setShowArrows(dataItem.isShowArrows()); + gpx.setShowStartFinish(dataItem.isShowStartFinish()); sf.setJoinSegments(dataItem.isJoinSegments()); } sf.setGpxFile(gpx, app); From 94919b25a5c51c583d8f0d19500b6018ad3d728c Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 6 Jul 2020 11:41:18 +0300 Subject: [PATCH 005/551] Fix merge conflicts --- .../osmand/plus/dialogs/ConfigureMapMenu.java | 2 -- .../plus/dialogs/MapLayerMenuListener.java | 19 ------------------- 2 files changed, 21 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 46221ce063..726475cdc7 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -47,7 +47,6 @@ import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.transport.TransportLinesMenu; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.corenative.NativeCoreContext; -import net.osmand.plus.wikipedia.WikipediaPoiMenu; import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleStorageProperties; import net.osmand.render.RenderingRulesStorage; @@ -173,7 +172,6 @@ public class ConfigureMapMenu { final OsmandApplication app = activity.getMyApplication(); final OsmandSettings settings = app.getSettings(); final int selectedProfileColorRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode); - final int selectedProfileColor = ContextCompat.getColor(app, selectedProfileColorRes); MapLayerMenuListener l = new MapLayerMenuListener(activity, adapter); adapter.addItem(new ContextMenuItem.ItemBuilder() .setId(SHOW_CATEGORY_ID) diff --git a/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java b/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java index d369ac0ea2..91e55e1d73 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java @@ -8,7 +8,6 @@ import android.widget.CompoundButton; import androidx.appcompat.app.AlertDialog; -import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; import net.osmand.GPXUtilities.GPXFile; import net.osmand.plus.ContextMenuAdapter; @@ -22,13 +21,11 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.activities.PluginActivity; -import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.transport.TransportLinesMenu; -import net.osmand.plus.wikipedia.WikipediaPoiMenu; import net.osmand.util.Algorithms; import java.io.File; @@ -77,10 +74,6 @@ final class MapLayerMenuListener extends OnRowItemClick { } else if (itemId == R.string.layer_gpx_layer && menuAdapter.getItem(pos).getSelected()) { showGpxSelectionDialog(adapter, adapter.getItem(pos)); return false; - } else if (itemId == R.string.shared_string_wikipedia) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.WIKIPEDIA, - AndroidUtils.getCenterViewCoordinates(view)); - return false; } else if (itemId == R.string.rendering_category_transport) { final ContextMenuItem item = adapter.getItem(pos); TransportLinesMenu.showTransportsDialog(mapActivity, new CallbackWithObject() { @@ -144,18 +137,6 @@ final class MapLayerMenuListener extends OnRowItemClick { } else { showGpxSelectionDialog(adapter, adapter.getItem(pos)); } - } else if (itemId == R.string.shared_string_wikipedia) { - WikipediaPoiMenu.toggleWikipediaPoi(mapActivity, isChecked, new CallbackWithObject() { - @Override - public boolean processResult(Boolean selected) { - item.setSelected(selected); - item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); - item.setDescription(selected ? - WikipediaPoiMenu.getLanguagesSummary(mapActivity.getMyApplication()) : null); - adapter.notifyDataSetChanged(); - return true; - } - }); } else if (itemId == R.string.rendering_category_transport) { boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication()); TransportLinesMenu.toggleTransportLines(mapActivity, !selected, new CallbackWithObject() { From a0c83cf8b527645ce98d562a276c1c0708649403 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 6 Jul 2020 12:30:55 +0300 Subject: [PATCH 006/551] Add track gradient scale types --- .../main/java/net/osmand/GPXUtilities.java | 118 +++++++++++------- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 83 +++++++++++- OsmAnd/src/net/osmand/plus/GpxDbHelper.java | 9 +- .../net/osmand/plus/GpxSelectionHelper.java | 11 ++ 4 files changed, 171 insertions(+), 50 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index ef54ed7edb..077e249ac8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -42,7 +42,9 @@ import java.util.Stack; import java.util.TimeZone; public class GPXUtilities { + public final static Log log = PlatformUtil.getLog(GPXUtilities.class); + private static final String ICON_NAME_EXTENSION = "icon"; private static final String DEFAULT_ICON_NAME = "special_star"; private static final String BACKGROUND_TYPE_EXTENSION = "background"; @@ -115,6 +117,13 @@ public class GPXUtilities { return extensions; } + public Map getExtensionsToWrite() { + if (extensions == null) { + extensions = new LinkedHashMap<>(); + } + return extensions; + } + public GPXExtensionsWriter getExtensionsWriter() { return extensionsWriter; } @@ -148,50 +157,7 @@ public class GPXUtilities { getExtensionsToWrite().remove("color"); } - public String getWidth(String defWidth) { - String widthValue = null; - if (extensions != null) { - widthValue = extensions.get("width"); - } - return widthValue != null ? widthValue : defWidth; - } - - public void setWidth(String width) { - getExtensionsToWrite().put("width", width); - } - - public boolean isShowArrows() { - String showArrows = null; - if (extensions != null) { - showArrows = extensions.get("showArrows"); - } - return Boolean.parseBoolean(showArrows); - } - - public void setShowArrows(boolean showArrows) { - getExtensionsToWrite().put("showArrows", String.valueOf(showArrows)); - } - - public boolean isShowStartFinish() { - String showStartFinish = null; - if (extensions != null) { - showStartFinish = extensions.get("showStartFinish"); - } - return Boolean.parseBoolean(showStartFinish); - } - - public void setShowStartFinish(boolean showStartFinish) { - getExtensionsToWrite().put("showStartFinish", String.valueOf(showStartFinish)); - } - - public Map getExtensionsToWrite() { - if (extensions == null) { - extensions = new LinkedHashMap<>(); - } - return extensions; - } - - private int parseColor(String colorString, int defColor) { + protected int parseColor(String colorString, int defColor) { if (!Algorithms.isEmpty(colorString)) { if (colorString.charAt(0) == '#') { long color = Long.parseLong(colorString.substring(1), 16); @@ -1547,6 +1513,70 @@ public class GPXUtilities { } return new QuadRect(left, top, right, bottom); } + + public enum GradientScaleType { + SPEED("gradientSpeedColor"), + ALTITUDE("gradientAltitudeColor"), + SLOPE("gradientSlopeColor"); + + private String typeName; + + GradientScaleType(String typeName) { + this.typeName = typeName; + } + + public String getTypeName() { + return typeName; + } + } + + public void setGradientScaleColor(GradientScaleType gradientScaleType, int gradientScaleSpeedColor) { + getExtensionsToWrite().put(gradientScaleType.getTypeName(), Algorithms.colorToString(gradientScaleSpeedColor)); + } + + public int getGradientScaleColor(GradientScaleType gradientScaleType, int defColor) { + String clrValue = null; + if (extensions != null) { + clrValue = extensions.get(gradientScaleType.getTypeName()); + } + return parseColor(clrValue, defColor); + } + + public String getWidth(String defWidth) { + String widthValue = null; + if (extensions != null) { + widthValue = extensions.get("width"); + } + return widthValue != null ? widthValue : defWidth; + } + + public void setWidth(String width) { + getExtensionsToWrite().put("width", width); + } + + public boolean isShowArrows() { + String showArrows = null; + if (extensions != null) { + showArrows = extensions.get("showArrows"); + } + return Boolean.parseBoolean(showArrows); + } + + public void setShowArrows(boolean showArrows) { + getExtensionsToWrite().put("showArrows", String.valueOf(showArrows)); + } + + public boolean isShowStartFinish() { + String showStartFinish = null; + if (extensions != null) { + showStartFinish = extensions.get("showStartFinish"); + } + return Boolean.parseBoolean(showStartFinish); + } + + public void setShowStartFinish(boolean showStartFinish) { + getExtensionsToWrite().put("showStartFinish", String.valueOf(showStartFinish)); + } } public static String asString(GPXFile file) { diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index 1595e2b3b5..b45e5582a2 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -3,6 +3,7 @@ package net.osmand.plus; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.IndexConstants; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; @@ -63,6 +64,12 @@ public class GPXDatabase { private static final String GPX_COL_WIDTH = "width"; + private static final String GPX_COL_GRADIENT_SPEED_COLOR = "gradientSpeedColor"; + + private static final String GPX_COL_GRADIENT_ALTITUDE_COLOR = "gradientAltitudeColor"; + + private static final String GPX_COL_GRADIENT_SLOPE_COLOR = "gradientSlopeColor"; + public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1; public static final int GPX_SPLIT_TYPE_DISTANCE = 1; public static final int GPX_SPLIT_TYPE_TIME = 2; @@ -99,7 +106,10 @@ public class GPXDatabase { GPX_COL_JOIN_SEGMENTS + " int, " + // 1 = true, 0 = false GPX_COL_SHOW_ARROWS + " int, " + // 1 = true, 0 = false GPX_COL_SHOW_START_FINISH + " int, " + // 1 = true, 0 = false - GPX_COL_WIDTH + " TEXT);"; + GPX_COL_WIDTH + " TEXT, " + + GPX_COL_GRADIENT_SPEED_COLOR + " TEXT, " + + GPX_COL_GRADIENT_ALTITUDE_COLOR + " TEXT, " + + GPX_COL_GRADIENT_SLOPE_COLOR + " TEXT);"; private static final String GPX_TABLE_SELECT = "SELECT " + GPX_COL_NAME + ", " + @@ -129,8 +139,10 @@ public class GPXDatabase { GPX_COL_SHOW_AS_MARKERS + ", " + GPX_COL_JOIN_SEGMENTS + ", " + GPX_COL_SHOW_ARROWS + ", " + - GPX_COL_SHOW_START_FINISH + ", " + - GPX_COL_WIDTH + + GPX_COL_WIDTH + ", " + + GPX_COL_GRADIENT_SPEED_COLOR + ", " + + GPX_COL_GRADIENT_ALTITUDE_COLOR + ", " + + GPX_COL_GRADIENT_SLOPE_COLOR + " FROM " + GPX_TABLE_NAME; private static final String GPX_TABLE_UPDATE_ANALYSIS = "UPDATE " + @@ -162,6 +174,9 @@ public class GPXDatabase { private GPXTrackAnalysis analysis; private String width; private int color; + private int gradientSpeedColor; + private int gradientAltitudeColor; + private int gradientSlopeColor; private int splitType; private double splitInterval; private long fileLastModifiedTime; @@ -194,6 +209,30 @@ public class GPXDatabase { return color; } + public int getGradientSpeedColor() { + return gradientSpeedColor; + } + + public void setGradientSpeedColor(int gradientSpeedColor) { + this.gradientSpeedColor = gradientSpeedColor; + } + + public int getGradientAltitudeColor() { + return gradientAltitudeColor; + } + + public void setGradientAltitudeColor(int gradientAltitudeColor) { + this.gradientAltitudeColor = gradientAltitudeColor; + } + + public int getGradientSlopeColor() { + return gradientSlopeColor; + } + + public void setGradientSlopeColor(int gradientSlopeColor) { + this.gradientSlopeColor = gradientSlopeColor; + } + public String getWidth() { return width; } @@ -314,7 +353,7 @@ public class GPXDatabase { if (oldVersion < 3) { db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_FILE_LAST_MODIFIED_TIME + " long"); } - + if (oldVersion < 4) { db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_TYPE + " int"); db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_INTERVAL + " double"); @@ -386,6 +425,9 @@ public class GPXDatabase { db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SHOW_ARROWS + " int"); db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SHOW_START_FINISH + " int"); db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_WIDTH + " TEXT"); + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_SPEED_COLOR + " TEXT"); + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_ALTITUDE_COLOR + " TEXT"); + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_SLOPE_COLOR + " TEXT"); db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " + "WHERE " + GPX_COL_SHOW_ARROWS + " IS NULL", new Object[]{0}); @@ -454,6 +496,34 @@ public class GPXDatabase { return false; } + public boolean updateGradientScaleColor(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType, int gradientScaleColor) { + SQLiteConnection db = openConnection(false); + if (db != null) { + try { + String fileName = getFileName(item.file); + String fileDir = getFileDir(item.file); + String columnName = null; + if (GradientScaleType.SPEED == gradientScaleType) { + columnName = GPX_COL_GRADIENT_SPEED_COLOR; + item.gradientSpeedColor = gradientScaleColor; + } else if (GradientScaleType.ALTITUDE == gradientScaleType) { + columnName = GPX_COL_GRADIENT_ALTITUDE_COLOR; + item.gradientAltitudeColor = gradientScaleColor; + } else if (GradientScaleType.SLOPE == gradientScaleType) { + columnName = GPX_COL_GRADIENT_SLOPE_COLOR; + item.gradientSlopeColor = gradientScaleColor; + } + db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + columnName + " = ? " + + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", + new Object[] {(gradientScaleColor == 0 ? "" : Algorithms.colorToString(gradientScaleColor)), fileName, fileDir}); + } finally { + db.close(); + } + return true; + } + return false; + } + public boolean updateShowArrows(GpxDataItem item, boolean showArrows) { SQLiteConnection db = openConnection(false); if (db != null) { @@ -642,7 +712,10 @@ public class GPXDatabase { GPX_COL_JOIN_SEGMENTS + ", " + GPX_COL_SHOW_ARROWS + ", " + GPX_COL_SHOW_START_FINISH + ", " + - GPX_COL_WIDTH + + GPX_COL_WIDTH + ", " + + GPX_COL_GRADIENT_SPEED_COLOR + ", " + + GPX_COL_GRADIENT_ALTITUDE_COLOR + ", " + + GPX_COL_GRADIENT_SLOPE_COLOR + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index c929348297..cb011336bb 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -8,6 +8,7 @@ import androidx.annotation.Nullable; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; @@ -77,6 +78,12 @@ public class GpxDbHelper { return res; } + public boolean updateGradientScaleColor(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType, int color) { + boolean res = db.updateGradientScaleColor(item, gradientScaleType, color); + putToCache(item); + return res; + } + public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) { boolean res = db.updateShowAsMarkers(item, showAsMarkers); putToCache(item); @@ -107,7 +114,7 @@ public class GpxDbHelper { return res; } - public boolean updateJoinSegments(@NonNull GpxDataItem item, boolean joinSegments) { + public boolean updateJoinSegments(@NonNull GpxDataItem item, boolean joinSegments) { boolean res = db.updateJoinSegments(item, joinSegments); putToCache(item); return res; diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 31f4755803..8d689978a1 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -11,6 +11,7 @@ import androidx.core.content.ContextCompat; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.GPXUtilities.Route; import net.osmand.GPXUtilities.Track; @@ -518,6 +519,7 @@ public class GpxSelectionHelper { int clr = Algorithms.parseColor(obj.getString(COLOR)); gpx.setColor(clr); } + loadGpxScaleTypes(obj, gpx); if (obj.has(SHOW_ARROWS)) { boolean showArrows = obj.optBoolean(SHOW_ARROWS, false); gpx.setShowArrows(showArrows); @@ -555,6 +557,15 @@ public class GpxSelectionHelper { } } + private void loadGpxScaleTypes(JSONObject obj, GPXFile gpx) throws JSONException { + for (GradientScaleType scaleType : GradientScaleType.values()) { + if (obj.has(scaleType.getTypeName())) { + int clr = Algorithms.parseColor(obj.getString(scaleType.getTypeName())); + gpx.setGradientScaleColor(scaleType, clr); + } + } + } + private void saveCurrentSelections() { JSONArray ar = new JSONArray(); for (SelectedGpxFile s : selectedGPXFiles) { From 15e26432f8a87f1dddff7e599d4916dba6af127c Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 6 Jul 2020 15:01:47 +0300 Subject: [PATCH 007/551] Add selected gradient scale type for track --- .../main/java/net/osmand/GPXUtilities.java | 18 +++++ OsmAnd/src/net/osmand/plus/GPXDatabase.java | 80 ++++++++++++++++--- OsmAnd/src/net/osmand/plus/GpxDbHelper.java | 6 ++ .../net/osmand/plus/GpxSelectionHelper.java | 36 ++++++--- 4 files changed, 115 insertions(+), 25 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 077e249ac8..c1ad5d5cef 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1542,6 +1542,24 @@ public class GPXUtilities { return parseColor(clrValue, defColor); } + public void setGradientScaleType(GradientScaleType gradientScaleType) { + getExtensionsToWrite().put("gradientScaleType", gradientScaleType != null ? gradientScaleType.name() : null); + } + + public GradientScaleType getGradientScaleType() { + if (extensions != null) { + String gradientScaleTypeName = extensions.get("gradientScaleType"); + if (!Algorithms.isEmpty(gradientScaleTypeName)) { + try { + return GradientScaleType.valueOf(gradientScaleTypeName); + } catch (IllegalArgumentException e) { + log.error("Error reading gradientScaleType", e); + } + } + } + return null; + } + public String getWidth(String defWidth) { String widthValue = null; if (extensions != null) { diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index b45e5582a2..e5bd1c3ad0 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -70,6 +70,8 @@ public class GPXDatabase { private static final String GPX_COL_GRADIENT_SLOPE_COLOR = "gradientSlopeColor"; + private static final String GPX_COL_GRADIENT_SCALE_TYPE = "gradientScaleType"; + public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1; public static final int GPX_SPLIT_TYPE_DISTANCE = 1; public static final int GPX_SPLIT_TYPE_TIME = 2; @@ -109,7 +111,8 @@ public class GPXDatabase { GPX_COL_WIDTH + " TEXT, " + GPX_COL_GRADIENT_SPEED_COLOR + " TEXT, " + GPX_COL_GRADIENT_ALTITUDE_COLOR + " TEXT, " + - GPX_COL_GRADIENT_SLOPE_COLOR + " TEXT);"; + GPX_COL_GRADIENT_SLOPE_COLOR + " TEXT, " + + GPX_COL_GRADIENT_SCALE_TYPE+ " TEXT);"; private static final String GPX_TABLE_SELECT = "SELECT " + GPX_COL_NAME + ", " + @@ -142,8 +145,9 @@ public class GPXDatabase { GPX_COL_WIDTH + ", " + GPX_COL_GRADIENT_SPEED_COLOR + ", " + GPX_COL_GRADIENT_ALTITUDE_COLOR + ", " + - GPX_COL_GRADIENT_SLOPE_COLOR + - " FROM " + GPX_TABLE_NAME; + GPX_COL_GRADIENT_SLOPE_COLOR + ", " + + GPX_COL_GRADIENT_SCALE_TYPE + + " FROM " + GPX_TABLE_NAME; private static final String GPX_TABLE_UPDATE_ANALYSIS = "UPDATE " + GPX_TABLE_NAME + " SET " + @@ -173,6 +177,7 @@ public class GPXDatabase { private File file; private GPXTrackAnalysis analysis; private String width; + private GradientScaleType gradientScaleType; private int color; private int gradientSpeedColor; private int gradientAltitudeColor; @@ -209,6 +214,14 @@ public class GPXDatabase { return color; } + public GradientScaleType getGradientScaleType() { + return gradientScaleType; + } + + public void setGradientScaleType(GradientScaleType gradientScaleType) { + this.gradientScaleType = gradientScaleType; + } + public int getGradientSpeedColor() { return gradientSpeedColor; } @@ -428,6 +441,7 @@ public class GPXDatabase { db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_SPEED_COLOR + " TEXT"); db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_ALTITUDE_COLOR + " TEXT"); db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_SLOPE_COLOR + " TEXT"); + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_SCALE_TYPE + " TEXT"); db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " + "WHERE " + GPX_COL_SHOW_ARROWS + " IS NULL", new Object[]{0}); @@ -524,6 +538,24 @@ public class GPXDatabase { return false; } + public boolean updateGradientScaleType(@NonNull GpxDataItem item, GradientScaleType gradientScaleType) { + SQLiteConnection db = openConnection(false); + if (db != null) { + try { + String fileName = getFileName(item.file); + String fileDir = getFileDir(item.file); + db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_GRADIENT_SCALE_TYPE + " = ? " + + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", + new Object[] {(gradientScaleType == null ? "" : gradientScaleType.name()), fileName, fileDir}); + item.gradientScaleType = gradientScaleType; + } finally { + db.close(); + } + return true; + } + return false; + } + public boolean updateShowArrows(GpxDataItem item, boolean showArrows) { SQLiteConnection db = openConnection(false); if (db != null) { @@ -690,15 +722,17 @@ public class GPXDatabase { } else { color = Algorithms.colorToString(item.color); } + String gradientScaleType = item.gradientScaleType != null ? item.gradientScaleType.name() : null; if (a != null) { db.execSQL( - "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[] {fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime, a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown, a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints, color, item.file.lastModified(), item.splitType, item.splitInterval, item.apiImported ? 1 : 0, Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0, - item.joinSegments ? 1 : 0, item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width}); + item.joinSegments ? 1 : 0, item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width, + item.gradientSpeedColor, item.gradientAltitudeColor, item.gradientSlopeColor, gradientScaleType}); } else { db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" + GPX_COL_NAME + ", " + @@ -715,11 +749,13 @@ public class GPXDatabase { GPX_COL_WIDTH + ", " + GPX_COL_GRADIENT_SPEED_COLOR + ", " + GPX_COL_GRADIENT_ALTITUDE_COLOR + ", " + - GPX_COL_GRADIENT_SLOPE_COLOR + - ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + GPX_COL_GRADIENT_SLOPE_COLOR + ", " + + GPX_COL_GRADIENT_SCALE_TYPE + + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, - item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width}); + item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width, + item.gradientSpeedColor, item.gradientAltitudeColor, item.gradientSlopeColor, gradientScaleType}); } } @@ -803,6 +839,10 @@ public class GPXDatabase { boolean showArrows = query.getInt(26) == 1; boolean showStartFinish = query.getInt(27) == 1; String width = query.getString(28); + String gradientSpeedColor = query.getString(29); + String gradientAltitudeColor = query.getString(30); + String gradientSlopeColor = query.getString(31); + String gradientScaleType = query.getString(32); GPXTrackAnalysis a = new GPXTrackAnalysis(); a.totalDistance = totalDistance; @@ -833,11 +873,7 @@ public class GPXDatabase { dir = context.getAppPath(IndexConstants.GPX_INDEX_DIR); } GpxDataItem item = new GpxDataItem(new File(dir, fileName), a); - try { - item.color = Algorithms.isEmpty(color) ? 0 : Algorithms.parseColor(color); - } catch (IllegalArgumentException e) { - item.color = 0; - } + item.color = parseColor(color); item.fileLastModifiedTime = fileLastModifiedTime; item.splitType = splitType; item.splitInterval = splitInterval; @@ -847,9 +883,27 @@ public class GPXDatabase { item.showArrows = showArrows; item.showStartFinish = showStartFinish; item.width = width; + item.gradientSpeedColor = parseColor(gradientSpeedColor); + item.gradientAltitudeColor = parseColor(gradientAltitudeColor); + item.gradientSlopeColor = parseColor(gradientSlopeColor); + + try { + item.gradientScaleType = Algorithms.isEmpty(gradientScaleType) ? null : GradientScaleType.valueOf(gradientScaleType); + } catch (IllegalArgumentException e) { + item.gradientScaleType = null; + } + return item; } + private int parseColor(String color) { + try { + return Algorithms.isEmpty(color) ? 0 : Algorithms.parseColor(color); + } catch (IllegalArgumentException e) { + return 0; + } + } + @NonNull public List getItems() { List items = new ArrayList<>(); diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index cb011336bb..0762982a33 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -84,6 +84,12 @@ public class GpxDbHelper { return res; } + public boolean updateGradientScaleType(@NonNull GpxDataItem item, @Nullable GradientScaleType gradientScaleType) { + boolean res = db.updateGradientScaleType(item, gradientScaleType); + putToCache(item); + return res; + } + public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) { boolean res = db.updateShowAsMarkers(item, showAsMarkers); putToCache(item); diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 8d689978a1..3959318853 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -55,6 +55,7 @@ public class GpxSelectionHelper { private static final String WIDTH = "width"; private static final String SELECTED_BY_USER = "selected_by_user"; private static final String SHOW_ARROWS = "showArrows"; + private static final String GRADIENT_SCALE_TYPE = "gradientScaleType"; private static final String SHOW_START_FINISH = "showStartFinish"; private OsmandApplication app; @@ -519,11 +520,22 @@ public class GpxSelectionHelper { int clr = Algorithms.parseColor(obj.getString(COLOR)); gpx.setColor(clr); } - loadGpxScaleTypes(obj, gpx); + for (GradientScaleType scaleType : GradientScaleType.values()) { + if (obj.has(scaleType.getTypeName())) { + int clr = Algorithms.parseColor(obj.getString(scaleType.getTypeName())); + gpx.setGradientScaleColor(scaleType, clr); + } + } if (obj.has(SHOW_ARROWS)) { boolean showArrows = obj.optBoolean(SHOW_ARROWS, false); gpx.setShowArrows(showArrows); } + if (obj.has(GRADIENT_SCALE_TYPE)) { + String gradientScaleTypeName = obj.optString(GRADIENT_SCALE_TYPE); + if (!Algorithms.isEmpty(gradientScaleTypeName)) { + gpx.setGradientScaleType(GradientScaleType.valueOf(gradientScaleTypeName)); + } + } if (obj.has(SHOW_START_FINISH)) { boolean showStartFinish = obj.optBoolean(SHOW_START_FINISH, false); gpx.setShowStartFinish(showStartFinish); @@ -557,15 +569,6 @@ public class GpxSelectionHelper { } } - private void loadGpxScaleTypes(JSONObject obj, GPXFile gpx) throws JSONException { - for (GradientScaleType scaleType : GradientScaleType.values()) { - if (obj.has(scaleType.getTypeName())) { - int clr = Algorithms.parseColor(obj.getString(scaleType.getTypeName())); - gpx.setGradientScaleColor(scaleType, clr); - } - } - } - private void saveCurrentSelections() { JSONArray ar = new JSONArray(); for (SelectedGpxFile s : selectedGPXFiles) { @@ -582,8 +585,17 @@ public class GpxSelectionHelper { if (s.gpxFile.getWidth(null) != null) { obj.put(WIDTH, s.gpxFile.getWidth(null)); } + if (s.gpxFile.getGradientScaleType() != null) { + obj.put(GRADIENT_SCALE_TYPE, s.gpxFile.getGradientScaleType()); + } obj.put(SHOW_ARROWS, s.gpxFile.isShowArrows()); obj.put(SHOW_START_FINISH, s.gpxFile.isShowStartFinish()); + for (GradientScaleType scaleType : GradientScaleType.values()) { + int gradientScaleColor = s.gpxFile.getGradientScaleColor(scaleType, 0); + if (gradientScaleColor != 0) { + obj.put(scaleType.getTypeName(), Algorithms.colorToString(gradientScaleColor)); + } + } } obj.put(SELECTED_BY_USER, s.selectedByUser); } catch (JSONException e) { @@ -1059,13 +1071,13 @@ public class GpxSelectionHelper { @Override protected void onProgressUpdate(Void... values) { - gpxTaskListener.gpxSelectionInProgress(); + gpxTaskListener.gpxSelectionInProgress(); } @Override protected void onPreExecute() { collectSelectedItems(); - gpxTaskListener.gpxSelectionStarted(); + gpxTaskListener.gpxSelectionStarted(); } private void collectSelectedItems() { From 3bab88942a8d9fdb872e158c449b1fc1131a803d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 6 Jul 2020 17:02:25 +0300 Subject: [PATCH 008/551] Fix track gradient scale color --- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 1 + OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index e5bd1c3ad0..5633730e67 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -142,6 +142,7 @@ public class GPXDatabase { GPX_COL_SHOW_AS_MARKERS + ", " + GPX_COL_JOIN_SEGMENTS + ", " + GPX_COL_SHOW_ARROWS + ", " + + GPX_COL_SHOW_START_FINISH + ", " + GPX_COL_WIDTH + ", " + GPX_COL_GRADIENT_SPEED_COLOR + ", " + GPX_COL_GRADIENT_ALTITUDE_COLOR + ", " + diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 3959318853..8a288d96b5 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -648,6 +648,18 @@ public class GpxSelectionHelper { if (dataItem.getColor() != 0) { gpx.setColor(dataItem.getColor()); } + if (dataItem.getGradientSpeedColor() != 0) { + gpx.setGradientScaleColor(GradientScaleType.SPEED, dataItem.getGradientSpeedColor()); + } + if (dataItem.getGradientAltitudeColor() != 0) { + gpx.setGradientScaleColor(GradientScaleType.ALTITUDE, dataItem.getGradientAltitudeColor()); + } + if (dataItem.getGradientSlopeColor() != 0) { + gpx.setGradientScaleColor(GradientScaleType.SLOPE, dataItem.getGradientSlopeColor()); + } + if (dataItem.getGradientScaleType() != null) { + gpx.setGradientScaleType(dataItem.getGradientScaleType()); + } if (dataItem.getWidth() != null) { gpx.setWidth(dataItem.getWidth()); } From 03951910fde453dad0873dc1a6821b3b631948a1 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 6 Jul 2020 21:07:48 +0300 Subject: [PATCH 009/551] Add track start and finish icons to map layer --- .../src/net/osmand/plus/views/GPXLayer.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 68e31dc4ca..4073194ea4 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -10,6 +10,7 @@ import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.RectF; +import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.os.AsyncTask; import android.util.Pair; @@ -41,6 +42,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; @@ -82,10 +84,12 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private Paint paintIcon; private int cachedHash; private int cachedColor; + private int currentTrackColor; private float defaultTrackWidth; private Map cachedTrackWidth = new HashMap<>(); - private int currentTrackColor; + private Drawable startPointIcon; + private Drawable finishPointIcon; private LayerDrawable selectedPoint; private TrackChartPoints trackChartPoints; @@ -167,6 +171,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM paintIcon = new Paint(); selectedPoint = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), R.drawable.map_location_default); + UiUtilities iconsCache = view.getApplication().getUIUtilities(); + startPointIcon = iconsCache.getIcon(R.drawable.map_track_point_start); + finishPointIcon = iconsCache.getIcon(R.drawable.map_track_point_finish); + contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class); visitedColor = ContextCompat.getColor(view.getApplication(), R.color.color_ok); @@ -201,6 +209,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings); drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles); + drawSelectedFilesStartEndPoints(canvas, tileBox, selectedGPXFiles); } if (textLayer != null && isTextVisible()) { textLayer.putData(this, cache); @@ -383,6 +392,34 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } } + private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List selectedGPXFiles) { + if (tileBox.getZoom() >= START_ZOOM) { + for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) { + if (selectedGpxFile.getGpxFile().isShowStartFinish()) { + List segments = selectedGpxFile.getPointsToDisplay(); + TrkSegment endSegment = segments.get(segments.size() - 1); + + WptPt start = segments.get(0).points.get(0); + WptPt end = endSegment.points.get(endSegment.points.size() - 1); + + drawPoint(canvas, tileBox, start, startPointIcon); + drawPoint(canvas, tileBox, end, finishPointIcon); + } + } + } + } + + private void drawPoint(Canvas canvas, RotatedTileBox tileBox, WptPt wptPt, Drawable icon) { + int pointX = (int) tileBox.getPixXFromLatLon(wptPt.lat, wptPt.lon); + int pointY = (int) tileBox.getPixYFromLatLon(wptPt.lat, wptPt.lon); + + icon.setBounds(pointX - icon.getIntrinsicWidth() / 2, + pointY - icon.getIntrinsicHeight() / 2, + pointX + icon.getIntrinsicWidth() / 2, + pointY + icon.getIntrinsicHeight() / 2); + icon.draw(canvas); + } + private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List selectedGPXFiles) { if (tileBox.getZoom() >= START_ZOOM) { float textScale = view.getSettings().TEXT_SCALE.get(); From 5f60f452c0678813699f4e1d72c26c0bbf4a5b09 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 7 Jul 2020 10:24:29 +0300 Subject: [PATCH 010/551] Change gradient parameters names --- .../src/main/java/net/osmand/GPXUtilities.java | 18 +++++++++--------- .../net/osmand/plus/GpxSelectionHelper.java | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index c1ad5d5cef..916e279160 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1515,9 +1515,9 @@ public class GPXUtilities { } public enum GradientScaleType { - SPEED("gradientSpeedColor"), - ALTITUDE("gradientAltitudeColor"), - SLOPE("gradientSlopeColor"); + SPEED("gradient_speed_color"), + ALTITUDE("gradient_altitude_color"), + SLOPE("gradient_slope_color"); private String typeName; @@ -1543,12 +1543,12 @@ public class GPXUtilities { } public void setGradientScaleType(GradientScaleType gradientScaleType) { - getExtensionsToWrite().put("gradientScaleType", gradientScaleType != null ? gradientScaleType.name() : null); + getExtensionsToWrite().put("gradient_scale_type", gradientScaleType != null ? gradientScaleType.name() : null); } public GradientScaleType getGradientScaleType() { if (extensions != null) { - String gradientScaleTypeName = extensions.get("gradientScaleType"); + String gradientScaleTypeName = extensions.get("gradient_scale_type"); if (!Algorithms.isEmpty(gradientScaleTypeName)) { try { return GradientScaleType.valueOf(gradientScaleTypeName); @@ -1575,25 +1575,25 @@ public class GPXUtilities { public boolean isShowArrows() { String showArrows = null; if (extensions != null) { - showArrows = extensions.get("showArrows"); + showArrows = extensions.get("show_arrows"); } return Boolean.parseBoolean(showArrows); } public void setShowArrows(boolean showArrows) { - getExtensionsToWrite().put("showArrows", String.valueOf(showArrows)); + getExtensionsToWrite().put("show_arrows", String.valueOf(showArrows)); } public boolean isShowStartFinish() { String showStartFinish = null; if (extensions != null) { - showStartFinish = extensions.get("showStartFinish"); + showStartFinish = extensions.get("show_start_finish"); } return Boolean.parseBoolean(showStartFinish); } public void setShowStartFinish(boolean showStartFinish) { - getExtensionsToWrite().put("showStartFinish", String.valueOf(showStartFinish)); + getExtensionsToWrite().put("show_start_finish", String.valueOf(showStartFinish)); } } diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 8a288d96b5..07a183712d 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -54,9 +54,9 @@ public class GpxSelectionHelper { private static final String COLOR = "color"; private static final String WIDTH = "width"; private static final String SELECTED_BY_USER = "selected_by_user"; - private static final String SHOW_ARROWS = "showArrows"; - private static final String GRADIENT_SCALE_TYPE = "gradientScaleType"; - private static final String SHOW_START_FINISH = "showStartFinish"; + private static final String SHOW_ARROWS = "show_arrows"; + private static final String GRADIENT_SCALE_TYPE = "gradient_scale_type"; + private static final String SHOW_START_FINISH = "show_start_finish"; private OsmandApplication app; @NonNull From c18b5ba25c5b2ba9cf2b06d6db9c6571df42a844 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 7 Jul 2020 11:23:53 +0300 Subject: [PATCH 011/551] Fix gpx files import --- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 2 +- OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index 5633730e67..58f8cdf27f 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -752,7 +752,7 @@ public class GPXDatabase { GPX_COL_GRADIENT_ALTITUDE_COLOR + ", " + GPX_COL_GRADIENT_SLOPE_COLOR + ", " + GPX_COL_GRADIENT_SCALE_TYPE + - ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width, diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java index fe33fa61d4..b5a9ee75e9 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java @@ -23,6 +23,7 @@ import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.WptPt; import net.osmand.IProgress; import net.osmand.IndexConstants; @@ -1018,6 +1019,13 @@ public class ImportHelper { File file = new File(gpxFile.path); if (!destinationExists) { GPXDatabase.GpxDataItem item = new GPXDatabase.GpxDataItem(file, gpxFile.getColor(0)); + item.setWidth(gpxFile.getWidth(null)); + item.setShowArrows(gpxFile.isShowArrows()); + item.setShowStartFinish(gpxFile.isShowStartFinish()); + item.setGradientScaleType(gpxFile.getGradientScaleType()); + item.setGradientSpeedColor(gpxFile.getGradientScaleColor(GradientScaleType.SPEED, 0)); + item.setGradientSlopeColor(gpxFile.getGradientScaleColor(GradientScaleType.SLOPE, 0)); + item.setGradientAltitudeColor(gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE, 0)); app.getGpxDbHelper().add(item); } else { GPXDatabase.GpxDataItem item = app.getGpxDbHelper().getItem(file); From 2284de7055494e59606cb5e5eed1cf123bf3bcdd Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 7 Jul 2020 14:15:48 +0300 Subject: [PATCH 012/551] Load gpx split type from file --- .../main/java/net/osmand/GPXUtilities.java | 96 ++++++++++++++----- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 4 - OsmAnd/src/net/osmand/plus/GpxDbHelper.java | 5 +- .../net/osmand/plus/GpxSelectionHelper.java | 7 +- .../net/osmand/plus/helpers/ImportHelper.java | 4 + .../TrackActivityFragmentAdapter.java | 16 ++-- 6 files changed, 93 insertions(+), 39 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 916e279160..762ed0deb8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1514,26 +1514,6 @@ public class GPXUtilities { return new QuadRect(left, top, right, bottom); } - public enum GradientScaleType { - SPEED("gradient_speed_color"), - ALTITUDE("gradient_altitude_color"), - SLOPE("gradient_slope_color"); - - private String typeName; - - GradientScaleType(String typeName) { - this.typeName = typeName; - } - - public String getTypeName() { - return typeName; - } - } - - public void setGradientScaleColor(GradientScaleType gradientScaleType, int gradientScaleSpeedColor) { - getExtensionsToWrite().put(gradientScaleType.getTypeName(), Algorithms.colorToString(gradientScaleSpeedColor)); - } - public int getGradientScaleColor(GradientScaleType gradientScaleType, int defColor) { String clrValue = null; if (extensions != null) { @@ -1542,8 +1522,8 @@ public class GPXUtilities { return parseColor(clrValue, defColor); } - public void setGradientScaleType(GradientScaleType gradientScaleType) { - getExtensionsToWrite().put("gradient_scale_type", gradientScaleType != null ? gradientScaleType.name() : null); + public void setGradientScaleColor(GradientScaleType gradientScaleType, int gradientScaleColor) { + getExtensionsToWrite().put(gradientScaleType.getTypeName(), Algorithms.colorToString(gradientScaleColor)); } public GradientScaleType getGradientScaleType() { @@ -1560,6 +1540,46 @@ public class GPXUtilities { return null; } + public void setGradientScaleType(GradientScaleType gradientScaleType) { + getExtensionsToWrite().put("gradient_scale_type", gradientScaleType != null ? gradientScaleType.name() : null); + } + + public GpxSplitType getSplitType() { + if (extensions != null) { + String gradientScaleTypeName = extensions.get("split_type"); + if (!Algorithms.isEmpty(gradientScaleTypeName)) { + try { + return GpxSplitType.valueOf(gradientScaleTypeName); + } catch (IllegalArgumentException e) { + log.error("Error reading GpxSplitType", e); + } + } + } + return null; + } + + public void setSplitType(GpxSplitType gpxSplitType) { + getExtensionsToWrite().put("split_type", gpxSplitType != null ? gpxSplitType.name() : null); + } + + public double getSplitInterval() { + if (extensions != null) { + String splitIntervalStr = extensions.get("split_interval"); + if (!Algorithms.isEmpty(splitIntervalStr)) { + try { + return Double.parseDouble(splitIntervalStr); + } catch (NumberFormatException e) { + log.error("Error reading split_interval", e); + } + } + } + return 0; + } + + public void setSplitInterval(double splitInterval) { + getExtensionsToWrite().put("split_interval", String.valueOf(splitInterval)); + } + public String getWidth(String defWidth) { String widthValue = null; if (extensions != null) { @@ -1595,6 +1615,38 @@ public class GPXUtilities { public void setShowStartFinish(boolean showStartFinish) { getExtensionsToWrite().put("show_start_finish", String.valueOf(showStartFinish)); } + + public enum GradientScaleType { + SPEED("gradient_speed_color"), + ALTITUDE("gradient_altitude_color"), + SLOPE("gradient_slope_color"); + + private String typeName; + + GradientScaleType(String typeName) { + this.typeName = typeName; + } + + public String getTypeName() { + return typeName; + } + } + + public enum GpxSplitType { + NO_SPLIT(-1), + DISTANCE(1), + TIME(2); + + private int type; + + GpxSplitType(int type) { + this.type = type; + } + + public int getType() { + return type; + } + } } public static String asString(GPXFile file) { diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index 58f8cdf27f..dd573eba54 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -72,10 +72,6 @@ public class GPXDatabase { private static final String GPX_COL_GRADIENT_SCALE_TYPE = "gradientScaleType"; - public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1; - public static final int GPX_SPLIT_TYPE_DISTANCE = 1; - public static final int GPX_SPLIT_TYPE_TIME = 2; - private static final String GPX_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + GPX_TABLE_NAME + " (" + GPX_COL_NAME + " TEXT, " + GPX_COL_DIR + " TEXT, " + diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index 0762982a33..4f4c12c9a4 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -8,6 +8,7 @@ import androidx.annotation.Nullable; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.GPXFile.GpxSplitType; import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.plus.GPXDatabase.GpxDataItem; @@ -114,8 +115,8 @@ public class GpxDbHelper { return res; } - public boolean updateSplit(@NonNull GpxDataItem item, int splitType, double splitInterval) { - boolean res = db.updateSplit(item, splitType, splitInterval); + public boolean updateSplit(@NonNull GpxDataItem item, @NonNull GpxSplitType splitType, double splitInterval) { + boolean res = db.updateSplit(item, splitType.getType(), splitInterval); putToCache(item); return res; } diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 07a183712d..6f239e2286 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -11,6 +11,7 @@ import androidx.core.content.ContextCompat; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.GPXFile.GpxSplitType; import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.GPXUtilities.Route; @@ -172,17 +173,17 @@ public class GpxSelectionHelper { if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) { GPXFile gpxFile = selectedGpxFile.getGpxFile(); List groups = app.getSelectedGpxHelper().collectDisplayGroups(gpxFile); - if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_NO_SPLIT) { + if (dataItem.getSplitType() == GpxSplitType.NO_SPLIT.getType()) { for (GpxDisplayGroup model : groups) { model.noSplit(app); } selectedGpxFile.setDisplayGroups(groups, app); - } else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) { + } else if (dataItem.getSplitType() == GpxSplitType.DISTANCE.getType()) { for (GpxDisplayGroup model : groups) { model.splitByDistance(app, dataItem.getSplitInterval(), dataItem.isJoinSegments()); } selectedGpxFile.setDisplayGroups(groups, app); - } else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_TIME) { + } else if (dataItem.getSplitType() == GpxSplitType.TIME.getType()) { for (GpxDisplayGroup model : groups) { model.splitByTime(app, (int) dataItem.getSplitInterval(), dataItem.isJoinSegments()); } diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java index b5a9ee75e9..7bf86aff9e 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java @@ -1027,6 +1027,10 @@ public class ImportHelper { item.setGradientSlopeColor(gpxFile.getGradientScaleColor(GradientScaleType.SLOPE, 0)); item.setGradientAltitudeColor(gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE, 0)); app.getGpxDbHelper().add(item); + + if (gpxFile.getSplitType() != null && gpxFile.getSplitInterval() != 0) { + app.getGpxDbHelper().updateSplit(item, gpxFile.getSplitType(), gpxFile.getSplitInterval()); + } } else { GPXDatabase.GpxDataItem item = app.getGpxDbHelper().getItem(file); if (item != null) { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java index 0304618a7c..260d7fccda 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java @@ -39,12 +39,12 @@ import com.squareup.picasso.RequestCreator; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.GPXFile.GpxSplitType; import net.osmand.GPXUtilities.WptPt; import net.osmand.PicassoUtils; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; -import net.osmand.plus.GPXDatabase; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; @@ -764,9 +764,9 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { double splitInterval = getGpxDataItem().getSplitInterval(); int position = 0; - if (splitType == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) { + if (splitType == GpxSplitType.DISTANCE.getType()) { position = distanceSplit.indexOf(splitInterval); - } else if (splitType == GPXDatabase.GPX_SPLIT_TYPE_TIME) { + } else if (splitType == GpxSplitType.TIME.getType()) { position = timeSplit.indexOf((int) splitInterval); } @@ -877,20 +877,20 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { } private void updateSplitInDatabase() { - int splitType = 0; double splitInterval = 0; + GpxSplitType splitType = null; if (selectedSplitInterval == 0) { - splitType = GPXDatabase.GPX_SPLIT_TYPE_NO_SPLIT; + splitType = GpxSplitType.NO_SPLIT; splitInterval = 0; } else if (distanceSplit.get(selectedSplitInterval) > 0) { - splitType = GPXDatabase.GPX_SPLIT_TYPE_DISTANCE; + splitType = GpxSplitType.DISTANCE; splitInterval = distanceSplit.get(selectedSplitInterval); } else if (timeSplit.get(selectedSplitInterval) > 0) { - splitType = GPXDatabase.GPX_SPLIT_TYPE_TIME; + splitType = GpxSplitType.TIME; splitInterval = timeSplit.get(selectedSplitInterval); } GpxDataItem item = getGpxDataItem(); - if (item != null) { + if (item != null && splitType != null) { app.getGpxDbHelper().updateSplit(item, splitType, splitInterval); } } From 109eb77f88bb5a050ab497038f2323dc396223bd Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 7 Jul 2020 17:15:37 +0200 Subject: [PATCH 013/551] Fix route calculation for GPX --- .../main/java/net/osmand/IndexConstants.java | 3 -- .../osmand/router/RoutePlannerFrontEnd.java | 49 +++++++++++------- .../osmand/router/RouteResultPreparation.java | 51 +++++++++++-------- .../net/osmand/router/RouteSegmentResult.java | 34 +++++++++---- .../plus/routing/RouteCalculationResult.java | 6 +-- 5 files changed, 88 insertions(+), 55 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java b/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java index 14401c4a04..0dea2d42fb 100644 --- a/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java +++ b/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java @@ -28,9 +28,6 @@ public class IndexConstants { public static final String EXTRA_EXT = ".extra"; public static final String EXTRA_ZIP_EXT = ".extra.zip"; - public static final String TOUR_INDEX_EXT = ".tour"; //$NON-NLS-1$ - public static final String TOUR_INDEX_EXT_ZIP = ".tour.zip"; //$NON-NLS-1$ - public static final String GEN_LOG_EXT = ".gen.log"; //$NON-NLS-1$ public static final String VOICE_INDEX_EXT_ZIP = ".voice.zip"; //$NON-NLS-1$ diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index acf76552a4..ba500a9471 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -31,7 +31,7 @@ public class RoutePlannerFrontEnd { // Check issue #8649 protected static final double GPS_POSSIBLE_ERROR = 7; public boolean useSmartRouteRecalculation = true; - + public RoutePlannerFrontEnd() { } @@ -50,7 +50,7 @@ public class RoutePlannerFrontEnd { // don't search subsegments shorter than specified distance (also used to step back for car turns) public double MINIMUM_STEP_APPROXIMATION = 100; // Parameter to smoother the track itself (could be 0 if it's not recorded track) - public double SMOOTHEN_POINTS_NO_ROUTE = 2; + public double SMOOTHEN_POINTS_NO_ROUTE = 5; public final RoutingContext ctx; public int routeCalculations = 0; @@ -92,6 +92,7 @@ public class RoutePlannerFrontEnd { public double cumDist; public RouteSegmentPoint pnt; public List routeToTarget; + public List stepBackRoute; public int targetInd = -1; } @@ -203,11 +204,7 @@ public class RoutePlannerFrontEnd { } - // TODO last segment not correct (cut) before end point and point of straight line - - // TODO add missing turns for straight lines (compare code) // TODO native matches less roads - // TODO fix progress - next iteration // TODO fix timings and remove logging every iteration public GpxRouteApproximation searchGpxRoute(GpxRouteApproximation gctx, List points) throws IOException, InterruptedException { @@ -217,7 +214,7 @@ public class RoutePlannerFrontEnd { } List gpxPoints = generageGpxPoints(points, gctx); GpxPoint start = gpxPoints.size() > 0 ? gpxPoints.get(0) : null; - boolean prevRouteFound = false; + GpxPoint prev = null; while (start != null) { double routeDist = gctx.MAXIMUM_STEP_APPROXIMATION; GpxPoint next = findNextGpxPointWithin(gctx, gpxPoints, start, routeDist); @@ -227,13 +224,13 @@ public class RoutePlannerFrontEnd { while (routeDist >= gctx.MINIMUM_STEP_APPROXIMATION && !routeFound) { routeFound = initRoutingPoint(next, gctx, gctx.MINIMUM_POINT_APPROXIMATION); if (routeFound) { - routeFound = findGpxRouteSegment(gctx, gpxPoints, start, next, prevRouteFound); + routeFound = findGpxRouteSegment(gctx, gpxPoints, start, next, prev != null); if (routeFound) { // route is found - cut the end of the route and move to next iteration boolean stepBack = stepBackAndFindPrevPointInRoute(gctx, gpxPoints, start, next); if (!stepBack) { // not supported case (workaround increase MAXIMUM_STEP_APPROXIMATION) - log.info("Consider to increase MAXIMUM_STEP_APPROXIMATION to: " + routeDist*2); + log.info("Consider to increase MAXIMUM_STEP_APPROXIMATION to: " + routeDist * 2); start.routeToTarget = null; routeFound = false; break; @@ -257,16 +254,17 @@ public class RoutePlannerFrontEnd { if (!routeFound) { // route is not found, move start point by next = findNextGpxPointWithin(gctx, gpxPoints, start, gctx.MINIMUM_STEP_APPROXIMATION); - if (prevRouteFound) { - if (next == null) { - // TODO finish - // makeSegmentPointPrecise(prev.routeToTarget.get(prev.routeToTarget.size() - 1), start.loc, false); - } else { + if (prev != null) { + prev.routeToTarget.addAll(prev.stepBackRoute); + makeSegmentPointPrecise(prev.routeToTarget.get(prev.routeToTarget.size() - 1), start.loc, false); + if (next != null) { log.warn("NOT found route from: " + start.pnt.getRoad() + " at " + start.pnt.getSegmentStart()); } } + prev = null; + } else { + prev = start; } - prevRouteFound = routeFound; start = next; } @@ -289,6 +287,7 @@ public class RoutePlannerFrontEnd { double d = 0; int segmendInd = start.routeToTarget.size() - 1; boolean search = true; + start.stepBackRoute = new ArrayList(); mainLoop: for (; segmendInd >= 0 && search; segmendInd--) { RouteSegmentResult rr = start.routeToTarget.get(segmendInd); boolean minus = rr.getStartPointIndex() < rr.getEndPointIndex(); @@ -300,6 +299,7 @@ public class RoutePlannerFrontEnd { if (nextInd == rr.getStartPointIndex()) { segmendInd--; } else { + start.stepBackRoute.add(new RouteSegmentResult(rr.getObject(), nextInd, rr.getEndPointIndex())); rr.setEndPointIndex(nextInd); } search = false; @@ -311,8 +311,10 @@ public class RoutePlannerFrontEnd { // here all route segments - 1 is longer than needed distance to step back return false; } + while (start.routeToTarget.size() > segmendInd + 1) { - start.routeToTarget.remove(segmendInd + 1); + RouteSegmentResult removed = start.routeToTarget.remove(segmendInd + 1); + start.stepBackRoute.add(removed); } RouteSegmentResult res = start.routeToTarget.get(segmendInd); next.pnt = new RouteSegmentPoint(res.getObject(), res.getEndPointIndex(), 0); @@ -321,7 +323,7 @@ public class RoutePlannerFrontEnd { private void calculateGpxRoute(GpxRouteApproximation gctx, List gpxPoints) { RouteRegion reg = new RouteRegion(); - reg.initRouteEncodingRule(0, "highway", "unmatched"); + reg.initRouteEncodingRule(0, "highway", RouteResultPreparation.UNMATCHED_HIGHWAY_TYPE); List lastStraightLine = null; for (int i = 0; i < gpxPoints.size(); ) { GpxPoint pnt = gpxPoints.get(i); @@ -424,8 +426,17 @@ public class RoutePlannerFrontEnd { rdo.pointsY = y.toArray(); rdo.types = new int[] { 0 } ; rdo.id = -1; - // comment to see road without straight connections - res.add(new RouteSegmentResult(rdo, 0, rdo.getPointsLength() - 1)); + List rts = new ArrayList<>(); + rts.add(new RouteSegmentResult(rdo, 0, rdo.getPointsLength() - 1)); + RouteResultPreparation preparation = new RouteResultPreparation(); + try { + preparation.prepareResult(gctx.ctx, rts, false); + } catch (IOException e) { + throw new IllegalStateException(e); + } + + // VIEW: comment to see road without straight connections + res.addAll(rts); } diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index 8344ff6027..3de09af9d1 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -44,8 +44,11 @@ public class RouteResultPreparation { public static boolean PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = false; public static String PRINT_TO_GPX_FILE = null; private static final float TURN_DEGREE_MIN = 45; + private static final float UNMATCHED_TURN_DEGREE_MINIMUM = 45; + private static final float SPLIT_TURN_DEGREE_NOT_STRAIGHT = 100; public static final int SHIFT_ID = 6; private Log log = PlatformUtil.getLog(RouteResultPreparation.class); + public static final String UNMATCHED_HIGHWAY_TYPE = "unmatched"; /** * Helper method to prepare final result */ @@ -222,7 +225,7 @@ public class RouteResultPreparation { private void justifyUTurns(boolean leftSide, List result) { int next; - for (int i = 0; i < result.size() - 1; i = next) { + for (int i = 1; i < result.size() - 1; i = next) { next = i + 1; TurnType t = result.get(i).getTurnType(); // justify turn @@ -313,6 +316,7 @@ public class RouteResultPreparation { RouteSegmentResult rr = result.get(i); boolean plus = rr.getStartPointIndex() < rr.getEndPointIndex(); int next; + boolean unmatched = UNMATCHED_HIGHWAY_TYPE.equals(rr.getObject().getHighway()); for (int j = rr.getStartPointIndex(); j != rr.getEndPointIndex(); j = next) { next = plus ? j + 1 : j - 1; if (j == rr.getStartPointIndex()) { @@ -323,27 +327,33 @@ public class RouteResultPreparation { } List attachedRoutes = rr.getAttachedRoutes(next); boolean tryToSplit = next != rr.getEndPointIndex() && !rr.getObject().roundabout() && attachedRoutes != null; - if(rr.getDistance(next, plus ) == 0) { + if (rr.getDistance(next, plus) == 0) { // same point will be processed next step tryToSplit = false; } if (tryToSplit) { + float distBearing = unmatched ? RouteSegmentResult.DIST_BEARING_DETECT_UNMATCHED : RouteSegmentResult.DIST_BEARING_DETECT; // avoid small zigzags - float before = rr.getBearing(next, !plus); - float after = rr.getBearing(next, plus); - if(rr.getDistance(next, plus ) < 5) { - after = before + 180; - } else if(rr.getDistance(next, !plus ) < 5) { - before = after - 180; + float before = rr.getBearingEnd(next, distBearing); + float after = rr.getBearingBegin(next, distBearing); + if (rr.getDistance(next, plus) < distBearing) { + after = before; + } else if (rr.getDistance(next, !plus) < distBearing) { + before = after; } - boolean straight = Math.abs(MapUtils.degreesDiff(before + 180, after)) < TURN_DEGREE_MIN; + double contAngle = Math.abs(MapUtils.degreesDiff(before, after)); + boolean straight = contAngle < TURN_DEGREE_MIN; boolean isSplit = false; + + if (unmatched && Math.abs(contAngle) >= UNMATCHED_TURN_DEGREE_MINIMUM) { + isSplit = true; + } // split if needed for (RouteSegmentResult rs : attachedRoutes) { - double diff = MapUtils.degreesDiff(before + 180, rs.getBearingBegin()); + double diff = MapUtils.degreesDiff(before, rs.getBearingBegin()); if (Math.abs(diff) <= TURN_DEGREE_MIN) { isSplit = true; - } else if (!straight && Math.abs(diff) < 100) { + } else if (!straight && Math.abs(diff) < SPLIT_TURN_DEGREE_NOT_STRAIGHT) { isSplit = true; } } @@ -1061,18 +1071,17 @@ public class RouteResultPreparation { } TurnType t = null; if (prev != null) { - boolean noAttachedRoads = rr.getAttachedRoutes(rr.getStartPointIndex()).size() == 0; // add description about turn - double mpi = MapUtils.degreesDiff(prev.getBearingEnd(), rr.getBearingBegin()); - if(noAttachedRoads){ - // VICTOR : look at the comment inside direction route - // ? avoid small zigzags is covered at (search for "zigzags") -// double begin = rr.getObject().directionRoute(rr.getStartPointIndex(), rr.getStartPointIndex() < -// rr.getEndPointIndex(), 25); -// mpi = MapUtils.degreesDiff(prev.getBearingEnd(), begin); + // avoid small zigzags is covered at (search for "zigzags") + float bearingDist = RouteSegmentResult.DIST_BEARING_DETECT; + // could be || noAttachedRoads, boolean noAttachedRoads = rr.getAttachedRoutes(rr.getStartPointIndex()).size() == 0; + if (UNMATCHED_HIGHWAY_TYPE.equals(rr.getObject().getHighway())) { + bearingDist = RouteSegmentResult.DIST_BEARING_DETECT_UNMATCHED; } + double mpi = MapUtils.degreesDiff(prev.getBearingEnd(prev.getEndPointIndex(), bearingDist), + rr.getBearingBegin(rr.getStartPointIndex(), bearingDist)); if (mpi >= TURN_DEGREE_MIN) { - if (mpi < 45) { + if (mpi < TURN_DEGREE_MIN) { // Slight turn detection here causes many false positives where drivers would expect a "normal" TL. Best use limit-angle=TURN_DEGREE_MIN, this reduces TSL to the turn-lanes cases. t = TurnType.valueOf(TurnType.TSLL, leftSide); } else if (mpi < 120) { @@ -1085,7 +1094,7 @@ public class RouteResultPreparation { int[] lanes = getTurnLanesInfo(prev, t.getValue()); t.setLanes(lanes); } else if (mpi < -TURN_DEGREE_MIN) { - if (mpi > -45) { + if (mpi > -TURN_DEGREE_MIN) { t = TurnType.valueOf(TurnType.TSLR, leftSide); } else if (mpi > -120) { t = TurnType.valueOf(TurnType.TR, leftSide); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteSegmentResult.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteSegmentResult.java index 40257c474b..6ebe1645ee 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteSegmentResult.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteSegmentResult.java @@ -22,7 +22,10 @@ import gnu.trove.map.hash.TIntObjectHashMap; public class RouteSegmentResult implements StringExternalizable { // this should be bigger (50-80m) but tests need to be fixed first - private static final float DIST_BEARING_DETECT = 5; + public static final float DIST_BEARING_DETECT = 5; + + public static final float DIST_BEARING_DETECT_UNMATCHED = 50; + private RouteDataObject object; private int startPointIndex; private int endPointIndex; @@ -446,19 +449,32 @@ public class RouteSegmentResult implements StringExternalizable } public float getBearingBegin() { - return (float) (object.directionRoute(startPointIndex, startPointIndex < endPointIndex, DIST_BEARING_DETECT) / Math.PI * 180); + return getBearingBegin(startPointIndex, DIST_BEARING_DETECT); } - public float getBearing(int point, boolean plus) { - return (float) (object.directionRoute(point, plus, DIST_BEARING_DETECT) / Math.PI * 180); - } - - public float getDistance(int point, boolean plus) { - return (float) (plus? object.distance(point, endPointIndex): object.distance(startPointIndex, point)); + public float getBearingBegin(int point, float dist) { + return getBearing(point, true, dist); } public float getBearingEnd() { - return (float) (MapUtils.alignAngleDifference(object.directionRoute(endPointIndex, startPointIndex > endPointIndex, DIST_BEARING_DETECT) - Math.PI) / Math.PI * 180); + return getBearingEnd(endPointIndex, DIST_BEARING_DETECT); + } + + public float getBearingEnd(int point, float dist) { + return getBearing(point, false, dist); + } + + public float getBearing(int point, boolean begin, float dist) { + if (begin) { + return (float) (object.directionRoute(point, startPointIndex < endPointIndex, dist) / Math.PI * 180); + } else { + double dr = object.directionRoute(point, startPointIndex > endPointIndex, dist); + return (float) (MapUtils.alignAngleDifference(dr - Math.PI) / Math.PI * 180); + } + } + + public float getDistance(int point, boolean plus) { + return (float) (plus ? object.distance(point, endPointIndex) : object.distance(startPointIndex, point)); } public void setSegmentTime(float segmentTime) { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 6ac55e7592..46ceaf70ea 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -493,9 +493,9 @@ public class RouteCalculationResult { Location current = locations.get(i); float bearing = current.bearingTo(next); // try to get close to current location if possible - while(prevBearingLocation < i - 1){ - if(locations.get(prevBearingLocation + 1).distanceTo(current) > 70){ - prevBearingLocation ++; + while (prevBearingLocation < i - 1) { + if (locations.get(prevBearingLocation + 1).distanceTo(current) > 70) { + prevBearingLocation++; } else { break; } From ede816431dca3a5b5b890a0e291a5da7ed2951dd Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 7 Jul 2020 18:52:40 +0200 Subject: [PATCH 014/551] Fix route preparation --- .../net/osmand/router/BinaryRoutePlanner.java | 21 ++++++++----------- .../osmand/router/RoutePlannerFrontEnd.java | 16 +++++++------- .../net/osmand/router/RoutingContext.java | 18 ++++++---------- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index 1b6077cbb1..5c0f38f4a5 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -65,13 +65,11 @@ public class BinaryRoutePlanner { * Calculate route between start.segmentEnd and end.segmentStart (using A* algorithm) * return list of segments */ - @SuppressWarnings("unused") FinalRouteSegment searchRouteInternal(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end, RouteSegment recalculationEnd ) throws InterruptedException, IOException { // measure time ctx.timeToLoad = 0; ctx.memoryOverhead = 1000; - ctx.visitedSegments = 0; // Initializing priority queue to visit way segments Comparator nonHeuristicSegmentsComparator = new NonHeuristicSegmentsComparator(); @@ -166,8 +164,12 @@ public class BinaryRoutePlanner { throw new InterruptedException("Route calculation interrupted"); } } - ctx.visitedSegments = visitedDirectSegments.size() + visitedOppositeSegments.size(); - printDebugMemoryInformation(ctx, graphDirectSegments, graphReverseSegments, visitedDirectSegments, visitedOppositeSegments); + ctx.visitedSegments += visitedDirectSegments.size() + visitedOppositeSegments.size(); + ctx.visitedDirectSegments += visitedDirectSegments.size(); + ctx.visitedOppositeSegments += visitedOppositeSegments.size(); + ctx.directQueueSize = graphDirectSegments.size(); // Math.max(ctx.directQueueSize, graphDirectSegments.size()); + ctx.oppositeQueueSize = graphReverseSegments.size(); + ctx.visitedOppositeSegments += visitedOppositeSegments.size(); return finalSegment; } @@ -368,8 +370,7 @@ public class BinaryRoutePlanner { log.warn(logMsg); } - public void printDebugMemoryInformation(RoutingContext ctx, PriorityQueue graphDirectSegments, PriorityQueue graphReverseSegments, - TLongObjectHashMap visitedDirectSegments,TLongObjectHashMap visitedOppositeSegments) { + public static void printDebugMemoryInformation(RoutingContext ctx) { printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to calc dev: %.2f ", (System.nanoTime() - ctx.timeToCalculate) / 1e6, ctx.timeToLoad / 1e6, ctx.timeToLoadHeaders / 1e6, ctx.timeNanoToCalcDeviation / 1e6)); @@ -380,12 +381,8 @@ public class BinaryRoutePlanner { ", loaded more than once same tiles " + ctx.loadedPrevUnloadedTiles); printInfo("Visited segments " + ctx.visitedSegments + ", relaxed roads " + ctx.relaxedSegments); - if (graphDirectSegments != null && graphReverseSegments != null) { - printInfo("Priority queues sizes : " + graphDirectSegments.size() + "/" + graphReverseSegments.size()); - } - if (visitedDirectSegments != null && visitedOppositeSegments != null) { - printInfo("Visited interval sizes: " + visitedDirectSegments.size() + "/" + visitedOppositeSegments.size()); - } + printInfo("Priority queues sizes : " + ctx.directQueueSize + "/" + ctx.oppositeQueueSize); + printInfo("Visited interval sizes: " + ctx.visitedDirectSegments + "/" + ctx.visitedOppositeSegments); } diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index ba500a9471..60dc5add01 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -203,23 +203,24 @@ public class RoutePlannerFrontEnd { useSmartRouteRecalculation = use; } - // TODO native matches less roads - // TODO fix progress - next iteration - // TODO fix timings and remove logging every iteration public GpxRouteApproximation searchGpxRoute(GpxRouteApproximation gctx, List points) throws IOException, InterruptedException { gctx.ctx.timeToCalculate = System.nanoTime(); if (gctx.ctx.calculationProgress == null) { gctx.ctx.calculationProgress = new RouteCalculationProgress(); } List gpxPoints = generageGpxPoints(points, gctx); - GpxPoint start = gpxPoints.size() > 0 ? gpxPoints.get(0) : null; + GpxPoint start = null; GpxPoint prev = null; + if(gpxPoints.size() > 0) { + gctx.ctx.calculationProgress.totalIterations = (int) (gpxPoints.get(gpxPoints.size() - 1).cumDist / gctx.MAXIMUM_STEP_APPROXIMATION + 1); + start = gpxPoints.get(0); + } while (start != null) { double routeDist = gctx.MAXIMUM_STEP_APPROXIMATION; GpxPoint next = findNextGpxPointWithin(gctx, gpxPoints, start, routeDist); boolean routeFound = false; - + gctx.ctx.calculationProgress.nextIteration(); if (next != null && initRoutingPoint(start, gctx, gctx.MINIMUM_POINT_APPROXIMATION)) { while (routeDist >= gctx.MINIMUM_STEP_APPROXIMATION && !routeFound) { routeFound = initRoutingPoint(next, gctx, gctx.MINIMUM_POINT_APPROXIMATION); @@ -267,9 +268,8 @@ public class RoutePlannerFrontEnd { } start = next; } - + BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx); calculateGpxRoute(gctx, gpxPoints); - if (!gctx.res.isEmpty()) { new RouteResultPreparation().printResults(gctx.ctx, points.get(0), points.get(points.size() - 1), gctx.res); System.out.println(gctx); @@ -504,6 +504,7 @@ public class RoutePlannerFrontEnd { gctx.routeDistCalculations += (target.cumDist - start.cumDist); gctx.routeCalculations++; res = searchRouteInternalPrepare(gctx.ctx, start.pnt, target.pnt, null); + //BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx); routeIsCorrect = res != null && !res.isEmpty(); for (int k = start.ind + 1; routeIsCorrect && k < target.ind; k++) { GpxPoint ipoint = gpxPoints.get(k); @@ -859,6 +860,7 @@ public class RoutePlannerFrontEnd { } pringGC(ctx, true); List res = searchRouteInternalPrepare(ctx, points.get(0), points.get(1), routeDirection); + BinaryRoutePlanner.printDebugMemoryInformation(ctx); pringGC(ctx, false); makeStartEndPointsPrecise(res, points.get(0).getPreciseLatLon(), points.get(1).getPreciseLatLon(), null); return res; diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java index 2c44940dff..e3c233b4d4 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java @@ -98,11 +98,17 @@ public class RoutingContext { public int loadedTiles = 0; public int visitedSegments = 0; public int relaxedSegments = 0; + public int visitedDirectSegments = 0; + public int visitedOppositeSegments = 0; + public int directQueueSize = 0; + public int oppositeQueueSize = 0; // callback of processing segments RouteSegmentVisitor visitor = null; // old planner public FinalRouteSegment finalRouteSegment; + + RoutingContext(RoutingContext cp) { this.config = cp.config; @@ -252,18 +258,6 @@ public class RoutingContext { return ind; } - public void newRoutingPoints() { - int middleX = startX / 2 + targetX / 2; - int middleY = startY / 2 + targetY; - List dataObjects = new ArrayList(); - loadTileData(middleX, middleY, 17, dataObjects); - - - System.out.println("Size of data objects " + dataObjects.size()); - } - - - public RouteSegment loadRouteSegment(int x31, int y31, long memoryLimit) { long tileId = getRoutingTile(x31, y31, memoryLimit); From 005aa87d149751b6c1f466e2ce91cb9306567b09 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 7 Jul 2020 22:09:00 +0200 Subject: [PATCH 015/551] Fix #9336 --- .../osmand/router/RouteResultPreparation.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index 3de09af9d1..b0c32de648 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -1476,32 +1476,39 @@ public class RouteResultPreparation { protected TurnType createSimpleKeepLeftRightTurn(boolean leftSide, RouteSegmentResult prevSegm, RouteSegmentResult currentSegm, RoadSplitStructure rs) { + double devation = Math.abs(MapUtils.degreesDiff(prevSegm.getBearingEnd(), currentSegm.getBearingBegin())); + boolean makeSlightTurn = devation > 5 && (!isMotorway(prevSegm) || !isMotorway(currentSegm)); + TurnType t = null; + int laneType = TurnType.C; + if (rs.keepLeft && rs.keepRight) { + t = TurnType.valueOf(TurnType.C, leftSide); + } else if (rs.keepLeft) { + t = TurnType.valueOf(makeSlightTurn ? TurnType.TSLL : TurnType.KL, leftSide); + if (makeSlightTurn) { + laneType = TurnType.TSLL; + } + } else if (rs.keepRight) { + t = TurnType.valueOf(makeSlightTurn ? TurnType.TSLR : TurnType.KR, leftSide); + if (makeSlightTurn) { + laneType = TurnType.TSLR; + } + } else { + return null; + } int current = countLanesMinOne(currentSegm); int ls = current + rs.leftLanes + rs.rightLanes; int[] lanes = new int[ls]; for (int it = 0; it < ls; it++) { if (it < rs.leftLanes || it >= rs.leftLanes + current) { - lanes[it] = 0; + lanes[it] = TurnType.C << 1; } else { - lanes[it] = 1; + lanes[it] = (laneType << 1) + 1; } } // sometimes links are if ((current <= rs.leftLanes + rs.rightLanes) && (rs.leftLanes > 1 || rs.rightLanes > 1)) { rs.speak = true; } - double devation = Math.abs(MapUtils.degreesDiff(prevSegm.getBearingEnd(), currentSegm.getBearingBegin())); - boolean makeSlightTurn = devation > 5 && (!isMotorway(prevSegm) || !isMotorway(currentSegm)); - TurnType t = null; - if (rs.keepLeft && rs.keepRight) { - t = TurnType.valueOf(TurnType.C, leftSide); - } else if (rs.keepLeft) { - t = TurnType.valueOf(makeSlightTurn ? TurnType.TSLL : TurnType.KL, leftSide); - } else if (rs.keepRight) { - t = TurnType.valueOf(makeSlightTurn ? TurnType.TSLR : TurnType.KR, leftSide); - } else { - return t; - } t.setSkipToSpeak(!rs.speak); t.setLanes(lanes); return t; From 45991e883429d98e0995f17699029b23f5fb3302 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 7 Jul 2020 22:53:00 +0200 Subject: [PATCH 016/551] Fix #9345 wrong time for short route --- .../src/main/java/net/osmand/router/GeneralRouter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java b/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java index 3c6553f523..537e3a5f74 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java @@ -72,6 +72,8 @@ public class GeneralRouter implements VehicleRouter { private float defaultSpeed = 1f; // speed in m/s private float maxSpeed = 10f; + // speed in m/s (used for shortest route) + private float maxVehicleSpeed; private TLongHashSet impassableRoads; private GeneralRouterProfile profile; @@ -149,6 +151,7 @@ public class GeneralRouter implements VehicleRouter { if (params.containsKey(MAX_SPEED)) { maxSpeed = parseSilentFloat(params.get(MAX_SPEED), maxSpeed); } + maxVehicleSpeed = maxSpeed; if (shortestRoute) { maxSpeed = Math.min(CAR_SHORTEST_DEFAULT_SPEED, maxSpeed); } @@ -489,10 +492,15 @@ public class GeneralRouter implements VehicleRouter { @Override public float defineVehicleSpeed(RouteDataObject road) { + // don't use cache cause max/min is different for routing speed + if (maxVehicleSpeed != maxSpeed) { + float spd = getObjContext(RouteDataObjectAttribute.ROAD_SPEED).evaluateFloat(road, defaultSpeed); + return Math.max(Math.min(spd, maxVehicleSpeed), minSpeed); + } Float sp = getCache(RouteDataObjectAttribute.ROAD_SPEED, road); if (sp == null) { float spd = getObjContext(RouteDataObjectAttribute.ROAD_SPEED).evaluateFloat(road, defaultSpeed); - sp = Math.max(Math.min(spd, maxSpeed), minSpeed); + sp = Math.max(Math.min(spd, maxVehicleSpeed), minSpeed); putCache(RouteDataObjectAttribute.ROAD_SPEED, road, sp); } return sp; From 89a05082aca412cd1199f3b2da6d5be61485538a Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Wed, 8 Jul 2020 11:03:21 +0300 Subject: [PATCH 017/551] Fix #7131 --- .../main/java/net/osmand/data/Amenity.java | 1 + .../builders/AmenityMenuBuilder.java | 6 +- .../builders/cards/ImageCard.java | 5 ++ .../net/osmand/plus/wikimedia/WikiImage.java | 33 +++++++ .../osmand/plus/wikimedia/WikiImageCard.java | 41 +++++++++ .../plus/wikimedia/WikiImageHelper.java | 90 +++++++++++++++++++ .../osmand/plus/wikimedia/pojo/Claims.java | 22 +++++ .../osmand/plus/wikimedia/pojo/Datavalue.java | 32 +++++++ .../osmand/plus/wikimedia/pojo/Mainsnak.java | 65 ++++++++++++++ .../net/osmand/plus/wikimedia/pojo/P18.java | 54 +++++++++++ .../wikimedia/pojo/WikipediaResponse.java | 21 +++++ 11 files changed, 369 insertions(+), 1 deletion(-) create mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/WikiImage.java create mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/WikiImageCard.java create mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java create mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/Claims.java create mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/Datavalue.java create mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/Mainsnak.java create mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/P18.java create mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/WikipediaResponse.java diff --git a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java index a041d6f694..38854cb33b 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java @@ -38,6 +38,7 @@ public class Amenity extends MapObject { public static final String COLLECTION_TIMES = "collection_times"; public static final String CONTENT = "content"; public static final String CUISINE = "cuisine"; + public static final String WIKIDATA = "wikidata"; public static final String DISH = "dish"; public static final String REF = "ref"; public static final String OSM_DELETE_VALUE = "delete"; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 66567bc76c..eb1e0df1eb 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -471,7 +471,7 @@ public class AmenityMenuBuilder extends MenuBuilder { } textPrefix = app.getString(R.string.poi_cuisine); vl = sb.toString(); - } else if (key.contains(Amenity.ROUTE)) { + } else if (key.contains(Amenity.ROUTE) || key.contains(Amenity.WIKIDATA)) { continue; } else { if (key.contains(Amenity.DESCRIPTION)) { @@ -784,12 +784,16 @@ public class AmenityMenuBuilder extends MenuBuilder { Map additionalInfo = amenity.getAdditionalInfo(); String imageValue = additionalInfo.get("image"); String mapillaryValue = additionalInfo.get("mapillary"); + String wikidataValue = additionalInfo.get("wikidata"); if (!Algorithms.isEmpty(imageValue)) { params.put("osm_image", imageValue); } if (!Algorithms.isEmpty(mapillaryValue)) { params.put("osm_mapillary_key", mapillaryValue); } + if (!Algorithms.isEmpty(wikidataValue)) { + params.put("wikidata_id", wikidataValue); + } return params; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java index a821d8b3cf..e0733d7d56 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java @@ -25,6 +25,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapillary.MapillaryContributeCard; import net.osmand.plus.mapillary.MapillaryImageCard; +import net.osmand.plus.wikimedia.WikiImageHelper; import net.osmand.util.Algorithms; import org.json.JSONArray; @@ -438,6 +439,10 @@ public abstract class ImageCard extends AbstractCard { } if (this.params != null) { pms.putAll(this.params); + String wikidataId = this.params.get("wikidata_id"); + if (wikidataId != null) { + WikiImageHelper.fillWikiMediaCards(mapActivity, wikidataId, result); + } } String response = AndroidNetworkUtils.sendRequest(app, "https://osmand.net/api/cm_place", pms, "Requesting location images...", false, false); diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImage.java b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImage.java new file mode 100644 index 0000000000..d442afbb4e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImage.java @@ -0,0 +1,33 @@ +package net.osmand.plus.wikimedia; + +public class WikiImage { + + private String imageName; + private String imageStubUrl; + private String imageHiResUrl; + private String datatype; + + public WikiImage(String imageName, String imageStubUrl, + String imageHiResUrl, String datatype) { + this.imageName = imageName; + this.imageStubUrl = imageStubUrl; + this.imageHiResUrl = imageHiResUrl; + this.datatype = datatype; + } + + public String getImageName() { + return imageName; + } + + public String getImageStubUrl() { + return imageStubUrl; + } + + public String getImageHiResUrl() { + return imageHiResUrl; + } + + public String getDatatype() { + return datatype; + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageCard.java b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageCard.java new file mode 100644 index 0000000000..db4ccef2ea --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageCard.java @@ -0,0 +1,41 @@ +package net.osmand.plus.wikimedia; + +import android.view.View; + +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; +import net.osmand.util.Algorithms; + +import org.json.JSONObject; + +public class WikiImageCard extends ImageCard { + + public WikiImageCard(final MapActivity mapActivity, final JSONObject imageObject, + final WikiImage wikiImage) { + super(mapActivity, imageObject); + + if (topIconId == 0) { + topIconId = R.drawable.ic_logo_wikimedia; + } + + this.imageUrl = wikiImage.getImageStubUrl(); + this.url = this.imageUrl; + + View.OnClickListener onClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + openUrl(getMapActivity(), getMyApplication(), getTitle(), wikiImage.getImageHiResUrl(), + isExternalLink() || Algorithms.isEmpty(getImageHiresUrl()), + !Algorithms.isEmpty(getImageHiresUrl())); + } + }; + + if (!Algorithms.isEmpty(buttonText)) { + this.onButtonClickListener = onClickListener; + } else { + this.onClickListener = onClickListener; + } + } + +} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java new file mode 100644 index 0000000000..3a2c23fdec --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java @@ -0,0 +1,90 @@ +package net.osmand.plus.wikimedia; + +import androidx.annotation.NonNull; + +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; + +import net.osmand.PlatformUtil; +import net.osmand.osm.io.NetworkUtils; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; +import net.osmand.plus.wikimedia.pojo.P18; +import net.osmand.plus.wikimedia.pojo.WikipediaResponse; + +import org.apache.commons.codec.binary.Hex; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.logging.Log; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.List; + +public class WikiImageHelper { + private static final String WIKIDATA_API_ENDPOINT = "https://www.wikidata.org/w/api.php"; + private static final String ACTION = "?action=wbgetclaims&property=P18&entity="; + private static final String FORMAT_JSON = "&format=json"; + private static final String IMAGE_BASE_URL = "https://upload.wikimedia.org/wikipedia/commons/"; + private static final String WIKIDATA_PREFIX = "Q"; + private static final int THUMB_SIZE = 500; + private static final Log LOG = PlatformUtil.getLog(WikiImageHelper.class); + + public static void fillWikiMediaCards(@NonNull MapActivity mapActivity, @NonNull String wikidata, + List images) { + if (wikidata.startsWith(WIKIDATA_PREFIX)) { + StringBuilder rawResponse = new StringBuilder(); + String url = WIKIDATA_API_ENDPOINT + ACTION + wikidata + FORMAT_JSON; + String error = NetworkUtils.sendGetRequest(url, null, rawResponse); + if (error == null) { + try { + Gson gson = new Gson(); + WikipediaResponse response = gson.fromJson(rawResponse.toString(), WikipediaResponse.class); + for (WikiImage img : getImageData(response)) { + images.add(new WikiImageCard(mapActivity, null, img)); + } + return; + } catch (JsonSyntaxException e) { + error = e.getLocalizedMessage(); + } + LOG.error(error); + } + } else { + LOG.error("Wrong WikiMedia ID"); + } + } + + public static List getImageData(WikipediaResponse response) { + List images = new ArrayList<>(); + try { + for (P18 p18 : response.getClaims().getP18()) { + String imageFileName = p18.getMainsnak().getDatavalue().getValue(); + if (imageFileName != null) { + String imageName = URLDecoder.decode(imageFileName, "UTF-8"); + imageFileName = imageName.replace(" ", "_"); + imageName = imageName.substring(0, imageName.lastIndexOf(".")); + String[] urlHashParts = getHash(imageFileName); + + String imageHiResUrl = IMAGE_BASE_URL + + urlHashParts[0] + "/" + urlHashParts[1] + "/" + + imageFileName; + String imageStubUrl = IMAGE_BASE_URL + "thumb/" + + urlHashParts[0] + "/" + urlHashParts[1] + "/" + + imageFileName + "/" + THUMB_SIZE + "px-" + + imageFileName; + images.add(new WikiImage(imageName, imageStubUrl, + imageHiResUrl, p18.getMainsnak().getDatatype())); + } + } + } catch (UnsupportedEncodingException e) { + LOG.error(e.getLocalizedMessage()); + } + return images; + } + + @NonNull + public static String[] getHash(@NonNull String s) { + String md5 = new String(Hex.encodeHex(DigestUtils.md5(s))); + return new String[]{md5.substring(0, 1), md5.substring(0, 2)}; + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Claims.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Claims.java new file mode 100644 index 0000000000..0f9aacaff7 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Claims.java @@ -0,0 +1,22 @@ + +package net.osmand.plus.wikimedia.pojo; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Claims { + + @SerializedName("P18") + @Expose + private List p18 = null; + + public List getP18() { + return p18; + } + + public void setP18(List p18) { + this.p18 = p18; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Datavalue.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Datavalue.java new file mode 100644 index 0000000000..975c0de82f --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Datavalue.java @@ -0,0 +1,32 @@ + +package net.osmand.plus.wikimedia.pojo; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Datavalue { + + @SerializedName("value") + @Expose + private String value; + @SerializedName("type") + @Expose + private String type; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Mainsnak.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Mainsnak.java new file mode 100644 index 0000000000..a757043bdd --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Mainsnak.java @@ -0,0 +1,65 @@ + +package net.osmand.plus.wikimedia.pojo; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Mainsnak { + + @SerializedName("snaktype") + @Expose + private String snaktype; + @SerializedName("property") + @Expose + private String property; + @SerializedName("hash") + @Expose + private String hash; + @SerializedName("datavalue") + @Expose + private Datavalue datavalue; + @SerializedName("datatype") + @Expose + private String datatype; + + public String getSnaktype() { + return snaktype; + } + + public void setSnaktype(String snaktype) { + this.snaktype = snaktype; + } + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } + + public Datavalue getDatavalue() { + return datavalue; + } + + public void setDatavalue(Datavalue datavalue) { + this.datavalue = datavalue; + } + + public String getDatatype() { + return datatype; + } + + public void setDatatype(String datatype) { + this.datatype = datatype; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/P18.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/P18.java new file mode 100644 index 0000000000..5cecaf5112 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/P18.java @@ -0,0 +1,54 @@ + +package net.osmand.plus.wikimedia.pojo; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class P18 { + + @SerializedName("mainsnak") + @Expose + private Mainsnak mainsnak; + @SerializedName("type") + @Expose + private String type; + @SerializedName("id") + @Expose + private String id; + @SerializedName("rank") + @Expose + private String rank; + + public Mainsnak getMainsnak() { + return mainsnak; + } + + public void setMainsnak(Mainsnak mainsnak) { + this.mainsnak = mainsnak; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRank() { + return rank; + } + + public void setRank(String rank) { + this.rank = rank; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/WikipediaResponse.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/WikipediaResponse.java new file mode 100644 index 0000000000..412f25602b --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/WikipediaResponse.java @@ -0,0 +1,21 @@ + +package net.osmand.plus.wikimedia.pojo; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class WikipediaResponse { + + @SerializedName("claims") + @Expose + private Claims claims; + + public Claims getClaims() { + return claims; + } + + public void setClaims(Claims claims) { + this.claims = claims; + } + +} From 4eabba3489cecc6129d35829114a294c2be66052 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 8 Jul 2020 13:03:28 +0300 Subject: [PATCH 018/551] Show track start finish icons by default --- OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java | 7 +++---- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 762ed0deb8..b3c3e18e8a 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1605,11 +1605,10 @@ public class GPXUtilities { } public boolean isShowStartFinish() { - String showStartFinish = null; - if (extensions != null) { - showStartFinish = extensions.get("show_start_finish"); + if (extensions != null && extensions.containsKey("show_start_finish")) { + return Boolean.parseBoolean(extensions.get("show_start_finish")); } - return Boolean.parseBoolean(showStartFinish); + return true; } public void setShowStartFinish(boolean showStartFinish) { diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index dd573eba54..16f480df10 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -443,7 +443,7 @@ public class GPXDatabase { db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " + "WHERE " + GPX_COL_SHOW_ARROWS + " IS NULL", new Object[]{0}); db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " + - "WHERE " + GPX_COL_SHOW_START_FINISH + " IS NULL", new Object[]{0}); + "WHERE " + GPX_COL_SHOW_START_FINISH + " IS NULL", new Object[]{1}); } db.execSQL("CREATE INDEX IF NOT EXISTS " + GPX_INDEX_NAME_DIR + " ON " + GPX_TABLE_NAME + " (" + GPX_COL_NAME + ", " + GPX_COL_DIR + ");"); } From 17ab336cfcaaa8d855071322ba8384f13fc3c87e Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Wed, 8 Jul 2020 13:33:40 +0300 Subject: [PATCH 019/551] Small refactoring --- .../builders/AmenityMenuBuilder.java | 2 +- .../builders/cards/ImageCard.java | 3 +- .../plus/wikimedia/WikiImageHelper.java | 75 ++++++++++++++++--- .../osmand/plus/wikimedia/pojo/Claims.java | 22 ------ .../osmand/plus/wikimedia/pojo/Datavalue.java | 32 -------- .../osmand/plus/wikimedia/pojo/Mainsnak.java | 65 ---------------- .../net/osmand/plus/wikimedia/pojo/P18.java | 54 ------------- .../wikimedia/pojo/WikipediaResponse.java | 21 ------ 8 files changed, 68 insertions(+), 206 deletions(-) delete mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/Claims.java delete mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/Datavalue.java delete mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/Mainsnak.java delete mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/P18.java delete mode 100644 OsmAnd/src/net/osmand/plus/wikimedia/pojo/WikipediaResponse.java diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index eb1e0df1eb..d627b4e6e6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -471,7 +471,7 @@ public class AmenityMenuBuilder extends MenuBuilder { } textPrefix = app.getString(R.string.poi_cuisine); vl = sb.toString(); - } else if (key.contains(Amenity.ROUTE) || key.contains(Amenity.WIKIDATA)) { + } else if (key.contains(Amenity.ROUTE) || key.equals(Amenity.WIKIDATA)) { continue; } else { if (key.contains(Amenity.DESCRIPTION)) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java index e0733d7d56..94c045fa4d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java @@ -438,11 +438,12 @@ public abstract class ImageCard extends AbstractCard { pms.put("lang", preferredLang); } if (this.params != null) { - pms.putAll(this.params); String wikidataId = this.params.get("wikidata_id"); if (wikidataId != null) { + this.params.remove("wikidata_id"); WikiImageHelper.fillWikiMediaCards(mapActivity, wikidataId, result); } + pms.putAll(this.params); } String response = AndroidNetworkUtils.sendRequest(app, "https://osmand.net/api/cm_place", pms, "Requesting location images...", false, false); diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java index 3a2c23fdec..59a53ba54e 100644 --- a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java @@ -4,13 +4,13 @@ import androidx.annotation.NonNull; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; import net.osmand.PlatformUtil; import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; -import net.osmand.plus.wikimedia.pojo.P18; -import net.osmand.plus.wikimedia.pojo.WikipediaResponse; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; @@ -47,8 +47,8 @@ public class WikiImageHelper { } catch (JsonSyntaxException e) { error = e.getLocalizedMessage(); } - LOG.error(error); } + LOG.error(error); } else { LOG.error("Wrong WikiMedia ID"); } @@ -56,10 +56,10 @@ public class WikiImageHelper { public static List getImageData(WikipediaResponse response) { List images = new ArrayList<>(); - try { - for (P18 p18 : response.getClaims().getP18()) { - String imageFileName = p18.getMainsnak().getDatavalue().getValue(); - if (imageFileName != null) { + for (P18 p18 : response.claims.p18) { + String imageFileName = p18.mainsnak.datavalue.value; + if (imageFileName != null) { + try { String imageName = URLDecoder.decode(imageFileName, "UTF-8"); imageFileName = imageName.replace(" ", "_"); imageName = imageName.substring(0, imageName.lastIndexOf(".")); @@ -73,11 +73,12 @@ public class WikiImageHelper { imageFileName + "/" + THUMB_SIZE + "px-" + imageFileName; images.add(new WikiImage(imageName, imageStubUrl, - imageHiResUrl, p18.getMainsnak().getDatatype())); + imageHiResUrl, p18.mainsnak.datatype)); + + } catch (UnsupportedEncodingException e) { + LOG.error(e.getLocalizedMessage()); } } - } catch (UnsupportedEncodingException e) { - LOG.error(e.getLocalizedMessage()); } return images; } @@ -87,4 +88,58 @@ public class WikiImageHelper { String md5 = new String(Hex.encodeHex(DigestUtils.md5(s))); return new String[]{md5.substring(0, 1), md5.substring(0, 2)}; } + + private class Claims { + @SerializedName("P18") + @Expose + private List p18 = null; + } + + public class Datavalue { + @SerializedName("value") + @Expose + private String value; + @SerializedName("type") + @Expose + private String type; + } + + public class Mainsnak { + @SerializedName("snaktype") + @Expose + private String snaktype; + @SerializedName("property") + @Expose + private String property; + @SerializedName("hash") + @Expose + private String hash; + @SerializedName("datavalue") + @Expose + private Datavalue datavalue; + @SerializedName("datatype") + @Expose + private String datatype; + } + + public class P18 { + @SerializedName("mainsnak") + @Expose + private Mainsnak mainsnak; + @SerializedName("type") + @Expose + private String type; + @SerializedName("id") + @Expose + private String id; + @SerializedName("rank") + @Expose + private String rank; + } + + public class WikipediaResponse { + @SerializedName("claims") + @Expose + private Claims claims; + } } diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Claims.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Claims.java deleted file mode 100644 index 0f9aacaff7..0000000000 --- a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Claims.java +++ /dev/null @@ -1,22 +0,0 @@ - -package net.osmand.plus.wikimedia.pojo; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Claims { - - @SerializedName("P18") - @Expose - private List p18 = null; - - public List getP18() { - return p18; - } - - public void setP18(List p18) { - this.p18 = p18; - } - -} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Datavalue.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Datavalue.java deleted file mode 100644 index 975c0de82f..0000000000 --- a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Datavalue.java +++ /dev/null @@ -1,32 +0,0 @@ - -package net.osmand.plus.wikimedia.pojo; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Datavalue { - - @SerializedName("value") - @Expose - private String value; - @SerializedName("type") - @Expose - private String type; - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - -} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Mainsnak.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Mainsnak.java deleted file mode 100644 index a757043bdd..0000000000 --- a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/Mainsnak.java +++ /dev/null @@ -1,65 +0,0 @@ - -package net.osmand.plus.wikimedia.pojo; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Mainsnak { - - @SerializedName("snaktype") - @Expose - private String snaktype; - @SerializedName("property") - @Expose - private String property; - @SerializedName("hash") - @Expose - private String hash; - @SerializedName("datavalue") - @Expose - private Datavalue datavalue; - @SerializedName("datatype") - @Expose - private String datatype; - - public String getSnaktype() { - return snaktype; - } - - public void setSnaktype(String snaktype) { - this.snaktype = snaktype; - } - - public String getProperty() { - return property; - } - - public void setProperty(String property) { - this.property = property; - } - - public String getHash() { - return hash; - } - - public void setHash(String hash) { - this.hash = hash; - } - - public Datavalue getDatavalue() { - return datavalue; - } - - public void setDatavalue(Datavalue datavalue) { - this.datavalue = datavalue; - } - - public String getDatatype() { - return datatype; - } - - public void setDatatype(String datatype) { - this.datatype = datatype; - } - -} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/P18.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/P18.java deleted file mode 100644 index 5cecaf5112..0000000000 --- a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/P18.java +++ /dev/null @@ -1,54 +0,0 @@ - -package net.osmand.plus.wikimedia.pojo; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class P18 { - - @SerializedName("mainsnak") - @Expose - private Mainsnak mainsnak; - @SerializedName("type") - @Expose - private String type; - @SerializedName("id") - @Expose - private String id; - @SerializedName("rank") - @Expose - private String rank; - - public Mainsnak getMainsnak() { - return mainsnak; - } - - public void setMainsnak(Mainsnak mainsnak) { - this.mainsnak = mainsnak; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getRank() { - return rank; - } - - public void setRank(String rank) { - this.rank = rank; - } - -} diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/WikipediaResponse.java b/OsmAnd/src/net/osmand/plus/wikimedia/pojo/WikipediaResponse.java deleted file mode 100644 index 412f25602b..0000000000 --- a/OsmAnd/src/net/osmand/plus/wikimedia/pojo/WikipediaResponse.java +++ /dev/null @@ -1,21 +0,0 @@ - -package net.osmand.plus.wikimedia.pojo; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class WikipediaResponse { - - @SerializedName("claims") - @Expose - private Claims claims; - - public Claims getClaims() { - return claims; - } - - public void setClaims(Claims claims) { - this.claims = claims; - } - -} From a08ac1fa0112d562d3db155cea95646e8183a9b9 Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Wed, 8 Jul 2020 14:36:11 +0300 Subject: [PATCH 020/551] Small refactoring p.2 --- .../net/osmand/plus/wikimedia/WikiImage.java | 7 +--- .../osmand/plus/wikimedia/WikiImageCard.java | 7 ++-- .../plus/wikimedia/WikiImageHelper.java | 37 +++++-------------- 3 files changed, 13 insertions(+), 38 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImage.java b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImage.java index d442afbb4e..d545b024e6 100644 --- a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImage.java +++ b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImage.java @@ -5,14 +5,12 @@ public class WikiImage { private String imageName; private String imageStubUrl; private String imageHiResUrl; - private String datatype; public WikiImage(String imageName, String imageStubUrl, - String imageHiResUrl, String datatype) { + String imageHiResUrl) { this.imageName = imageName; this.imageStubUrl = imageStubUrl; this.imageHiResUrl = imageHiResUrl; - this.datatype = datatype; } public String getImageName() { @@ -27,7 +25,4 @@ public class WikiImage { return imageHiResUrl; } - public String getDatatype() { - return datatype; - } } diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageCard.java b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageCard.java index db4ccef2ea..e423e3daa5 100644 --- a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageCard.java +++ b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageCard.java @@ -7,19 +7,18 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.util.Algorithms; -import org.json.JSONObject; - public class WikiImageCard extends ImageCard { - public WikiImageCard(final MapActivity mapActivity, final JSONObject imageObject, + public WikiImageCard(final MapActivity mapActivity, final WikiImage wikiImage) { - super(mapActivity, imageObject); + super(mapActivity, null); if (topIconId == 0) { topIconId = R.drawable.ic_logo_wikimedia; } this.imageUrl = wikiImage.getImageStubUrl(); + this.title = wikiImage.getImageName(); this.url = this.imageUrl; View.OnClickListener onClickListener = new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java index 59a53ba54e..eded246941 100644 --- a/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikimedia/WikiImageHelper.java @@ -41,7 +41,7 @@ public class WikiImageHelper { Gson gson = new Gson(); WikipediaResponse response = gson.fromJson(rawResponse.toString(), WikipediaResponse.class); for (WikiImage img : getImageData(response)) { - images.add(new WikiImageCard(mapActivity, null, img)); + images.add(new WikiImageCard(mapActivity, img)); } return; } catch (JsonSyntaxException e) { @@ -54,7 +54,7 @@ public class WikiImageHelper { } } - public static List getImageData(WikipediaResponse response) { + private static List getImageData(WikipediaResponse response) { List images = new ArrayList<>(); for (P18 p18 : response.claims.p18) { String imageFileName = p18.mainsnak.datavalue.value; @@ -72,8 +72,7 @@ public class WikiImageHelper { urlHashParts[0] + "/" + urlHashParts[1] + "/" + imageFileName + "/" + THUMB_SIZE + "px-" + imageFileName; - images.add(new WikiImage(imageName, imageStubUrl, - imageHiResUrl, p18.mainsnak.datatype)); + images.add(new WikiImage(imageName, imageStubUrl, imageHiResUrl)); } catch (UnsupportedEncodingException e) { LOG.error(e.getLocalizedMessage()); @@ -84,18 +83,18 @@ public class WikiImageHelper { } @NonNull - public static String[] getHash(@NonNull String s) { + private static String[] getHash(@NonNull String s) { String md5 = new String(Hex.encodeHex(DigestUtils.md5(s))); return new String[]{md5.substring(0, 1), md5.substring(0, 2)}; } - private class Claims { + private static class Claims { @SerializedName("P18") @Expose private List p18 = null; } - public class Datavalue { + private static class Datavalue { @SerializedName("value") @Expose private String value; @@ -104,16 +103,7 @@ public class WikiImageHelper { private String type; } - public class Mainsnak { - @SerializedName("snaktype") - @Expose - private String snaktype; - @SerializedName("property") - @Expose - private String property; - @SerializedName("hash") - @Expose - private String hash; + private static class Mainsnak { @SerializedName("datavalue") @Expose private Datavalue datavalue; @@ -122,22 +112,13 @@ public class WikiImageHelper { private String datatype; } - public class P18 { + private static class P18 { @SerializedName("mainsnak") @Expose private Mainsnak mainsnak; - @SerializedName("type") - @Expose - private String type; - @SerializedName("id") - @Expose - private String id; - @SerializedName("rank") - @Expose - private String rank; } - public class WikipediaResponse { + private static class WikipediaResponse { @SerializedName("claims") @Expose private Claims claims; From 0f1d23ddfed5098c0f27bc03caeda3d4b34753e6 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 8 Jul 2020 16:17:41 +0300 Subject: [PATCH 021/551] Fix #9319 Move a favourite to hidden category, fix #9060 changing color group of favourite, --- .../net/osmand/plus/FavouritesDbHelper.java | 16 +++++++-- .../FavoritePointEditorFragmentNew.java | 33 +++++++++++-------- .../editors/PointEditorFragmentNew.java | 28 +++++++++++++--- .../editors/WptPtEditorFragmentNew.java | 2 ++ 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index f6bb1866e7..4b9dc43eb3 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -679,6 +679,16 @@ public class FavouritesDbHelper { return favoriteGroups; } + public boolean isGroupVisible(String name) { + String nameLowercase = name.toLowerCase(); + for (String groupName : flatGroups.keySet()) { + if (groupName.toLowerCase().equals(nameLowercase) || FavoriteGroup.getDisplayName(context, groupName).equals(name)) { + return flatGroups.get(groupName).isVisible(); + } + } + return false; + } + public boolean groupExists(String name) { String nameLowercase = name.toLowerCase(); for (String groupName : flatGroups.keySet()) { @@ -800,10 +810,12 @@ public class FavouritesDbHelper { public void editFavouriteGroup(FavoriteGroup group, String newName, int color, boolean visible) { if (color != 0 && group.color != color) { FavoriteGroup gr = flatGroups.get(group.name); - group.color = color; for (FavouritePoint p : gr.points) { - p.setColor(color); + if (p.getColor() == group.color) { + p.setColor(color); + } } + group.color = color; runSyncWithMarkers(gr); } if (group.visible != visible) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java index 2362252307..b3159922cf 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java @@ -97,7 +97,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { } }); if (editor != null && editor.isNew()) { - ImageView toolbarAction = (ImageView) view.findViewById(R.id.toolbar_action); + ImageView toolbarAction = view.findViewById(R.id.toolbar_action); toolbarAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -460,30 +460,36 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { @Override public Set getCategories() { Set categories = new LinkedHashSet<>(); + Set categoriesHidden = new LinkedHashSet<>(); FavouritesDbHelper helper = getHelper(); if (helper != null && editor != null) { OsmandApplication app = getMyApplication(); - if (editor.isNew()) { - FavoriteGroup lastUsedGroup = helper.getGroup(getLastUsedGroup()); - if (lastUsedGroup != null && lastUsedGroup.isVisible()) { - categories.add(lastUsedGroup.getDisplayName(app)); - } - for (FavouritesDbHelper.FavoriteGroup fg : getHelper().getFavoriteGroups()) { - if (!fg.equals(lastUsedGroup) && fg.isVisible()) { - categories.add(fg.getDisplayName(app)); - } - } - } else { - for (FavoriteGroup fg : helper.getFavoriteGroups()) { + FavoriteGroup lastUsedGroup = helper.getGroup(getLastUsedGroup()); + if (lastUsedGroup != null) { + categories.add(lastUsedGroup.getDisplayName(app)); + } + for (FavouritesDbHelper.FavoriteGroup fg : helper.getFavoriteGroups()) { + if (!fg.equals(lastUsedGroup)) { if (fg.isVisible()) { categories.add(fg.getDisplayName(app)); + } else { + categoriesHidden.add(fg.getDisplayName(app)); } } } + categories.addAll(categoriesHidden); } return categories; } + @Override + public boolean isCategoryVisible(String name) { + if (getHelper() != null) { + return getHelper().isGroupVisible(name); + } + return true; + } + @Override public int getCategoryPointsCount(String category) { FavouritesDbHelper helper = getHelper(); @@ -498,6 +504,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { } @Override + @ColorInt public int getCategoryColor(String category) { FavouritesDbHelper helper = getHelper(); if (helper != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 70697426ed..68ada0922b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -5,6 +5,7 @@ import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.graphics.Rect; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.os.Build; @@ -675,6 +676,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { public void setCategory(String name, int color) { setSelectedItemWithScroll(name); + updateColorSelector(color, groupRecyclerView.getRootView()); } private void setSelectedItemWithScroll(String name) { @@ -732,6 +734,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { public abstract String getToolbarTitle(); + @ColorInt public abstract int getCategoryColor(String category); public abstract int getCategoryPointsCount(String category); @@ -762,6 +765,12 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { public abstract Set getCategories(); + protected boolean isCategoryVisible(String name) { + return true; + } + + ; + String getNameTextValue() { EditText nameEdit = view.findViewById(R.id.name_edit); return nameEdit.getText().toString().trim(); @@ -885,16 +894,13 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { public void onClick(View view) { int previousSelectedPosition = getItemPosition(selectedItemName); selectedItemName = items.get(holder.getAdapterPosition()); + updateColorSelector(getCategoryColor(selectedItemName), groupRecyclerView.getRootView()); notifyItemChanged(holder.getAdapterPosition()); notifyItemChanged(previousSelectedPosition); } }); final String group = items.get(position); holder.groupName.setText(group); - int categoryColor = getCategoryColor(group); - int color = categoryColor == 0 ? getDefaultColor() : categoryColor; - holder.groupIcon.setImageDrawable(UiUtilities.tintDrawable( - AppCompatResources.getDrawable(app, R.drawable.ic_action_folder), color)); holder.pointsCounter.setText(String.valueOf(getCategoryPointsCount(group))); int strokeColor; int strokeWidth; @@ -913,6 +919,20 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, strokeWidth), strokeColor); holder.groupButton.setImageDrawable(rectContourDrawable); } + int color; + int iconID; + if (!isCategoryVisible(group)) { + color = ContextCompat.getColor(app, R.color.text_color_secondary_light); + iconID = R.drawable.ic_action_hide; + holder.groupName.setTypeface(null, Typeface.ITALIC); + } else { + int categoryColor = getCategoryColor(group); + color = categoryColor == 0 ? getDefaultColor() : categoryColor; + iconID = R.drawable.ic_action_folder; + holder.groupName.setTypeface(null, Typeface.NORMAL); + } + holder.groupIcon.setImageDrawable(UiUtilities.tintDrawable( + AppCompatResources.getDrawable(app, iconID), color)); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AndroidUtils.setBackground(app, holder.groupButton, nightMode, R.drawable.ripple_solid_light_6dp, diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index e74539a06a..94ecff5478 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -8,6 +8,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.view.View; +import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; @@ -454,6 +455,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { } @Override + @ColorInt public int getCategoryColor(String category) { if (categoriesMap != null) { Integer color = categoriesMap.get(category); From de95a3e353d6d0575cb23b114d3205bf377d0b67 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 8 Jul 2020 17:28:47 +0300 Subject: [PATCH 022/551] Updated icon for motorcycle, added new icons for enduro motorcycle and motor scooter --- .../drawable/ic_action_enduro_motorcycle.xml | 10 +++++++++ .../res/drawable/ic_action_motor_scooter.xml | 21 +++++++++++++++++++ .../drawable/ic_action_motorcycle_dark.xml | 4 ++-- OsmAnd/res/values/strings.xml | 2 ++ .../osmand/plus/profiles/ProfileIcons.java | 2 ++ 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 OsmAnd/res/drawable/ic_action_enduro_motorcycle.xml create mode 100644 OsmAnd/res/drawable/ic_action_motor_scooter.xml diff --git a/OsmAnd/res/drawable/ic_action_enduro_motorcycle.xml b/OsmAnd/res/drawable/ic_action_enduro_motorcycle.xml new file mode 100644 index 0000000000..ce8f40ad06 --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_enduro_motorcycle.xml @@ -0,0 +1,10 @@ + + + diff --git a/OsmAnd/res/drawable/ic_action_motor_scooter.xml b/OsmAnd/res/drawable/ic_action_motor_scooter.xml new file mode 100644 index 0000000000..a8a0cf4551 --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_motor_scooter.xml @@ -0,0 +1,21 @@ + + + + + diff --git a/OsmAnd/res/drawable/ic_action_motorcycle_dark.xml b/OsmAnd/res/drawable/ic_action_motorcycle_dark.xml index 2bf23aff89..a89713cff8 100644 --- a/OsmAnd/res/drawable/ic_action_motorcycle_dark.xml +++ b/OsmAnd/res/drawable/ic_action_motorcycle_dark.xml @@ -4,7 +4,7 @@ android:viewportWidth="24" android:viewportHeight="24"> diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 64f9e464bd..35de06c09b 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,8 @@ Thx - Hardy --> + Motor scooter + Enduro motorcycle Get information about points of interest from Wikipedia. It is your pocket offline guide - just enable Wikipedia plugin and enjoy articles about objects around you. Download Wikipedia maps The current destination point on the route will be deleted. If it will be the Destination, navigation will stop. diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileIcons.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileIcons.java index 9bc0bb2441..b7beb6d124 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfileIcons.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileIcons.java @@ -17,6 +17,8 @@ public enum ProfileIcons { BUS(R.drawable.ic_action_bus_dark, R.string.app_mode_bus, "ic_action_bus_dark"), SUBWAY(R.drawable.ic_action_subway, R.string.app_mode_subway, "ic_action_subway"), MOTORCYCLE(R.drawable.ic_action_motorcycle_dark, R.string.app_mode_motorcycle, "ic_action_motorcycle_dark"), + ENDURO_MOTORCYCLE(R.drawable.ic_action_enduro_motorcycle, R.string.app_mode_enduro_motorcycle, "ic_action_enduro_motorcycle"), + MOTOR_SCOOTER(R.drawable.ic_action_motor_scooter, R.string.app_mode_motor_scooter, "ic_action_motor_scooter"), BICYCLE(R.drawable.ic_action_bicycle_dark, R.string.app_mode_bicycle, "ic_action_bicycle_dark"), HORSE(R.drawable.ic_action_horse, R.string.app_mode_horse, "ic_action_horse"), PEDESTRIAN(R.drawable.ic_action_pedestrian_dark, R.string.app_mode_pedestrian, "ic_action_pedestrian_dark"), From d2d903762b0a4be29cd4e70f7cd3ad07aec17f95 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 8 Jul 2020 18:10:50 +0300 Subject: [PATCH 023/551] Fix #9192 UI Canadian road signs --- OsmAnd/res/values-large/sizes.xml | 4 ++-- OsmAnd/res/values/sizes.xml | 4 ++-- .../plus/views/mapwidgets/RouteInfoWidgetsFactory.java | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index d30012865a..b8c65c032e 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -22,12 +22,12 @@ 120dp 6dp 84dp - 116dp + 138dp 12dp 35sp 30dp 22sp - 12sp + 18sp 131dp 81dp diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index d3eb9bf16d..ebefb8942f 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -114,7 +114,7 @@ 120dp 9dp - 78dp + 92dp 8dp @@ -148,7 +148,7 @@ 25sp 20dp 16sp - 8sp + 12sp 1sp 3sp 2dp diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index 7ee0d1c4c6..06e5838c73 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -1252,6 +1252,7 @@ public class RouteInfoWidgetsFactory { private int imgId; private String cachedText; private String cachedBottomText; + private OsmandSettings.DrivingRegion cachedRegion; public AlarmWidget(final OsmandApplication app, MapActivity ma) { layout = ma.findViewById(R.id.map_alarm_warning); @@ -1366,7 +1367,7 @@ public class RouteInfoWidgetsFactory { icon.setImageResource(locimgId); } Resources res = layout.getContext().getResources(); - if (!Algorithms.objectEquals(text, cachedText)) { + if (!Algorithms.objectEquals(text, cachedText) || cachedRegion != region) { cachedText = text; widgetText.setText(cachedText); if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && americanType && !isCanadianRegion) { @@ -1376,9 +1377,10 @@ public class RouteInfoWidgetsFactory { widgetText.setPadding(0, 0, 0, 0); } } - if (!Algorithms.objectEquals(bottomText, cachedBottomText)) { + if (!Algorithms.objectEquals(bottomText, cachedBottomText) || cachedRegion != region) { cachedBottomText = bottomText; widgetBottomText.setText(cachedBottomText); + cachedRegion = region; if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && isCanadianRegion) { int bottomPadding = res.getDimensionPixelSize(R.dimen.map_button_margin); widgetBottomText.setPadding(0, 0, 0, bottomPadding); From 050e77a81eb46e9c5fbde0fe84e5b13dd76d7c7b Mon Sep 17 00:00:00 2001 From: Tymofij Lytvynenko Date: Wed, 8 Jul 2020 12:38:53 +0000 Subject: [PATCH 024/551] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3415 of 3415 strings) --- OsmAnd/res/values-uk/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 8a5184b325..e5f9a46df6 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -3804,4 +3804,10 @@ Роликові ковзани Увімкнути для зміни масштабу мапи кнопками гучності пристрою. Масштабування кнопками гучності + Вкажіть довжину вашого автомобіля, для довгих транспортних засобів можуть застосовуватися деякі обмеження на маршрутах. + Видалити наступну точку призначення + Укажіть назву пункту + Поточна точка призначення на маршруті буде видалена. Якщо це буде Місце призначення, навігація припиниться. + Завантажити мапи Вікіпедії + Отримайте відомості про визначні місця у Вікіпедії. Це ваш кишеньковий посібник без мережі - просто ввімкніть втулок \"Вікіпедія\" і насолоджуйтесь статтями про об\'єкти навколо вас. \ No newline at end of file From 49ef3f920f104fe62069163c9db3042e8b220c74 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 7 Jul 2020 18:42:37 +0000 Subject: [PATCH 025/551] Translated using Weblate (Russian) Currently translated at 99.8% (3411 of 3415 strings) --- OsmAnd/res/values-ru/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index cb563bcdd3..59c18bc0be 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -3252,7 +3252,7 @@ Карта во время навигации Карта во время навигации Вес, высота, длина, скорость - Параметры транспортного средства + Параметры автомобиля Голосовые оповещения происходят только во время навигации. Навигационные инструкции и объявления Голосовые подсказки @@ -3369,7 +3369,7 @@ Выберите цвет Вы не можете удалить стандартные профили OsmAnd, но вы можете отключить их на предыдущем экране или переместить вниз. Редактировать профили - Тип навигации влияет на правила расчёта маршрута. + «Тип навигации» определяет способ расчета маршрутов. Внешний вид профиля Значок, цвет и имя Редактировать список профилей From 3e4cb0910f2f8ddda8dbe2cc9e7ab07cedf24a70 Mon Sep 17 00:00:00 2001 From: Deelite <556xxy@gmail.com> Date: Tue, 7 Jul 2020 10:19:23 +0000 Subject: [PATCH 026/551] Translated using Weblate (Russian) Currently translated at 99.8% (3411 of 3415 strings) --- OsmAnd/res/values-ru/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 59c18bc0be..c7ff9b3162 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -548,7 +548,7 @@ Минимальный масштаб векторных карт Не удалось выполнить локальный поиск. Поиск по географическому положению - Системная + Системный Язык интерфейса приложения (будет использован после перезапуска OsmAnd). Язык интерфейса Далее @@ -1200,7 +1200,7 @@ Выберите цветовую схему дорог: Цветовая схема дорог Ш %1$.3f Д %2$.3f - незавершённое + неполный Ограничение скорости GPX Прочие карты @@ -1386,7 +1386,7 @@ \n Примечание 2: в новом хранилище совместное использование файлов OsmAnd и OsmAnd+ невозможно. Копирование файла (%s) на новое место… Копирование файлов данных OsmAnd на новое место (%s)… - Выключение 2-фазной маршрутизации для автомобильной навигации. + Выключение двухфазной маршрутизации для автомобильной навигации. Быстрое построение маршрута не удалось (%s), отмените для возврата к медленному построению. Масштаб Выберите GPX… @@ -1624,7 +1624,7 @@ Нежелательные участки %1$s необходимо это разрешение, чтобы выключить экран для экономии энергии. Автовключение экрана перед поворотом - Включать экран устройства (если он выключен) при приближении к повороту. + Включать экран перед поворотом (если выключен). Карты доступные для обновления: %1$s Координаты Дом @@ -1833,7 +1833,7 @@ Умный перерасчёт маршрута Перерасчёт только начальной части маршрута для длительных поездок. Удалить правки OSM - Выключен + Выключено Раскраска по сетевой принадлежности Раскраска туристических меток по OSMC Выход @@ -1998,7 +1998,7 @@ Поделиться местоположением Отправить Выберите, где вы хотите хранить файлы карт и другие данные. - «Выключено» запускает карту непосредственно. + При выключении сразу открывается карта. Карта загружена QR код Показать карту @@ -3245,7 +3245,7 @@ Внешний вид Настроить навигацию Предупреждения отображаются в левом нижнем углу во время навигации. - Влияет для всего приложения + Общие настройки приложения Настройки OsmAnd Копировать из другого профиля Включить экран From 4250dc69a6e69f690e147fc48a697bf2deff6e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Tue, 7 Jul 2020 10:07:25 +0000 Subject: [PATCH 027/551] Translated using Weblate (Turkish) Currently translated at 100.0% (3415 of 3415 strings) --- OsmAnd/res/values-tr/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 50457451cb..61d155b793 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -975,7 +975,7 @@ (%s) dosyası yeni hedefine kopyalanıyor… OsmAnd veri dosyaları yeni hedef (%s) \'e kopyalanıyor… Navigasyon tercihleri - Güzergah seçenekleri + Yönlendirme tercihleri Metinden konuşmaya konuşma hızını belirtin. Hoparlör yerleşimi Hızlı rota hesaplama ( $1%s) başarısız oldu , hesaplama yavaş çare . @@ -3371,7 +3371,7 @@ Renk seç OsmAnd öntanımlı profilleri silinemez, ancak (önceki ekranda) devre dışı bırakılabilir veya en altta sıralanabilir. Profilleri düzenle - \'Navigasyon türü\' rotaların nasıl hesaplandığını yönetir. + \'Navigasyon türü\' güzergahın nasıl hesaplandığını yönetir. Profil görünümü Simge, renk ve isim Profil listesini düzenle From 23a2140c78a98fbbac81598158f61a84007d9df6 Mon Sep 17 00:00:00 2001 From: ihor_ck Date: Wed, 8 Jul 2020 18:57:43 +0000 Subject: [PATCH 028/551] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3415 of 3415 strings) --- OsmAnd/res/values-uk/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index e5f9a46df6..e534957f01 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -3807,7 +3807,7 @@ Вкажіть довжину вашого автомобіля, для довгих транспортних засобів можуть застосовуватися деякі обмеження на маршрутах. Видалити наступну точку призначення Укажіть назву пункту - Поточна точка призначення на маршруті буде видалена. Якщо це буде Місце призначення, навігація припиниться. + Поточну точку призначення на маршруті буде видалено. Якщо це буде місце призначення, навігація припиниться. Завантажити мапи Вікіпедії Отримайте відомості про визначні місця у Вікіпедії. Це ваш кишеньковий посібник без мережі - просто ввімкніть втулок \"Вікіпедія\" і насолоджуйтесь статтями про об\'єкти навколо вас. \ No newline at end of file From 0c4dfdb300893a2df8dc51494fbe0172540b3b45 Mon Sep 17 00:00:00 2001 From: D M Date: Tue, 7 Jul 2020 23:34:29 +0000 Subject: [PATCH 029/551] Translated using Weblate (Serbian) Currently translated at 76.6% (2923 of 3812 strings) --- OsmAnd/res/values-sr/phrases.xml | 118 +++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/OsmAnd/res/values-sr/phrases.xml b/OsmAnd/res/values-sr/phrases.xml index 94e738e86b..b220869840 100644 --- a/OsmAnd/res/values-sr/phrases.xml +++ b/OsmAnd/res/values-sr/phrases.xml @@ -2815,4 +2815,122 @@ Мофа приступ Приступ мотоциклима Стена пењања + Саветовање (брачно): не + Саветовање (брачно): да + Саветовање (имигрант): не + Саветовање (имигрант): да + Саветовање (бескућно): не + Саветовање (бескућно): да + Саветовање (породично): не + Саветовање (породично): да + Саветовање (образовање): не + Саветовање (образовање): да + Саветовање (око дрога): не + Саветовање (око дрога): да + Саветовање (кризно): не + Саветовање (кризно): да + Саветовање (за парове): не + Саветовање (за парове): да + Саветовање (смернице за дете): не + Саветовање (смернице за дете): да + Саветовање (пренатално): не + Саветовање (пренатално): да + Саветовање (зависност): не + Саветовање (зависност): да + Улога здравственог радника: вештак + Улога здравственог радника: техничар + Улога здравственог радника: помоћник лекара + Улога здравственог радника: терапеут + Улога здравственог радника: психолог + Улога здравственог радника: подолог + Улога здравственог радника: лекар + Улога здравственог радника: болничар + Улога здравственог радника: медицинска сестра + Улога здравственог радника: бабица + Улога здравственог радника: исцелитељ + Улога здравственог радника: асистент + Зид + Понд + Суво буре + Стуб + Подземни + Тачка усисавања + Тип здравствене установе: дом групе за подршку + Тип здравствене установе: старачки дом + Тип здравствене установе: прва помоћ + Тип здравствене установе: амбуланта + Тип здравствене установе: одељење + Тип здравствене установе: терапија + Тип здравствене установе: лабораторија + Тип здравствене установе: саветовалиште + Тип здравствене установе: теренска болница + Медицинска канцеларија + Здравствена услуга: тест: не + Здравствена служба: тест: да + Здравствена служба: подршка: не + Здравствена служба: подршка: да + Здравствена служба: вакцинација: не + Здравствена служба: вакцинација: да + Здравствена служба: превенција: не + Здравствена служба: превенција: да + Здравствена услуга: дечје одељење: не + Здравствена услуга: дечје одељење: да + Здравствена служба: преглед: не + Здравствена служба: преглед: да + Здравствена служба: саветовање: не + Здравствена служба: саветовање: да + Здравствена служба: породилиште: не + Здравствена служба: породилиште: да + Унани + Сида + Традиционално Тибетански + Традиционално монголски + Кампо + Ајурведа + Традиционално Кинески + Западни + Санитарна отпадна станица + Соларијум + Смернице за госте: не + Смернице за госте: да + Оријентација места слободног летења: З + Оријентација места слободног летења: ЈЗ + Нема време лета (слободно летење) + Оријентација места слободног летења: СЗ + Оријентација места слободног летења: Ј + Оријентација места слободног летења: ЈИ + Оријентација места слободног летења: И + Оријентација места слободног летења: СИ + Оријентација места слободног летења: С + Слободно летење круто: не + Крута + Змајарство: не + Змајарство + Параглајдинг: не + Параглајдинг + Званично: не + Званично: да + Обука + Вуча + Слетање на врху + Слетање + Полетање + Управљано дугметом: не + Управљано дугметом: да + Славина за воду + Слободно летење (спорт) + Усисивач + Усисавач: не + Да + Компримовани ваздух: не + Да + Расадник биљака + Име куће + Експлозија: уређај + Експлозија: бојева глава + Експлозија: пречник кратера + Плотун експлозија: друга или каснија детонација плотун теста + Плотун експлозија: прва детонација плотун теста + Куглање + Мрежа \ No newline at end of file From 16a25290162d63ab6398348dc15af26c7aabdfa1 Mon Sep 17 00:00:00 2001 From: Kars de Jong Date: Tue, 7 Jul 2020 17:39:08 +0000 Subject: [PATCH 030/551] Translated using Weblate (Dutch) Currently translated at 96.6% (3299 of 3415 strings) --- OsmAnd/res/values-nl/strings.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 46c160660b..4661668ee8 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -2556,7 +2556,7 @@ Weg Een tik op de kaart verbergt/toont de bedieningsknoppen en widgets. Volledig scherm - Markering overslaan + Markering gepasseerd kan worden geïmporteerd als Favorieten of als GPX-bestand. importeer als GPX-bestand Importeren als Favorieten @@ -3702,4 +3702,10 @@ Time-out van het scherm Inschakelen om het zoomniveau van de kaart in te stellen met de volumeknoppen. Gebruik volumeknoppen om in en uit te zoomen + Verkrijg informatie over POIs uit Wikipedia. Het is je offline reisgidsje - schakel de Wikipedia-plug-in in en geniet van artikelen over de bezienswaardigheden in je omgeving. + Geef de voertuiglengte op, er zijn mogelijk routebeperkingen voor lange voertuigen. + Het volgende routepunt wordt verwijderd. Als dit de eindbestemming was, stopt de navigatie. + Verwijder het volgende routepunt + Kies een naam voor het punt + Wikipedia-kaarten downloaden \ No newline at end of file From 954a876287572d30f61c05ad3490af697297bff7 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 7 Jul 2020 18:39:58 +0000 Subject: [PATCH 031/551] Translated using Weblate (Russian) Currently translated at 100.0% (3812 of 3812 strings) --- OsmAnd/res/values-ru/phrases.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index c685fd9c49..c85fd1297b 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -3817,4 +3817,7 @@ Вибрация: нет Стрелка Вибрация + Городской квартал + Муниципалитет + Подарочная коробка \ No newline at end of file From 3b75e8c337565ba00ebaab07957ce8a3c1beb49d Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Wed, 8 Jul 2020 20:17:22 +0000 Subject: [PATCH 032/551] Translated using Weblate (French) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-fr/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index ca570fd8e3..f264af132d 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3797,4 +3797,6 @@ Merci de renseigner un nom pour le point Utilisez un guide de poche hors ligne grâce à Wikipédia. Activez le plugin Wikipédia : des points d\'intérêt seront affichés, ils vous permettrons d\'obtenir des informations sur les lieux qui vous entourent. Télécharger les cartes Wikipédia + Scooter + Moto enduro \ No newline at end of file From 0977517bdb2c7011bf3d64014071b02b97172fc5 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Jul 2020 06:41:52 +0000 Subject: [PATCH 033/551] Translated using Weblate (German) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-de/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 752c1b528a..acb3358a91 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3822,4 +3822,6 @@ Der aktuelle Punkt auf der Route wird gelöscht. Wenn es das Ziel ist, wird die Navigation gestoppt. Wikipedia-Karten herunterladen Informationen über Sehenswürdigkeiten erhalten Sie bei Wikipedia. Es ist Ihr Offline-Wegweiser für die Hosentasche - aktivieren Sie einfach das Wikipedia-Modul und genießen Sie Artikel über Objekte in Ihrer Umgebung. + Enduro + Motorroller \ No newline at end of file From 1181aaa56dfe69b1c6182c0712e76813c63981c8 Mon Sep 17 00:00:00 2001 From: Deelite <556xxy@gmail.com> Date: Wed, 8 Jul 2020 21:42:42 +0000 Subject: [PATCH 034/551] Translated using Weblate (Russian) Currently translated at 99.9% (3415 of 3417 strings) --- OsmAnd/res/values-ru/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index c7ff9b3162..7c0a021979 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1120,7 +1120,7 @@ Стиль карты Эл. почта Восход/закат - Мобильный просмотр и навигация по онлайн и локальным картам OSM всего мира + Мобильные карты и навигация по всему миру для локальных и онлайн-карт OSM OsmAnd (Open Street Maps Automated Navigation Directions) \n \n OsmAnd — это навигационное приложение с открытым исходным кодом и доступом к картам и данным на основе OSM. Все данные карт (векторные или растровые) могут быть сохранены на карту памяти устройства для использования без подключения к интернету. OsmAnd также предоставляет локальные и онлайн-средства построения маршрута, включая голосовые инструкции по маршруту. @@ -2414,7 +2414,7 @@ Маркер перемещён в действующие Указатель расстояния Показать карту - Для использования этой функции вы должны добавить хотя бы один маркер. + Для использования этой функции нужно добавить хотя бы один маркер. Не удалось изменить заметку. Дорога Показывать направляющие линии From aea59e54e64d5aab4dfb70529b1358a5c2760de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Wed, 8 Jul 2020 20:13:41 +0000 Subject: [PATCH 035/551] Translated using Weblate (Turkish) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-tr/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 61d155b793..6ae6c3f291 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -2582,7 +2582,7 @@ Yeni profil Çökme Kişisel taşıyıcı - Scooter + Mobilet Gün Günler Günler @@ -3770,4 +3770,6 @@ Yakınlaştırma için ses seviyesi düğmeleri Wikipedia haritalarını indir Wikipedia\'dan ilgi çekici yerler hakkında bilgi alın. Bu sizin çevrim dışı cep rehberinizdir - sadece Wikipedia eklentisini etkinleştirin ve etrafınızdaki nesneler hakkında makalelerin tadını çıkarın. + Enduro motosiklet + Küçük motosiklet \ No newline at end of file From 4f287720981472a2e7153abc1bf48f22d74ece28 Mon Sep 17 00:00:00 2001 From: Branko Kokanovic Date: Wed, 8 Jul 2020 21:10:56 +0000 Subject: [PATCH 036/551] Translated using Weblate (Serbian) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-sr/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-sr/strings.xml b/OsmAnd/res/values-sr/strings.xml index 5b6be8d957..5d5e145f14 100644 --- a/OsmAnd/res/values-sr/strings.xml +++ b/OsmAnd/res/values-sr/strings.xml @@ -3812,4 +3812,6 @@ Тренутна одредишна тачка биће уклоњена. Ако је она одредишна, стопираће се навигација. Преузмите мапе Википедије Информације о тачкама од интереса потражите од Википедије. То је ваш џепни ванмрежни водич - само омогућите додатак Википедиа и уживајте у чланцима о објектима око вас. + Ендуро скутер + Скутер \ No newline at end of file From 979cc9c74654cf0cd32b066434c947ba69068262 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Thu, 9 Jul 2020 09:09:07 +0000 Subject: [PATCH 037/551] Translated using Weblate (Hebrew) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-he/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-he/strings.xml b/OsmAnd/res/values-he/strings.xml index 6a93ee035a..d8b81e15d3 100644 --- a/OsmAnd/res/values-he/strings.xml +++ b/OsmAnd/res/values-he/strings.xml @@ -3823,4 +3823,6 @@ נקודת היעד הנוכחית במסלול תימחק. אם זה יהיה היעד, הניווט ייעצר. הורדת מפות ויקיפדיה קבלת מידע על נקודות עניין מוויקיפדיה. מדריך הכיס הפרטי שלך - עליך פשוט להפעיל את התוסף של ויקיפדיה וליהנות מערכים על מה שסביבך. + אופנוע שטח + טוסטוס \ No newline at end of file From 7dc761dbdfe58a8032358f324878758ade967e32 Mon Sep 17 00:00:00 2001 From: Piotr Kubowicz Date: Wed, 8 Jul 2020 19:46:48 +0000 Subject: [PATCH 038/551] Translated using Weblate (Polish) Currently translated at 98.7% (3375 of 3417 strings) --- OsmAnd/res/values-pl/strings.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml index c5167021fe..21e9dc02f5 100644 --- a/OsmAnd/res/values-pl/strings.xml +++ b/OsmAnd/res/values-pl/strings.xml @@ -3251,7 +3251,7 @@ Wybiera styl aplikacji, jednostki, region Ustawienia OsmAnd Skopiuj z innego profilu - Ciężar, wysokość, prędkość + Waga, wysokość, długość, prędkość Parametry pojazdu Komunikaty głosowe są odtwarzane tylko podczas nawigacji. Komunikaty głosowe @@ -3463,12 +3463,12 @@ Efekt uboczny: trasa nie będzie zawierała sekcji, w których nie zostało spełnione kryterium minimalnej prędkości (np. podczas pchania roweru pod strome wzgórze). Nie będzie również zawierała informacji o czasach odpoczynku, np. przerwach. Ma to wpływ na analizę i przetwarzanie końcowe, np. przy próbie określenia całkowitej długości trasy, czasu w ruchu lub średniej prędkości. Zmień układ kategorii Zmień kolejność sortowania listy, ukryj niepotrzebne kategorie. Wszystkie zmiany można importować lub eksportować za pomocą profili. - Można dodać nową, niestandardową kategorię wybierając jedną lub kilka potrzebnych kategorii. + Można dodać nową, niestandardową kategorię wybierając jedną lub kilka kategorii. Dostępne Dodaj niestandardową kategorię Wyświetlaj tylko w nocy - Ustawienia wtyczek przywrócone do stanu domyślnego. - Ustawienia profili przywrócone do stanu domyślnego. + Ustawienia wtyczek przywrócone do domyślnych. + Ustawienia profili przywrócone do domyślnych. %1$s/%2$s Zachód słońca o %1$s Wschód słońca o %1$s @@ -3480,7 +3480,7 @@ Użyj aplikacji systemowej Dźwięk migawki aparatu Przywrócenie domyślnej kolejności sortowania spowoduje przywrócenie porządku sortowania do stanu domyślnego po instalacji. - Tryb ułatwień dostępu wyłączony w twoim systemie. + Tryb ułatwień jest dostępu wyłączony w twoim systemie. Wygaś ekran zgodnie z ustawieniami systemu Wyczyść zarejestrowane dane - Profile: teraz można zmienić kolejność, ustawić ikonę dla mapy, zmienić wszystkie ustawienia dla profili bazowych i przywrócić je do domyślnych ustawień. @@ -3523,7 +3523,7 @@ Pokaż powiadomienia systemowe podczas nawigacji z instrukcjami nawigacji. Powiadomienie nawigacyjne Domyślnie (%s) - Wyłączenie ponownego obliczania + Bez ponownego obliczania Minimalna odległość do ponownego wyznaczenia trasy Wyznacza ponownie trasę, jeśli odległość do trasy jest dłuższa niż określony parametr Twoje nagrane ślady są w %1$s lub w folderze OsmAnd. @@ -3588,7 +3588,7 @@ Przycisk do wyświetlania lub ukrywania warstwy terenu na mapie. Pokaż teren Ukryj teren - Pokaż/ukryj teren + Pokaż / ukryj teren Nachylenie Włącz, aby wyświetlić cieniowanie wzniesień lub stoków. Możesz przeczytać więcej o tego rodzaju mapach na naszej stronie. Legenda @@ -3630,7 +3630,7 @@ Ukryte Te elementy są ukryte w menu, jednak reprezentowane opcje i wtyczki będą wciąż działać. Ukrycie ustawień resetuje je do pierwotnego stanu. - \"Główne czynności\" zawierają tylko 4 przyciski. + Mieści tylko 4 przyciski. Główne działania Możesz przemieszczać elementy tylko wewnątrz tej kategorii. Wtyczka deweloperska @@ -3719,7 +3719,7 @@ Ukryj transport publiczny Pokaż transport publiczny Pokaż/ukryj transport publiczny - Utwórz / Edytuj POI + Utwórz / Edytuj użyteczne miejsce Dodaj / Edytuj Ulubione Naciśnięcie przycisku akcji powoduje przełączanie między wybranymi profilami. Dodaj profil From e84be04dfa130f60216f7888dd6777ff0fe96718 Mon Sep 17 00:00:00 2001 From: Ahmad Alfrhood Date: Thu, 9 Jul 2020 01:23:00 +0000 Subject: [PATCH 039/551] Translated using Weblate (Arabic) Currently translated at 99.9% (3416 of 3417 strings) --- OsmAnd/res/values-ar/strings.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index 93c9629d1c..2cf4d277fa 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -3170,7 +3170,7 @@ خريطة أثناء التنقل أخرى الوزن ، الارتفاع ، السرعة - معلمات السيارة + معلمات المركبات الإعلامات الصوتية تحدث فقط أثناء التنقل. إرشادات التنقل والإعلامات المطالبات الصوتية @@ -3212,7 +3212,7 @@ السرعة الافتراضية تغيير إعدادات السرعة الافتراضية تعيين حد السرعة الأدنى/الأعلى - وضع جديد + ملف تعريف جديد خروج مفاجئ فشل العملية الأخيرة لأوسماند. الرجاء مساعدتنا في التحسين من خلال مشاركة رسالة الخطأ. • أوضاع التطبيق: قم بإنشاء وضع مخصص لاحتياجاتك الخاصة ، باستخدام رمز ولون مخصصين @@ -3398,7 +3398,7 @@ حدد أيقونه الخريطة بعد النقر فوق \"تطبيق\" ، سيتم فقد الأوضاع المحذوفة بالكامل. الوضع الرئيسي - اختر اللون + لا يمكنك حذف أوضاع أوسماند الافتراضية ، ولكن يمكنك تعطيلها في الشاشة السابقة ، أو نقلها إلى الأسفل. تحرير الأوضاع يؤثر نوع التنقل على قواعد حسابات المسار. @@ -3805,4 +3805,6 @@ سيتم حذف نقطة الوجهة الحالية على المسار. إذا كانت هي الوجهة، سوف تتوقف الملاحة. تنزيل بيانات ويكيبيديا الحصول على معلومات حول النقاط المثيرة للاهتمام من ويكيبيديا. إنه دليلك غير المتصل بجيبك - ما عليك سوى تمكين المكون الإضافي ويكبيديا والاستمتاع بمقالات حول الكائنات من حولك. + دراجة نارية + سكوتر موتور \ No newline at end of file From b84e51c0810c606bcd8fb8dd8cf94436b6f77bc6 Mon Sep 17 00:00:00 2001 From: ce4 Date: Thu, 9 Jul 2020 07:20:37 +0000 Subject: [PATCH 040/551] Translated using Weblate (German) Currently translated at 100.0% (3812 of 3812 strings) --- OsmAnd/res/values-de/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-de/phrases.xml b/OsmAnd/res/values-de/phrases.xml index 16dc17d12e..65018d07c7 100644 --- a/OsmAnd/res/values-de/phrases.xml +++ b/OsmAnd/res/values-de/phrases.xml @@ -2766,7 +2766,7 @@ Toilettenspülung: Plumpsklo Wikipedia Gewürzgeschäft - Kraftstoffart + Kraftstoffsorte Zahlungsart Zusätzlich Ladestation: ja From d547f14e4bb6cd3cd93b7e151d20e1a238785c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Wed, 8 Jul 2020 20:10:36 +0000 Subject: [PATCH 041/551] Translated using Weblate (Turkish) Currently translated at 62.5% (2386 of 3812 strings) --- OsmAnd/res/values-tr/phrases.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-tr/phrases.xml b/OsmAnd/res/values-tr/phrases.xml index 5b939eb519..5d6ab323b0 100644 --- a/OsmAnd/res/values-tr/phrases.xml +++ b/OsmAnd/res/values-tr/phrases.xml @@ -1476,7 +1476,7 @@ Serbest sürüş Klasik Klasik+paten - Scooter + Mobilet Paten Hayır Tümsek @@ -2394,4 +2394,7 @@ URL Ok Titreşim + Mobilet: hayır + Mobilet: evet + Mobilet \ No newline at end of file From 206b8eeae5f43867ea920c8ed891d8311797806a Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Thu, 9 Jul 2020 03:36:06 +0000 Subject: [PATCH 042/551] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index bd7b2cf482..f8e2063502 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -3810,4 +3810,6 @@ 目前路徑上的目的地點將會被刪除。如果其將為目的地,導航就會停止。 下載維基百科地圖 從維基百科取得關於興趣點的資訊。這是您的離線口袋指南 ── 只要啟用維基百科外掛程式並享受有關於您周圍景點的文章。 + 耐力賽摩托車 + 小型摩托車 \ No newline at end of file From c9041032eabb4b8d0bbf7685a2886d6bc786b82d Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 9 Jul 2020 12:44:57 +0300 Subject: [PATCH 043/551] Fix #8042 Switching to Hebrew is useless --- OsmAnd/res/{values-he => values-iw}/phrases.xml | 0 OsmAnd/res/{values-he => values-iw}/strings.xml | 0 .../src/net/osmand/plus/activities/SettingsGeneralActivity.java | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename OsmAnd/res/{values-he => values-iw}/phrases.xml (100%) rename OsmAnd/res/{values-he => values-iw}/strings.xml (100%) diff --git a/OsmAnd/res/values-he/phrases.xml b/OsmAnd/res/values-iw/phrases.xml similarity index 100% rename from OsmAnd/res/values-he/phrases.xml rename to OsmAnd/res/values-iw/phrases.xml diff --git a/OsmAnd/res/values-he/strings.xml b/OsmAnd/res/values-iw/strings.xml similarity index 100% rename from OsmAnd/res/values-he/strings.xml rename to OsmAnd/res/values-iw/strings.xml diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index 384678f7bc..aaf206ca06 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -280,7 +280,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR "fi", "fr", "gl", - "he", + "iw", "hr", "hsb", "hu", From 3374ed149d3ec0c903ac19f4d7c887b2a023bd1b Mon Sep 17 00:00:00 2001 From: Ahmad Alfrhood Date: Thu, 9 Jul 2020 09:41:52 +0000 Subject: [PATCH 044/551] Translated using Weblate (Arabic) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-ar/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index 2cf4d277fa..f54b58fff2 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -3398,7 +3398,7 @@ حدد أيقونه الخريطة بعد النقر فوق \"تطبيق\" ، سيتم فقد الأوضاع المحذوفة بالكامل. الوضع الرئيسي - + اختر اللون لا يمكنك حذف أوضاع أوسماند الافتراضية ، ولكن يمكنك تعطيلها في الشاشة السابقة ، أو نقلها إلى الأسفل. تحرير الأوضاع يؤثر نوع التنقل على قواعد حسابات المسار. From cccd89434c48afc3ee23b86328d7ecbeef0f0348 Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Thu, 9 Jul 2020 12:51:48 +0300 Subject: [PATCH 045/551] Fix #6380 Change icon (After review) --- OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java index 2650725c11..9251e555b0 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java @@ -473,7 +473,7 @@ public class QuickSearchListAdapter extends ArrayAdapter { ContextCompat.getColor(app, colorClosed)); int colorId = rs.isOpenedForTime(Calendar.getInstance()) ? colorOpen : colorClosed; timeLayout.setVisibility(View.VISIBLE); - timeIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_time_16, colorId)); + timeIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_opening_hour_16, colorId)); timeText.setText(openHours); } else { timeLayout.setVisibility(View.GONE); From ec89e824ba83349a23f4099b6c68818f67780fdf Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 9 Jul 2020 13:01:07 +0300 Subject: [PATCH 046/551] Update inline skates icon, added two icons for wheelchair, added icon for go-cart --- OsmAnd/res/drawable/ic_action_go_cart.xml | 10 ++++++++++ OsmAnd/res/drawable/ic_action_inline_skates.xml | 9 +++++++-- OsmAnd/res/drawable/ic_action_wheelchair.xml | 12 ++++++++++++ OsmAnd/res/drawable/ic_action_wheelchair_forward.xml | 12 ++++++++++++ OsmAnd/res/values/strings.xml | 3 +++ .../src/net/osmand/plus/profiles/ProfileIcons.java | 3 +++ 6 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 OsmAnd/res/drawable/ic_action_go_cart.xml create mode 100644 OsmAnd/res/drawable/ic_action_wheelchair.xml create mode 100644 OsmAnd/res/drawable/ic_action_wheelchair_forward.xml diff --git a/OsmAnd/res/drawable/ic_action_go_cart.xml b/OsmAnd/res/drawable/ic_action_go_cart.xml new file mode 100644 index 0000000000..3b3f321cea --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_go_cart.xml @@ -0,0 +1,10 @@ + + + diff --git a/OsmAnd/res/drawable/ic_action_inline_skates.xml b/OsmAnd/res/drawable/ic_action_inline_skates.xml index b86fe84c27..1d597ad389 100644 --- a/OsmAnd/res/drawable/ic_action_inline_skates.xml +++ b/OsmAnd/res/drawable/ic_action_inline_skates.xml @@ -4,7 +4,12 @@ android:viewportWidth="24" android:viewportHeight="24"> + diff --git a/OsmAnd/res/drawable/ic_action_wheelchair.xml b/OsmAnd/res/drawable/ic_action_wheelchair.xml new file mode 100644 index 0000000000..de21179bb8 --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_wheelchair.xml @@ -0,0 +1,12 @@ + + + + diff --git a/OsmAnd/res/drawable/ic_action_wheelchair_forward.xml b/OsmAnd/res/drawable/ic_action_wheelchair_forward.xml new file mode 100644 index 0000000000..96bf7169a8 --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_wheelchair_forward.xml @@ -0,0 +1,12 @@ + + + + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 35de06c09b..2c917272b1 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,9 @@ Thx - Hardy --> + Go-cart + Wheelchair forward + Wheelchair Motor scooter Enduro motorcycle Get information about points of interest from Wikipedia. It is your pocket offline guide - just enable Wikipedia plugin and enjoy articles about objects around you. diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileIcons.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileIcons.java index b7beb6d124..8e41b2bce6 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfileIcons.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileIcons.java @@ -31,6 +31,8 @@ public enum ProfileIcons { MONOWHEEL(R.drawable.ic_action_monowheel, R.string.app_mode_monowheel, "ic_action_monowheel"), SCOOTER(R.drawable.ic_action_scooter, R.string.app_mode_scooter, "ic_action_scooter"), INLINE_SKATES(R.drawable.ic_action_inline_skates, R.string.app_mode_inline_skates, "ic_action_inline_skates"), + WHEELCHAIR(R.drawable.ic_action_wheelchair, R.string.app_mode_wheelchair, "ic_action_wheelchair"), + WHEELCHAIR_FORWARD(R.drawable.ic_action_wheelchair_forward, R.string.app_mode_wheelchair_forward, "ic_action_wheelchair_forward"), UFO(R.drawable.ic_action_ufo, R.string.app_mode_ufo, "ic_action_ufo"), OFFROAD(R.drawable.ic_action_offroad, R.string.app_mode_offroad, "ic_action_offroad"), CAMPERVAN(R.drawable.ic_action_campervan, R.string.app_mode_campervan, "ic_action_campervan"), @@ -40,6 +42,7 @@ public enum ProfileIcons { UTV(R.drawable.ic_action_ski_touring, R.string.app_mode_utv, "ic_action_ski_touring"), SKI_TOURING(R.drawable.ic_action_utv, R.string.app_mode_ski_touring, "ic_action_utv"), SNOWMOBILE(R.drawable.ic_action_snowmobile, R.string.app_mode_ski_snowmobile, "ic_action_snowmobile"), + GO_CART(R.drawable.ic_action_go_cart, R.string.app_mode_go_cart, "ic_action_go_cart"), OSM(R.drawable.ic_action_openstreetmap_logo, R.string.app_mode_osm, "ic_action_openstreetmap_logo"); @DrawableRes From 8d2e7a793766ccf7810c2e666abe915176e0482a Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Thu, 9 Jul 2020 13:28:42 +0300 Subject: [PATCH 047/551] Fix #5012 --- OsmAnd/res/values-ar/strings.xml | 1 - OsmAnd/res/values-az/strings.xml | 1 - OsmAnd/res/values-b+be+Latn/strings.xml | 1 - OsmAnd/res/values-b+hsb/strings.xml | 1 - OsmAnd/res/values-be/strings.xml | 1 - OsmAnd/res/values-bg/strings.xml | 1 - OsmAnd/res/values-ca/strings.xml | 1 - OsmAnd/res/values-cs/strings.xml | 1 - OsmAnd/res/values-da/strings.xml | 1 - OsmAnd/res/values-de/strings.xml | 1 - OsmAnd/res/values-el/strings.xml | 1 - OsmAnd/res/values-eo/strings.xml | 1 - OsmAnd/res/values-es-rAR/strings.xml | 1 - OsmAnd/res/values-es-rUS/strings.xml | 1 - OsmAnd/res/values-es/strings.xml | 1 - OsmAnd/res/values-et/strings.xml | 1 - OsmAnd/res/values-eu/strings.xml | 1 - OsmAnd/res/values-fa/strings.xml | 1 - OsmAnd/res/values-fi/strings.xml | 1 - OsmAnd/res/values-fr/strings.xml | 1 - OsmAnd/res/values-gl/strings.xml | 1 - OsmAnd/res/values-hu/strings.xml | 1 - OsmAnd/res/values-hy/strings.xml | 1 - OsmAnd/res/values-is/strings.xml | 1 - OsmAnd/res/values-it/strings.xml | 1 - OsmAnd/res/values-iw/strings.xml | 1 - OsmAnd/res/values-ja/strings.xml | 1 - OsmAnd/res/values-kn/strings.xml | 1 - OsmAnd/res/values-lt/strings.xml | 1 - OsmAnd/res/values-lv/strings.xml | 1 - OsmAnd/res/values-ml/strings.xml | 1 - OsmAnd/res/values-nb/strings.xml | 1 - OsmAnd/res/values-nl/strings.xml | 1 - OsmAnd/res/values-pl/strings.xml | 1 - OsmAnd/res/values-pt-rBR/strings.xml | 1 - OsmAnd/res/values-pt/strings.xml | 1 - OsmAnd/res/values-ro/strings.xml | 1 - OsmAnd/res/values-ru/strings.xml | 1 - OsmAnd/res/values-sc/strings.xml | 1 - OsmAnd/res/values-sk/strings.xml | 1 - OsmAnd/res/values-sl/strings.xml | 1 - OsmAnd/res/values-sr/strings.xml | 1 - OsmAnd/res/values-sv/strings.xml | 1 - OsmAnd/res/values-tr/strings.xml | 1 - OsmAnd/res/values-uk/strings.xml | 1 - OsmAnd/res/values-zh-rCN/strings.xml | 1 - OsmAnd/res/values-zh-rTW/strings.xml | 1 - OsmAnd/res/values/strings.xml | 2 +- OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java | 2 +- 49 files changed, 2 insertions(+), 49 deletions(-) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index f54b58fff2..e56073c6c8 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -1842,7 +1842,6 @@ عند الإيقاف ستبدأ واجهة الخريطة مباشرة. OSM POI معدل ملاحظة OSM معلق عليها - ملاحظة OSM محذوفة مسار زلق لإظهار خرائط التزلج، يجب تحميل خريطة خاصة محلية. حافلة، ترامواي وغيرها diff --git a/OsmAnd/res/values-az/strings.xml b/OsmAnd/res/values-az/strings.xml index 56c525fa8f..e162549076 100644 --- a/OsmAnd/res/values-az/strings.xml +++ b/OsmAnd/res/values-az/strings.xml @@ -1578,7 +1578,6 @@ Silinmiş OSM POI Yenidən açılmış OSM qeydi Rəy yazılmış OSM qeydi - Silinmiş OSM qeydi Yaradılmış OSM qeydi Təsdiq et Yaradılmış OSM POI diff --git a/OsmAnd/res/values-b+be+Latn/strings.xml b/OsmAnd/res/values-b+be+Latn/strings.xml index a5a49915b4..68f3cc2d12 100644 --- a/OsmAnd/res/values-b+be+Latn/strings.xml +++ b/OsmAnd/res/values-b+be+Latn/strings.xml @@ -1571,7 +1571,6 @@ Praparcyjnaj pamiacі %4$s MB (Abmiežavańnie Android %5$s MB, Dalvik %6$s MB). Dadać natatku OSM Natatka OSM adkryta znoŭ Da natatkі OSM dadadzieny kamentar - Natatka OSM vydalenaja Natatka OSM stvorana Natatka OSM Stvaryć natatku diff --git a/OsmAnd/res/values-b+hsb/strings.xml b/OsmAnd/res/values-b+hsb/strings.xml index e76a7e56cb..f6eee351c8 100644 --- a/OsmAnd/res/values-b+hsb/strings.xml +++ b/OsmAnd/res/values-b+hsb/strings.xml @@ -73,7 +73,6 @@ Změnjene OSM POI-dypki Wotstronjene OSM POI-dypki Komentowana OSM-notica - Wotstronjena OSM-notica OSM-notica Komentar přidać Noticu začinić diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index dde803e8d7..f02b3d7626 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -1808,7 +1808,6 @@ Дадаць нататку OSM Нататка OSM адкрытая зноў Да нататкі OSM дададзены каментар - Нататка OSM выдаленая Нататка OSM створаная Нататка OSM Стварыць нататку diff --git a/OsmAnd/res/values-bg/strings.xml b/OsmAnd/res/values-bg/strings.xml index 907fafd625..1238c5a8b9 100644 --- a/OsmAnd/res/values-bg/strings.xml +++ b/OsmAnd/res/values-bg/strings.xml @@ -1568,7 +1568,6 @@ \"Изкл.\" стартира директно картата. Отворена отново бележка на OSM Бележка на OSM с коментар - Изтрита бележка на OSM Създадена бележка на OSM Бележка на OSM Създайте Бележка diff --git a/OsmAnd/res/values-ca/strings.xml b/OsmAnd/res/values-ca/strings.xml index 3c4e7ee70f..27ec7ebddc 100644 --- a/OsmAnd/res/values-ca/strings.xml +++ b/OsmAnd/res/values-ca/strings.xml @@ -1787,7 +1787,6 @@ Per retornar a l\'estil habitual dels mapes d\'OsmAnd, només cal desactivar aqu Obre una nota d\'OSM S\'ha reobert nota d\'OSM S\'ha comentat nota d\'OSM - S\'ha eliminat nota d\'OSM S\'ha creat nota d\'OSM Nota d\'OSM Crea nota diff --git a/OsmAnd/res/values-cs/strings.xml b/OsmAnd/res/values-cs/strings.xml index 5efebf14f4..f8f7d4196d 100644 --- a/OsmAnd/res/values-cs/strings.xml +++ b/OsmAnd/res/values-cs/strings.xml @@ -1755,7 +1755,6 @@ Délka %2$s Otevřít OSM poznámku Znovuotevřená OSM poznámka Komentovaná OSM poznámka - Smazaná OSM poznámka Vytvořená OSM poznámka OSM poznámka Vytvořit poznámku diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index 4b878e8432..0e4bf01dbe 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -1778,7 +1778,6 @@ Åbn OSM-note Genåbnet OSM-note Kommenteret OSM-note - Slettet OSM-note Oprettet OSM-note OSM-note Opret note diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index acb3358a91..c177aba730 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -1765,7 +1765,6 @@ OSM-Notiz erstellen Wiedereröffnete OSM-Notiz Kommentierte OSM-Notiz - Gelöschte OSM-Notiz Erstellte OSM-Notiz OSM-Notiz Notiz erstellen diff --git a/OsmAnd/res/values-el/strings.xml b/OsmAnd/res/values-el/strings.xml index f18342af5d..df52e8653d 100644 --- a/OsmAnd/res/values-el/strings.xml +++ b/OsmAnd/res/values-el/strings.xml @@ -2190,7 +2190,6 @@ Άνοιγμα σημείωσης OSM Ξανανοιγμένη σημείωση OSM Σχολιασμένη Σημείωση OSM - Διαγράφηκε σημείωση OSM Δημιουργήθηκε σημείωση OSM Σημείωση OSM Δημιουργία σημείωσης diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index 6d14a73ec3..0933178823 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -123,7 +123,6 @@ Krei OSM-rimarkon Remalfermis OSM-rimarkon Komentis OSM-rimarkon - Forigis OSM-rimarkon Kreita OSM-rimarko OSM-rimarko Krei rimarkon diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 5de3ca867e..6e06602862 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -1772,7 +1772,6 @@ Abrir nota de OSM Nota de OSM reabierta Nota de OSM comentada - Nota de OSM resuelta Nota de OSM creada Nota de OSM Crear nota diff --git a/OsmAnd/res/values-es-rUS/strings.xml b/OsmAnd/res/values-es-rUS/strings.xml index 504a7a63d2..6230a0046d 100644 --- a/OsmAnd/res/values-es-rUS/strings.xml +++ b/OsmAnd/res/values-es-rUS/strings.xml @@ -1772,7 +1772,6 @@ Abrir nota de OSM Nota de OSM reabierta Nota de OSM comentada - Nota de OSM resuelta Nota de OSM creada Nota de OSM Crear nota diff --git a/OsmAnd/res/values-es/strings.xml b/OsmAnd/res/values-es/strings.xml index a0baae1d76..126e6956fa 100644 --- a/OsmAnd/res/values-es/strings.xml +++ b/OsmAnd/res/values-es/strings.xml @@ -1771,7 +1771,6 @@ Abrir nota de OSM Nota de OSM reabierta Nota de OSM comentada - Nota de OSM resuelta Nota de OSM creada Nota de OSM Crear nota diff --git a/OsmAnd/res/values-et/strings.xml b/OsmAnd/res/values-et/strings.xml index 83b9a9ec24..8b422cc796 100644 --- a/OsmAnd/res/values-et/strings.xml +++ b/OsmAnd/res/values-et/strings.xml @@ -2254,7 +2254,6 @@ Ava OSM märge Uuesti avatud OSM märge Kommenteeritud OSM märge - Kustutatud OSM märge Loodud OSM märge OSM märge Loo märge diff --git a/OsmAnd/res/values-eu/strings.xml b/OsmAnd/res/values-eu/strings.xml index 6c92616fcb..7bb968baf9 100644 --- a/OsmAnd/res/values-eu/strings.xml +++ b/OsmAnd/res/values-eu/strings.xml @@ -1374,7 +1374,6 @@ Lorratza %2$s Ireki OSM oharra OSM oharra berrireki da OSM oharrean iruzkina egin da - OSM oharra ezabatu da OSM oharra sortu da OSM oharra Sortu oharra diff --git a/OsmAnd/res/values-fa/strings.xml b/OsmAnd/res/values-fa/strings.xml index 061c2a10e9..44a95baf83 100644 --- a/OsmAnd/res/values-fa/strings.xml +++ b/OsmAnd/res/values-fa/strings.xml @@ -1963,7 +1963,6 @@ هنگام شروع نشانش بده کپی شد حذف POI - بستن یادداشت OSM یادداشت OSM‏ نوشتن یادداشت افزودن توضیح diff --git a/OsmAnd/res/values-fi/strings.xml b/OsmAnd/res/values-fi/strings.xml index 23bfa2ddf7..ecbbad329f 100644 --- a/OsmAnd/res/values-fi/strings.xml +++ b/OsmAnd/res/values-fi/strings.xml @@ -1078,7 +1078,6 @@ Maailmanlaajuiset tiedot (välillä 70 astetta pohjoista ja 70 astetta eteläist Avaa OSM Huomautus Uudelleen avattu OSM Huomautus Kommentoitu OSM Huomautus - Poistettu OSM Huomautus OSM Huomautus luotu OSM Huomautus Luo huomautus diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index f264af132d..4261dd28db 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -1760,7 +1760,6 @@ Modifier l\'étape GPX Signaler une anomalie OSM Note OSM réouverte - Note OSM supprimée Note OSM créée Note OSM Créer une note diff --git a/OsmAnd/res/values-gl/strings.xml b/OsmAnd/res/values-gl/strings.xml index d373b082d4..9e146396df 100644 --- a/OsmAnd/res/values-gl/strings.xml +++ b/OsmAnd/res/values-gl/strings.xml @@ -1763,7 +1763,6 @@ Lon %2$s Abrir nota do OSM Reabriuse a nota de OSM Nota de OSM comentada - Nota de OSM eliminada Nota de OSM creada Nota de OSM Crear unha nota diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 678c4dda4d..ce0242574b 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -1762,7 +1762,6 @@ OSM Jegyzet megnyitása Újranyitott OSM Jegyzet Kommentált OSM Jegyzet - Törölt OSM Jegyzet Létrehozott OSM Jegyzet OSM Jegyzet Jegyzet létrehozása diff --git a/OsmAnd/res/values-hy/strings.xml b/OsmAnd/res/values-hy/strings.xml index e41d3c45ed..c8c71b8bb1 100644 --- a/OsmAnd/res/values-hy/strings.xml +++ b/OsmAnd/res/values-hy/strings.xml @@ -642,7 +642,6 @@ Ավելացնել OSM նշումը OSM նշումը կրկին բացված է OSM նշումին ավելացվել է մեկնաբանություն - OSM նշումը հեռացվեց OSM նշում ստեղծվել է OSM նշում Ստեղծել նշում diff --git a/OsmAnd/res/values-is/strings.xml b/OsmAnd/res/values-is/strings.xml index 05205af693..d5619f7a96 100644 --- a/OsmAnd/res/values-is/strings.xml +++ b/OsmAnd/res/values-is/strings.xml @@ -765,7 +765,6 @@ Veldu raddleiðsögn Opna OSM-minnispunkt Enduropnaði OSM-minnispunkt - Eyddi OSM-minnispunkti Bjó til OSM-minnispunkt OSM-minnispunktur Búa til minnispunkt diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index 84112aba40..e96e07e7b5 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -1766,7 +1766,6 @@ Apri una nota di OSM Nota di OSM riaperta Nota di OSM commentata - Nota di OSM eliminata Nota di OSM creata Nota di OSM Crea nota diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index d8b81e15d3..fed119f881 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -2390,7 +2390,6 @@ \n כמה לפני המועד ברצונך להיוודע על הגעה ליעד? חוצץ זמן למעקב מקוון - הערת OSM נמחקה נוצרה הערת OSM הערת OSM יצירת הערה diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index a01259ddc6..d1982ce869 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -1742,7 +1742,6 @@ POIの更新は利用できません OSMでの注釈を開く OSMでの注釈を開き直す OSMの注釈にコメントを付加しました - OSMの注釈を削除しました OSMに注釈を作成しました OSMでの注釈 注釈の作成 diff --git a/OsmAnd/res/values-kn/strings.xml b/OsmAnd/res/values-kn/strings.xml index bbe6999e0d..0e3884002f 100644 --- a/OsmAnd/res/values-kn/strings.xml +++ b/OsmAnd/res/values-kn/strings.xml @@ -209,7 +209,6 @@ ಲಭ್ಯವಿರುವ ನಕ್ಷೆಗಳು ದೂರ: ಒಎಸ್ಎಂ ಟಿಪ್ಪಣಿಯನ್ನು ತೆರೆಯಿರಿ - ಅಳಿಸಲಾದ ಒಎಸ್ಎಂ ಟಿಪ್ಪಣಿ ಸೃಷ್ಟಿಸಲಾದ ಒಎಸ್ಎಂ ಟಿಪ್ಪಣಿ ಒಎಸ್ಎಂ ಟಿಪ್ಪಣಿ ಟಿಪ್ಪಣಿಯನ್ನು ಹಾಕಿರಿ diff --git a/OsmAnd/res/values-lt/strings.xml b/OsmAnd/res/values-lt/strings.xml index a8f4eee382..1e8c0895ce 100644 --- a/OsmAnd/res/values-lt/strings.xml +++ b/OsmAnd/res/values-lt/strings.xml @@ -1749,7 +1749,6 @@ Ilguma %2$s Pridėti OSM pastabą OSM pastaba iš naujo atidaryta OSM pastaba papildyta komentaru - OSM pastaba ištrinta OSM pastaba sukurta OSM pastaba Iš naujo atidaryti pastabą diff --git a/OsmAnd/res/values-lv/strings.xml b/OsmAnd/res/values-lv/strings.xml index 2ee47646cc..33b8d8415a 100644 --- a/OsmAnd/res/values-lv/strings.xml +++ b/OsmAnd/res/values-lv/strings.xml @@ -1615,7 +1615,6 @@ Atvērt OSM piezīmi Atkārtoti atvērta OSM piezīme OSM Note pievienots komentārs - OSM piezīme ir izdzēsta Izveidota OSM piezīme OSM piezīme Izveidot piezīmi diff --git a/OsmAnd/res/values-ml/strings.xml b/OsmAnd/res/values-ml/strings.xml index 5a7b728ea8..947cb21a92 100644 --- a/OsmAnd/res/values-ml/strings.xml +++ b/OsmAnd/res/values-ml/strings.xml @@ -2058,7 +2058,6 @@ OSM POI ഇല്ലാതാക്കി OSM കുറിപ്പ് വീണ്ടും തുറന്നു OSM കുറിപ്പിൽ അഭിപ്രായമിട്ടു - OSM കുറിപ്പ് ഇല്ലാതാക്കി OSM കുറിപ്പു് സൃഷ്ടിച്ചു കുറിപ്പ് സൃഷ്ടിക്കുക OSM POI സൃഷ്ടിച്ചു diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index 1c3c51e2d8..f502cb1dd6 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -1748,7 +1748,6 @@ Åpne OSM-notat Gjenåpnet OSM-notat Kommentert OSM-notat - Slettet OSM-notat Opprettet OSM-notat OSM-notat Opprett notat diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 4661668ee8..0702198718 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -1755,7 +1755,6 @@ OSM-notitie aanmaken Heropen OSM-notitie Becommentarieerde OSM-notitie - Verwijderde OSM-notitie Aangemaakte OSM-notitie OSM-notitie Maak OSM-notitie aan diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml index 21e9dc02f5..eea73e1812 100644 --- a/OsmAnd/res/values-pl/strings.xml +++ b/OsmAnd/res/values-pl/strings.xml @@ -1781,7 +1781,6 @@ Usunięto użyteczne miejce OSM Otwarto ponownie notatkę OSM Skomentowano uwagę OSM - Usunięto uwagę OSM Utworzono uwagę OSM Utwórz uwagę Nie utworzono uwagi. diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 1054f6d06a..4ad3f4b969 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -1682,7 +1682,6 @@ Pôr do Sol: %2$s Abrir nota no OSM Nota no OSM reaberta Nota no OSM comentada - Nota no OSM excluído Nota no OSM criada Nota no OSM Criar nota diff --git a/OsmAnd/res/values-pt/strings.xml b/OsmAnd/res/values-pt/strings.xml index 898063f44d..52ec68e2d2 100644 --- a/OsmAnd/res/values-pt/strings.xml +++ b/OsmAnd/res/values-pt/strings.xml @@ -1506,7 +1506,6 @@ Abrir anotação OSM Re-abrir anotação OSM Anotação OSM comentada - Nota OSM eliminada Anotação OSM adicionada Anotação OSM Adicionar anotação OSM diff --git a/OsmAnd/res/values-ro/strings.xml b/OsmAnd/res/values-ro/strings.xml index 3e7d433de9..c0a9abe434 100644 --- a/OsmAnd/res/values-ro/strings.xml +++ b/OsmAnd/res/values-ro/strings.xml @@ -1359,7 +1359,6 @@ \"Oprit\" lansează direct ecranul hărții. Copiat în clipboard Nota OSM comentată - Nota OSM ștearsă Nota OSM creată Notă OSM Crează notă diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 7c0a021979..ef9375b604 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -274,7 +274,6 @@ Редактировать POI Заметка OSM открыта снова К заметке OSM добавлен комментарий - Заметка OSM удалена Заметка OSM создана Заметка OSM Создать заметку diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index fd9438d853..7af00c0cae 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -1770,7 +1770,6 @@ Aberi una nota de OSM Nota OSM torrada a abèrrere Nota OSM cummentada - Nota OSM iscantzellada Nota OSM creada Nota OSM Crea nota diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index d850b202d7..f5e8919fc8 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -1767,7 +1767,6 @@ Otvoriť OSM poznámku Znovuotvorená OSM poznámka Pridaný komentár k OSM poznámke - Odstránená OSM poznámka Vytvorená OSM poznámka OSM poznámka Vytvoriť poznámku diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml index 2878167119..323ca39e8e 100644 --- a/OsmAnd/res/values-sl/strings.xml +++ b/OsmAnd/res/values-sl/strings.xml @@ -1768,7 +1768,6 @@ Sorazmerna velikost pomnilnika je %4$s MB (omejitev na androidu je %5$s MB, na d Izbrisana točka POI Odpri opombe OSM Ponovno odprte opombe OSM - Izbrisana opomba OSM Ustvarjena opomba OSM Opomba OSM Ustvari opombo diff --git a/OsmAnd/res/values-sr/strings.xml b/OsmAnd/res/values-sr/strings.xml index 5d5e145f14..0d73885ba5 100644 --- a/OsmAnd/res/values-sr/strings.xml +++ b/OsmAnd/res/values-sr/strings.xml @@ -357,7 +357,6 @@ Отвори белешку ОСМ-а Поново отворена белешка ОСМ-а Искоментарисана белешка ОСМ-а - Избрисана белешка ОСМ-а Белешка ОСМ-а Направи белешку Додај коментар diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index 20b9ae5977..36934d43c5 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -1711,7 +1711,6 @@ Long %2$s Raderat OSM POI Öppna OSM-anteckning Kommenterat OSM-anteckning - Tagit bort OSM-anteckning Skapat OSM-anteckning OSM-anteckning Skapa anteckning diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 6ae6c3f291..612339d2a6 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -1273,7 +1273,6 @@ OSM Not\'u aç Yeniden açılmış OSM Notu Yorum yazılmış OSM Notu - Silinmiş OSM Notu Oluşturulmuş OSM Notu OSM Notu Not oluştur diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index e534957f01..3d8ce5177f 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -1639,7 +1639,6 @@ Відкрити OSM-нотатку Відкрити заново OSM-нотатку До OSM-нотатки додано коментар - Вилучено OSM-нотатку Створено OSM-нотатку OSM-нотатка Створити нотатку diff --git a/OsmAnd/res/values-zh-rCN/strings.xml b/OsmAnd/res/values-zh-rCN/strings.xml index 7f0187f5d9..b72be1f2c0 100644 --- a/OsmAnd/res/values-zh-rCN/strings.xml +++ b/OsmAnd/res/values-zh-rCN/strings.xml @@ -911,7 +911,6 @@ 打开 OSM 注解 重新打开 OSM 注解 已评论 OSM 注解 - 已删除 OSM 注解 已创建 OSM 注解 OSM 注解 创建注解 diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index f8e2063502..9dc5ab36ad 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -1764,7 +1764,6 @@ 開啟 OSM 註解 重新開啟 OSM 註解 已評論 OSM 註解 - 已刪除 OSM 註解 建立 OSM 的註解 OSM 註解 建立註解 diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 2c917272b1..5d733cf83f 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Closed OSM Note Go-cart Wheelchair forward Wheelchair @@ -1687,7 +1688,6 @@ Open OSM Note Reopened OSM Note Commented OSM Note - Deleted OSM Note Created OSM Note OSM Note Create note diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 2ef7632e19..47c2eb5200 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -94,7 +94,7 @@ public class EditPOIMenuController extends MenuController { } } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { if (osmPoint.getAction() == Action.DELETE) { - actionStr = mapActivity.getString(R.string.osm_edit_removed_note); + actionStr = mapActivity.getString(R.string.osm_edit_closed_note); } else if (osmPoint.getAction() == Action.MODIFY) { actionStr = mapActivity.getString(R.string.osm_edit_commented_note); } else if (osmPoint.getAction() == Action.REOPEN) { From 1a0e73af0d9b87b69b6807c69c880ee697201f08 Mon Sep 17 00:00:00 2001 From: MadWasp79 Date: Thu, 9 Jul 2020 14:32:59 +0300 Subject: [PATCH 048/551] add preciese coordinates to new start points --- .../src/main/java/net/osmand/router/BinaryRoutePlanner.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index 5c0f38f4a5..cf7eacd2ee 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -852,6 +852,8 @@ public class BinaryRoutePlanner { public RouteSegmentPoint(RouteDataObject road, int segmentStart, double distSquare) { super(road, segmentStart); this.distSquare = distSquare; + this.preciseX = road.getPoint31XTile(segmentStart); + this.preciseY = road.getPoint31YTile(segmentStart); } public RouteSegmentPoint(RouteSegmentPoint pnt) { From 2db3b07225a16ca1174bc457e83449aec9af597a Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 9 Jul 2020 14:01:43 +0200 Subject: [PATCH 049/551] Fix exception --- .../java/net/osmand/router/RoutePlannerFrontEnd.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index 60dc5add01..108e00f2c9 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -228,6 +228,8 @@ public class RoutePlannerFrontEnd { routeFound = findGpxRouteSegment(gctx, gpxPoints, start, next, prev != null); if (routeFound) { // route is found - cut the end of the route and move to next iteration +// start.stepBackRoute = new ArrayList(); +// boolean stepBack = true; boolean stepBack = stepBackAndFindPrevPointInRoute(gctx, gpxPoints, start, next); if (!stepBack) { // not supported case (workaround increase MAXIMUM_STEP_APPROXIMATION) @@ -518,9 +520,12 @@ public class RoutePlannerFrontEnd { // make first position precise makeSegmentPointPrecise(res.get(0), start.loc, true); } else { - assert res.get(0).getObject().getId() == start.pnt.getRoad().getId(); - // start point could shift to +-1 due to direction - res.get(0).setStartPointIndex(start.pnt.getSegmentStart()); + if(res.get(0).getObject().getId() == start.pnt.getRoad().getId()) { + // start point could shift to +-1 due to direction + res.get(0).setStartPointIndex(start.pnt.getSegmentStart()); + } else { + //throw new IllegalStateException("TODO"); + } } start.routeToTarget = res; start.targetInd = target.ind; From e63e9b686543977081be5c0f541076ba68f4e6c8 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 9 Jul 2020 19:34:49 +0200 Subject: [PATCH 050/551] Fix #9293 --- .../net/osmand/binary/GeocodingUtilities.java | 64 ++++++++++++++++--- .../osmand/router/RoutePlannerFrontEnd.java | 11 +++- .../net/osmand/router/RoutingContext.java | 7 ++ .../osmand/plus/CurrentPositionHelper.java | 6 +- .../sample1/CurrentPositionHelper.java | 6 +- 5 files changed, 79 insertions(+), 15 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/GeocodingUtilities.java b/OsmAnd-java/src/main/java/net/osmand/binary/GeocodingUtilities.java index 1699d749d9..77357bac9b 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/GeocodingUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/GeocodingUtilities.java @@ -4,6 +4,7 @@ import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.CollatorStringMatcher.StringMatcherMode; import net.osmand.binary.BinaryMapIndexReader.SearchRequest; +import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion; import net.osmand.data.Building; import net.osmand.data.City; import net.osmand.data.LatLon; @@ -23,9 +24,11 @@ import java.text.Collator; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import gnu.trove.set.hash.TLongHashSet; @@ -40,7 +43,7 @@ public class GeocodingUtilities { public static final float STOP_SEARCHING_STREET_WITH_MULTIPLIER_RADIUS = 250; public static final float STOP_SEARCHING_STREET_WITHOUT_MULTIPLIER_RADIUS = 400; - public static final int DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 15000; + public static final int DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 45000; public static final float DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME = 1000; public static final float THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER = 1.5f; @@ -142,15 +145,12 @@ public class GeocodingUtilities { RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(); List lst = new ArrayList(); List listR = new ArrayList(); - rp.findRouteSegment(lat, lon, ctx, listR); + // we allow duplications to search in both files for boundary regions + rp.findRouteSegment(lat, lon, ctx, listR, false, true); double distSquare = 0; - TLongHashSet set = new TLongHashSet(); - Set streetNames = new HashSet(); + Map> streetNames = new HashMap<>(); for (RouteSegmentPoint p : listR) { RouteDataObject road = p.getRoad(); - if (!set.add(road.getId())) { - continue; - } // System.out.println(road.toString() + " " + Math.sqrt(p.distSquare)); String name = Algorithms.isEmpty(road.getName()) ? road.getRef("", false, true) : road.getName(); if (allowEmptyNames || !Algorithms.isEmpty(name)) { @@ -164,7 +164,13 @@ public class GeocodingUtilities { sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX)); sr.regionFP = road.region.getFilePointer(); sr.regionLen = road.region.getLength(); - if (streetNames.add(sr.streetName)) { + List plst = streetNames.get(sr.streetName); + if (plst == null) { + plst = new ArrayList(); + streetNames.put(sr.streetName, plst); + } + if (!plst.contains(road.region)) { + plst.add(road.region); lst.add(sr); } } @@ -308,6 +314,48 @@ public class GeocodingUtilities { return res; } + public void filterDuplicateRegionResults(final List res) { + Collections.sort(res, DISTANCE_COMPARATOR); + // filter duplicate city results (when building is in both regions on boundary) + for (int i = 0; i < res.size() - 1;) { + int cmp = cmpResult(res.get(i), res.get(i + 1)); + if (cmp > 0) { + res.remove(i); + } else if (cmp < 0) { + res.remove(i + 1); + } else { + // nothing to delete + i++; + } + } + } + + private int cmpResult(GeocodingResult gr1, GeocodingResult gr2) { + boolean eqStreet = Algorithms.stringsEqual(gr1.streetName, gr2.streetName); + if (eqStreet) { + boolean sameObj = false; + if (gr1.building != null && gr2.building != null) { + if (Algorithms.stringsEqual(gr1.building.getName(), gr2.building.getName())) { + // same building + sameObj = true; + } + } else if (gr1.building == null && gr2.building == null) { + // same street + sameObj = true; + } + if (sameObj) { + double cityDist1 = MapUtils.getDistance(gr1.searchPoint, gr1.city.getLocation()); + double cityDist2 = MapUtils.getDistance(gr2.searchPoint, gr2.city.getLocation()); + if (cityDist1 < cityDist2) { + return -1; + } else { + return 1; + } + } + } + return 0; + } + private List loadStreetBuildings(final GeocodingResult road, BinaryMapIndexReader reader, GeocodingResult street) throws IOException { final List streetBuildings = new ArrayList(); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index 108e00f2c9..7a56f82591 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -117,15 +117,20 @@ public class RoutePlannerFrontEnd { } public RouteSegmentPoint findRouteSegment(double lat, double lon, RoutingContext ctx, List list, boolean transportStop) throws IOException { + return findRouteSegment(lat, lon, ctx, list, false, false); + } + + public RouteSegmentPoint findRouteSegment(double lat, double lon, RoutingContext ctx, List list, boolean transportStop, + boolean allowDuplications) throws IOException { int px = MapUtils.get31TileNumberX(lon); int py = MapUtils.get31TileNumberY(lat); ArrayList dataObjects = new ArrayList(); - ctx.loadTileData(px, py, 17, dataObjects); + ctx.loadTileData(px, py, 17, dataObjects, allowDuplications); if (dataObjects.isEmpty()) { - ctx.loadTileData(px, py, 15, dataObjects); + ctx.loadTileData(px, py, 15, dataObjects, allowDuplications); } if (dataObjects.isEmpty()) { - ctx.loadTileData(px, py, 14, dataObjects); + ctx.loadTileData(px, py, 14, dataObjects, allowDuplications); } if (list == null) { list = new ArrayList(); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java index e3c233b4d4..75a4295b5a 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java @@ -412,6 +412,10 @@ public class RoutingContext { } public void loadTileData(int x31, int y31, int zoomAround, final List toFillIn) { + loadTileData(x31, y31, zoomAround, toFillIn, false); + } + + public void loadTileData(int x31, int y31, int zoomAround, final List toFillIn, boolean allowDuplications) { int t = config.ZOOM_TO_LOAD_TILES - zoomAround; int coordinatesShift = (1 << (31 - config.ZOOM_TO_LOAD_TILES)); if(t <= 0) { @@ -432,6 +436,9 @@ public class RoutingContext { TLongObjectHashMap excludeDuplications = new TLongObjectHashMap(); while (it.hasNext()) { getAllObjects(it.next(), toFillIn, excludeDuplications); + if (allowDuplications) { + excludeDuplications.clear(); + } } timeToFindInitialSegments += (System.nanoTime() - now); } diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index 5fce920b91..a50a345aa3 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -237,6 +237,7 @@ public class CurrentPositionHelper { List complete = new ArrayList<>(); double minBuildingDistance = 0; if (res != null) { + GeocodingUtilities gu = new GeocodingUtilities(); for (GeocodingResult r : res) { BinaryMapIndexReader foundRepo = null; List rts = usedReaders; @@ -259,7 +260,7 @@ public class CurrentPositionHelper { } else if (foundRepo != null) { List justified = null; try { - justified = new GeocodingUtilities().justifyReverseGeocodingSearch(r, foundRepo, + justified = gu.justifyReverseGeocodingSearch(r, foundRepo, minBuildingDistance, result); } catch (IOException e) { log.error("Exception happened during reverse geocoding", e); @@ -277,6 +278,7 @@ public class CurrentPositionHelper { complete.add(r); } } + gu.filterDuplicateRegionResults(complete); } if (result.isCancelled()) { @@ -287,7 +289,7 @@ public class CurrentPositionHelper { }); return; } - Collections.sort(complete, GeocodingUtilities.DISTANCE_COMPARATOR); +// Collections.sort(complete, GeocodingUtilities.DISTANCE_COMPARATOR); // for(GeocodingResult rt : complete) { // System.out.println(rt.toString()); // } diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java index 351f1891d6..e490925754 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java @@ -191,6 +191,7 @@ public class CurrentPositionHelper { private void justifyResult(List res, final ResultMatcher result) { List complete = new ArrayList<>(); double minBuildingDistance = 0; + GeocodingUtilities gu = new GeocodingUtilities(); if (res != null) { for (GeocodingResult r : res) { BinaryMapIndexReader foundRepo = null; @@ -208,7 +209,7 @@ public class CurrentPositionHelper { } else if (foundRepo != null) { List justified = null; try { - justified = new GeocodingUtilities().justifyReverseGeocodingSearch(r, foundRepo, + justified = gu.justifyReverseGeocodingSearch(r, foundRepo, minBuildingDistance, result); } catch (IOException e) { log.error("Exception happened during reverse geocoding", e); @@ -227,6 +228,7 @@ public class CurrentPositionHelper { complete.add(r); } } + gu.filterDuplicateRegionResults(complete); } if (result.isCancelled()) { @@ -237,7 +239,7 @@ public class CurrentPositionHelper { }); return; } - Collections.sort(complete, GeocodingUtilities.DISTANCE_COMPARATOR); + // Collections.sort(complete, GeocodingUtilities.DISTANCE_COMPARATOR); // for(GeocodingResult rt : complete) { // System.out.println(rt.toString()); // } From c02df5e2dc0515c8b82e3721a086b67eab823d78 Mon Sep 17 00:00:00 2001 From: Artem Date: Thu, 9 Jul 2020 21:42:25 +0000 Subject: [PATCH 051/551] Translated using Weblate (Russian) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-ru/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 7c0a021979..ceed6e6f30 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -3814,4 +3814,6 @@ Текущий пункт назначения на маршруте будет удалён. Если это пункт назначения, навигация остановится. Информация о достопримечательностях из Википедии. Это ваш карманный автономный гид — просто включите плагин Википедии и наслаждайтесь статьями об объектах вокруг вас. Скачать карты Википедии + Эндуро мотоцикл + Мотороллер \ No newline at end of file From 4578838adbe51b684ce3a76795b6e35028e1e1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Thu, 9 Jul 2020 16:28:07 +0000 Subject: [PATCH 052/551] Translated using Weblate (Turkish) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-tr/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 6ae6c3f291..41d2a10683 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -2501,7 +2501,7 @@ Nokta ekle Açıklamayı gizle Açıklamayı göster - Haritaları taşı + Haritaları hareket ettir Yürüme navigasyonunu dene. Ayarları değiştirmeyi deneyin. Restore et From 5300623faf0aeb79947eaba4096e9d44d313a6df Mon Sep 17 00:00:00 2001 From: ihor_ck Date: Thu, 9 Jul 2020 19:57:59 +0000 Subject: [PATCH 053/551] Translated using Weblate (Ukrainian) Currently translated at 99.9% (3416 of 3417 strings) --- OsmAnd/res/values-uk/strings.xml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index e534957f01..44e3a07707 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -1127,7 +1127,7 @@ Маршрутна точка " \n -\nДовго утримуйте, щоб побачити на мапі" +\nУтримуйте, щоб побачити на мапі" Запускати навігацію автоматично виділені Під-треки: %1$s @@ -3125,7 +3125,7 @@ Прогулянки, походи, біг Види громадського транспорту Корабель, веслування, вітрильний спорт - Літак, аероглайдинг + Літак, планер Геокодування Пряма лінія BRouter (автономний) @@ -3408,10 +3408,10 @@ Позиція значка в спокої Натиснення \"Застосувати\" видалить профілі назавжди. Основний профіль - Оберіть колір + Виберіть колір Усталені профілі OsmAnd не видалено, проте вимкнуто (на попередньому екрані) чи відпорядковано донизу. Редагувати профілі - \"Вид навігації\" визначає спосіб обчислення маршрутів. + \'Тип навігації\' визначає спосіб обчислення маршрутів. Зовнішній вигляд профілю Значок, колір та назва Редагувати список профілів @@ -3806,8 +3806,9 @@ Масштабування кнопками гучності Вкажіть довжину вашого автомобіля, для довгих транспортних засобів можуть застосовуватися деякі обмеження на маршрутах. Видалити наступну точку призначення - Укажіть назву пункту + Вкажіть назву пункту Поточну точку призначення на маршруті буде видалено. Якщо це буде місце призначення, навігація припиниться. Завантажити мапи Вікіпедії Отримайте відомості про визначні місця у Вікіпедії. Це ваш кишеньковий посібник без мережі - просто ввімкніть втулок \"Вікіпедія\" і насолоджуйтесь статтями про об\'єкти навколо вас. + Моторолер \ No newline at end of file From 1ecec3bac1bac7282ea73abd1c5e27f0d2393ea8 Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Thu, 9 Jul 2020 13:38:41 +0000 Subject: [PATCH 054/551] Translated using Weblate (Sardinian) Currently translated at 99.6% (3406 of 3417 strings) --- OsmAnd/res/values-sc/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index fd9438d853..49e91ed6c8 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -3817,4 +3817,6 @@ Su puntu de destinatzione atuale in s\'àndala at a èssere iscantzelladu. Si at a èssere sa destinatzione, sa navigatzione s\'at a firmare. Iscàrriga sas mapas de Wikipedia Otene informatziones a pitzu de puntos de interesse dae Wikipedia. Est sa ghia non in lìnia tua de mantènnere in butzaca - abìlita s\'estensione Wikipedia e ispassia·ti cun sos artìculos a pitzu de sos ogetos a fùrriu de tie. + Moto enduro + Motorinu \ No newline at end of file From 4ff830b3f1237c8752235b45097ffb9054fab258 Mon Sep 17 00:00:00 2001 From: Kars de Jong Date: Thu, 9 Jul 2020 20:47:39 +0000 Subject: [PATCH 055/551] Translated using Weblate (German) Currently translated at 100.0% (3812 of 3812 strings) --- OsmAnd/res/values-de/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-de/phrases.xml b/OsmAnd/res/values-de/phrases.xml index 65018d07c7..e2ca883769 100644 --- a/OsmAnd/res/values-de/phrases.xml +++ b/OsmAnd/res/values-de/phrases.xml @@ -3603,7 +3603,7 @@ Anzahl der Wickeltische Wickeltischgebühr: ja Wickeltischgebühr: nein - Holzkohlestoß + Kohlenmeiler Historischer Panzer Wasserpfeifen-Lounge Energiequelle: Biomasse From 34e7568739be90ef0219be6648fb8090b77a21a3 Mon Sep 17 00:00:00 2001 From: Kars de Jong Date: Thu, 9 Jul 2020 20:52:04 +0000 Subject: [PATCH 056/551] Translated using Weblate (French) Currently translated at 99.9% (3809 of 3812 strings) --- OsmAnd/res/values-fr/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-fr/phrases.xml b/OsmAnd/res/values-fr/phrases.xml index b220d4eaf1..f26c9279aa 100644 --- a/OsmAnd/res/values-fr/phrases.xml +++ b/OsmAnd/res/values-fr/phrases.xml @@ -3600,7 +3600,7 @@ Nombre de tables à langer Table à langer payante Table à langer gratuite - Pile de charbon + Meule Bar à chicha Balkanique Point de vente From e9bf88c68708004dd615573ed8b59b0c29bf3001 Mon Sep 17 00:00:00 2001 From: Kars de Jong Date: Thu, 9 Jul 2020 22:08:58 +0000 Subject: [PATCH 057/551] Translated using Weblate (Dutch) Currently translated at 96.8% (3693 of 3812 strings) --- OsmAnd/res/values-nl/phrases.xml | 94 ++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/OsmAnd/res/values-nl/phrases.xml b/OsmAnd/res/values-nl/phrases.xml index fb9b279343..f2cbdafc8d 100644 --- a/OsmAnd/res/values-nl/phrases.xml +++ b/OsmAnd/res/values-nl/phrases.xml @@ -3612,4 +3612,98 @@ Kinderopvang Tolportaal Atol + Aangegeven + Aangegeven + Bestemmingsverkeer + Aangegeven + Toegestaan + Bestemmingsverkeer + Aangegeven + Aangegeven + Aangegeven + Bestemmingsverkeer + Toegestaan + Aangegeven + Aangegeven + Aangegeven + Aangegeven + Toegestaan + Aangegeven + Toegang voor gehandicapten: nee + Toegang voor taxi’s: nee + Toegang voor taxi’s: aangegeven + Toegang voor taxi’s: ja + Toegang voor landbouwvoertuigen: nee + Toegang voor landbouwvoertuigen: ja + Toegang voor sneeuwscooters: nee + Toegang voor sneeuwscooters: privé + Toegang voor skiërs: nee + Toegang voor skiërs: ja + Toegang voor touringcars: nee + Toegang voor touringcars: aangegeven + Toegang voor lijnbussen: nee + Toegang voor touringcars: ja + Toegang voor touringcars: ja + Toegang voor touringcars: nee + Toegang voor publiek transport of taxi’s: nee + Toegang voor publiek transport of taxi’s: aangegeven + Toegang voor publiek transport of taxi’s: ja + Toegang voor aanhangers: nee + Toegang voor campers: nee + Toegang voor caravans: nee + Toegang voor fietsers: klanten + Toegang voor fietsers: toegestaan + Toegang voor fietsers: bestemmingsverkeer + Toegang voor fietsers: afstappen + Toegang voor fietsers: privé + Toegang voor snorfietsers: nee + Toegang voor bromfietsers: nee + Toegang voor motorbestuurders: nee + Toegang voor motorbestuurders: privé + Toegang voor voetgangers: klanten + Toegang voor voetgangers: toegestaan + Toegang voor voetgangers: bestemmingsverkeer + Toegang voor voetgangers: nee + Toegang voor voetgangers: privé + Toegang voor voetgangers: ja + Toegang voor ruiters: boswachterij + Toegang voor ruiters: toegestaan + Toegang voor ruiters: bestemmingsverkeer + Toegang voor ruiters: privé + Toegang voor bestelwagens: nee + Toegang voor vrachtwagens: ongeschikt + Toegang voor vrachtwagens: ontraden + Toegang voor vrachtwagens: landbouw + Toegang voor vrachtwagens: nee + Toegang voor vrachtwagens: privé + Toegang voor motorvoertuigen: landbouw + Toegang voor motorvoertuigen: boswachterij + Toegang voor motorvoertuigen: bezorging + Toegang voor motorvoertuigen: militair + Toegang voor motorvoertuigen: klanten + Toegang voor motorvoertuigen: toegestaan + Toegang voor motorvoertuigen: bestemmingsverkeer + Toegang voor motorvoertuigen: nee + Toegang voor motorvoertuigen: privé + Toegang voor auto’s: toegestaan + Toegang voor auto’s: bestemmingsverkeer + Toegang voor auto’s: nee + Toegang voor auto’s: privé + Toegang voor auto’s: ja + Toegang voor auto’s: klanten + Toegang voor auto’s: boswachterij + Toegang voor motorvoertuigen: ja + Toegang voor voertuigen: boswachterij + Toegang voor voertuigen: bezorging + Toegang voor voertuigen: militair + Toegang voor voertuigen: klanten + Toegang voor voertuigen: toegestaan + Toegang voor voertuigen: bestemmingsverkeer + Toegang voor voertuigen: nee + Toegang voor voertuigen: privé + Toegang voor voertuigen: ja + Hookah lounge + Meiler + Noodhulpkist + Faciliteiten voor pijpleidingen \ No newline at end of file From df91b5e17b3634b4e0c759de2dbab741103429db Mon Sep 17 00:00:00 2001 From: Franco Date: Thu, 9 Jul 2020 21:14:34 +0000 Subject: [PATCH 058/551] Translated using Weblate (Spanish (Argentina)) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 5de3ca867e..a31affafb7 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -3820,4 +3820,6 @@ El punto de destino actual de la ruta será borrado. Si será el destino, la navegación se detendrá. Descargar datos de Wikipedia Obtén información sobre los puntos de interés de Wikipedia. Es tu guía de bolsillo sin conexión - sólo activa el complemento de Wikipedia y disfruta los artículos sobre los objetos de alrededor. + Motocicleta de enduro + Motoneta (motor) \ No newline at end of file From bd93904c2437d4fea8aba4affd158e5d4b83f837 Mon Sep 17 00:00:00 2001 From: Franco Date: Thu, 9 Jul 2020 20:55:26 +0000 Subject: [PATCH 059/551] Translated using Weblate (Spanish (Argentina)) Currently translated at 100.0% (3812 of 3812 strings) --- OsmAnd/res/values-es-rAR/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-es-rAR/phrases.xml b/OsmAnd/res/values-es-rAR/phrases.xml index 9e596b6667..5e9d8b5c82 100644 --- a/OsmAnd/res/values-es-rAR/phrases.xml +++ b/OsmAnd/res/values-es-rAR/phrases.xml @@ -1852,7 +1852,7 @@ Monumento técnico Templo piramidal Oficina del campamento - Aeródromo a escala + Pista de aeromodelismo Oficina del guía ONG casi autónoma Oficina de consultoría From 38f178cd62a7b59b3e26ab2b910da203e0e7046d Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Thu, 9 Jul 2020 22:01:11 +0000 Subject: [PATCH 060/551] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 1054f6d06a..3e2d4ea1cc 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -3802,4 +3802,6 @@ Pôr do Sol: %2$s O ponto de destino atual na rota será excluído. Se for o destino, a navegação será interrompida. Baixar mapas da Wikipédia Obter informações sobre pontos de interesse da Wikipédia. É o seu guia de bolso off-line - só ativar o complemento Wikipédia e desfrutar de artigos sobre os elementos ao seu redor. + Motocicleta enduro + Motoneta \ No newline at end of file From 01ce91c5a6a686328acd9e5cd0398c87d9eaff00 Mon Sep 17 00:00:00 2001 From: Franco Date: Thu, 9 Jul 2020 21:32:54 +0000 Subject: [PATCH 061/551] Translated using Weblate (Spanish (American)) Currently translated at 100.0% (3417 of 3417 strings) --- OsmAnd/res/values-es-rUS/strings.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-es-rUS/strings.xml b/OsmAnd/res/values-es-rUS/strings.xml index 504a7a63d2..c256576e9e 100644 --- a/OsmAnd/res/values-es-rUS/strings.xml +++ b/OsmAnd/res/values-es-rUS/strings.xml @@ -3803,7 +3803,7 @@ Un botón que alterna la capa de Mapillary en el mapa. Rumbo %1$s borrado - Debes reiniciar para borrar completamente los datos de los radares de velocidad. + Se debe reiniciar para borrar completamente los datos de los radares de velocidad. Desinstalar y reiniciar Indica la longitud permitida del vehículo en rutas. Límite de longitud @@ -3811,4 +3811,12 @@ Patines en línea Permite controlar el nivel de zoom del mapa con los botones de volumen del dispositivo. Botones de volumen como zoom + Descargar datos de Wikipedia + El punto de destino actual de la ruta será borrado. Si será el destino, la navegación se detendrá. + Borrar el siguiente punto de destino + Obtén información sobre los puntos de interés de Wikipedia. Es tu guía de bolsillo sin conexión - sólo activa el complemento de Wikipedia y disfruta los artículos sobre los objetos de alrededor. + Proporciona un nombre para el punto + Proporciona la longitud del vehículo, se pueden aplicar algunas restricciones de rutas para vehículos largos. + Motoneta (motor) + Motocicleta de enduro \ No newline at end of file From 53bb40a84ab68beb53781c9f581b695fbe28c26b Mon Sep 17 00:00:00 2001 From: Franco Date: Thu, 9 Jul 2020 21:25:36 +0000 Subject: [PATCH 062/551] Translated using Weblate (Spanish (American)) Currently translated at 100.0% (3812 of 3812 strings) --- OsmAnd/res/values-es-rUS/phrases.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-es-rUS/phrases.xml b/OsmAnd/res/values-es-rUS/phrases.xml index ceb20a440f..7f0a081326 100644 --- a/OsmAnd/res/values-es-rUS/phrases.xml +++ b/OsmAnd/res/values-es-rUS/phrases.xml @@ -1852,7 +1852,7 @@ Monumento técnico Templo piramidal Oficina del campamento - Aeródromo a escala + Pista de aeromodelismo Oficina del guía ONG casi autónoma Oficina de consultoría @@ -3837,4 +3837,6 @@ Flecha Vibración Caja de regalo + Manzana (cuadra) + Municipio \ No newline at end of file From 89b7b472f2ab28fbb57347288c8ddd0ddcdbcf60 Mon Sep 17 00:00:00 2001 From: Kars de Jong Date: Thu, 9 Jul 2020 17:11:50 +0000 Subject: [PATCH 063/551] Translated using Weblate (Dutch) Currently translated at 96.8% (3311 of 3417 strings) --- OsmAnd/res/values-nl/strings.xml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 4661668ee8..f0d440d519 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -3432,7 +3432,7 @@ Recht-naar-punt Kies een naam voor het profiel Open instellingen - Plugin uitgeschakeld + Plug-in uit Deze plug-in is een afzonderlijke app, die afzonderlijk verwijderd moet worden als je deze niet meer nodig denkt te hebben. \n \nDe plug-in blijft op het apparaat aanwezig na het verwijderen van OsmAnd. @@ -3443,7 +3443,7 @@ Het geïmporteerde profiel bevat bijkomende gegevens. Klik \'importeer\' om enkel de profielgegevens te importeren of kies bijkomende gegevens om te importeren. Je kan bijkomende gegevens om mee met het profiel te exporteren. App Standaardwaarde (%s) - Herberekening uitschakelen + Niet herberekenen Minimale afstand om route te herbereken De route wordt herberekend wanneer de afstand tot die route groter is dan de opgegeven parameter Eigen profiel @@ -3472,17 +3472,17 @@ Alle profielinstellingen herstellen\? Slaat nieuw profiel op Kan profiel niet back-uppen. - %1$s of %2$s + %1$s van %2$s Hellingen Terrein tonen / verbergen Terrein verbergen Terrein tonen Een knop om de terreinlaag al dan niet te tonen op de kaart. - Verwijder een beschrijving - Voeg een beschrijving toe - Selecteer groep - Selecteer vorm - cirkel + Beschrijving verwijderen + Beschrijving toevoegen + Groep kiezen + Vorm kiezen + Cirkel Ruit Min Combineer POI-types uit verschillende categorieën. Tik op \"Schakelen\" om alles te selecteren, tik op de linkerkant voor de categoriekeuze. @@ -3708,4 +3708,6 @@ Verwijder het volgende routepunt Kies een naam voor het punt Wikipedia-kaarten downloaden + Motorscooter + Enduromotor \ No newline at end of file From f479debb79855ec328d0d098ea27c2d2a24dabe2 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 10 Jul 2020 16:56:55 +0300 Subject: [PATCH 064/551] Fix #8318 --- .../src/main/java/net/osmand/GPXUtilities.java | 1 - .../mapcontextmenu/other/TrackDetailsMenu.java | 15 ++++++++------- .../plus/myplaces/TrackSegmentFragment.java | 11 +++++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 6eb20d0f15..d5e404a76f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -932,7 +932,6 @@ public class GPXUtilities { sp = new SplitSegment(segment, k - 1, cf); currentMetricEnd += metricLimit; - prev = sp.get(0); } total += currentSegment; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java index fdc58e7831..586a301d45 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java @@ -46,6 +46,7 @@ import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet; import net.osmand.plus.views.GPXLayer; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; +import net.osmand.util.MapUtils; import java.util.ArrayList; import java.util.Collections; @@ -312,18 +313,15 @@ public class TrackDetailsMenu { } } else { float distance = pos * dataSet.getDivX(); - double previousSplitDistance = 0; + double totalDistance = 0; WptPt previousPoint = null; for (int i = 0; i < segment.points.size(); i++) { WptPt currentPoint = segment.points.get(i); if (previousPoint != null) { - if (currentPoint.distance < previousPoint.distance) { - previousSplitDistance += previousPoint.distance; - } + totalDistance += MapUtils.getDistance(previousPoint.lat, previousPoint.lon, currentPoint.lat, currentPoint.lon); } - double totalDistance = previousSplitDistance + currentPoint.distance; - if (totalDistance >= distance) { - if (previousPoint != null) { + if (currentPoint.distance >= distance || Math.abs(totalDistance - distance) < 0.1) { + if (previousPoint != null && currentPoint.distance >= distance) { double percent = 1 - (totalDistance - distance) / (currentPoint.distance - previousPoint.distance); double dLat = (currentPoint.lat - previousPoint.lat) * percent; double dLon = (currentPoint.lon - previousPoint.lon) * percent; @@ -500,6 +498,9 @@ public class TrackDetailsMenu { } else { mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints); } + if (location != null) { + mapActivity.refreshMap(); + } fitTrackOnMap(chart, location, forceFit); } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index 8207d401ff..41343f0fa3 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -57,7 +57,6 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; @@ -70,12 +69,14 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet; import net.osmand.plus.measurementtool.NewGpxData; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.controls.PagerSlidingTabStrip; import net.osmand.plus.views.controls.PagerSlidingTabStrip.CustomTabProvider; import net.osmand.plus.views.controls.WrapContentHeightViewPager; import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface; import net.osmand.plus.widgets.IconPopupMenu; import net.osmand.util.Algorithms; +import net.osmand.util.MapUtils; import java.io.File; import java.lang.ref.WeakReference; @@ -525,16 +526,14 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit } } else { float distance = pos * dataSet.getDivX(); - double previousSplitDistance = 0; + double totalDistance = 0; for (int i = 0; i < segment.points.size(); i++) { WptPt currentPoint = segment.points.get(i); if (i != 0) { WptPt previousPoint = segment.points.get(i - 1); - if (currentPoint.distance < previousPoint.distance) { - previousSplitDistance += previousPoint.distance; - } + totalDistance += MapUtils.getDistance(previousPoint.lat, previousPoint.lon, currentPoint.lat, currentPoint.lon); } - if (previousSplitDistance + currentPoint.distance >= distance) { + if (currentPoint.distance >= distance || Math.abs(totalDistance - distance) < 0.1) { wpt = currentPoint; break; } From 2b23c7e8ca277c18204822dfac776a6dde271ca1 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 10 Jul 2020 19:54:50 +0200 Subject: [PATCH 065/551] Refactor field names --- .../net/osmand/router/BinaryRoutePlanner.java | 52 ++++++++----- .../router/RouteCalculationProgress.java | 19 ++++- .../osmand/router/RoutePlannerFrontEnd.java | 76 +++++++++--------- .../osmand/router/RouteResultPreparation.java | 7 +- .../net/osmand/router/RoutingContext.java | 78 +++++++++++-------- .../java/net/osmand/router/TestRouting.java | 8 +- 6 files changed, 143 insertions(+), 97 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index cf7eacd2ee..fe7780ea0f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -68,7 +68,6 @@ public class BinaryRoutePlanner { FinalRouteSegment searchRouteInternal(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end, RouteSegment recalculationEnd ) throws InterruptedException, IOException { // measure time - ctx.timeToLoad = 0; ctx.memoryOverhead = 1000; // Initializing priority queue to visit way segments @@ -120,7 +119,9 @@ public class BinaryRoutePlanner { if (ctx.memoryOverhead > ctx.config.memoryLimitation * 0.95) { throw new IllegalStateException("There is not enough memory " + ctx.config.memoryLimitation / (1 << 20) + " Mb"); } - ctx.visitedSegments ++; + if (ctx.calculationProgress != null) { + ctx.calculationProgress.visitedSegments++; + } if (forwardSearch) { boolean doNotAddIntersections = onlyBackward; processRouteSegment(ctx, false, graphDirectSegments, visitedDirectSegments, @@ -164,12 +165,14 @@ public class BinaryRoutePlanner { throw new InterruptedException("Route calculation interrupted"); } } - ctx.visitedSegments += visitedDirectSegments.size() + visitedOppositeSegments.size(); - ctx.visitedDirectSegments += visitedDirectSegments.size(); - ctx.visitedOppositeSegments += visitedOppositeSegments.size(); - ctx.directQueueSize = graphDirectSegments.size(); // Math.max(ctx.directQueueSize, graphDirectSegments.size()); - ctx.oppositeQueueSize = graphReverseSegments.size(); - ctx.visitedOppositeSegments += visitedOppositeSegments.size(); + if (ctx.calculationProgress != null) { + ctx.calculationProgress.visitedDirectSegments += visitedDirectSegments.size(); + ctx.calculationProgress.visitedOppositeSegments += visitedOppositeSegments.size(); + ctx.calculationProgress.directQueueSize = graphDirectSegments.size(); // Math.max(ctx.directQueueSize, + // graphDirectSegments.size()); + ctx.calculationProgress.oppositeQueueSize = graphReverseSegments.size(); + ctx.calculationProgress.visitedOppositeSegments += visitedOppositeSegments.size(); + } return finalSegment; } @@ -371,18 +374,21 @@ public class BinaryRoutePlanner { } public static void printDebugMemoryInformation(RoutingContext ctx) { - printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to calc dev: %.2f ", - (System.nanoTime() - ctx.timeToCalculate) / 1e6, ctx.timeToLoad / 1e6, - ctx.timeToLoadHeaders / 1e6, ctx.timeNanoToCalcDeviation / 1e6)); -// GeneralRouter.TIMER = 0; - int maxLoadedTiles = Math.max(ctx.maxLoadedTiles, ctx.getCurrentlyLoadedTiles()); - printInfo("Current loaded tiles : " + ctx.getCurrentlyLoadedTiles() + ", maximum loaded tiles " + maxLoadedTiles); - printInfo("Loaded tiles " + ctx.loadedTiles + " (distinct " + ctx.distinctLoadedTiles + "), unloaded tiles " + ctx.unloadedTiles + - ", loaded more than once same tiles " - + ctx.loadedPrevUnloadedTiles); - printInfo("Visited segments " + ctx.visitedSegments + ", relaxed roads " + ctx.relaxedSegments); - printInfo("Priority queues sizes : " + ctx.directQueueSize + "/" + ctx.oppositeQueueSize); - printInfo("Visited interval sizes: " + ctx.visitedDirectSegments + "/" + ctx.visitedOppositeSegments); + if (ctx.calculationProgress != null) { + RouteCalculationProgress p = ctx.calculationProgress; + printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to calc dev: %.2f ", + p.timeToCalculate / 1e6, p.timeToLoad / 1e6, p.timeToLoadHeaders / 1e6, + p.timeNanoToCalcDeviation / 1e6)); + // GeneralRouter.TIMER = 0; + int maxLoadedTiles = Math.max(p.maxLoadedTiles, ctx.getCurrentlyLoadedTiles()); + printInfo("Current loaded tiles : " + ctx.getCurrentlyLoadedTiles() + ", maximum loaded tiles " + + maxLoadedTiles); + printInfo("Loaded tiles " + p.loadedTiles + " (distinct " + p.distinctLoadedTiles + "), unloaded tiles " + + p.unloadedTiles + ", loaded more than once same tiles " + p.loadedPrevUnloadedTiles); + printInfo("Visited segments: " + ctx.getVisitedSegments() + ", relaxed roads " + p.relaxedSegments); + printInfo("Priority queues sizes : " + p.directQueueSize + "/" + p.oppositeQueueSize); + printInfo("Visited interval sizes: " + p.visitedDirectSegments + "/" + p.visitedOppositeSegments); + } } @@ -849,6 +855,7 @@ public class BinaryRoutePlanner { } public static class RouteSegmentPoint extends RouteSegment { + public RouteSegmentPoint(RouteDataObject road, int segmentStart, double distSquare) { super(road, segmentStart); this.distSquare = distSquare; @@ -873,6 +880,11 @@ public class BinaryRoutePlanner { } + @Override + public String toString() { + return String.format("%d (%s): %s", segStart, getPreciseLatLon(), road); + } + } public static class RouteSegment { diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteCalculationProgress.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteCalculationProgress.java index b34c2fd5bb..eb93e95699 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteCalculationProgress.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteCalculationProgress.java @@ -12,12 +12,29 @@ public class RouteCalculationProgress { public float totalEstimatedDistance = 0; public float routingCalculatedTime = 0; - public int loadedTiles = 0; + + public int relaxedSegments = 0; public int visitedSegments = 0; + public int visitedDirectSegments = 0; + public int visitedOppositeSegments = 0; + public int directQueueSize = 0; + public int oppositeQueueSize = 0; public int totalIterations = 1; public int iteration = -1; + public long timeNanoToCalcDeviation = 0; + public long timeToLoad = 0; + public long timeToLoadHeaders = 0; + public long timeToFindInitialSegments = 0; + public long timeToCalculate = 0; + + public int distinctLoadedTiles = 0; + public int maxLoadedTiles = 0; + public int loadedPrevUnloadedTiles = 0; + public int unloadedTiles = 0; + public int loadedTiles = 0; + public boolean isCancelled; public boolean requestPrivateAccessRouting; diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index 7a56f82591..d6c6c6611f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -208,9 +208,8 @@ public class RoutePlannerFrontEnd { useSmartRouteRecalculation = use; } - // TODO native matches less roads public GpxRouteApproximation searchGpxRoute(GpxRouteApproximation gctx, List points) throws IOException, InterruptedException { - gctx.ctx.timeToCalculate = System.nanoTime(); + long timeToCalculate = System.nanoTime(); if (gctx.ctx.calculationProgress == null) { gctx.ctx.calculationProgress = new RouteCalculationProgress(); } @@ -275,6 +274,10 @@ public class RoutePlannerFrontEnd { } start = next; } + if(gctx.ctx.calculationProgress != null) { + // TODO + gctx.ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate; + } BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx); calculateGpxRoute(gctx, gpxPoints); if (!gctx.res.isEmpty()) { @@ -529,7 +532,9 @@ public class RoutePlannerFrontEnd { // start point could shift to +-1 due to direction res.get(0).setStartPointIndex(start.pnt.getSegmentStart()); } else { - //throw new IllegalStateException("TODO"); + // for native routing this is possible when point lies on intersection of 2 lines + // solution here could be to pass to native routing id of the route + // though it should not create any issue } } start.routeToTarget = res; @@ -590,7 +595,7 @@ public class RoutePlannerFrontEnd { public List searchRoute(final RoutingContext ctx, LatLon start, LatLon end, List intermediates, PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException { - ctx.timeToCalculate = System.nanoTime(); + long timeToCalculate = System.nanoTime(); if (ctx.calculationProgress == null) { ctx.calculationProgress = new RouteCalculationProgress(); } @@ -622,6 +627,7 @@ public class RoutePlannerFrontEnd { } routeDirection = PrecalculatedRouteDirection.build(ls, ctx.config.DEVIATION_RADIUS, ctx.getRouter().getMaxSpeed()); } + List res ; if (intermediatesEmpty && ctx.nativeLib != null) { ctx.startX = MapUtils.get31TileNumberX(start.getLongitude()); ctx.startY = MapUtils.get31TileNumberY(start.getLatitude()); @@ -635,31 +641,33 @@ public class RoutePlannerFrontEnd { ctx.precalculatedRouteDirection = routeDirection.adopt(ctx); } ctx.calculationProgress.nextIteration(); - List res = runNativeRouting(ctx, recalculationEnd); - if (res != null) { - new RouteResultPreparation().printResults(ctx, start, end, res); - } + res = runNativeRouting(ctx, recalculationEnd); makeStartEndPointsPrecise(res, start, end, intermediates); - return res; - } - int indexNotFound = 0; - List points = new ArrayList(); - if (!addSegment(start, ctx, indexNotFound++, points, ctx.startTransportStop)) { - return null; - } - if (intermediates != null) { - for (LatLon l : intermediates) { - if (!addSegment(l, ctx, indexNotFound++, points, false)) { - System.out.println(points.get(points.size() - 1).getRoad().toString()); - return null; + } else { + int indexNotFound = 0; + List points = new ArrayList(); + if (!addSegment(start, ctx, indexNotFound++, points, ctx.startTransportStop)) { + return null; + } + if (intermediates != null) { + for (LatLon l : intermediates) { + if (!addSegment(l, ctx, indexNotFound++, points, false)) { + System.out.println(points.get(points.size() - 1).getRoad().toString()); + return null; + } } } + if (!addSegment(end, ctx, indexNotFound++, points, ctx.targetTransportStop)) { + return null; + } + ctx.calculationProgress.nextIteration(); + res = searchRouteImpl(ctx, points, routeDirection); } - if (!addSegment(end, ctx, indexNotFound++, points, ctx.targetTransportStop)) { - return null; + if (ctx.calculationProgress != null) { + // TODO + ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate; } - ctx.calculationProgress.nextIteration(); - List res = searchRouteImpl(ctx, points, routeDirection); + BinaryRoutePlanner.printDebugMemoryInformation(ctx); if (res != null) { new RouteResultPreparation().printResults(ctx, start, end, res); } @@ -839,11 +847,11 @@ public class RoutePlannerFrontEnd { ctx.checkOldRoutingFiles(ctx.startX, ctx.startY); ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY); - long time = System.currentTimeMillis(); + // long time = System.currentTimeMillis(); RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx.startX, ctx.startY, ctx.targetX, ctx.targetY, ctx.config, regions, ctx.calculationProgress, ctx.precalculatedRouteDirection, ctx.calculationMode == RouteCalculationMode.BASE, ctx.publicTransport, ctx.startTransportStop, ctx.targetTransportStop); - log.info("Native routing took " + (System.currentTimeMillis() - time) / 1000f + " seconds"); + // log.info("Native routing took " + (System.currentTimeMillis() - time) / 1000f + " seconds"); ArrayList result = new ArrayList(Arrays.asList(res)); if (recalculationEnd != null) { log.info("Native routing use precalculated route"); @@ -855,8 +863,6 @@ public class RoutePlannerFrontEnd { } } ctx.routingTime = ctx.calculationProgress.routingCalculatedTime; - ctx.visitedSegments = ctx.calculationProgress.visitedSegments; - ctx.loadedTiles = ctx.calculationProgress.loadedTiles; return new RouteResultPreparation().prepareResult(ctx, result, recalculationEnd != null); } @@ -870,7 +876,6 @@ public class RoutePlannerFrontEnd { } pringGC(ctx, true); List res = searchRouteInternalPrepare(ctx, points.get(0), points.get(1), routeDirection); - BinaryRoutePlanner.printDebugMemoryInformation(ctx); pringGC(ctx, false); makeStartEndPointsPrecise(res, points.get(0).getPreciseLatLon(), points.get(1).getPreciseLatLon(), null); return res; @@ -917,14 +922,11 @@ public class RoutePlannerFrontEnd { List res = searchRouteInternalPrepare(local, points.get(i), points.get(i + 1), routeDirection); makeStartEndPointsPrecise(res, points.get(i).getPreciseLatLon(), points.get(i + 1).getPreciseLatLon(), null); results.addAll(res); - ctx.distinctLoadedTiles += local.distinctLoadedTiles; - ctx.loadedTiles += local.loadedTiles; - ctx.visitedSegments += local.visitedSegments; - ctx.loadedPrevUnloadedTiles += local.loadedPrevUnloadedTiles; - ctx.timeToCalculate += local.timeToCalculate; - ctx.timeToLoad += local.timeToLoad; - ctx.timeToLoadHeaders += local.timeToLoadHeaders; - ctx.relaxedSegments += local.relaxedSegments; + if(ctx.calculationProgress != null) { + ctx.calculationProgress.distinctLoadedTiles += local.calculationProgress.distinctLoadedTiles; + ctx.calculationProgress.loadedTiles += local.calculationProgress.loadedTiles; + ctx.calculationProgress.loadedPrevUnloadedTiles += local.calculationProgress.loadedPrevUnloadedTiles; + } ctx.routingTime += local.routingTime; // local.unloadAllData(ctx); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index b0c32de648..9892bfb730 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -394,7 +394,7 @@ public class RouteResultPreparation { private List convertFinalSegmentToResults(RoutingContext ctx, FinalRouteSegment finalSegment) { List result = new ArrayList(); if (finalSegment != null) { - ctx.routingTime = finalSegment.distanceFromStart; + ctx.routingTime += finalSegment.distanceFromStart; println("Routing calculated time distance " + finalSegment.distanceFromStart); // Get results from opposite direction roads RouteSegment segment = finalSegment.reverseWaySearch ? finalSegment : @@ -496,8 +496,9 @@ public class RouteResultPreparation { String msg = String.format("", - ctx.config.routerName, startLat, startLon, endLat, endLon, ctx.routingTime, ctx.loadedTiles, - ctx.visitedSegments, completeDistance, completeTime); + ctx.config.routerName, startLat, startLon, endLat, endLon, ctx.routingTime, + ctx.getLoadedTiles(), + ctx.getVisitedSegments(), completeDistance, completeTime); // String msg = MessageFormat.format("", // startLat + "", startLon + "", endLat + "", endLon + "", ctx.config.routerName, diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java index 75a4295b5a..99d959265d 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java @@ -40,8 +40,6 @@ public class RoutingContext { private final static Log log = PlatformUtil.getLog(RoutingContext.class); - - // Final context variables public final RoutingConfiguration config; @@ -82,26 +80,8 @@ public class RoutingContext { public TileStatistics global = new TileStatistics(); // updated by route planner in bytes public int memoryOverhead = 0; - - - long timeNanoToCalcDeviation = 0; - long timeToLoad = 0; - long timeToLoadHeaders = 0; - long timeToFindInitialSegments = 0; - public long timeToCalculate = 0; - - int distinctLoadedTiles = 0; - int maxLoadedTiles = 0; - int loadedPrevUnloadedTiles = 0; - int unloadedTiles = 0; public float routingTime = 0; - public int loadedTiles = 0; - public int visitedSegments = 0; - public int relaxedSegments = 0; - public int visitedDirectSegments = 0; - public int visitedOppositeSegments = 0; - public int directQueueSize = 0; - public int oppositeQueueSize = 0; + // callback of processing segments RouteSegmentVisitor visitor = null; @@ -224,7 +204,9 @@ public class RoutingContext { if (tl.isLoaded()) { if(except == null || except.searchSubregionTile(tl.subregion) < 0){ tl.unload(); - unloadedTiles ++; + if(calculationProgress != null) { + calculationProgress.unloadedTiles ++; + } global.size -= tl.tileStatistics.size; } } @@ -308,27 +290,37 @@ public class RoutingContext { } catch (IOException e) { throw new RuntimeException("Loading data exception", e); } - - timeToLoad += (System.nanoTime() - now); + if (calculationProgress != null) { + calculationProgress.timeToLoad += (System.nanoTime() - now); + } } else { long now = System.nanoTime(); NativeRouteSearchResult ns = nativeLib.loadRouteRegion(ts.subregion, loadObjectsInMemory); // System.out.println(ts.subregion.shiftToData + " " + Arrays.toString(ns.objects)); ts.setLoadedNative(ns, this); - timeToLoad += (System.nanoTime() - now); + if (calculationProgress != null) { + calculationProgress.timeToLoad += (System.nanoTime() - now); + } } - loadedTiles++; + if (calculationProgress != null) { + calculationProgress.loadedTiles++; + } + if (wasUnloaded) { if(ucount == 1) { - loadedPrevUnloadedTiles++; + if(calculationProgress != null) { + calculationProgress.loadedPrevUnloadedTiles++; + } } } else { if(global != null) { global.allRoutes += ts.tileStatistics.allRoutes; global.coordinates += ts.tileStatistics.coordinates; } - distinctLoadedTiles++; + if(calculationProgress != null) { + calculationProgress.distinctLoadedTiles++; + } } global.size += ts.tileStatistics.size; } @@ -402,7 +394,9 @@ public class RoutingContext { } collection.add(found); } - timeToLoadHeaders += (System.nanoTime() - now); + if (calculationProgress != null) { + calculationProgress.timeToLoadHeaders += (System.nanoTime() - now); + } } } catch (IOException e) { throw new RuntimeException("Loading data exception", e); @@ -440,7 +434,9 @@ public class RoutingContext { excludeDuplications.clear(); } } - timeToFindInitialSegments += (System.nanoTime() - now); + if (calculationProgress != null) { + calculationProgress.timeToFindInitialSegments += (System.nanoTime() - now); + } } @SuppressWarnings("unused") @@ -523,7 +519,9 @@ public class RoutingContext { loaded++; } } - maxLoadedTiles = Math.max(maxLoadedTiles, getCurrentlyLoadedTiles()); + if(calculationProgress != null) { + calculationProgress.maxLoadedTiles = Math.max(calculationProgress.maxLoadedTiles, getCurrentlyLoadedTiles()); + } Collections.sort(list, new Comparator() { private int pow(int base, int pw) { int r = 1; @@ -545,7 +543,9 @@ public class RoutingContext { i++; // System.out.println("Unload " + unload); unload.unload(); - unloadedTiles ++; + if(calculationProgress != null) { + calculationProgress.unloadedTiles ++; + } global.size -= unload.tileStatistics.size; // tile could be cleaned from routing tiles and deleted from whole list @@ -796,6 +796,20 @@ public class RoutingContext { return map.keySet().toArray(new BinaryMapIndexReader[map.size()]); } + public int getVisitedSegments() { + if(calculationProgress != null) { + return calculationProgress.visitedSegments; + } + return 0; + } + + public int getLoadedTiles() { + if (calculationProgress != null) { + return calculationProgress.loadedTiles; + } + return 0; + } + diff --git a/OsmAnd-java/src/main/java/net/osmand/router/TestRouting.java b/OsmAnd-java/src/main/java/net/osmand/router/TestRouting.java index 78222819d9..95e2e0d15c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/TestRouting.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/TestRouting.java @@ -236,13 +236,13 @@ public class TestRouting { throw new IllegalArgumentException(MessageFormat.format("Complete routing time (expected) {0} != {1} (original) : {2}", routing_time, calcRoutingTime, testDescription)); } - if (visitedSegments > 0 && !isInOrLess(visitedSegments, ctx.visitedSegments, percent)) { + if (visitedSegments > 0 && !isInOrLess(visitedSegments, ctx.getVisitedSegments(), percent)) { throw new IllegalArgumentException(MessageFormat.format("Visited segments (expected) {0} != {1} (original) : {2}", visitedSegments, - ctx.visitedSegments, testDescription)); + ctx.getVisitedSegments(), testDescription)); } - if (loadedTiles > 0 && !isInOrLess(loadedTiles, ctx.loadedTiles, percent)) { + if (loadedTiles > 0 && !isInOrLess(loadedTiles, ctx.getLoadedTiles(), percent)) { throw new IllegalArgumentException(MessageFormat.format("Loaded tiles (expected) {0} != {1} (original) : {2}", loadedTiles, - ctx.loadedTiles, testDescription)); + ctx.getLoadedTiles(), testDescription)); } if(TEST_BOTH_DIRECTION){ From 386c7dc3f41a45a1454b2ebba0fbf6a608a33540 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 10 Jul 2020 20:03:31 +0200 Subject: [PATCH 066/551] Fix calculation --- .../osmand/plus/routing/RouteCalculationResult.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 46ceaf70ea..e70752b7f1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -140,9 +140,13 @@ public class RouteCalculationResult { OsmandApplication ctx, boolean leftSide, RoutingContext rctx, List waypoints, ApplicationMode mode) { if (rctx != null) { this.routingTime = rctx.routingTime; - this.visitedSegments = rctx.visitedSegments; - this.loadedTiles = rctx.loadedTiles; - this.calculateTime = (float) (((System.nanoTime() - rctx.timeToCalculate) / 1e6) / 1000f); + this.visitedSegments = rctx.getVisitedSegments(); + this.loadedTiles = rctx.getLoadedTiles(); + if (rctx.calculationProgress != null) { + this.calculateTime = (float) (rctx.calculationProgress.timeToCalculate / 1.0e9); + } else { + this.calculateTime = 0; + } } else { this.routingTime = 0; this.visitedSegments = 0; From a1cbdc111bba52ab0c0f036b4ce746d4326b5dfa Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 10 Jul 2020 20:35:22 +0200 Subject: [PATCH 067/551] Refactor time fields --- .../main/java/net/osmand/router/BinaryRoutePlanner.java | 4 ++-- .../main/java/net/osmand/router/RoutePlannerFrontEnd.java | 8 +++++--- .../src/main/java/net/osmand/router/RoutingContext.java | 4 ---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index fe7780ea0f..480bca455a 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -376,9 +376,9 @@ public class BinaryRoutePlanner { public static void printDebugMemoryInformation(RoutingContext ctx) { if (ctx.calculationProgress != null) { RouteCalculationProgress p = ctx.calculationProgress; - printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to calc dev: %.2f ", + printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to find start/end: %.2f, extra: %.2f ", p.timeToCalculate / 1e6, p.timeToLoad / 1e6, p.timeToLoadHeaders / 1e6, - p.timeNanoToCalcDeviation / 1e6)); + p.timeToFindInitialSegments / 1e6, p.timeNanoToCalcDeviation / 1e6)); // GeneralRouter.TIMER = 0; int maxLoadedTiles = Math.max(p.maxLoadedTiles, ctx.getCurrentlyLoadedTiles()); printInfo("Current loaded tiles : " + ctx.getCurrentlyLoadedTiles() + ", maximum loaded tiles " diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index d6c6c6611f..03b49df3e5 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -122,6 +122,7 @@ public class RoutePlannerFrontEnd { public RouteSegmentPoint findRouteSegment(double lat, double lon, RoutingContext ctx, List list, boolean transportStop, boolean allowDuplications) throws IOException { + long now = System.nanoTime(); int px = MapUtils.get31TileNumberX(lon); int py = MapUtils.get31TileNumberY(lat); ArrayList dataObjects = new ArrayList(); @@ -172,6 +173,9 @@ public class RoutePlannerFrontEnd { return Double.compare(o1.distSquare, o2.distSquare); } }); + if (ctx.calculationProgress != null) { + ctx.calculationProgress.timeToFindInitialSegments += (System.nanoTime() - now); + } if (list.size() > 0) { RouteSegmentPoint ps = null; if (ctx.publicTransport) { @@ -275,7 +279,6 @@ public class RoutePlannerFrontEnd { start = next; } if(gctx.ctx.calculationProgress != null) { - // TODO gctx.ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate; } BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx); @@ -664,8 +667,7 @@ public class RoutePlannerFrontEnd { res = searchRouteImpl(ctx, points, routeDirection); } if (ctx.calculationProgress != null) { - // TODO - ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate; + ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate; } BinaryRoutePlanner.printDebugMemoryInformation(ctx); if (res != null) { diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java index 99d959265d..81f4936234 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java @@ -420,7 +420,6 @@ public class RoutingContext { } TLongHashSet ts = new TLongHashSet(); - long now = System.nanoTime(); for(int i = -t; i <= t; i++) { for(int j = -t; j <= t; j++) { ts.add(getRoutingTile(x31 +i*coordinatesShift, y31 + j*coordinatesShift, 0)); @@ -434,9 +433,6 @@ public class RoutingContext { excludeDuplications.clear(); } } - if (calculationProgress != null) { - calculationProgress.timeToFindInitialSegments += (System.nanoTime() - now); - } } @SuppressWarnings("unused") From f59cea9c0a35bbf3ca4d3968ce0762e0de4215c3 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 10 Jul 2020 20:45:49 +0200 Subject: [PATCH 068/551] Refactor time fields --- .../src/main/java/net/osmand/router/BinaryRoutePlanner.java | 4 ++-- .../src/main/java/net/osmand/router/RoutingContext.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index 480bca455a..6b8926b413 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -168,9 +168,9 @@ public class BinaryRoutePlanner { if (ctx.calculationProgress != null) { ctx.calculationProgress.visitedDirectSegments += visitedDirectSegments.size(); ctx.calculationProgress.visitedOppositeSegments += visitedOppositeSegments.size(); - ctx.calculationProgress.directQueueSize = graphDirectSegments.size(); // Math.max(ctx.directQueueSize, + ctx.calculationProgress.directQueueSize += graphDirectSegments.size(); // Math.max(ctx.directQueueSize, // graphDirectSegments.size()); - ctx.calculationProgress.oppositeQueueSize = graphReverseSegments.size(); + ctx.calculationProgress.oppositeQueueSize += graphReverseSegments.size(); ctx.calculationProgress.visitedOppositeSegments += visitedOppositeSegments.size(); } return finalSegment; diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java index 81f4936234..e888ad1d59 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java @@ -318,7 +318,7 @@ public class RoutingContext { global.allRoutes += ts.tileStatistics.allRoutes; global.coordinates += ts.tileStatistics.coordinates; } - if(calculationProgress != null) { + if (calculationProgress != null) { calculationProgress.distinctLoadedTiles++; } } From 46703209ff672ac64e7520e96f628565d9a2a951 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Fri, 10 Jul 2020 21:49:35 +0300 Subject: [PATCH 069/551] Fix https://github.com/osmandapp/Osmand/issues/9379 --- OsmAnd/res/values-sv/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-sv/phrases.xml b/OsmAnd/res/values-sv/phrases.xml index 4306fea7c0..60e90c4246 100644 --- a/OsmAnd/res/values-sv/phrases.xml +++ b/OsmAnd/res/values-sv/phrases.xml @@ -1640,7 +1640,7 @@ Ja Drive-in: nej Ja - Drive-through: ja + Drive-through: nej Bryggerinamn Ja Inget mikrobryggeri From 1433eb0ca93b717916da7f7dbf0ec8b14f5ff49d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 10 Jul 2020 23:12:29 +0200 Subject: [PATCH 070/551] Refactor native parameters for routing --- .../main/java/net/osmand/NativeLibrary.java | 16 +++++----------- .../osmand/router/RoutePlannerFrontEnd.java | 18 +++++++----------- .../java/net/osmand/router/RoutingContext.java | 14 ++++++++++---- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java b/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java index 25e1a21969..60a5b3dd10 100644 --- a/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java +++ b/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java @@ -26,10 +26,9 @@ import net.osmand.data.QuadRect; import net.osmand.render.RenderingRuleSearchRequest; import net.osmand.render.RenderingRulesStorage; import net.osmand.router.NativeTransportRoutingResult; -import net.osmand.router.PrecalculatedRouteDirection; import net.osmand.router.RouteCalculationProgress; import net.osmand.router.RouteSegmentResult; -import net.osmand.router.RoutingConfiguration; +import net.osmand.router.RoutingContext; import net.osmand.router.TransportRoutingConfiguration; import net.osmand.util.Algorithms; @@ -135,12 +134,10 @@ public class NativeLibrary { return nativeTransportRouting(new int[] { sx31, sy31, ex31, ey31 }, cfg, progress); } - public RouteSegmentResult[] runNativeRouting(int sx31, int sy31, int ex31, int ey31, RoutingConfiguration config, - RouteRegion[] regions, RouteCalculationProgress progress, PrecalculatedRouteDirection precalculatedRouteDirection, - boolean basemap, boolean publicTransport, boolean startTransportStop, boolean targetTransportStop) { + public RouteSegmentResult[] runNativeRouting(RoutingContext c, RouteRegion[] regions, boolean basemap) { // config.router.printRules(System.out); - return nativeRouting(new int[] { sx31, sy31, ex31, ey31 }, config, config.initialDirection == null ? -360 : config.initialDirection.floatValue(), - regions, progress, precalculatedRouteDirection, basemap, publicTransport, startTransportStop, targetTransportStop); + return nativeRouting(c, c.config.initialDirection == null ? -360 : c.config.initialDirection.floatValue(), + regions, basemap); } @@ -162,10 +159,7 @@ public class NativeLibrary { protected static native RouteDataObject[] getRouteDataObjects(RouteRegion reg, long rs, int x31, int y31); - protected static native RouteSegmentResult[] nativeRouting(int[] coordinates, RoutingConfiguration r, - float initDirection, RouteRegion[] regions, RouteCalculationProgress progress, - PrecalculatedRouteDirection precalculatedRouteDirection, boolean basemap, - boolean publicTransport, boolean startTransportStop, boolean targetTransportStop); + protected static native RouteSegmentResult[] nativeRouting(RoutingContext c, float initDirection, RouteRegion[] regions, boolean basemap); protected static native NativeTransportRoutingResult[] nativeTransportRouting(int[] coordinates, TransportRoutingConfiguration cfg, RouteCalculationProgress progress); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index 03b49df3e5..fb5f73c460 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -349,8 +349,8 @@ public class RoutePlannerFrontEnd { } if (gctx.distFromLastPoint(startPoint) > 1) { gctx.routeGapDistance += gctx.distFromLastPoint(startPoint); - System.out.println(String.format("????? gap of route point = %f, gap of actual gpxPoint = %f ", - gctx.distFromLastPoint(startPoint), gctx.distFromLastPoint(pnt.loc))); + System.out.println(String.format("????? gap of route point = %f, gap of actual gpxPoint = %f, %s ", + gctx.distFromLastPoint(startPoint), gctx.distFromLastPoint(pnt.loc), pnt.loc)); } gctx.res.addAll(pnt.routeToTarget); i = pnt.targetInd; @@ -784,8 +784,12 @@ public class RoutePlannerFrontEnd { if (ctx.nativeLib != null) { ctx.startX = start.preciseX; ctx.startY = start.preciseY; + ctx.startRoadId = start.road.id; + ctx.startSegmentInd = start.segStart; ctx.targetX = end.preciseX; ctx.targetY = end.preciseY; + ctx.targetRoadId = end.road.id; + ctx.targetSegmentInd = end.segStart; return runNativeRouting(ctx, recalculationEnd); } else { refreshProgressDistance(ctx); @@ -850,9 +854,7 @@ public class RoutePlannerFrontEnd { ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY); // long time = System.currentTimeMillis(); - RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx.startX, ctx.startY, ctx.targetX, ctx.targetY, - ctx.config, regions, ctx.calculationProgress, ctx.precalculatedRouteDirection, ctx.calculationMode == RouteCalculationMode.BASE, - ctx.publicTransport, ctx.startTransportStop, ctx.targetTransportStop); + RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx, regions, ctx.calculationMode == RouteCalculationMode.BASE); // log.info("Native routing took " + (System.currentTimeMillis() - time) / 1000f + " seconds"); ArrayList result = new ArrayList(Arrays.asList(res)); if (recalculationEnd != null) { @@ -924,13 +926,7 @@ public class RoutePlannerFrontEnd { List res = searchRouteInternalPrepare(local, points.get(i), points.get(i + 1), routeDirection); makeStartEndPointsPrecise(res, points.get(i).getPreciseLatLon(), points.get(i + 1).getPreciseLatLon(), null); results.addAll(res); - if(ctx.calculationProgress != null) { - ctx.calculationProgress.distinctLoadedTiles += local.calculationProgress.distinctLoadedTiles; - ctx.calculationProgress.loadedTiles += local.calculationProgress.loadedTiles; - ctx.calculationProgress.loadedPrevUnloadedTiles += local.calculationProgress.loadedPrevUnloadedTiles; - } ctx.routingTime += local.routingTime; - // local.unloadAllData(ctx); if (restPartRecalculatedRoute != null) { results.addAll(restPartRecalculatedRoute); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java index e888ad1d59..46eda15f90 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java @@ -51,14 +51,16 @@ public class RoutingContext { // 1. Initial variables public int startX; public int startY; + public long startRoadId; + public int startSegmentInd; public boolean startTransportStop; public int targetX; public int targetY; + public long targetRoadId; + public int targetSegmentInd; public boolean targetTransportStop; + public boolean publicTransport; - // deprecated - public long firstRoadId; - public int firstRoadDirection; public RouteCalculationProgress calculationProgress; public boolean leftSideNavigation; @@ -187,12 +189,16 @@ public class RoutingContext { public void initStartAndTargetPoints(RouteSegment start, RouteSegment end) { initTargetPoint(end); startX = start.road.getPoint31XTile(start.getSegmentStart()); - startY = start.road.getPoint31YTile(start.getSegmentStart()); + startY = start.road.getPoint31YTile(start.getSegmentStart()); + startRoadId = start.road.getId(); + startSegmentInd = start.getSegmentStart(); } public void initTargetPoint(RouteSegment end) { targetX = end.road.getPoint31XTile(end.getSegmentStart()); targetY = end.road.getPoint31YTile(end.getSegmentStart()); + targetRoadId = end.road.getId(); + targetSegmentInd = end.getSegmentStart(); } public void unloadAllData() { From 9052ccc09961bad1a2635c4e4c58e90374359f2b Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Fri, 10 Jul 2020 10:57:19 +0000 Subject: [PATCH 071/551] Translated using Weblate (French) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-fr/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 4261dd28db..805fa38ba4 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3798,4 +3798,8 @@ Télécharger les cartes Wikipédia Scooter Moto enduro + Kart + Note OSM fermée + Fauteuil roulant + Fauteuil roulant vers l\'avant \ No newline at end of file From 921515b965bed54ceda43daa3d87108e5b747c1c Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 10 Jul 2020 20:52:24 +0000 Subject: [PATCH 072/551] Translated using Weblate (German) Currently translated at 99.9% (3419 of 3420 strings) --- OsmAnd/res/values-de/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index c177aba730..f0c311d795 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3823,4 +3823,7 @@ Informationen über Sehenswürdigkeiten erhalten Sie bei Wikipedia. Es ist Ihr Offline-Wegweiser für die Hosentasche - aktivieren Sie einfach das Wikipedia-Modul und genießen Sie Artikel über Objekte in Ihrer Umgebung. Enduro Motorroller + Rollstuhl + Go-Kart + Geschlossene OSM-Notiz \ No newline at end of file From 5221d7393a974849084f93abf9d569f217fd94b1 Mon Sep 17 00:00:00 2001 From: solokot Date: Fri, 10 Jul 2020 13:58:17 +0000 Subject: [PATCH 073/551] Translated using Weblate (Russian) Currently translated at 99.9% (3417 of 3420 strings) --- OsmAnd/res/values-ru/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index e38d45dd1c..d5774eafc4 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -3815,4 +3815,5 @@ Скачать карты Википедии Эндуро мотоцикл Мотороллер + Закрытая заметка OSM \ No newline at end of file From 7a4a689e12b2218eaab88c8cdfd3c1412a7461cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Fri, 10 Jul 2020 15:45:18 +0000 Subject: [PATCH 074/551] Translated using Weblate (Turkish) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-tr/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 71c495c709..268467dae2 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -3771,4 +3771,8 @@ Wikipedia\'dan ilgi çekici yerler hakkında bilgi alın. Bu sizin çevrim dışı cep rehberinizdir - sadece Wikipedia eklentisini etkinleştirin ve etrafınızdaki nesneler hakkında makalelerin tadını çıkarın. Enduro motosiklet Küçük motosiklet + Tekerlekli sandalye + İleri tekerlekli sandalye + Go-kart + Kapatılmış OSM Notu \ No newline at end of file From 1acecb5cb3e4535641bbbe39b0c2a38b4dd85b68 Mon Sep 17 00:00:00 2001 From: Athoss Date: Fri, 10 Jul 2020 16:16:17 +0000 Subject: [PATCH 075/551] Translated using Weblate (Hungarian) Currently translated at 99.5% (3403 of 3420 strings) --- OsmAnd/res/values-hu/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index ce0242574b..0cf54ee018 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -3767,4 +3767,9 @@ \nAz előfizetéseit a Google Play beállításainál tudja kezelni és lemondani. Törli az útvonal soron következő célpontját. Amennyiben ez a végző célpont, a navigáció megáll. Szerezzen információt az érdekes helyekkel kapcsolatban a Wikipédiáról. Ez az ön offline zseb útikönyve - egyszerűen engedélyezze a Wikipédia bővítményt és élvezze az ön körül lévő objektumokról szóló cikkeket. + Salakmotor + Robogó + Kerekesszék + Gokart + Lezárt OSM-jegyzet \ No newline at end of file From bd02d9595cd3cb3e25eabf7b86b5fea9c12ec201 Mon Sep 17 00:00:00 2001 From: ace shadow Date: Fri, 10 Jul 2020 20:34:16 +0000 Subject: [PATCH 076/551] Translated using Weblate (Slovak) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-sk/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index f5e8919fc8..b41cf8721c 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -3812,4 +3812,10 @@ Aktuálny cieľový bod na trase bude vymazaný. Ak je to posledný cieľ, navigácia sa zastaví. Stiahnuť mapy Wikipédia Získajte informácie o bodoch záujmu z Wikipédie. Je to váš vreckový sprievodca - zapnite modul Wikipédia a užívajte si články o objektoch okolo vás. + Enduro motorka + Skúter + Invalidný vozík + Invalidný vozík dopredu + Motokára + Zatvorená OSM poznámka \ No newline at end of file From 18d81b9053ca95a90a2cd7bf52b3bbe1339b293d Mon Sep 17 00:00:00 2001 From: D M Date: Fri, 10 Jul 2020 17:06:55 +0000 Subject: [PATCH 077/551] Translated using Weblate (Serbian) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-sr/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-sr/strings.xml b/OsmAnd/res/values-sr/strings.xml index 0d73885ba5..7a19f27534 100644 --- a/OsmAnd/res/values-sr/strings.xml +++ b/OsmAnd/res/values-sr/strings.xml @@ -3813,4 +3813,8 @@ Информације о тачкама од интереса потражите од Википедије. То је ваш џепни ванмрежни водич - само омогућите додатак Википедиа и уживајте у чланцима о објектима око вас. Ендуро скутер Скутер + Инвалидска колица + Инвалидска колица напред + Корпа + Затворена ОСМ белешка \ No newline at end of file From 26e4e91bf0a4e9d978bdaf6002755cc7c724f906 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Fri, 10 Jul 2020 14:55:49 +0000 Subject: [PATCH 078/551] Translated using Weblate (Hebrew) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-iw/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index fed119f881..ba88963918 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -3824,4 +3824,8 @@ קבלת מידע על נקודות עניין מוויקיפדיה. מדריך הכיס הפרטי שלך - עליך פשוט להפעיל את התוסף של ויקיפדיה וליהנות מערכים על מה שסביבך. אופנוע שטח טוסטוס + כסא גלגלים + כסא גלגלים ספורטיבי + קארטינג + הערת OSM סגורה \ No newline at end of file From e2880375d41810d7df5a4a195cec60f48ea907fe Mon Sep 17 00:00:00 2001 From: Ahmad Alfrhood Date: Fri, 10 Jul 2020 11:40:51 +0000 Subject: [PATCH 079/551] Translated using Weblate (Arabic) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-ar/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index e56073c6c8..21346619a7 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -3806,4 +3806,8 @@ الحصول على معلومات حول النقاط المثيرة للاهتمام من ويكيبيديا. إنه دليلك غير المتصل بجيبك - ما عليك سوى تمكين المكون الإضافي ويكبيديا والاستمتاع بمقالات حول الكائنات من حولك. دراجة نارية سكوتر موتور + منحدرات للأمام + منحدرات + عربة التسوق + أغلق ملاحظة OSM \ No newline at end of file From 6f9a9fd6edc0ac3e3def92c195c4c7df1f4576b5 Mon Sep 17 00:00:00 2001 From: Kars de Jong Date: Fri, 10 Jul 2020 21:30:41 +0000 Subject: [PATCH 080/551] Translated using Weblate (Dutch) Currently translated at 98.0% (3736 of 3812 strings) --- OsmAnd/res/values-nl/phrases.xml | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/OsmAnd/res/values-nl/phrases.xml b/OsmAnd/res/values-nl/phrases.xml index f2cbdafc8d..65a281ce68 100644 --- a/OsmAnd/res/values-nl/phrases.xml +++ b/OsmAnd/res/values-nl/phrases.xml @@ -3706,4 +3706,47 @@ Meiler Noodhulpkist Faciliteiten voor pijpleidingen + Parkeerplaats + Graf + Soort klooster: reguliere orde + Soort klooster: kluizenaars + Soort klooster: kanunniken + Soort klooster: convent + Soort klooster: monniken + Nee + Ja + Voetenbad + Meer + Rivier + Thermisch + Hamam + Onsen + Warmwaterbron + Postbank + Girokaart + Migros bank + Postfinance card + Geldopname: internationaal + Geldopname: minimum aankoopbedrag + Kostenloze geldopname: ja + Kostenloze geldopname: nee + Geldopname: zonder aankoop + Geldopname: bij aankoop + Munteenheid + Opnamelimiet + Geldopname via: zelfbedieningskassa + Geldopname via: kassa + Uitbatende organisatie van geldopname + Geldopname + Geldopname: ja + Huisdierverzorging + Tarief + Meubelmaker + Bakkerij + Vloerenlegger + Schrijnwerker + Destilleerderij + Aannemer + Health food + Kelderingang \ No newline at end of file From 366b8665703222e09889fab14062b6b1eabcb191 Mon Sep 17 00:00:00 2001 From: Franco Date: Sat, 11 Jul 2020 00:41:57 +0000 Subject: [PATCH 081/551] Translated using Weblate (Spanish (Argentina)) Currently translated at 99.9% (3419 of 3420 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index cc21120a15..afdc93674d 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -3821,4 +3821,7 @@ Obtén información sobre los puntos de interés de Wikipedia. Es tu guía de bolsillo sin conexión - sólo activa el complemento de Wikipedia y disfruta los artículos sobre los objetos de alrededor. Motocicleta de enduro Motoneta (motor) + Silla de ruedas + Go-kart + Nota de OSM cerrada \ No newline at end of file From 6fcdd5e987acf36f87ce20dd9b7cda8aff62cd18 Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Fri, 10 Jul 2020 17:09:00 +0000 Subject: [PATCH 082/551] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 286117a1e0..3b0b437c87 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -3803,4 +3803,8 @@ Pôr do Sol: %2$s Obter informações sobre pontos de interesse da Wikipédia. É o seu guia de bolso off-line - só ativar o complemento Wikipédia e desfrutar de artigos sobre os elementos ao seu redor. Motocicleta enduro Motoneta + Cadeira de rodas + Cadeira de rodas para a frente + Carrinho de compras + Nota OSM fechada \ No newline at end of file From 1b3899cf4546acc1b341800dc8b21bfb095f9bd2 Mon Sep 17 00:00:00 2001 From: D M Date: Fri, 10 Jul 2020 22:22:20 +0000 Subject: [PATCH 083/551] Translated using Weblate (Serbian) Currently translated at 85.4% (3259 of 3812 strings) --- OsmAnd/res/values-sr/phrases.xml | 346 +++++++++++++++++++++++++++++++ 1 file changed, 346 insertions(+) diff --git a/OsmAnd/res/values-sr/phrases.xml b/OsmAnd/res/values-sr/phrases.xml index b220869840..001ca0a730 100644 --- a/OsmAnd/res/values-sr/phrases.xml +++ b/OsmAnd/res/values-sr/phrases.xml @@ -2933,4 +2933,350 @@ Плотун експлозија: прва детонација плотун теста Куглање Мрежа + Продаја: половна + Продаја: да, половна + Продаја: не + Продаја + Штандови + Рептили + Соколарник + Птичник + Птице + Сафари парк + Кућиште + Парк дивљих животиња + Зоолошки врт са мажењем животиња + Животни прстен + Школа страних језика + Музичка школа + Дечији камп + Поправка електронике: ТВ + Поправка електронике: телефон + Поправка електронике: апарати + Поправка електронике: рачунари + Канцеларија снабдевача енергије + Вино: сервирано + Вино: малопродаја + Вино: да + Да + Заједнички радни простор + Теретна станица + Конструкција: скривена + Конструкција: купола + Конструкција: тањир + Конструкција: самостојећа + Конструкција: решетка + Тип: отворена штала + Бушеншанк + Затворено + Отворено + Видљивост: подручје + Видљивост: улица + Видљивост: кућа + Локација: улаз + Локација: зид + Локација: мост + Локација: платформа + Локација: унутар + Локација: напољу + Локација: врх крова + Локација: кров + Локација: изнад главе + Локација: надземље + Локација: подводна + Локација: подземна + Метална мрежа + Декотрава + Вештачка трава + Тартан + Глина + Планинско подручје + Кулуар + Клисура + ВХФ канал + Законодавна институција + Транспортна институција + Благајна + Социјалне услуге + Социјално осигурање + Јавни сервис + Министарство + Архива + Мрежа + Кану: не + Кану: да + Кајаци: не + Кајаци: да + Гумењак: не + Гумењак: да + Једрењаци: не + Једрењаци: да + Џетски: не + Џетски: да + Бродови на веслање: не + Бродови на веслање: да + Кућни бродови: не + Кућни бродови: да + Моторни бродови: не + Моторни бродови: да + Тип: ограђен део + Чување животиња: овца + Чување животиња: коњ + Чување животиња + Литица + Фото студио + Додаци исхрани + Локомотива + Продавница електронских цигарета + Бинго + Клађење + Слот машине + Пацинко + Лутрија + Врста + Место коцкања + Лото срећке + Опрема за расвету + Браварска продавница + Електро продавница + Намирнице за забаву + Место за исхрану животиња + Кантонска + Пастел + Суб + Сагардотегиа + Чај са мехурићима + Брасери + Емпанада + Предјело + Пиадина + Кантина + Слане палачинке + Замрзнути јогурт + Деликатеси + Фина јела + Соба + Багел + Хеуригер + Гастропуб + Гиудон + Риба и помфрит + Тип: метални орман + Тип: дрвени ормар + Тип: кутија за читање + Тип: телефонска кутија + Јавна полица за књиге + Божић: вебсајт + Божић: локација + Божић: радно време + Божић: белешка + Божић: период догађаја + Јелка + Продавница дрвећа + Божићна радња + Божићна пирамида + Божићно тржиште + Божићни догађај + Божић + Википедија + Дужина + Одлагање тоалета: кантом + Одлагање тоалета: хемијско + Одлагање тоалета: питлатрине + Одлагање тоалета: испирање + Резервоар за воду + Противпожарни оператор + Висока комисија + Резиденција амбасадора + Делегација + Стална мисија + Почасни конзулат + Генерални конзулат + Конзулат + Саобраћајно огледало + Једино + Не + Да + Минимална старост + Главни дистрибуциони оквир + Аквакултура: дагње + Аквакултура: риба + Аквакултура: шкампи + Аквакултура + Приказ информација путницима: не + Приказ информација путницима: да + Подршка: кула + Подршка: кров + Подршка: носеће + Подршка: плафон + Подршка: билбord + Подршка: земља + Подршка: постоље + Подршка: дрво + Подршка: зид + Подршка: стуб + Приказ датума: не + Приказ датума + Хигрометар: не + Капацитет (кревета) + ХигрометарHygrometer + Термометар: не + Термометар + Сунчани сат + Дигитални екран + Аналогни екран + Пумпна станица + Екран: не + Екран: да + Излаз: биогас + Излазна снага биогаса + Излаз: вакуум + Излаз: компримовани ваздух + Излаз: хладна вода + Излаз: врућ ваздух + Излаз: пара + Излаз: топла вода + Излаз (струја): не + Излаз: струја + Напон + Стакленичка хортикултура + Гравитациона + Метеоролошка + Употреба: шпијунажа + Употреба: истраживање + Употреба: шпијунажа + Употреба: образовање + Спектар + Пречник + Гама + Радио + Оптички + Телескоп + Картица \"Тројка\" се не прихвата + Тројка + Статус пумпе: закључана + Статус пумпе: поломљена + Статус пумпе: у реду + Стил пумпе: историјски + Стил пумпе: модеран + Тип пумпе: гравитациона + Тип пумпе: Индија Мк II или III> + Тип пумпе: пумпа снопа + Вентилациони отвор + Балка + Приватни + Јавни + Регионални + Међународни + Испорука: не + Да + Надзор прелаза: камера + Надзор прелаза: полазник + Надзор прелаза: не + Надзор прелаза + Прелазни салтир: не + Прелазни салтир + Прелаз на захтев: не + Прелаз на захтев + Прелазно светло: не + Прелазно светло + Прелазно звоно: не + Прелазно звоно + Прелазна баријера: дупло половична + Прелазна баријера: половична + Прелазна баријера: пуна + Прелазна баријера + Прелазна баријера: не + Активирање прелаза: даљинско + Активирање прелаза: локално + Активирање прелаза: аутоматско + Рекреациони центар + Летњи камп + Покварена гомила + Одређено + Со: не + Со + Дубина + Улично постоље + Бицикл дрво + Ормарићи + Војни контролни пункт + Тип кабинета: улична расвета + Тип кабинета: водоводни + Тип кабинета: отпади + Тип кабинета: поштански + Тип кабинета: гасни + Тип кабинета: кабловска телевизија + Тип кабинета: телекомски + Тип кабинета: енергетски + У употреби: да + Цистерна + Ток + Понд + Главни + Стил хидранта: wsh + Подземни + Улица + Паркинг + Трака + Зелена + Тротоар + Капацитет протока хидранта + Број хидранта + Притисак хидранта + Пречник хидранта + Канцеларија бабице + Услуга неге + Канцеларија психолога + Канцеларија исцелитеља + Канцеларија подолога + Канцеларија терапеута + Лекарска ординација + СИДА: не + СИДА: да + Аутизам: не + Аутизам: да + Ебола: не + Ебола: да + Маларија: не + Маларија: да + Кућна посета: не + Да + Хитна: не + Хитна: да + Саветовање: не + Саветовање: да + Болничке услуге: само + Болничке услуге: не + Болничке услуге: да + Предвиђено за дечаке: не + Предвиђено за дечаке: да + Предвиђено за мушкарце: не + Предвиђено за мушкарце: да + Предвиђено за девојке: не + Предвиђено за девојке: да + Предвиђено за старије особе: не + Предвиђено за старије особе: да + Предвиђено за жене: не + Предвиђено за жене: да + Предвиђено за одрасле: не + Предвиђено за одрасле: да + Предвиђено за децу: не + Предвиђено за децу: да + Предвиђено за малишане: не + Предвиђено за малишане: да + Предвиђено за новорођенчад: не + Предвиђено за новорођенчад: да + Саветовање (насиље): не + Саветовање (насиље): да + Саветовање (жртве): не + Саветовање (жртве): да + Саветовање (сексуално злостављање): не + Саветовање (сексуално злостављање): да + Саветовање (сексуално): не + Саветовање (сексуално): да + Саветовање (рехабилитација): не + Саветовање (рехабилитација): да + Саветовање (исхрана): не + Саветовање (исхрана): да \ No newline at end of file From 9069f1bb53fd345dad4893bfc52780f68bd14c4a Mon Sep 17 00:00:00 2001 From: Kars de Jong Date: Fri, 10 Jul 2020 21:03:46 +0000 Subject: [PATCH 084/551] Translated using Weblate (Dutch) Currently translated at 96.9% (3314 of 3420 strings) --- OsmAnd/res/values-nl/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 5a863ecedb..8823108ba9 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -3709,4 +3709,8 @@ Wikipedia-kaarten downloaden Motorscooter Enduromotor + Rolstoel + Rolstoel vooraanzicht + Opgeloste OSM-notitie + Kart \ No newline at end of file From 6e72be0af25f90f2ff5861b9945fad4140581d65 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Fri, 10 Jul 2020 20:13:33 +0000 Subject: [PATCH 085/551] Translated using Weblate (French) Currently translated at 98.8% (264 of 267 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/fr/ --- OsmAnd-telegram/res/values-fr/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd-telegram/res/values-fr/strings.xml b/OsmAnd-telegram/res/values-fr/strings.xml index e010baf46b..6f2116c625 100644 --- a/OsmAnd-telegram/res/values-fr/strings.xml +++ b/OsmAnd-telegram/res/values-fr/strings.xml @@ -248,4 +248,6 @@ Partager la position Afficher sur la carte Vous avez besoin d\'un compte Telegram enregistré et d\'un numéro de téléphone + OsmAnd Online GPS Tracker + Sélectionnez l’un des services de localisation pour partager votre position. \ No newline at end of file From 4e7433ab120264081630ffa626c883cd85485ffa Mon Sep 17 00:00:00 2001 From: Yldun Date: Fri, 10 Jul 2020 19:38:34 +0000 Subject: [PATCH 086/551] Translated using Weblate (French) Currently translated at 98.8% (264 of 267 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/fr/ --- OsmAnd-telegram/res/values-fr/strings.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OsmAnd-telegram/res/values-fr/strings.xml b/OsmAnd-telegram/res/values-fr/strings.xml index 6f2116c625..9ebff1a4d8 100644 --- a/OsmAnd-telegram/res/values-fr/strings.xml +++ b/OsmAnd-telegram/res/values-fr/strings.xml @@ -250,4 +250,18 @@ Vous avez besoin d\'un compte Telegram enregistré et d\'un numéro de téléphone OsmAnd Online GPS Tracker Sélectionnez l’un des services de localisation pour partager votre position. + OsmAnd Tracker vous permet de partager votre position et voir celle des autres dans OsmAnd.

Cette application utilise l\'API de Telegram, et donc vous avez besoin d\'un compte Telegram.
+ Vous avez besoin d\'installer la version gratuite ou payante d\'OsmAnd d\'abord + OsmAnd Tracker s\'exécute en arrière-plan, écran éteint. + Merci d\'activer la géolocalisation dans les paramètres du système + Numéro de téléphone au format international + Numéro de téléphone + Recherche : groupe ou contact + Sélectionner les contacts et les groupes avec lesquels vous souhaitez partager votre position. + Définir l\'heure + Heure visible par tous + Rendre l\'heure visible par tous + Définir l\'intervalle minimum pour partager sa position. + La dernière fois qu\'un contact s\'est déplacé. + Cacher les contacts qui ne se sont pas déplacés depuis un temps donné. \ No newline at end of file From 58e37866f61a129a45f9c07c8aa9a16f10dea5c6 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Sat, 11 Jul 2020 19:13:09 +0300 Subject: [PATCH 087/551] Fix #9425 --- OsmAnd/AndroidManifest.xml | 1 + OsmAnd/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 5a0082b792..e1508f6ba2 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -955,6 +955,7 @@ android:process="net.osmand.plus" android:label="@string/process_navigation_service" android:name="net.osmand.plus.NavigationService" + android:foregroundServiceType="location" android:stopWithTask="false"> diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 79c1027c84..714b85eae8 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -22,8 +22,8 @@ task printc { } android { - compileSdkVersion 28 - buildToolsVersion "28.0.3" + compileSdkVersion 29 + buildToolsVersion "29.0.3" // compileNdkVersion "android-ndk-r17b" signingConfigs { From 9c100a0552e1399ec19f7cf49a77e58b5ff82f5a Mon Sep 17 00:00:00 2001 From: max-klaus Date: Sat, 11 Jul 2020 19:44:35 +0300 Subject: [PATCH 088/551] Fix #9412 --- OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java index 4b1471a396..6629228696 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java @@ -682,7 +682,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable if (subtype != null) { PoiCategory c = subtype.getCategory(); String typeName = subtype.getKeyName(); - if (!getAcceptedSubtypes(c).contains(typeName)) { + Set acceptedSubtypes = getAcceptedSubtypes(c); + if (acceptedSubtypes != null && !acceptedSubtypes.contains(typeName)) { LinkedHashSet typeNames = acceptedTypesOrigin.get(c); if (typeNames == null) { typeNames = new LinkedHashSet<>(); From 8048f2fd2cfd258da87c97117baadaea7f36d8dd Mon Sep 17 00:00:00 2001 From: ssantos Date: Sat, 11 Jul 2020 15:18:41 +0000 Subject: [PATCH 089/551] Translated using Weblate (German) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-de/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index f0c311d795..80666c5ffd 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3826,4 +3826,5 @@ Rollstuhl Go-Kart Geschlossene OSM-Notiz + Rollstuhl vorwärts \ No newline at end of file From 307de23ee1e3a61930f4b00e99c2da0df2d235c3 Mon Sep 17 00:00:00 2001 From: Artem Date: Sat, 11 Jul 2020 13:18:15 +0000 Subject: [PATCH 090/551] Translated using Weblate (Russian) Currently translated at 99.9% (3418 of 3420 strings) --- OsmAnd/res/values-ru/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index d5774eafc4..659e2b28c2 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -3816,4 +3816,5 @@ Эндуро мотоцикл Мотороллер Закрытая заметка OSM + Инвалидная коляска \ No newline at end of file From 76a6a5135485b8cf3143778a276cb2afe142b132 Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Sat, 11 Jul 2020 13:46:28 +0000 Subject: [PATCH 091/551] Translated using Weblate (Sardinian) Currently translated at 99.6% (3408 of 3420 strings) --- OsmAnd/res/values-sc/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index cc4b7b2754..f8c3f277fc 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -3818,4 +3818,8 @@ Otene informatziones a pitzu de puntos de interesse dae Wikipedia. Est sa ghia non in lìnia tua de mantènnere in butzaca - abìlita s\'estensione Wikipedia e ispassia·ti cun sos artìculos a pitzu de sos ogetos a fùrriu de tie. Moto enduro Motorinu + Cadira a rodas cara a in antis + Cadira a rodas + Go-kart + Nota de OSM serrada \ No newline at end of file From 8fd2084a1363c21c79ddf6d5f129baddd40a718b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1ns?= Date: Sat, 11 Jul 2020 14:59:50 +0000 Subject: [PATCH 092/551] Translated using Weblate (Galician) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-gl/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-gl/strings.xml b/OsmAnd/res/values-gl/strings.xml index 9e146396df..43bb801860 100644 --- a/OsmAnd/res/values-gl/strings.xml +++ b/OsmAnd/res/values-gl/strings.xml @@ -3841,4 +3841,10 @@ Lon %2$s O punto de destino actual na ruta será eliminado. Se fora o destino, a navegación sería interrompida. Baixar mapas da Wikipedia Obter información sobre os puntos de interesse da Wikipédia. É o teu guía de peto sen conexión - só activar o complemento da Wikipédia e desfrutar dos artigos sobre os elementos ó teu redor. + Enduro + Scooter + Cadeira de rodas + Cadeira de rodas só cara adiante + Kart + Nota do OSM pechada \ No newline at end of file From 825bca755769f5e882ae7feb7be4a2216e666b85 Mon Sep 17 00:00:00 2001 From: Verdulo Date: Sat, 11 Jul 2020 21:29:29 +0000 Subject: [PATCH 093/551] Translated using Weblate (Esperanto) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-eo/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index 0933178823..47ab66dfe5 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -3814,4 +3814,10 @@ La markita celo de la kurso estos forigita. Se tio ĉi estos la fina celo, la navigado ĉesos. Elŝuti vikipediajn mapojn Akiru informojn pri interesaj punktoj el Vikipedio. Gvidilo en via poŝo – aktivigu la kromprogramon Vikipedio por ricevi artikolojn pri proksimaj objektoj. + Motorciklo (enduro) + Motorciklo (skotero) + Rulseĝo + Rulseĝo (klinita) + Gokarto + Fermita OSM‑rimarko \ No newline at end of file From 538ba02bf4f356d1d181c257ea51437eafd59b73 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Sat, 11 Jul 2020 02:15:39 +0000 Subject: [PATCH 094/551] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 9dc5ab36ad..88c644aee8 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -3811,4 +3811,8 @@ 從維基百科取得關於興趣點的資訊。這是您的離線口袋指南 ── 只要啟用維基百科外掛程式並享受有關於您周圍景點的文章。 耐力賽摩托車 小型摩托車 + 輪椅 + 輪椅向前 + 卡丁車 + 已關閉的 OSM 註記 \ No newline at end of file From d03cc665a6eeaee66d3cf6e07e4aa40d031cd55e Mon Sep 17 00:00:00 2001 From: D M Date: Sat, 11 Jul 2020 21:31:21 +0000 Subject: [PATCH 095/551] Translated using Weblate (Serbian) Currently translated at 94.3% (3596 of 3812 strings) --- OsmAnd/res/values-sr/phrases.xml | 352 +++++++++++++++++++++++++++++++ 1 file changed, 352 insertions(+) diff --git a/OsmAnd/res/values-sr/phrases.xml b/OsmAnd/res/values-sr/phrases.xml index 001ca0a730..2908da2fc3 100644 --- a/OsmAnd/res/values-sr/phrases.xml +++ b/OsmAnd/res/values-sr/phrases.xml @@ -3279,4 +3279,356 @@ Саветовање (рехабилитација): да Саветовање (исхрана): не Саветовање (исхрана): да + Атол + Донација крви + Медицинска лабораторија + Велепродаја + Производња кондиторских производа + Теренско прикупљање + Уређај инспекције + Вентилски групна + Вентилска + Мерна + Компресиона + Компензациона + Претварачка + Вучна + Прелазна + Индустријска + Мања дистрибуциона + Дистрибуциона + Преносна + Цевоводна подстаница + Једино + Да + Поправка обуће + Брдо + Лиценцни часови + Рушевине + Минско поље + Опасност од поплаве + Клизав пут + Опасност од лавине + Опасност од ерозије + Нуклеарна опасност + Опасност + Бесконтактно не прихвата се + Бесконтактно + Нагла појава + Продавница апарата + Крајњи датум + Стена + Курс + Електронски + Инјектор + Код + Тачка уреза + Пешачка контролна тачка + Просечан нагиб + Најнижа тачка + Највиша тачка + Ледени језик + Остатак + Полица + Стена + Ледопад + Висећи + Планински + Плимски + Излазни + Долина + Плато + Ледено поље + Ледена капа + Тежина + Број кабла + Виа ферата + Авантура пењања + Зип линија + Гуме + Осигурање + Мотор + Поправка трансмисије + Реглажа + Пригушивач + Поправка камиона + Стакло + Точкови + Електрика + Поправка каросерије + Клима уређај + Батерије + Ауто делови + Дијагностика + Продаја нових аутомобила + Кочнице + Продаја половних аутомобила + Промена уља + Ауто сервис + Играчки центар за одрасле + Забавна аркадна игра + Канцеларија за водоснабдевање + Место испоруке продавнице + Име речних брзака + Керамика + Продавница подова + Низак + Средњи + Висок + Низак + Средњи + Висок + Низак + Средњи + Висок + Низак + Средњи + Висок + Низак + Средњи + Висок + Низак + Средњи + Висок + АС / НЗС 3112 + БС 1363 + Шуко + НЕМА 14-30 + НЕМА 14-30 + НЕМА 5-20 + НЕМА 5-15Р + Тесла Роудстер + Тесла Суперпуњач + Тесла стандард + CHAdeMO + Тип 3 + Тип 2 комбо + Тип 2 + Тип 1 комбо + Тип 1 + ЦЕЕ црвена 125А + ЦЕЕ црвена 64А + ЦЕЕ црвена 32А + ЦЕЕ црвена 16А + ЦЕЕ плава + Продавница канабиса + Продавница чамаца + Продавница камина + Замрзнута храна + Тип: пашњак + Тип: трајна + Тип: прелазна + Пречник круне + Обим + Пењачке руте + Дневник врха пењања: не + Дневник врха пењања: да + Оријентација зида: СЗ + Оријентација зида: З + Оријентација зида: ЈЗ + Оријентација зида: Ј + Оријентација зида: ЈИ + Оријентација зида: И + Оријентација зида: СИ + Оријентација зида: С + Фиксна сидра: не + Фиксна сидра: да + Квалитет пењања: крх + Квалитет пењања: чврст + Стена за пењање: порфир + Стена за пењање: гнеисс + Стена за пењање: кварцит + Стена за пењање: пешчењак + Пењање на камен: гранит + Стена за пењање: кречњак + Максимална дужина пењања + Минимална дужина пењања + Дужина пењања + Соло у дубљим водама: не + Соло у дубљим водама: да + Мешовито: не + Мешовито: да + Лед: не + Лед: да + Руте на више тачака: не + Руте са више тачака: да + Традиционално: не + Традиционално: да + Горње уже: не + Горње уже: да + Балванирање: не + Балванирање: да + Спорт: не + Спорт: да + Поштански број + Трансфер новца + Центар плаћања + Стан + Кућни број + Улица + Кутија писма + Депо + Станица пуњење + Величина мапе: регија + Величина мапе: град + Величина мапе: сајт + Тип мапе: топоскопска + Тип мапе: шема + Врста мапе: улична + Врста мапе: топо + Излаз станице пуњења + Ампеража + Цена паркирања + Цена паркирања: не + Цена паркирања: да + Камион: не + Камион: да + Скутер: не + Скутер: да + Бицикл: не + Бицикл: да + Аутомобил: не + Аутомобил: да + Утичница: АС / НЗС 3112: излаз + Утичница: АС / НЗС 3112: струја + Утичница: АС / НЗС 3112 + Утичница: БС 1363: излаз + Утичница: БС 1363: струја + Утичница: БС 1363 + Утичница: Шуко: излаз + Утичница: Шуко: струја + Утичница: Шуко + Утичница: НЕМА 14-50: излаз + Утичница: НЕМА 14-50: струја + Утичница: НЕМА 14-50 + Утичница: НЕМА 14-30: излаз + Утичница: НЕМА 14-30: струја + Утичница: НЕМА 14-30 + Утичница: НЕМА 5-20: излаз + Утичница: НЕМА 5-20: струја + Утичница: НЕМА 5-20 + Утичница: НЕМА 5-15Р: излаз + Утичница: НЕМА 5-15Р: струја + Утичница: НЕМА 5-15Р + Утичница: Тесла Роудстер: излаз + Утичница: Тесла Роудстер: струја + Утичница: Тесла Роудстер + Утичница: Тесла суперпуњач: излаз + Утичница: Тесла суперпуњач: струја + Утичница: Тесла суперпуњач + Утичница: Тесла стандард: излаз + Утичница: Тесла стандард: струја + Утичница: Тесла стандард + Утичница: CHAdeMO: излаз + Утичница: CHAdeMO: струја + Утичница: CHAdeMO + Утичница: Тип 3: излаз + Утичница: Тип 3: струја + Утичница: Тип 3 + Утичница: Тип 2 комбо: излаз + Утичница: Тип 2 комбо: струја + Утичница: Тип 2 комбо + Утичница: Тип 2: излаз + Утичница: Тип 2: струја + Утичница: Тип 2 + Утичница: Тип 1 комбо: излаз + Утичница: Тип 1 комбо: струја + Утичница: Тип 1 комбо + Соцкет: Тип 1: излаз + Утичница: Тип 1: струја + Утичница: Тип 1 + Утичница: ЦЕЕ црвена 125А: излаз + Утичница: ЦЕЕ црвена 125А: струја + Утичница: ЦЕЕ црвена 125А + Утичница: ЦЕЕ црвена 64А: излаз + Утичница: ЦЕЕ црвена 64А: струја + Утичница: ЦЕЕ црвена 64А + Утичница: ЦЕЕ црвена 32А: излаз + Утичница: ЦЕЕ црвена 32А: струја + Утичница: ЦЕЕ црвена 32А + Утичница: ЦЕЕ црвена 16А: излаз + Утичница: ЦЕЕ црвена 16А: струја + Утичница: ЦЕЕ црвена 16А + Утичница: ЦЕЕ плава: излаз + Утичница: ЦЕЕ плава: струја + Утичница: ЦЕЕ плава + Флаширана вода + Резервоар за воду + Превоз воде + Бушотина + Пумпа + Текућа вода + Цевовод + Бунар + Акватаблете + Обрнута осмоза + Хлор + Нема + Трајност воденог места: хитно + Трајност воденог места: издржљива + Потребно одржавање + Прекинуто + Ограничен + Локација: киоск + Изнајмљивање чамаца + Кревети + Резервација: само чланови + Резервација: не + Резервација: да + Резервације: препоручује се + Резервација: обавезна + Зимска соба: не + Зимска соба: да + Правац: сви + Правац: излаз + Правац: улаз + Правац: надоле + Правац: нагоре + Правац: супротно од казаљке на сату + Правац: у смеру казаљке на сату + Правац: уназад + Правац: напред + Правац: север-северозапад + Правац: северозапад + Правац: запад-северозапад + Правац: запад + Правац: запад-југозапад + Правац: југозапад + Правац: југ-југозапад + Правац: југ + Правац: југ-југоисток + Правац: југоисток + Правац: исток-југоисток + Правац: исток + Правац: исток-североисток + Правац: североисток + Правац: север-североисток + Правац: север + Свемирска лука + Пуштање: не + Пуштање: да + Усвајање: не + Усвајање: да + Власник + Стандардни + Дуалспорт + Ван пута + Чопер + Спортски моторцикл + Скутер + Мото одећа: не + Мото одећа + Гуме: не + Гуме + Делови: не + Делови + Поправака: не + Поправка + Изнајмљивање: не + Изнајмљивање + Да + Ознака земље + Природни споменик + Брига о деци + Путарина \ No newline at end of file From d592736252b362fe8ca2ad18e38da20c282c44c1 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 12 Jul 2020 23:29:11 +0200 Subject: [PATCH 096/551] Support sharing native context and passing road id to native (to speed up search) --- .../main/java/net/osmand/NativeLibrary.java | 2 ++ .../osmand/router/RoutePlannerFrontEnd.java | 4 ++++ .../osmand/router/RouteResultPreparation.java | 2 +- .../java/net/osmand/router/RoutingContext.java | 18 +++++++++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java b/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java index 60a5b3dd10..0189d38378 100644 --- a/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java +++ b/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java @@ -153,6 +153,8 @@ public class NativeLibrary { protected static native NativeRouteSearchResult loadRoutingData(RouteRegion reg, String regName, int regfp, RouteSubregion subreg, boolean loadObjects); + public static native void deleteNativeRoutingContext(long handle); + protected static native void deleteRenderingContextHandle(long handle); protected static native void deleteRouteSearchResult(long searchResultHandle); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index fb5f73c460..eb1d3b9352 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -217,6 +217,7 @@ public class RoutePlannerFrontEnd { if (gctx.ctx.calculationProgress == null) { gctx.ctx.calculationProgress = new RouteCalculationProgress(); } + gctx.ctx.keepNativeRoutingContext = true; List gpxPoints = generageGpxPoints(points, gctx); GpxPoint start = null; GpxPoint prev = null; @@ -281,6 +282,7 @@ public class RoutePlannerFrontEnd { if(gctx.ctx.calculationProgress != null) { gctx.ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate; } + gctx.ctx.deleteNativeRoutingContext(); BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx); calculateGpxRoute(gctx, gpxPoints); if (!gctx.res.isEmpty()) { @@ -538,6 +540,8 @@ public class RoutePlannerFrontEnd { // for native routing this is possible when point lies on intersection of 2 lines // solution here could be to pass to native routing id of the route // though it should not create any issue + System.out.println("??? not found " + start.pnt.getRoad().getId() + " instead " + + res.get(0).getObject().getId()); } } start.routeToTarget = res; diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index 9892bfb730..d7ebbaba8f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -395,7 +395,7 @@ public class RouteResultPreparation { List result = new ArrayList(); if (finalSegment != null) { ctx.routingTime += finalSegment.distanceFromStart; - println("Routing calculated time distance " + finalSegment.distanceFromStart); + // println("Routing calculated time distance " + finalSegment.distanceFromStart); // Get results from opposite direction roads RouteSegment segment = finalSegment.reverseWaySearch ? finalSegment : finalSegment.opposite.getParentRoute(); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java index 46eda15f90..922e225855 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java @@ -48,6 +48,10 @@ public class RoutingContext { public final Map> map = new LinkedHashMap>(); public final Map reverseMap = new LinkedHashMap(); + // 0. Reference to native routingcontext for multiple routes + public long nativeRoutingContext; + public boolean keepNativeRoutingContext; + // 1. Initial variables public int startX; public int startY; @@ -62,11 +66,13 @@ public class RoutingContext { public boolean publicTransport; + public RouteCalculationProgress calculationProgress; public boolean leftSideNavigation; public List previouslyCalculatedRoute; public PrecalculatedRouteDirection precalculatedRouteDirection; + // 2. Routing memory cache (big objects) TLongObjectHashMap> indexedSubregions = new TLongObjectHashMap>(); @@ -812,7 +818,17 @@ public class RoutingContext { return 0; } + public synchronized void deleteNativeRoutingContext() { + if (nativeRoutingContext != 0) { + NativeLibrary.deleteNativeRoutingContext(nativeRoutingContext); + } + nativeRoutingContext = 0; + } - + @Override + protected void finalize() throws Throwable { + deleteNativeRoutingContext(); + super.finalize(); + } } From f4d0145d59b747a571423c6ec2c8f0d5aa04ef33 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 13 Jul 2020 00:09:10 +0200 Subject: [PATCH 097/551] Fix timings --- .../src/main/java/net/osmand/router/RoutePlannerFrontEnd.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index eb1d3b9352..826a40dbb8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -671,7 +671,7 @@ public class RoutePlannerFrontEnd { res = searchRouteImpl(ctx, points, routeDirection); } if (ctx.calculationProgress != null) { - ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate; + ctx.calculationProgress.timeToCalculate += (System.nanoTime() - timeToCalculate); } BinaryRoutePlanner.printDebugMemoryInformation(ctx); if (res != null) { @@ -870,7 +870,7 @@ public class RoutePlannerFrontEnd { current = pr; } } - ctx.routingTime = ctx.calculationProgress.routingCalculatedTime; + ctx.routingTime += ctx.calculationProgress.routingCalculatedTime; return new RouteResultPreparation().prepareResult(ctx, result, recalculationEnd != null); } From b7c1fe6ba792e690db92e18fcf4dac68666865e8 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 13 Jul 2020 12:03:20 +0300 Subject: [PATCH 098/551] Remove unnecessary setters from GpxDataItem --- .../main/java/net/osmand/GPXUtilities.java | 10 ++-- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 54 +++++++------------ OsmAnd/src/net/osmand/plus/GpxDbHelper.java | 2 +- .../net/osmand/plus/helpers/ImportHelper.java | 18 ++----- .../src/net/osmand/plus/views/GPXLayer.java | 4 +- 5 files changed, 32 insertions(+), 56 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index b3c3e18e8a..200dca61dc 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1,6 +1,8 @@ package net.osmand; +import com.sun.istack.internal.NotNull; + import net.osmand.data.QuadRect; import net.osmand.util.Algorithms; @@ -1540,8 +1542,8 @@ public class GPXUtilities { return null; } - public void setGradientScaleType(GradientScaleType gradientScaleType) { - getExtensionsToWrite().put("gradient_scale_type", gradientScaleType != null ? gradientScaleType.name() : null); + public void setGradientScaleType(@NotNull GradientScaleType gradientScaleType) { + getExtensionsToWrite().put("gradient_scale_type", gradientScaleType.name()); } public GpxSplitType getSplitType() { @@ -1558,8 +1560,8 @@ public class GPXUtilities { return null; } - public void setSplitType(GpxSplitType gpxSplitType) { - getExtensionsToWrite().put("split_type", gpxSplitType != null ? gpxSplitType.name() : null); + public void setSplitType(@NotNull GpxSplitType gpxSplitType) { + getExtensionsToWrite().put("split_type", gpxSplitType.name()); } public double getSplitInterval() { diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index 16f480df10..b25bc4aefd 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -3,6 +3,7 @@ package net.osmand.plus; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.IndexConstants; @@ -198,6 +199,22 @@ public class GPXDatabase { this.color = color; } + public GpxDataItem(File file, @NonNull GPXUtilities.GPXFile gpxFile) { + this.file = file; + color = gpxFile.getColor(0); + width = gpxFile.getWidth(null); + showArrows = gpxFile.isShowArrows(); + showStartFinish = gpxFile.isShowStartFinish(); + gradientScaleType = gpxFile.getGradientScaleType(); + gradientSpeedColor = gpxFile.getGradientScaleColor(GradientScaleType.SPEED, 0); + gradientSlopeColor = gpxFile.getGradientScaleColor(GradientScaleType.SLOPE, 0); + gradientAltitudeColor = gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE, 0); + if (gpxFile.getSplitType() != null && gpxFile.getSplitInterval() != 0) { + splitType = gpxFile.getSplitType().getType(); + splitInterval = gpxFile.getSplitInterval(); + } + } + public File getFile() { return file; } @@ -215,41 +232,22 @@ public class GPXDatabase { return gradientScaleType; } - public void setGradientScaleType(GradientScaleType gradientScaleType) { - this.gradientScaleType = gradientScaleType; - } - public int getGradientSpeedColor() { return gradientSpeedColor; } - public void setGradientSpeedColor(int gradientSpeedColor) { - this.gradientSpeedColor = gradientSpeedColor; - } - public int getGradientAltitudeColor() { return gradientAltitudeColor; } - public void setGradientAltitudeColor(int gradientAltitudeColor) { - this.gradientAltitudeColor = gradientAltitudeColor; - } - public int getGradientSlopeColor() { return gradientSlopeColor; } - public void setGradientSlopeColor(int gradientSlopeColor) { - this.gradientSlopeColor = gradientSlopeColor; - } - public String getWidth() { return width; } - public void setWidth(String width) { - this.width = width; - } public long getFileLastModifiedTime() { return fileLastModifiedTime; @@ -283,26 +281,14 @@ public class GPXDatabase { return joinSegments; } - public void setJoinSegments(boolean joinSegments) { - this.joinSegments = joinSegments; - } - public boolean isShowArrows() { return showArrows; } - public void setShowArrows(boolean showArrows) { - this.showArrows = showArrows; - } - public boolean isShowStartFinish() { return showStartFinish; } - public void setShowStartFinish(boolean showStartFinish) { - this.showStartFinish = showStartFinish; - } - @Override public int hashCode() { return file != null ? file.hashCode() : 0; @@ -562,7 +548,7 @@ public class GPXDatabase { db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", new Object[] {showArrows ? 1 : 0, fileName, fileDir}); - item.setShowArrows(showArrows); + item.showArrows = showArrows; } finally { db.close(); } @@ -580,7 +566,7 @@ public class GPXDatabase { db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", new Object[] {showStartFinish ? 1 : 0, fileName, fileDir}); - item.setShowStartFinish(showStartFinish); + item.showStartFinish = showStartFinish; } finally { db.close(); } @@ -636,7 +622,7 @@ public class GPXDatabase { GPX_COL_JOIN_SEGMENTS + " = ? " + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", new Object[]{joinSegments ? 1 : 0, fileName, fileDir}); - item.setJoinSegments(joinSegments); + item.joinSegments = joinSegments; } finally { db.close(); } diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index 4f4c12c9a4..fc0ffb636e 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -189,7 +189,7 @@ public class GpxDbHelper { } private void readGpxItem(@NonNull File gpxFile, @Nullable GpxDataItem item, @Nullable GpxDataItemCallback callback) { - readingItemsMap.put(gpxFile, item != null ? item : new GpxDataItem(null, null)); + readingItemsMap.put(gpxFile, item != null ? item : new GpxDataItem(null, (GPXTrackAnalysis) null)); if (callback != null) { readingItemsCallbacks.put(gpxFile, callback); } diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java index 7bf86aff9e..36d5b9ab92 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java @@ -23,7 +23,6 @@ import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.WptPt; import net.osmand.IProgress; import net.osmand.IndexConstants; @@ -33,7 +32,7 @@ import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.plus.AppInitializer; import net.osmand.plus.CustomOsmandPlugin; import net.osmand.plus.FavouritesDbHelper; -import net.osmand.plus.GPXDatabase; +import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; @@ -1018,21 +1017,10 @@ public class ImportHelper { gpxFile.path = toWrite.getAbsolutePath(); File file = new File(gpxFile.path); if (!destinationExists) { - GPXDatabase.GpxDataItem item = new GPXDatabase.GpxDataItem(file, gpxFile.getColor(0)); - item.setWidth(gpxFile.getWidth(null)); - item.setShowArrows(gpxFile.isShowArrows()); - item.setShowStartFinish(gpxFile.isShowStartFinish()); - item.setGradientScaleType(gpxFile.getGradientScaleType()); - item.setGradientSpeedColor(gpxFile.getGradientScaleColor(GradientScaleType.SPEED, 0)); - item.setGradientSlopeColor(gpxFile.getGradientScaleColor(GradientScaleType.SLOPE, 0)); - item.setGradientAltitudeColor(gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE, 0)); + GpxDataItem item = new GpxDataItem(file, gpxFile); app.getGpxDbHelper().add(item); - - if (gpxFile.getSplitType() != null && gpxFile.getSplitInterval() != 0) { - app.getGpxDbHelper().updateSplit(item, gpxFile.getSplitType(), gpxFile.getSplitInterval()); - } } else { - GPXDatabase.GpxDataItem item = app.getGpxDbHelper().getItem(file); + GpxDataItem item = app.getGpxDbHelper().getItem(file); if (item != null) { app.getGpxDbHelper().clearAnalysis(item); } diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 4073194ea4..c9ee1b2433 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -266,7 +266,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM shadowPaint.setStrokeWidth(paint.getStrokeWidth() + 2 * shadowRadius); } for (String key : cachedTrackWidth.keySet()) { - searchTrackWidth(key, rrs, req, rc); + acquireTrackWidth(key, rrs, req, rc); } } else { log.error("Rendering attribute gpx is not found !"); @@ -284,7 +284,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM return cachedColor; } - private void searchTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) { + private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) { if (!Algorithms.isEmpty(widthKey) && Algorithms.isInt(widthKey)) { try { int widthDp = Integer.parseInt(widthKey); From 4d81d797dbaca42228bcffa8badf00d4bd1a41f9 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 13 Jul 2020 12:11:10 +0300 Subject: [PATCH 099/551] Add constant for default width multiplier --- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 4 ++-- OsmAnd/src/net/osmand/plus/views/GPXLayer.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index b25bc4aefd..d0a19e80b9 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -3,7 +3,7 @@ package net.osmand.plus; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.IndexConstants; @@ -199,7 +199,7 @@ public class GPXDatabase { this.color = color; } - public GpxDataItem(File file, @NonNull GPXUtilities.GPXFile gpxFile) { + public GpxDataItem(File file, @NonNull GPXFile gpxFile) { this.file = file; color = gpxFile.getColor(0); width = gpxFile.getWidth(null); diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index c9ee1b2433..7cc2e97f63 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -75,6 +75,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private static final Log log = PlatformUtil.getLog(GPXLayer.class); private static final double TOUCH_RADIUS_MULTIPLIER = 1.5; + private static final int DEFAULT_WIDTH_MULTIPLIER = 7; private static final int START_ZOOM = 7; private OsmandMapTileView view; @@ -225,7 +226,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM if (hash != cachedHash) { cachedHash = hash; cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track); - defaultTrackWidth = 7 * view.getDensity(); + defaultTrackWidth = DEFAULT_WIDTH_MULTIPLIER * view.getDensity(); if (rrs != null) { RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); From 7a18f2e5cada96d5e3819a5437bbdb3c673d5707 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 13 Jul 2020 12:29:56 +0300 Subject: [PATCH 100/551] Remove unnecessary annotations --- OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 4cd237fc66..3498450ab4 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1,7 +1,6 @@ package net.osmand; -import com.sun.istack.internal.NotNull; import net.osmand.data.QuadRect; import net.osmand.util.Algorithms; @@ -1541,7 +1540,7 @@ public class GPXUtilities { return null; } - public void setGradientScaleType(@NotNull GradientScaleType gradientScaleType) { + public void setGradientScaleType(GradientScaleType gradientScaleType) { getExtensionsToWrite().put("gradient_scale_type", gradientScaleType.name()); } @@ -1559,7 +1558,7 @@ public class GPXUtilities { return null; } - public void setSplitType(@NotNull GpxSplitType gpxSplitType) { + public void setSplitType(GpxSplitType gpxSplitType) { getExtensionsToWrite().put("split_type", gpxSplitType.name()); } From a89ec4b10eb8ebceab452b726b94b2e210775704 Mon Sep 17 00:00:00 2001 From: MadWasp79 Date: Mon, 13 Jul 2020 18:17:11 +0300 Subject: [PATCH 101/551] fix for osmand_ele tags as text --- .../net/osmand/binary/RouteDataObject.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java index c5f713cdf6..bfe638d394 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java @@ -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]; + } } } From 79c59ee709383ae229d5b6a75af89369d33f4b60 Mon Sep 17 00:00:00 2001 From: Athoss Date: Mon, 13 Jul 2020 11:18:16 +0000 Subject: [PATCH 102/551] Translated using Weblate (Hungarian) Currently translated at 99.5% (3404 of 3420 strings) --- OsmAnd/res/values-hu/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 0cf54ee018..70cf693f39 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -3772,4 +3772,5 @@ Kerekesszék Gokart Lezárt OSM-jegyzet + Előre döntött kerekesszék \ No newline at end of file From 8f037a569fcb450ad73debf86e94f0c4b4a292b1 Mon Sep 17 00:00:00 2001 From: Mirco Zorzo Date: Sun, 12 Jul 2020 19:20:23 +0000 Subject: [PATCH 103/551] Translated using Weblate (Italian) Currently translated at 89.5% (3062 of 3420 strings) --- OsmAnd/res/values-it/strings.xml | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index e96e07e7b5..e982579f7d 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -3787,4 +3787,38 @@ Nascondi Mapilly Mostra Mapillary Un pulsante per visualizzare nella mappa o nascondere il livello Mapillary . + Fornisci la lunghezza del tuo veicolo, alcune restrizioni di percorso potrebbero essere applicate per veicoli. + Disinstalla autovelox + Legale + PDI autovelox + In alcuni paesi o regioni, gli avvisi di presenza di autovelox sono proibiti dalla legge. +\n +\nDevi scegliere in base alle leggi del tuo paese. +\n +\nScegliendo %1$s e riceverai gli avvisi della presenza di autovelox. +\n +\nScegliendo %2$s. Tutti i dati relativi agli autovelox: avvisi, notifiche, PDI saranno cancellati fino a che OsmAnd non sarà completamente reinstallato. + Mantieni attivo + Disinstalla + Gli avvisi sulla presenza di autovelox in alcuni paesi è proibita dalla legge. + Specifica la lunghezza del veicolo permessa nei percorsi. + Lunghezza massima + Bussola + %1$s cancellato + Il riavvio è necessario per cancellare completamente i dati degli autovelox. + Disinstalla e Riavvia + Questo dispositivo non ha autovelox. + Pattini in linea + Cancella il prossimo punto di destinazione + Abilita il controllo del zoom della mappa con i pulsanti del volume del dispositivo. + Pulsanti del volume come zoom + Per favore indica un nome per il punto + Il punto di destinazione nel percorso attuale verrà cancellato. Se sarà la Destinazione la navigazione si arresterà. + Scarica mappe Wikimedia + 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. + Moto enduro + Moto scooter + Sedia a rotelle + Go-kart + Chiudi la nota OSM \ No newline at end of file From eb9703d1c356e6d1ca3fef13c2bc8d5dc27ee037 Mon Sep 17 00:00:00 2001 From: jan madsen Date: Mon, 13 Jul 2020 07:58:37 +0000 Subject: [PATCH 104/551] Translated using Weblate (Danish) Currently translated at 94.1% (3221 of 3420 strings) --- OsmAnd/res/values-da/strings.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index 0e4bf01dbe..addb268595 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -3709,4 +3709,13 @@ Repræsenterer område: %1$s x %2$s Vis/skjul Mapillary Skjul Mapillary Vis Mapillary + Slet næste destinationspunkt + Lydstyrkeknapper som zoom + Angiv et navn til punktet + Hent Wikipedia-kort + Enduro motorcykel + Scooter + Kørestol + Go cart + Lukket OSM-note \ No newline at end of file From f681bc527346e4f95ac8a3044457579825274976 Mon Sep 17 00:00:00 2001 From: WaldiS Date: Sun, 12 Jul 2020 18:58:43 +0000 Subject: [PATCH 105/551] Translated using Weblate (Polish) Currently translated at 99.4% (3402 of 3420 strings) --- OsmAnd/res/values-pl/strings.xml | 87 ++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml index eea73e1812..c7ab2ef74d 100644 --- a/OsmAnd/res/values-pl/strings.xml +++ b/OsmAnd/res/values-pl/strings.xml @@ -61,7 +61,7 @@ Pobierz dane (\"offline\") by używać map offline. " \n -\nPrzytrzymaj dłużej, aby uzyskać opcje" +\nPrzytrzymaj dłużej, aby wyświetlić opcje"
Wersja lokalna Zarchiwizowano %1$d z %2$d. Usunięto %1$d z %2$d. @@ -97,7 +97,9 @@ Odwróć kierunek GPX Użyj bieżącego celu Pobierz mapę wektorową offline tego położenia w „Ustawieniach” (\"Zarządzaj mapami\") lub przełącz na wtyczkę \"Mapy online\". - Dla bieżącego położenia dostępna jest wektorowa mapa offline. Aby jej użyć, proszę wybrać „Menu” → „Skonfiguruj mapę” → „Zasób mapy…” → „Wektorowe mapy offline”. + Dla bieżącego położenia dostępna jest wektorowa mapa offline. +\n +\nAby jej użyć wybierz „Menu” → „Skonfiguruj mapę” → „Źródło mapy…” → „Wektorowe mapy offline”. Wyjście dźwięku nawigacji głosowej Wybiera kanał do odtwarzania komunikatów głosowych. Kanał telefoniczny (przerywa odtwarzanie muzyki z głośników) @@ -1053,7 +1055,7 @@ Kanada Diagnozowanie błędów FPS Pobrane stopnie przybliżenia: %1$s - Wygaśnięcie (minuty): %1$s + Czas wygaśnięcia (minuty): %1$s Do pobrania: %1$s Maksymalne przybliżenie: %1$s Minimalne przybliżenie: %1$s @@ -1228,7 +1230,7 @@ %1$s \nTrasa %2$s " \n -\nPrzytrzymaj nacisk, aby zobaczyć na mapie" +\nPrzytrzymaj dłużej, aby wyświetlić na mapie"
Rozpocznij nawigację automatycznie wybrano Interwał podziału @@ -2033,7 +2035,7 @@ Pomijanie aktualizacji Uaktualnić wszystkie mapy? Wyczyść wszystkie kafelki - Opłata za subskrypcję na miesiąc. Anuluj ją w Google Play w dowolnym momencie. + Subskrypcja naliczona za wybrany okres. Anuluj go w Google Play w dowolnym momencie. Darowizna na rzecz społeczności OSM Część z dotacji jest przekazywana darczyńcom OSM. Koszt subskrypcji pozostaje taki sam. Subskrypcje pozwalają na cogodzinne, codzienne i cotygodniowe uaktualnienia i nieograniczone liczbą pobieranie map całego świata. @@ -2307,18 +2309,18 @@ Pokaż lub ukryj notatki OSM Pokaż uwagi OSM Ukryj uwagi OSM - Przybliżony zasięg i jakość mapy: -\n • Europa Zachodnia: **** -\n • Europa Wschodnia: *** -\n • Rosja: *** -\n • Ameryka Północna: *** -\n • Ameryka Południowa: ** -\n • Azja: ** -\n • Japonia i Korea: *** -\n • Bliski Wschód: ** -\n • Afryka: ** + Przybliżony zasięg i jakość mapy: +\n • Europa Zachodnia: **** +\n • Europa Wschodnia: *** +\n • Rosja: *** +\n • Ameryka Północna: *** +\n • Ameryka Południowa: ** +\n • Azja: ** +\n • Japonia i Korea: *** +\n • Bliski Wschód: ** +\n • Afryka: ** \n • Antarktyda: * -\n Jest możliwe pobranie map większości krajów na świecie! +\n Jest możliwe pobranie map większości krajów na świecie! \n Od Afganistanu po Zimbabwe, przez Australię po USA. Argentyna, Brazylia, Kanada, Francja, Niemcy, Polska, Meksyk, Wielka Brytania, Hiszpania, … \n Posortowane wg odległości @@ -2340,7 +2342,7 @@ Udostępnia zdjęcia w widoku ulicznym. Pozwala na odkrywanie miejsc, współpracę nad uchwyceniem świata. Zainstaluj Zwiększ pokrycie zdjęć Mapillary - Proszę zainstalować Mapillary, aby dodać zdjęcia tego położenia na mapie. + Zainstaluj Mapillary, aby dodać zdjęcia do tej lokalizacji na mapie. Otwórz Mapillary Obraz Mapillary Poprawiona odległość @@ -2409,7 +2411,7 @@ Dodaj pliki GPX Importowanie plików GPX lub nagranych tras. Dodaj do ulubionych - Importuje ulubione lub dodaje poprzez zaznaczenie punktów na mapie. + Zaimportuj Ulubione lub dodaj je poprzez zaznaczenie punktów na mapie. Importuj plik GPX Plik %1$s nie zawiera punktów trasy, czy zaimportować go jako ślad? Przesuń punkt @@ -2522,7 +2524,7 @@ Czytaj cały artykuł Czytaj artykuł Notuj! - Dodaj notatkę audio, video lub zdjęciową do każdego punktu na mapie, za pomocą widgetu lub menu kontekstowego. + Dodaj notatki audio, wideo lub zdjęcia do dowolnego punktu na mapie za pomocą widżetów lub menu kontekstowego. Notatki A/V według daty Importuj grupy Wybierz kategorię Ulubione, aby dodać znaczniki. @@ -3152,7 +3154,7 @@ Przebudzaj przed zakrętem Ustaw jak długo ekran będzie włączony. Używanie czujnika zbliżeniowego - Włącza ekran podczas nawigacji machaniem ręką nad ekranem. + Włącza ekran machaniem ręką nad ekranem. Zewnętrzne urządzenia wejściowe Wybierz urządzenie takie jak zwykła klawiatura lub WundeRLINQ do sterowania zewnętrznego. Brak @@ -3418,12 +3420,12 @@ Wybór koloru Nie można usunąć domyślnych profili OsmAnd, ale można je wyłączyć (na poprzednim ekranie) lub przenieść na dół. Edytuj profile - Określa w jaki sposób wyznaczane są trasy. + „Typ nawigacji” określa sposób obliczania tras. Wygląd profilu Ikona, kolor i nazwa Edytuj listę profili Wybrany profil - Stuknięcie %1$s spowoduje utratę wszystkich zmian. + Naciśnięcie przycisku %1$s powoduje odrzucenie wszystkich zmian. Wszystkie ustawienia profilu zostaną przywrócone do stanu po instalacji. Zresetować wszystkie ustawienia profilu\? %1$s: %2$s @@ -3461,7 +3463,7 @@ Uwierzytelniono Efekt uboczny: trasa nie będzie zawierała sekcji, w których nie zostało spełnione kryterium minimalnej prędkości (np. podczas pchania roweru pod strome wzgórze). Nie będzie również zawierała informacji o czasach odpoczynku, np. przerwach. Ma to wpływ na analizę i przetwarzanie końcowe, np. przy próbie określenia całkowitej długości trasy, czasu w ruchu lub średniej prędkości. Zmień układ kategorii - Zmień kolejność sortowania listy, ukryj niepotrzebne kategorie. Wszystkie zmiany można importować lub eksportować za pomocą profili. + Zmień kolejność sortowania listy, ukryj kategorie. Wszystkie zmiany można importować lub eksportować za pomocą profili. Można dodać nową, niestandardową kategorię wybierając jedną lub kilka kategorii. Dostępne Dodaj niestandardową kategorię @@ -3478,7 +3480,7 @@ Przywrócenie ustawień wtyczki do wartości domyślnych Użyj aplikacji systemowej Dźwięk migawki aparatu - Przywrócenie domyślnej kolejności sortowania spowoduje przywrócenie porządku sortowania do stanu domyślnego po instalacji. + Opcja \'Przywróć ustawienia domyślne\' spowoduje przywrócenie porządku sortowania do stanu domyślnego po instalacji. Tryb ułatwień jest dostępu wyłączony w twoim systemie. Wygaś ekran zgodnie z ustawieniami systemu Wyczyść zarejestrowane dane @@ -3678,7 +3680,7 @@ \nMożesz wyłączyć nieużywane wtyczki, aby ukryć ich elementy w aplikacji. %1$s. %1$s / %2$s Szukaj typów użytecznych miejsc - Łącz typy użytecznych zmian z różnych kategorii. Stuknij \"Zmień\", aby zaznaczyć wszystko, stuknij lewą stronę, aby wybrać kategorię. + Łącz typy użytecznych zmian z różnych kategorii. Stuknij przełącznik, aby zaznaczyć wszystko, stuknij lewą stronę, aby wybrać kategorię. Przewodnik po symbolach mapy. Profile nawigacji OsmAnd + Mapillary @@ -3695,22 +3697,22 @@ \nSubskrypcja automatycznie odnawia się, chyba że anulujesz ją przed dniem odnowienia. Twoje konto zostanie obciążone za okres odnowienia (miesiąc/trzy miesiące/rok) dopiero w dniu odnowienia. \n \nMożesz zarządzać subskrypcjami i anulować je w ustawieniach Google Play.
- • Nowe mapy stoków offline -\n + • Nowe mapy stoków offline +\n \n • Pełna personalizacja Ulubionych i Punktów GPX - niestandardowe kolory, ikony, kształty -\n -\n • Dostosowywanie kolejności elementów w menu kontekstowym, konfiguracji mapy, menu podręcznym -\n +\n +\n • Dostosowywanie kolejności elementów w menu kontekstowym, konfiguracji mapy i menu podręcznym +\n \n • Wikipedia jako osobna warstwa w konfiguracji mapy, wybierz tylko potrzebne języki -\n -\n • Tworzenie własnego filtru użytecznych miejsc/mapy z pełną elastycznością -\n +\n +\n • Tworzenie własnego filtru użytecznych miejsc/map z pełną elastycznością +\n \n • Dodano opcje przywracania ustawień profili niestandardowych -\n +\n \n • Pełne trasy GPX z nawigacji obsługują pasy ruchu i pełne instrukcje skrętu -\n +\n \n • Naprawiono rozmiary interfejsu użytkownika na tabletach -\n +\n \n • Naprawiono błędy z RTL \n \n @@ -3720,7 +3722,7 @@ Pokaż/ukryj transport publiczny Utwórz / Edytuj użyteczne miejsce Dodaj / Edytuj Ulubione - Naciśnięcie przycisku akcji powoduje przełączanie między wybranymi profilami. + Przycisk akcji przełącza między wybranymi profilami. Dodaj profil Zmiana profilu aplikacji Możesz uzyskać dostęp do tych czynności, naciskając przycisk „%1$s”. @@ -3802,4 +3804,15 @@ Usunięto %1$s Ponowne uruchomienie jest wymagane, żeby całkowicie usunąć dane fotoradarów. Odinstaluj i zrestartuj + Tracker OsmAnd + Podaj długość pojazdu, niektóre ograniczenia tras mogą być stosowane dla długich pojazdów. + To urządzenie nie ma fotoradarów. + Usuń następny punkt docelowy + Włącz sterowanie poziomem powiększenia mapy za pomocą przycisków głośności urządzenia. + Podaj nazwę punktu + Bieżący punkt docelowy na trasie zostanie usunięty. Jeśli będzie to miejsce docelowe, nawigacja zostanie zatrzymana. + Pobierz mapy Wikipedii + Uzyskaj informacje o interesujących miejscach z Wikipedii. Jest to kieszonkowy przewodnik offline - wystarczy włączyć wtyczkę Wikipedii i cieszyć się artykułami o obiektach wokół ciebie. + Motocykl Enduro + Skuter \ No newline at end of file From b727df2ef89a8656865b8c82fdc079b88fd147f7 Mon Sep 17 00:00:00 2001 From: Zmicer Turok Date: Mon, 13 Jul 2020 09:25:07 +0000 Subject: [PATCH 106/551] Translated using Weblate (Belarusian) Currently translated at 93.7% (3206 of 3420 strings) --- OsmAnd/res/values-be/strings.xml | 211 ++++++++++++++++--------------- 1 file changed, 106 insertions(+), 105 deletions(-) diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index f02b3d7626..dc4aa09a11 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -7,7 +7,7 @@ Лупа мапы Асноўная мапа свету Версія: - Пра дадатак + Пра праграму Версія, ліцэнзіі, удзельнікі праекта Спампаваныя маштабы: %1$s Тэрмін дзеяння (у хвілінах): %1$s @@ -100,7 +100,7 @@ Наладзьце запіс вашых паездак. Паказвае налады ўключэння фонавага адсочвання і навігацыі праз перыядычнае абуджэнне GPS прылады (з выключаным экранам). Усталёўка версіі - Наладка выгляду дадатку. + Наладка выгляду праграмы. Выгляд Налады адмысловых магчымасцяў Вызначце адрас @@ -139,10 +139,10 @@ Прадвызначанае дзеянне віджэта Фармат вываду відэа: Фармат відэа - Выкарыстоўваць сістэмны дадатак для запісу відэа. - Выкарыстоўваць сістэмны дадатак для запісу - Выкарыстоўваць сістэмны дадатак для фота. - Выкарыстоўваць дадатак камеры + Выкарыстоўваць сістэмную праграму для запісу відэа. + Выкарыстоўваць сістэмную праграму для запісу + Выкарыстоўваць сістэмную праграму для фота. + Выкарыстоўваць праграму камеры Наладзіць параметры аўдыё і відэа. Налады аўдыё і відэа Запісаць не атрымалася @@ -186,10 +186,10 @@ Мапы толькі дарог Працаваць у бяспечным рэжыме (трохі павольней, але без уласных бібліятэк). Бяспечны рэжым - Дадатак працуе ў бяспечным рэжыме (адключыць ў «Наладах»). + Праграма працуе ў бяспечным рэжыме (адключыць ў «Наладах»). Фонавы рэжым OsmAnd па-ранейшаму працуе. Спыніць яго? Закрыць набор змен - Дадатак «ZXing Barcode Scanner» не ўсталяваны. Знайсці ў Google Play\? + Праграма «ZXing Barcode Scanner» не ўсталяваная. Знайсці ў Google Play\? Абярыце схему колераў дарог: Схема колераў дарог Паказваць напрамак да месца прызначэння @@ -237,19 +237,19 @@ Прывязвацца да дарог OsmAnd Мапы і навігацыя Прагляд глабальнай мабільнай мапы і навігатар для аўтаномных і сеціўных мапаў OSM - OsmAnd (OSM Automated Navigation Directions) -\n -\n -\nOsmAnd — навігацыйны дадатак з адкрытым кодам з доступам да разнастайных даных ад OpenStreetMap (OSM). Усе даныя (вектарныя і растравыя) можна захаваць на картцы памяці для аўтаномнага выкарыстання. Таксама падтрымліваецца аўтаномная і сеціўная маршрутызацыя, уключаючы пакрокавае галасавое суправаджэнне. -\n -\n + OsmAnd (OSM Automated Navigation Directions) +\n +\n +\nOsmAnd — навігацыйная праграма з адкрытым кодам з доступам да разнастайных даных ад OpenStreetMap (OSM). Усе даныя (вектарныя і растравыя) можна захаваць на картцы памяці для аўтаномнага выкарыстання. Таксама падтрымліваецца аўтаномная і сеціўная маршрутызацыя, уключаючы пакрокавае галасавое суправаджэнне. +\n +\n \nНекалькі асноўных магчымасцяў: \n \n - паўнавартасная праца без інтэрнэт-злучэння (захоўвае вектарныя або растравыя даныя ў памяці прылады); \n \n - кампактная вектарная мапа ўсяго свету; \n -\n - спампоўванне мапаў краін або рэгіёну непасрэдна ў дадатку; +\n - спампоўванне мапаў краін або рэгіёну непасрэдна ў праграме; \n \n - магчымасць адлюстравання звестак на мапе, напрыклад пласт для пракладкі маршруту або пласт з запісам GPX-следу, з POI, улюбёнымі мясцінамі, ізалініямі вышынь, грамадскім транспартам, дадатковымі мапамі з магчымасцю налады ўзроўню празрыстасці; \n @@ -257,7 +257,7 @@ \n \n - пракладка маршрутаў па-за сецівам на кароткія адлегласці (эксперыментальная функцыя); \n -\n - рэжымы для пешаходнай, аўтамабільнай і роваравай навігацыі з: +\n - рэжымы для пешаходнай, аўтамабільнай і роварнай навігацыі з: \n \n - магчымасцю аўтаматычнага пераключэння дзённага/начнога адлюстравання; \n @@ -282,7 +282,7 @@ \n \n \n -\n OsmAnd+ — навігацыйны дадатак з адкрытым кодам з доступам да разнастайных даных ад OpenStreetMap (OSM). Усе даныя (вектарныя і растравыя) можна захаваць на картцы памяці для далейшага аўтаномнага выкарыстання. Таксама падтрымліваецца аўтаномная і сеціўная маршрутызацыя, уключаючы пакрокавае галасавое суправаджэнне. +\n OsmAnd+ — навігацыйная праграма з адкрытым кодам з доступам да разнастайных даных ад OpenStreetMap (OSM). Усе даныя (вектарныя і растравыя) можна захаваць на картцы памяці для далейшага аўтаномнага выкарыстання. Таксама падтрымліваецца аўтаномная і сеціўная маршрутызацыя, уключаючы пакрокавае галасавое суправаджэнне. \n \n \n @@ -296,7 +296,7 @@ \n \n - кампактная вектарная мапа для ўсяго cвету; \n -\n - неабмежаваная колькасць спампоўванняў мапаў асобнай краіны або рэгіёну непасрэдна ў дадатку; +\n - неабмежаваная колькасць спампоўванняў мапаў асобнай краіны або рэгіёну непасрэдна ў праграме; \n \n - магчымасць аўтаномнай працы з данымі Вікіпедыі (спампоўванне POI з Вікіпедыі) з\'яўляецца цудоўным інструментам для падарожнікаў; \n @@ -370,7 +370,7 @@ Хуткасць сімуляцыі маршруту: Адведзена памяці %1$s МБ (Абмежаванне Android %2$s МБ, Dalvik %3$s МБ). Адведзеная памяць - Агулам фізічнай памяці занятай дадаткам %1$s МБ (Dalvik %2$s МБ, іншае %3$s МБ). + Агулам фізічнай памяці занятай праграмай %1$s МБ (Dalvik %2$s МБ, іншае %3$s МБ). \n Прапарцыйнай памяці %4$s МБ (Абмежаванне Android %5$s МБ, Dalvik %6$s МБ). Фізічнай памяці агулам Пункт адпраўлення знаходзіцца занадта далёка ад бліжэйшай дарогі. @@ -462,7 +462,7 @@ Калі ласка, пазначце імя і пароль карыстальніка OSM, каб адсылаць GPX-файлы. Падтрымка Падтрымка новых магчымасцяў - Ахвяраваць, каб убачыць новыя магчымасці, рэалізаваныя ў дадатку. + Ахвяраваць, каб убачыць новыя магчымасці, рэалізаваныя ў праграме. Паказваць маштаб Інфармацыя Вярнуцца да становішча @@ -518,7 +518,7 @@ Ужываць флюарэсцэнтныя колеры для слядоў і шляхоў. Пазасеціўнае рэдагаванне Заўсёды выкарыстоўваць аўтаномнае рэдагаванне. - Змены POI у дадатку не паўплываюць на cпампаваныя файлы мапаў, змены захоўваюцца як файлы на вашай прыладзе. + Змены цікавых пунктаў (POI) у праграме не паўплываюць на cпампаваныя файлы мапаў, змены захоўваюцца як файлы на вашай прыладзе. Запампоўка… {0} POI/нататкі запампаваныя Запампаваць усё @@ -560,8 +560,8 @@ Агульныя налады Кіраваць файламі мапаў Агульныя - Налады экрана і агульныя налады дадатку. - Агульныя налады дадатку + Налады экрана і агульныя налады праграмы. + Агульныя налады праграмы Вашае імя карыстальніка OSM Патрэбна для падачы ў openstreetmap.org. Ваш пароль OSM @@ -599,7 +599,7 @@ Файл POI \'%1$s\' залішні і можа быць выдалены. Лакальны файл для падтрымкі змен у POI не знойдзены і не можа быць створаны. Палепшыць да OsmAnd+ - Спампаваць новую версію дадатку, каб мець магчымасць выкарыстоўваць новыя файлы мапаў. + Спампаваць новую версію праграмы, каб мець магчымасць выкарыстоўваць новыя файлы мапаў. Сеціўны Nominatim Вызначэнне становішча… Маё становішча (знойдзена) @@ -671,7 +671,7 @@ Канал телефанавання (спыняе музыку з дынамікаў) Канал апавяшчэння Канал медыя/навігацыі - Дадатак не можа спампаваць пласт мапы %1$s. Можа дапамагчы пераўсталёўка. + Праграма не можа спампаваць пласт мапы %1$s. Можа дапамагчы пераўсталёўка. Падладзіць празрыстаць накладзенага пласта. Празрыстасць накладкі Падладзіць празрыстасць асноўнай мапы. @@ -752,14 +752,14 @@ \nНавігацыя часова пераключаецца на сэрвіс CloudMade. Не атрымалася знайсці вызначаны каталог. Каталог захоўвання даных - Усе аўтаномныя даныя ў старым усталяваным дадатку будуць падтрымлівацца новым, але ўлюбёныя мясціны патрэбна экспартаваць са старой версіі і імпартаваць у новую. + Усе аўтаномныя даныя ў старой усталяванай праграме будуць падтрымлівацца новыай, але ўлюбёныя мясціны патрэбна экспартаваць са старой версіі і імпартаваць у новую. Зборка {0} ўсталяваная ({1}). Спампоўваецца зборка… Усталяваць OsmAnd - {0} з {1} {2} МБ? Не ўдалося атрымаць спіс зборак OsmAnd Загружаюцца зборкі OsmAnd… Абярыце зборку OsmAnd для ўсталёўкі - Дадатак стану GPS не ўсталяваны. Пашукаць ў краме\? + Праграма статусу GPS не ўсталяваная. Пашукаць ў краме\? Галасавыя загады недаступныя. Калі ласка, перайдзіце ў \"Налады\" → \"Налады навігацыі\", абярыце профіль \"Галасавыя даныя\" і абярыце ці спампуйце пакунак галасавых падказак. Абярыце пакунак галасавых падказак Дзень @@ -893,7 +893,7 @@ Транспарт Паказаць прыпынкі грамадскага транспарту на мапе. Паказваць прыпынкі транспарту - Навігацыйны дадатак OsmAnd + Навігацыйная праграма OsmAnd Даныя POI былі абноўленыя ({0} аб\'ектаў загружана) Не атрымалася абнавіць лакальны спіс POI. Не атрымалася загрузіць даныя з сервера. @@ -977,7 +977,7 @@ Мэта Выбар паміж мясцовымі і англійскімі назвамі. Выкарыстоўваць англійскія назвы - Налады дадатку + Налады праграмы Пошук адраса Абраць будынак Абраць вуліцу @@ -995,7 +995,7 @@ Паказаць вашае становішча Паказаць GPS-каардынаты на мапе Спампаваць адсутныя фрагменты мапы - Навігацыйны дадатак + Навігацыйная праграма Пошук Пошук Абраць POI @@ -1147,7 +1147,7 @@ Аддаваць перавагу аўтамагістралям Імітацыя з выкарыстаннем разлічанага маршруту Імітацыя з выкарыстаннем GPX-следу - Профілі дадатку + Профілі праграмы Глабальная карэкцыя вышыні Навігацыйныя знакі ўсяго свету Плацяжы Bitcoin ўсяго свету @@ -1547,7 +1547,7 @@ \n \nГэты стыль на любым маштабе мапы паказвае максімальную колькасць падрабязнасцяў для паездкі, наяўных у даных мапы (у прыватнасці, дарогі, дарожкі, сцяжынкі, і арыенціры). \n -\nЁн таксама дакладна адлюстроўвае ўсе тыпы дарог праз колеравае кадаванне, што карысна, для, напрыклад, кіравання вялікімі транспартнымі сродкамі. +\nЁн таксама дакладна адлюстроўвае ўсе тыпы дарог праз каляровае кадаванне, што карысна, для, напрыклад, кіравання вялікімі транспартнымі сродкамі. \n \nІ ён дадае адмысловыя турыстычныя налады, такія як роварныя маршруты або альпійскія горныя маршруты. \n @@ -1574,7 +1574,7 @@ Высокая кантрастнасць дарог Немагчыма стварыць мапы ў вызначаным каталозе Перамясціць файлы не атрымалася - Унутраная памяць дадатку + Унутраная памяць праграмы Вызначана ўласнаручна Унутраная памяць Капіяваць @@ -1600,7 +1600,7 @@ Сапраўды хочаце выдаліць %1$d нататак\? Імпартаваць у OsmAnd Прадухіліць аўтаномны запіс - Запіс GPX прыпыніцца, калі дадатак будзе забіты (праз надаўнія дадаткі). (Апавяшчэнне ў вобласці падказак Android пра фонавы рэжым OsmAnd знікне.) + Запіс GPX прыпыніцца, калі праграма будзе забітая (праз надаўнія праграмы). (Апавяшчэнне ў вобласці падказак Android пра фонавы рэжым OsmAnd знікне.) Служба вызначэння месцазнаходжання выключаная. Уключыць яе\? Даныя Вікіпедыі састарэлі і больш непрыдатныя. Заархіваваць іх\? Спампаваць дадатковыя даныя Вікіпедыі (%1$s МБ)\? @@ -1636,7 +1636,7 @@ Бішнупрыя Наваха Неварская / Непал-бхаса - Каб усе змены ўжыліся, патрэбна перезапусціць дадатак. + Каб усе змены ўжыліся, патрэбна перезапусціць праграму. Колер GPX Шырыня GPX Чырвоны @@ -1657,7 +1657,7 @@ Прадвызначана (13) Прадвызначана (празрысты сіні) Вам падабаецца OsmAnd? - Ацаніце гэты дадатак + Ацаніце праграму Калі ласка, дайце ацэнку OsmAnd на Google Play Скажыце нам чаму. Калі ласка, пішыце прапановы. @@ -1760,7 +1760,7 @@ Падзяліцца месцазнаходжаннем геа: \"Выключана\" наўпрост запускае мапу. - Імітаваць першы запуск дадатку + Імітаваць першы запуск праграмы QR-код Мапа спампаваная Зваротная сувязь @@ -1778,7 +1778,7 @@ Абнавіць Базавая мапа свету (якая пакрывае ўвесь свет пры малым маштабе) адсутнічае або састарэла. Калі ласка, спампуйце яе каб мець магчымасць базавага агляду ўсяго свету. Мапа «%1$s» гатовая для выкарыстання. - Усталёўвае прыкмету першага запуску дадатку, не змяняе іншых налад. + Вызначае адзнаку першага запуску праграмы, не змяняе іншых налад. Увядзіце назву краіны Першыя крокі з OsmAnd Дапамажыце палепшыць OsmAnd @@ -1944,7 +1944,7 @@ Актыўны Не актыўны Паказаць празрыстую пошукавую панэль - Дадатак мае дазвол на запіс на рухомы носьбіт, але патрабуецца перазагрузка. + Праграма мае дазвол на запіс на рухомы носьбіт, але патрабуецца перазагрузка. Поўная справаздача Імя карыстальніка і пароль OpenStreetMap Дзякуй вам за падтрымку OsmAnd! @@ -2265,7 +2265,7 @@ Збалансаваны Аддаваць перавагу завулкам На адсылаць ананімную статыстыку выкарыстання - OsmAnd збірае інфармацыю аб тым, якія часткі дадатку выкарыстоўваюцца вамі. Вашае месцазнаходжанне ніколі не адпраўляецца, як і ўсё, што вы ўводзіце, якія вобласці праглядаеце, што шукаеце ці спампоўваеце. + OsmAnd збірае інфармацыю аб тым, якія часткі праграмы выкарыстоўваюцца вамі. Ваша месцазнаходжанне ніколі не адпраўляецца, як і ўсё, што вы ўводзіце, якія вобласці праглядаеце, што шукаеце ці спампоўваеце. Не паказваць паведамленні падчас запуску Не паказваць зніжкі і адмысловыя паведамленні аб мясцовых падзеях. Параметры паркоўкі @@ -2307,9 +2307,9 @@ Аналізуй на мапе Бачны Прыпынена - OsmAnd (OSM Automated Navigation Directions) мапа і навігацыйны дадатак з доступам да бясплатных якасных мапаў усяго свету OpenStreetMap (OSM). + OsmAnd (OSM Automated Navigation Directions) мапа і навігацыйная праграма з доступам да бясплатных якасных мапаў усяго свету OpenStreetMap (OSM). \n -\nАтрымлівайце асалоду ад голасавога і візуальнага навігатара, прагляду карысных месцаў (анг. POI, points of interest), стварэння і кіравання GPX-слядоў, выкарыстання контурных ліній і інфармацыі аб вышыні (праз убудову), выбару паміж кіраваннем аўтамабілем, яздой на ровары і шпацырам, рэдагавання OSM і шмат іншым. +\nАтрымлівайце асалоду ад галасавога і візуальнага навігатара, прагляду цікавых пунктаў (анг. POI, points of interest), стварэння і кіравання GPX-слядоў, выкарыстання контурных ліній і інфармацыі аб вышыні (праз убудову), выбару паміж кіраваннем аўтамабілем, яздой на ровары і шпацырам, рэдагавання OSM і шмат іншым. Агляд Прыблізнае пакрыццё і якасць мапы: \n • Заходняя Еўропа: **** @@ -2354,10 +2354,10 @@ Узровень маштабавання паказу: %1$s Для вялікіх адлегласцяў: калі ласка, дадайце прамежкавыя пункты, калі разлік не завяршыўся цягам 10 хвілін. Лыжня -\nУбудова лыжных мап для OsmAnd дазваляе бачыць лыжныя трасы з узроўнем складанасці і некаторай дадатковай інфармацыяй: размяшчэнне пад\'ёмнікаў і іншых аб\'ектаў. +\nУбудова лыжных мапаў для OsmAnd дазваляе бачыць лыжныя трасы з узроўнем складанасці і некаторай дадатковай інфармацыяй: размяшчэнне пад\'ёмнікаў і іншых аб\'ектаў. Назва змяшчае занадта шмат вялікіх літар. Працягнуць\? Мапа -\n• Адлюстроўвае POI (пункт цікавасці) побач вас +\n• Адлюстроўвае POI (цікавы пункт) побач вас \n• Адаптуе мапу ў напрамку вашага руху (ці компаса) \n• Паказвае, дзе вы знаходзіцеся і куды вы глядзіце \n• Дзяліцеся сваім месцазнаходжаннем, каб сябры змаглі знайсці вас @@ -2386,7 +2386,7 @@ \n Удзел у OSM \n • Паведамленне аб памылках -\n • Спампоўванне GPX-слядоў у OSM проста з дадатку +\n • Спампоўванне GPX-слядоў у OSM проста з праграмы \n • Даданне цікавых пунктаў (POI) і запампоўка іх у OSM (ці пазней, па-за сецівам) \n Навігацыя @@ -2426,38 +2426,38 @@ \n • Антарктыда: \n Большасць краін свету даступная да спампоўвання! \n Атрымайце надзейны навігатар у вашай краіне — будзь то Беларусь, Францыя, Германія, Мексіка, Вялікабрытанія, Іспанія, Нідэрланды, ЗША, Расія, Бразілія ці якая іншая. - OsmAnd+ (OSM Automated Navigation Directions) — мапа і навігацыйны дадатак з доступам да бясплатных, сусветных і высокаякасных даных OpenStreetMap (OSM). -\n Атрымлівайце асалоду ад галасавой і візуальная навігацыі, праглядайце пукты цікавасцяў (POI), запісвайце GPX-сляды, выкарыстоўвайце візуалізацыю контурных ліній ды даных вышыні, пераключайцеся паміж рэжымамі кіравання, яздой на ровары ды шпацырамі, рэдагуйце OSM-даныя і шмат іншага. -\n + OsmAnd+ (OSM Automated Navigation Directions) — мапа і навігацыйная праграма з доступам да бясплатных, сусветных і высокаякасных даных OpenStreetMap (OSM). +\n Атрымлівайце асалоду ад галасавой і візуальная навігацыі, праглядайце цікавыя пукты (POI), запісвайце GPX-сляды, выкарыстоўвайце візуалізацыю контурных ліній ды даных вышыні, пераключайцеся паміж рэжымамі кіравання, яздой на ровары ды шпацырамі, рэдагуйце OSM-даныя і шмат іншага. +\n \n OsmAnd+ — платная версія. Пры набыцці вы падтрымліваеце праект, фінансуеце распрацоўку новых магчымасцяў ды атрымліваеце апошнія абнаўленні. -\n +\n \nНекаторыя з галоўных магчымасцяў: Прагляд мапы -\n +\n \n • Паказвае дзе вы знаходзіцеся і куды глядзіце -\n +\n \n • Пры патрэбе выраўняе мапу па компасе ці па напрамку вашага руху -\n +\n \n • Захавае вашыя найважнейшыя месцы ва ўлюблёных -\n -\n • Адлюстроўвае пункты цікавасцяў вакол вас -\n +\n +\n • Адлюстроўвае цікавыя пункты вакол вас +\n \n • Паказвае адмысловыя сеціўныя мапы, спадарожнікавыя здымкі (Bing), розныя накладкі накшталт турыстычных/навігацыйных GPX-слядоў і дадатковыя пласты з наладжвальнай празрыстасцю -\n +\n \n • Можа адлюстроўваць на мапе беларускія, англійскія, мясцовыя назвы ці фанетычным напісаннем \n - Выкарыстоўваюцца даныя OSM ды Вікіпедыі -\n -\n • Высокаякасная інфармацыя ад найлепшых праектаў свету -\n -\n • OSM-даныя даступныя па краіне ці рэгіёну -\n -\n • Пункты цікавасцяў з Вікіпедыі, выдатна падыходзіць для агляду выбітнасцяў -\n -\n • Неабмежаваная колькасць бясплатных спампоўванняў непасрэдна з дадатку -\n -\n • Кампактныя пазасеціўныя вектарныя мапы абнаўляюцца не радзей за раз на месяц -\n + Выкарыстоўваюцца даныя OSM ды Вікіпедыі +\n +\n • Высокаякасная інфармацыя ад найлепшых праектаў свету +\n +\n • OSM-даныя даступныя па краіне ці рэгіёну +\n +\n • Цікавыя пункты з Вікіпедыі, выдатна падыходзіць для агляду выбітнасцяў +\n +\n • Неабмежаваная колькасць бясплатных спампоўванняў непасрэдна з праграмы +\n +\n • Кампактныя пазасеціўныя вектарныя мапы абнаўляюцца не радзей за раз на месяц +\n \n • Выбар паміж поўнымі данымі рэгіёна ці толькі дарожнай сеткай (напрыклад, уся Японія займае 700 МБ, а дарожная сетка — 200 МБ) Асаблівасці бяспекі \n • Магчамасць аўтаматычнага пераключэння рэжыма дзень/ноч @@ -2471,11 +2471,11 @@ \n • Прыпынкі грамадскага транспарту (аўтобус, трамвай, цягнік), уключаючы назвы маршрутаў \n • Магчымасць запісу падарожжа ў лакальны GPX-файл ці інтэрнэт-сэрвіс \n • Магчымасць адлюстравання хуткасці ды вышыні -\n • Адлюстраванне контурных ліній ды зацянення вышынь (праз дадатак) +\n • Адлюстраванне контурных ліній ды зацянення вышынь (праз праграму) Непасрэдны ўнёсак у OSM \n • Заявы аб памылках у даных -\n • Запампоўванне GPX-слядоў у OSM проста з дадатку -\n • Даданне пунктаў цікавасцяў (POI) і непасрэдная запампоўка іх у OSM (ці пазней, па-за сецівам) +\n • Запампоўванне GPX-слядоў у OSM проста з праграмы +\n • Даданне цікавых пунктаў (POI) і непасрэдная запампоўка іх у OSM (ці пазней, па-за сецівам) \n • Магчымасць запісу падарожжа ў фонавым рэжыме (у той час, як прылада знаходзіцца ў рэжыме сну) \n OsmAnd — адкрытае праграмнае забяспячэнне ў актыўнай распрацоўцы. Кожны можа ўнесці ўклад паведамляючы аб памылках, паляпшаючы пераклад ці распрацоўваючы новыя магчымасці. Ход праекта залежыць таксама ад фінансавых унёскаў для забяспячэння кадавання і тэставання новай функцыянальнасці. \n @@ -2590,7 +2590,7 @@ Экспартаваць вашыя адзнакі ў наступны GPX-файл: Захаваць як GPX-файл Перамясціць у гісторыю - Групы ўжо не будзе пасля наступнага перазапуску дадатку. + Групы ўжо не будзе пасля наступнага перазапуску праграмы. Адзнакі Фармат каардынат Выкарыстоўваць сістэмную клавіятуру @@ -2642,7 +2642,7 @@ Паказвае лініі накірунку ад вашага становішча да актыўнай адзнакі. Паказвае адну ці дзьве стрэлкі, якія паказваюць накірунак да актыўных адзнак. Абярыце, як адлюстроўваць адлегласць да актыўных адзнак. - Вызначце колькасць указальнікаў кірунку: + Вызначце колькасць указальнікаў кірунку. Выгляд на мапе Абраць след, каб дадаць яго пункты ў адзнакі. Направа @@ -2754,7 +2754,7 @@ Выдаліць гісторыю пошукаў Паказаць выявы Папулярныя напрамкі - Платны дадатак + Платная праграма Платная ўбудова Дастуны новыя даныя Wikivoyage, абнавіце іх. Спампуйце даведнікі Wikivoyage для прагляду артыкулаў аб мясцінах па ўсім свеце без Інтэрнэту. @@ -2771,7 +2771,7 @@ Дапаможнік па самым цікавым месцам на планеце ўнутры OsmAnd без злучэння з Інтэрнэтам. Штомесячныя абнаўленні мапаў Штогадзінныя абнаўленні мапаў - Пакупка ў дадатку + Пакупка ў праграме Разавы плацёж Аднойчы набыты, будзе заўсёды даступны для вас. Купіць - %1$s @@ -2800,7 +2800,7 @@ Пошук адпаведнага артыкула вікіпедыі Артыкул не знойдзены Як адкрыць артыкулы Вікіпедыі? - Перазапуск дадатку + Перазапуск праграмы Вы анулявалі падпіску OsmAnd Live Прадоўжыць падпіску, каб і далей карыстацца ўсімі функцыямі: На падставе закладзеных вамі артыкулаў рэкамендуецца спампаваць наступныя мапы: @@ -2877,7 +2877,7 @@ \n Выдаліць адзнаку мапы «%s»\? Рэдагаваць адзнаку мапы - Асобны дадатак + Асобная праграма Пошук вуліцы Спачатку вызначце горад/мясцовасць Аднавіць @@ -2934,7 +2934,7 @@ трансферы пешшу Шлях - Пункты цікавасцяў (POI) + Цікавыя пункты (POI) Падлік маршруту… Грамадскі транспарт Абярыце дарогу, якой хочаце пазбягаць падчас навігацыі, або на мапе, або са спіса ніжэй: @@ -3133,11 +3133,11 @@ Вызначыць мінімальную / максімальную хуткасць Новы профіль Крушэнне - Апошні запуск OsmAnd завяршыўся хібай. Калі ласка, адпраўце паведамленне памылкі, каб палепшыць дадатак. + Апошні запуск OsmAnd завяршыўся хібай. Калі ласка, адпраўце паведамленне памылкі, каб палепшыць праграму. Асабісты транспарт Монакола Скутар - Дазвольце OsmAnd збіраць і апрацоўваць ананімныя даныя пра выкарыстанне дадатку. Мы не збіраем і не захоўваем даныя вашай пазіцыі ці месцаў, якія вы бачыце на мапе. + Дазвольце OsmAnd збіраць і апрацоўваць ананімныя даныя пра выкарыстанне праграмы. Мы не збіраем і не захоўваем даныя вашай пазіцыі ці месцаў, якія вы бачыце на мапе. \n \nВы можаце змяніць свой выбар у любы час у \"Налады\" > \"Прыватнасць і бяспека\". Дапамагае нам даведацца пра папулярнасць мапаў рэгіёнаў і краін. @@ -3166,7 +3166,7 @@ Тып: %s Базавы профіль Абярыце тып навігацыі - Калі ласка, абярыце тып навігацыі для новага профілю дадатку + Калі ласка, абярыце тып навігацыі для новага профілю праграмы Увядзіце назву профілю Спачатку неабходна даць профілю назву. Дублікат назвы @@ -3186,8 +3186,8 @@ BRouter (па-за сецівам) Адвольны профіль маршрутызацыі Адмысловая маршрутызацыя - Абярыце профілі, што будуць бачныя ў дадатку. - Профілі дадатку + Абярыце профілі, што будуць бачныя ў праграме. + Профілі праграмы Лыжныя туры Трасы для гарналыжных тураў. Санкі @@ -3206,7 +3206,7 @@ Клавіятура WunderLINQ Parrot - Калі ласка, ўключыце па меншай меры адзін профіль дадатку, каб выкарыстоўваць гэты параметр. + Калі ласка, ўключыце па меншай меры адзін профіль праграмы, каб выкарыстоўваць гэты параметр. Абраць gaps Прычэп Паказваць на мапе зоны з нізкім узроўнем выкідаў. Не ўплывае на маршрутызацыю. @@ -3242,7 +3242,7 @@ Буфер logcat UTM Standard Адкрыты код месцазнаходжання (OLC) - Абраны фармат будзе ужыты да ўсяго дадатку. + Абраны фармат будзе ужыты да ўсёй праграмы. Параметр прадвызначана абраны для профіляў: %s Змяніць налады Адкінуць змены @@ -3250,7 +3250,7 @@ Ужыць да ўсіх профіляў Паведамленне падчас запуску Аналітыка - Профіль дадатку зменены на \"%s\" + Профіль праграмы зменены на \"%s\" Налады ўбудоў Шпацыры, паходы, бег Карабель, веславанне, парусны спорт @@ -3272,30 +3272,30 @@ Аддаваць перавагу трасам гэтай складанаці, але не выключаць прастейшыя, калі шлях будзе карацейшым. Па-за трасай Freerides і offpiste - неафіцыйныя маршруты і праходы. Як правіла, недагледжаныя, неразмечаныя, не асвятляюцца ўвечары. Будзьце вельмі ўважлівымі. - • Профілі дадатку: стварыце ўласны профіль адпаведна вашых патрэб, выкарыстаўшы адмысловыя значок і колер. -\n + • Профілі праграмы: стварыце ўласны профіль адпаведна вашых патрэб, выкарыстаўшы адмысловыя значок і колер. +\n \n \n • Для профіляў дададзеныя прадвызначаныя налады і мінімальная / максімальная хуткасць \n -\n +\n \n • Дададзены віджэт з бягучымі каардынатамі \n -\n +\n \n • Дададзены параметры для адлюстравання на мапе компаса і радыуснай лінейкі \n -\n +\n \n • Палепшана загрузка мапаў у фонавым рэжыме \n -\n +\n \n • Вернуты параметр \"Уключыць экран\" \n -\n +\n \n • Выпраўлены выбар мовы Вікіпедыі \n -\n +\n \n • Выпраўлены паводзіны кнопкі компаса падчас навігацыі \n -\n +\n \n • Выпраўленні памылак \n \n @@ -3314,13 +3314,13 @@ Выгляд мапы Усталяваныя убудовы Наладзіць навігацыю - Тэма дадатку, адзінкі вымярэння, рэгіён + Тэма праграмы, адзінкі вымярэння, рэгіён Апавяшчэнні будуць паказвацца падчас навігацыі ў левым ніжнім куце экрана. Мова і вывад Скінуць да прадвызначаных Стварэнне, імпарт, рэдагаванне профіляў - Кіраванне профілямі дадатку… - Уплывае на ўвесь дадатак + Кіраванне профілямі праграмы… + Уплывае на ўсю праграму Налады OsmAnd Скапіяваць з іншага профілю Уключыць экран @@ -3439,10 +3439,10 @@ Перамясціць у новы пункт прызначэння Запісваць сляды кожны дзень у новы падкаталог (напрыклад, 2018-01-01). Сапраўды хочаце абнавіць усе мапы (%1$d)\? - Стварыце свой профіль на аснове аднаго з базавых профіляў - гэта будзе вызначаць асноўныя параметры, такія як віджэты, адзінкі вымярэння хуткасці і адлегласці. Гэта тыповыя профілі дадатку, якія разам з прыкладамі профіляў карыстальніка можна пашырыць да: + Стварыце свой профіль на аснове аднаго з базавых профіляў - гэта будзе вызначаць асноўныя параметры, такія як віджэты, адзінкі вымярэння хуткасці і адлегласці. Гэта тыповыя профілі праграмы, якія разам з прыкладамі профіляў карыстальніка можна пашырыць да: Маршруты, падрыхтаваныя толькі для класічнага стылю без канькабежных трас. Сюды ўваходзяць маршруты, падрыхтаваныя невялікім снегаходам з больш свабоднай лыжнёй і трасамі, падрыхтаваныя непасрэдна лыжнікамі. Спампаваць падрабязную мапу %s, каб праглядзець гэтую вобласць. - Унутранае сховішча OsmAnd, схаванае ад карыстальніка і іншых дадаткаў. + Унутранае сховішча OsmAnd, схаванае ад карыстальніка і іншых праграм. Змена каталога сховішча Ландшафтны парк Самаходныя і несамаходныя сані (запрэжкі) @@ -3464,7 +3464,7 @@ Складанасць гарналыжнай трасы Абмежаванне па шырыні Увядзіце шырыню транспартнага сродку для ўліку пры разліку маршруту. - • Абноўлены налады дадатку і профілю. Цяпер налады размешчаныя па тыпу. Кожны профіль можна наладзіць асобна. + • Абноўлены налады праграмы і профілю. Цяпер налады размешчаныя па тыпу. Кожны профіль можна наладзіць асобна. \n  \n  • Новы дыялог загрузкі мапы, які прапануе загрузіць мапу падчас прагляду \n  @@ -3502,7 +3502,7 @@ Рэдагаванне OSM OSM Значок будзе паказвацца падчас навігацыі або руху. - Прадвызначаны дадатак (%s) + Прадвызначаная праграма (%s) Адвольны профіль Вугал: %s° Вугал @@ -3527,7 +3527,7 @@ Улюбёнае Падпіска - OsmAnd Live Пакупкі OsmAnd - Даведка па знаках мапы + Даведка па знаках мапы. Профілі навігацыі Стварыць/Рэдагаваць POI Месца паркоўкі @@ -3567,7 +3567,7 @@ \"Асноўныя дзеянні\" змяшчаюць толькі 4 кнопкі. Асноўныя дзеянні Убудова для распрацоўшчыкаў - Замяніць іншы пункт на гэты + Замяніць іншы пункт на гэты. Лыжныя туры Снегаход Адвольная ўбудова OsmAnd @@ -3614,9 +3614,10 @@ Ламбардская %1$s / %2$s Можна спалучаць тыпы POI з розных катэгорый. Націсніце \"Пераключыць\", каб абраць усе ці націсніце злева, каб абраць катэгорыю. - Змяніць профіль дадатку + Змяніць профіль праграмы Аглядная мапа свету (падрабязная) Схаваць грамадскі транспарт Паказаць/схаваць грамадскі транспарт Пералічыць маршрут у выпадку адхілення + Выдаліць \ No newline at end of file From d9e4c375e4c0f72d6753c6ef5dc5da6cf49a1378 Mon Sep 17 00:00:00 2001 From: WaldiS Date: Sun, 12 Jul 2020 18:48:47 +0000 Subject: [PATCH 107/551] Translated using Weblate (Polish) Currently translated at 99.8% (3808 of 3812 strings) --- OsmAnd/res/values-pl/phrases.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-pl/phrases.xml b/OsmAnd/res/values-pl/phrases.xml index 263a687f98..f0ae512c20 100644 --- a/OsmAnd/res/values-pl/phrases.xml +++ b/OsmAnd/res/values-pl/phrases.xml @@ -3825,4 +3825,7 @@ Ciśnienie Strzałka Wibracja + Tak + Tak + Wibracja: nie \ No newline at end of file From d5cba20e6560e5fe852413c8467a5df765d26e41 Mon Sep 17 00:00:00 2001 From: Zmicer Turok Date: Mon, 13 Jul 2020 09:26:26 +0000 Subject: [PATCH 108/551] Translated using Weblate (Belarusian) Currently translated at 94.9% (3618 of 3812 strings) --- OsmAnd/res/values-be/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-be/phrases.xml b/OsmAnd/res/values-be/phrases.xml index 5a66eeae18..42e8654cab 100644 --- a/OsmAnd/res/values-be/phrases.xml +++ b/OsmAnd/res/values-be/phrases.xml @@ -1049,7 +1049,7 @@ Асвятляльная вежа Выратавальная станцыя Толькі калі пераход дазволены - Не + Гук: не Так Без тактыльнага пакрыцця Так From 767ea8574e75cd75d7679d49485ac3e53054a8a9 Mon Sep 17 00:00:00 2001 From: WaldiS Date: Sun, 12 Jul 2020 18:49:43 +0000 Subject: [PATCH 109/551] Translated using Weblate (Polish) Currently translated at 100.0% (267 of 267 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/pl/ --- OsmAnd-telegram/res/values-pl/strings.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/OsmAnd-telegram/res/values-pl/strings.xml b/OsmAnd-telegram/res/values-pl/strings.xml index 426e4ad507..22e12de229 100644 --- a/OsmAnd-telegram/res/values-pl/strings.xml +++ b/OsmAnd-telegram/res/values-pl/strings.xml @@ -142,9 +142,7 @@ h min sek - - Nadajnik OsmAnd pozwala Ci udostępniać swoją lokalizację i widzieć ją w OsmAnd.
-
Aplikacja używa API Telegram, a więc potrzebujesz konta Telegram.
+ Nadajnik OsmAnd pozwala Ci udostępniać swoją lokalizację i widzieć ją w OsmAnd.

Aplikacja używa API Telegram, a więc potrzebujesz konta Telegram.
Moja lokalizacja Na żywo Wybierz nazwę, której jeszcze nie używasz From ba1557668a0af4c3e6319e48852bf0665336dc4e Mon Sep 17 00:00:00 2001 From: Zmicer Turok Date: Sun, 12 Jul 2020 23:27:41 +0000 Subject: [PATCH 110/551] Translated using Weblate (Belarusian) Currently translated at 100.0% (267 of 267 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/be/ --- OsmAnd-telegram/res/values-be/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd-telegram/res/values-be/strings.xml b/OsmAnd-telegram/res/values-be/strings.xml index eec8513da5..1051d6b1fd 100644 --- a/OsmAnd-telegram/res/values-be/strings.xml +++ b/OsmAnd-telegram/res/values-be/strings.xml @@ -85,7 +85,7 @@ Рэгістрацыя ў Telegram Для абмену вам неабходны акаўнт Тэлеграм. Калі ласка, ўсталюйце Тэлеграм і наладзьце акаўнт. - Пасля гэтага вы зможаце выкарыстоўваць дадатак. + Пасля гэтага вы зможаце выкарыстоўваць праграму. Усе Выкл Вам неабходна мець акаўнт Тэлеграм і нумар тэлефона @@ -125,7 +125,7 @@ Працягнуць Скасаваць Налады - Дадатак не мае дазволу на доступ да даных аб месцазнаходжанні. + Праграма не мае дазволу на доступ да даных аб месцазнаходжанні. Калі ласка, ўключыце \"Месцазнаходжанне\" ў сістэмных наладах Абярыце аднаго пастаўшчыка месцазнаходжання, каб падзяліцца сваім месцазнаходжаннем. Фонавы рэжым @@ -168,7 +168,7 @@ г хвіл сек - Назіральнік OsmAnd Дае магчымасць дзяліцца сваім месцазнаходжаннем і бачыць месцазнаходжанне іншых у OsmAnd.

Дадатак выкарыстоўвае Telegram API, таму вам неабходны акаўнт Тэлеграм.
+ Назіральнік OsmAnd Дае магчымасць дзяліцца сваім месцазнаходжаннем і бачыць месцазнаходжанне іншых у OsmAnd.

Праграма выкарыстоўвае Telegram API, таму вам неабходны акаўнт Тэлеграм.
Маё месцазнаходжанне Зараз дзейнічае Адправіць месцазнаходжанне як @@ -200,7 +200,7 @@ Уключыць маніторынг, каб захоўваць пункты месцазнаходжання ў гісторыі. Назіральнік OsmAnd Telegram - Telegram (дадатак для ліставання) выкарыстоўваецца для зносін паміж людзьмі. + Telegram (праграма для ліставання) выкарыстоўваецца для зносін паміж людзьмі. Назіральнік OsmAnd - адзін з кліентаў для адкрытай платформы Telegram. Вашыя кантакты могуць выкарыстоўваць іншы кліент. Націскаючы \"Працягнуць\" вы пагаджаецеся з палітыкай прыватнасці Telegram і OsmAnd. Ухваліць From d88bf79930c54355d1aa2824a4b559b302280f05 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 13 Jul 2020 19:17:34 +0300 Subject: [PATCH 111/551] Track appearance screen first part --- .../layout/point_editor_group_select_item.xml | 10 +- OsmAnd/res/layout/track_appearance.xml | 115 ++++++++ OsmAnd/res/layout/track_width_card.xml | 112 ++++++++ OsmAnd/res/values-ru/strings.xml | 2 + OsmAnd/res/values/sizes.xml | 3 +- OsmAnd/res/values/strings.xml | 6 + .../plus/dialogs/GpxAppearanceAdapter.java | 49 ++-- .../plus/myplaces/DirectionArrowsCard.java | 64 +++++ .../myplaces/TrackAppearanceFragment.java | 164 +++++++++++ .../osmand/plus/myplaces/TrackWidthCard.java | 259 ++++++++++++++++++ 10 files changed, 763 insertions(+), 21 deletions(-) create mode 100644 OsmAnd/res/layout/track_appearance.xml create mode 100644 OsmAnd/res/layout/track_width_card.xml create mode 100644 OsmAnd/src/net/osmand/plus/myplaces/DirectionArrowsCard.java create mode 100644 OsmAnd/src/net/osmand/plus/myplaces/TrackAppearanceFragment.java create mode 100644 OsmAnd/src/net/osmand/plus/myplaces/TrackWidthCard.java diff --git a/OsmAnd/res/layout/point_editor_group_select_item.xml b/OsmAnd/res/layout/point_editor_group_select_item.xml index 09afe219ff..e747485150 100644 --- a/OsmAnd/res/layout/point_editor_group_select_item.xml +++ b/OsmAnd/res/layout/point_editor_group_select_item.xml @@ -37,15 +37,17 @@ tools:text="255" /> - \ No newline at end of file diff --git a/OsmAnd/res/layout/track_appearance.xml b/OsmAnd/res/layout/track_appearance.xml new file mode 100644 index 0000000000..967501118d --- /dev/null +++ b/OsmAnd/res/layout/track_appearance.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/track_width_card.xml b/OsmAnd/res/layout/track_width_card.xml new file mode 100644 index 0000000000..03103560eb --- /dev/null +++ b/OsmAnd/res/layout/track_width_card.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 659e2b28c2..15f0a65b91 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -3817,4 +3817,6 @@ Мотороллер Закрытая заметка OSM Инвалидная коляска + Выберите нужный вариант разбиения: по времени или по расстоянию. + Выберите интервал с которым будут отображаться метки с расстоянием или временем на треке. \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index ebefb8942f..55119079e5 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -96,7 +96,8 @@ 3dp 14dp 6dp - + 60dp + 96dp 16dp 48dp diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5d733cf83f..83cb0a8b90 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,12 @@ Thx - Hardy --> + Direction arrows + Custom + Select the desired splitting option: by time or by distance. + Select the interval at which marks with distance or time on the track will be displayed. + Select width + Show start finish icons Closed OSM Note Go-cart Wheelchair forward diff --git a/OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java b/OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java index 048461da55..a330e2c940 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java @@ -18,10 +18,14 @@ import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; +import java.util.ArrayList; import java.util.List; public class GpxAppearanceAdapter extends ArrayAdapter { + public static final String TRACK_WIDTH_BOLD = "bold"; + public static final String TRACK_WIDTH_MEDIUM = "medium"; + private OsmandApplication app; private GpxAppearanceAdapterType adapterType; private int currentColor; @@ -61,14 +65,7 @@ public class GpxAppearanceAdapter extends ArrayAdapter getAppearanceItems(OsmandApplication app, GpxAppearanceAdapterType adapterType) { + List items = new ArrayList<>(); RenderingRuleProperty trackWidthProp = null; RenderingRuleProperty trackColorProp = null; RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); @@ -102,30 +114,31 @@ public class GpxAppearanceAdapter extends ArrayAdapter appearanceItems; + + public TrackWidthCard(MapActivity mapActivity, SelectedGpxFile selectedGpxFile) { + super(mapActivity); + this.mapActivity = mapActivity; + this.selectedGpxFile = selectedGpxFile; + appearanceItems = getWidthAppearanceItems(); + } + + @Override + public int getCardLayoutId() { + return R.layout.track_width_card; + } + + @Override + protected void updateContent() { + updateHeader(); + updateCustomWidthSlider(); + + RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view); + groupRecyclerView.setAdapter(new GpxWidthAdapter(appearanceItems)); + groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); + } + + private AppearanceListItem getSelectedItem() { + if (selectedItem == null) { + String selectedWidth = selectedGpxFile.getGpxFile().getWidth(null); + for (AppearanceListItem item : appearanceItems) { + if (Algorithms.objectEquals(item.getValue(), selectedWidth) + || Algorithms.isInt(selectedWidth) && CUSTOM_WIDTH.equals(item.getAttrName())) { + selectedItem = item; + break; + } + } + } + return selectedItem; + } + + private List getWidthAppearanceItems() { + List items = GpxAppearanceAdapter.getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_WIDTH); + + String selectedWidth = selectedGpxFile.getGpxFile().getWidth(null); + String customWidth = Algorithms.isInt(selectedWidth) ? selectedWidth : String.valueOf(CUSTOM_WIDTH_MIN); + + items.add(new AppearanceListItem(CUSTOM_WIDTH, customWidth, app.getString(R.string.shared_string_custom))); + return items; + } + + private void updateHeader() { + AndroidUiHelper.updateVisibility(view.findViewById(R.id.icon), false); + + TextView titleView = view.findViewById(R.id.title); + titleView.setText(R.string.select_track_width); + + TextView descriptionView = view.findViewById(R.id.description); + descriptionView.setText(getSelectedItem().getLocalizedValue()); + } + + private void updateCustomWidthSlider() { + if (CUSTOM_WIDTH.equals(getSelectedItem().getAttrName())) { + Slider widthSlider = view.findViewById(R.id.width_slider); + + widthSlider.setValueTo(CUSTOM_WIDTH_MAX); + widthSlider.setValueFrom(CUSTOM_WIDTH_MIN); + + ((TextView) view.findViewById(R.id.width_value_min)).setText(String.valueOf(CUSTOM_WIDTH_MIN)); + ((TextView) view.findViewById(R.id.width_value_max)).setText(String.valueOf(CUSTOM_WIDTH_MAX)); + + String width = getSelectedItem().getValue(); + if (!Algorithms.isEmpty(width) && Algorithms.isInt(width)) { + try { + widthSlider.setValue(Integer.parseInt(width)); + } catch (NumberFormatException e) { + widthSlider.setValue(1); + } + } else { + widthSlider.setValue(1); + } + + final TextView selectedCustomWidth = view.findViewById(R.id.width_value_tv); + widthSlider.addOnChangeListener(new Slider.OnChangeListener() { + @Override + public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { + if (fromUser) { + String valueStr = String.valueOf((int) value); + selectedCustomWidth.setText(valueStr); + getSelectedItem().setValue(valueStr); + setGpxWidth(valueStr); + } + } + }); + UiUtilities.setupSlider(widthSlider, nightMode, null); + AndroidUiHelper.updateVisibility(view.findViewById(R.id.slider_container), true); + } else { + AndroidUiHelper.updateVisibility(view.findViewById(R.id.slider_container), false); + } + } + + private void setGpxWidth(String width) { + if (selectedGpxFile.getGpxFile() != null) { + GPXFile gpxFile = selectedGpxFile.getGpxFile(); + gpxFile.setWidth(width); + GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path)); + if (gpxDataItem != null) { + app.getGpxDbHelper().updateWidth(gpxDataItem, width); + } + mapActivity.refreshMap(); + } + } + + private class GpxWidthAdapter extends RecyclerView.Adapter { + + private List items; + + private GpxWidthAdapter(List items) { + this.items = items; + } + + @NonNull + @Override + public GpxWidthViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode); + View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false); + view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width); + view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height); + + GpxWidthViewHolder holder = new GpxWidthViewHolder(view); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + AndroidUtils.setBackground(app, holder.widthButton, nightMode, R.drawable.ripple_solid_light_6dp, + R.drawable.ripple_solid_dark_6dp); + } + return holder; + } + + @Override + public void onBindViewHolder(@NonNull final GpxWidthViewHolder holder, int position) { + AppearanceListItem item = items.get(position); + holder.widthAttrName.setText(item.getLocalizedValue()); + + updateButtonBg(holder, item); + updateWidthIcon(holder, item); + + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int prevSelectedPosition = getItemPosition(getSelectedItem()); + selectedItem = items.get(holder.getAdapterPosition()); + notifyItemChanged(holder.getAdapterPosition()); + notifyItemChanged(prevSelectedPosition); + + setGpxWidth(selectedItem.getValue()); + + updateHeader(); + updateCustomWidthSlider(); + } + }); + } + + private void updateWidthIcon(GpxWidthViewHolder holder, AppearanceListItem item) { + int color; + if (selectedGpxFile.isShowCurrentTrack()) { + color = app.getSettings().CURRENT_TRACK_COLOR.get(); + } else { + color = selectedGpxFile.getGpxFile().getColor(0); + } + + int iconId; + if (CUSTOM_WIDTH.equals(item.getAttrName())) { + iconId = R.drawable.ic_action_settings; + color = AndroidUtils.getColorFromAttr(holder.itemView.getContext(), R.attr.active_color_basic); + } else { + iconId = GpxAppearanceAdapter.getWidthIconId(item.getValue()); + } + holder.widthIcon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconId, color)); + } + + private void updateButtonBg(GpxWidthViewHolder holder, AppearanceListItem item) { + GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline); + if (rectContourDrawable != null) { + if (getSelectedItem() != null && getSelectedItem().equals(item)) { + int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light); + rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), strokeColor); + } else { + int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.stroked_buttons_and_links_outline_dark + : R.color.stroked_buttons_and_links_outline_light); + rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 1), strokeColor); + } + holder.widthButton.setImageDrawable(rectContourDrawable); + } + } + + @Override + public int getItemCount() { + return items.size(); + } + + int getItemPosition(AppearanceListItem name) { + return items.indexOf(name); + } + } + + private static class GpxWidthViewHolder extends RecyclerView.ViewHolder { + + final TextView widthAttrName; + final ImageView widthIcon; + final ImageView widthButton; + + GpxWidthViewHolder(View itemView) { + super(itemView); + widthAttrName = itemView.findViewById(R.id.groupName); + widthIcon = itemView.findViewById(R.id.groupIcon); + widthButton = itemView.findViewById(R.id.outlineRect); + } + } +} \ No newline at end of file From 2377a089ab47099fe3b6adcf303a081fda88d1fc Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Tue, 14 Jul 2020 11:02:02 +0300 Subject: [PATCH 112/551] Fix #6589 --- OsmAnd/res/values/strings.xml | 1 + .../plus/osmedit/AdvancedEditPoiFragment.java | 14 +++++++++++-- .../plus/osmedit/EditPoiDialogFragment.java | 16 ++++++++++++++- .../OpeningHoursDaysDialogFragment.java | 20 ++++++++++++------- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5d733cf83f..1141efecd2 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + You need to set working days to continue Closed OSM Note Go-cart Wheelchair forward diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 3aba617bda..9d343a04c2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -15,6 +15,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; +import android.widget.EditText; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; @@ -45,7 +46,8 @@ import java.util.Set; import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH; public class AdvancedEditPoiFragment extends BaseOsmAndFragment - implements EditPoiDialogFragment.OnFragmentActivatedListener { + implements EditPoiDialogFragment.OnFragmentActivatedListener, + EditPoiDialogFragment.OnSaveButtonClickListener { private static final String TAG = "AdvancedEditPoiFragment"; private static final Log LOG = PlatformUtil.getLog(AdvancedEditPoiFragment.class); @@ -55,6 +57,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment private TextView nameTextView; private TextView amenityTagTextView; private TextView amenityTextView; + private EditText currentTagEditText; @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { @@ -165,6 +168,13 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment } } + @Override + public void onSaveButtonClick() { + if (currentTagEditText != null) { + currentTagEditText.clearFocus(); + } + } + public class TagAdapterLinearLayoutHack { private final LinearLayout linearLayout; private final EditPoiData editPoiData; @@ -241,6 +251,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment } } } else { + currentTagEditText = tagEditText; tagAdapter.getFilter().filter(tagEditText.getText()); } } @@ -269,7 +280,6 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment initAutocompleteTextView(valueEditText, valueAdapter); linearLayout.addView(convertView); - tagEditText.requestFocus(); } public void setTagData(String[] tags) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 848fd77fd1..932ef59db5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -113,6 +113,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { private EditPoiViewPager viewPager; private AutoCompleteTextView poiTypeEditText; + private OnSaveButtonClickListener onSaveButtonClickListener; private OpenstreetmapUtil mOpenstreetmapUtil; private TextInputLayout poiTypeTextInputLayout; private View view; @@ -173,7 +174,13 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { @Override public void onPageSelected(int i) { - ((OnFragmentActivatedListener) pagerAdapter.getItem(i)).onFragmentActivated(); + Fragment pageFragment = pagerAdapter.getItem(i); + ((OnFragmentActivatedListener) pageFragment).onFragmentActivated(); + if (pageFragment instanceof OnSaveButtonClickListener) { + onSaveButtonClickListener = (OnSaveButtonClickListener) pageFragment; + } else { + onSaveButtonClickListener = null; + } } @Override @@ -433,6 +440,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { } private void trySave() { + if (onSaveButtonClickListener != null) { + onSaveButtonClickListener.onSaveButtonClick(); + } String tagWithExceedingValue = isTextLengthInRange(); if (!Algorithms.isEmpty(tagWithExceedingValue)){ ValueExceedLimitDialogFragment f = new ValueExceedLimitDialogFragment(); @@ -996,4 +1006,8 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { public interface OnFragmentActivatedListener { void onFragmentActivated(); } + + public interface OnSaveButtonClickListener { + void onSaveButtonClick(); + } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java index 497ceb4735..5dd69ac2c7 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java @@ -4,6 +4,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.text.format.DateFormat; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; @@ -57,21 +58,26 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment { } }); - builder.setPositiveButton(createNew ? R.string.next_proceed - : R.string.shared_string_save, + builder.setPositiveButton(createNew ? R.string.next_proceed : R.string.shared_string_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { boolean[] days = item.getDays(); + boolean activeDaysAvailable = false; for (int i = 0; i < 7; i++) { days[(first + 5 + i) % 7] = dayToShow[i]; + activeDaysAvailable = activeDaysAvailable || dayToShow[i]; } - if (createNew) { - OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true, 0) - .show(getFragmentManager(), "TimePickerDialogFragment"); + if (activeDaysAvailable) { + if (createNew) { + OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true, 0) + .show(getFragmentManager(), "TimePickerDialogFragment"); + } else { + ((BasicEditPoiFragment) getParentFragment()) + .setBasicOpeningHoursRule(item, positionToAdd); + } } else { - ((BasicEditPoiFragment) getParentFragment()) - .setBasicOpeningHoursRule(item, positionToAdd); + Toast.makeText(getContext(), getString(R.string.set_working_days_to_continue), Toast.LENGTH_SHORT).show(); } } From 67d2166d0fb6cb8f6304b620a7c94d521f2bc0db Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 14 Jul 2020 11:49:44 +0300 Subject: [PATCH 113/551] Move GpxSplitType and GradientScaleType to android module --- .../main/java/net/osmand/GPXUtilities.java | 69 ++++--------------- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 34 ++++++--- OsmAnd/src/net/osmand/plus/GpxDbHelper.java | 4 +- .../net/osmand/plus/GpxSelectionHelper.java | 18 ++--- .../TrackActivityFragmentAdapter.java | 2 +- .../net/osmand/plus/track/GpxSplitType.java | 32 +++++++++ .../osmand/plus/track/GradientScaleType.java | 40 +++++++++++ 7 files changed, 122 insertions(+), 77 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/track/GpxSplitType.java create mode 100644 OsmAnd/src/net/osmand/plus/track/GradientScaleType.java diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 3498450ab4..9b055cd01f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1514,52 +1514,38 @@ public class GPXUtilities { return new QuadRect(left, top, right, bottom); } - public int getGradientScaleColor(GradientScaleType gradientScaleType, int defColor) { + public int getGradientScaleColor(String gradientScaleType, int defColor) { String clrValue = null; if (extensions != null) { - clrValue = extensions.get(gradientScaleType.getTypeName()); + clrValue = extensions.get(gradientScaleType); } return parseColor(clrValue, defColor); } - public void setGradientScaleColor(GradientScaleType gradientScaleType, int gradientScaleColor) { - getExtensionsToWrite().put(gradientScaleType.getTypeName(), Algorithms.colorToString(gradientScaleColor)); + public void setGradientScaleColor(String gradientScaleType, int gradientScaleColor) { + getExtensionsToWrite().put(gradientScaleType, Algorithms.colorToString(gradientScaleColor)); } - public GradientScaleType getGradientScaleType() { + public String getGradientScaleType() { if (extensions != null) { - String gradientScaleTypeName = extensions.get("gradient_scale_type"); - if (!Algorithms.isEmpty(gradientScaleTypeName)) { - try { - return GradientScaleType.valueOf(gradientScaleTypeName); - } catch (IllegalArgumentException e) { - log.error("Error reading gradientScaleType", e); - } - } + return extensions.get("gradient_scale_type"); } return null; } - public void setGradientScaleType(GradientScaleType gradientScaleType) { - getExtensionsToWrite().put("gradient_scale_type", gradientScaleType.name()); + public void setGradientScaleType(String gradientScaleType) { + getExtensionsToWrite().put("gradient_scale_type", gradientScaleType); } - public GpxSplitType getSplitType() { + public String getSplitType() { if (extensions != null) { - String gradientScaleTypeName = extensions.get("split_type"); - if (!Algorithms.isEmpty(gradientScaleTypeName)) { - try { - return GpxSplitType.valueOf(gradientScaleTypeName); - } catch (IllegalArgumentException e) { - log.error("Error reading GpxSplitType", e); - } - } + return extensions.get("split_type"); } return null; } - public void setSplitType(GpxSplitType gpxSplitType) { - getExtensionsToWrite().put("split_type", gpxSplitType.name()); + public void setSplitType(String gpxSplitType) { + getExtensionsToWrite().put("split_type", gpxSplitType); } public double getSplitInterval() { @@ -1615,37 +1601,6 @@ public class GPXUtilities { getExtensionsToWrite().put("show_start_finish", String.valueOf(showStartFinish)); } - public enum GradientScaleType { - SPEED("gradient_speed_color"), - ALTITUDE("gradient_altitude_color"), - SLOPE("gradient_slope_color"); - - private String typeName; - - GradientScaleType(String typeName) { - this.typeName = typeName; - } - - public String getTypeName() { - return typeName; - } - } - - public enum GpxSplitType { - NO_SPLIT(-1), - DISTANCE(1), - TIME(2); - - private int type; - - GpxSplitType(int type) { - this.type = type; - } - - public int getType() { - return type; - } - } } public static String asString(GPXFile file) { diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index d0a19e80b9..7a3ec03992 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -4,11 +4,12 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.GPXUtilities.GPXFile.GradientScaleType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.IndexConstants; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; +import net.osmand.plus.track.GpxSplitType; +import net.osmand.plus.track.GradientScaleType; import net.osmand.util.Algorithms; import java.io.File; @@ -201,17 +202,34 @@ public class GPXDatabase { public GpxDataItem(File file, @NonNull GPXFile gpxFile) { this.file = file; + readGpxParams(gpxFile); + } + + private void readGpxParams(GPXFile gpxFile) { color = gpxFile.getColor(0); width = gpxFile.getWidth(null); showArrows = gpxFile.isShowArrows(); showStartFinish = gpxFile.isShowStartFinish(); - gradientScaleType = gpxFile.getGradientScaleType(); - gradientSpeedColor = gpxFile.getGradientScaleColor(GradientScaleType.SPEED, 0); - gradientSlopeColor = gpxFile.getGradientScaleColor(GradientScaleType.SLOPE, 0); - gradientAltitudeColor = gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE, 0); - if (gpxFile.getSplitType() != null && gpxFile.getSplitInterval() != 0) { - splitType = gpxFile.getSplitType().getType(); - splitInterval = gpxFile.getSplitInterval(); + gradientSpeedColor = gpxFile.getGradientScaleColor(GradientScaleType.SPEED.getTypeName(), 0); + gradientSlopeColor = gpxFile.getGradientScaleColor(GradientScaleType.SLOPE.getTypeName(), 0); + gradientAltitudeColor = gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE.getTypeName(), 0); + + if (!Algorithms.isEmpty(gpxFile.getSplitType()) && gpxFile.getSplitInterval() != 0) { + for (GpxSplitType gpxSplitType : GpxSplitType.values()) { + if (gpxSplitType.name().equalsIgnoreCase(gpxFile.getSplitType())) { + splitType = gpxSplitType.getType(); + splitInterval = gpxFile.getSplitInterval(); + break; + } + } + } + if (!Algorithms.isEmpty(gpxFile.getGradientScaleType())) { + for (GradientScaleType scaleType : GradientScaleType.values()) { + if (scaleType.name().equalsIgnoreCase(gpxFile.getGradientScaleType())) { + gradientScaleType = scaleType; + break; + } + } } } diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index fc0ffb636e..d5e05e8db3 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -8,11 +8,11 @@ import androidx.annotation.Nullable; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.GPXUtilities.GPXFile.GpxSplitType; -import net.osmand.GPXUtilities.GPXFile.GradientScaleType; +import net.osmand.plus.track.GpxSplitType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; +import net.osmand.plus.track.GradientScaleType; import java.io.File; import java.util.List; diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 6f239e2286..f75a5bf829 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -11,8 +11,7 @@ import androidx.core.content.ContextCompat; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.GPXUtilities.GPXFile.GpxSplitType; -import net.osmand.GPXUtilities.GPXFile.GradientScaleType; +import net.osmand.plus.track.GpxSplitType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.GPXUtilities.Route; import net.osmand.GPXUtilities.Track; @@ -29,6 +28,7 @@ import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants; +import net.osmand.plus.track.GradientScaleType; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -524,7 +524,7 @@ public class GpxSelectionHelper { for (GradientScaleType scaleType : GradientScaleType.values()) { if (obj.has(scaleType.getTypeName())) { int clr = Algorithms.parseColor(obj.getString(scaleType.getTypeName())); - gpx.setGradientScaleColor(scaleType, clr); + gpx.setGradientScaleColor(scaleType.getTypeName(), clr); } } if (obj.has(SHOW_ARROWS)) { @@ -534,7 +534,7 @@ public class GpxSelectionHelper { if (obj.has(GRADIENT_SCALE_TYPE)) { String gradientScaleTypeName = obj.optString(GRADIENT_SCALE_TYPE); if (!Algorithms.isEmpty(gradientScaleTypeName)) { - gpx.setGradientScaleType(GradientScaleType.valueOf(gradientScaleTypeName)); + gpx.setGradientScaleType(GradientScaleType.valueOf(gradientScaleTypeName).getTypeName()); } } if (obj.has(SHOW_START_FINISH)) { @@ -592,7 +592,7 @@ public class GpxSelectionHelper { obj.put(SHOW_ARROWS, s.gpxFile.isShowArrows()); obj.put(SHOW_START_FINISH, s.gpxFile.isShowStartFinish()); for (GradientScaleType scaleType : GradientScaleType.values()) { - int gradientScaleColor = s.gpxFile.getGradientScaleColor(scaleType, 0); + int gradientScaleColor = s.gpxFile.getGradientScaleColor(scaleType.getTypeName(), 0); if (gradientScaleColor != 0) { obj.put(scaleType.getTypeName(), Algorithms.colorToString(gradientScaleColor)); } @@ -650,16 +650,16 @@ public class GpxSelectionHelper { gpx.setColor(dataItem.getColor()); } if (dataItem.getGradientSpeedColor() != 0) { - gpx.setGradientScaleColor(GradientScaleType.SPEED, dataItem.getGradientSpeedColor()); + gpx.setGradientScaleColor(GradientScaleType.SPEED.getTypeName(), dataItem.getGradientSpeedColor()); } if (dataItem.getGradientAltitudeColor() != 0) { - gpx.setGradientScaleColor(GradientScaleType.ALTITUDE, dataItem.getGradientAltitudeColor()); + gpx.setGradientScaleColor(GradientScaleType.ALTITUDE.getTypeName(), dataItem.getGradientAltitudeColor()); } if (dataItem.getGradientSlopeColor() != 0) { - gpx.setGradientScaleColor(GradientScaleType.SLOPE, dataItem.getGradientSlopeColor()); + gpx.setGradientScaleColor(GradientScaleType.SLOPE.getTypeName(), dataItem.getGradientSlopeColor()); } if (dataItem.getGradientScaleType() != null) { - gpx.setGradientScaleType(dataItem.getGradientScaleType()); + gpx.setGradientScaleType(dataItem.getGradientScaleType().getTypeName()); } if (dataItem.getWidth() != null) { gpx.setWidth(dataItem.getWidth()); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java index 260d7fccda..99cfa60ddc 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java @@ -39,7 +39,7 @@ import com.squareup.picasso.RequestCreator; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.GPXUtilities.GPXFile.GpxSplitType; +import net.osmand.plus.track.GpxSplitType; import net.osmand.GPXUtilities.WptPt; import net.osmand.PicassoUtils; import net.osmand.data.LatLon; diff --git a/OsmAnd/src/net/osmand/plus/track/GpxSplitType.java b/OsmAnd/src/net/osmand/plus/track/GpxSplitType.java new file mode 100644 index 0000000000..76659a36ce --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/track/GpxSplitType.java @@ -0,0 +1,32 @@ +package net.osmand.plus.track; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.StringRes; + +import net.osmand.plus.R; + +public enum GpxSplitType { + + NO_SPLIT(-1, R.string.shared_string_none), + DISTANCE(1, R.string.distance), + TIME(2, R.string.shared_string_time); + + private int type; + @StringRes + private int resId; + + GpxSplitType(int type, @StringRes int resId) { + this.type = type; + this.resId = resId; + } + + public int getType() { + return type; + } + + public String getHumanString(@NonNull Context ctx) { + return ctx.getString(resId); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java b/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java new file mode 100644 index 0000000000..9c2ae36a59 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java @@ -0,0 +1,40 @@ +package net.osmand.plus.track; + +import android.content.Context; + +import androidx.annotation.DrawableRes; +import androidx.annotation.NonNull; +import androidx.annotation.StringRes; + +import net.osmand.plus.R; + +public enum GradientScaleType { + + SPEED("gradient_speed_color", R.string.map_widget_speed, R.drawable.ic_action_speed), + ALTITUDE("gradient_altitude_color", R.string.altitude, R.drawable.ic_action_altitude_average), + SLOPE("gradient_slope_color", R.string.shared_string_slope, R.drawable.ic_action_altitude_ascent); + + private String typeName; + @StringRes + private int resId; + @DrawableRes + private int iconId; + + GradientScaleType(@NonNull String typeName, @StringRes int resId, @DrawableRes int iconId) { + this.typeName = typeName; + this.resId = resId; + this.iconId = iconId; + } + + public String getTypeName() { + return typeName; + } + + public int getIconId() { + return iconId; + } + + public String getHumanString(@NonNull Context ctx) { + return ctx.getString(resId); + } +} From 07fe241f9e8da5b74181868b606283d97dda874d Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 14 Jul 2020 12:19:54 +0300 Subject: [PATCH 114/551] Fix avoid roads icon position --- OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java index 6acc0c8d7b..e2e715a029 100644 --- a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java @@ -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); } From bd54b829efdfce06082ce330652ccfe4ab4b14a7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 14 Jul 2020 15:00:34 +0300 Subject: [PATCH 115/551] Add solid gradient scale type and track coloring card --- .../main/java/net/osmand/GPXUtilities.java | 1 - OsmAnd/res/values/strings.xml | 1 + .../net/osmand/plus/GpxSelectionHelper.java | 2 +- .../osmand/plus/track/GradientScaleType.java | 1 + .../TrackAppearanceFragment.java | 6 +- .../osmand/plus/track/TrackColoringCard.java | 287 ++++++++++++++++++ .../{myplaces => track}/TrackWidthCard.java | 2 +- 7 files changed, 296 insertions(+), 4 deletions(-) rename OsmAnd/src/net/osmand/plus/{myplaces => track}/TrackAppearanceFragment.java (95%) create mode 100644 OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java rename OsmAnd/src/net/osmand/plus/{myplaces => track}/TrackWidthCard.java (99%) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 9b055cd01f..aec72cbbcb 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1600,7 +1600,6 @@ public class GPXUtilities { public void setShowStartFinish(boolean showStartFinish) { getExtensionsToWrite().put("show_start_finish", String.valueOf(showStartFinish)); } - } public static String asString(GPXFile file) { diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 83cb0a8b90..b7feef3e1b 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Solid Direction arrows Custom Select the desired splitting option: by time or by distance. diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index f75a5bf829..f8adfdbf5c 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -659,7 +659,7 @@ public class GpxSelectionHelper { gpx.setGradientScaleColor(GradientScaleType.SLOPE.getTypeName(), dataItem.getGradientSlopeColor()); } if (dataItem.getGradientScaleType() != null) { - gpx.setGradientScaleType(dataItem.getGradientScaleType().getTypeName()); + gpx.setGradientScaleType(dataItem.getGradientScaleType().name()); } if (dataItem.getWidth() != null) { gpx.setWidth(dataItem.getWidth()); diff --git a/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java b/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java index 9c2ae36a59..b458078528 100644 --- a/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java +++ b/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java @@ -10,6 +10,7 @@ import net.osmand.plus.R; public enum GradientScaleType { + SOLID("gradient_solid_color", R.string.track_coloring_solid, R.drawable.ic_action_circle), SPEED("gradient_speed_color", R.string.map_widget_speed, R.drawable.ic_action_speed), ALTITUDE("gradient_altitude_color", R.string.altitude, R.drawable.ic_action_altitude_average), SLOPE("gradient_slope_color", R.string.shared_string_slope, R.drawable.ic_action_altitude_ascent); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java similarity index 95% rename from OsmAnd/src/net/osmand/plus/myplaces/TrackAppearanceFragment.java rename to OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index 839084db2a..0c60221f9a 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -1,4 +1,4 @@ -package net.osmand.plus.myplaces; +package net.osmand.plus.track; import android.os.Bundle; import android.view.Gravity; @@ -19,6 +19,7 @@ import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.myplaces.DirectionArrowsCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard; @@ -124,6 +125,9 @@ public class TrackAppearanceFragment extends ContextMenuFragment { BaseCard arrowsCard = new DirectionArrowsCard(mapActivity, selectedGpxFile); cardsContainer.addView(arrowsCard.build(mapActivity)); + TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile); + cardsContainer.addView(trackColoringCard.build(mapActivity)); + BaseCard width = new TrackWidthCard(mapActivity, selectedGpxFile); cardsContainer.addView(width.build(mapActivity)); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java new file mode 100644 index 0000000000..c9117b3bc0 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java @@ -0,0 +1,287 @@ +package net.osmand.plus.track; + +import android.graphics.drawable.GradientDrawable; +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import net.osmand.AndroidUtils; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.plus.GPXDatabase.GpxDataItem; +import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; +import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.plus.widgets.FlowLayout; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems; + +public class TrackColoringCard extends BaseCard { + + private SelectedGpxFile selectedGpxFile; + + private GradientScaleType selectedScaleType; + + @ColorInt + private int selectedColor; + + public TrackColoringCard(MapActivity mapActivity, GpxSelectionHelper.SelectedGpxFile selectedGpxFile) { + super(mapActivity); + this.mapActivity = mapActivity; + this.selectedGpxFile = selectedGpxFile; + } + + @Override + public int getCardLayoutId() { + return R.layout.track_coloring_card; + } + + @Override + protected void updateContent() { + updateHeader(); + updateCustomWidthSlider(); + createColorSelector(); + + RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view); + groupRecyclerView.setAdapter(new GpxWidthAdapter(Arrays.asList(GradientScaleType.values()))); + groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); + } + + private void createColorSelector() { + FlowLayout selectColor = view.findViewById(R.id.select_color); + List colors = new ArrayList<>(); + for (AppearanceListItem appearanceListItem : getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_COLOR)) { + if (!colors.contains(appearanceListItem.getColor())) { + colors.add(appearanceListItem.getColor()); + } + } + for (int color : colors) { + selectColor.addView(createColorItemView(color, selectColor), new FlowLayout.LayoutParams(0, 0)); + } + + if (selectedGpxFile.isShowCurrentTrack()) { + selectedColor = app.getSettings().CURRENT_TRACK_COLOR.get(); + } else { + selectedColor = selectedGpxFile.getGpxFile().getColor(0); + } + updateColorSelector(selectedColor, selectColor); + } + + private View createColorItemView(@ColorInt final int color, final FlowLayout rootView) { + FrameLayout colorItemView = (FrameLayout) UiUtilities.getInflater(rootView.getContext(), nightMode) + .inflate(R.layout.point_editor_button, rootView, false); + ImageView outline = colorItemView.findViewById(R.id.outline); + outline.setImageDrawable( + UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle_contour), + ContextCompat.getColor(app, + nightMode ? R.color.stroked_buttons_and_links_outline_dark + : R.color.stroked_buttons_and_links_outline_light))); + ImageView backgroundCircle = colorItemView.findViewById(R.id.background); + backgroundCircle.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle), color)); + backgroundCircle.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + updateColorSelector(color, rootView); + } + }); + colorItemView.setTag(color); + return colorItemView; + } + + private void updateColorSelector(int color, View rootView) { + View oldColor = rootView.findViewWithTag(selectedColor); + if (oldColor != null) { + oldColor.findViewById(R.id.outline).setVisibility(View.INVISIBLE); + ImageView icon = oldColor.findViewById(R.id.icon); + icon.setImageDrawable(UiUtilities.tintDrawable(icon.getDrawable(), R.color.icon_color_default_light)); + } + View newColor = rootView.findViewWithTag(color); + if (newColor != null) { + newColor.findViewById(R.id.outline).setVisibility(View.VISIBLE); + } + selectedColor = color; + setGpxColor(color); + } + + private void setGpxColor(int color) { + GPXFile gpxFile = selectedGpxFile.getGpxFile(); + if (gpxFile != null) { + if (color != 0) { + selectedGpxFile.getGpxFile().setColor(color); + GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path)); + if (gpxDataItem != null) { + app.getGpxDbHelper().updateColor(gpxDataItem, color); + } + } + if (gpxFile.showCurrentTrack) { + app.getSettings().CURRENT_TRACK_COLOR.set(color); + } + mapActivity.refreshMap(); + } + } + + private GradientScaleType getSelectedScaleType() { + if (selectedScaleType == null) { + String gradientScaleType = selectedGpxFile.getGpxFile().getGradientScaleType(); + for (GradientScaleType item : GradientScaleType.values()) { + if (item.name().equalsIgnoreCase(gradientScaleType)) { + selectedScaleType = item; + break; + } + } + if (selectedScaleType == null) { + selectedScaleType = GradientScaleType.SOLID; + } + } + return selectedScaleType; + } + + private void updateHeader() { + AndroidUiHelper.updateVisibility(view.findViewById(R.id.icon), false); + + TextView titleView = view.findViewById(R.id.title); + titleView.setText(R.string.select_color); + + TextView descriptionView = view.findViewById(R.id.description); + descriptionView.setText(getSelectedScaleType().getHumanString(view.getContext())); + } + + private void updateCustomWidthSlider() { + boolean visible = GradientScaleType.SOLID == getSelectedScaleType(); + AndroidUiHelper.updateVisibility(view.findViewById(R.id.select_color), visible); + } + + private void setGradientScaleType(GradientScaleType gradientScaleType) { + if (selectedGpxFile.getGpxFile() != null) { + GPXFile gpxFile = selectedGpxFile.getGpxFile(); + gpxFile.setGradientScaleType(gradientScaleType.getTypeName()); + GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path)); + if (gpxDataItem != null) { + app.getGpxDbHelper().updateGradientScaleType(gpxDataItem, gradientScaleType); + } + mapActivity.refreshMap(); + } + } + + private class GpxWidthAdapter extends RecyclerView.Adapter { + + private List items; + + private GpxWidthAdapter(List items) { + this.items = items; + } + + @NonNull + @Override + public GpxWidthViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode); + View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false); + view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width); + view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height); + + GpxWidthViewHolder holder = new GpxWidthViewHolder(view); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + AndroidUtils.setBackground(app, holder.widthButton, nightMode, R.drawable.ripple_solid_light_6dp, + R.drawable.ripple_solid_dark_6dp); + } + return holder; + } + + @Override + public void onBindViewHolder(@NonNull final GpxWidthViewHolder holder, int position) { + GradientScaleType item = items.get(position); + holder.widthAttrName.setText(item.getHumanString(holder.itemView.getContext())); + + updateButtonBg(holder, item); + + int colorId; + if (item == GradientScaleType.SOLID) { + if (selectedGpxFile.isShowCurrentTrack()) { + colorId = app.getSettings().CURRENT_TRACK_COLOR.get(); + } else { + colorId = selectedGpxFile.getGpxFile().getColor(0); + } + } else if (item.equals(getSelectedScaleType())) { + colorId = ContextCompat.getColor(app, nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light); + } else { + colorId = AndroidUtils.getColorFromAttr(holder.itemView.getContext(), R.attr.default_icon_color); + } + + holder.widthIcon.setImageDrawable(app.getUIUtilities().getPaintedIcon(item.getIconId(), colorId)); + + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int prevSelectedPosition = getItemPosition(getSelectedScaleType()); + selectedScaleType = items.get(holder.getAdapterPosition()); + notifyItemChanged(holder.getAdapterPosition()); + notifyItemChanged(prevSelectedPosition); + + setGradientScaleType(selectedScaleType); + + updateHeader(); + updateCustomWidthSlider(); + } + }); + } + + private void updateButtonBg(GpxWidthViewHolder holder, GradientScaleType item) { + GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline); + if (rectContourDrawable != null) { + if (getSelectedScaleType() != null && getSelectedScaleType().equals(item)) { + int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light); + rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), strokeColor); + } else { + int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.stroked_buttons_and_links_outline_dark + : R.color.stroked_buttons_and_links_outline_light); + rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 1), strokeColor); + } + holder.widthButton.setImageDrawable(rectContourDrawable); + } + } + + @Override + public int getItemCount() { + return items.size(); + } + + int getItemPosition(GradientScaleType name) { + return items.indexOf(name); + } + } + + private static class GpxWidthViewHolder extends RecyclerView.ViewHolder { + + final TextView widthAttrName; + final ImageView widthIcon; + final ImageView widthButton; + + GpxWidthViewHolder(View itemView) { + super(itemView); + widthAttrName = itemView.findViewById(R.id.groupName); + widthIcon = itemView.findViewById(R.id.groupIcon); + widthButton = itemView.findViewById(R.id.outlineRect); + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackWidthCard.java b/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java similarity index 99% rename from OsmAnd/src/net/osmand/plus/myplaces/TrackWidthCard.java rename to OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java index e49ff6beb9..bceded63f0 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java @@ -1,4 +1,4 @@ -package net.osmand.plus.myplaces; +package net.osmand.plus.track; import android.graphics.drawable.GradientDrawable; import android.os.Build; From e5c61ddc8b91ba447fff7eac34ee63dcdccc4989 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 14 Jul 2020 17:31:21 +0300 Subject: [PATCH 116/551] Remove track color setting from TrackActivityFragmentAdapter --- OsmAnd/res/layout/gpx_item_list_header.xml | 34 ------ .../TrackActivityFragmentAdapter.java | 112 +----------------- .../osmand/plus/track/TrackColoringCard.java | 1 - .../net/osmand/plus/track/TrackWidthCard.java | 1 - 4 files changed, 2 insertions(+), 146 deletions(-) diff --git a/OsmAnd/res/layout/gpx_item_list_header.xml b/OsmAnd/res/layout/gpx_item_list_header.xml index 43ceaf7e3f..4cef607fb6 100644 --- a/OsmAnd/res/layout/gpx_item_list_header.xml +++ b/OsmAnd/res/layout/gpx_item_list_header.xml @@ -158,40 +158,6 @@ - - - - - - - - diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java index 99cfa60ddc..74991ffce2 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java @@ -39,7 +39,6 @@ import com.squareup.picasso.RequestCreator; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.plus.track.GpxSplitType; import net.osmand.GPXUtilities.WptPt; import net.osmand.PicassoUtils; import net.osmand.data.LatLon; @@ -55,19 +54,15 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TrackActivity; -import net.osmand.plus.dialogs.GpxAppearanceAdapter; -import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; -import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType; import net.osmand.plus.measurementtool.NewGpxData; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; +import net.osmand.plus.track.GpxSplitType; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.WikivoyageUtils; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; -import net.osmand.render.RenderingRulesStorage; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -76,9 +71,6 @@ import java.util.Map; import gnu.trove.list.array.TIntArrayList; -import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR; -import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR; - public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { private OsmandApplication app; @@ -308,7 +300,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { final View splitColorView = headerView.findViewById(R.id.split_color_view); final View divider = headerView.findViewById(R.id.divider); final View splitIntervalView = headerView.findViewById(R.id.split_interval_view); - final View colorView = headerView.findViewById(R.id.color_view); vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle); final View bottomDivider = headerView.findViewById(R.id.bottom_divider); GPXFile gpxFile = getGpx(); @@ -340,7 +331,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { setTrackVisibilityOnMap(vis.isChecked()); if (!showMapOnly) { updateSplitIntervalView(splitIntervalView); - updateColorView(colorView); } TrackActivity trackActivity = getTrackActivity(); if (trackActivity != null) { @@ -358,37 +348,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { } else { bottomDivider.setVisibility(View.GONE); - updateColorView(colorView); - colorView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - TrackActivity activity = getTrackActivity(); - final GPXFile gpxFile = getGpx(); - if (activity != null && gpxFile != null) { - final GpxAppearanceAdapter appearanceAdapter = new GpxAppearanceAdapter(activity, - gpxFile.getColor(0), GpxAppearanceAdapterType.TRACK_WIDTH_COLOR); - OnItemClickListener itemClickListener = new OnItemClickListener() { - - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - AppearanceListItem item = appearanceAdapter.getItem(position); - if (item != null) { - if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) { - setGpxColor(item, gpxFile); - } else if (CURRENT_TRACK_WIDTH_ATTR.equals(item.getAttrName())) { - setGpxWidth(item, gpxFile); - } - } - colorListPopupWindow.dismiss(); - updateColorView(colorView); - } - }; - colorListPopupWindow = createPopupWindow(activity, splitIntervalView, appearanceAdapter, itemClickListener); - colorListPopupWindow.show(); - } - } - }); - if (hasPath) { if (!gpxFile.showCurrentTrack && listItemsCount > 0) { prepareSplitIntervalAdapterData(); @@ -428,41 +387,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { } } - private void setGpxColor(AppearanceListItem item, GPXFile gpxFile) { - int color = item.getColor(); - if (vis.isChecked()) { - SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, vis.isChecked(), false); - if (color != 0 && sf.getModifiableGpxFile() != null) { - sf.getModifiableGpxFile().setColor(color); - if (getGpxDataItem() != null) { - app.getGpxDbHelper().updateColor(getGpxDataItem(), color); - } - } - } else if (getGpxDataItem() != null) { - app.getGpxDbHelper().updateColor(getGpxDataItem(), color); - } - if (gpxFile.showCurrentTrack) { - app.getSettings().CURRENT_TRACK_COLOR.set(color); - } - refreshTrackBitmap(); - } - - private void setGpxWidth(AppearanceListItem item, GPXFile gpxFile) { - String width = item.getValue(); - if (vis.isChecked()) { - SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, vis.isChecked(), false); - if (width != null && sf.getModifiableGpxFile() != null) { - sf.getModifiableGpxFile().setWidth(width); - if (getGpxDataItem() != null) { - app.getGpxDbHelper().updateWidth(getGpxDataItem(), width); - } - } - } else if (getGpxDataItem() != null) { - app.getGpxDbHelper().updateWidth(getGpxDataItem(), width); - } - refreshTrackBitmap(); - } - private ListPopupWindow createPopupWindow(Activity activity, View anchorView, ListAdapter adapter, OnItemClickListener itemClickListener) { ListPopupWindow popupWindow = new ListPopupWindow(activity); popupWindow.setAnchorView(anchorView); @@ -773,33 +697,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { return Math.max(position, 0); } - private void updateColorView(View colorView) { - final ImageView colorImageView = (ImageView) colorView.findViewById(R.id.colorImage); - int color = getGpxDataItem() != null ? getGpxDataItem().getColor() : 0; - GPXFile gpxFile = getGpx(); - if (color == 0 && gpxFile != null) { - if (gpxFile.showCurrentTrack) { - color = app.getSettings().CURRENT_TRACK_COLOR.get(); - } else { - color = gpxFile.getColor(0); - } - } - if (color == 0) { - RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); - CommonPreference prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR); - color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColor.get()); - } - if (color == 0) { - colorImageView.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle)); - } else { - colorImageView.setImageDrawable(app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color)); - } - TrackBitmapDrawer trackDrawer = getTrackBitmapDrawer(); - if (trackDrawer != null) { - trackDrawer.setTrackColor(color); - } - } - public List flatten(List groups) { ArrayList list = new ArrayList<>(); for (GpxDisplayGroup g : groups) { @@ -1057,11 +954,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { List groups = fragment.getDisplayGroups(); selectedGpx.setDisplayGroups(groups, app); } - /* - if (fragment.isVisible()) { - fragment.updateContent(); - } - */ } } @@ -1079,4 +971,4 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { return null; } } -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java index c9117b3bc0..8bf1fb89e6 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java @@ -48,7 +48,6 @@ public class TrackColoringCard extends BaseCard { public TrackColoringCard(MapActivity mapActivity, GpxSelectionHelper.SelectedGpxFile selectedGpxFile) { super(mapActivity); - this.mapActivity = mapActivity; this.selectedGpxFile = selectedGpxFile; } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java b/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java index bceded63f0..3159e516b8 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java @@ -46,7 +46,6 @@ public class TrackWidthCard extends BaseCard { public TrackWidthCard(MapActivity mapActivity, SelectedGpxFile selectedGpxFile) { super(mapActivity); - this.mapActivity = mapActivity; this.selectedGpxFile = selectedGpxFile; appearanceItems = getWidthAppearanceItems(); } From 7534c0bfc81c060b4144139724dd9099c7aa2228 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 14 Jul 2020 18:54:19 +0300 Subject: [PATCH 117/551] Fix importing profile (refactor) --- OsmAnd/res/values-eo/strings.xml | 2 +- .../net/osmand/plus/CustomOsmandPlugin.java | 8 +- .../plus/settings/backend/SettingsHelper.java | 143 ++++++++------ .../ExportImportSettingsAdapter.java | 33 ++-- .../fragments/ExportProfileBottomSheet.java | 21 +- .../fragments/ImportCompleteFragment.java | 3 +- .../fragments/ImportSettingsFragment.java | 179 ++++++++++++------ 7 files changed, 243 insertions(+), 146 deletions(-) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index 47ab66dfe5..4d47baaff2 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -3611,7 +3611,7 @@ Anstataŭigi alian punkton per tiu ĉi. Aplikis ŝanĝojn al la profilo “%1$s”. Ne povas legi el “%1$s”. - Ne povas skribi al “%1%s”. + Ne povas skribi al “%1$s”. Ne povas enporti el “%1$s”. Elekti dosieron de spuro Lingvoj diff --git a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java index 2c232ea8e8..e0cb743a64 100644 --- a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java @@ -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 poiUIFilters = poiUiFilterSettingsItem.getItems(); + } else if (item instanceof PoiUiFiltersSettingsItem) { + PoiUiFiltersSettingsItem poiUiFiltersSettingsItem = (PoiUiFiltersSettingsItem) item; + List poiUIFilters = poiUiFiltersSettingsItem.getItems(); for (PoiUIFilter filter : poiUIFilters) { app.getPoiFilters().removePoiFilter(filter); } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/SettingsHelper.java index 2abbd10e22..41d251ea06 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/SettingsHelper.java @@ -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 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 getReader(); @Nullable - abstract SettingsItemWriter getWriter(); + abstract SettingsItemWriter getWriter(); @NonNull - SettingsItemReader getJsonReader() { + SettingsItemReader getJsonReader() { return new SettingsItemReader(this) { @Override public void readFromStream(@NonNull InputStream inputStream) throws IOException, IllegalArgumentException { @@ -315,7 +320,7 @@ public class SettingsHelper { } @NonNull - SettingsItemWriter getJsonWriter() { + SettingsItemWriter getJsonWriter() { return new SettingsItemWriter(this) { @Override public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { @@ -445,13 +450,13 @@ public class SettingsHelper { @Nullable @Override - SettingsItemReader getReader() { + SettingsItemReader getReader() { return null; } @Nullable @Override - SettingsItemWriter getWriter() { + SettingsItemWriter getWriter() { return null; } } @@ -555,13 +560,13 @@ public class SettingsHelper { @Nullable @Override - SettingsItemReader getReader() { + SettingsItemReader getReader() { return null; } @Nullable @Override - SettingsItemWriter getWriter() { + SettingsItemWriter getWriter() { return null; } } @@ -638,13 +643,13 @@ public class SettingsHelper { @Nullable @Override - SettingsItemReader getReader() { + SettingsItemReader getReader() { return null; } @Nullable @Override - SettingsItemWriter getWriter() { + SettingsItemWriter getWriter() { return null; } } @@ -664,12 +669,12 @@ public class SettingsHelper { duplicateItems = new ArrayList<>(); } - CollectionSettingsItem(OsmandApplication app, @NonNull List items) { - super(app); + CollectionSettingsItem(@NonNull OsmandApplication app, @Nullable CollectionSettingsItem baseItem, @NonNull List 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 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 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 reader = getReader(); if (reader instanceof OsmandSettingsItemReader) { ((OsmandSettingsItemReader) reader).readPreferencesFromJson(additionalPrefsJson); } @@ -1116,7 +1126,7 @@ public class SettingsHelper { @Nullable @Override - SettingsItemReader getReader() { + SettingsItemReader 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 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 getWriter() { return new StreamSettingsItemWriter(this); } } @@ -1282,7 +1292,7 @@ public class SettingsHelper { @Nullable @Override - SettingsItemReader getReader() { + SettingsItemReader 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 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 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 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 getWriter() { return null; } } @@ -1585,7 +1596,11 @@ public class SettingsHelper { private QuickActionRegistry actionRegistry; public QuickActionsSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { - super(app, items); + super(app, null, items); + } + + public QuickActionsSettingsItem(@NonNull OsmandApplication app, @Nullable QuickActionsSettingsItem baseItem, @NonNull List 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 getReader() { return getJsonReader(); } @Nullable @Override - SettingsItemWriter getWriter() { + SettingsItemWriter getWriter() { return null; } } - public static class PoiUiFilterSettingsItem extends CollectionSettingsItem { + public static class PoiUiFiltersSettingsItem extends CollectionSettingsItem { - public PoiUiFilterSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { - super(app, items); + public PoiUiFiltersSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + super(app, null, items); } - PoiUiFilterSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + public PoiUiFiltersSettingsItem(@NonNull OsmandApplication app, @Nullable PoiUiFiltersSettingsItem baseItem, @NonNull List 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 getReader() { return getJsonReader(); } @Nullable @Override - SettingsItemWriter getWriter() { + SettingsItemWriter getWriter() { return null; } } @@ -1889,7 +1908,11 @@ public class SettingsHelper { private List existingItemsNames; public MapSourcesSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { - super(app, items); + super(app, null, items); + } + + public MapSourcesSettingsItem(@NonNull OsmandApplication app, @Nullable MapSourcesSettingsItem baseItem, @NonNull List 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 getReader() { return getJsonReader(); } @Nullable @Override - SettingsItemWriter getWriter() { + SettingsItemWriter getWriter() { return null; } } @@ -2102,7 +2125,11 @@ public class SettingsHelper { private AvoidSpecificRoads specificRoads; public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { - super(app, items); + super(app, null, items); + } + + public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @Nullable AvoidRoadsSettingsItem baseItem, @NonNull List 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 getReader() { return getJsonReader(); } @Nullable @Override - SettingsItemWriter getWriter() { + SettingsItemWriter getWriter() { return null; } } @@ -2256,7 +2283,7 @@ public class SettingsHelper { private OsmandApplication app; private List 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 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 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); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java index cf2b8d6a11..18e8900203 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java @@ -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 dataToOperate; + private List data; private Map> itemsMap; private List 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 getDataToOperate() { - return this.dataToOperate; + List getData() { + return this.data; } public enum Type { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportProfileBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportProfileBottomSheet.java index fc25b7990c..a09a8ba435 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportProfileBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportProfileBottomSheet.java @@ -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 prepareSettingsItemsForExport() { List 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 poiUIFilters = new ArrayList<>(); List tileSourceTemplates = new ArrayList<>(); List 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; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java index b7ab4e13ea..a521e8e079 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java @@ -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 diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index bf3df71f48..13dc2f94ce 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -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 selectedItems = getSettingsItemsFromData(adapter.getDataToOperate()); + List 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 getSettingsItemsFromData(List 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 getSettingsItemsFromData(List data) { List settingsItems = new ArrayList<>(); + List appModeBeans = new ArrayList<>(); List quickActions = new ArrayList<>(); List poiUIFilters = new ArrayList<>(); List tileSourceTemplates = new ArrayList<>(); List 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> getSettingsToOperate(List settingsItems, boolean importComplete) { Map> settingsToOperate = new HashMap<>(); - List profiles = new ArrayList<>(); + List profiles = new ArrayList<>(); List quickActions = new ArrayList<>(); List poiUIFilters = new ArrayList<>(); List tileSourceTemplates = new ArrayList<>(); List routingFilesList = new ArrayList<>(); List renderFilesList = new ArrayList<>(); List 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; } } From 1eb20f7dfa3900d097b5e59227bfab50adedb341 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 14 Jul 2020 20:59:08 +0300 Subject: [PATCH 118/551] Add split interval card and bottom sheet --- OsmAnd/res/layout/track_coloring_card.xml | 45 +++ OsmAnd/res/layout/track_split_interval.xml | 169 +++++++++ .../osmand/plus/activities/TrackActivity.java | 2 +- .../myplaces/SplitSegmentDialogFragment.java | 4 +- .../plus/myplaces/SplitTrackAsyncTask.java | 76 ++++ .../TrackActivityFragmentAdapter.java | 117 +++--- .../plus/track/SplitIntervalBottomSheet.java | 358 ++++++++++++++++++ .../osmand/plus/track/SplitIntervalCard.java | 44 +++ .../plus/track/TrackAppearanceFragment.java | 6 +- 9 files changed, 745 insertions(+), 76 deletions(-) create mode 100644 OsmAnd/res/layout/track_coloring_card.xml create mode 100644 OsmAnd/res/layout/track_split_interval.xml create mode 100644 OsmAnd/src/net/osmand/plus/myplaces/SplitTrackAsyncTask.java create mode 100644 OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java create mode 100644 OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java diff --git a/OsmAnd/res/layout/track_coloring_card.xml b/OsmAnd/res/layout/track_coloring_card.xml new file mode 100644 index 0000000000..1b71491c5d --- /dev/null +++ b/OsmAnd/res/layout/track_coloring_card.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/track_split_interval.xml b/OsmAnd/res/layout/track_split_interval.xml new file mode 100644 index 0000000000..7b12e4c22d --- /dev/null +++ b/OsmAnd/res/layout/track_split_interval.xml @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java index 64c137e347..15f37141db 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java @@ -178,7 +178,7 @@ public class TrackActivity extends TabActivity { } } - public List getGpxFile(boolean useDisplayGroups) { + public List getGpxDisplayGroups(boolean useDisplayGroups) { if (gpxFile == null) { return new ArrayList<>(); } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentDialogFragment.java index c7b3d0ba18..4601f73e11 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentDialogFragment.java @@ -380,7 +380,7 @@ public class SplitSegmentDialogFragment extends DialogFragment { private List filterGroups(boolean useDisplayGroups) { List groups = new ArrayList<>(); if (getTrackActivity() != null) { - List result = getTrackActivity().getGpxFile(useDisplayGroups); + List result = getTrackActivity().getGpxDisplayGroups(useDisplayGroups); for (GpxDisplayGroup group : result) { boolean add = hasFilterType(group.getType()); if (add) { @@ -397,7 +397,7 @@ public class SplitSegmentDialogFragment extends DialogFragment { TrackActivity trackActivity = getTrackActivity(); List splitSegments = new ArrayList<>(); if (trackActivity != null) { - List result = trackActivity.getGpxFile(true); + List result = trackActivity.getGpxDisplayGroups(true); if (result != null && result.size() > 0 && trkSegment.points.size() > 0) { for (GpxDisplayGroup group : result) { splitSegments.addAll(collectDisplayItemsFromGroup(group)); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitTrackAsyncTask.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitTrackAsyncTask.java new file mode 100644 index 0000000000..464530a16d --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitTrackAsyncTask.java @@ -0,0 +1,76 @@ +package net.osmand.plus.myplaces; + +import android.os.AsyncTask; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.track.GpxSplitType; + +import java.util.List; + +public class SplitTrackAsyncTask extends AsyncTask { + + private OsmandApplication app; + private GpxSplitType gpxSplitType; + private List groups; + private SplitTrackListener splitTrackListener; + + private boolean joinSegments; + private int timeSplitInterval; + private double distanceSplitInterval; + + public SplitTrackAsyncTask(@NonNull OsmandApplication app, + @NonNull GpxSplitType gpxSplitType, + @NonNull List groups, + @Nullable SplitTrackListener splitTrackListener, + boolean joinSegments, + int timeSplitInterval, + double distanceSplitInterval) { + this.app = app; + this.groups = groups; + this.gpxSplitType = gpxSplitType; + this.splitTrackListener = splitTrackListener; + this.joinSegments = joinSegments; + this.timeSplitInterval = timeSplitInterval; + this.distanceSplitInterval = distanceSplitInterval; + } + + @Override + protected void onPreExecute() { + if (splitTrackListener != null) { + splitTrackListener.trackSplittingStarted(); + } + } + + @Override + protected Void doInBackground(Void... params) { + for (GpxSelectionHelper.GpxDisplayGroup model : groups) { + if (gpxSplitType == GpxSplitType.NO_SPLIT) { + model.noSplit(app); + } else if (gpxSplitType == GpxSplitType.DISTANCE && distanceSplitInterval > 0) { + model.splitByDistance(app, distanceSplitInterval, joinSegments); + } else if (gpxSplitType == GpxSplitType.TIME && timeSplitInterval > 0) { + model.splitByTime(app, timeSplitInterval, joinSegments); + } + } + return null; + } + + @Override + protected void onPostExecute(Void result) { + if (splitTrackListener != null) { + splitTrackListener.trackSplittingFinished(); + } + } + + public interface SplitTrackListener { + + void trackSplittingStarted(); + + void trackSplittingFinished(); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java index 74991ffce2..c5899000f4 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java @@ -55,6 +55,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.measurementtool.NewGpxData; +import net.osmand.plus.myplaces.SplitTrackAsyncTask.SplitTrackListener; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.track.GpxSplitType; @@ -64,7 +65,6 @@ import net.osmand.plus.wikivoyage.WikivoyageUtils; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; -import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -639,7 +639,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { List groups = new ArrayList<>(); TrackActivity activity = getTrackActivity(); if (activity != null) { - List result = activity.getGpxFile(useDisplayGroups); + List result = activity.getGpxDisplayGroups(useDisplayGroups); for (GpxDisplayGroup group : result) { boolean add = hasFilterType(group.getType()); if (add) { @@ -738,14 +738,55 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { addOptionSplit(3600, false, groups); } - private void updateSplit(@NonNull List groups, @Nullable SelectedGpxFile sf) { + private void updateSplit(@NonNull List groups, @Nullable final SelectedGpxFile selectedGpx) { TrackActivity activity = getTrackActivity(); if (activity != null) { - new SplitTrackAsyncTask(activity, this, sf, groups) - .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); + GpxSplitType gpxSplitType = getGpxSplitType(); + if (gpxSplitType != null) { + int timeSplit = this.timeSplit.get(selectedSplitInterval); + double distanceSplit = this.distanceSplit.get(selectedSplitInterval); + + SplitTrackListener splitTrackListener = new SplitTrackListener() { + + @Override + public void trackSplittingStarted() { + TrackActivity activity = getTrackActivity(); + if (activity != null) { + activity.setSupportProgressBarIndeterminateVisibility(true); + } + } + + @Override + public void trackSplittingFinished() { + TrackActivity activity = getTrackActivity(); + if (activity != null) { + if (AndroidUtils.isActivityNotDestroyed(activity)) { + activity.setSupportProgressBarIndeterminateVisibility(false); + } + if (selectedGpx != null) { + List groups = getDisplayGroups(); + selectedGpx.setDisplayGroups(groups, app); + } + } + } + }; + new SplitTrackAsyncTask(app, gpxSplitType, groups, splitTrackListener, activity.isJoinSegments(), + timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } } } + private GpxSplitType getGpxSplitType() { + if (selectedSplitInterval == 0) { + return GpxSplitType.NO_SPLIT; + } else if (distanceSplit.get(selectedSplitInterval) > 0) { + return GpxSplitType.DISTANCE; + } else if (timeSplit.get(selectedSplitInterval) > 0) { + return GpxSplitType.TIME; + } + return null; + } + private void addOptionSplit(int value, boolean distance, @NonNull List model) { if (model.size() > 0) { if (distance) { @@ -905,70 +946,4 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener { public void drawTrackBitmap(Bitmap bitmap) { imageView.setImageDrawable(new BitmapDrawable(app.getResources(), bitmap)); } - - private static class SplitTrackAsyncTask extends AsyncTask { - private final SelectedGpxFile selectedGpx; - private OsmandApplication app; - private final WeakReference activityRef; - private final WeakReference fragmentAdapterRef; - private final List groups; - - private List distanceSplit; - private TIntArrayList timeSplit; - private int selectedSplitInterval; - private boolean joinSegments; - - SplitTrackAsyncTask(@NonNull TrackActivity activity, - @NonNull TrackActivityFragmentAdapter fragmentAdapter, - @Nullable SelectedGpxFile selectedGpx, - @NonNull List groups) { - activityRef = new WeakReference<>(activity); - fragmentAdapterRef = new WeakReference<>(fragmentAdapter); - app = activity.getMyApplication(); - this.selectedGpx = selectedGpx; - this.groups = groups; - - selectedSplitInterval = fragmentAdapter.selectedSplitInterval; - distanceSplit = fragmentAdapter.distanceSplit; - timeSplit = fragmentAdapter.timeSplit; - joinSegments = activity.isJoinSegments(); - } - - @Override - protected void onPreExecute() { - TrackActivity activity = activityRef.get(); - if (activity != null) { - activity.setSupportProgressBarIndeterminateVisibility(true); - } - } - - @Override - protected void onPostExecute(Void result) { - TrackActivity activity = activityRef.get(); - TrackActivityFragmentAdapter fragment = fragmentAdapterRef.get(); - if (activity != null && fragment != null) { - if (!activity.isFinishing()) { - activity.setSupportProgressBarIndeterminateVisibility(false); - } - if (selectedGpx != null) { - List groups = fragment.getDisplayGroups(); - selectedGpx.setDisplayGroups(groups, app); - } - } - } - - @Override - protected Void doInBackground(Void... params) { - for (GpxDisplayGroup model : groups) { - if (selectedSplitInterval == 0) { - model.noSplit(app); - } else if (distanceSplit.get(selectedSplitInterval) > 0) { - model.splitByDistance(app, distanceSplit.get(selectedSplitInterval), joinSegments); - } else if (timeSplit.get(selectedSplitInterval) > 0) { - model.splitByTime(app, timeSplit.get(selectedSplitInterval), joinSegments); - } - } - return null; - } - } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java new file mode 100644 index 0000000000..64ee8f266e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java @@ -0,0 +1,358 @@ +package net.osmand.plus.track; + +import android.os.AsyncTask; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentManager; + +import com.google.android.material.slider.Slider; + +import net.osmand.PlatformUtil; +import net.osmand.plus.GPXDatabase.GpxDataItem; +import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.myplaces.SplitTrackAsyncTask; +import net.osmand.plus.myplaces.SplitTrackAsyncTask.SplitTrackListener; + +import org.apache.commons.logging.Log; + +import java.io.File; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static net.osmand.plus.track.TrackAppearanceFragment.SELECTED_TRACK_FILE_PATH; + +public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { + + public static final String TAG = SplitIntervalBottomSheet.class.getSimpleName(); + + private static final Log log = PlatformUtil.getLog(SplitIntervalBottomSheet.class); + + public static final String SELECTED_TRACK_SPLIT_TYPE = "selected_track_split_type"; + public static final String SELECTED_TIME_SPLIT_INTERVAL = "selected_time_split_interval"; + public static final String SELECTED_DISTANCE_SPLIT_INTERVAL = "selected_distance_split_interval"; + + + private OsmandApplication app; + private SelectedGpxFile selectedGpxFile; + + private Map timeSplitOptions = new LinkedHashMap<>(); + private Map distanceSplitOptions = new LinkedHashMap<>(); + + private int selectedTimeSplitInterval; + private int selectedDistanceSplitInterval; + private GpxSplitType selectedSplitType = GpxSplitType.NO_SPLIT; + + private Slider slider; + private View sliderContainer; + private TextView splitValueMin; + private TextView splitValueMax; + private TextView selectedSplitValue; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + app = requiredMyApplication(); + + Bundle arguments = getArguments(); + if (savedInstanceState != null) { + String gpxFilePath = savedInstanceState.getString(SELECTED_TRACK_FILE_PATH); + selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); + prepareSplitIntervalOptions(); + + selectedTimeSplitInterval = savedInstanceState.getInt(SELECTED_TIME_SPLIT_INTERVAL); + selectedDistanceSplitInterval = savedInstanceState.getInt(SELECTED_DISTANCE_SPLIT_INTERVAL); + selectedSplitType = GpxSplitType.valueOf(savedInstanceState.getString(SELECTED_TRACK_SPLIT_TYPE)); + } else if (arguments != null) { + String gpxFilePath = arguments.getString(SELECTED_TRACK_FILE_PATH); + selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); + prepareSplitIntervalOptions(); + updateSelectedSplitParams(); + } + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + items.add(new TitleItem(getString(R.string.gpx_split_interval))); + items.add(new LongDescriptionItem(getString(R.string.gpx_split_interval_descr))); + + LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode); + View view = themedInflater.inflate(R.layout.track_split_interval, null); + + sliderContainer = view.findViewById(R.id.slider_container); + slider = sliderContainer.findViewById(R.id.split_slider); + + splitValueMin = (TextView) view.findViewById(R.id.split_value_min); + splitValueMax = (TextView) view.findViewById(R.id.split_value_max); + selectedSplitValue = (TextView) view.findViewById(R.id.split_value_tv); + + UiUtilities.setupSlider(slider, nightMode, null); + + view.findViewById(R.id.left_btn_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectedSplitType = GpxSplitType.NO_SPLIT; + updateSlider(); + } + }); + view.findViewById(R.id.center_btn_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectedSplitType = GpxSplitType.TIME; + updateSlider(); + } + }); + view.findViewById(R.id.right_btn_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectedSplitType = GpxSplitType.DISTANCE; + updateSlider(); + } + }); + + SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() + .setCustomView(view) + .create(); + items.add(titleItem); + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt(SELECTED_TIME_SPLIT_INTERVAL, selectedTimeSplitInterval); + outState.putInt(SELECTED_DISTANCE_SPLIT_INTERVAL, selectedDistanceSplitInterval); + outState.putString(SELECTED_TRACK_SPLIT_TYPE, selectedSplitType.name()); + outState.putString(SELECTED_TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path); + } + + private void updateSelectedSplitParams() { + GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(selectedGpxFile.getGpxFile().path)); + if (gpxDataItem != null) { + if (gpxDataItem.getSplitType() == GpxSplitType.DISTANCE.getType()) { + selectedSplitType = GpxSplitType.DISTANCE; + List splitOptions = new ArrayList<>(distanceSplitOptions.values()); + int index = splitOptions.indexOf(gpxDataItem.getSplitInterval()); + selectedDistanceSplitInterval = Math.max(index, 0); + } else if (gpxDataItem.getSplitType() == GpxSplitType.TIME.getType()) { + selectedSplitType = GpxSplitType.TIME; + List splitOptions = new ArrayList<>(timeSplitOptions.values()); + int index = splitOptions.indexOf((int) gpxDataItem.getSplitInterval()); + selectedTimeSplitInterval = Math.max(index, 0); + } + } + } + + private void prepareSplitIntervalOptions() { + List groups = getDisplayGroups(); + addDistanceOptionSplit(30, groups); // 50 feet, 20 yards, 20 m + addDistanceOptionSplit(60, groups); // 100 feet, 50 yards, 50 m + addDistanceOptionSplit(150, groups); // 200 feet, 100 yards, 100 m + addDistanceOptionSplit(300, groups); // 500 feet, 200 yards, 200 m + addDistanceOptionSplit(600, groups); // 1000 feet, 500 yards, 500 m + addDistanceOptionSplit(1500, groups); // 2000 feet, 1000 yards, 1 km + addDistanceOptionSplit(3000, groups); // 1 mi, 2 km + addDistanceOptionSplit(6000, groups); // 2 mi, 5 km + addDistanceOptionSplit(15000, groups); // 5 mi, 10 km + + addTimeOptionSplit(15, groups); + addTimeOptionSplit(30, groups); + addTimeOptionSplit(60, groups); + addTimeOptionSplit(120, groups); + addTimeOptionSplit(150, groups); + addTimeOptionSplit(300, groups); + addTimeOptionSplit(600, groups); + addTimeOptionSplit(900, groups); + addTimeOptionSplit(1800, groups); + addTimeOptionSplit(3600, groups); + } + + private void addDistanceOptionSplit(int value, @NonNull List displayGroups) { + if (displayGroups.size() > 0) { + double dvalue = OsmAndFormatter.calculateRoundedDist(value, app); + String formattedDist = OsmAndFormatter.getFormattedDistance((float) dvalue, app); + distanceSplitOptions.put(formattedDist, dvalue); + if (Math.abs(displayGroups.get(0).getSplitDistance() - dvalue) < 1) { + selectedDistanceSplitInterval = distanceSplitOptions.size() - 1; + } + } + } + + private void addTimeOptionSplit(int value, @NonNull List model) { + if (model.size() > 0) { + String time; + if (value < 60) { + time = value + " " + getString(R.string.int_seconds); + } else if (value % 60 == 0) { + time = (value / 60) + " " + getString(R.string.int_min); + } else { + time = (value / 60f) + " " + getString(R.string.int_min); + } + timeSplitOptions.put(time, value); + if (model.get(0).getSplitTime() == value) { + selectedTimeSplitInterval = timeSplitOptions.size() - 1; + } + } + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + updateSlider(); + } + + private void updateSlider() { + if (selectedSplitType != GpxSplitType.NO_SPLIT) { + slider.clearOnChangeListeners(); + if (selectedSplitType == GpxSplitType.TIME) { + updateSliderTimeInterval(); + } else { + updateSliderDistanceInterval(); + } + AndroidUiHelper.updateVisibility(sliderContainer, true); + } else { + AndroidUiHelper.updateVisibility(sliderContainer, false); + } + setupHeightAndBackground(getView()); + } + + private void updateSliderTimeInterval() { + final List splitOptions = new ArrayList<>(timeSplitOptions.keySet()); + updateSliderMinMaxValues(splitOptions); + + slider.setValue(selectedTimeSplitInterval); + slider.addOnChangeListener(new Slider.OnChangeListener() { + @Override + public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { + if (fromUser) { + selectedTimeSplitInterval = (int) value; + selectedSplitValue.setText(splitOptions.get(selectedTimeSplitInterval)); + } + } + }); + selectedSplitValue.setText(splitOptions.get(selectedTimeSplitInterval)); + } + + private void updateSliderDistanceInterval() { + final List splitOptions = new ArrayList<>(distanceSplitOptions.keySet()); + updateSliderMinMaxValues(splitOptions); + + slider.setValue(selectedDistanceSplitInterval); + slider.addOnChangeListener(new Slider.OnChangeListener() { + @Override + public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { + if (fromUser) { + selectedDistanceSplitInterval = (int) value; + selectedSplitValue.setText(splitOptions.get(selectedDistanceSplitInterval)); + } + } + }); + selectedSplitValue.setText(splitOptions.get(selectedDistanceSplitInterval)); + } + + private void updateSliderMinMaxValues(List splitOptions) { + int valueFrom = 0; + int valueTo = splitOptions.size() - 1; + + slider.setValueTo(valueTo); + slider.setValueFrom(valueFrom); + splitValueMin.setText(splitOptions.get(valueFrom)); + splitValueMax.setText(splitOptions.get(valueTo)); + } + + @Override + protected int getRightBottomButtonTextId() { + return R.string.shared_string_apply; + } + + @Override + protected void onRightBottomButtonClick() { + applySelectedSplit(); + updateSplitInDatabase(); + dismiss(); + } + + private void updateSplitInDatabase() { + double splitInterval = 0; + if (selectedSplitType == GpxSplitType.NO_SPLIT) { + splitInterval = 0; + } else if (selectedSplitType == GpxSplitType.DISTANCE) { + splitInterval = new ArrayList<>(distanceSplitOptions.values()).get(selectedDistanceSplitInterval); + } else if (selectedSplitType == GpxSplitType.TIME) { + splitInterval = new ArrayList<>(timeSplitOptions.values()).get(selectedTimeSplitInterval); + } + GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(selectedGpxFile.getGpxFile().path)); + if (gpxDataItem != null) { + app.getGpxDbHelper().updateSplit(gpxDataItem, selectedSplitType, splitInterval); + } + } + + private void applySelectedSplit() { + int timeSplit = new ArrayList<>(timeSplitOptions.values()).get(selectedTimeSplitInterval); + double distanceSplit = new ArrayList<>(distanceSplitOptions.values()).get(selectedDistanceSplitInterval); + + SplitTrackListener splitTrackListener = new SplitTrackListener() { + + @Override + public void trackSplittingStarted() { + + } + + @Override + public void trackSplittingFinished() { + if (selectedGpxFile != null) { + List groups = getDisplayGroups(); + selectedGpxFile.setDisplayGroups(groups, app); + } + } + }; + List groups = selectedGpxFile.getDisplayGroups(app); + GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(selectedGpxFile.getGpxFile().path)); + boolean isJoinSegments = gpxDataItem != null && gpxDataItem.isJoinSegments(); + + new SplitTrackAsyncTask(app, selectedSplitType, groups, splitTrackListener, isJoinSegments, + timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + + @NonNull + private List getDisplayGroups() { + List groups = new ArrayList<>(); + for (GpxDisplayGroup group : selectedGpxFile.getDisplayGroups(app)) { + if (GpxSelectionHelper.GpxDisplayItemType.TRACK_SEGMENT == group.getType()) { + groups.add(group); + } + } + return groups; + } + + public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile) { + try { + if (fragmentManager.findFragmentByTag(SplitIntervalBottomSheet.TAG) == null) { + Bundle args = new Bundle(); + args.putString(SELECTED_TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path); + + SplitIntervalBottomSheet splitIntervalBottomSheet = new SplitIntervalBottomSheet(); + splitIntervalBottomSheet.setArguments(args); + splitIntervalBottomSheet.show(fragmentManager, SplitIntervalBottomSheet.TAG); + } + } catch (RuntimeException e) { + log.error("showInstance", e); + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java new file mode 100644 index 0000000000..12ed4d6091 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java @@ -0,0 +1,44 @@ +package net.osmand.plus.track; + +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.routepreparationmenu.cards.BaseCard; + +public class SplitIntervalCard extends BaseCard { + + private SelectedGpxFile selectedGpxFile; + + public SplitIntervalCard(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile) { + super(mapActivity); + this.selectedGpxFile = selectedGpxFile; + } + + @Override + public int getCardLayoutId() { + return R.layout.bottom_sheet_item_with_right_descr; + } + + @Override + protected void updateContent() { + AndroidUiHelper.updateVisibility(view.findViewById(R.id.icon), false); + + TextView titleView = view.findViewById(R.id.title); + titleView.setText(R.string.gpx_split_interval); + + TextView descriptionView = view.findViewById(R.id.description); + + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), selectedGpxFile); + } + }); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index 0c60221f9a..1989d02b13 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -27,13 +27,12 @@ public class TrackAppearanceFragment extends ContextMenuFragment { public static final String SELECTED_TRACK_FILE_PATH = "selected_track_file_path"; - private OsmandApplication app; private SelectedGpxFile selectedGpxFile; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - app = requireMyApplication(); + OsmandApplication app = requireMyApplication(); String gpxFilePath = null; Bundle arguments = getArguments(); @@ -122,6 +121,9 @@ public class TrackAppearanceFragment extends ContextMenuFragment { ViewGroup cardsContainer = getCardsContainer(); cardsContainer.removeAllViews(); + BaseCard splitIntervalCard = new SplitIntervalCard(mapActivity, selectedGpxFile); + cardsContainer.addView(splitIntervalCard.build(mapActivity)); + BaseCard arrowsCard = new DirectionArrowsCard(mapActivity, selectedGpxFile); cardsContainer.addView(arrowsCard.build(mapActivity)); From 620b8215127c5ceacf360c17dfe448ade1147eea Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 15 Jul 2020 09:24:52 +0300 Subject: [PATCH 119/551] Add radio group instead of simple buttons --- OsmAnd/res/drawable/radio_button_center.xml | 5 ++ OsmAnd/res/drawable/radio_button_left.xml | 5 ++ .../drawable/radio_button_regular_center.xml | 7 ++ .../drawable/radio_button_regular_left.xml | 10 +++ .../drawable/radio_button_regular_right.xml | 10 +++ OsmAnd/res/drawable/radio_button_right.xml | 5 ++ .../drawable/radio_button_selected_center.xml | 8 ++ .../drawable/radio_button_selected_left.xml | 11 +++ .../drawable/radio_button_selected_right.xml | 11 +++ .../res/drawable/radio_flat_text_selector.xml | 5 ++ OsmAnd/res/layout/track_split_interval.xml | 81 ++++++++----------- .../plus/track/SplitIntervalBottomSheet.java | 39 +++++---- .../net/osmand/plus/track/TrackWidthCard.java | 5 +- 13 files changed, 134 insertions(+), 68 deletions(-) create mode 100644 OsmAnd/res/drawable/radio_button_center.xml create mode 100644 OsmAnd/res/drawable/radio_button_left.xml create mode 100644 OsmAnd/res/drawable/radio_button_regular_center.xml create mode 100644 OsmAnd/res/drawable/radio_button_regular_left.xml create mode 100644 OsmAnd/res/drawable/radio_button_regular_right.xml create mode 100644 OsmAnd/res/drawable/radio_button_right.xml create mode 100644 OsmAnd/res/drawable/radio_button_selected_center.xml create mode 100644 OsmAnd/res/drawable/radio_button_selected_left.xml create mode 100644 OsmAnd/res/drawable/radio_button_selected_right.xml create mode 100644 OsmAnd/res/drawable/radio_flat_text_selector.xml diff --git a/OsmAnd/res/drawable/radio_button_center.xml b/OsmAnd/res/drawable/radio_button_center.xml new file mode 100644 index 0000000000..1c1304d0fc --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_center.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_button_left.xml b/OsmAnd/res/drawable/radio_button_left.xml new file mode 100644 index 0000000000..838a3f4929 --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_left.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_button_regular_center.xml b/OsmAnd/res/drawable/radio_button_regular_center.xml new file mode 100644 index 0000000000..e0cca408c5 --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_regular_center.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_button_regular_left.xml b/OsmAnd/res/drawable/radio_button_regular_left.xml new file mode 100644 index 0000000000..4a983673da --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_regular_left.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_button_regular_right.xml b/OsmAnd/res/drawable/radio_button_regular_right.xml new file mode 100644 index 0000000000..e2186a923b --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_regular_right.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_button_right.xml b/OsmAnd/res/drawable/radio_button_right.xml new file mode 100644 index 0000000000..7c227b1319 --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_right.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_button_selected_center.xml b/OsmAnd/res/drawable/radio_button_selected_center.xml new file mode 100644 index 0000000000..e429400abe --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_selected_center.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_button_selected_left.xml b/OsmAnd/res/drawable/radio_button_selected_left.xml new file mode 100644 index 0000000000..a96a06f544 --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_selected_left.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_button_selected_right.xml b/OsmAnd/res/drawable/radio_button_selected_right.xml new file mode 100644 index 0000000000..ffb60d307b --- /dev/null +++ b/OsmAnd/res/drawable/radio_button_selected_right.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/radio_flat_text_selector.xml b/OsmAnd/res/drawable/radio_flat_text_selector.xml new file mode 100644 index 0000000000..359b2777c6 --- /dev/null +++ b/OsmAnd/res/drawable/radio_flat_text_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/track_split_interval.xml b/OsmAnd/res/layout/track_split_interval.xml index 7b12e4c22d..becc0378d7 100644 --- a/OsmAnd/res/layout/track_split_interval.xml +++ b/OsmAnd/res/layout/track_split_interval.xml @@ -1,13 +1,12 @@ - - + android:layout_weight="1" + android:background="@drawable/radio_button_left" + android:button="@android:color/transparent" + android:checked="true" + android:foreground="?attr/selectableItemBackground" + android:gravity="center" + android:text="@string/shared_string_none" + android:textColor="@drawable/radio_flat_text_selector" /> - - - - - + android:layout_weight="1" + android:background="@drawable/radio_button_center" + android:button="@android:color/transparent" + android:foreground="?attr/selectableItemBackground" + android:gravity="center" + android:text="@string/shared_string_time" + android:textColor="@drawable/radio_flat_text_selector" /> - - - - - + android:layout_weight="1" + android:background="@drawable/radio_button_right" + android:button="@android:color/transparent" + android:foreground="?attr/selectableItemBackground" + android:gravity="center" + android:text="@string/distance" + android:textColor="@drawable/radio_flat_text_selector" + android:textSize="@dimen/default_desc_text_size" /> - - - - - + items = GpxAppearanceAdapter.getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_WIDTH); String selectedWidth = selectedGpxFile.getGpxFile().getWidth(null); - String customWidth = Algorithms.isInt(selectedWidth) ? selectedWidth : String.valueOf(CUSTOM_WIDTH_MIN); + String customWidth = !Algorithms.isEmpty(selectedWidth) && Algorithms.isInt(selectedWidth) ? selectedWidth : String.valueOf(CUSTOM_WIDTH_MIN); items.add(new AppearanceListItem(CUSTOM_WIDTH, customWidth, app.getString(R.string.shared_string_custom))); return items; From d0fd025dbb70f4368ba05d5eba846469353a1dc4 Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Wed, 15 Jul 2020 09:32:19 +0300 Subject: [PATCH 120/551] Fix #9377 --- .../net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 978525ac5f..5b209060f5 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -1022,7 +1022,7 @@ public class MapInfoWidgetsFactory { } if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) { updateVisibility(false); - } else if (!showClosestWaypointFirstInAddress && updateWaypoint()) { + } else if (showClosestWaypointFirstInAddress && updateWaypoint()) { updateVisibility(true); AndroidUiHelper.updateVisibility(addressText, false); AndroidUiHelper.updateVisibility(addressTextShadow, false); From 87e204169b3cb66acc4038a27715308e98eba05b Mon Sep 17 00:00:00 2001 From: Tymofij Lytvynenko Date: Tue, 14 Jul 2020 08:33:15 +0000 Subject: [PATCH 121/551] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3420 of 3420 strings) --- OsmAnd/res/values-uk/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 8e1ff5e6fe..41f145794f 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -3810,4 +3810,9 @@ Завантажити мапи Вікіпедії Отримайте відомості про визначні місця у Вікіпедії. Це ваш кишеньковий посібник без мережі - просто ввімкніть втулок \"Вікіпедія\" і насолоджуйтесь статтями про об\'єкти навколо вас. Моторолер + легкий мотоцикл + Інвалідне крісло + Інвалідне крісло попереду + у мапу + Закрита нотатка OSM \ No newline at end of file From 4f4e391f05e6cf7e4a31c9e1b094786ab4c674b0 Mon Sep 17 00:00:00 2001 From: Andreas Lattmann Date: Tue, 14 Jul 2020 18:36:38 +0000 Subject: [PATCH 122/551] Translated using Weblate (Italian) Currently translated at 89.8% (3072 of 3420 strings) --- OsmAnd/res/values-it/strings.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index e982579f7d..7f6412e75a 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -3810,13 +3810,13 @@ Questo dispositivo non ha autovelox. Pattini in linea Cancella il prossimo punto di destinazione - Abilita il controllo del zoom della mappa con i pulsanti del volume del dispositivo. - Pulsanti del volume come zoom + Abilita per controllare il livello di zoom della mappa con i pulsanti del volume del dispositivo. + Pulsanti volume come zoom Per favore indica un nome per il punto - Il punto di destinazione nel percorso attuale verrà cancellato. Se sarà la Destinazione la navigazione si arresterà. - Scarica mappe Wikimedia - 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. - Moto enduro + Il punto di destinazione corrente sul percorso verrà eliminato. Se sarà la Destinazione, la navigazione verrà interrotta. + Scarica mappe Wikipedia + 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. + Moto da enduro Moto scooter Sedia a rotelle Go-kart From 706f632835117338adfb06ad19836129c0e14d0d Mon Sep 17 00:00:00 2001 From: Mirco Zorzo Date: Tue, 14 Jul 2020 03:56:44 +0000 Subject: [PATCH 123/551] Translated using Weblate (Italian) Currently translated at 89.8% (3072 of 3420 strings) --- OsmAnd/res/values-it/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index 7f6412e75a..1eb7abb563 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -3821,4 +3821,5 @@ Sedia a rotelle Go-kart Chiudi la nota OSM + Sedia a rotelle \ No newline at end of file From a916a32ac70c8082c68acd1c076d53b5a19a7d5c Mon Sep 17 00:00:00 2001 From: Zmicer Turok Date: Tue, 14 Jul 2020 08:15:05 +0000 Subject: [PATCH 124/551] Translated using Weblate (Belarusian) Currently translated at 95.2% (3258 of 3420 strings) --- OsmAnd/res/values-be/strings.xml | 46 ++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index dc4aa09a11..10ef38a0f0 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -9,14 +9,14 @@ Версія: Пра праграму Версія, ліцэнзіі, удзельнікі праекта - Спампаваныя маштабы: %1$s + Спампаваныя ўзроўні маштабавання: %1$s Тэрмін дзеяння (у хвілінах): %1$s Можна спампаваць: %1$s Максімальнае павелічэнне: %1$s Мінімальнае павелічэнне: %1$s Даныя фрагменту: %1$s Крыніца фрагментаў мапы «%1$s» захаваная - Эліптычны меркатар + Эліптычная праекцыя меркатара Максімальнае павелічэнне Тэрмін дзеяння (у хвілінах) Мінімальнае павелічэнне @@ -2071,7 +2071,7 @@ Атрымайце неабмежаваную колькасць спампоўванняў мапаў у дадатак да штотыднёвых, штодзённых і нават штогадзінных абнаўленняў. Неабмежаваная колькасць спамоўванняў мапаў, абнаўленняў і ўбудова Wikipedia. Мілі/метры - Плата за падпіску спаганяецца штомесяц. Скасаваць яе на Google Play можна у любы момант. + Плата за падпіску спаганяецца за абраны перыяд. Скасаваць яе на Google Play можна у любы момант. Ахвяраванне супольнасці OpenStreetMap Частка вашага ахвяравання накіроўваецца ўдзельнікам праекта OpenStreetMap. Кошт падпіскі застаецца тым жа самым. Падпіска дазваляе атрымліваць штогадзіныя, штодзённыя, штотыднёвыя абнаўленні і неабмежаваную колькасць спампоўванняў для ўсіх мапаў па ўсім свеце. @@ -2481,7 +2481,7 @@ \n Усталяваць Палепшыць фотапакрыццё Mapillary - Усталяваць Mapillary, каб дадаць адзін альбо некалькі фотаздымкаў да гэтага месца на мапе. + Усталюйце Mapillary, каб дадаць фотаздымкі гэтага месца. Адкрыць Mapillary Выява Mapillary Дыстанцыя выпраўленая @@ -3093,7 +3093,7 @@ У кожнага профілю свае налады Вызначце час, цягам якога экран не будзе выключацца. Выкарыстоўваць датчык адлегласці - Правядзіце рукой па верхняй частцы экрана, каб уключыць яго падчас навігацыі. + Уключаць экран правёўшы па яму рукой. Зімовая дарога Ледзяная дарога Зімовыя і ледзяныя дарогі @@ -3307,7 +3307,7 @@ Пікап Паказваць мапу падчас навігацыі на заблакаваным экране. Налады пабудовы маршруту абранага профілю \"%1$s\". - Час абуджэння + Час працы пасля абуджэння Адзінкі вымярэння і фарматы Выгляд Выгляд мапы @@ -3327,7 +3327,7 @@ Мапа падчас навігацыі Мапа падчас навігацыі Іншае - Вага, вышыня, хуткасць + Вага, вышыня, даўжыня, хуткасць Параметры аўтамабіля Галасавыя апавяшчэнні прайграюцца толькі падчас навігацыі. Навігацыйныя інструкцыі і апавяшчэнні @@ -3535,7 +3535,7 @@ Аднавіць прадвызначаны парадак элементаў Вярнуцца да рэдагавання Паказаць грамадскі транспарт - Кнопка, каб паказаць ці схаваць грамадскі транспарт на мапе. + Кнопка для паказу ці хавання грамадскага транспарту на мапе. Дадаць профіль %1$s з %2$s Схілы @@ -3564,7 +3564,7 @@ Падзяляльнік Схавана Калі схаваць налады, то яны скінуцца да зыходнага стану. - \"Асноўныя дзеянні\" змяшчаюць толькі 4 кнопкі. + Толькі 4 кнопкі. Асноўныя дзеянні Убудова для распрацоўшчыкаў Замяніць іншы пункт на гэты. @@ -3596,8 +3596,8 @@ Арагонская Адвольны колер Пошук тыпаў POI - Абраныя профілі пераключаюцца націскам на кнопку \"Дзеянне\". - Профіляў, абраных для гэтага дзеяння, не знойдзена. + Пры націсканні на кнопку \"Дзеянні\" пераключаюцца абраныя профілі. + Адпаведных профіляў не знойдзена. Кантонская Ёруба Узбекская @@ -3620,4 +3620,28 @@ Паказаць/схаваць грамадскі транспарт Пералічыць маршрут у выпадку адхілення Выдаліць + Вызначце шырыню судна, каб пазбягаць вузкіх мастоў + Паказаць/схаваць Mapillary + Схаваць Mapillary + Паказаць Mapillary + Пераключальнік для паказу альбо хавання пласта Mapillary. + Пазначце даўжыню транспартнага сродку, дазволеную для руху па маршрутах. + Ліміт даўжыні + Арыентацыя + Выдалена: %1$s + Перазапуск патрабуецца для поўнага выдалення даных камер кантролю хуткасці. + Кіраванне ўзроўнем маштабавання мапы пры дапамозе кнопак рэгулявання гучнасці. + Інфармацыя пра славутасці з Вікіпедыі. Гэта ваш кішэнны даведнік - уключыце ўбудову вікіпедыі і чытайце артыкулы пра аб’екты вакол вас. + Матацыкл Эндура + Мотаролер + Выдаліць і перазапусціць + На гэтай прыладзе няма камер кантролю хуткасці. + Ролікі + Выдаліць наступны пункт прызначэння + Маштабаванне кнопкамі гучнасці + Калі ласка, дайце пункту назву + Бягучы пункт прызначэння маршруту будзе выдалены. Калі гэта канцавы пункт прызначэння, то навігацыя спыніцца. + Спампаваць мапы Вікіпедыі + Інвалідны вазок + Закрытая нататка OSM \ No newline at end of file From c4a18191f04e701e96f452ffe5ac36bde57cee3f Mon Sep 17 00:00:00 2001 From: Tymofij Lytvynenko Date: Tue, 14 Jul 2020 08:35:48 +0000 Subject: [PATCH 125/551] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3812 of 3812 strings) --- OsmAnd/res/values-uk/phrases.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-uk/phrases.xml b/OsmAnd/res/values-uk/phrases.xml index 530cedf2c2..3c309cdf27 100644 --- a/OsmAnd/res/values-uk/phrases.xml +++ b/OsmAnd/res/values-uk/phrases.xml @@ -3817,4 +3817,7 @@ Вібрація: вимкнено Стрілка Вібрація + Міський квартал + Район + Подарункова коробка \ No newline at end of file From d69a3f201269a4858f8b2fb8ae95491ada62bfba Mon Sep 17 00:00:00 2001 From: Zmicer Turok Date: Tue, 14 Jul 2020 08:02:47 +0000 Subject: [PATCH 126/551] Translated using Weblate (Belarusian) Currently translated at 95.1% (3626 of 3812 strings) --- OsmAnd/res/values-be/phrases.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OsmAnd/res/values-be/phrases.xml b/OsmAnd/res/values-be/phrases.xml index 42e8654cab..4e69352251 100644 --- a/OsmAnd/res/values-be/phrases.xml +++ b/OsmAnd/res/values-be/phrases.xml @@ -3638,4 +3638,12 @@ На адкрытым паветры Тып Статус + Даступна для механічнага транспартнага сродку: так + Даступна для механічнага транспартнага сродку: не + Даступна для механічнага транспартнага сродку: прыватны доступ + Стрэлка + Вібрацыя + Ціск + Відэа + SMS \ No newline at end of file From d618391459afe52cec16a376a42c1356c0a82ae7 Mon Sep 17 00:00:00 2001 From: Franco Date: Tue, 14 Jul 2020 01:08:41 +0000 Subject: [PATCH 127/551] Translated using Weblate (Spanish (Argentina)) Currently translated at 99.9% (3419 of 3420 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index afdc93674d..c4e1c15d19 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -3824,4 +3824,5 @@ Silla de ruedas Go-kart Nota de OSM cerrada + Silla de ruedas (hacia adelante) \ No newline at end of file From 844f18011190bd3eb2a916971a16440a6ca28734 Mon Sep 17 00:00:00 2001 From: Athoss Date: Wed, 15 Jul 2020 08:59:14 +0000 Subject: [PATCH 128/551] Translated using Weblate (Hungarian) Currently translated at 99.3% (3789 of 3812 strings) --- OsmAnd/res/values-hu/phrases.xml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-hu/phrases.xml b/OsmAnd/res/values-hu/phrases.xml index 07a5eabded..056b60bcf5 100644 --- a/OsmAnd/res/values-hu/phrases.xml +++ b/OsmAnd/res/values-hu/phrases.xml @@ -1116,7 +1116,7 @@ van Vakvezető burkolat nincs van - nincs + Hang nincs Csak amikor zöld Pihenőhely Mini körforgalom @@ -1198,13 +1198,13 @@ Elektromosautó-szerelés Motorkerékpár-szerelés igen - Nem önkiszolgáló + Nem igen Nem automatizált Teljes kiszolgálás igen Kefés - Autómosó nincs + Nincs Repülőgépüzemanyag-töltő állomás Közfürdő Férfi @@ -3792,4 +3792,15 @@ Nyíl Rezgés Nyomás + Akadály + Pálya azonosítószám + Bowling központ + Biztonsági szaküzlet + Hegyimentő + Igen + Igen + Rezgés nincs + Adomány doboz + Kerület + Háztömb \ No newline at end of file From 6773ef50310fa21e7363cd3067c2b1172a713cfd Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 15 Jul 2020 13:45:41 +0300 Subject: [PATCH 129/551] Move SaveGpxAsyncTask to separate file and remove duplicates --- .../net/osmand/plus/GpxSelectionHelper.java | 6 +- .../osmand/plus/base/ContextMenuFragment.java | 6 +- .../editors/WptPtEditorFragment.java | 43 +++--- .../editors/WptPtEditorFragmentNew.java | 45 +++--- .../plus/myplaces/SaveGpxAsyncTask.java | 50 +++++++ .../plus/myplaces/TrackSegmentFragment.java | 139 +++++++----------- .../plus/track/TrackAppearanceFragment.java | 64 +++++++- 7 files changed, 203 insertions(+), 150 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/myplaces/SaveGpxAsyncTask.java diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index f8adfdbf5c..3d74fca4d4 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -11,7 +11,6 @@ import androidx.core.content.ContextCompat; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.plus.track.GpxSplitType; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.GPXUtilities.Route; import net.osmand.GPXUtilities.Track; @@ -28,6 +27,7 @@ import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants; +import net.osmand.plus.track.GpxSplitType; import net.osmand.plus.track.GradientScaleType; import net.osmand.util.Algorithms; @@ -533,9 +533,7 @@ public class GpxSelectionHelper { } if (obj.has(GRADIENT_SCALE_TYPE)) { String gradientScaleTypeName = obj.optString(GRADIENT_SCALE_TYPE); - if (!Algorithms.isEmpty(gradientScaleTypeName)) { - gpx.setGradientScaleType(GradientScaleType.valueOf(gradientScaleTypeName).getTypeName()); - } + gpx.setGradientScaleType(gradientScaleTypeName); } if (obj.has(SHOW_START_FINISH)) { boolean showStartFinish = obj.optBoolean(SHOW_START_FINISH, false); diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java index 343594a990..c385364c59 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java @@ -148,6 +148,10 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment { return getLandscapeWidth() - getResources().getDimensionPixelSize(R.dimen.dashboard_land_shadow_width); } + public float getMiddleStateKoef() { + return MIDDLE_STATE_KOEF; + } + public abstract int getToolbarHeight(); public boolean isSingleFragment() { @@ -605,7 +609,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment { } private int getMinHalfY(MapActivity mapActivity) { - return viewHeight - (int) Math.min(viewHeight * MIDDLE_STATE_KOEF, + return viewHeight - (int) Math.min(viewHeight * getMiddleStateKoef(), MIDDLE_STATE_MIN_HEIGHT_DP * mapActivity.getMapView().getDensity() ); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java index 21cbe28ff1..444163fdd7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java @@ -12,7 +12,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; -import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.WptPt; import net.osmand.data.LatLon; @@ -27,9 +26,10 @@ import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; +import net.osmand.plus.myplaces.SaveGpxAsyncTask; +import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.util.Algorithms; -import java.io.File; import java.util.Map; public class WptPtEditorFragment extends PointEditorFragment { @@ -251,7 +251,7 @@ public class WptPtEditorFragment extends PointEditorFragment { } } else { addWpt(gpx, description, name, category, color); - new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + saveGpx(getMyApplication(), gpx, editor.isGpxSelected()); } syncGpx(gpx); } @@ -284,7 +284,7 @@ public class WptPtEditorFragment extends PointEditorFragment { } else { gpx.updateWptPt(wpt, wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color); - new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + saveGpx(getMyApplication(), gpx, editor.isGpxSelected()); } syncGpx(gpx); } @@ -309,7 +309,7 @@ public class WptPtEditorFragment extends PointEditorFragment { savingTrackHelper.deletePointData(wpt); } else { gpx.deleteWptPt(wpt); - new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + saveGpx(getMyApplication(), gpx, editor.isGpxSelected()); } syncGpx(gpx); } @@ -378,28 +378,19 @@ public class WptPtEditorFragment extends PointEditorFragment { return color == 0 ? defaultColor : color; } - private static class SaveGpxAsyncTask extends AsyncTask { - private final OsmandApplication app; - private final GPXFile gpx; - private final boolean gpxSelected; + private void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) { + new SaveGpxAsyncTask(gpxFile, new SaveGpxListener() { + @Override + public void gpxSavingStarted() { - SaveGpxAsyncTask(OsmandApplication app, GPXFile gpx, boolean gpxSelected) { - this.app = app; - this.gpx = gpx; - this.gpxSelected = gpxSelected; - } - - @Override - protected Void doInBackground(Void... params) { - GPXUtilities.writeGpxFile(new File(gpx.path), gpx); - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - if (!gpxSelected) { - app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); } - } + + @Override + public void gpxSavingFinished() { + if (!gpxSelected) { + app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile); + } + } + }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 94ecff5478..334275e760 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -14,7 +14,6 @@ import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.FragmentActivity; -import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.WptPt; import net.osmand.data.FavouritePoint.BackgroundType; @@ -31,9 +30,10 @@ import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; +import net.osmand.plus.myplaces.SaveGpxAsyncTask; +import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.util.Algorithms; -import java.io.File; import java.util.List; import java.util.Map; import java.util.Set; @@ -269,7 +269,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { } } else { addWpt(gpx, description, name, category, color, iconName, backgroundTypeName); - new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + saveGpx(getMyApplication(), gpx, editor.isGpxSelected()); } syncGpx(gpx); } @@ -303,7 +303,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { } else { gpx.updateWptPt(wpt, wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color, iconName, backgroundTypeName); - new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + saveGpx(getMyApplication(), gpx, editor.isGpxSelected()); } syncGpx(gpx); } @@ -332,7 +332,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { savingTrackHelper.deletePointData(wpt); } else { gpx.deleteWptPt(wpt); - new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + saveGpx(getMyApplication(), gpx, editor.isGpxSelected()); } syncGpx(gpx); } @@ -478,28 +478,19 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { return 0; } - private static class SaveGpxAsyncTask extends AsyncTask { - private final OsmandApplication app; - private final GPXFile gpx; - private final boolean gpxSelected; + private void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) { + new SaveGpxAsyncTask(gpxFile, new SaveGpxListener() { + @Override + public void gpxSavingStarted() { - SaveGpxAsyncTask(OsmandApplication app, GPXFile gpx, boolean gpxSelected) { - this.app = app; - this.gpx = gpx; - this.gpxSelected = gpxSelected; - } - - @Override - protected Void doInBackground(Void... params) { - GPXUtilities.writeGpxFile(new File(gpx.path), gpx); - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - if (!gpxSelected) { - app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); } - } + + @Override + public void gpxSavingFinished() { + if (!gpxSelected) { + app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile); + } + } + }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SaveGpxAsyncTask.java b/OsmAnd/src/net/osmand/plus/myplaces/SaveGpxAsyncTask.java new file mode 100644 index 0000000000..ac1e9c765b --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/myplaces/SaveGpxAsyncTask.java @@ -0,0 +1,50 @@ +package net.osmand.plus.myplaces; + +import android.os.AsyncTask; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; + +import java.io.File; + +public class SaveGpxAsyncTask extends AsyncTask { + + private final GPXFile gpx; + private final SaveGpxListener saveGpxListener; + + public SaveGpxAsyncTask(@NonNull GPXFile gpx, + @Nullable SaveGpxListener saveGpxListener) { + this.gpx = gpx; + this.saveGpxListener = saveGpxListener; + } + + @Override + protected void onPreExecute() { + if (saveGpxListener != null) { + saveGpxListener.gpxSavingStarted(); + } + } + + @Override + protected Void doInBackground(Void... params) { + GPXUtilities.writeGpxFile(new File(gpx.path), gpx); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + if (saveGpxListener != null) { + saveGpxListener.gpxSavingFinished(); + } + } + + public interface SaveGpxListener { + + void gpxSavingStarted(); + + void gpxSavingFinished(); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index 41343f0fa3..f6129a5980 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -68,6 +68,7 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet; import net.osmand.plus.measurementtool.NewGpxData; +import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.controls.PagerSlidingTabStrip; @@ -79,7 +80,6 @@ import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.io.File; -import java.lang.ref.WeakReference; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -788,10 +788,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == R.id.action_edit) { - TrkSegment segment = getTrkSegment(); - if (segment != null && fragmentAdapter != null) { - fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment); - } + editSegment(); return true; } else if (i == R.id.action_delete) { TrackActivity activity = getTrackActivity(); @@ -801,16 +798,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - TrackActivity trackActivity = getTrackActivity(); - if (trackActivity != null && deleteSegment()) { - GPXFile gpx = getGpx(); - if (gpx != null && fragmentAdapter != null) { - boolean showOnMap = fragmentAdapter.isShowOnMap(); - SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false); - new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null) - .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } - } + deleteAndSaveSegment(); } }); builder.setNegativeButton(R.string.shared_string_cancel, null); @@ -914,22 +902,10 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == R.id.action_edit) { - TrkSegment segment = getTrkSegment(); - if (segment != null && fragmentAdapter != null) { - fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment); - } + editSegment(); return true; } else if (i == R.id.action_delete) { - TrackActivity trackActivity = getTrackActivity(); - if (trackActivity != null && deleteSegment()) { - GPXFile gpx = getGpx(); - if (gpx != null && fragmentAdapter != null) { - boolean showOnMap = fragmentAdapter.isShowOnMap(); - SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false); - new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null) - .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } - } + deleteAndSaveSegment(); return true; } return false; @@ -1023,22 +999,10 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == R.id.action_edit) { - TrkSegment segment = getTrkSegment(); - if (segment != null && fragmentAdapter != null) { - fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment); - } + editSegment(); return true; } else if (i == R.id.action_delete) { - TrackActivity trackActivity = getTrackActivity(); - if (trackActivity != null && deleteSegment()) { - GPXFile gpx = getGpx(); - if (gpx != null && fragmentAdapter != null) { - boolean showOnMap = fragmentAdapter.isShowOnMap(); - SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false); - new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null) - .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } - } + deleteAndSaveSegment(); return true; } return false; @@ -1060,6 +1024,25 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit return view; } + private void editSegment() { + TrkSegment segment = getTrkSegment(); + if (segment != null && fragmentAdapter != null) { + fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment); + } + } + + private void deleteAndSaveSegment() { + TrackActivity trackActivity = getTrackActivity(); + if (trackActivity != null && deleteSegment()) { + GPXFile gpx = getGpx(); + if (gpx != null && fragmentAdapter != null) { + boolean showOnMap = fragmentAdapter.isShowOnMap(); + SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false); + saveGpx(showOnMap ? selectedGpxFile : null, gpx); + } + } + } + private boolean deleteSegment() { TrkSegment segment = getTrkSegment(); if (segment != null) { @@ -1269,55 +1252,33 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit } } - private static class SaveGpxAsyncTask extends AsyncTask { - private final GPXFile gpx; - private final SelectedGpxFile selectedGpx; - private OsmandApplication app; - private final WeakReference activityRef; - private final WeakReference fragmentRef; - - SaveGpxAsyncTask(@NonNull TrackActivity activity, - @NonNull TrackSegmentFragment fragment, - @NonNull GPXFile gpx, - @Nullable SelectedGpxFile selectedGpx) { - this.gpx = gpx; - activityRef = new WeakReference<>(activity); - fragmentRef = new WeakReference<>(fragment); - app = activity.getMyApplication(); - this.selectedGpx = selectedGpx; - } - - @Override - protected void onPreExecute() { - TrackActivity activity = activityRef.get(); - if (activity != null) { - activity.setSupportProgressBarIndeterminateVisibility(true); + private void saveGpx(final SelectedGpxFile selectedGpxFile, GPXFile gpxFile) { + new SaveGpxAsyncTask(gpxFile, new SaveGpxListener() { + @Override + public void gpxSavingStarted() { + TrackActivity activity = getTrackActivity(); + if (activity != null && AndroidUtils.isActivityNotDestroyed(activity)) { + activity.setSupportProgressBarIndeterminateVisibility(true); + } } - } - @Override - protected Void doInBackground(Void... params) { - GPXUtilities.writeGpxFile(new File(gpx.path), gpx); - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - TrackActivity activity = activityRef.get(); - TrackSegmentFragment fragment = fragmentRef.get(); - if (activity != null && fragment != null) { - if (selectedGpx != null) { - List groups = fragment.getDisplayGroups(); - if (groups != null) { - selectedGpx.setDisplayGroups(groups, app); - selectedGpx.processPoints(app); + @Override + public void gpxSavingFinished() { + TrackActivity activity = getTrackActivity(); + if (activity != null) { + if (selectedGpxFile != null) { + List groups = getDisplayGroups(); + if (groups != null) { + selectedGpxFile.setDisplayGroups(groups, app); + selectedGpxFile.processPoints(app); + } + } + updateContent(); + if (AndroidUtils.isActivityNotDestroyed(activity)) { + activity.setSupportProgressBarIndeterminateVisibility(false); } } - fragment.updateContent(); - if (!activity.isFinishing()) { - activity.setSupportProgressBarIndeterminateVisibility(false); - } } - } + }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index 1989d02b13..b75c776b44 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -1,5 +1,6 @@ package net.osmand.plus.track; +import android.os.AsyncTask; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; @@ -11,6 +12,8 @@ import android.widget.LinearLayout; import androidx.annotation.NonNull; import net.osmand.AndroidUtils; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -20,19 +23,27 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.myplaces.DirectionArrowsCard; +import net.osmand.plus.myplaces.SaveGpxAsyncTask; import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import java.io.File; public class TrackAppearanceFragment extends ContextMenuFragment { public static final String SELECTED_TRACK_FILE_PATH = "selected_track_file_path"; + private OsmandApplication app; + + private GpxDataItem gpxDataItem; + private TrackDrawInfo trackDrawInfo; private SelectedGpxFile selectedGpxFile; + private int menuTitleHeight; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - OsmandApplication app = requireMyApplication(); + app = requireMyApplication(); String gpxFilePath = null; Bundle arguments = getArguments(); @@ -43,6 +54,10 @@ public class TrackAppearanceFragment extends ContextMenuFragment { gpxFilePath = arguments.getString(SELECTED_TRACK_FILE_PATH); } selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); + + File file = new File(selectedGpxFile.getGpxFile().path); + gpxDataItem = app.getGpxDbHelper().getItem(file); + trackDrawInfo = new TrackDrawInfo(gpxDataItem); } @Override @@ -96,7 +111,8 @@ public class TrackAppearanceFragment extends ContextMenuFragment { saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - + saveTrackInfo(); + dismiss(); } }); @@ -115,6 +131,36 @@ public class TrackAppearanceFragment extends ContextMenuFragment { AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true); } + private void saveTrackInfo() { + GPXFile gpxFile = selectedGpxFile.getGpxFile(); + + gpxFile.setWidth(trackDrawInfo.getWidth()); + gpxFile.setGradientScaleType(trackDrawInfo.getGradientScaleType().name()); + gpxFile.setColor(trackDrawInfo.getColor()); + gpxFile.setGradientScaleColor(GradientScaleType.SPEED.getTypeName(), trackDrawInfo.getGradientSpeedColor()); + gpxFile.setGradientScaleColor(GradientScaleType.ALTITUDE.getTypeName(), trackDrawInfo.getGradientAltitudeColor()); + gpxFile.setGradientScaleColor(GradientScaleType.SLOPE.getTypeName(), trackDrawInfo.getGradientSlopeColor()); + + for (GpxSplitType gpxSplitType : GpxSplitType.values()) { + if (gpxSplitType.getType() == trackDrawInfo.getSplitType()) { + gpxFile.setSplitType(gpxSplitType.name()); + break; + } + } + + gpxFile.setSplitInterval(trackDrawInfo.getSplitInterval()); + gpxFile.setShowArrows(trackDrawInfo.isShowArrows()); + gpxFile.setShowStartFinish(trackDrawInfo.isShowStartFinish()); + + app.getSelectedGpxHelper().updateSelectedGpxFile(selectedGpxFile); + + saveGpx(gpxFile); + } + + private void saveGpx(GPXFile gpxFile) { + new SaveGpxAsyncTask(gpxFile, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + private void updateCards() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { @@ -142,7 +188,15 @@ public class TrackAppearanceFragment extends ContextMenuFragment { @Override public int getHeaderViewHeight() { - return 0; + return menuTitleHeight; + } + + @Override + protected void calculateLayout(View view, boolean initLayout) { + menuTitleHeight = view.findViewById(R.id.route_menu_top_shadow_all).getHeight() + + view.findViewById(R.id.control_buttons).getHeight() + - view.findViewById(R.id.buttons_shadow).getHeight(); + super.calculateLayout(view, initLayout); } @Override @@ -155,6 +209,10 @@ public class TrackAppearanceFragment extends ContextMenuFragment { return 0; } + public float getMiddleStateKoef() { + return 0.5f; + } + public static boolean showInstance(@NonNull MapActivity mapActivity, TrackAppearanceFragment fragment) { try { mapActivity.getSupportFragmentManager() From fce394f3f7335ccb49e9e9976acdf4d625ed3554 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 15 Jul 2020 13:47:18 +0300 Subject: [PATCH 130/551] Add trackDrawInfo for drawing unsaved gpx parameters --- .../plus/myplaces/DirectionArrowsCard.java | 29 +--- .../plus/track/SplitIntervalBottomSheet.java | 4 +- .../osmand/plus/track/SplitIntervalCard.java | 9 +- .../plus/track/TrackAppearanceFragment.java | 26 ++- .../osmand/plus/track/TrackColoringCard.java | 51 +----- .../net/osmand/plus/track/TrackDrawInfo.java | 160 ++++++++++++++++++ .../net/osmand/plus/track/TrackWidthCard.java | 32 +--- .../src/net/osmand/plus/views/GPXLayer.java | 23 ++- 8 files changed, 233 insertions(+), 101 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java diff --git a/OsmAnd/src/net/osmand/plus/myplaces/DirectionArrowsCard.java b/OsmAnd/src/net/osmand/plus/myplaces/DirectionArrowsCard.java index cd3b5f701a..a9f2fb87ee 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/DirectionArrowsCard.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/DirectionArrowsCard.java @@ -6,23 +6,19 @@ import android.widget.TextView; import androidx.annotation.NonNull; -import net.osmand.GPXUtilities.GPXFile; -import net.osmand.plus.GPXDatabase.GpxDataItem; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.routepreparationmenu.cards.BaseCard; - -import java.io.File; +import net.osmand.plus.track.TrackDrawInfo; public class DirectionArrowsCard extends BaseCard { - private SelectedGpxFile selectedGpxFile; + private TrackDrawInfo trackDrawInfo; - public DirectionArrowsCard(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile) { + public DirectionArrowsCard(@NonNull MapActivity mapActivity, @NonNull TrackDrawInfo trackDrawInfo) { super(mapActivity); - this.selectedGpxFile = selectedGpxFile; + this.trackDrawInfo = trackDrawInfo; } @Override @@ -38,27 +34,16 @@ public class DirectionArrowsCard extends BaseCard { titleView.setText(R.string.gpx_direction_arrows); final CompoundButton compoundButton = view.findViewById(R.id.compound_button); - compoundButton.setChecked(selectedGpxFile.getGpxFile().isShowStartFinish()); + compoundButton.setChecked(trackDrawInfo.isShowStartFinish()); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { boolean checked = !compoundButton.isChecked(); compoundButton.setChecked(checked); - setShowArrows(checked); + trackDrawInfo.setShowArrows(checked); + mapActivity.refreshMap(); } }); } - - private void setShowArrows(boolean showArrows) { - if (selectedGpxFile.getGpxFile() != null) { - GPXFile gpxFile = selectedGpxFile.getGpxFile(); - gpxFile.setShowArrows(showArrows); - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path)); - if (gpxDataItem != null) { - app.getGpxDbHelper().updateShowArrows(gpxDataItem, showArrows); - } - mapActivity.refreshMap(); - } - } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java index cc777b008f..ba858187f9 100644 --- a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java @@ -346,11 +346,11 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { return groups; } - public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile) { + public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo) { try { if (fragmentManager.findFragmentByTag(SplitIntervalBottomSheet.TAG) == null) { Bundle args = new Bundle(); - args.putString(SELECTED_TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path); + args.putString(SELECTED_TRACK_FILE_PATH, trackDrawInfo.getFilePath()); SplitIntervalBottomSheet splitIntervalBottomSheet = new SplitIntervalBottomSheet(); splitIntervalBottomSheet.setArguments(args); diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java index 12ed4d6091..f4e023b3cb 100644 --- a/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java @@ -5,7 +5,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; @@ -13,11 +12,11 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard; public class SplitIntervalCard extends BaseCard { - private SelectedGpxFile selectedGpxFile; + private TrackDrawInfo trackDrawInfo; - public SplitIntervalCard(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile) { + public SplitIntervalCard(@NonNull MapActivity mapActivity, TrackDrawInfo trackDrawInfo) { super(mapActivity); - this.selectedGpxFile = selectedGpxFile; + this.trackDrawInfo = trackDrawInfo; } @Override @@ -37,7 +36,7 @@ public class SplitIntervalCard extends BaseCard { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), selectedGpxFile); + SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo); } }); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index b75c776b44..d55d9cc047 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -80,6 +80,24 @@ public class TrackAppearanceFragment extends ContextMenuFragment { return view; } + @Override + public void onResume() { + super.onResume(); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.getMapLayers().getGpxLayer().setTrackDrawInfo(trackDrawInfo); + } + } + + @Override + public void onPause() { + super.onPause(); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.getMapLayers().getGpxLayer().setTrackDrawInfo(null); + } + } + @Override public void onSaveInstanceState(Bundle outState) { outState.putString(SELECTED_TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path); @@ -167,16 +185,16 @@ public class TrackAppearanceFragment extends ContextMenuFragment { ViewGroup cardsContainer = getCardsContainer(); cardsContainer.removeAllViews(); - BaseCard splitIntervalCard = new SplitIntervalCard(mapActivity, selectedGpxFile); + BaseCard splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo); cardsContainer.addView(splitIntervalCard.build(mapActivity)); - BaseCard arrowsCard = new DirectionArrowsCard(mapActivity, selectedGpxFile); + BaseCard arrowsCard = new DirectionArrowsCard(mapActivity, trackDrawInfo); cardsContainer.addView(arrowsCard.build(mapActivity)); - TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile); + TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile, trackDrawInfo); cardsContainer.addView(trackColoringCard.build(mapActivity)); - BaseCard width = new TrackWidthCard(mapActivity, selectedGpxFile); + BaseCard width = new TrackWidthCard(mapActivity, trackDrawInfo); cardsContainer.addView(width.build(mapActivity)); } } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java index 8bf1fb89e6..2e893dc4a1 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java @@ -17,9 +17,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import net.osmand.AndroidUtils; -import net.osmand.GPXUtilities.GPXFile; -import net.osmand.plus.GPXDatabase.GpxDataItem; -import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -30,7 +27,6 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.widgets.FlowLayout; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -39,6 +35,7 @@ import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems; public class TrackColoringCard extends BaseCard { + private TrackDrawInfo trackDrawInfo; private SelectedGpxFile selectedGpxFile; private GradientScaleType selectedScaleType; @@ -46,8 +43,9 @@ public class TrackColoringCard extends BaseCard { @ColorInt private int selectedColor; - public TrackColoringCard(MapActivity mapActivity, GpxSelectionHelper.SelectedGpxFile selectedGpxFile) { + public TrackColoringCard(MapActivity mapActivity, SelectedGpxFile selectedGpxFile, TrackDrawInfo trackDrawInfo) { super(mapActivity); + this.trackDrawInfo = trackDrawInfo; this.selectedGpxFile = selectedGpxFile; } @@ -120,35 +118,13 @@ public class TrackColoringCard extends BaseCard { newColor.findViewById(R.id.outline).setVisibility(View.VISIBLE); } selectedColor = color; - setGpxColor(color); - } - - private void setGpxColor(int color) { - GPXFile gpxFile = selectedGpxFile.getGpxFile(); - if (gpxFile != null) { - if (color != 0) { - selectedGpxFile.getGpxFile().setColor(color); - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path)); - if (gpxDataItem != null) { - app.getGpxDbHelper().updateColor(gpxDataItem, color); - } - } - if (gpxFile.showCurrentTrack) { - app.getSettings().CURRENT_TRACK_COLOR.set(color); - } - mapActivity.refreshMap(); - } + trackDrawInfo.setColor(color); + mapActivity.refreshMap(); } private GradientScaleType getSelectedScaleType() { if (selectedScaleType == null) { - String gradientScaleType = selectedGpxFile.getGpxFile().getGradientScaleType(); - for (GradientScaleType item : GradientScaleType.values()) { - if (item.name().equalsIgnoreCase(gradientScaleType)) { - selectedScaleType = item; - break; - } - } + selectedScaleType = trackDrawInfo.getGradientScaleType(); if (selectedScaleType == null) { selectedScaleType = GradientScaleType.SOLID; } @@ -171,18 +147,6 @@ public class TrackColoringCard extends BaseCard { AndroidUiHelper.updateVisibility(view.findViewById(R.id.select_color), visible); } - private void setGradientScaleType(GradientScaleType gradientScaleType) { - if (selectedGpxFile.getGpxFile() != null) { - GPXFile gpxFile = selectedGpxFile.getGpxFile(); - gpxFile.setGradientScaleType(gradientScaleType.getTypeName()); - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path)); - if (gpxDataItem != null) { - app.getGpxDbHelper().updateGradientScaleType(gpxDataItem, gradientScaleType); - } - mapActivity.refreshMap(); - } - } - private class GpxWidthAdapter extends RecyclerView.Adapter { private List items; @@ -237,7 +201,8 @@ public class TrackColoringCard extends BaseCard { notifyItemChanged(holder.getAdapterPosition()); notifyItemChanged(prevSelectedPosition); - setGradientScaleType(selectedScaleType); + trackDrawInfo.setGradientScaleType(selectedScaleType); + mapActivity.refreshMap(); updateHeader(); updateCustomWidthSlider(); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java b/OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java new file mode 100644 index 0000000000..b933ba32ef --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java @@ -0,0 +1,160 @@ +package net.osmand.plus.track; + +import net.osmand.plus.GPXDatabase.GpxDataItem; + +public class TrackDrawInfo { + + private String filePath; + private String width; + private GradientScaleType gradientScaleType; + private int color; + private int gradientSpeedColor; + private int gradientAltitudeColor; + private int gradientSlopeColor; + private int splitType; + private double splitInterval; + private long fileLastModifiedTime; + private boolean apiImported; + private boolean showAsMarkers; + private boolean joinSegments; + private boolean showArrows; + private boolean showStartFinish; + + public TrackDrawInfo(GpxDataItem gpxDataItem) { + filePath = gpxDataItem.getFile().getPath(); + width = gpxDataItem.getWidth(); + gradientScaleType = gpxDataItem.getGradientScaleType(); + color = gpxDataItem.getColor(); + gradientSpeedColor = gpxDataItem.getGradientSpeedColor(); + gradientAltitudeColor = gpxDataItem.getGradientAltitudeColor(); + gradientSlopeColor = gpxDataItem.getGradientSlopeColor(); + splitType = gpxDataItem.getSplitType(); + splitInterval = gpxDataItem.getSplitInterval(); + fileLastModifiedTime = gpxDataItem.getFileLastModifiedTime(); + apiImported = gpxDataItem.isApiImported(); + showAsMarkers = gpxDataItem.isShowAsMarkers(); + joinSegments = gpxDataItem.isJoinSegments(); + showArrows = gpxDataItem.isShowArrows(); + showStartFinish = gpxDataItem.isShowStartFinish(); + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getWidth() { + return width; + } + + public void setWidth(String width) { + this.width = width; + } + + public GradientScaleType getGradientScaleType() { + return gradientScaleType; + } + + public void setGradientScaleType(GradientScaleType gradientScaleType) { + this.gradientScaleType = gradientScaleType; + } + + public int getColor() { + return color; + } + + public void setColor(int color) { + this.color = color; + } + + public int getGradientSpeedColor() { + return gradientSpeedColor; + } + + public void setGradientSpeedColor(int gradientSpeedColor) { + this.gradientSpeedColor = gradientSpeedColor; + } + + public int getGradientAltitudeColor() { + return gradientAltitudeColor; + } + + public void setGradientAltitudeColor(int gradientAltitudeColor) { + this.gradientAltitudeColor = gradientAltitudeColor; + } + + public int getGradientSlopeColor() { + return gradientSlopeColor; + } + + public void setGradientSlopeColor(int gradientSlopeColor) { + this.gradientSlopeColor = gradientSlopeColor; + } + + public int getSplitType() { + return splitType; + } + + public void setSplitType(int splitType) { + this.splitType = splitType; + } + + public double getSplitInterval() { + return splitInterval; + } + + public void setSplitInterval(double splitInterval) { + this.splitInterval = splitInterval; + } + + public long getFileLastModifiedTime() { + return fileLastModifiedTime; + } + + public void setFileLastModifiedTime(long fileLastModifiedTime) { + this.fileLastModifiedTime = fileLastModifiedTime; + } + + public boolean isApiImported() { + return apiImported; + } + + public void setApiImported(boolean apiImported) { + this.apiImported = apiImported; + } + + public boolean isShowAsMarkers() { + return showAsMarkers; + } + + public void setShowAsMarkers(boolean showAsMarkers) { + this.showAsMarkers = showAsMarkers; + } + + public boolean isJoinSegments() { + return joinSegments; + } + + public void setJoinSegments(boolean joinSegments) { + this.joinSegments = joinSegments; + } + + public boolean isShowArrows() { + return showArrows; + } + + public void setShowArrows(boolean showArrows) { + this.showArrows = showArrows; + } + + public boolean isShowStartFinish() { + return showStartFinish; + } + + public void setShowStartFinish(boolean showStartFinish) { + this.showStartFinish = showStartFinish; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java b/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java index 27fca5b210..0e1c3a0d03 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java @@ -17,9 +17,6 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.slider.Slider; import net.osmand.AndroidUtils; -import net.osmand.GPXUtilities.GPXFile; -import net.osmand.plus.GPXDatabase.GpxDataItem; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; @@ -30,7 +27,6 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.util.Algorithms; -import java.io.File; import java.util.List; public class TrackWidthCard extends BaseCard { @@ -39,14 +35,14 @@ public class TrackWidthCard extends BaseCard { private final static int CUSTOM_WIDTH_MIN = 1; private final static int CUSTOM_WIDTH_MAX = 24; - private SelectedGpxFile selectedGpxFile; + private TrackDrawInfo trackDrawInfo; private AppearanceListItem selectedItem; private List appearanceItems; - public TrackWidthCard(MapActivity mapActivity, SelectedGpxFile selectedGpxFile) { + public TrackWidthCard(MapActivity mapActivity, TrackDrawInfo trackDrawInfo) { super(mapActivity); - this.selectedGpxFile = selectedGpxFile; + this.trackDrawInfo = trackDrawInfo; appearanceItems = getWidthAppearanceItems(); } @@ -67,7 +63,7 @@ public class TrackWidthCard extends BaseCard { private AppearanceListItem getSelectedItem() { if (selectedItem == null) { - String selectedWidth = selectedGpxFile.getGpxFile().getWidth(null); + String selectedWidth = trackDrawInfo.getWidth(); for (AppearanceListItem item : appearanceItems) { if (Algorithms.objectEquals(item.getValue(), selectedWidth) || ((Algorithms.isEmpty(selectedWidth) || Algorithms.isInt(selectedWidth)) @@ -83,7 +79,7 @@ public class TrackWidthCard extends BaseCard { private List getWidthAppearanceItems() { List items = GpxAppearanceAdapter.getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_WIDTH); - String selectedWidth = selectedGpxFile.getGpxFile().getWidth(null); + String selectedWidth = trackDrawInfo.getWidth(); String customWidth = !Algorithms.isEmpty(selectedWidth) && Algorithms.isInt(selectedWidth) ? selectedWidth : String.valueOf(CUSTOM_WIDTH_MIN); items.add(new AppearanceListItem(CUSTOM_WIDTH, customWidth, app.getString(R.string.shared_string_custom))); @@ -141,15 +137,8 @@ public class TrackWidthCard extends BaseCard { } private void setGpxWidth(String width) { - if (selectedGpxFile.getGpxFile() != null) { - GPXFile gpxFile = selectedGpxFile.getGpxFile(); - gpxFile.setWidth(width); - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path)); - if (gpxDataItem != null) { - app.getGpxDbHelper().updateWidth(gpxDataItem, width); - } - mapActivity.refreshMap(); - } + trackDrawInfo.setWidth(width); + mapActivity.refreshMap(); } private class GpxWidthAdapter extends RecyclerView.Adapter { @@ -201,12 +190,7 @@ public class TrackWidthCard extends BaseCard { } private void updateWidthIcon(GpxWidthViewHolder holder, AppearanceListItem item) { - int color; - if (selectedGpxFile.isShowCurrentTrack()) { - color = app.getSettings().CURRENT_TRACK_COLOR.get(); - } else { - color = selectedGpxFile.getGpxFile().getColor(0); - } + int color = trackDrawInfo.getColor(); int iconId; if (CUSTOM_WIDTH.equals(item.getAttrName())) { diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 7cc2e97f63..43d7e18d04 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -49,6 +49,7 @@ import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.render.OsmandRenderer; import net.osmand.plus.render.OsmandRenderer.RenderingContext; import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; +import net.osmand.plus.track.TrackDrawInfo; import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.ContextMenuLayer.IMoveObjectProvider; import net.osmand.plus.views.MapTextLayer.MapTextProvider; @@ -92,6 +93,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private Drawable startPointIcon; private Drawable finishPointIcon; private LayerDrawable selectedPoint; + private TrackDrawInfo trackDrawInfo; private TrackChartPoints trackChartPoints; private GpxSelectionHelper selectedGpxHelper; @@ -136,6 +138,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM this.trackChartPoints = trackChartPoints; } + public void setTrackDrawInfo(TrackDrawInfo trackDrawInfo) { + this.trackDrawInfo = trackDrawInfo; + } + private void initUI() { paint = new Paint(); paint.setStyle(Style.STROKE); @@ -396,7 +402,11 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List selectedGPXFiles) { if (tileBox.getZoom() >= START_ZOOM) { for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) { - if (selectedGpxFile.getGpxFile().isShowStartFinish()) { + boolean showStartFinish = selectedGpxFile.getGpxFile().isShowStartFinish(); + if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) { + showStartFinish = trackDrawInfo.isShowStartFinish(); + } + if (showStartFinish) { List segments = selectedGpxFile.getPointsToDisplay(); TrkSegment endSegment = segments.get(segments.size() - 1); @@ -410,6 +420,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } } + private boolean hasTrackDrawInfoForSelectedGpx(SelectedGpxFile selectedGpxFile) { + return trackDrawInfo != null && trackDrawInfo.getFilePath().equals(selectedGpxFile.getGpxFile().path); + } + private void drawPoint(Canvas canvas, RotatedTileBox tileBox, WptPt wptPt, Drawable icon) { int pointX = (int) tileBox.getPixXFromLatLon(wptPt.lat, wptPt.lon); int pointY = (int) tileBox.getPixYFromLatLon(wptPt.lat, wptPt.lon); @@ -573,6 +587,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM List selectedGPXFiles, DrawSettings settings) { for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) { String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get()); + if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) { + width = trackDrawInfo.getWidth(); + } if (!cachedTrackWidth.containsKey(width)) { cachedTrackWidth.put(width, null); } @@ -602,6 +619,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM if (color == 0) { color = ts.getColor(cachedColor); } + if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) { + color = trackDrawInfo.getColor(); + width = trackDrawInfo.getWidth(); + } if (ts.renderer == null && !ts.points.isEmpty()) { if (currentTrack) { ts.renderer = new Renderable.CurrentTrack(ts.points); From debe7d19527e59aabf2f2c7137a3cf720fa36fad Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 15 Jul 2020 15:27:30 +0300 Subject: [PATCH 131/551] Save gpx appearance changes to db --- .../net/osmand/plus/track/TrackAppearanceFragment.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index d55d9cc047..3d84ce4d79 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -34,7 +34,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment { private OsmandApplication app; - private GpxDataItem gpxDataItem; private TrackDrawInfo trackDrawInfo; private SelectedGpxFile selectedGpxFile; @@ -56,7 +55,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment { selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); File file = new File(selectedGpxFile.getGpxFile().path); - gpxDataItem = app.getGpxDbHelper().getItem(file); + GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(file); trackDrawInfo = new TrackDrawInfo(gpxDataItem); } @@ -155,9 +154,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment { gpxFile.setWidth(trackDrawInfo.getWidth()); gpxFile.setGradientScaleType(trackDrawInfo.getGradientScaleType().name()); gpxFile.setColor(trackDrawInfo.getColor()); - gpxFile.setGradientScaleColor(GradientScaleType.SPEED.getTypeName(), trackDrawInfo.getGradientSpeedColor()); - gpxFile.setGradientScaleColor(GradientScaleType.ALTITUDE.getTypeName(), trackDrawInfo.getGradientAltitudeColor()); - gpxFile.setGradientScaleColor(GradientScaleType.SLOPE.getTypeName(), trackDrawInfo.getGradientSlopeColor()); for (GpxSplitType gpxSplitType : GpxSplitType.values()) { if (gpxSplitType.getType() == trackDrawInfo.getSplitType()) { @@ -172,6 +168,8 @@ public class TrackAppearanceFragment extends ContextMenuFragment { app.getSelectedGpxHelper().updateSelectedGpxFile(selectedGpxFile); + GpxDataItem item = new GpxDataItem(new File(gpxFile.path), gpxFile); + app.getGpxDbHelper().add(item); saveGpx(gpxFile); } From ed1db1978ae8e96fb279f5e76651f66cbcd8da8b Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 15 Jul 2020 16:20:15 +0300 Subject: [PATCH 132/551] Save track appearance params on orientation change --- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 8 +- OsmAnd/src/net/osmand/plus/GpxDbHelper.java | 2 +- .../plus/track/SplitIntervalBottomSheet.java | 10 +-- .../plus/track/TrackAppearanceFragment.java | 29 ++++--- .../net/osmand/plus/track/TrackDrawInfo.java | 81 ++++++++++++------- 5 files changed, 75 insertions(+), 55 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index 7a3ec03992..02af03f89f 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -539,7 +539,7 @@ public class GPXDatabase { return false; } - public boolean updateGradientScaleType(@NonNull GpxDataItem item, GradientScaleType gradientScaleType) { + public boolean updateGradientScaleType(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType) { SQLiteConnection db = openConnection(false); if (db != null) { try { @@ -547,7 +547,7 @@ public class GPXDatabase { String fileDir = getFileDir(item.file); db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_GRADIENT_SCALE_TYPE + " = ? " + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", - new Object[] {(gradientScaleType == null ? "" : gradientScaleType.name()), fileName, fileDir}); + new Object[] {gradientScaleType.name(), fileName, fileDir}); item.gradientScaleType = gradientScaleType; } finally { db.close(); @@ -723,7 +723,7 @@ public class GPXDatabase { } else { color = Algorithms.colorToString(item.color); } - String gradientScaleType = item.gradientScaleType != null ? item.gradientScaleType.name() : null; + String gradientScaleType = item.gradientScaleType != null ? item.gradientScaleType.name() : GradientScaleType.SOLID.name(); if (a != null) { db.execSQL( "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", @@ -891,7 +891,7 @@ public class GPXDatabase { try { item.gradientScaleType = Algorithms.isEmpty(gradientScaleType) ? null : GradientScaleType.valueOf(gradientScaleType); } catch (IllegalArgumentException e) { - item.gradientScaleType = null; + item.gradientScaleType = GradientScaleType.SOLID; } return item; diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index d5e05e8db3..59a5f02895 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -85,7 +85,7 @@ public class GpxDbHelper { return res; } - public boolean updateGradientScaleType(@NonNull GpxDataItem item, @Nullable GradientScaleType gradientScaleType) { + public boolean updateGradientScaleType(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType) { boolean res = db.updateGradientScaleType(item, gradientScaleType); putToCache(item); return res; diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java index ba858187f9..ffb3fade30 100644 --- a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java @@ -38,7 +38,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import static net.osmand.plus.track.TrackAppearanceFragment.SELECTED_TRACK_FILE_PATH; +import static net.osmand.plus.track.TrackDrawInfo.TRACK_FILE_PATH; public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { @@ -75,7 +75,7 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { Bundle arguments = getArguments(); if (savedInstanceState != null) { - String gpxFilePath = savedInstanceState.getString(SELECTED_TRACK_FILE_PATH); + String gpxFilePath = savedInstanceState.getString(TRACK_FILE_PATH); selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); prepareSplitIntervalOptions(); @@ -83,7 +83,7 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { selectedDistanceSplitInterval = savedInstanceState.getInt(SELECTED_DISTANCE_SPLIT_INTERVAL); selectedSplitType = GpxSplitType.valueOf(savedInstanceState.getString(SELECTED_TRACK_SPLIT_TYPE)); } else if (arguments != null) { - String gpxFilePath = arguments.getString(SELECTED_TRACK_FILE_PATH); + String gpxFilePath = arguments.getString(TRACK_FILE_PATH); selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); prepareSplitIntervalOptions(); updateSelectedSplitParams(); @@ -142,7 +142,7 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { outState.putInt(SELECTED_TIME_SPLIT_INTERVAL, selectedTimeSplitInterval); outState.putInt(SELECTED_DISTANCE_SPLIT_INTERVAL, selectedDistanceSplitInterval); outState.putString(SELECTED_TRACK_SPLIT_TYPE, selectedSplitType.name()); - outState.putString(SELECTED_TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path); + outState.putString(TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path); } private void updateSelectedSplitParams() { @@ -350,7 +350,7 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { try { if (fragmentManager.findFragmentByTag(SplitIntervalBottomSheet.TAG) == null) { Bundle args = new Bundle(); - args.putString(SELECTED_TRACK_FILE_PATH, trackDrawInfo.getFilePath()); + args.putString(TRACK_FILE_PATH, trackDrawInfo.getFilePath()); SplitIntervalBottomSheet splitIntervalBottomSheet = new SplitIntervalBottomSheet(); splitIntervalBottomSheet.setArguments(args); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index 3d84ce4d79..e267a15dc1 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -28,9 +28,9 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard; import java.io.File; -public class TrackAppearanceFragment extends ContextMenuFragment { +import static net.osmand.plus.track.TrackDrawInfo.TRACK_FILE_PATH; - public static final String SELECTED_TRACK_FILE_PATH = "selected_track_file_path"; +public class TrackAppearanceFragment extends ContextMenuFragment { private OsmandApplication app; @@ -44,19 +44,18 @@ public class TrackAppearanceFragment extends ContextMenuFragment { super.onCreate(savedInstanceState); app = requireMyApplication(); - String gpxFilePath = null; Bundle arguments = getArguments(); - if (savedInstanceState != null && savedInstanceState.containsKey(SELECTED_TRACK_FILE_PATH)) { - gpxFilePath = savedInstanceState.getString(SELECTED_TRACK_FILE_PATH); + if (savedInstanceState != null) { + trackDrawInfo = new TrackDrawInfo(); + trackDrawInfo.readBundle(savedInstanceState); + selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(trackDrawInfo.getFilePath()); + } else if (arguments != null) { + String gpxFilePath = arguments.getString(TRACK_FILE_PATH); + selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); + File file = new File(selectedGpxFile.getGpxFile().path); + GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(file); + trackDrawInfo = new TrackDrawInfo(gpxDataItem); } - if (arguments != null && arguments.containsKey(SELECTED_TRACK_FILE_PATH)) { - gpxFilePath = arguments.getString(SELECTED_TRACK_FILE_PATH); - } - selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); - - File file = new File(selectedGpxFile.getGpxFile().path); - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(file); - trackDrawInfo = new TrackDrawInfo(gpxDataItem); } @Override @@ -98,9 +97,9 @@ public class TrackAppearanceFragment extends ContextMenuFragment { } @Override - public void onSaveInstanceState(Bundle outState) { - outState.putString(SELECTED_TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path); + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); + trackDrawInfo.saveToBundle(outState); } private void updateCardsLayout() { diff --git a/OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java b/OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java index b933ba32ef..40cf4c52a7 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java @@ -1,9 +1,26 @@ package net.osmand.plus.track; +import android.os.Bundle; + +import androidx.annotation.NonNull; + import net.osmand.plus.GPXDatabase.GpxDataItem; public class TrackDrawInfo { + public static final String TRACK_FILE_PATH = "track_file_path"; + private static final String TRACK_WIDTH = "track_width"; + private static final String TRACK_GRADIENT_SCALE_TYPE = "track_gradient_scale_type"; + private static final String TRACK_COLOR = "track_color"; + private static final String TRACK_GRADIENT_SPEED_COLOR = "track_gradient_speed_color"; + private static final String TRACK_GRADIENT_ALTITUDE_COLOR = "track_gradient_altitude_color"; + private static final String TRACK_GRADIENT_SLOPE_COLOR = "track_gradient_slope_color"; + private static final String TRACK_SPLIT_TYPE = "track_split_type"; + private static final String TRACK_SPLIT_INTERVAL = "track_split_interval"; + private static final String TRACK_JOIN_SEGMENTS = "track_join_segments"; + private static final String TRACK_SHOW_ARROWS = "track_show_arrows"; + private static final String TRACK_SHOW_START_FINISH = "track_show_start_finish"; + private String filePath; private String width; private GradientScaleType gradientScaleType; @@ -13,13 +30,14 @@ public class TrackDrawInfo { private int gradientSlopeColor; private int splitType; private double splitInterval; - private long fileLastModifiedTime; - private boolean apiImported; - private boolean showAsMarkers; private boolean joinSegments; private boolean showArrows; private boolean showStartFinish; + public TrackDrawInfo() { + + } + public TrackDrawInfo(GpxDataItem gpxDataItem) { filePath = gpxDataItem.getFile().getPath(); width = gpxDataItem.getWidth(); @@ -30,9 +48,6 @@ public class TrackDrawInfo { gradientSlopeColor = gpxDataItem.getGradientSlopeColor(); splitType = gpxDataItem.getSplitType(); splitInterval = gpxDataItem.getSplitInterval(); - fileLastModifiedTime = gpxDataItem.getFileLastModifiedTime(); - apiImported = gpxDataItem.isApiImported(); - showAsMarkers = gpxDataItem.isShowAsMarkers(); joinSegments = gpxDataItem.isJoinSegments(); showArrows = gpxDataItem.isShowArrows(); showStartFinish = gpxDataItem.isShowStartFinish(); @@ -110,30 +125,6 @@ public class TrackDrawInfo { this.splitInterval = splitInterval; } - public long getFileLastModifiedTime() { - return fileLastModifiedTime; - } - - public void setFileLastModifiedTime(long fileLastModifiedTime) { - this.fileLastModifiedTime = fileLastModifiedTime; - } - - public boolean isApiImported() { - return apiImported; - } - - public void setApiImported(boolean apiImported) { - this.apiImported = apiImported; - } - - public boolean isShowAsMarkers() { - return showAsMarkers; - } - - public void setShowAsMarkers(boolean showAsMarkers) { - this.showAsMarkers = showAsMarkers; - } - public boolean isJoinSegments() { return joinSegments; } @@ -157,4 +148,34 @@ public class TrackDrawInfo { public void setShowStartFinish(boolean showStartFinish) { this.showStartFinish = showStartFinish; } + + protected void readBundle(@NonNull Bundle bundle) { + filePath = bundle.getString(TRACK_FILE_PATH); + width = bundle.getString(TRACK_WIDTH); + gradientScaleType = GradientScaleType.valueOf(bundle.getString(TRACK_GRADIENT_SCALE_TYPE)); + color = bundle.getInt(TRACK_COLOR); + gradientSpeedColor = bundle.getInt(TRACK_GRADIENT_SPEED_COLOR); + gradientAltitudeColor = bundle.getInt(TRACK_GRADIENT_ALTITUDE_COLOR); + gradientSlopeColor = bundle.getInt(TRACK_GRADIENT_SLOPE_COLOR); + splitType = bundle.getInt(TRACK_SPLIT_TYPE); + splitInterval = bundle.getDouble(TRACK_SPLIT_INTERVAL); + joinSegments = bundle.getBoolean(TRACK_JOIN_SEGMENTS); + showArrows = bundle.getBoolean(TRACK_SHOW_ARROWS); + showStartFinish = bundle.getBoolean(TRACK_SHOW_START_FINISH); + } + + protected void saveToBundle(@NonNull Bundle bundle) { + bundle.putString(TRACK_FILE_PATH, filePath); + bundle.putString(TRACK_WIDTH, width); + bundle.putString(TRACK_GRADIENT_SCALE_TYPE, gradientScaleType.name()); + bundle.putInt(TRACK_COLOR, color); + bundle.putInt(TRACK_GRADIENT_SPEED_COLOR, gradientSpeedColor); + bundle.putInt(TRACK_GRADIENT_ALTITUDE_COLOR, gradientAltitudeColor); + bundle.putInt(TRACK_GRADIENT_SLOPE_COLOR, gradientSlopeColor); + bundle.putInt(TRACK_SPLIT_TYPE, splitType); + bundle.putDouble(TRACK_SPLIT_INTERVAL, splitInterval); + bundle.putBoolean(TRACK_JOIN_SEGMENTS, joinSegments); + bundle.putBoolean(TRACK_SHOW_ARROWS, showArrows); + bundle.putBoolean(TRACK_SHOW_START_FINISH, showStartFinish); + } } \ No newline at end of file From f7338da2974bd1de2ac11d38209be02d97469cdd Mon Sep 17 00:00:00 2001 From: Everton Hermann Date: Wed, 15 Jul 2020 16:48:19 +0200 Subject: [PATCH 133/551] CHANGE: enable translation on filter names from a custom package --- OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java index a67d5554a6..676e20e095 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java @@ -812,7 +812,13 @@ public class PoiFiltersHelper { String filterId = query.getString(0); boolean deleted = query.getInt(3) == TRUE_INT; if (map.containsKey(filterId) && (includeDeleted || !deleted)) { - PoiUIFilter filter = new PoiUIFilter(query.getString(1), filterId, + String filterName = query.getString(1); + String translation = application.getPoiTypes().getPoiTranslation(filterName); + if(translation != null) + { + filterName = translation; + } + PoiUIFilter filter = new PoiUIFilter(filterName, filterId, map.get(filterId), application); filter.setSavedFilterByName(query.getString(2)); filter.setDeleted(deleted); From 0e69e7cadfb52326808ba55c59c1eb71580d8ae7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 16 Jul 2020 11:52:49 +0300 Subject: [PATCH 134/551] Discard split track changes --- .../plus/track/SplitIntervalBottomSheet.java | 62 ++++---- .../osmand/plus/track/SplitIntervalCard.java | 7 +- .../plus/track/TrackAppearanceFragment.java | 144 +++++++++++++----- 3 files changed, 146 insertions(+), 67 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java index ffb3fade30..0deee639d2 100644 --- a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java @@ -9,14 +9,14 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import com.google.android.material.slider.Slider; import net.osmand.PlatformUtil; -import net.osmand.plus.GPXDatabase.GpxDataItem; -import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; @@ -32,7 +32,6 @@ import net.osmand.plus.myplaces.SplitTrackAsyncTask.SplitTrackListener; import org.apache.commons.logging.Log; -import java.io.File; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -50,9 +49,9 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { public static final String SELECTED_TIME_SPLIT_INTERVAL = "selected_time_split_interval"; public static final String SELECTED_DISTANCE_SPLIT_INTERVAL = "selected_distance_split_interval"; - private OsmandApplication app; private SelectedGpxFile selectedGpxFile; + private TrackDrawInfo trackDrawInfo; private Map timeSplitOptions = new LinkedHashMap<>(); private Map distanceSplitOptions = new LinkedHashMap<>(); @@ -73,6 +72,10 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { super.onCreate(savedInstanceState); app = requiredMyApplication(); + Fragment target = getTargetFragment(); + if (target instanceof TrackAppearanceFragment) { + trackDrawInfo = ((TrackAppearanceFragment) target).getTrackDrawInfo(); + } Bundle arguments = getArguments(); if (savedInstanceState != null) { String gpxFilePath = savedInstanceState.getString(TRACK_FILE_PATH); @@ -101,10 +104,10 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { sliderContainer = view.findViewById(R.id.slider_container); slider = sliderContainer.findViewById(R.id.split_slider); - splitValueMin = (TextView) view.findViewById(R.id.split_value_min); - splitValueMax = (TextView) view.findViewById(R.id.split_value_max); - selectedSplitValue = (TextView) view.findViewById(R.id.split_value_tv); - splitIntervalNoneDescr = (TextView) view.findViewById(R.id.split_interval_none_descr); + splitValueMin = view.findViewById(R.id.split_value_min); + splitValueMax = view.findViewById(R.id.split_value_max); + selectedSplitValue = view.findViewById(R.id.split_value_tv); + splitIntervalNoneDescr = view.findViewById(R.id.split_interval_none_descr); UiUtilities.setupSlider(slider, nightMode, null); @@ -146,17 +149,16 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { } private void updateSelectedSplitParams() { - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(selectedGpxFile.getGpxFile().path)); - if (gpxDataItem != null) { - if (gpxDataItem.getSplitType() == GpxSplitType.DISTANCE.getType()) { + if (trackDrawInfo != null) { + if (trackDrawInfo.getSplitType() == GpxSplitType.DISTANCE.getType()) { selectedSplitType = GpxSplitType.DISTANCE; List splitOptions = new ArrayList<>(distanceSplitOptions.values()); - int index = splitOptions.indexOf(gpxDataItem.getSplitInterval()); + int index = splitOptions.indexOf(trackDrawInfo.getSplitInterval()); selectedDistanceSplitInterval = Math.max(index, 0); - } else if (gpxDataItem.getSplitType() == GpxSplitType.TIME.getType()) { + } else if (trackDrawInfo.getSplitType() == GpxSplitType.TIME.getType()) { selectedSplitType = GpxSplitType.TIME; List splitOptions = new ArrayList<>(timeSplitOptions.values()); - int index = splitOptions.indexOf((int) gpxDataItem.getSplitInterval()); + int index = splitOptions.indexOf((int) trackDrawInfo.getSplitInterval()); selectedTimeSplitInterval = Math.max(index, 0); } } @@ -288,12 +290,12 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { @Override protected void onRightBottomButtonClick() { + updateSplit(); applySelectedSplit(); - updateSplitInDatabase(); dismiss(); } - private void updateSplitInDatabase() { + private void updateSplit() { double splitInterval = 0; if (selectedSplitType == GpxSplitType.NO_SPLIT) { splitInterval = 0; @@ -302,10 +304,8 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { } else if (selectedSplitType == GpxSplitType.TIME) { splitInterval = new ArrayList<>(timeSplitOptions.values()).get(selectedTimeSplitInterval); } - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(selectedGpxFile.getGpxFile().path)); - if (gpxDataItem != null) { - app.getGpxDbHelper().updateSplit(gpxDataItem, selectedSplitType, splitInterval); - } + trackDrawInfo.setSplitType(selectedSplitType.getType()); + trackDrawInfo.setSplitInterval(splitInterval); } private void applySelectedSplit() { @@ -327,26 +327,27 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { } } }; - List groups = selectedGpxFile.getDisplayGroups(app); - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(selectedGpxFile.getGpxFile().path)); - boolean isJoinSegments = gpxDataItem != null && gpxDataItem.isJoinSegments(); - - new SplitTrackAsyncTask(app, selectedSplitType, groups, splitTrackListener, isJoinSegments, + List groups = getDisplayGroups(); + new SplitTrackAsyncTask(app, selectedSplitType, groups, splitTrackListener, trackDrawInfo.isJoinSegments(), timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @NonNull - private List getDisplayGroups() { + public List getDisplayGroups() { List groups = new ArrayList<>(); - for (GpxDisplayGroup group : selectedGpxFile.getDisplayGroups(app)) { - if (GpxSelectionHelper.GpxDisplayItemType.TRACK_SEGMENT == group.getType()) { - groups.add(group); + Fragment target = getTargetFragment(); + if (target instanceof TrackAppearanceFragment) { + List result = ((TrackAppearanceFragment) target).getGpxDisplayGroups(); + for (GpxDisplayGroup group : result) { + if (GpxDisplayItemType.TRACK_SEGMENT == group.getType()) { + groups.add(group); + } } } return groups; } - public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo) { + public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo, Fragment target) { try { if (fragmentManager.findFragmentByTag(SplitIntervalBottomSheet.TAG) == null) { Bundle args = new Bundle(); @@ -354,6 +355,7 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { SplitIntervalBottomSheet splitIntervalBottomSheet = new SplitIntervalBottomSheet(); splitIntervalBottomSheet.setArguments(args); + splitIntervalBottomSheet.setTargetFragment(target, 0); splitIntervalBottomSheet.show(fragmentManager, SplitIntervalBottomSheet.TAG); } } catch (RuntimeException e) { diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java index f4e023b3cb..c8cfaa7714 100644 --- a/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalCard.java @@ -4,6 +4,7 @@ import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; @@ -13,10 +14,12 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard; public class SplitIntervalCard extends BaseCard { private TrackDrawInfo trackDrawInfo; + private Fragment targetFragment; - public SplitIntervalCard(@NonNull MapActivity mapActivity, TrackDrawInfo trackDrawInfo) { + public SplitIntervalCard(@NonNull MapActivity mapActivity, TrackDrawInfo trackDrawInfo, Fragment targetFragment) { super(mapActivity); this.trackDrawInfo = trackDrawInfo; + this.targetFragment = targetFragment; } @Override @@ -36,7 +39,7 @@ public class SplitIntervalCard extends BaseCard { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo); + SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo, targetFragment); } }); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index e267a15dc1..0d634da7b9 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -14,6 +14,7 @@ import androidx.annotation.NonNull; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.GPXFile; import net.osmand.plus.GPXDatabase.GpxDataItem; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -24,9 +25,13 @@ import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.myplaces.DirectionArrowsCard; import net.osmand.plus.myplaces.SaveGpxAsyncTask; +import net.osmand.plus.myplaces.SplitTrackAsyncTask; import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.util.Algorithms; import java.io.File; +import java.util.ArrayList; +import java.util.List; import static net.osmand.plus.track.TrackDrawInfo.TRACK_FILE_PATH; @@ -34,11 +39,40 @@ public class TrackAppearanceFragment extends ContextMenuFragment { private OsmandApplication app; + private GpxDataItem gpxDataItem; private TrackDrawInfo trackDrawInfo; private SelectedGpxFile selectedGpxFile; private int menuTitleHeight; + @Override + public int getMainLayoutId() { + return R.layout.track_appearance; + } + + @Override + public int getHeaderViewHeight() { + return menuTitleHeight; + } + + @Override + public boolean isHeaderViewDetached() { + return false; + } + + @Override + public int getToolbarHeight() { + return 0; + } + + public float getMiddleStateKoef() { + return 0.5f; + } + + public TrackDrawInfo getTrackDrawInfo() { + return trackDrawInfo; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -48,12 +82,13 @@ public class TrackAppearanceFragment extends ContextMenuFragment { if (savedInstanceState != null) { trackDrawInfo = new TrackDrawInfo(); trackDrawInfo.readBundle(savedInstanceState); + gpxDataItem = app.getGpxDbHelper().getItem(new File(trackDrawInfo.getFilePath())); selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(trackDrawInfo.getFilePath()); } else if (arguments != null) { String gpxFilePath = arguments.getString(TRACK_FILE_PATH); selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); File file = new File(selectedGpxFile.getGpxFile().path); - GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(file); + gpxDataItem = app.getGpxDbHelper().getItem(file); trackDrawInfo = new TrackDrawInfo(gpxDataItem); } } @@ -78,6 +113,14 @@ public class TrackAppearanceFragment extends ContextMenuFragment { return view; } + @Override + protected void calculateLayout(View view, boolean initLayout) { + menuTitleHeight = view.findViewById(R.id.route_menu_top_shadow_all).getHeight() + + view.findViewById(R.id.control_buttons).getHeight() + - view.findViewById(R.id.buttons_shadow).getHeight(); + super.calculateLayout(view, initLayout); + } + @Override public void onResume() { super.onResume(); @@ -136,6 +179,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment { cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + discardChanges(); dismiss(); } }); @@ -167,13 +211,57 @@ public class TrackAppearanceFragment extends ContextMenuFragment { app.getSelectedGpxHelper().updateSelectedGpxFile(selectedGpxFile); - GpxDataItem item = new GpxDataItem(new File(gpxFile.path), gpxFile); - app.getGpxDbHelper().add(item); + gpxDataItem = new GpxDataItem(new File(gpxFile.path), gpxFile); + app.getGpxDbHelper().add(gpxDataItem); saveGpx(gpxFile); } - private void saveGpx(GPXFile gpxFile) { - new SaveGpxAsyncTask(gpxFile, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + private void discardChanges() { + if (gpxDataItem.getSplitType() != trackDrawInfo.getSplitType() || gpxDataItem.getSplitInterval() != trackDrawInfo.getSplitInterval()) { + int timeSplit = (int) gpxDataItem.getSplitInterval(); + double distanceSplit = gpxDataItem.getSplitInterval(); + + GpxSplitType splitType = null; + if (gpxDataItem.getSplitType() == GpxSplitType.DISTANCE.getType()) { + splitType = GpxSplitType.DISTANCE; + } else if (gpxDataItem.getSplitType() == GpxSplitType.TIME.getType()) { + splitType = GpxSplitType.TIME; + } + if (splitType != null) { + SplitTrackAsyncTask.SplitTrackListener splitTrackListener = new SplitTrackAsyncTask.SplitTrackListener() { + + @Override + public void trackSplittingStarted() { + + } + + @Override + public void trackSplittingFinished() { + if (selectedGpxFile != null) { + List groups = getGpxDisplayGroups(); + selectedGpxFile.setDisplayGroups(groups, app); + } + } + }; + List groups = getGpxDisplayGroups(); + new SplitTrackAsyncTask(app, splitType, groups, splitTrackListener, trackDrawInfo.isJoinSegments(), + timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + } + } + + private void saveGpx(final GPXFile gpxFile) { + new SaveGpxAsyncTask(gpxFile, new SaveGpxAsyncTask.SaveGpxListener() { + @Override + public void gpxSavingStarted() { + + } + + @Override + public void gpxSavingFinished() { + app.showShortToastMessage(R.string.shared_string_track_is_saved, Algorithms.getFileWithoutDirs(gpxFile.path)); + } + }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void updateCards() { @@ -182,7 +270,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment { ViewGroup cardsContainer = getCardsContainer(); cardsContainer.removeAllViews(); - BaseCard splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo); + BaseCard splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo, this); cardsContainer.addView(splitIntervalCard.build(mapActivity)); BaseCard arrowsCard = new DirectionArrowsCard(mapActivity, trackDrawInfo); @@ -196,36 +284,22 @@ public class TrackAppearanceFragment extends ContextMenuFragment { } } - @Override - public int getMainLayoutId() { - return R.layout.track_appearance; - } + private long modifiedTime = -1; + private List displayGroups; - @Override - public int getHeaderViewHeight() { - return menuTitleHeight; - } - - @Override - protected void calculateLayout(View view, boolean initLayout) { - menuTitleHeight = view.findViewById(R.id.route_menu_top_shadow_all).getHeight() - + view.findViewById(R.id.control_buttons).getHeight() - - view.findViewById(R.id.buttons_shadow).getHeight(); - super.calculateLayout(view, initLayout); - } - - @Override - public boolean isHeaderViewDetached() { - return false; - } - - @Override - public int getToolbarHeight() { - return 0; - } - - public float getMiddleStateKoef() { - return 0.5f; + public List getGpxDisplayGroups() { + GPXFile gpxFile = selectedGpxFile.getGpxFile(); + if (gpxFile == null) { + return new ArrayList<>(); + } + if (gpxFile.modifiedTime != modifiedTime) { + modifiedTime = gpxFile.modifiedTime; + displayGroups = app.getSelectedGpxHelper().collectDisplayGroups(gpxFile); + if (selectedGpxFile.getDisplayGroups(app) != null) { + displayGroups = selectedGpxFile.getDisplayGroups(app); + } + } + return displayGroups; } public static boolean showInstance(@NonNull MapActivity mapActivity, TrackAppearanceFragment fragment) { From 255f52f52cf04f7d67c8401c35f0fd6bdac5f077 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 16 Jul 2020 12:03:16 +0300 Subject: [PATCH 135/551] Change Measure distance -> Plan a route --- .../main/java/net/osmand/GPXUtilities.java | 22 +++++ .../layout-land/fragment_measurement_tool.xml | 25 +++--- .../res/layout/fragment_measurement_tool.xml | 86 ++++++++----------- .../plan_route_toolbar_and_up_down_row.xml | 27 +++--- OsmAnd/res/values-large/sizes.xml | 3 +- OsmAnd/res/values/sizes.xml | 10 ++- OsmAnd/res/values/strings.xml | 3 + .../plus/activities/MapActivityActions.java | 8 +- .../MeasurementEditingContext.java | 55 +++++++++++- .../MeasurementToolFragment.java | 60 +++++++++---- .../measurementtool/MeasurementToolLayer.java | 10 ++- .../OptionsBottomSheetDialogFragment.java | 66 ++++++-------- 12 files changed, 226 insertions(+), 149 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 6eb20d0f15..5b7feed761 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -46,6 +46,8 @@ public class GPXUtilities { private static final String ICON_NAME_EXTENSION = "icon"; private static final String DEFAULT_ICON_NAME = "special_star"; private static final String BACKGROUND_TYPE_EXTENSION = "background"; + private static final String PROFILE_TYPE_EXTENSION = "profile"; + private static final String TRKPT_INDEX_EXTENSION = "trkpt_idx"; private final static String GPX_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; //$NON-NLS-1$ private final static String GPX_TIME_FORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; //$NON-NLS-1$ @@ -302,6 +304,26 @@ public class GPXUtilities { getExtensionsToWrite().put(BACKGROUND_TYPE_EXTENSION, backType); } + public String getProfileType() { + return getExtensionsToRead().get(PROFILE_TYPE_EXTENSION); + } + + public void setProfileType(String profileType) { + getExtensionsToWrite().put(PROFILE_TYPE_EXTENSION, profileType); + } + + public int getTrkPtIndex() { + try { + return Integer.parseInt(getExtensionsToRead().get(TRKPT_INDEX_EXTENSION)); + }catch(NumberFormatException e){ + return -1; + } + } + + public void setTrkPtIndex(int index) { + getExtensionsToWrite().put(TRKPT_INDEX_EXTENSION, String.valueOf(index)); + } + @Override public int hashCode() { final int prime = 31; diff --git a/OsmAnd/res/layout-land/fragment_measurement_tool.xml b/OsmAnd/res/layout-land/fragment_measurement_tool.xml index de02d4e67c..4bcb08756a 100644 --- a/OsmAnd/res/layout-land/fragment_measurement_tool.xml +++ b/OsmAnd/res/layout-land/fragment_measurement_tool.xml @@ -163,30 +163,25 @@ android:paddingStart="@dimen/measurement_tool_text_button_padding" android:text="@string/shared_string_options" android:textColor="?attr/color_dialog_buttons" - osmand:textAllCapsCompat="true" osmand:typeface="@string/font_roboto_medium"/> @@ -242,6 +236,7 @@ android:paddingRight="@dimen/measurement_tool_button_padding" android:text="@string/shared_string_apply" android:textColor="@color/color_white" + android:textAllCaps="false" android:paddingEnd="@dimen/measurement_tool_button_padding" android:paddingStart="@dimen/measurement_tool_button_padding" /> @@ -304,6 +299,7 @@ android:paddingRight="@dimen/measurement_tool_button_padding" android:text="@string/shared_string_apply" android:textColor="?attr/color_dialog_buttons" + android:textAllCaps="false" android:paddingEnd="@dimen/measurement_tool_button_padding" android:paddingStart="@dimen/measurement_tool_button_padding" /> @@ -316,13 +312,12 @@ android:layout_marginRight="@dimen/measurement_tool_button_margin" android:layout_marginTop="@dimen/measurement_tool_button_margin" android:background="?attr/btn_round" - osmand:drawableLeftCompat="@drawable/ic_action_plus" - osmand:drawableStartCompat="@drawable/ic_action_plus" android:minHeight="@dimen/measurement_tool_button_height" android:paddingLeft="@dimen/measurement_tool_button_padding" android:paddingRight="@dimen/measurement_tool_button_padding" android:text="@string/shared_string_add" android:textColor="@color/color_white" + android:textAllCaps="false" android:paddingStart="@dimen/measurement_tool_button_padding" android:paddingEnd="@dimen/measurement_tool_button_padding" /> diff --git a/OsmAnd/res/layout/fragment_measurement_tool.xml b/OsmAnd/res/layout/fragment_measurement_tool.xml index d6f1470ba0..e126e58a29 100644 --- a/OsmAnd/res/layout/fragment_measurement_tool.xml +++ b/OsmAnd/res/layout/fragment_measurement_tool.xml @@ -39,10 +39,10 @@ android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_centerVertical="true" - android:layout_marginEnd="@dimen/bottom_sheet_content_margin" - android:layout_marginLeft="@dimen/bottom_sheet_content_margin" - android:layout_marginRight="@dimen/bottom_sheet_content_margin" - android:layout_marginStart="@dimen/bottom_sheet_content_margin" + android:layout_marginEnd="@dimen/measurement_tool_text_button_padding" + android:layout_marginLeft="@dimen/measurement_tool_text_button_padding" + android:layout_marginRight="@dimen/measurement_tool_text_button_padding" + android:layout_marginStart="@dimen/measurement_tool_text_button_padding" android:background="@null" tools:src="@drawable/ic_action_ruler"/> @@ -64,11 +64,11 @@ android:id="@+id/measurement_distance_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerVertical="true" + android:layout_marginTop="@dimen/measurement_tool_button_padding" android:layout_marginEnd="@dimen/text_margin_small" - android:layout_marginLeft="@dimen/measurement_tool_text_margin" + android:layout_marginLeft="@dimen/measurement_tool_text_button_padding" android:layout_marginRight="@dimen/text_margin_small" - android:layout_marginStart="@dimen/measurement_tool_text_margin" + android:layout_marginStart="@dimen/measurement_tool_text_button_padding" android:layout_toEndOf="@id/main_icon" android:layout_toRightOf="@id/main_icon" android:textAppearance="@style/TextAppearance.ListItemTitle" @@ -78,7 +78,7 @@ android:id="@+id/measurement_points_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerVertical="true" + android:layout_marginTop="@dimen/measurement_tool_button_padding" android:layout_toEndOf="@id/measurement_distance_text_view" android:layout_toRightOf="@id/measurement_distance_text_view" android:textColor="?android:textColorSecondary" @@ -87,17 +87,15 @@ + android:textColor="@color/color_distance" + android:textSize="@dimen/default_desc_text_size" + tools:text=" – 700 m" /> + android:layout_height="@dimen/measurement_tool_controls_height" + android:paddingTop="@dimen/measurement_tool_button_padding_top" + android:paddingBottom="@dimen/measurement_tool_button_padding_top" + android:paddingLeft="@dimen/measurement_tool_button_margin" + android:paddingRight="@dimen/measurement_tool_button_margin"> @@ -261,6 +250,7 @@ android:paddingRight="@dimen/measurement_tool_button_padding" android:text="@string/shared_string_apply" android:textColor="@color/color_white" + android:textAllCaps="false" android:paddingEnd="@dimen/measurement_tool_button_padding" android:paddingStart="@dimen/measurement_tool_button_padding" /> @@ -268,15 +258,12 @@ android:id="@+id/cancel_move_point_button" android:layout_width="wrap_content" android:layout_height="match_parent" + android:layout_margin="@dimen/measurement_tool_button_margin" android:background="?attr/selectableItemBackground" android:gravity="center_vertical" - android:paddingEnd="12dp" - android:paddingLeft="16dp" - android:paddingRight="12dp" - android:paddingStart="16dp" + android:padding="@dimen/measurement_tool_text_button_padding_small" android:text="@string/shared_string_cancel" android:textColor="?attr/color_dialog_buttons" - osmand:textAllCapsCompat="true" osmand:typeface="@string/font_roboto_medium"/> @@ -292,15 +279,12 @@ android:id="@+id/cancel_point_before_after_button" android:layout_width="wrap_content" android:layout_height="match_parent" + android:layout_margin="@dimen/measurement_tool_button_margin" android:background="?attr/selectableItemBackground" android:gravity="center_vertical" - android:paddingEnd="@dimen/measurement_tool_text_button_padding_small" - android:paddingLeft="@dimen/measurement_tool_text_button_padding" - android:paddingRight="@dimen/measurement_tool_text_button_padding_small" - android:paddingStart="@dimen/measurement_tool_text_button_padding" + android:padding="@dimen/measurement_tool_text_button_padding_small" android:text="@string/shared_string_cancel" android:textColor="?attr/color_dialog_buttons" - osmand:textAllCapsCompat="true" osmand:typeface="@string/font_roboto_medium"/> @@ -334,13 +319,12 @@ android:layout_marginRight="@dimen/measurement_tool_button_margin" android:layout_marginTop="@dimen/measurement_tool_button_margin" android:background="?attr/btn_round" - osmand:drawableLeftCompat="@drawable/ic_action_plus" - osmand:drawableStartCompat="@drawable/ic_action_plus" android:minHeight="@dimen/measurement_tool_button_height" android:paddingLeft="@dimen/measurement_tool_button_padding" android:paddingRight="@dimen/measurement_tool_button_padding" android:text="@string/shared_string_add" android:textColor="@color/color_white" + android:textAllCaps="false" android:paddingEnd="@dimen/measurement_tool_button_padding" android:paddingStart="@dimen/measurement_tool_button_padding" /> diff --git a/OsmAnd/res/layout/plan_route_toolbar_and_up_down_row.xml b/OsmAnd/res/layout/plan_route_toolbar_and_up_down_row.xml index 25e86566bc..773f46b403 100644 --- a/OsmAnd/res/layout/plan_route_toolbar_and_up_down_row.xml +++ b/OsmAnd/res/layout/plan_route_toolbar_and_up_down_row.xml @@ -1,7 +1,6 @@ + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> @@ -63,8 +62,8 @@ android:id="@+id/toolbar_divider" android:layout_width="wrap_content" android:layout_height="1dp" - android:layout_marginLeft="54dp" - android:layout_marginStart="54dp" + android:layout_marginLeft="@dimen/toolbar_inset_start" + android:layout_marginStart="@dimen/toolbar_inset_start" android:visibility="gone" tools:background="?attr/dashboard_divider" tools:visibility="visible"/> @@ -81,7 +80,7 @@ 12dp 330dp 48dp - 78dp + 84dp 18dp 24dp 18dp @@ -88,6 +88,7 @@ 24dp 12dp 12dp + 15dp 54dp diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index ebefb8942f..1c1a621495 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -251,15 +251,16 @@ 4dp 8dp 220dp - 48dp - 52dp - 12dp + 60dp + 56dp + 8dp 16dp - 12dp + 6dp 14dp 16dp 8dp 8dp + 10dp 36dp 52dp 44dp @@ -340,6 +341,7 @@ 56dp 96dp 72dp + 54dp 36dp 80dp diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5d733cf83f..1dba39ca31 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,9 @@ Thx - Hardy --> + Add to a Track + Plan a route + Route between points Closed OSM Note Go-cart Wheelchair forward diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 25c1b95601..273d69d831 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -1,6 +1,5 @@ package net.osmand.plus.activities; -import android.Manifest; import android.app.Activity; import android.app.Dialog; import android.content.DialogInterface; @@ -21,7 +20,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; -import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; @@ -425,7 +423,7 @@ public class MapActivityActions implements DialogProvider { } adapter.addItem(itemBuilder - .setTitleId(R.string.measurement_tool, mapActivity) + .setTitleId(R.string.plan_a_route, mapActivity) .setId(MAP_CONTEXT_MENU_MEASURE_DISTANCE) .setIcon(R.drawable.ic_action_ruler) .setOrder(MEASURE_DISTANCE_ITEM_ORDER) @@ -473,7 +471,7 @@ public class MapActivityActions implements DialogProvider { // new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, // REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION); //} - } else if (standardId == R.string.measurement_tool) { + } else if (standardId == R.string.plan_a_route) { mapActivity.getContextMenu().close(); MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), new LatLon(latitude, longitude)); } else if (standardId == R.string.avoid_road) { @@ -932,7 +930,7 @@ public class MapActivityActions implements DialogProvider { } }).createItem()); - optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity) + optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.plan_a_route, mapActivity) .setId(DRAWER_MEASURE_DISTANCE_ID) .setIcon(R.drawable.ic_action_ruler) .setListener(new ItemClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java index 388cd91d72..27305c989f 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java @@ -17,6 +17,7 @@ import net.osmand.plus.routing.RouteCalculationParams; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RoutingHelper; import net.osmand.router.RouteCalculationProgress; +import net.osmand.util.MapUtils; import java.util.ArrayList; import java.util.Arrays; @@ -45,6 +46,7 @@ public class MeasurementEditingContext { private boolean inSnapToRoadMode; private boolean needUpdateCacheForSnap; private int calculatedPairs; + private int trkptIndex; private SnapToRoadProgressListener progressListener; private ApplicationMode snapToRoadAppMode; private RouteCalculationProgress calculationProgress; @@ -112,7 +114,7 @@ public class MeasurementEditingContext { this.progressListener = progressListener; } - ApplicationMode getSnapToRoadAppMode() { + public ApplicationMode getSnapToRoadAppMode() { return snapToRoadAppMode; } @@ -260,6 +262,54 @@ public class MeasurementEditingContext { } } + void addPoints() { + List points = getNewGpxData().getTrkSegment().points; + if (isSnapToRoadTrack()) { + List routePoints = getNewGpxData().getGpxFile().getRoutePoints(); + int prevPointIndex = 0; + for (int i = 0; i < routePoints.size() - 1; i++) { + Pair pair = new Pair<>(routePoints.get(i), routePoints.get(i + 1)); + int startIndex = pair.first.getTrkPtIndex(); + if (startIndex < 0 || startIndex < prevPointIndex || startIndex >= points.size()) { + startIndex = findPointIndex(pair.first, points, prevPointIndex); + } + int endIndex = pair.second.getTrkPtIndex() + 1; + if (endIndex < 0 || endIndex < startIndex || endIndex >= points.size()) { + endIndex = findPointIndex(pair.second, points, startIndex); + } + if (startIndex >= 0 && endIndex >= 0) { + List cacheSegment = new ArrayList<>(); + for (int j = startIndex; j < endIndex && j < points.size(); j++) { + cacheSegment.add(points.get(j)); + prevPointIndex = j; + } + snappedToRoadPoints.put(pair, cacheSegment); + } + } + addPoints(routePoints); + } else { + addPoints(points); + } + } + + private int findPointIndex(WptPt point, List points, int firstIndex) { + double minDistance = Double.MAX_VALUE; + int index = 0; + for (int i = Math.max(0, firstIndex); i < points.size(); i++) { + double distance = MapUtils.getDistance(point.lat, point.lon, points.get(i).lat, points.get(i).lon); + if (distance < minDistance) { + minDistance = distance; + index = i; + } + } + return index; + } + + boolean isSnapToRoadTrack() { + return !getNewGpxData().getTrkSegment().points.isEmpty() + && !getNewGpxData().getGpxFile().getRoutePoints().isEmpty(); + } + private void updateCacheForSnapIfNeeded(boolean both) { if (needUpdateCacheForSnap) { recreateCacheForSnap(beforeCacheForSnap = new TrkSegment(), before); @@ -342,6 +392,9 @@ public class MeasurementEditingContext { } calculatedPairs++; snappedToRoadPoints.put(currentPair, pts); + trkptIndex = currentPair.first.getTrkPtIndex(); + trkptIndex += pts.size() - 1; + currentPair.second.setTrkPtIndex(trkptIndex); updateCacheForSnapIfNeeded(true); application.runInUIThread(new Runnable() { @Override diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 9cdbbe1037..6a04eb7dd3 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -74,6 +74,7 @@ import net.osmand.plus.measurementtool.command.ReorderPointCommand; import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; +import net.osmand.util.Algorithms; import java.io.File; import java.text.MessageFormat; @@ -220,7 +221,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { mainIcon = (ImageView) mainView.findViewById(R.id.main_icon); final NewGpxData newGpxData = editingCtx.getNewGpxData(); - if (editingCtx.getNewGpxData() != null) { + if (newGpxData != null) { + List points = newGpxData.getGpxFile().getRoutePoints(); + if (!points.isEmpty()) { + ApplicationMode snapToRoadAppMode = ApplicationMode + .valueOfStringKey(points.get(points.size() - 1).getProfileType(), null); + if (snapToRoadAppMode != null) { + enableSnapToRoadMode(snapToRoadAppMode); + } + } ActionType actionType = newGpxData.getActionType(); if (actionType == ActionType.ADD_SEGMENT || actionType == ActionType.EDIT_SEGMENT) { mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark)); @@ -467,9 +476,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { enterMeasurementMode(); - if (editingCtx.isInSnapToRoadMode()) { - showSnapToRoadControls(); - } + showSnapToRoadControls(); if (newGpxData != null && !gpxPointsAdded) { ActionType actionType = newGpxData.getActionType(); @@ -560,7 +567,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { if (rememberPreviousTitle) { previousToolBarTitle = toolBarController.getTitle(); } - toolBarController.setTitle(getString(R.string.snap_to_road)); + toolBarController.setTitle(getString(R.string.route_between_points)); mapActivity.refreshMap(); SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment(); fragment.setListener(createSnapToRoadFragmentListener()); @@ -587,6 +594,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { public void addToGpxOnClick() { if (mapActivity != null && measurementLayer != null) { if (editingCtx.getPointsCount() > 0) { + if (editingCtx.isInSnapToRoadMode()) { + editingCtx.getPoints().clear(); + editingCtx.getPoints().addAll(editingCtx.getBeforePoints()); + editingCtx.getBeforePoints().clear(); + editingCtx.getBeforePoints().addAll(editingCtx.getBeforeTrkSegmentLine().points); + } addToGpx(mapActivity); } else { Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show(); @@ -803,14 +816,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { private void showSnapToRoadControls() { final MapActivity mapActivity = getMapActivity(); final ApplicationMode appMode = editingCtx.getSnapToRoadAppMode(); - if (mapActivity != null && appMode != null) { - toolBarController.setTopBarSwitchVisible(true); - toolBarController.setTopBarSwitchChecked(true); - mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_snap_to_road)); - + if (mapActivity != null) { + Drawable icon; + if (appMode == null) { + icon = getActiveIcon(R.drawable.ic_action_split_interval); + } else { + icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode)); + } ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button); snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle); - snapToRoadBtn.setImageDrawable(getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode))); + snapToRoadBtn.setImageDrawable(icon); snapToRoadBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -829,11 +844,18 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler)); editingCtx.setInSnapToRoadMode(false); editingCtx.cancelSnapToRoad(); + hideSnapToRoadIcon(); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE); + mapActivity.refreshMap(); + } + } + + private void hideSnapToRoadIcon() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE); - mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE); - mapActivity.refreshMap(); } } @@ -851,11 +873,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { private void displaySegmentPoints() { final MeasurementToolLayer measurementLayer = getMeasurementLayer(); - - TrkSegment segment = editingCtx.getNewGpxData().getTrkSegment(); - List points = segment.points; if (measurementLayer != null) { - editingCtx.addPoints(points); + editingCtx.addPoints(); adapter.notifyDataSetChanged(); updateText(); } @@ -898,6 +917,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { MeasurementToolLayer measurementLayer = getMeasurementLayer(); if (measurementLayer != null) { WptPt newPoint = measurementLayer.getMovedPointToApply(); + String profileType = editingCtx.getSnapToRoadAppMode().getStringKey(); + if (!Algorithms.isEmpty(profileType)) { + newPoint.setProfileType(profileType); + } WptPt oldPoint = editingCtx.getOriginalPointToMove(); int position = editingCtx.getSelectedPointPosition(); editingCtx.getCommandManager().execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position)); @@ -1309,6 +1332,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { editingCtx.exportRouteAsGpx(trackName, new MeasurementEditingContext.ExportAsGpxListener() { @Override public void onExportAsGpxFinished(GPXFile gpx) { + gpx.addRoutePoints(editingCtx.getPoints()); final Exception res = GPXUtilities.writeGpxFile(toSave, gpx); gpx.path = toSave.getAbsolutePath(); OsmandApplication app = getMyApplication(); @@ -1594,6 +1618,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { } if (editingCtx.isInSnapToRoadMode()) { disableSnapToRoadMode(); + } else { + hideSnapToRoadIcon(); } if (editingCtx.getNewGpxData() != null) { GPXFile gpx = editingCtx.getNewGpxData().getGpxFile(); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index bd69a1f094..c937d404ff 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -10,7 +10,6 @@ import android.graphics.PointF; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; -import net.osmand.data.QuadPoint; import net.osmand.data.RotatedTileBox; import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; @@ -20,6 +19,7 @@ import net.osmand.plus.views.ContextMenuLayer; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.Renderable; +import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.util.ArrayList; @@ -322,6 +322,10 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL pt.lon = l.getLongitude(); boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt); if (allowed) { + String profileType = editingCtx.getSnapToRoadAppMode().getStringKey(); + if (!Algorithms.isEmpty(profileType)) { + pt.setProfileType(profileType); + } editingCtx.addPoint(pt); return pt; } @@ -338,6 +342,10 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL pressedPointLatLon = null; boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt); if (allowed) { + String profileType = editingCtx.getSnapToRoadAppMode().getStringKey(); + if (!Algorithms.isEmpty(profileType)) { + pt.setProfileType(profileType); + } editingCtx.addPoint(pt); moveMapToLatLon(lat, lon); return pt; diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java index 9d69604c40..8ac32fa803 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java @@ -6,7 +6,7 @@ import android.view.View; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; -import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; @@ -32,14 +32,11 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm items.add(new TitleItem(getString(R.string.shared_string_options))); - BaseBottomSheetItem snapToRoadItem = new BottomSheetItemWithCompoundButton.Builder() - .setChecked(snapToRoadEnabled) - .setDescription(getString(snapToRoadEnabled ? R.string.shared_string_on : R.string.shared_string_off)) - .setIcon(snapToRoadEnabled - ? getActiveIcon(R.drawable.ic_action_snap_to_road) - : getContentIcon(R.drawable.ic_action_snap_to_road)) - .setTitle(getString(R.string.snap_to_road)) - .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp) + BaseBottomSheetItem snapToRoadItem = new BottomSheetItemWithDescription.Builder() + .setDescription(getString(R.string.routing_profile_straightline)) + .setIcon(getContentIcon(R.drawable.ic_action_split_interval)) + .setTitle(getString(R.string.route_between_points)) + .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -72,21 +69,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm items.add(saveAsNewSegmentItem); } else if (addLineMode) { - BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder() - .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)) - .setTitle(getString(R.string.shared_string_save_as_gpx)) - .setLayoutId(R.layout.bottom_sheet_item_simple) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (listener != null) { - listener.saveAsNewTrackOnClick(); - } - dismiss(); - } - }) - .create(); - items.add(saveAsNewTrackItem); + items.add(getSaveAsNewTrackItem()); BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)) @@ -104,25 +87,11 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm .create(); items.add(saveAsNewSegmentItem); } else { - BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder() - .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)) - .setTitle(getString(R.string.shared_string_save_as_gpx)) - .setLayoutId(R.layout.bottom_sheet_item_simple) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (listener != null) { - listener.saveAsNewTrackOnClick(); - } - dismiss(); - } - }) - .create(); - items.add(saveAsNewTrackItem); + items.add(getSaveAsNewTrackItem()); BaseBottomSheetItem addToTrackItem = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_split_interval)) - .setTitle(getString(R.string.add_segment_to_the_track)) + .setTitle(getString(R.string.add_to_a_track)) .setLayoutId(R.layout.bottom_sheet_item_simple) .setOnClickListener(new View.OnClickListener() { @Override @@ -156,6 +125,23 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm items.add(clearAllItem); } + private BaseBottomSheetItem getSaveAsNewTrackItem() { + return new SimpleBottomSheetItem.Builder() + .setIcon(getContentIcon(R.drawable.ic_action_save_to_file)) + .setTitle(getString(R.string.edit_filter_save_as_menu_item)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (listener != null) { + listener.saveAsNewTrackOnClick(); + } + dismiss(); + } + }) + .create(); + } + @Override protected int getDismissButtonTextId() { return R.string.shared_string_close; From d8f7adc0232693ee4ca43f45fd2a3b3851f21af3 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 16 Jul 2020 13:33:55 +0300 Subject: [PATCH 136/551] Show track appearance fragment from track activity --- OsmAnd/res/layout/gpx_item_list_header.xml | 30 +++++++++++++++++++ .../osmand/plus/activities/MapActivity.java | 25 ++++++++++++++++ .../TrackActivityFragmentAdapter.java | 23 ++++++++++++++ .../plus/track/TrackAppearanceFragment.java | 24 +++++++++++++-- .../src/net/osmand/plus/views/GPXLayer.java | 4 +++ .../osmand/plus/views/MapControlsLayer.java | 28 ++++++++++------- 6 files changed, 120 insertions(+), 14 deletions(-) diff --git a/OsmAnd/res/layout/gpx_item_list_header.xml b/OsmAnd/res/layout/gpx_item_list_header.xml index 4cef607fb6..251eda21b6 100644 --- a/OsmAnd/res/layout/gpx_item_list_header.xml +++ b/OsmAnd/res/layout/gpx_item_list_header.xml @@ -160,6 +160,36 @@ + + + + + + + + displayGroups; private int menuTitleHeight; + private long modifiedTime = -1; @Override public int getMainLayoutId() { @@ -284,9 +294,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment { } } - private long modifiedTime = -1; - private List displayGroups; - public List getGpxDisplayGroups() { GPXFile gpxFile = selectedGpxFile.getGpxFile(); if (gpxFile == null) { @@ -302,6 +309,17 @@ public class TrackAppearanceFragment extends ContextMenuFragment { return displayGroups; } + public void dismissImmediate() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + try { + mapActivity.getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); + } catch (Exception e) { + log.error(e); + } + } + } + public static boolean showInstance(@NonNull MapActivity mapActivity, TrackAppearanceFragment fragment) { try { mapActivity.getSupportFragmentManager() diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 43d7e18d04..8b05c2099f 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -138,6 +138,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM this.trackChartPoints = trackChartPoints; } + public boolean isInTrackAppearanceMode() { + return trackDrawInfo != null; + } + public void setTrackDrawInfo(TrackDrawInfo trackDrawInfo) { this.trackDrawInfo = trackDrawInfo; } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 976bf8fd4b..52dd5cc884 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -37,15 +37,10 @@ import net.osmand.core.android.MapRendererContext; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationSimulation; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; @@ -63,6 +58,11 @@ import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.OsmAndAppCustomization; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; +import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; import net.osmand.plus.views.corenative.NativeCoreContext; import java.util.ArrayList; @@ -791,7 +791,9 @@ public class MapControlsLayer extends OsmandMapLayer { boolean routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu()); updateMyLocation(rh, routeDialogOpened || contextMenuOpened); boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) - && !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode(); + && !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() + && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode() + && !isInWaypointsChoosingMode() && !isInTrackAppearanceMode(); //routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_info_dark : R.drawable.ic_action_gdirections_dark); int routePlanningBtnImage = mapRouteInfoMenu.getRoutePlanningBtnImage(); if (routePlanningBtnImage != 0) { @@ -811,10 +813,10 @@ public class MapControlsLayer extends OsmandMapLayer { menuControl.updateVisibility(showButtons); - mapZoomIn.updateVisibility(!routeDialogOpened && !contextMenuOpened && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait)); - mapZoomOut.updateVisibility(!routeDialogOpened && !contextMenuOpened && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait)); + mapZoomIn.updateVisibility(!routeDialogOpened && !contextMenuOpened && !isInTrackAppearanceMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait)); + mapZoomOut.updateVisibility(!routeDialogOpened && !contextMenuOpened && !isInTrackAppearanceMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait)); boolean forceHideCompass = routeDialogOpened || trackDialogOpened - || isInMeasurementToolMode() || isInPlanRouteMode() || contextMenuOpened || isInChoosingRoutesMode() || isInWaypointsChoosingMode(); + || isInMeasurementToolMode() || isInPlanRouteMode() || contextMenuOpened || isInChoosingRoutesMode() || isInTrackAppearanceMode() || isInWaypointsChoosingMode(); compassHud.forceHideCompass = forceHideCompass; compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); @@ -824,9 +826,9 @@ public class MapControlsLayer extends OsmandMapLayer { layersHud.update(app, isNight); } layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode() - && !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode()); + && !contextMenuOpened && !isInChoosingRoutesMode() && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode()); quickSearchHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode() - && !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode()); + && !contextMenuOpened && !isInChoosingRoutesMode() && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode()); if (mapView.isZooming()) { lastZoom = System.currentTimeMillis(); @@ -1212,6 +1214,10 @@ public class MapControlsLayer extends OsmandMapLayer { return mapActivity.getMapLayers().getMapMarkersLayer().isInPlanRouteMode(); } + private boolean isInTrackAppearanceMode() { + return mapActivity.getMapLayers().getGpxLayer().isInTrackAppearanceMode(); + } + private boolean isInChoosingRoutesMode() { return MapRouteInfoMenu.chooseRoutesVisible; } From b2563269ac4f3e3aee2249cf3b6e0a31684746ad Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 16 Jul 2020 13:42:08 +0300 Subject: [PATCH 137/551] Change Measure distance -> Plan a route --- .../MeasurementToolFragment.java | 2 +- .../measurementtool/MeasurementToolLayer.java | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 6a04eb7dd3..c5c802ac1e 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -378,7 +378,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { public void onMeasure(float distance, float bearing) { String distStr = OsmAndFormatter.getFormattedDistance(distance, mapActivity.getMyApplication()); String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, getMyApplication()); - distanceToCenterTv.setText(String.format(" – %1$s • %2$s", distStr, azimuthStr)); + distanceToCenterTv.setText(String.format("%1$s • %2$s", distStr, azimuthStr)); TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration( distanceToCenterTv, 12, 18, 2, TypedValue.COMPLEX_UNIT_SP ); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index c937d404ff..2d0ebed3c3 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -15,6 +15,7 @@ import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.views.ContextMenuLayer; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; @@ -322,9 +323,13 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL pt.lon = l.getLongitude(); boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt); if (allowed) { - String profileType = editingCtx.getSnapToRoadAppMode().getStringKey(); - if (!Algorithms.isEmpty(profileType)) { - pt.setProfileType(profileType); + + ApplicationMode applicationMode = editingCtx.getSnapToRoadAppMode(); + if(applicationMode!=null) { + String profileType = applicationMode.getStringKey(); + if (!Algorithms.isEmpty(profileType)) { + pt.setProfileType(profileType); + } } editingCtx.addPoint(pt); return pt; @@ -342,9 +347,12 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL pressedPointLatLon = null; boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt); if (allowed) { - String profileType = editingCtx.getSnapToRoadAppMode().getStringKey(); - if (!Algorithms.isEmpty(profileType)) { - pt.setProfileType(profileType); + ApplicationMode applicationMode = editingCtx.getSnapToRoadAppMode(); + if(applicationMode!=null) { + String profileType = applicationMode.getStringKey(); + if (!Algorithms.isEmpty(profileType)) { + pt.setProfileType(profileType); + } } editingCtx.addPoint(pt); moveMapToLatLon(lat, lon); From 0df0d3894b9c126b8357a498897a227c5716a4e3 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 16 Jul 2020 14:58:06 +0300 Subject: [PATCH 138/551] UI fixes first part --- OsmAnd/res/drawable/bg_dash_line_dark.xml | 6 ++ OsmAnd/res/drawable/bg_dash_line_light.xml | 6 ++ OsmAnd/res/layout/track_appearance.xml | 2 +- OsmAnd/res/values/attrs.xml | 1 + OsmAnd/res/values/styles.xml | 2 + .../plus/track/TrackAppearanceFragment.java | 89 +++++++++++++++++-- .../net/osmand/plus/track/TrackDrawInfo.java | 55 ++++-------- .../net/osmand/plus/track/TrackWidthCard.java | 11 ++- 8 files changed, 128 insertions(+), 44 deletions(-) create mode 100644 OsmAnd/res/drawable/bg_dash_line_dark.xml create mode 100644 OsmAnd/res/drawable/bg_dash_line_light.xml diff --git a/OsmAnd/res/drawable/bg_dash_line_dark.xml b/OsmAnd/res/drawable/bg_dash_line_dark.xml new file mode 100644 index 0000000000..ac1547e5af --- /dev/null +++ b/OsmAnd/res/drawable/bg_dash_line_dark.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/OsmAnd/res/drawable/bg_dash_line_light.xml b/OsmAnd/res/drawable/bg_dash_line_light.xml new file mode 100644 index 0000000000..508cf2e78f --- /dev/null +++ b/OsmAnd/res/drawable/bg_dash_line_light.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/OsmAnd/res/layout/track_appearance.xml b/OsmAnd/res/layout/track_appearance.xml index 967501118d..1577d29817 100644 --- a/OsmAnd/res/layout/track_appearance.xml +++ b/OsmAnd/res/layout/track_appearance.xml @@ -30,7 +30,7 @@ android:layout_gravity="center" android:layout_marginTop="@dimen/context_menu_padding_margin_tiny" android:layout_marginBottom="@dimen/list_item_button_padding" - android:background="?attr/secondary_icon_color" /> + android:background="?attr/bg_dash_line" /> + diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index 5b4dfd70b0..6ae9c18952 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -296,6 +296,7 @@ @dimen/action_bar_height @style/ToolbarStyle @style/ToolbarStyle + @drawable/bg_dash_line_light