diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 4db84c5c33..cb5f40a4b9 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -1662,16 +1662,16 @@ public class GPXUtilities { return new QuadRect(left, top, right, bottom); } - public int getGradientScaleColor(String gradientScaleType, int defColor) { + public int[] getGradientScaleColor(String gradientScaleType) { String clrValue = null; if (extensions != null) { clrValue = extensions.get(gradientScaleType); } - return parseColor(clrValue, defColor); + return Algorithms.stringToGradientPalette(clrValue); } - public void setGradientScaleColor(String gradientScaleType, int gradientScaleColor) { - getExtensionsToWrite().put(gradientScaleType, Algorithms.colorToString(gradientScaleColor)); + public void setGradientScaleColor(String gradientScaleType, int[] gradientScalePalette) { + getExtensionsToWrite().put(gradientScaleType, Algorithms.gradientPaletteToString(gradientScalePalette)); } public String getGradientScaleType() { 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 6730965d1f..63f0ee1cd3 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java @@ -24,11 +24,12 @@ public class RouteColorize { public static final int DARK_GREY = rgbaToDecimal(92, 92, 92, 255); public static final int LIGHT_GREY = rgbaToDecimal(200, 200, 200, 255); - public static final int RED = rgbaToDecimal(255,1,1,255); - public static final int GREEN = rgbaToDecimal(46,185,0,191); - public static final int YELLOW = rgbaToDecimal(255,222,2,227); + public static final int GREEN = rgbaToDecimal(90, 220, 95, 1); + public static final int YELLOW = rgbaToDecimal(212, 239, 50, 1); + public static final int RED = rgbaToDecimal(243, 55, 77, 1); + public static final int[] colors = new int[] {GREEN, YELLOW, RED}; - public enum ValueType { + public enum ColorizationType { ELEVATION, SPEED, SLOPE, @@ -42,7 +43,7 @@ public class RouteColorize { private final int BLUE_COLOR_INDEX = 3;//RGB private final int ALPHA_COLOR_INDEX = 4;//RGBA - private ValueType valueType; + private ColorizationType colorizationType; public static int SLOPE_RANGE = 150;//150 meters private static final double MIN_DIFFERENCE_SLOPE = 0.05d;//5% @@ -73,7 +74,7 @@ public class RouteColorize { /** * @param type ELEVATION, SPEED, SLOPE */ - public RouteColorize(int zoom, GPXUtilities.GPXFile gpxFile, ValueType type) { + public RouteColorize(int zoom, GPXUtilities.GPXFile gpxFile, ColorizationType type) { if (!gpxFile.hasTrkPt()) { LOG.warn("GPX file is not consist of track points"); @@ -88,7 +89,7 @@ public class RouteColorize { for (GPXUtilities.WptPt p : ts.points) { latList.add(p.lat); lonList.add(p.lon); - if (type == ValueType.SPEED) { + if (type == ColorizationType.SPEED) { valList.add(p.speed); } else { valList.add(p.ele); @@ -101,14 +102,14 @@ public class RouteColorize { latitudes = listToArray(latList); longitudes = listToArray(lonList); - if (type == ValueType.SLOPE) { + if (type == ColorizationType.SLOPE) { values = calculateSlopesByElevations(latitudes, longitudes, listToArray(valList), SLOPE_RANGE); } else { values = listToArray(valList); } calculateMinMaxValue(); - valueType = type; + colorizationType = type; checkPalette(); sortPalette(); } @@ -282,7 +283,7 @@ public class RouteColorize { double[][] defaultPalette = { {minValue, GREEN}, - {valueType == ValueType.SLOPE ? 0 : (minValue + maxValue) / 2, YELLOW}, + {colorizationType == ColorizationType.SLOPE ? 0 : (minValue + maxValue) / 2, YELLOW}, {maxValue, RED} }; palette = defaultPalette; diff --git a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java index 36c0034a26..737e302e6a 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java @@ -2,6 +2,7 @@ package net.osmand.util; import net.osmand.IProgress; import net.osmand.PlatformUtil; +import net.osmand.router.RouteColorize; import org.apache.commons.logging.Log; import org.xmlpull.v1.XmlPullParser; @@ -1027,4 +1028,30 @@ public class Algorithms { } return false; } + + public static int[] stringToGradientPalette(String str) { + if (Algorithms.isBlank(str)) { + return RouteColorize.colors; + } + String[] arr = str.split(" "); + if (arr.length != 3) { + return RouteColorize.colors; + } + int[] colors = new int[3]; + try { + for (int i = 0; i < 3; i++) { + colors[i] = Algorithms.parseColor(arr[i]); + } + } catch (IllegalArgumentException e) { + return RouteColorize.colors; + } + return colors; + } + + public static String gradientPaletteToString(int[] colors) { + int[] src = colors.length == 3 ? colors : RouteColorize.colors; + return Algorithms.colorToString(src[0]) + " " + + Algorithms.colorToString(src[1]) + " " + + Algorithms.colorToString(src[2]); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index 74dc02be9c..b08013017f 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -178,9 +178,9 @@ public class GPXDatabase { private String width; private GradientScaleType gradientScaleType; private int color; - private int gradientSpeedColor; - private int gradientAltitudeColor; - private int gradientSlopeColor; + private int[] gradientSpeedPalette; + private int[] gradientAltitudePalette; + private int[] gradientSlopePalette; private int splitType; private double splitInterval; private long fileLastModifiedTime; @@ -210,9 +210,9 @@ public class GPXDatabase { width = gpxFile.getWidth(null); showArrows = gpxFile.isShowArrows(); showStartFinish = gpxFile.isShowStartFinish(); - gradientSpeedColor = gpxFile.getGradientScaleColor(GradientScaleType.SPEED.getColorTypeName(), 0); - gradientSlopeColor = gpxFile.getGradientScaleColor(GradientScaleType.SLOPE.getColorTypeName(), 0); - gradientAltitudeColor = gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE.getColorTypeName(), 0); + gradientSpeedPalette = gpxFile.getGradientScaleColor(GradientScaleType.SPEED.getColorTypeName()); + gradientSlopePalette = gpxFile.getGradientScaleColor(GradientScaleType.SLOPE.getColorTypeName()); + gradientAltitudePalette = gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE.getColorTypeName()); if (!Algorithms.isEmpty(gpxFile.getSplitType()) && gpxFile.getSplitInterval() > 0) { GpxSplitType gpxSplitType = GpxSplitType.getSplitTypeByName(gpxFile.getSplitType()); @@ -243,23 +243,22 @@ public class GPXDatabase { return gradientScaleType; } - public int getGradientSpeedColor() { - return gradientSpeedColor; + public int[] getGradientSpeedPalette() { + return gradientSpeedPalette; } - public int getGradientAltitudeColor() { - return gradientAltitudeColor; + public int[] getGradientAltitudePalette() { + return gradientAltitudePalette; } - public int getGradientSlopeColor() { - return gradientSlopeColor; + public int[] getGradientSlopePalette() { + return gradientSlopePalette; } public String getWidth() { return width; } - public long getFileLastModifiedTime() { return fileLastModifiedTime; } @@ -507,7 +506,7 @@ public class GPXDatabase { return false; } - public boolean updateGradientScaleColor(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType, int gradientScaleColor) { + public boolean updateGradientScaleColor(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType, int[] gradientScalePalette) { SQLiteConnection db = openConnection(false); if (db != null) { try { @@ -516,17 +515,17 @@ public class GPXDatabase { String columnName = null; if (GradientScaleType.SPEED == gradientScaleType) { columnName = GPX_COL_GRADIENT_SPEED_COLOR; - item.gradientSpeedColor = gradientScaleColor; + item.gradientSpeedPalette = gradientScalePalette; } else if (GradientScaleType.ALTITUDE == gradientScaleType) { columnName = GPX_COL_GRADIENT_ALTITUDE_COLOR; - item.gradientAltitudeColor = gradientScaleColor; + item.gradientAltitudePalette = gradientScalePalette; } else if (GradientScaleType.SLOPE == gradientScaleType) { columnName = GPX_COL_GRADIENT_SLOPE_COLOR; - item.gradientSlopeColor = gradientScaleColor; + item.gradientSlopePalette = gradientScalePalette; } 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}); + new Object[] {Algorithms.gradientPaletteToString(gradientScalePalette), fileName, fileDir}); } finally { db.close(); } @@ -729,7 +728,7 @@ public class GPXDatabase { 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.gradientSpeedColor, item.gradientAltitudeColor, item.gradientSlopeColor, gradientScaleType}); + item.gradientSpeedPalette, item.gradientAltitudePalette, item.gradientSlopePalette, gradientScaleType}); } else { db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" + GPX_COL_NAME + ", " + @@ -752,7 +751,7 @@ public class GPXDatabase { 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.gradientSpeedColor, item.gradientAltitudeColor, item.gradientSlopeColor, gradientScaleType}); + item.gradientSpeedPalette, item.gradientAltitudePalette, item.gradientSlopePalette, gradientScaleType}); } } @@ -836,9 +835,9 @@ 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 gradientSpeedPalette = query.getString(29); + String gradientAltitudePalette = query.getString(30); + String gradientSlopePalette = query.getString(31); String gradientScaleType = query.getString(32); GPXTrackAnalysis a = new GPXTrackAnalysis(); @@ -880,9 +879,9 @@ public class GPXDatabase { item.showArrows = showArrows; item.showStartFinish = showStartFinish; item.width = width; - item.gradientSpeedColor = parseColor(gradientSpeedColor); - item.gradientAltitudeColor = parseColor(gradientAltitudeColor); - item.gradientSlopeColor = parseColor(gradientSlopeColor); + item.gradientSpeedPalette = Algorithms.stringToGradientPalette(gradientSpeedPalette); + item.gradientAltitudePalette = Algorithms.stringToGradientPalette(gradientAltitudePalette); + item.gradientSlopePalette = Algorithms.stringToGradientPalette(gradientSlopePalette); try { item.gradientScaleType = Algorithms.isEmpty(gradientScaleType) ? null : GradientScaleType.valueOf(gradientScaleType); diff --git a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java index 8a7d886a63..ef93703190 100644 --- a/OsmAnd/src/net/osmand/plus/GpxDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxDbHelper.java @@ -78,8 +78,8 @@ public class GpxDbHelper { return res; } - public boolean updateGradientScaleColor(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType, int color) { - boolean res = db.updateGradientScaleColor(item, gradientScaleType, color); + public boolean updateGradientScaleColor(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType, int[] palette) { + boolean res = db.updateGradientScaleColor(item, gradientScaleType, palette); putToCache(item); return res; } diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index c2f3d831b8..ce33c21803 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -2246,15 +2246,9 @@ public class GpxUiHelper { if (dataItem.getWidth() != null) { gpxFile.setWidth(dataItem.getWidth()); } - if (dataItem.getGradientSpeedColor() != 0) { - gpxFile.setGradientScaleColor(GradientScaleType.SPEED.getColorTypeName(), dataItem.getGradientSpeedColor()); - } - if (dataItem.getGradientSlopeColor() != 0) { - gpxFile.setGradientScaleColor(GradientScaleType.SLOPE.getColorTypeName(), dataItem.getGradientSlopeColor()); - } - if (dataItem.getGradientAltitudeColor() != 0) { - gpxFile.setGradientScaleColor(GradientScaleType.ALTITUDE.getColorTypeName(), dataItem.getGradientAltitudeColor()); - } + gpxFile.setGradientScaleColor(GradientScaleType.SPEED.getColorTypeName(), dataItem.getGradientSpeedPalette()); + gpxFile.setGradientScaleColor(GradientScaleType.SLOPE.getColorTypeName(), dataItem.getGradientSlopePalette()); + gpxFile.setGradientScaleColor(GradientScaleType.ALTITUDE.getColorTypeName(), dataItem.getGradientAltitudePalette()); if (dataItem.getGradientScaleType() != null) { gpxFile.setGradientScaleType(dataItem.getGradientScaleType().name()); } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 2854520bbf..0635f8d7c1 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -50,6 +50,7 @@ import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.srtmplugin.TerrainMode; +import net.osmand.plus.track.GradientScaleType; import net.osmand.plus.views.layers.RadiusRulerControlLayer.RadiusRulerMode; import net.osmand.plus.voice.CommandPlayer; import net.osmand.plus.wikipedia.WikiArticleShowImages; @@ -1408,6 +1409,7 @@ public class OsmandSettings { public final OsmandPreference LAST_UPDATES_CARD_REFRESH = new LongPreference(this, "last_updates_card_refresh", 0).makeGlobal(); public final CommonPreference CURRENT_TRACK_COLOR = new IntPreference(this, "current_track_color", 0).makeGlobal().makeShared().cache(); + public final CommonPreference CURRENT_TRACK_COLORIZATION = new EnumStringPreference<>(this, "current_track_colorization", null, GradientScaleType.values()).makeGlobal().makeShared().cache(); public final CommonPreference CURRENT_TRACK_WIDTH = new StringPreference(this, "current_track_width", "").makeGlobal().makeShared().cache(); public final CommonPreference CURRENT_TRACK_SHOW_ARROWS = new BooleanPreference(this, "current_track_show_arrows", false).makeGlobal().makeShared().cache(); public final CommonPreference CURRENT_TRACK_SHOW_START_FINISH = new BooleanPreference(this, "current_track_show_start_finish", true).makeGlobal().makeShared().cache(); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/GpxAppearanceInfo.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/GpxAppearanceInfo.java index 157d5ecb0a..a893e63a41 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/GpxAppearanceInfo.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/GpxAppearanceInfo.java @@ -17,9 +17,9 @@ public class GpxAppearanceInfo { public String width; public GradientScaleType scaleType; public int color; - public int gradientSpeedColor; - public int gradientAltitudeColor; - public int gradientSlopeColor; + public int[] gradientSpeedPalette; + public int[] gradientAltitudePalette; + public int[] gradientSlopePalette; public int splitType; public double splitInterval; public boolean showArrows; @@ -41,9 +41,9 @@ public class GpxAppearanceInfo { splitType = dataItem.getSplitType(); splitInterval = dataItem.getSplitInterval(); scaleType = dataItem.getGradientScaleType(); - gradientSpeedColor = dataItem.getGradientSpeedColor(); - gradientSlopeColor = dataItem.getGradientSlopeColor(); - gradientAltitudeColor = dataItem.getGradientAltitudeColor(); + gradientSpeedPalette = dataItem.getGradientSpeedPalette(); + gradientSlopePalette = dataItem.getGradientSlopePalette(); + gradientAltitudePalette = dataItem.getGradientAltitudePalette(); GPXTrackAnalysis analysis = dataItem.getAnalysis(); if (analysis != null) { @@ -61,9 +61,9 @@ public class GpxAppearanceInfo { writeParam(json, "split_type", GpxSplitType.getSplitTypeByTypeId(splitType).getTypeName()); writeParam(json, "split_interval", splitInterval); writeParam(json, "gradient_scale_type", scaleType); - writeParam(json, GradientScaleType.SPEED.getColorTypeName(), gradientSpeedColor); - writeParam(json, GradientScaleType.SLOPE.getColorTypeName(), gradientSlopeColor); - writeParam(json, GradientScaleType.ALTITUDE.getColorTypeName(), gradientAltitudeColor); + writeParam(json, GradientScaleType.SPEED.getColorTypeName(), Algorithms.gradientPaletteToString(gradientSpeedPalette)); + writeParam(json, GradientScaleType.ALTITUDE.getColorTypeName(), Algorithms.gradientPaletteToString(gradientAltitudePalette)); + writeParam(json, GradientScaleType.SLOPE.getColorTypeName(), Algorithms.gradientPaletteToString(gradientSlopePalette)); writeParam(json, "time_span", timeSpan); writeParam(json, "wpt_points", wptPoints); @@ -79,9 +79,9 @@ public class GpxAppearanceInfo { gpxAppearanceInfo.splitType = GpxSplitType.getSplitTypeByName(json.optString("split_type")).getType(); gpxAppearanceInfo.splitInterval = json.optDouble("split_interval"); gpxAppearanceInfo.scaleType = getScaleType(json.optString("gradient_scale_type")); - gpxAppearanceInfo.gradientSpeedColor = json.optInt(GradientScaleType.SPEED.getColorTypeName()); - gpxAppearanceInfo.gradientSlopeColor = json.optInt(GradientScaleType.SLOPE.getColorTypeName()); - gpxAppearanceInfo.gradientAltitudeColor = json.optInt(GradientScaleType.ALTITUDE.getColorTypeName()); + gpxAppearanceInfo.gradientSpeedPalette = getGradientPalette(json, GradientScaleType.SPEED); + gpxAppearanceInfo.gradientAltitudePalette = getGradientPalette(json, GradientScaleType.ALTITUDE); + gpxAppearanceInfo.gradientSlopePalette = getGradientPalette(json, GradientScaleType.SLOPE); gpxAppearanceInfo.timeSpan = json.optLong("time_span"); gpxAppearanceInfo.wptPoints = json.optInt("wpt_points"); @@ -101,6 +101,10 @@ public class GpxAppearanceInfo { return null; } + private static int[] getGradientPalette(JSONObject json, GradientScaleType scaleType) { + return Algorithms.stringToGradientPalette(json.optString(scaleType.getColorTypeName())); + } + private static void writeParam(@NonNull JSONObject json, @NonNull String name, @Nullable Object value) throws JSONException { if (value instanceof Integer) { if ((Integer) value != 0) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/GpxSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/GpxSettingsItem.java index b9c39026a9..2eca72fba1 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/GpxSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/GpxSettingsItem.java @@ -9,6 +9,7 @@ import net.osmand.plus.GpxDbHelper; import net.osmand.plus.GpxDbHelper.GpxDataItemCallback; import net.osmand.plus.OsmandApplication; import net.osmand.plus.track.GpxSplitType; +import net.osmand.plus.track.GradientScaleType; import org.json.JSONException; import org.json.JSONObject; @@ -83,6 +84,9 @@ public class GpxSettingsItem extends FileSettingsItem { gpxDbHelper.updateShowStartFinish(dataItem, appearanceInfo.showStartFinish); gpxDbHelper.updateSplit(dataItem, splitType, appearanceInfo.splitInterval); gpxDbHelper.updateGradientScaleType(dataItem, appearanceInfo.scaleType); + gpxDbHelper.updateGradientScaleColor(dataItem, GradientScaleType.SPEED, appearanceInfo.gradientSpeedPalette); + gpxDbHelper.updateGradientScaleColor(dataItem, GradientScaleType.ALTITUDE, appearanceInfo.gradientAltitudePalette); + gpxDbHelper.updateGradientScaleColor(dataItem, GradientScaleType.SLOPE, appearanceInfo.gradientSlopePalette); } private void createGpxAppearanceInfo() { diff --git a/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java b/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java index f237c1e721..9b7e681122 100644 --- a/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java +++ b/OsmAnd/src/net/osmand/plus/track/GradientScaleType.java @@ -7,6 +7,7 @@ import androidx.annotation.NonNull; import androidx.annotation.StringRes; import net.osmand.plus.R; +import net.osmand.router.RouteColorize.ColorizationType; public enum GradientScaleType { @@ -44,6 +45,18 @@ public enum GradientScaleType { return ctx.getString(resId); } + public ColorizationType toColorizationType() { + if (this == SPEED) { + return ColorizationType.SPEED; + } else if (this == ALTITUDE) { + return ColorizationType.ELEVATION; + } else if (this == SLOPE) { + return ColorizationType.SLOPE; + } else { + return ColorizationType.NONE; + } + } + public static GradientScaleType getGradientTypeByName(@NonNull String name) { for (GradientScaleType scaleType : GradientScaleType.values()) { if (scaleType.name().equalsIgnoreCase(name)) { diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index 1de2c1c6ee..98831141bc 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -159,6 +159,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement if (selectedGpxFile.isShowCurrentTrack()) { trackDrawInfo = new TrackDrawInfo(true); trackDrawInfo.setColor(app.getSettings().CURRENT_TRACK_COLOR.get()); + trackDrawInfo.setGradientScaleType(app.getSettings().CURRENT_TRACK_COLORIZATION.get()); trackDrawInfo.setWidth(app.getSettings().CURRENT_TRACK_WIDTH.get()); trackDrawInfo.setShowArrows(app.getSettings().CURRENT_TRACK_SHOW_ARROWS.get()); trackDrawInfo.setShowStartFinish(app.getSettings().CURRENT_TRACK_SHOW_START_FINISH.get()); @@ -343,6 +344,8 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo, this); } else if (card instanceof TrackColoringCard) { GradientScaleType currentScaleType = ((TrackColoringCard) card).getSelectedScaleType(); + trackDrawInfo.setGradientScaleType(currentScaleType); + mapActivity.refreshMap(); if (gradientCard != null) { gradientCard.setSelectedScaleType(currentScaleType); } @@ -575,6 +578,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement GPXFile gpxFile = selectedGpxFile.getGpxFile(); if (gpxFile.showCurrentTrack) { app.getSettings().CURRENT_TRACK_COLOR.set(trackDrawInfo.getColor()); + app.getSettings().CURRENT_TRACK_COLORIZATION.set(trackDrawInfo.getGradientScaleType()); app.getSettings().CURRENT_TRACK_WIDTH.set(trackDrawInfo.getWidth()); app.getSettings().CURRENT_TRACK_SHOW_ARROWS.set(trackDrawInfo.isShowArrows()); app.getSettings().CURRENT_TRACK_SHOW_START_FINISH.set(trackDrawInfo.isShowStartFinish());