From 42187119719fad59beffad83a41e29a8e349247c Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Feb 2021 20:04:37 +0200 Subject: [PATCH 1/6] fix popup with saved track name in trip recording dialog --- OsmAnd/res/values/strings.xml | 1 + .../StopTrackRecordingBottomFragment.java | 4 +-- .../TripRecordingActiveBottomSheet.java | 26 +++++++++++++------ .../plus/track/TrackAppearanceFragment.java | 3 ++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 0447ac33aa..ed1259ed1f 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,7 @@ --> + The recording will be continued. Distance by tap A toggle to show or hide the Coordinates widget on the map. Show Coordinates widget diff --git a/OsmAnd/src/net/osmand/plus/monitoring/StopTrackRecordingBottomFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/StopTrackRecordingBottomFragment.java index d996a8a1cd..f648c5bbdf 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/StopTrackRecordingBottomFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/StopTrackRecordingBottomFragment.java @@ -90,11 +90,11 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm @Override public void onClick(View v) { tag = (ItemType) buttonSave.getTag(); - if (plugin != null && settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) { + if (plugin != null && app.getSavingTrackHelper().hasDataToSave()) { plugin.saveCurrentTrack(null, mapActivity); app.getNotificationHelper().refreshNotifications(); + dismiss(); } - dismiss(); } }) .create()); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java index af636b3424..e2e0522e42 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java @@ -1,6 +1,5 @@ package net.osmand.plus.monitoring; -import android.annotation.SuppressLint; import android.app.Activity; import android.app.Dialog; import android.content.Context; @@ -38,6 +37,7 @@ import com.google.android.material.snackbar.Snackbar; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; @@ -61,6 +61,7 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; import java.lang.ref.WeakReference; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -71,6 +72,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen public static final String TAG = TripRecordingActiveBottomSheet.class.getSimpleName(); private static final Log log = PlatformUtil.getLog(TripRecordingActiveBottomSheet.class); private static final String UPDATE_CURRENT_GPX_FILE = "update_current_gpx_file"; + public static final String UPDATE_TRACK_ICON = "update_track_icon"; private static final int GENERAL_UPDATE_GPS_INTERVAL = 1000; private static final int GENERAL_UPDATE_SAVE_INTERVAL = 1000; @@ -131,7 +133,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen View buttonClear = itemView.findViewById(R.id.button_clear); final View buttonOnline = itemView.findViewById(R.id.button_online); - View buttonSegment = itemView.findViewById(R.id.button_segment); + final View buttonSegment = itemView.findViewById(R.id.button_segment); buttonSave = itemView.findViewById(R.id.button_save); final View buttonPause = itemView.findViewById(R.id.button_pause); View buttonStop = itemView.findViewById(R.id.button_stop); @@ -274,6 +276,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored); updateStatus(); createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true); + createItem(buttonSegment, ItemType.START_SEGMENT, wasTrackMonitored); } }); @@ -443,16 +446,21 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen @Override public void gpxSavingFinished(Exception errorMessage) { - String gpxFileName = Algorithms.getFileWithoutDirs(getGPXFile().path); final MapActivity mapActivity = getMapActivity(); final Context context = getContext(); final SaveGpxResult result = helper.saveDataToGpx(app.getAppCustomization().getTracksDir()); + ArrayList filenames = new ArrayList<>(result.getFilenames()); + String fileName = ""; + if (filenames.size() > 0) { + fileName = filenames.get(filenames.size() - 1) + IndexConstants.GPX_FILE_EXT; + } + String message = fileName + " " + app.getResources().getString(R.string.shared_string_is_saved) + ". " + + app.getResources().getString(R.string.track_recording_will_be_continued); if (mapActivity != null && context != null) { final WeakReference mapActivityRef = new WeakReference<>(mapActivity); final FragmentManager fragmentManager = mapActivityRef.get().getSupportFragmentManager(); - @SuppressLint({"StringFormatInvalid", "LocalSuppress"}) Snackbar snackbar = Snackbar.make(getView(), - app.getResources().getString(R.string.shared_string_file_is_saved, gpxFileName), + message, Snackbar.LENGTH_LONG) .setAction(R.string.shared_string_rename, new View.OnClickListener() { @Override @@ -492,10 +500,12 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } } - public void show(boolean updateTrackIcon) { + public void show(String... keys) { show(); - if (updateTrackIcon && buttonAppearance != null) { - updateTrackIcon(buttonAppearance); + for (String key : keys) { + if (key.equals(UPDATE_TRACK_ICON)) { + updateTrackIcon(buttonAppearance); + } } } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index eda708dbc9..f586700ef2 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -64,6 +64,7 @@ import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems; +import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.UPDATE_TRACK_ICON; public class TrackAppearanceFragment extends ContextMenuScrollFragment implements CardListener, ColorPickerListener { @@ -385,7 +386,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement if (target instanceof TripRecordingBottomSheet) { ((TripRecordingBottomSheet) target).show(); } else if (target instanceof TripRecordingActiveBottomSheet) { - ((TripRecordingActiveBottomSheet) target).show(true); + ((TripRecordingActiveBottomSheet) target).show(UPDATE_TRACK_ICON); } } From bb6099d41a4ef32654fe6a5d16a623386b47930e Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 26 Feb 2021 01:38:45 +0200 Subject: [PATCH 2/6] fix legend text for night mode; fix duration time for route statistic --- .../measurementtool/graph/CustomGraphAdapter.java | 1 + .../cards/RouteStatisticCard.java | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java b/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java index 32a1f6a654..fe7eff5261 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java @@ -158,6 +158,7 @@ public class CustomGraphAdapter extends BaseGraphAdapter 0) { - timeStr.append(String.valueOf(hours)).append(" ").append(app.getString(R.string.osmand_parking_hour)).append(" "); - } - if (minutes > 0) { - timeStr.append(String.valueOf(minutes)).append(" ").append(app.getString(R.string.osmand_parking_minute)); - } + timeStr.append(OsmAndFormatter.getFormattedDuration(time, app)); spaceIndex = timeStr.toString().lastIndexOf(" "); if (spaceIndex != -1) { timeStr.setSpan(new ForegroundColorSpan(getMainFontColor()), 0, spaceIndex, 0); From b8f3452a1cc038af7cb581cebcc90370d1fe01a0 Mon Sep 17 00:00:00 2001 From: cepprice Date: Fri, 26 Feb 2021 23:49:10 +0500 Subject: [PATCH 3/6] Bind water polygons with land ones for underlay maps --- .../osmand/plus/dialogs/RasterMapMenu.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index 1e91810253..4f18cb88c9 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -66,21 +66,29 @@ public class RasterMapMenu { final CommonPreference hidePolygonsPref = mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons"); + final CommonPreference hideWaterPolygonsPref = + mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("hideWaterPolygons"); + String mapTypeDescr = mapTypePreference.get(); if (mapTypeDescr!=null && mapTypeDescr.contains(".sqlitedb")) { mapTypeDescr = mapTypeDescr.replaceFirst(".sqlitedb", ""); } - final boolean selected = mapTypeDescr != null; - final int toggleActionStringId = selected ? R.string.shared_string_on + final boolean mapSelected = mapTypeDescr != null; + final int toggleActionStringId = mapSelected ? R.string.shared_string_on : R.string.shared_string_off; + if (mapSelected && type == RasterMapType.UNDERLAY) { + hideWaterPolygonsPref.set(hidePolygonsPref.get()); + } + final OnMapSelectedCallback onMapSelectedCallback = new OnMapSelectedCallback() { @Override public void onMapSelected(boolean canceled) { mapActivity.getDashboard().refreshContent(true); + hideWaterPolygonsPref.set(hidePolygonsPref.get()); } }; final MapActivityLayers mapLayers = mapActivity.getMapLayers(); @@ -89,7 +97,7 @@ public class RasterMapMenu { public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int pos) { if (itemId == mapTypeString) { - if (selected) { + if (mapSelected) { plugin.selectMapOverlayLayer(mapActivity.getMapView(), mapTypePreference, exMapTypePreference, true, mapActivity, onMapSelectedCallback); } @@ -111,6 +119,7 @@ public class RasterMapMenu { }); } else if (itemId == R.string.show_polygons) { hidePolygonsPref.set(!isChecked); + hideWaterPolygonsPref.set(!isChecked); mapActivity.refreshMapComplete(); } else if (itemId == R.string.show_transparency_seekbar) { if (isChecked) { @@ -126,13 +135,13 @@ public class RasterMapMenu { } }; - mapTypeDescr = selected ? mapTypeDescr : mapActivity.getString(R.string.shared_string_none); + mapTypeDescr = mapSelected ? mapTypeDescr : mapActivity.getString(R.string.shared_string_none); contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(toggleActionStringId, mapActivity) .hideDivider(true) .setListener(l) - .setSelected(selected).createItem()); - if (selected) { + .setSelected(mapSelected).createItem()); + if (mapSelected) { contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(mapTypeString, mapActivity) .hideDivider(true) From 38d6183a43d49eb0311f35c6355c3a75fbaca29c Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 28 Feb 2021 21:56:07 +0500 Subject: [PATCH 4/6] Don't overwrite units of measurement in automatic region --- .../src/net/osmand/plus/settings/backend/OsmandSettings.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 9652fc3bad..6725bf4db3 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -848,7 +848,8 @@ public class OsmandSettings { public final OsmandPreference DRIVING_REGION = new EnumStringPreference(this, "default_driving_region", DrivingRegion.EUROPE_ASIA, DrivingRegion.values()) { public boolean setValue(Object prefs, DrivingRegion val) { - if (val != null) { + boolean overrideMetricSystem = !DRIVING_REGION_AUTOMATIC.getValue(prefs, DRIVING_REGION_AUTOMATIC.getDefaultValue()); + if (overrideMetricSystem && val != null) { METRIC_SYSTEM.set(val.defMetrics); } return super.setValue(prefs, val); From d114b23e3095efc47f6fdcb78869d1ba6a70c1d0 Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 28 Feb 2021 22:41:35 +0500 Subject: [PATCH 5/6] Fix logic --- OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java | 9 ++++----- .../osmand/plus/rastermaps/OsmandRasterMapsPlugin.java | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index 4f18cb88c9..169865ab3d 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -79,16 +79,15 @@ public class RasterMapMenu { final int toggleActionStringId = mapSelected ? R.string.shared_string_on : R.string.shared_string_off; - if (mapSelected && type == RasterMapType.UNDERLAY) { - hideWaterPolygonsPref.set(hidePolygonsPref.get()); - } - final OnMapSelectedCallback onMapSelectedCallback = new OnMapSelectedCallback() { @Override public void onMapSelected(boolean canceled) { mapActivity.getDashboard().refreshContent(true); - hideWaterPolygonsPref.set(hidePolygonsPref.get()); + boolean refreshToHidePolygons = type == RasterMapType.UNDERLAY; + if (refreshToHidePolygons) { + mapActivity.refreshMapComplete(); + } } }; final MapActivityLayers mapLayers = mapActivity.getMapLayers(); diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index ce4cf2664c..59ba2dadf7 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -106,10 +106,12 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { @Override public boolean init(@NonNull final OsmandApplication app, Activity activity) { final CommonPreference hidePolygonsPref = settings.getCustomRenderBooleanProperty("noPolygons"); + final CommonPreference hideWaterPolygonsPref = settings.getCustomRenderBooleanProperty("hideWaterPolygons"); underlayListener = new StateChangedListener() { @Override public void stateChanged(String change) { hidePolygonsPref.set(settings.MAP_UNDERLAY.get() != null); + hideWaterPolygonsPref.set(settings.MAP_UNDERLAY.get() != null); } }; settings.MAP_UNDERLAY.addListener(underlayListener); From 4d4783b2ead6eda266bd5feca2223ec7805cda6f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 28 Feb 2021 19:48:33 +0200 Subject: [PATCH 6/6] Small fix for inflater --- .../plus/measurementtool/graph/CustomGraphAdapter.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java b/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java index fe7eff5261..75ba2a5204 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java @@ -22,10 +22,10 @@ import net.osmand.AndroidUtils; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.helpers.CustomBarChartRenderer; -import net.osmand.router.RouteStatisticsHelper; -import net.osmand.router.RouteStatisticsHelper.RouteStatistics; import net.osmand.router.RouteStatisticsHelper.RouteSegmentAttribute; +import net.osmand.router.RouteStatisticsHelper.RouteStatistics; import net.osmand.util.Algorithms; import java.util.ArrayList; @@ -140,7 +140,7 @@ public class CustomGraphAdapter extends BaseGraphAdapter list, String propertyNameToFullSpan) { OsmandApplication app = getMyApplication(); - LayoutInflater inflater = LayoutInflater.from(app); + LayoutInflater inflater = UiUtilities.getInflater(app, isNightMode()); for (RouteSegmentAttribute segment : list) { View view = inflater.inflate(R.layout.route_details_legend, legendContainer, false); int segmentColor = segment.getColor(); @@ -158,7 +158,6 @@ public class CustomGraphAdapter extends BaseGraphAdapter