From 1ce5313dfd570174f023c2be3fdbd299c9d61f4d Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Tue, 30 Mar 2021 23:53:18 +0300 Subject: [PATCH 01/21] Data storage folder show second slash "/" for path goes to the second line. --- .../datastorage/DataStorageFragment.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java index 41c58ebd7f..57da72c4cc 100644 --- a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java @@ -234,7 +234,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto ivIcon.setImageDrawable(icon); if (currentKey.equals(MANUALLY_SPECIFIED)) { - tvSummary.setText(item.getDirectory()); + setFormattedPath(item, tvSummary); secondPart.setVisibility(View.GONE); tvAdditionalDescription.setVisibility(View.GONE); divider.setVisibility(View.GONE); @@ -252,15 +252,8 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto } if (currentKey.equals(INTERNAL_STORAGE)) { tvAdditionalDescription.setText(item.getDescription()); - } else if (currentKey.equals(SHARED_STORAGE)) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - BidiFormatter rtlFormatter = BidiFormatter.getInstance(); - tvAdditionalDescription.setText(rtlFormatter.unicodeWrap(item.getDirectory())); - } else { - tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory())); - } } else { - tvAdditionalDescription.setText(item.getDirectory()); + setFormattedPath(item, tvAdditionalDescription); } } } @@ -310,6 +303,15 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto } } + private void setFormattedPath(StorageItem item, TextView tvAdditionalDescription) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + BidiFormatter pathRtlFormatter = BidiFormatter.getInstance(); + tvAdditionalDescription.setText(pathRtlFormatter.unicodeWrap(item.getDirectory())); + } else { + tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory())); + } + } + @Override public void onDestroy() { if (!activity.isChangingConfigurations()) { From 8f8d4366d48fa1e544b56573744e0f367d802d9a Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 31 Mar 2021 13:01:16 +0300 Subject: [PATCH 02/21] Please re-check the "Terrain" menu empty state, it looks strange, why URL is on the first line? Other rtl languages work fine: Persian, Hebrew. Arabic may have its own characteristics , so its hardcoded in commit. --- .../plus/srtmplugin/TerrainFragment.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java index 1475a0a7fd..6583dea040 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java @@ -21,7 +21,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.SwitchCompat; -import androidx.core.content.ContextCompat; import com.github.ksoichiro.android.observablescrollview.ObservableListView; import com.google.android.material.slider.RangeSlider; @@ -50,14 +49,16 @@ import org.apache.commons.logging.Log; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.List; +import java.util.Locale; -import static net.osmand.plus.UiUtilities.CustomRadioButtonType.*; +import static net.osmand.plus.UiUtilities.CustomRadioButtonType.END; +import static net.osmand.plus.UiUtilities.CustomRadioButtonType.START; import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE; import static net.osmand.plus.download.DownloadActivityType.SLOPE_FILE; -import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE; -import static net.osmand.plus.srtmplugin.TerrainMode.SLOPE; import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MAX_ZOOM; import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MIN_ZOOM; +import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE; +import static net.osmand.plus.srtmplugin.TerrainMode.SLOPE; public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener, @@ -102,7 +103,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL private ArrayAdapter listAdapter; - private Slider.OnChangeListener transparencySliderChangeListener = new Slider.OnChangeListener() { + private final Slider.OnChangeListener transparencySliderChangeListener = new Slider.OnChangeListener() { @Override public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { if (fromUser) { @@ -114,7 +115,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL } }; - private RangeSlider.OnChangeListener zoomSliderChangeListener = new RangeSlider.OnChangeListener() { + private final RangeSlider.OnChangeListener zoomSliderChangeListener = new RangeSlider.OnChangeListener() { @Override public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) { List values = slider.getValues(); @@ -186,11 +187,13 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL getString(R.string.slope_read_more), wikiString ); - String emptyStateText = String.format( - getString(R.string.ltr_or_rtl_combine_via_space), - getString(R.string.terrain_empty_state_text), - PLUGIN_URL - ); + boolean isArabicLocale = Locale.getDefault().getLanguage().equals("ar"); + String emptyStateText; + if (isArabicLocale) { + emptyStateText = getString(R.string.terrain_empty_state_text) + "\n" + PLUGIN_URL; + } else { + emptyStateText = String.format(getString(R.string.ltr_or_rtl_combine_via_space), getString(R.string.terrain_empty_state_text), PLUGIN_URL); + } setupClickableText(slopeReadMoreTv, readMoreText, wikiString, SLOPES_WIKI_URL, false); setupClickableText(emptyStateDescriptionTv, emptyStateText, PLUGIN_URL, PLUGIN_URL, true); @@ -269,7 +272,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL } private void adjustGlobalVisibility() { - emptyState.setVisibility(terrainEnabled ? View.GONE : View.VISIBLE); + emptyState.setVisibility(View.VISIBLE); titleBottomDivider.setVisibility(terrainEnabled ? View.GONE : View.VISIBLE); contentContainer.setVisibility(terrainEnabled ? View.VISIBLE : View.GONE); } @@ -290,10 +293,10 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL } private void setupClickableText(TextView textView, - String text, - String clickableText, - final String url, - final boolean medium) { + String text, + String clickableText, + final String url, + final boolean medium) { SpannableString spannableString = new SpannableString(text); ClickableSpan clickableSpan = new ClickableSpan() { @Override From 169d734f47e792c7749d8bd63e84f30697e6c9ba Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 1 Apr 2021 10:51:00 +0300 Subject: [PATCH 03/21] Quick action map: suggestion to display current map name --- OsmAnd/res/values/strings.xml | 1 + .../plus/quickaction/actions/MapStyleAction.java | 9 +++++++++ .../osmand/plus/rastermaps/MapOverlayAction.java | 13 +++++++++++-- .../net/osmand/plus/rastermaps/MapSourceAction.java | 13 ++++++++++++- .../osmand/plus/rastermaps/MapUnderlayAction.java | 9 +++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a716c8b4f7..5cb21e97eb 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,7 @@ --> + %1$s + %2$d Update all maps added to %1$s? • OsmAnd Live updates moved to \"Downloads > Updates\"\n\n diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java index 1bcac88a36..1e2a8e097e 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java @@ -245,4 +245,13 @@ public class MapStyleAction extends SwitchableAction { ? filters.get(0) + " +" + (filters.size() - 1) : filters.get(0); } + + @Override + public String getActionText(OsmandApplication application) { + List mapStyles = getFilteredStyles(); + int mapCount = mapStyles.size() - 1; + String name = application.getSettings().RENDERER.get(); + + return application.getString(R.string.ltr_or_rtl_combine_via_plus, name, mapCount); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java index 7972b264aa..15ae55cfae 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java @@ -104,8 +104,8 @@ public class MapOverlayAction extends SwitchableAction> { } int index = -1; - final String currentSource = settings.MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY - : settings.MAP_OVERLAY.get(); + String currentSource = settings.MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY + : settings.MAP_OVERLAY.get(); for (int idx = 0; idx < sources.size(); idx++) { if (sources.get(idx).first.equals(currentSource)) { @@ -224,4 +224,13 @@ public class MapOverlayAction extends SwitchableAction> { getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); return super.fillParams(root, activity); } + + @Override + public String getActionText(OsmandApplication application) { + List> sources = loadListFromParams(); + int mapCount = sources.size() - 1; + String name = application.getSettings().MAP_OVERLAY.get(); + + return application.getString(R.string.ltr_or_rtl_combine_via_plus, name, mapCount); + } } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java index b11a8ec812..556f8bbd61 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java @@ -91,7 +91,7 @@ public class MapSourceAction extends SwitchableAction> { OsmandSettings settings = activity.getMyApplication().getSettings(); List> sources = loadListFromParams(); if (sources.size() > 0) { - boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG)); + boolean showBottomSheetStyles = Boolean.parseBoolean(getParams().get(KEY_DIALOG)); if (showBottomSheetStyles) { showChooseDialog(activity.getSupportFragmentManager()); return; @@ -214,4 +214,15 @@ public class MapSourceAction extends SwitchableAction> { getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); return super.fillParams(root, activity); } + + @Override + public String getActionText(OsmandApplication application) { + Pair currentSource = application.getSettings().MAP_ONLINE_DATA.get() + ? new Pair<>(application.getSettings().MAP_TILE_SOURCES.get(), application.getSettings().MAP_TILE_SOURCES.get()) + : new Pair<>(LAYER_OSM_VECTOR, application.getString(R.string.vector_data)); + final LinkedHashMap entriesMap = new LinkedHashMap<>(); + int mapCount = entriesMap.size() - 1; + + return application.getString(R.string.ltr_or_rtl_combine_via_plus, currentSource, mapCount); + } } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java index ed598a344b..0bb2838b36 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java @@ -226,4 +226,13 @@ public class MapUnderlayAction extends SwitchableAction> { getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); return super.fillParams(root, activity); } + + @Override + public String getActionText(OsmandApplication application) { + List> sources = loadListFromParams(); + int mapCount = sources.size() - 1; + String name = application.getSettings().MAP_UNDERLAY.get(); + + return application.getString(R.string.ltr_or_rtl_combine_via_plus, name, mapCount); + } } From bf6d5f0b838bcbccf8d869753f82fe1d6217ce9f Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 1 Apr 2021 12:30:38 +0300 Subject: [PATCH 04/21] Change map quick widget naming style using arrow and three dots --- OsmAnd/res/values/strings.xml | 2 +- .../plus/quickaction/actions/MapStyleAction.java | 6 ++---- .../net/osmand/plus/rastermaps/MapOverlayAction.java | 7 +++---- .../net/osmand/plus/rastermaps/MapSourceAction.java | 10 ++++------ .../net/osmand/plus/rastermaps/MapUnderlayAction.java | 7 +++---- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5cb21e97eb..b4e3e4fdc2 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,7 +12,7 @@ --> - %1$s + %2$d + %1$s → … Update all maps added to %1$s? • OsmAnd Live updates moved to \"Downloads > Updates\"\n\n diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java index 1e2a8e097e..0938e4d121 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java @@ -248,10 +248,8 @@ public class MapStyleAction extends SwitchableAction { @Override public String getActionText(OsmandApplication application) { - List mapStyles = getFilteredStyles(); - int mapCount = mapStyles.size() - 1; - String name = application.getSettings().RENDERER.get(); + String currentSource = application.getSettings().RENDERER.get(); - return application.getString(R.string.ltr_or_rtl_combine_via_plus, name, mapCount); + return application.getString(R.string.map_quick_action_pattern, currentSource); } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java index 15ae55cfae..41ae2b709b 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java @@ -227,10 +227,9 @@ public class MapOverlayAction extends SwitchableAction> { @Override public String getActionText(OsmandApplication application) { - List> sources = loadListFromParams(); - int mapCount = sources.size() - 1; - String name = application.getSettings().MAP_OVERLAY.get(); + String currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY + : application.getSettings().MAP_OVERLAY.get(); - return application.getString(R.string.ltr_or_rtl_combine_via_plus, name, mapCount); + return application.getString(R.string.map_quick_action_pattern, currentSource); } } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java index 556f8bbd61..86043763ea 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java @@ -217,12 +217,10 @@ public class MapSourceAction extends SwitchableAction> { @Override public String getActionText(OsmandApplication application) { - Pair currentSource = application.getSettings().MAP_ONLINE_DATA.get() - ? new Pair<>(application.getSettings().MAP_TILE_SOURCES.get(), application.getSettings().MAP_TILE_SOURCES.get()) - : new Pair<>(LAYER_OSM_VECTOR, application.getString(R.string.vector_data)); - final LinkedHashMap entriesMap = new LinkedHashMap<>(); - int mapCount = entriesMap.size() - 1; + String currentSource = application.getSettings().MAP_ONLINE_DATA.get() + ? application.getSettings().MAP_TILE_SOURCES.get() + : application.getString(R.string.vector_data); - return application.getString(R.string.ltr_or_rtl_combine_via_plus, currentSource, mapCount); + return application.getString(R.string.map_quick_action_pattern, currentSource); } } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java index 0bb2838b36..bb3708ba03 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java @@ -229,10 +229,9 @@ public class MapUnderlayAction extends SwitchableAction> { @Override public String getActionText(OsmandApplication application) { - List> sources = loadListFromParams(); - int mapCount = sources.size() - 1; - String name = application.getSettings().MAP_UNDERLAY.get(); + String currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY + : application.getSettings().MAP_UNDERLAY.get(); - return application.getString(R.string.ltr_or_rtl_combine_via_plus, name, mapCount); + return application.getString(R.string.map_quick_action_pattern, currentSource); } } From a5fce381d5f15d40272cb9594797d676d22618cc Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 1 Apr 2021 16:22:28 +0300 Subject: [PATCH 05/21] Misprint fix --- OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java index 6583dea040..149d118124 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java @@ -272,7 +272,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL } private void adjustGlobalVisibility() { - emptyState.setVisibility(View.VISIBLE); + emptyState.setVisibility(terrainEnabled ? View.GONE : View.VISIBLE); titleBottomDivider.setVisibility(terrainEnabled ? View.GONE : View.VISIBLE); contentContainer.setVisibility(terrainEnabled ? View.VISIBLE : View.GONE); } From e3c456fd95da5c149dd8e629b67583beb65fe00a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 1 Apr 2021 17:35:45 +0300 Subject: [PATCH 06/21] Fix #10978 --- .../src/net/osmand/plus/settings/backend/OsmandSettings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 39f3cf3d92..f227cb9b1e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -853,7 +853,7 @@ public class OsmandSettings { public boolean setValue(Object prefs, DrivingRegion val) { boolean overrideMetricSystem = !DRIVING_REGION_AUTOMATIC.getValue(prefs, DRIVING_REGION_AUTOMATIC.getDefaultValue()); if (overrideMetricSystem && val != null) { - METRIC_SYSTEM.set(val.defMetrics); + METRIC_SYSTEM.setValue(prefs, val.defMetrics); } return super.setValue(prefs, val); } @@ -866,7 +866,7 @@ public class OsmandSettings { // this value string is synchronized with settings_pref.xml preference name // cache of metrics constants as they are used very often - public final OsmandPreference METRIC_SYSTEM = new EnumStringPreference(this, + public final EnumStringPreference METRIC_SYSTEM = (EnumStringPreference) new EnumStringPreference(this, "default_metric_system", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()) { protected MetricsConstants getDefaultValue() { return DRIVING_REGION.get().defMetrics; From 74ba484ffb2ebb580ef166605badc281c96ccad9 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 1 Apr 2021 18:13:53 +0300 Subject: [PATCH 07/21] Fix #10904 --- .../net/osmand/plus/helpers/GpxUiHelper.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 620224d466..87f9d4e579 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -611,7 +611,7 @@ public class GpxUiHelper { } } dialog.dismiss(); - updateSelectedTracksAppearance(app, fileNames); + updateSelectedTracksAppearance(app, fileNames, gpxAppearanceParams); loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX, fileNames.toArray(new String[0])); } @@ -718,13 +718,7 @@ public class GpxUiHelper { return dlg; } - private static void updateSelectedTracksAppearance(OsmandApplication app, List fileNames) { - final GpxDbHelper gpxDbHelper = app.getGpxDbHelper(); - final boolean showStartFinish = app.getSettings().SHOW_START_FINISH_ICONS.get(); - final String savedWidth = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR).get(); - String savedColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR).get(); - final int color = GpxAppearanceAdapter.parseTrackColor(app.getRendererRegistry().getCurrentSelectedRenderer(), savedColor); - + private static void updateSelectedTracksAppearance(final OsmandApplication app, List fileNames, final Map params) { GpxDataItemCallback callback = new GpxDataItemCallback() { @Override public boolean isCancelled() { @@ -733,21 +727,34 @@ public class GpxUiHelper { @Override public void onGpxDataItemReady(GpxDataItem item) { - updateTrackAppearance(gpxDbHelper, item, savedWidth, color, showStartFinish); + updateTrackAppearance(app, item, params); } }; + GpxDbHelper gpxDbHelper = app.getGpxDbHelper(); for (String name : fileNames) { GpxDataItem item = gpxDbHelper.getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), name), callback); if (item != null) { - updateTrackAppearance(gpxDbHelper, item, savedWidth, color, showStartFinish); + updateTrackAppearance(app, item, params); } } } - private static void updateTrackAppearance(GpxDbHelper gpxDbHelper, GpxDataItem item, String width, int color, boolean showStartFinish) { - gpxDbHelper.updateColor(item, color); - gpxDbHelper.updateWidth(item, width); - gpxDbHelper.updateShowStartFinish(item, showStartFinish); + private static void updateTrackAppearance(OsmandApplication app, GpxDataItem item, Map params) { + OsmandSettings settings = app.getSettings(); + GpxDbHelper gpxDbHelper = app.getGpxDbHelper(); + if (params.containsKey(CURRENT_TRACK_COLOR_ATTR)) { + String savedColor = settings.getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR).get(); + int color = GpxAppearanceAdapter.parseTrackColor(app.getRendererRegistry().getCurrentSelectedRenderer(), savedColor); + gpxDbHelper.updateColor(item, color); + } + if (params.containsKey(CURRENT_TRACK_WIDTH_ATTR)) { + String width = settings.getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR).get(); + gpxDbHelper.updateWidth(item, width); + } + if (params.containsKey(SHOW_START_FINISH_ATTR)) { + boolean showStartFinish = settings.SHOW_START_FINISH_ICONS.get(); + gpxDbHelper.updateShowStartFinish(item, showStartFinish); + } } public static void updateGpxInfoView(final @NonNull OsmandApplication app, From 38523c64904af4788595d7acb46f3a709eb37384 Mon Sep 17 00:00:00 2001 From: aceman444 Date: Thu, 1 Apr 2021 17:34:58 +0200 Subject: [PATCH 08/21] Add missing word "Please follow this link if you any issues with purchases." is missing "have". --- OsmAnd/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a716c8b4f7..eb08b88bd1 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -29,7 +29,7 @@ Monthly subscription Annual subscription OsmAnd Live - Please follow this link if you any issues with purchases. + Please follow this link if you have any issues with purchases. Troubleshooting Contact support If your purchases don\'t show up here, tap on “%1$s”, or contact our support team. From b42a69e53f27d54955b82d959f83a5ef9708d609 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 1 Apr 2021 19:34:03 +0300 Subject: [PATCH 09/21] Fix #11184 --- .../activities/MapActivityKeyListener.java | 2 ++ .../plus/base/MapViewTrackingUtilities.java | 20 ++++++++++++++++++- .../plus/views/layers/MapControlsLayer.java | 18 +---------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java index 46ce19e3c2..08004ec9ab 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java @@ -92,6 +92,8 @@ public class MapActivityKeyListener implements KeyEvent.Callback { return true; } else if (keyCode == KeyEvent.KEYCODE_C) { mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); + } else if (keyCode == KeyEvent.KEYCODE_D) { + mapActivity.getMapViewTrackingUtilities().switchRotateMapMode(); } else if (settings.EXTERNAL_INPUT_DEVICE.get() == PARROT_EXTERNAL_DEVICE) { // Parrot device has only dpad left and right if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index 14a6623eae..d220b8bec1 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -39,6 +39,8 @@ import java.util.Map; public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener, MapMarkerChangedListener { + + private static final int COMPASS_REQUEST_TIME_INTERVAL_MS = 5000; private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4; private long lastTimeAutoZooming = 0; @@ -59,6 +61,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc private Float heading; private boolean drivingRegionUpdated = false; private boolean movingToMyLocation = false; + private long compassRequest; public MapViewTrackingUtilities(OsmandApplication app){ this.app = app; @@ -424,7 +427,22 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc setMapLinkedToLocation(false); } - public void switchRotateMapMode(){ + public void switchRotateMapMode() { + if (app.getRoutingHelper().isFollowingMode()) { + if (compassRequest + COMPASS_REQUEST_TIME_INTERVAL_MS > System.currentTimeMillis()) { + compassRequest = 0; + switchRotateMapModeImpl(); + } else { + compassRequest = System.currentTimeMillis(); + app.showShortToastMessage(app.getString(R.string.press_again_to_change_the_map_orientation)); + } + } else { + compassRequest = 0; + switchRotateMapModeImpl(); + } + } + + private void switchRotateMapModeImpl(){ if (mapView != null) { String rotMode = app.getString(R.string.rotate_map_none_opt); if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE && mapView.getRotate() != 0) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index 22c077f02d..a4158feced 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -97,8 +97,6 @@ public class MapControlsLayer extends OsmandMapLayer { private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201; private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202; - private static final int COMPASS_PRESSED_TIME_INTERVAL_MS = 5000; - public MapHudButton createHudButton(View iv, int resId, String id) { MapHudButton mc = new MapHudButton(); mc.iv = iv; @@ -139,7 +137,6 @@ public class MapControlsLayer extends OsmandMapLayer { private MapQuickActionLayer mapQuickActionLayer; private boolean forceShowCompass; private LatLon requestedLatLon; - private long compassPressed; private Set themeInfoProviderTags = new HashSet<>(); public MapControlsLayer(MapActivity activity) { @@ -292,20 +289,7 @@ public class MapControlsLayer extends OsmandMapLayer { compass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - boolean followingMode = app.getRoutingHelper().isFollowingMode(); - - if (followingMode) { - if (compassPressed + COMPASS_PRESSED_TIME_INTERVAL_MS > System.currentTimeMillis()) { - compassPressed = 0; - mapActivity.getMapViewTrackingUtilities().switchRotateMapMode(); - } else { - compassPressed = System.currentTimeMillis(); - app.showShortToastMessage(app.getString(R.string.press_again_to_change_the_map_orientation)); - } - } else { - compassPressed = 0; - mapActivity.getMapViewTrackingUtilities().switchRotateMapMode(); - } + mapActivity.getMapViewTrackingUtilities().switchRotateMapMode(); } }); From 33a2565c41545c9ea7619ba8ce90261cacb4b634 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 1 Apr 2021 20:49:49 +0300 Subject: [PATCH 10/21] Fix #11206 --- .../backend/OsmAndPreferencesDataStore.java | 6 +++-- .../fragments/RouteParametersFragment.java | 26 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java index 6e493ad34f..9c69b48b2c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java @@ -43,7 +43,8 @@ public class OsmAndPreferencesDataStore extends PreferenceDataStore { @Override public void putBoolean(String key, boolean value) { - if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(key)) { + if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(key) + || osmandSettings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(key)) { osmandSettings.setPreference(key, !value, appMode); } else { osmandSettings.setPreference(key, value, appMode); @@ -107,7 +108,8 @@ public class OsmAndPreferencesDataStore extends PreferenceDataStore { OsmandPreference preference = osmandSettings.getPreference(key); if (preference instanceof BooleanPreference) { BooleanPreference booleanPreference = (BooleanPreference) preference; - if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(booleanPreference.getId())) { + if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(booleanPreference.getId()) + || osmandSettings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(booleanPreference.getId())) { return !booleanPreference.getModeValue(appMode); } return booleanPreference.getModeValue(appMode); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java index eb4f09f4aa..6f7a974ddd 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java @@ -31,9 +31,8 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; -import net.osmand.plus.routing.RouteService; import net.osmand.plus.development.OsmandDevelopmentPlugin; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.BooleanPreference; @@ -357,15 +356,14 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP } private void setupReverseDirectionRecalculation(PreferenceScreen screen) { - SwitchPreferenceEx recalcRouteReverseDirectionPreference = - createSwitchPreferenceEx(settings.DISABLE_WRONG_DIRECTION_RECALC.getId(), - R.string.in_case_of_reverse_direction, - R.layout.preference_with_descr_dialog_and_switch); - recalcRouteReverseDirectionPreference.setIcon( - getRoutingPrefIcon(settings.DISABLE_WRONG_DIRECTION_RECALC.getId())); - recalcRouteReverseDirectionPreference.setSummaryOn(R.string.shared_string_enabled); - recalcRouteReverseDirectionPreference.setSummaryOff(R.string.shared_string_disabled); - screen.addPreference(recalcRouteReverseDirectionPreference); + OsmandPreference preference = settings.DISABLE_WRONG_DIRECTION_RECALC; + SwitchPreferenceEx switchPreference = createSwitchPreferenceEx(preference.getId(), + R.string.in_case_of_reverse_direction, + R.layout.preference_with_descr_dialog_and_switch); + switchPreference.setIcon(getRoutingPrefIcon(preference.getId())); + switchPreference.setSummaryOn(R.string.shared_string_enabled); + switchPreference.setSummaryOff(R.string.shared_string_disabled); + screen.addPreference(switchPreference); } private void setupRouteRecalcHeader(PreferenceScreen screen) { @@ -546,7 +544,9 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - if (settings.DISABLE_COMPLEX_ROUTING.getId().equals(preference.getKey()) && newValue instanceof Boolean) { + if ((settings.DISABLE_COMPLEX_ROUTING.getId().equals(preference.getKey()) || + settings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(preference.getKey())) && + newValue instanceof Boolean) { return onConfirmPreferenceChange(preference.getKey(), !(Boolean) newValue, getApplyQueryType()); // pref ui was inverted } return onConfirmPreferenceChange(preference.getKey(), newValue, getApplyQueryType()); @@ -573,8 +573,6 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP applyPreference(ROUTING_RECALC_DISTANCE, applyToAllProfiles, valueToSave); applyPreference(settings.DISABLE_OFFROUTE_RECALC.getId(), applyToAllProfiles, !enabled); updateRouteRecalcDistancePref(); - } else if (settings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(prefId)) { - applyPreference(settings.DISABLE_WRONG_DIRECTION_RECALC.getId(), applyToAllProfiles, newValue); } else { super.onApplyPreferenceChange(prefId, applyToAllProfiles, newValue); } From b9e886ef64461282210937c7145b93e81066fa50 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 1 Apr 2021 22:00:04 +0300 Subject: [PATCH 11/21] Underlay, overlay naming fix --- OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java | 2 +- OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java index 41ae2b709b..8190b6c995 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java @@ -230,6 +230,6 @@ public class MapOverlayAction extends SwitchableAction> { String currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY : application.getSettings().MAP_OVERLAY.get(); - return application.getString(R.string.map_quick_action_pattern, currentSource); + return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource)); } } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java index bb3708ba03..ddb941e10b 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java @@ -232,6 +232,6 @@ public class MapUnderlayAction extends SwitchableAction> { String currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY : application.getSettings().MAP_UNDERLAY.get(); - return application.getString(R.string.map_quick_action_pattern, currentSource); + return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource)); } } From 98887aba71a56349487d5fc55adeb41a960970a7 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Fri, 2 Apr 2021 16:24:58 +0300 Subject: [PATCH 12/21] Remove phrase --- OsmAnd/res/values/phrases.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index bfe9be1e13..fe727f7ad7 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -284,7 +284,6 @@ Ship chandler Sporting goods Stationery store - Tableware store Ticket sales Tobacco store Toyshop From 1a18eb5b58a332103c70c0cedae9fa10e4bcd99c Mon Sep 17 00:00:00 2001 From: xmd5a Date: Fri, 2 Apr 2021 17:24:17 +0300 Subject: [PATCH 13/21] Add missing phrase (fix https://github.com/osmandapp/OsmAnd/issues/11322) --- OsmAnd/res/values/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index fe727f7ad7..10ea9f7ae6 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -4378,4 +4378,6 @@ Horseshoes Kickboxing + Diplomatic office + From 741f92ddcd93c86c1514bf01a9eb95cfadd9ec4e Mon Sep 17 00:00:00 2001 From: xmd5a Date: Sat, 3 Apr 2021 21:32:33 +0300 Subject: [PATCH 14/21] Add phrase --- OsmAnd/res/values/phrases.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 10ea9f7ae6..2089642add 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -144,6 +144,7 @@ Non-immigrant visas Immigrant visas Citizen services + Bay type Store From 241a2387b12cfc12c46399dc3821e4b169467bf1 Mon Sep 17 00:00:00 2001 From: cepprice Date: Sat, 3 Apr 2021 01:26:33 +0500 Subject: [PATCH 15/21] Fix colorization when speed was derived from timestamps --- .../java/net/osmand/router/RouteColorize.java | 43 ++++++++++++++----- .../net/osmand/plus/track/GradientCard.java | 24 +++-------- .../osmand/plus/views/layers/GPXLayer.java | 9 +++- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java index 8fb0046bb4..e224e9c679 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java @@ -4,6 +4,7 @@ import net.osmand.GPXUtilities; import net.osmand.PlatformUtil; import net.osmand.osm.edit.Node; import net.osmand.osm.edit.OsmMapUtils; +import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; @@ -30,6 +31,8 @@ public class RouteColorize { public static final int RED = rgbaToDecimal(243, 55, 77, 255); public static final int[] colors = new int[] {GREEN, YELLOW, RED}; + private static final int MAX_SLOPE_VALUE = 25; + public enum ColorizationType { ELEVATION, SPEED, @@ -75,7 +78,7 @@ public class RouteColorize { /** * @param type ELEVATION, SPEED, SLOPE */ - public RouteColorize(int zoom, GPXUtilities.GPXFile gpxFile, ColorizationType type) { + public RouteColorize(int zoom, GPXUtilities.GPXFile gpxFile, ColorizationType type, float maxProfileSpeed) { if (!gpxFile.hasTrkPt()) { LOG.warn("GPX file is not consist of track points"); @@ -85,21 +88,27 @@ public class RouteColorize { List latList = new ArrayList<>(); List lonList = new ArrayList<>(); List valList = new ArrayList<>(); + + GPXUtilities.GPXTrackAnalysis analysis = Algorithms.isEmpty(gpxFile.path) ? + gpxFile.getAnalysis(System.currentTimeMillis()) : gpxFile.getAnalysis(gpxFile.modifiedTime); + int wptIdx = 0; for (GPXUtilities.Track t : gpxFile.tracks) { for (GPXUtilities.TrkSegment ts : t.segments) { for (GPXUtilities.WptPt p : ts.points) { latList.add(p.lat); lonList.add(p.lon); if (type == ColorizationType.SPEED) { - valList.add(p.speed); + valList.add((double) analysis.speedData.get(wptIdx).speed); } else { - valList.add(p.ele); + valList.add((double) analysis.elevationData.get(wptIdx).elevation); } + wptIdx++; } } } this.zoom = zoom; + colorizationType = type; latitudes = listToArray(latList); longitudes = listToArray(lonList); @@ -108,9 +117,8 @@ public class RouteColorize { } else { values = listToArray(valList); } - calculateMinMaxValue(); - colorizationType = type; + maxValue = getMaxValue(colorizationType, analysis, minValue, maxProfileSpeed); checkPalette(); sortPalette(); } @@ -194,7 +202,7 @@ public class RouteColorize { return rgbaToDecimal((int) resultRed, (int) resultGreen, (int) resultBlue, (int) resultAlpha); } } - return getDefaultColor(); + return getTransparentColor(); } public void setPalette(double[][] palette) { @@ -209,12 +217,12 @@ public class RouteColorize { } setPalette(new double[][] { {minValue, gradientPalette[0]}, - {colorizationType == ColorizationType.SLOPE ? 0 : (minValue + maxValue) / 2, gradientPalette[1]}, + {(minValue + maxValue) / 2, gradientPalette[1]}, {maxValue, gradientPalette[2]} }); } - private int getDefaultColor() { + private int getTransparentColor() { return rgbaToDecimal(0, 0, 0, 0); } @@ -295,7 +303,7 @@ public class RouteColorize { double[][] defaultPalette = { {minValue, GREEN}, - {colorizationType == ColorizationType.SLOPE ? 0 : (minValue + maxValue) / 2, YELLOW}, + {(minValue + maxValue) / 2, YELLOW}, {maxValue, RED} }; palette = defaultPalette; @@ -397,6 +405,20 @@ public class RouteColorize { return result; } + public static double getMinValue(ColorizationType type, GPXUtilities.GPXTrackAnalysis analysis) { + return type == ColorizationType.ELEVATION ? analysis.minElevation : 0.0; + } + + public static double getMaxValue(ColorizationType type, GPXUtilities.GPXTrackAnalysis analysis, double minValue, double maxProfileSpeed) { + if (type == ColorizationType.SPEED) { + return Math.max(analysis.maxSpeed, maxProfileSpeed); + } else if (type == ColorizationType.ELEVATION) { + return Math.max(analysis.maxElevation, minValue + 50); + } else { + return MAX_SLOPE_VALUE; + } + } + private void calculateMinMaxValue() { if (values.length == 0) return; @@ -457,5 +479,4 @@ public class RouteColorize { this.val = val; } } - -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/GradientCard.java b/OsmAnd/src/net/osmand/plus/track/GradientCard.java index 217ad2a8f1..3c34d9f68d 100644 --- a/OsmAnd/src/net/osmand/plus/track/GradientCard.java +++ b/OsmAnd/src/net/osmand/plus/track/GradientCard.java @@ -12,6 +12,7 @@ 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 net.osmand.router.RouteColorize; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -42,8 +43,9 @@ public class GradientCard extends BaseCard { AndroidUiHelper.updateVisibility(view, true); TextView minValue = view.findViewById(R.id.min_value); TextView maxValue = view.findViewById(R.id.max_value); - float min = getMinValue(); - float max = getMaxValue(min); + double min = RouteColorize.getMinValue(selectedScaleType.toColorizationType(), gpxTrackAnalysis); + double max = RouteColorize.getMaxValue(selectedScaleType.toColorizationType(), + gpxTrackAnalysis, min, app.getSettings().getApplicationMode().getMaxSpeed()); minValue.setText(formatValue(min)); maxValue.setText(formatValue(max)); } @@ -53,27 +55,13 @@ public class GradientCard extends BaseCard { updateContent(); } - private float getMinValue() { - return (float) (selectedScaleType == GradientScaleType.ALTITUDE ? gpxTrackAnalysis.minElevation : 0.0); - } - - private float getMaxValue(float minValue) { - if (selectedScaleType == GradientScaleType.SPEED) { - return (Math.max(gpxTrackAnalysis.maxSpeed, app.getSettings().getApplicationMode().getMaxSpeed())); - } else if (selectedScaleType == GradientScaleType.ALTITUDE) { - return (float) Math.max(gpxTrackAnalysis.maxElevation, minValue + 50); - } else { - return 25; - } - } - - private CharSequence formatValue(float value) { + private CharSequence formatValue(double value) { if (selectedScaleType == GradientScaleType.ALTITUDE) { return OsmAndFormatter.getFormattedAlt(value, app); } else if (selectedScaleType == GradientScaleType.SLOPE) { return (int) value + " %"; } - String speed = OsmAndFormatter.getFormattedSpeed(value, app); + String speed = OsmAndFormatter.getFormattedSpeed((float) value, app); String speedUnit = app.getSettings().SPEED_SYSTEM.get().toShortString(app); Spannable formattedSpeed = new SpannableString(speed); formattedSpeed.setSpan( diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index c16d687614..5c757285ef 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -684,11 +684,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM List segments = selectedGpxFile.getPointsToDisplay(); GradientScaleType scaleType = getGradientScaleType(gpxFile); List colorsOfPoints = null; - if (scaleType != null) { - RouteColorize colorize = new RouteColorize(view.getZoom(), gpxFile, scaleType.toColorizationType()); + boolean needCalculateColors = scaleType != null && segments.get(0).points.get(0) + .getColor(scaleType.toColorizationType()) == 0; + + if (scaleType != null && currentTrack || needCalculateColors) { + RouteColorize colorize = new RouteColorize(view.getZoom(), gpxFile, + scaleType.toColorizationType(), view.getApplication().getSettings().getApplicationMode().getMaxSpeed()); colorize.setPalette(getColorizationPalette(gpxFile, scaleType)); colorsOfPoints = colorize.getResult(false); } + int startIdx = 0; for (TrkSegment ts : segments) { String width = getTrackWidthName(gpxFile, defaultTrackWidthPref.get()); From 6cfc02979f1c5946bd26760ce8c50ad95c6707fb Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 4 Apr 2021 03:22:09 +0500 Subject: [PATCH 16/21] Remove border overlapping when zooming gradient track --- .../src/net/osmand/plus/views/Renderable.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/Renderable.java b/OsmAnd/src/net/osmand/plus/views/Renderable.java index 27d741d964..657cf3856a 100644 --- a/OsmAnd/src/net/osmand/plus/views/Renderable.java +++ b/OsmAnd/src/net/osmand/plus/views/Renderable.java @@ -61,6 +61,7 @@ public class Renderable { public List points = null; // Original list of points protected List culled = new ArrayList<>(); // Reduced/resampled list of points + protected List oldCulled = new ArrayList<>(); protected int pointSize; protected double segmentSize; @@ -116,7 +117,7 @@ public class Renderable { updateLocalPaint(p); canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); if (scaleType != null) { - drawGradient(getPointsForDrawing(), p, canvas, tileBox); + drawGradient(getPointsForDrawingWithBorder(), p, canvas, tileBox); } else { drawSolid(getPointsForDrawing(), p, canvas, tileBox); } @@ -126,6 +127,9 @@ public class Renderable { public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) { if (QuadRect.trivialOverlap(tileBox.getLatLonBounds(), trackBounds)) { // is visible? + if (tileBox.getZoomAnimation() > 0 && !Algorithms.isEmpty(culled) && scaleType != null) { + oldCulled = new ArrayList<>(culled); + } startCuller(zoom); drawSingleSegment(zoom, p, canvas, tileBox); } @@ -139,6 +143,16 @@ public class Renderable { return culled.isEmpty() ? points : culled; } + public List getPointsForDrawingWithBorder() { + if (!culled.isEmpty()) { + return culled; + } else if (!oldCulled.isEmpty()) { + return oldCulled; + } else { + return points; + } + } + public void drawGeometry(Canvas canvas, RotatedTileBox tileBox, QuadRect quadRect, int arrowColor, int trackColor, float trackWidth) { if (geometryWay != null) { List points = getPointsForDrawing(); @@ -290,7 +304,8 @@ public class Renderable { super(pt, 0); } - @Override public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) { + @Override + public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) { if (points.size() != pointSize) { int prevSize = pointSize; pointSize = points.size(); From 9e46f46a6b98cced1b7a10200685df549e841c46 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Sun, 4 Apr 2021 10:13:42 +0300 Subject: [PATCH 17/21] Custom width: increase max. number to 36 --- .../src/net/osmand/plus/routing/cards/RouteLineWidthCard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java index 72055da936..d9843f72ea 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java @@ -36,7 +36,7 @@ import java.util.List; public class RouteLineWidthCard extends BaseCard { private final static int CUSTOM_WIDTH_MIN = 1; - private final static int CUSTOM_WIDTH_MAX = 24; + private final static int CUSTOM_WIDTH_MAX = 36; private RouteLineDrawInfo routeLineDrawInfo; private OnNeedScrollListener onNeedScrollListener; From 4aa78747502aea4987c6d7417dfb75cd98b9a6e8 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Sun, 4 Apr 2021 10:15:23 +0300 Subject: [PATCH 18/21] Fix dark theme --- OsmAnd/res/layout/route_line_appearance.xml | 1 - .../settings/fragments/RouteLineAppearanceFragment.java | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/route_line_appearance.xml b/OsmAnd/res/layout/route_line_appearance.xml index ca822afb37..e5410cdd2f 100644 --- a/OsmAnd/res/layout/route_line_appearance.xml +++ b/OsmAnd/res/layout/route_line_appearance.xml @@ -88,7 +88,6 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/card_and_list_background_basic" android:minHeight="@dimen/toolbar_height" android:padding="0dp" osmand:contentInsetEnd="0dp" diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java index 2975815bb4..254e1e3d3d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java @@ -15,6 +15,7 @@ import android.widget.ScrollView; import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; @@ -32,7 +33,6 @@ import net.osmand.plus.routing.cards.RouteLineColorCard; import net.osmand.plus.routing.cards.RouteLineColorCard.OnMapThemeUpdateListener; import net.osmand.plus.routing.cards.RouteLineColorCard.OnSelectedColorChangeListener; import net.osmand.plus.routing.cards.RouteLineWidthCard; -import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener; @@ -203,6 +203,8 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple } }); closeButton.setImageResource(AndroidUtils.getNavigationIconResId(toolbarContainer.getContext())); + int bgColorId = isNightMode() ? R.color.app_bar_color_dark : R.color.list_background_color_light; + toolbarContainer.setBackgroundColor(ContextCompat.getColor(requireContext(), bgColorId)); updateToolbarVisibility(toolbarContainer); } @@ -212,7 +214,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple if (Build.VERSION.SDK_INT >= 23 && !isNightMode() && view != null) { view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } - return isNightMode() ? R.color.divider_color_dark : R.color.divider_color_light; + return isNightMode() ? R.color.status_bar_color_dark : R.color.divider_color_light; } @Override From d8ddb717427df979d339412e36c0d694f325d4c5 Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 4 Apr 2021 18:03:09 +0500 Subject: [PATCH 19/21] Fixes after review --- .../java/net/osmand/router/RouteColorize.java | 21 +++++++------- .../osmand/plus/views/layers/GPXLayer.java | 28 +++++++++++++++---- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java index e224e9c679..a4d5e8a597 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java @@ -1,10 +1,13 @@ package net.osmand.router; -import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.GPXTrackAnalysis; +import net.osmand.GPXUtilities.Track; +import net.osmand.GPXUtilities.TrkSegment; +import net.osmand.GPXUtilities.WptPt; import net.osmand.PlatformUtil; import net.osmand.osm.edit.Node; import net.osmand.osm.edit.OsmMapUtils; -import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; @@ -78,7 +81,7 @@ public class RouteColorize { /** * @param type ELEVATION, SPEED, SLOPE */ - public RouteColorize(int zoom, GPXUtilities.GPXFile gpxFile, ColorizationType type, float maxProfileSpeed) { + public RouteColorize(int zoom, GPXFile gpxFile, GPXTrackAnalysis analysis, ColorizationType type, float maxProfileSpeed) { if (!gpxFile.hasTrkPt()) { LOG.warn("GPX file is not consist of track points"); @@ -89,12 +92,10 @@ public class RouteColorize { List lonList = new ArrayList<>(); List valList = new ArrayList<>(); - GPXUtilities.GPXTrackAnalysis analysis = Algorithms.isEmpty(gpxFile.path) ? - gpxFile.getAnalysis(System.currentTimeMillis()) : gpxFile.getAnalysis(gpxFile.modifiedTime); int wptIdx = 0; - for (GPXUtilities.Track t : gpxFile.tracks) { - for (GPXUtilities.TrkSegment ts : t.segments) { - for (GPXUtilities.WptPt p : ts.points) { + for (Track t : gpxFile.tracks) { + for (TrkSegment ts : t.segments) { + for (WptPt p : ts.points) { latList.add(p.lat); lonList.add(p.lon); if (type == ColorizationType.SPEED) { @@ -405,11 +406,11 @@ public class RouteColorize { return result; } - public static double getMinValue(ColorizationType type, GPXUtilities.GPXTrackAnalysis analysis) { + public static double getMinValue(ColorizationType type, GPXTrackAnalysis analysis) { return type == ColorizationType.ELEVATION ? analysis.minElevation : 0.0; } - public static double getMaxValue(ColorizationType type, GPXUtilities.GPXTrackAnalysis analysis, double minValue, double maxProfileSpeed) { + public static double getMaxValue(ColorizationType type, GPXTrackAnalysis analysis, double minValue, double maxProfileSpeed) { if (type == ColorizationType.SPEED) { return Math.max(analysis.maxSpeed, maxProfileSpeed); } else if (type == ColorizationType.ELEVATION) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 5c757285ef..69266746a9 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -680,16 +680,15 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { + OsmandApplication app = view.getApplication(); GPXFile gpxFile = selectedGpxFile.getGpxFile(); List segments = selectedGpxFile.getPointsToDisplay(); GradientScaleType scaleType = getGradientScaleType(gpxFile); List colorsOfPoints = null; - boolean needCalculateColors = scaleType != null && segments.get(0).points.get(0) - .getColor(scaleType.toColorizationType()) == 0; - if (scaleType != null && currentTrack || needCalculateColors) { - RouteColorize colorize = new RouteColorize(view.getZoom(), gpxFile, - scaleType.toColorizationType(), view.getApplication().getSettings().getApplicationMode().getMaxSpeed()); + if (needCalculatePointsColors(segments, scaleType)) { + RouteColorize colorize = new RouteColorize(view.getZoom(), gpxFile, selectedGpxFile.getTrackAnalysis(app), + scaleType.toColorizationType(), app.getSettings().getApplicationMode().getMaxSpeed()); colorize.setPalette(getColorizationPalette(gpxFile, scaleType)); colorsOfPoints = colorize.getResult(false); } @@ -721,6 +720,25 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } } + private boolean needCalculatePointsColors(List segments, GradientScaleType scaleType) { + if (scaleType == null) { + return false; + } + RouteColorize.ColorizationType colorizationType = scaleType.toColorizationType(); + for (int segIdx = segments.size() - 1; segIdx >= 0; segIdx--) { + List pts = segments.get(segIdx).points; + if (!Algorithms.isEmpty(pts)) { + for (int wptIdx = pts.size() - 1; wptIdx >= 0; wptIdx--) { + WptPt pt = pts.get(wptIdx); + if (pt.getColor(colorizationType) == 0) { + return true; + } + } + } + } + return false; + } + private int setColorsToPoints(TrkSegment segment, List colors, GradientScaleType scaleType, int startIdx) { int pointsSize = segment.points.size(); RouteColorize.RouteColorizationPoint startColor = colors.get(startIdx); From 516881f8a5fd7fde473f65ed245d8919328f9cd6 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 5 Apr 2021 09:25:07 +0300 Subject: [PATCH 20/21] Add getTranslatedItemName() to other class --- .../src/net/osmand/plus/quickaction/actions/MapStyleAction.java | 2 +- OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java index 0938e4d121..5838bfc1a2 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java @@ -250,6 +250,6 @@ public class MapStyleAction extends SwitchableAction { public String getActionText(OsmandApplication application) { String currentSource = application.getSettings().RENDERER.get(); - return application.getString(R.string.map_quick_action_pattern, currentSource); + return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource)); } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java index 86043763ea..d81b1f12ed 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java @@ -221,6 +221,6 @@ public class MapSourceAction extends SwitchableAction> { ? application.getSettings().MAP_TILE_SOURCES.get() : application.getString(R.string.vector_data); - return application.getString(R.string.map_quick_action_pattern, currentSource); + return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource)); } } From f8cd5510855c3278c55f7633531ffb6e4d2b0ee6 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 5 Apr 2021 09:29:16 +0300 Subject: [PATCH 21/21] Remove else block with rtl and ltr combine --- .../src/net/osmand/plus/srtmplugin/TerrainFragment.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java index 149d118124..ae15dfbf6e 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java @@ -187,13 +187,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL getString(R.string.slope_read_more), wikiString ); - boolean isArabicLocale = Locale.getDefault().getLanguage().equals("ar"); - String emptyStateText; - if (isArabicLocale) { - emptyStateText = getString(R.string.terrain_empty_state_text) + "\n" + PLUGIN_URL; - } else { - emptyStateText = String.format(getString(R.string.ltr_or_rtl_combine_via_space), getString(R.string.terrain_empty_state_text), PLUGIN_URL); - } + String emptyStateText = getString(R.string.terrain_empty_state_text) + "\n" + PLUGIN_URL; setupClickableText(slopeReadMoreTv, readMoreText, wikiString, SLOPES_WIKI_URL, false); setupClickableText(emptyStateDescriptionTv, emptyStateText, PLUGIN_URL, PLUGIN_URL, true);