diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java index bc81ca667e..f444a56b04 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java @@ -4,6 +4,7 @@ import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule; +import net.osmand.data.LatLon; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import net.osmand.util.TransliterationHelper; @@ -37,7 +38,9 @@ public class RouteDataObject { public int[] nameIds; // mixed array [0, height, cumulative_distance height, cumulative_distance, height, ...] - length is length(points)*2 public float[] heightDistanceArray = null; + public float heightByCurrentLocation; private static final Log LOG = PlatformUtil.getLog(RouteDataObject.class); + public RouteDataObject(RouteRegion region) { this.region = region; } @@ -124,7 +127,7 @@ public class RouteDataObject { equals = this.pointTypes[i] == thatObj.pointTypes[i]; } else if (pointTypes[i].length != thatObj.pointTypes[i].length) { equals = false; - } else { + } else { for (int j = 0; j < this.pointTypes[i].length && equals; j++) { String thisTag = region.routeEncodingRules.get(pointTypes[i][j]).getTag(); String thisValue = region.routeEncodingRules.get(pointTypes[i][j]).getValue(); @@ -147,7 +150,7 @@ public class RouteDataObject { equals = this.pointNameTypes[i] == thatObj.pointNameTypes[i]; } else if (pointNameTypes[i].length != thatObj.pointNameTypes[i].length) { equals = false; - } else { + } else { for (int j = 0; j < this.pointNameTypes[i].length && equals; j++) { String thisTag = region.routeEncodingRules.get(pointNameTypes[i][j]).getTag(); String thisValue = pointNames[i][j]; @@ -165,53 +168,67 @@ public class RouteDataObject { } public float[] calculateHeightArray() { - if(heightDistanceArray != null) { + return calculateHeightArray(null); + } + + public float[] calculateHeightArray(LatLon currentLocation) { + if (heightDistanceArray != null) { return heightDistanceArray; } int startHeight = Algorithms.parseIntSilently(getValue("osmand_ele_start"), HEIGHT_UNDEFINED); int endHeight = Algorithms.parseIntSilently(getValue("osmand_ele_end"), startHeight); - if(startHeight == HEIGHT_UNDEFINED) { + if (startHeight == HEIGHT_UNDEFINED) { heightDistanceArray = new float[0]; return heightDistanceArray; } - heightDistanceArray = new float[2*getPointsLength()]; + heightDistanceArray = new float[2 * getPointsLength()]; double plon = 0; double plat = 0; - float prevHeight = startHeight; - for(int k = 0; k < getPointsLength(); k++) { + float prevHeight = heightByCurrentLocation = startHeight; + double prevDistance = 0; + for (int k = 0; k < getPointsLength(); k++) { double lon = MapUtils.get31LongitudeX(getPoint31XTile(k)); double lat = MapUtils.get31LatitudeY(getPoint31YTile(k)); - if(k > 0) { + if (k > 0) { double dd = MapUtils.getDistance(plat, plon, lat, lon); float height = HEIGHT_UNDEFINED; - if(k == getPointsLength() - 1) { + if (k == getPointsLength() - 1) { height = endHeight; } else { String asc = getValue(k, "osmand_ele_asc"); - if(asc != null && asc.length() > 0) { + if (asc != null && asc.length() > 0) { height = (prevHeight + Float.parseFloat(asc)); } else { String desc = getValue(k, "osmand_ele_desc"); - if(desc != null && desc.length() > 0) { + if (desc != null && desc.length() > 0) { height = (prevHeight - Float.parseFloat(desc)); } } } - heightDistanceArray[2*k] = (float) dd; - heightDistanceArray[2*k+1] = height; - if(height != HEIGHT_UNDEFINED) { + heightDistanceArray[2 * k] = (float) dd; + heightDistanceArray[2 * k + 1] = height; + + if (currentLocation != null) { + double distance = MapUtils.getDistance(currentLocation, lat, lon); + if (height != HEIGHT_UNDEFINED && distance < prevDistance) { + prevDistance = distance; + heightByCurrentLocation = height; + } + } + + if (height != HEIGHT_UNDEFINED) { // interpolate undefined double totalDistance = dd; int startUndefined = k; - while(startUndefined - 1 >= 0 && heightDistanceArray[2*(startUndefined - 1)+1] == HEIGHT_UNDEFINED) { - startUndefined --; - totalDistance += heightDistanceArray[2*(startUndefined)]; + while (startUndefined - 1 >= 0 && heightDistanceArray[2 * (startUndefined - 1) + 1] == HEIGHT_UNDEFINED) { + startUndefined--; + totalDistance += heightDistanceArray[2 * (startUndefined)]; } - if(totalDistance > 0) { + if (totalDistance > 0) { double angle = (height - prevHeight) / totalDistance; - for(int j = startUndefined; j < k; j++) { - heightDistanceArray[2*j+1] = (float) ((heightDistanceArray[2*j] * angle) + heightDistanceArray[2*j-1]); + for (int j = startUndefined; j < k; j++) { + heightDistanceArray[2 * j + 1] = (float) ((heightDistanceArray[2 * j] * angle) + heightDistanceArray[2 * j - 1]); } } prevHeight = height; @@ -223,6 +240,9 @@ public class RouteDataObject { } plat = lat; plon = lon; + if (currentLocation != null) { + prevDistance = MapUtils.getDistance(currentLocation, plat, plon); + } } return heightDistanceArray; } @@ -231,34 +251,34 @@ public class RouteDataObject { return id; } - public String getName(){ - if(names != null ) { + public String getName() { + if (names != null) { return names.get(region.nameTypeRule); } return null; } - public String getName(String lang){ + public String getName(String lang) { return getName(lang, false); } - public String getName(String lang, boolean transliterate){ - if(names != null ) { - if(Algorithms.isEmpty(lang)) { + public String getName(String lang, boolean transliterate) { + if (names != null) { + if (Algorithms.isEmpty(lang)) { return names.get(region.nameTypeRule); } int[] kt = names.keys(); - for(int i = 0 ; i < kt.length; i++) { + for (int i = 0; i < kt.length; i++) { int k = kt[i]; - if(region.routeEncodingRules.size() > k) { - if(("name:"+lang).equals(region.routeEncodingRules.get(k).getTag())) { + if (region.routeEncodingRules.size() > k) { + if (("name:" + lang).equals(region.routeEncodingRules.get(k).getTag())) { return names.get(k); } } } String nmDef = names.get(region.nameTypeRule); - if(transliterate && nmDef != null && nmDef.length() > 0) { + if (transliterate && nmDef != null && nmDef.length() > 0) { return TransliterationHelper.transliterate(nmDef); } return nmDef; @@ -279,20 +299,20 @@ public class RouteDataObject { // return getDestinationRef(direction); //} if (names != null) { - if(Algorithms.isEmpty(lang)) { + if (Algorithms.isEmpty(lang)) { return names.get(region.refTypeRule); } int[] kt = names.keys(); - for(int i = 0 ; i < kt.length; i++) { + for (int i = 0; i < kt.length; i++) { int k = kt[i]; - if(region.routeEncodingRules.size() > k) { - if(("ref:"+lang).equals(region.routeEncodingRules.get(k).getTag())) { + if (region.routeEncodingRules.size() > k) { + if (("ref:" + lang).equals(region.routeEncodingRules.get(k).getTag())) { return names.get(k); } } } String refDefault = names.get(region.refTypeRule); - if(transliterate && refDefault != null && refDefault.length() > 0) { + if (transliterate && refDefault != null && refDefault.length() > 0) { return TransliterationHelper.transliterate(refDefault); } return refDefault; @@ -307,13 +327,13 @@ public class RouteDataObject { String refTagDefault = "destination:ref"; String refDefault = null; - for(int i = 0 ; i < kt.length; i++) { + for (int i = 0; i < kt.length; i++) { int k = kt[i]; - if(region.routeEncodingRules.size() > k) { - if(refTag.equals(region.routeEncodingRules.get(k).getTag())) { + if (region.routeEncodingRules.size() > k) { + if (refTag.equals(region.routeEncodingRules.get(k).getTag())) { return names.get(k); } - if(refTagDefault.equals(region.routeEncodingRules.get(k).getTag())) { + if (refTagDefault.equals(region.routeEncodingRules.get(k).getTag())) { refDefault = names.get(k); } } @@ -326,12 +346,12 @@ public class RouteDataObject { return null; } - public String getDestinationName(String lang, boolean transliterate, boolean direction){ + public String getDestinationName(String lang, boolean transliterate, boolean direction) { //Issue #3289: Treat destination:ref like a destination, not like a ref String destRef = ((getDestinationRef(direction) == null) || getDestinationRef(direction).equals(getRef(lang, transliterate, direction))) ? "" : getDestinationRef(direction); String destRef1 = Algorithms.isEmpty(destRef) ? "" : destRef + ", "; - if(names != null) { + if (names != null) { int[] kt = names.keys(); // Issue #3181: Parse destination keys in this order: @@ -341,35 +361,35 @@ public class RouteDataObject { // destination String destinationTagLangFB = "destination:lang:XX"; - if(!Algorithms.isEmpty(lang)) { + if (!Algorithms.isEmpty(lang)) { destinationTagLangFB = (direction == true) ? "destination:lang:" + lang + ":forward" : "destination:lang:" + lang + ":backward"; } String destinationTagFB = (direction == true) ? "destination:forward" : "destination:backward"; String destinationTagLang = "destination:lang:XX"; - if(!Algorithms.isEmpty(lang)) { + if (!Algorithms.isEmpty(lang)) { destinationTagLang = "destination:lang:" + lang; } String destinationTagDefault = "destination"; String destinationDefault = null; - for(int i = 0 ; i < kt.length; i++) { + for (int i = 0; i < kt.length; i++) { int k = kt[i]; - if(region.routeEncodingRules.size() > k) { - if(!Algorithms.isEmpty(lang) && destinationTagLangFB.equals(region.routeEncodingRules.get(k).getTag())) { + if (region.routeEncodingRules.size() > k) { + if (!Algorithms.isEmpty(lang) && destinationTagLangFB.equals(region.routeEncodingRules.get(k).getTag())) { return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k)); } - if(destinationTagFB.equals(region.routeEncodingRules.get(k).getTag())) { + if (destinationTagFB.equals(region.routeEncodingRules.get(k).getTag())) { return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k)); } - if(!Algorithms.isEmpty(lang) && destinationTagLang.equals(region.routeEncodingRules.get(k).getTag())) { + if (!Algorithms.isEmpty(lang) && destinationTagLang.equals(region.routeEncodingRules.get(k).getTag())) { return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k)); } - if(destinationTagDefault.equals(region.routeEncodingRules.get(k).getTag())) { + if (destinationTagDefault.equals(region.routeEncodingRules.get(k).getTag())) { destinationDefault = names.get(k); } } } - if(destinationDefault != null) { + if (destinationDefault != null) { return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault); } } @@ -400,14 +420,14 @@ public class RouteDataObject { RestrictionInfo ri = new RestrictionInfo(); ri.toWay = getRestrictionId(k); ri.type = getRestrictionType(k); - if(restrictionsVia != null && k < restrictionsVia.length) { + if (restrictionsVia != null && k < restrictionsVia.length) { ri.viaWay = restrictionsVia[k]; } return ri; } public long getRestrictionVia(int i) { - if(restrictionsVia != null && restrictionsVia.length > i) { + if (restrictionsVia != null && restrictionsVia.length > i) { return restrictionsVia[i]; } return 0; @@ -441,7 +461,7 @@ public class RouteDataObject { } if (insNames) { pointNames = new String[opointNames.length + 1][]; - pointNameTypes = new int[opointNameTypes.length +1][]; + pointNameTypes = new int[opointNameTypes.length + 1][]; } int i = 0; for (; i < pos; i++) { @@ -590,7 +610,7 @@ public class RouteDataObject { } public static float parseSpeed(String v, float def) { - if(v.equals("none")) { + if (v.equals("none")) { return RouteDataObject.NONE_MAX_SPEED; } else { int i = Algorithms.findFirstNumberEndIndex(v); @@ -614,20 +634,20 @@ public class RouteDataObject { f += Float.parseFloat(v.substring(0, i)); String pref = v.substring(i, v.length()).trim(); float add = 0; - for(int ik = 0; ik < pref.length(); ik++) { - if(Algorithms.isDigit(pref.charAt(ik)) || pref.charAt(ik) == '.' || pref.charAt(ik) == '-') { + for (int ik = 0; ik < pref.length(); ik++) { + if (Algorithms.isDigit(pref.charAt(ik)) || pref.charAt(ik) == '.' || pref.charAt(ik) == '-') { int first = Algorithms.findFirstNumberEndIndex(pref.substring(ik)); - if(first != -1) { + if (first != -1) { add = parseLength(pref.substring(ik), 0); pref = pref.substring(0, ik); } break; } } - if(pref.contains("km")) { + if (pref.contains("km")) { f *= 1000; } - if(pref.contains("\"") || pref.contains("in")) { + if (pref.contains("\"") || pref.contains("in")) { f *= 0.0254; } else if (pref.contains("\'") || pref.contains("ft") || pref.contains("feet")) { // foot to meters @@ -673,27 +693,27 @@ public class RouteDataObject { return false; } - public boolean roundabout(){ + public boolean roundabout() { int sz = types.length; - for(int i=0; i endPoint) { + if (startPoint > endPoint) { int k = endPoint; endPoint = startPoint; startPoint = k; } double d = 0; - for(int k = startPoint; k < endPoint && k < getPointsLength() -1; k++) { + for (int k = startPoint; k < endPoint && k < getPointsLength() - 1; k++) { int x = getPoint31XTile(k); int y = getPoint31YTile(k); int kx = getPoint31XTile(k + 1); @@ -974,16 +994,16 @@ public class RouteDataObject { // translate into meters total += simplifyDistance(x, y, px, py); } while (total < dist); - return -Math.atan2( x - px, y - py ); + return -Math.atan2(x - px, y - py); } private double simplifyDistance(int x, int y, int px, int py) { return Math.abs(px - x) * 0.011d + Math.abs(py - y) * 0.01863d; } - private static void assertTrueLength(String vl, float exp){ + private static void assertTrueLength(String vl, float exp) { float dest = parseLength(vl, 0); - if(exp != dest) { + if (exp != dest) { System.err.println("FAIL " + vl + " " + dest); } else { System.out.println("OK " + vl); @@ -992,24 +1012,24 @@ public class RouteDataObject { public static void main(String[] args) { assertTrueLength("10 km", 10000); - assertTrueLength("0.01 km", 10); - assertTrueLength("0.01 km 10 m", 20); - assertTrueLength("10 m", 10); - assertTrueLength("10m", 10); - assertTrueLength("3.4 m", 3.4f); - assertTrueLength("3.40 m", 3.4f); - assertTrueLength("10 m 10m", 20); - assertTrueLength("14'10\"", 4.5212f); - assertTrueLength("14.5'", 4.4196f); - assertTrueLength("14.5 ft", 4.4196f); - assertTrueLength("14'0\"", 4.2672f); - assertTrueLength("15ft", 4.572f); - assertTrueLength("15 ft 1 in", 4.5974f); - assertTrueLength("4.1 metres", 4.1f); - assertTrueLength("14'0''", 4.2672f); - assertTrueLength("14 feet", 4.2672f); - assertTrueLength("14 mile", 22530.76f); - assertTrueLength("14 cm", 0.14f); + assertTrueLength("0.01 km", 10); + assertTrueLength("0.01 km 10 m", 20); + assertTrueLength("10 m", 10); + assertTrueLength("10m", 10); + assertTrueLength("3.4 m", 3.4f); + assertTrueLength("3.40 m", 3.4f); + assertTrueLength("10 m 10m", 20); + assertTrueLength("14'10\"", 4.5212f); + assertTrueLength("14.5'", 4.4196f); + assertTrueLength("14.5 ft", 4.4196f); + assertTrueLength("14'0\"", 4.2672f); + assertTrueLength("15ft", 4.572f); + assertTrueLength("15 ft 1 in", 4.5974f); + assertTrueLength("4.1 metres", 4.1f); + assertTrueLength("14'0''", 4.2672f); + assertTrueLength("14 feet", 4.2672f); + assertTrueLength("14 mile", 22530.76f); + assertTrueLength("14 cm", 0.14f); // float badValue = -1; // assertTrueLength("none", badValue); @@ -1054,7 +1074,7 @@ public class RouteDataObject { public RestrictionInfo next; // optional to simulate linked list public int length() { - if(next == null) { + if (next == null) { return 1; } return next.length() + 1; @@ -1064,16 +1084,16 @@ public class RouteDataObject { public void setRestriction(int k, long to, int type, long viaWay) { long valto = (to << RouteDataObject.RESTRICTION_SHIFT) | ((long) type & RouteDataObject.RESTRICTION_MASK); restrictions[k] = valto; - if(viaWay != 0) { + if (viaWay != 0) { setRestrictionVia(k, viaWay); } } public void setRestrictionVia(int k, long viaWay) { - if(restrictionsVia != null) { + if (restrictionsVia != null) { long[] nrestrictionsVia = new long[Math.max(k + 1, restrictions.length)]; System.arraycopy(restrictions, 0, nrestrictionsVia, 0, restrictions.length); - restrictionsVia = nrestrictionsVia; + restrictionsVia = nrestrictionsVia; } else { restrictionsVia = new long[k + 1]; } diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java new file mode 100644 index 0000000000..6730965d1f --- /dev/null +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java @@ -0,0 +1,448 @@ +package net.osmand.router; + +import net.osmand.GPXUtilities; +import net.osmand.PlatformUtil; +import net.osmand.osm.edit.Node; +import net.osmand.osm.edit.OsmMapUtils; +import net.osmand.util.MapUtils; +import org.apache.commons.logging.Log; + +import java.util.ArrayList; +import java.util.List; + +public class RouteColorize { + + public int zoom; + public double[] latitudes; + public double[] longitudes; + public double[] values; + public double minValue; + public double maxValue; + public double[][] palette; + + private List dataList; + + 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 enum ValueType { + ELEVATION, + SPEED, + SLOPE, + NONE + } + + private final int VALUE_INDEX = 0; + private final int DECIMAL_COLOR_INDEX = 1;//sRGB decimal format + private final int RED_COLOR_INDEX = 1;//RGB + private final int GREEN_COLOR_INDEX = 2;//RGB + private final int BLUE_COLOR_INDEX = 3;//RGB + private final int ALPHA_COLOR_INDEX = 4;//RGBA + + private ValueType valueType; + + public static int SLOPE_RANGE = 150;//150 meters + private static final double MIN_DIFFERENCE_SLOPE = 0.05d;//5% + + private static final Log LOG = PlatformUtil.getLog(RouteColorize.class); + + /** + * @param minValue can be NaN + * @param maxValue can be NaN + * @param palette array {{value,color},...} - color in sRGB (decimal) format OR {{value,RED,GREEN,BLUE,ALPHA},...} - color in RGBA format + */ + public RouteColorize(int zoom, double[] latitudes, double[] longitudes, double[] values, double minValue, double maxValue, double[][] palette) { + this.zoom = zoom; + this.latitudes = latitudes; + this.longitudes = longitudes; + this.values = values; + this.minValue = minValue; + this.maxValue = maxValue; + this.palette = palette; + + if (Double.isNaN(minValue) || Double.isNaN(maxValue)) { + calculateMinMaxValue(); + } + checkPalette(); + sortPalette(); + } + + /** + * @param type ELEVATION, SPEED, SLOPE + */ + public RouteColorize(int zoom, GPXUtilities.GPXFile gpxFile, ValueType type) { + + if (!gpxFile.hasTrkPt()) { + LOG.warn("GPX file is not consist of track points"); + return; + } + + List latList = new ArrayList<>(); + List lonList = new ArrayList<>(); + List valList = new ArrayList<>(); + 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 == ValueType.SPEED) { + valList.add(p.speed); + } else { + valList.add(p.ele); + } + } + } + } + + this.zoom = zoom; + latitudes = listToArray(latList); + longitudes = listToArray(lonList); + + if (type == ValueType.SLOPE) { + values = calculateSlopesByElevations(latitudes, longitudes, listToArray(valList), SLOPE_RANGE); + } else { + values = listToArray(valList); + } + + calculateMinMaxValue(); + valueType = type; + checkPalette(); + sortPalette(); + } + + /** + * Calculate slopes from elevations needs for right colorizing + * + * @param slopeRange - in what range calculate the derivative, usually we used 150 meters + * @return slopes array, in the begin and the end present NaN values! + */ + public double[] calculateSlopesByElevations(double[] latitudes, double[] longitudes, double[] elevations, double slopeRange) { + + double[] newElevations = elevations; + for (int i = 2; i < elevations.length - 2; i++) { + newElevations[i] = elevations[i - 2] + + elevations[i - 1] + + elevations[i] + + elevations[i + 1] + + elevations[i + 2]; + newElevations[i] /= 5; + } + elevations = newElevations; + + double[] slopes = new double[elevations.length]; + if (latitudes.length != longitudes.length || latitudes.length != elevations.length) { + LOG.warn("Sizes of arrays latitudes, longitudes and values are not match"); + return slopes; + } + + double[] distances = new double[elevations.length]; + double totalDistance = 0.0d; + distances[0] = totalDistance; + for (int i = 0; i < elevations.length - 1; i++) { + totalDistance += MapUtils.getDistance(latitudes[i], longitudes[i], latitudes[i + 1], longitudes[i + 1]); + distances[i + 1] = totalDistance; + } + + for (int i = 0; i < elevations.length; i++) { + if (distances[i] < slopeRange / 2 || distances[i] > totalDistance - slopeRange / 2) { + slopes[i] = Double.NaN; + } else { + double[] arg = findDerivativeArguments(distances, elevations, i, slopeRange); + slopes[i] = (arg[1] - arg[0]) / (arg[3] - arg[2]); + } + } + return slopes; + } + + public List getResult(boolean simplify) { + List result = new ArrayList<>(); + if (simplify) { + result = simplify(); + } else { + for (int i = 0; i < latitudes.length; i++) { + result.add(new RouteColorizationPoint(i, latitudes[i], longitudes[i], values[i])); + } + } + for (RouteColorizationPoint data : result) { + data.color = getColorByValue(data.val); + } + return result; + } + + public int getColorByValue(double value) { + if (Double.isNaN(value)) { + value = (minValue + maxValue) / 2; + } + for (int i = 0; i < palette.length - 1; i++) { + if (value == palette[i][VALUE_INDEX]) + return (int) palette[i][DECIMAL_COLOR_INDEX]; + if (value >= palette[i][VALUE_INDEX] && value <= palette[i + 1][VALUE_INDEX]) { + int minPaletteColor = (int) palette[i][DECIMAL_COLOR_INDEX]; + int maxPaletteColor = (int) palette[i + 1][DECIMAL_COLOR_INDEX]; + double minPaletteValue = palette[i][VALUE_INDEX]; + double maxPaletteValue = palette[i + 1][VALUE_INDEX]; + double percent = (value - minPaletteValue) / (maxPaletteValue - minPaletteValue); + double resultRed = getRed(minPaletteColor) + percent * (getRed(maxPaletteColor) - getRed(minPaletteColor)); + double resultGreen = getGreen(minPaletteColor) + percent * (getGreen(maxPaletteColor) - getGreen(minPaletteColor)); + double resultBlue = getBlue(minPaletteColor) + percent * (getBlue(maxPaletteColor) - getBlue(minPaletteColor)); + double resultAlpha = getAlpha(minPaletteColor) + percent * (getAlpha(maxPaletteColor) - getAlpha(minPaletteColor)); + return rgbaToDecimal((int) resultRed, (int) resultGreen, (int) resultBlue, (int) resultAlpha); + } + } + return getDefaultColor(); + } + + public void setPalette(double[][] palette) { + this.palette = palette; + checkPalette(); + sortPalette(); + } + + private int getDefaultColor() { + return rgbaToDecimal(0, 0, 0, 0); + } + + private List simplify() { + if (dataList == null) { + dataList = new ArrayList<>(); + for (int i = 0; i < latitudes.length; i++) { + //System.out.println(latitudes[i] + " " + longitudes[i] + " " + values[i]); + dataList.add(new RouteColorizationPoint(i, latitudes[i], longitudes[i], values[i])); + } + } + List nodes = new ArrayList<>(); + List result = new ArrayList<>(); + for (RouteColorizationPoint data : dataList) { + nodes.add(new net.osmand.osm.edit.Node(data.lat, data.lon, data.id)); + } + OsmMapUtils.simplifyDouglasPeucker(nodes, zoom + 5, 1, result, true); + + List simplified = new ArrayList<>(); + + for (int i = 1; i < result.size() - 1; i++) { + int prevId = (int) result.get(i - 1).getId(); + int currentId = (int) result.get(i).getId(); + List sublist = dataList.subList(prevId, currentId); + simplified.addAll(getExtremums(sublist)); + } + return simplified; + } + + private List getExtremums(List subDataList) { + if (subDataList.size() <= 2) { + return subDataList; + } + + List result = new ArrayList<>(); + double min; + double max; + min = max = subDataList.get(0).val; + for (RouteColorizationPoint pt : subDataList) { + if (min > pt.val) { + min = pt.val; + } + if (max < pt.val) { + max = pt.val; + } + } + + double diff = max - min; + + result.add(subDataList.get(0)); + for (int i = 1; i < subDataList.size() - 1; i++) { + double prev = subDataList.get(i - 1).val; + double current = subDataList.get(i).val; + double next = subDataList.get(i + 1).val; + RouteColorizationPoint currentData = subDataList.get(i); + + if ((current > prev && current > next) || (current < prev && current < next) + || (current < prev && current == next) || (current == prev && current < next) + || (current > prev && current == next) || (current == prev && current > next)) { + RouteColorizationPoint prevInResult; + if (result.size() > 0) { + prevInResult = result.get(0); + if (prevInResult.val / diff > MIN_DIFFERENCE_SLOPE) { + result.add(currentData); + } + } else + result.add(currentData); + } + } + result.add(subDataList.get(subDataList.size() - 1)); + return result; + } + + private void checkPalette() { + if (palette == null || palette.length < 2 || palette[0].length < 2 || palette[1].length < 2) { + LOG.info("Will use default palette"); + palette = new double[3][2]; + + double[][] defaultPalette = { + {minValue, GREEN}, + {valueType == ValueType.SLOPE ? 0 : (minValue + maxValue) / 2, YELLOW}, + {maxValue, RED} + }; + palette = defaultPalette; + } + double min; + double max = min = palette[0][VALUE_INDEX]; + int minIndex = 0; + int maxIndex = 0; + double[][] sRGBPalette = new double[palette.length][2]; + for (int i = 0; i < palette.length; i++) { + double[] p = palette[i]; + if (p.length == 2) { + sRGBPalette[i] = p; + } else if (p.length == 4) { + int color = rgbaToDecimal((int) p[RED_COLOR_INDEX], (int) p[GREEN_COLOR_INDEX], (int) p[BLUE_COLOR_INDEX], 255); + sRGBPalette[i] = new double[]{p[VALUE_INDEX], color}; + } else if (p.length >= 5) { + int color = rgbaToDecimal((int) p[RED_COLOR_INDEX], (int) p[GREEN_COLOR_INDEX], (int) p[BLUE_COLOR_INDEX], (int) p[ALPHA_COLOR_INDEX]); + sRGBPalette[i] = new double[]{p[VALUE_INDEX], color}; + } + if (p[VALUE_INDEX] > max) { + max = p[VALUE_INDEX]; + maxIndex = i; + } + if (p[VALUE_INDEX] < min) { + min = p[VALUE_INDEX]; + minIndex = i; + } + } + palette = sRGBPalette; + if (minValue < min) { + palette[minIndex][VALUE_INDEX] = minValue; + } + if (maxValue > max) { + palette[maxIndex][VALUE_INDEX] = maxValue; + } + } + + private void sortPalette() { + java.util.Arrays.sort(palette, new java.util.Comparator() { + public int compare(double[] a, double[] b) { + return Double.compare(a[VALUE_INDEX], b[VALUE_INDEX]); + } + }); + } + + /** + * @return double[minElevation, maxElevation, minDist, maxDist] + */ + private double[] findDerivativeArguments(double[] distances, double[] elevations, int index, double slopeRange) { + double[] result = new double[4]; + double minDist = distances[index] - slopeRange / 2; + double maxDist = distances[index] + slopeRange / 2; + result[0] = Double.NaN; + result[1] = Double.NaN; + result[2] = minDist; + result[3] = maxDist; + int closestMaxIndex = -1; + int closestMinIndex = -1; + for (int i = index; i < distances.length; i++) { + if (distances[i] == maxDist) { + result[1] = elevations[i]; + break; + } + if (distances[i] > maxDist) { + closestMaxIndex = i; + break; + } + } + for (int i = index; i >= 0; i--) { + if (distances[i] == minDist) { + result[0] = elevations[i]; + break; + } + if (distances[i] < minDist) { + closestMinIndex = i; + break; + } + } + if (closestMaxIndex > 0) { + double diff = distances[closestMaxIndex] - distances[closestMaxIndex - 1]; + double coef = (maxDist - distances[closestMaxIndex - 1]) / diff; + if (coef > 1 || coef < 0) { + LOG.warn("Coefficient fo max must be 0..1 , coef=" + coef); + } + result[1] = (1 - coef) * elevations[closestMaxIndex - 1] + coef * elevations[closestMaxIndex]; + } + if (closestMinIndex >= 0) { + double diff = distances[closestMinIndex + 1] - distances[closestMinIndex]; + double coef = (minDist - distances[closestMinIndex]) / diff; + if (coef > 1 || coef < 0) { + LOG.warn("Coefficient for min must be 0..1 , coef=" + coef); + } + result[0] = (1 - coef) * elevations[closestMinIndex] + coef * elevations[closestMinIndex + 1]; + } + if (Double.isNaN(result[0]) || Double.isNaN(result[1])) { + LOG.warn("Elevations wasn't calculated"); + } + return result; + } + + private void calculateMinMaxValue() { + if (values.length == 0) + return; + minValue = maxValue = Double.NaN; + for (double value : values) { + if ((Double.isNaN(maxValue) || Double.isNaN(minValue)) && !Double.isNaN(value)) + maxValue = minValue = value; + if (minValue > value) + minValue = value; + if (maxValue < value) + maxValue = value; + } + } + + private double[] listToArray(List doubleList) { + double[] result = new double[doubleList.size()]; + for (int i = 0; i < doubleList.size(); i++) { + result[i] = doubleList.get(i); + } + return result; + } + + private static int rgbaToDecimal(int r, int g, int b, int a) { + int value = ((a & 0xFF) << 24) | + ((r & 0xFF) << 16) | + ((g & 0xFF) << 8) | + ((b & 0xFF) << 0); + return value; + } + + private int getRed(int value) { + return (value >> 16) & 0xFF; + } + + private int getGreen(int value) { + return (value >> 8) & 0xFF; + } + + private int getBlue(int value) { + return (value >> 0) & 0xFF; + } + + private int getAlpha(int value) { + return (value >> 24) & 0xff; + } + + public static class RouteColorizationPoint { + int id; + public double lat; + public double lon; + public double val; + public int color; + + RouteColorizationPoint(int id, double lat, double lon, double val) { + this.id = id; + this.lat = lat; + this.lon = lon; + this.val = val; + } + } + +} 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 83b7c14b44..36c0034a26 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java @@ -53,6 +53,8 @@ public class Algorithms { public static final int XML_FILE_SIGNATURE = 0x3c3f786d; public static final int OBF_FILE_SIGNATURE = 0x08029001; public static final int SQLITE_FILE_SIGNATURE = 0x53514C69; + public static final int BZIP_FILE_SIGNATURE = 0x425a; + public static final int GZIP_FILE_SIGNATURE = 0x1f8b; public static String normalizeSearchText(String s) { boolean norm = false; @@ -322,6 +324,24 @@ public class Algorithms { return test == ZIP_FILE_SIGNATURE; } + public static boolean checkFileSignature(InputStream inputStream, int fileSignature) throws IOException { + if (inputStream == null) return false; + int firstBytes; + if (isSmallFileSignature(fileSignature)) { + firstBytes = readSmallInt(inputStream); + } else { + firstBytes = readInt(inputStream); + } + if (inputStream.markSupported()) { + inputStream.reset(); + } + return firstBytes == fileSignature; + } + + public static boolean isSmallFileSignature(int fileSignature) { + return fileSignature == BZIP_FILE_SIGNATURE || fileSignature == GZIP_FILE_SIGNATURE; + } + /** * Checks, whether the child directory is a subdirectory of the parent * directory. @@ -358,6 +378,14 @@ public class Algorithms { return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + ch4); } + public static int readSmallInt(InputStream in) throws IOException { + int ch1 = in.read(); + int ch2 = in.read(); + if ((ch1 | ch2) < 0) + throw new EOFException(); + return ((ch1 << 8) + ch2); + } + public static String capitalizeFirstLetterAndLowercase(String s) { if (s != null && s.length() > 1) { // not very efficient algorithm @@ -537,6 +565,13 @@ public class Algorithms { } } + public static ByteArrayInputStream createByteArrayIS(InputStream in) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + streamCopy(in, out); + in.close(); + return new ByteArrayInputStream(out.toByteArray()); + } + @SuppressWarnings("ResultOfMethodCallIgnored") public static void updateAllExistingImgTilesToOsmandFormat(File f) { if (f.isDirectory()) { diff --git a/OsmAnd/res/drawable/ic_action_file_report.xml b/OsmAnd/res/drawable/ic_action_file_report.xml new file mode 100644 index 0000000000..d2da33d3ca --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_file_report.xml @@ -0,0 +1,30 @@ + + + + + + + diff --git a/OsmAnd/res/drawable/ic_action_update.xml b/OsmAnd/res/drawable/ic_action_update.xml new file mode 100644 index 0000000000..eb6037c6ba --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_update.xml @@ -0,0 +1,12 @@ + + + + diff --git a/OsmAnd/res/layout/add_new_favorite_category.xml b/OsmAnd/res/layout/add_new_favorite_category.xml new file mode 100644 index 0000000000..74510f0842 --- /dev/null +++ b/OsmAnd/res/layout/add_new_favorite_category.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml index a346825302..d4d052c868 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml @@ -9,6 +9,7 @@ + + + + \ No newline at end of file diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index e374f5a869..ad8e8a22a1 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -2123,10 +2123,8 @@ عرض مربع الحوار مؤقتاً " حفظ إلى " مكان - عرض/إخفاء المفضلة عرض المفضلة إخفاء المفضلة - عرض/إخفاء نقاط الاهتمام عرض %1$s إخفاء %1$s إضافة فئة @@ -2241,7 +2239,6 @@ \n • إضافة POI ورفعها مباشرة إلى الموقع (أو في وقت لاحق إن كنت غير متصل بالشبكة) \n عدل طلب البحث أو زد النطاق. - عرض/إخفاء ملاحظات OSM إظهار ملاحظات OSM إخفاء ملاحظات OSM مرتبة حسب المسافة @@ -2880,7 +2877,6 @@ تبديل اعرض المزيد المسارات على الخريطة - إظهار/إخفاء مسارات GPX إظهار أو إخفاء مسارات GPX المحددة على الخريطة. إخفاء المسارات عرض المسارات @@ -3072,11 +3068,9 @@ لإظهار أو إخفاء الخطوط الكنتورية على الخريطة. إظهار الخطوط الكنتورية إخفاء الخطوط الكنتورية - إظهار/إخفاء الخطوط الكنتورية لإظهار وإخفاء التضاريس على الخريطة. إظهار التضاريس إخفاء التضاريس - إظهار/إخفاء التضاريس لا يمكن بدء تشغيل أداة تحويل النص إلى كلام. تصدير الوضع وضع أوسماند: %1$s @@ -3559,7 +3553,6 @@ زر لإظهار طبقة التضاريس أو إخفائها على الخريطة. إظهار التضاريس إخفاء التضاريس - إظهارأو إخفاء التضاريس المنحدرات التضاريس تمكين لعرض المنحدرات أو خريطة التضاريس. يمكنك قراءة المزيد عن أنواع الخرائط هذه على موقعنا. @@ -3682,7 +3675,6 @@ يمكنك الوصول إلى هذه الإجراءات عن طريق النقر على زر \"%1$s\". إخفاء وسائل النقل العام إظهار وسائل النقل العام - إظهارأو إخفاء وسائل النقل العام زر لإظهار أو إخفاء وسائل النقل العام على الخريطة. إنشاء أو تعديل نقطة الأهتمام POI مكان الموقف @@ -3750,7 +3742,6 @@ ضبط ارتفاع السفينة يمكنك ضبط ارتفاع الحاوية لتجنب الجسور المنخفضة. ضع في اعتبارك أنه إذا كان الجسر متحركاً ، فسوف نستخدم ارتفاعه في الحالة المفتوحة. تحديد عرض السفينة لتجنب الجسور الضيقة - إظهار/إخفاء مابيلاري إخفاء مابيلاري إظهار مابيلاري إظهار أو إخفاء طبقة مابيلاري على الخريطة. diff --git a/OsmAnd/res/values-az/strings.xml b/OsmAnd/res/values-az/strings.xml index e800999147..78625eeb5d 100644 --- a/OsmAnd/res/values-az/strings.xml +++ b/OsmAnd/res/values-az/strings.xml @@ -741,10 +741,8 @@ Favorit əlavə et " burda saxlandı: " Yer - Favoritləri göstər/gizlət Favoritləri göstər Favoritləri gizlət - POI-ni göstər/gizlət %1$s-i göstər %1$s-i gizlət Kateqoriya əlavə et @@ -754,7 +752,6 @@ Xəritə stilləri Axtarış radiusunu artır Axtarış sorğusunu dəyişin və ya axtarış radiusunu artırın. - OSM qeydlərini göstər və ya gizlət OSM qeydlərini göstər OSM qeydlərini gizlət Bu fəaliyyət düyməsinə toxunulduqda, xəritədə OSM qeydləri göstəriləcək və ya gizlədiləcək. @@ -2152,7 +2149,6 @@ Sil ton metr - Mapillary-ni göstər/gizlət Mapillary-ni gizlət Mapillary-ni göstər %1$s silindi diff --git a/OsmAnd/res/values-b+ast/strings.xml b/OsmAnd/res/values-b+ast/strings.xml index f1815fc169..787572e21b 100644 --- a/OsmAnd/res/values-b+ast/strings.xml +++ b/OsmAnd/res/values-b+ast/strings.xml @@ -539,7 +539,6 @@ Aumentar el radiu de gueta Nun s\'alcontró nada Modifica la consulta o aumenta\'l radiu de gueta. - Alternar notes d\'OSM Tocar esti botón d\'aición amuesa/anubre nel mapa les notes d\'OSM. Plugin Esquema de colores @@ -1114,7 +1113,6 @@ Mou nocherniegu Tocar esti botón d\'aición amuesa/anubre nel mapa los puntos favoritos. Tocar esti botón d\'aición amuesa/anubre nel mapa los PdI. - Amosar/anubrir Favoritos Navegación Esti mensaxe inclúise nel campu de comentarios. Esbilla una estaya opcional. @@ -1308,7 +1306,6 @@ Anovar too (%1$sMB) Camudar l\'estilu del mapa Cambiar al mou día/nueche - Amosar/anubrir PdI Creación d\'elementos Configuración del mapa Puntu 1 diff --git a/OsmAnd/res/values-b+be+Latn/strings.xml b/OsmAnd/res/values-b+be+Latn/strings.xml index 5ae3b5317a..3d0cfd1262 100644 --- a/OsmAnd/res/values-b+be+Latn/strings.xml +++ b/OsmAnd/res/values-b+be+Latn/strings.xml @@ -2017,7 +2017,6 @@ Praparcyjnaj pamiacі %4$s MB (Abmiežavańnie Android %5$s MB, Dalvik %6$s MB). Pavialičyć radyus pošuku Ničoha nie znojdziena Źmianicie pošukavy zapyt abo pavialičcie radyus pošuku. - Pakazać/schavać OSM-natatki Pakazać OSM-natatki Schavać OSM-natatki Nacisk na hetuju knopku pakaža ci schavaje OSM-natatki na mapie. @@ -2156,10 +2155,8 @@ Praparcyjnaj pamiacі %4$s MB (Abmiežavańnie Android %5$s MB, Dalvik %6$s MB). Ukliučyć Holas Dadać pieršy pramiežkavy punkt Pakazać pramiežkavy dyjaloh - Pakazać/schavać upadabanyja Pakazać upadabanyja Schavać upadabanyja - Pakazać/schavać POI Pakazać %1$s Schavać %1$s Dadać katehoryu @@ -2823,7 +2820,6 @@ Praparcyjnaj pamiacі %4$s MB (Abmiežavańnie Android %5$s MB, Dalvik %6$s MB). Pamianiać Pakazać boĺš Adliustroŭvajemyja sliady - Pakazać/schavać GPX-sliady Nacisk na knopku dziejannia pakaža ci schavaje abranyja GPX-sliady na mapie Schavać GPX-sliady Pakazać GPX-sliady diff --git a/OsmAnd/res/values-b+hsb/strings.xml b/OsmAnd/res/values-b+hsb/strings.xml index 242e4465ce..1268fbb09f 100644 --- a/OsmAnd/res/values-b+hsb/strings.xml +++ b/OsmAnd/res/values-b+hsb/strings.xml @@ -912,7 +912,6 @@ Pytanski radius powjetšić Žadyn pytanski wuslědk Změń pytanje abo powjetš jeho radius. - OSM-noticy pokazać/schować OSM-noticy pokazać OSM-noticy schować Sortěrowane po zdalenosći @@ -1021,10 +1020,8 @@ Předchadny dypk dodać Přichodny dypk dodać Nawigaciju zahajić/přetorhnyć - Fawority pokazać/schować Fawority pokazać Fawority schować - POI pokazać/schować %1$s pokazać %1$s schować Kategoriju dodać @@ -1583,10 +1580,8 @@ Změny na OSM Pokazaj wysokostne linije Schowaj wysokostne linije - Wysokostne linije pokazać/schować Pokazaj relief Schowaj relief - Relief pokazać/schować Profil eksportować OsmAnd-profil: %1$s Profil \'%1$s\' hižo eksistuje. Chceš jón přepisać\? diff --git a/OsmAnd/res/values-b+kab/strings.xml b/OsmAnd/res/values-b+kab/strings.xml index 89deec4af6..86cf7e67d3 100644 --- a/OsmAnd/res/values-b+kab/strings.xml +++ b/OsmAnd/res/values-b+kab/strings.xml @@ -1254,7 +1254,6 @@ Fren ameccaq ugar n wanida ara d-yettwasiden ubrid. Abrid ad yettwasiḍen ticki ameccaq gar ubrid akked wadig-ik yugar azal i d-yettwammlen. Iberdan isnawanen - Sken/ffer akal Ffer akal Sken akal Taqeffalt i uskan neɣ tuffra n tissi n wakal n tkarḍa. diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index 1f45267fa8..66488f8900 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -2137,10 +2137,8 @@ Выдаліць дзеянне Сапраўды выдаліць дзеянне \"%s\"\? Месца - Паказаць/схаваць улюбёныя мясціны Паказаць улюбёныя мясціны Схаваць улюбёныя мясціны - Паказаць/схаваць POI Паказаць %1$s Схаваць %1$s Дадаць катэгорыю @@ -2310,7 +2308,6 @@ Павялічыць радыус пошуку Нічога не знойдзена Змяніць пошукавы запыт альбо павялічыць радыус пошуку. - Паказаць/схаваць OSM-нататкі Паказаць OSM-нататкі Схаваць OSM-нататкі Кнопка для паказу / хавання OSM-нататак на мапе. @@ -2892,7 +2889,6 @@ Памяняць Паказаць больш Адлюстроўваемыя сляды - Паказаць/схаваць сляды Кнопка для адлюстравання/хавання абраных слядоў на мапе. Схаваць сляды Паказаць сляды @@ -3316,11 +3312,9 @@ Кнопка для адлюстравання/хавання контурных ліній на мапе. Паказаць контурныя лініі Схаваць контурныя лініі - Паказаць/схаваць контурныя лініі Кнопка для адлюстравання/хавання зацянення рэльефу на мапе. Паказаць зацяненне рэльефу Схаваць зацяненне рэльефу - Паказаць/схаваць зацяненне рэльефу Немагчыма запусціць механізм пераўтварэння тэксту ў гаворку. Экспарт профілю Профіль OsmAnd: %1$s @@ -3437,7 +3431,6 @@ Дадаць профіль %1$s з %2$s Схілы - Паказаць ці схаваць рэльеф Схаваць рэльеф Паказаць рэльеф Выдаліць апісанне @@ -3515,11 +3508,9 @@ Змяніць профіль праграмы Аглядная мапа свету (падрабязная) Схаваць грамадскі транспарт - Паказаць ці схаваць грамадскі транспарт Пералічыць маршрут у выпадку адхілення Выдаліць Вызначце шырыню судна, каб пазбягаць вузкіх мастоў - Паказаць/схаваць Mapillary Схаваць Mapillary Паказаць Mapillary Пераключальнік для паказу альбо хавання пласта Mapillary. diff --git a/OsmAnd/res/values-bg/strings.xml b/OsmAnd/res/values-bg/strings.xml index 868d2d9386..384039cf20 100644 --- a/OsmAnd/res/values-bg/strings.xml +++ b/OsmAnd/res/values-bg/strings.xml @@ -2063,7 +2063,6 @@ Маршрутът ще бъде преизчислен, ако разстоянието от маршрута до текущото местоположение е повече от избраната стойност. %1$s от %2$s Склонове - Показване/скриване на терена Скриване на терена Показване на терена Бутон за показване или скриване на терена върху картата. diff --git a/OsmAnd/res/values-ca/strings.xml b/OsmAnd/res/values-ca/strings.xml index 5bcd59d0b8..cc2aa8afe2 100644 --- a/OsmAnd/res/values-ca/strings.xml +++ b/OsmAnd/res/values-ca/strings.xml @@ -2113,10 +2113,8 @@ El nom de l\'acció directa està duplicat Un commutador per mostrar o amagar els punts Preferits en el mapa. Un commutador per mostrar o amagar els PDIs en el mapa. - Mostra/amaga Preferits Mostra Preferits Amaga Preferits - Mostra/amaga PDI Mostra %1$s Amaga %1$s Afegeix una categoria @@ -2382,7 +2380,6 @@ Compreu i instal·leu el connector \'Corbes de nivell\' per visualitzar una gradació vertical d\'àrees. Baixeu el mapa \'Corbes de nivell\' per utilitzar-les en aquesta zona. Amaga començant pel nivell d\'escala - Mostra o amaga notes OSM Mostra notes OSM Amaga notes OSM Botó que mostra o amaga notes OSM al mapa. @@ -2839,7 +2836,6 @@ Totes les cruïlles Tipus de carretera Sortida a - Mostra/amaga traces Un botó per mostrar o amagar les traces seleccionades al mapa. Amaga les traces Mostra les traces @@ -3215,11 +3211,9 @@ Botó per a mostrar o amagar les corbes de nivell en el mapa. Mostra les corbes de nivell Amaga les corbes de nivell - Mostra/amaga les corbes de nivell Botó per a mostrar o amagar l\'ombrejat de relleu al mapa. Mostra l\'ombrejat de relleu Amaga l\'ombrejat de relleu - Mostra/amaga l\'ombrejat de relleu No es pot iniciar el sistema text a veu. L\'OsmAnd utilitza l\'estàndard UTM, que és molt similar però no idèntic al format UTM NATO. El format seleccionat s\'aplicarà a tota l\'aplicació. @@ -3463,7 +3457,6 @@ Un botó per mostrar o amagar la capa de terreny al mapa. Mostra el terreny Amaga el terreny - Mostra o amaga el relleu Ombrejat del relleu Llegenda Nivells de zoom @@ -3560,7 +3553,6 @@ Podeu indicar l\'alçada del vaixell per evitar ponts baixos. Penseu que si el pont és mòbil, li aplicarem l\'alçada de quan estigui obert. Indiqueu l\'alçada del vaixell per evitar ponts baixos. Penseu que si el pont és mòbil, li aplicarem l\'alçada de quan estigui obert. Indiqueu l\'amplada del vaixell per evitar ponts ajustats - Mostra/amaga Mapil·lary Amaga Mapillary Mostra Mapillary Un commutador per mostrar o amagar la capa de Mapillary al mapa. @@ -3637,7 +3629,6 @@ Compres OsmAnd Perfils de navegació Amaga el transport públic - Mostra o amaga el transport públic Botó que mostra o oculta el transport públic al mapa. Crea o edita PDI Posicions d’aparcament diff --git a/OsmAnd/res/values-cs/strings.xml b/OsmAnd/res/values-cs/strings.xml index 94db359827..aca529b3ac 100644 --- a/OsmAnd/res/values-cs/strings.xml +++ b/OsmAnd/res/values-cs/strings.xml @@ -2117,10 +2117,8 @@ Duplicitní název rychlé akce Tlačítko pro zobrazení nebo skrytí Oblíbených míst na mapě. Tlačítko pro zobrazení nebo skrytí bodů zájmu na mapě. - Zobrazit/skrýt Oblíbená místa Zobrazit oblíbená místa Skrýt Oblíbená místa - Zobrazit/skrýt POI Zobrazit %1$s Skrýt %1$s Přidat kategorii @@ -2276,7 +2274,6 @@ Zvětšit okruh hledání Nic nalezeno Změňte vyhledávací dotaz nebo zvětšete okruh hledání. - Zobrazit nebo skrýt OSM poznámky Oprávnění Nepodařilo se naimportovat soubor. Prosím zkontrolujte, zda má OsmAnd oprávnění ke čtení souboru. Vzdálenost opravená @@ -2843,7 +2840,6 @@ Typy silnic Výjezd na Vyměnit - Zobrazit/skrýt stopy Tlačítko pro zobrazení nebo skrytí vybraných stop na mapě. Skrýt stopy Zobrazit stopy @@ -3255,7 +3251,6 @@ Trasa bude přepočítána, pokud vzdálenost od trasy k aktuální poloze je větší než zvolená hodnota. %1$s z %2$s Svahy - Zobrazit nebo skrýt terén Skrýt terén Zobrazit terén Tlačítko pro zobrazení nebo skrytí vrstvy terénu na mapě. @@ -3459,7 +3454,6 @@ Video poznámky Nastavte výšku plavidla, abyste se vyhnuli nízkým mostům. Mějte na paměti, že u pohyblivých mostů se zohledňuje jejich výška v otevřeném stavu. Nastavte šířku plavidla, abyste se vyhnuli úzkým mostům - Zobrazit/skrýt Mapillary Skrýt Mapillary Zobrazit Mapillary Přepínač pro zobrazení nebo skrytí mapové vrstvy Mapillary. @@ -3641,7 +3635,6 @@ Úvodní panel Skrýt veřejnou dopravu Zobrazit veřejnou dopravu - Zobrazit nebo skrýt veřejnou dopravu Tlačítko pro zobrazení nebo skrytí veřejné dopravy na mapě. Vytvořit nebo upravit bod zájmu Parkovací místa @@ -3758,11 +3751,9 @@ \n \n Tuto změnu můžete aplikovat na všechny profily nebo jen na vybraný profil. - Zobrazit/skrýt stínování svahů Skrýt stínování svahů Zobrazit stínování svahů Tlačítko pro zobrazení nebo skrytí stínování svahů na mapě. - Zobrazit/skrýt vrstevnice Skrýt vrstevnice Zobrazit vrstevnice Tlačítko pro zobrazení nebo skrytí vrstevnic na mapě. diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index c176ef70df..04f3d2785b 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -2123,10 +2123,8 @@ Dublet genvejsnavn En til/fra-knap til at vise eller skjule Favoritpunkter på kortet. En til/fra-knap til at vise eller skjule interessepunkter på kortet. - Vis/skjul Favoritter Vis Favoritter Skjul Favoritter - Vis/skjul intetessepunkt (IP) Vis %1$s Skjul %1$s Tilføj en kategori @@ -2394,7 +2392,6 @@ Skjul fra zoom-niveau Sorteret efter afstand Søg i Favoritter - Vis eller skjul OSM-noter Vis OSM-noter Skjul OSM-noter Knap til at vise eller skjule OSM-noter på kortet. @@ -2849,7 +2846,6 @@ Vejtyper Stå af ved Stig på ved stoppested - Vis/skjul GPX spor En knap til at vise eller skjule valgte GPX-spor på kortet. Skjul GPX spor Vis GPX spor @@ -3269,11 +3265,9 @@ Knap der viser eller skjuler højdekurver på kortet. Vis højdekurver Skjul højdekurver - Vis/skjul højdekurver En knap der viser eller skjuler reliefskygger på kortet. Vis reliefskygger Skjul reliefskygger - Vis/skjul reliefskygger Hvid Tekst-til-tale-programmet kan ikke startes. Simuler positionen ved hjælp af et optaget GPX-spor. @@ -3436,7 +3430,6 @@ Ruten genberegnes, hvis afstanden fra ruten til den aktuelle placering er større end den valgte værdi. %1$s af %2$s Skråninger - Vis/skjul terræn Skjul terræn Vis terræn En knap der viser eller skjuler terrænlag på kortet. @@ -3562,7 +3555,6 @@ OsmAnd køb Skjul offentlig transport Vis offentlig transport - Vis/skjul offentlig transport En knap til at vise eller skjule offentlig transport på kortet. Opret/rediger IP Parkeringsplads @@ -3606,7 +3598,6 @@ Vis eller skjul yderligere kort-detaljer Natkort Tilføj onlinekilde - Vis/skjul Mapillary Skjul Mapillary Vis Mapillary Slet næste destinationspunkt diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 931f8aaa37..f889f5fa19 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -2111,11 +2111,9 @@ Aktionsname Eine Schaltfläche zum Hinzufügen einer Kartenmarkierung in der Bildschirmmitte. Ort - Favoriten ein-/ausblenden Eine Schaltfläche, um eine Audio-Notiz in der Bildschirmmitte einzufügen. Eine Schaltfläche, um eine Video-Notiz in der Bildschirmmitte einzufügen. Eine Schaltfläche, um eine Foto-Notiz in der Bildschirmmitte einzufügen. - POI ein-/ausblenden %1$s anzeigen %1$s ausblenden Kategorie hinzufügen @@ -2386,7 +2384,6 @@ Privatzugang erlauben Zugang zu Privatgrund erlauben. Farbschema - OSM-Hinweise ein- oder ausblenden OSM-Hinweise einblenden OSM-Hinweise ausblenden Schaltfläche zum Ein- oder Ausblenden von OSM-Hinweisen auf der Karte. @@ -2853,7 +2850,6 @@ Von %1$s Schritt für Schritt Straßentypen - Tracks ein-/ausblenden Eine Schaltfläche zum Ein- oder Ausblenden ausgewählter Tracks auf der Karte. Tracks ausblenden Tracks einblenden @@ -3273,11 +3269,9 @@ Schaltfläche zum Ein- und Ausblenden von Höhenlinien auf der Karte. Höhenlinien anzeigen Höhenlinien ausblenden - Höhenlinien ein-/ausblenden Schaltfläche zum Ein- oder Ausblenden der Reliefdarstellung. Relief anzeigen Relief ausblenden - Relief ein-/ausblenden Text-to-Speech-Engine kann nicht gestartet werden. Simulation Ihrer Position mit einem aufgezeichneten GPX-Track. Profil exportieren @@ -3498,7 +3492,6 @@ Eine Schaltfläche zum Ein- und Ausblenden der Geländeebene auf der Karte. Gelände einblenden Gelände ausblenden - Gelände ein- oder ausblenden Relief Zoomstufen Transparenz @@ -3616,7 +3609,6 @@ Sie können auf diese Aktionen zugreifen, indem Sie auf die Schaltfläche \"%1$s\" tippen. Öffentliche Verkehrsmittel ausblenden Öffentliche Verkehrsmittel anzeigen - Öffentliche Verkehrsmittel anzeigen oder ausblenden Schaltfläche zum Ein- oder Ausblenden der öffentlichen Verkehrsmittel auf der Karte. POI erstellen oder bearbeiten Parkpositionen @@ -3689,7 +3681,6 @@ Sie können die Schiffshöhe einstellen, um niedrige Brücken zu vermeiden. Denken Sie daran, wenn die Brücke beweglich ist, werden wir ihre Höhe im offenen Zustand verwenden. Schiffshöhe einstellen, um niedrige Brücken zu vermeiden. Beachten Sie: Wenn die Brücke beweglich ist, verwendet die Berechnung ihre Höhe im geöffneten Zustand. Stellen Sie die Schiffsbreite ein, um schmale Brücken zu vermeiden - Mapillary ein-/ausblenden Mapillary ausblenden Mapillary anzeigen Eine Umschaltfläche zum Ein- oder Ausblenden des Mapillary-Layers auf der Karte. @@ -4035,4 +4026,4 @@ sek Rennsport Erste Ankündigung (größere Distanz) - \ No newline at end of file + diff --git a/OsmAnd/res/values-el/strings.xml b/OsmAnd/res/values-el/strings.xml index 901ae967d1..9846bd658c 100644 --- a/OsmAnd/res/values-el/strings.xml +++ b/OsmAnd/res/values-el/strings.xml @@ -1532,7 +1532,6 @@ Φωτογραφίες με σύνδεση Προσθήκη φωτογραφιών Δεν βρέθηκε τίποτα - Εμφάνιση ή απόκρυψη σημειώσεων OSM Εμφάνιση σημειώσεων OSM Απόκρυψη σημειώσεων OSM Προς @@ -2635,10 +2634,8 @@ Διπλό όνομα γρήγορης ενέργειας Εναλλαγή εμφάνισης ή απόκρυψης των αγαπημένων σημείων στον χάρτη. Εναλλαγή εμφάνισης ή απόκρυψης ΣΕ στον χάρτη. - Εμφάνιση/απόκρυψη αγαπημένων Εμφάνιση αγαπημένων Απόκρυψη αγαπημένων - Εμφάνιση/απόκρυψη ΣΕ Εμφάνιση %1$s Απόκρυψη %1$s Προσθήκη κατηγορίας @@ -2901,7 +2898,6 @@ Αλλαγή Εμφάνιση περισσοτέρων Εμφανιζόμενα ίχνη - Εμφάνιση/απόκρυψη ιχνών GPX Πλήκτρο εμφάνισης ή απόκρυψης επιλεγμένων ιχνών GPX στον χάρτη. Απόκρυψη ιχνών GPX Εμφάνιση ιχνών GPX @@ -3275,11 +3271,9 @@ Πλήκτρο εμφάνισης ή απόκρυψης ισοϋψών γραμμών στον χάρτη. Εμφάνιση ισοϋψών γραμμών Απόκρυψη ισοϋψών γραμμών - Εμφάνιση/Απόκρυψη ισοϋψών γραμμών Εμφάνιση ή απόκρυψη πλήκτρου σκίασης αναγλύφου στον χάρτη. Εμφάνιση σκίασης ανάγλυφου Απόκρυψη σκίασης ανάγλυφου - Εμφάνιση/Απόκρυψη σκίασης ανάγλυφου Αδυναμία εκκίνησης μηχανής κειμένου σε ομιλία. Προσομοίωση της θέσης σας χρησιμοποιώντας καταγεγραμμένη διαδρομή GPX. Εξαγωγή κατατομής (προφίλ) @@ -3497,7 +3491,6 @@ Μπορείτε να ορίσετε ύψος σκάφους για να αποφύγετε χαμηλές γέφυρες. Σημειώστε ότι εάν η γέφυρα είναι κινητή, θα χρησιμοποιηθεί το ύψος της ανοικτής κατάστασης. Ορίστε ύψος σκάφος για αποφυγή χαμηλών γεφυρών. Σημειώστε ότι εάν η γέφυρα είναι κινητή, θα χρησιμοποιηθεί το ύψος της στην ανοικτή κατάσταση. Ορίστε πλάτος σκάφους για αποφυγή στενών γεφυρών - Εμφάνιση/Απόκρυψη Mapillary Απόκρυψη Mapillary Εμφάνιση Mapillary Εναλλαγή εμφάνισης ή απόκρυψης της στρώσης Mapillary του χάρτη. @@ -3603,7 +3596,6 @@ \n Απόκρυψη δημόσιων συγκοινωνιών Εμφάνιση δημόσιων συγκοινωνιών - Εμφάνιση/απόκρυψη δημόσιων συγκοινωνιών Πλήκτρο εμφάνισης ή απόκρυψης δημόσιων συγκοινωνιών στον χάρτη. Δημιουργία / Επεξεργασία ΣΕ Θέσεις στάθμευσης @@ -3715,7 +3707,6 @@ Η διαδρομή θα επανυπολογιστεί εάν η απόσταση από τη διαδρομή στην τρέχουσα θέση είναι μεγαλύτερη από την επιλεγμένη τιμή. %1$s από %2$s Πλαγιές - Εμφάνιση / απόκρυψη εδάφους Απόκρυψη εδάφους Εμφάνιση εδάφους Ένα πλήκτρο εμφάνισης ή απόκρυψης της στρώσης εδάφους στον χάρτη. diff --git a/OsmAnd/res/values-en-rGB/strings.xml b/OsmAnd/res/values-en-rGB/strings.xml index 97aedb7ad8..1d0a01a412 100644 --- a/OsmAnd/res/values-en-rGB/strings.xml +++ b/OsmAnd/res/values-en-rGB/strings.xml @@ -96,7 +96,6 @@ Tapping the action button will add a map marker at the screen centre location. Tapping the action button will add a GPX waypoint at the screen centre location. Tapping the action button will show or hide the favourite points on the map. - Show/hide favourites Show Favourites Hide Favourites Category to save the Favourite in: diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index f8442229c2..5eecbe842e 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -2117,10 +2117,8 @@ Duplikata nomo de rapida ago Butono por montri/kaŝi ŝatatajn ejojn sur la mapo. Butono por montri/kaŝi interesejojn sur la mapo. - Montri/kaŝi ŝatatajn Montri ŝatatajn Kaŝi ŝatatajn - Montri/kaŝi interesejojn Montri %1$s Kaŝi %1$s Aldoni kategorion @@ -2386,7 +2384,6 @@ Kaŝi komence de skal‑nivelo Ordigitaj laŭ distanco Serĉi en ŝatataj - Montri aŭ kaŝi OSM-rimarkojn Montri OSM-rimarkojn Kaŝi OSM-rimarkojn Butono por montri/kaŝi OSM‑rimarkojn sur la mapo. @@ -2842,7 +2839,6 @@ Specoj de vojoj Eliru ĉe Atendu ĉe haltejo - Montri/kaŝi spurojn Butono por montri/kaŝi elektitajn spurojn sur la mapo. Kaŝi spurojn Montri spurojn @@ -3263,11 +3259,9 @@ Butono por montri/kaŝi nivelkurbojn sur la mapo. Montri nivelkurbojn Kaŝi nivelkurbojn - Montri/kaŝi nivelkurbojn Butono por montri/kaŝi nivelombrumon (reliefon) sur la mapo. Montri nivelombrumon Kaŝi nivelombrumon - Montri/kaŝi nivelombrumon Antaŭkalkulas tempon de alveno por vojoj de nekonata speco kaj limigas rapidon por ĉiuj vojoj (povas influi kurs‑difinadon). Ne povas ekigi parolsintezilon. Elporti profilon @@ -3493,7 +3487,6 @@ Mapklarigo Nivelombrumo %1$s el %2$s - Montri aŭ kaŝi teren‑formon Kaŝi teren‑formon Montri teren‑formon Butono por montri/kaŝi tavolon de formo de tereno sur la mapo. @@ -3610,7 +3603,6 @@ Vi povas ekigi tiujn agojn per frapeti la butonon “%1$s”. Kaŝi publikan transporton Montri publikan transporton - Montri aŭ kaŝi publikan transporton Butono por montri/kaŝi publikan transporton sur la mapo. Krei aŭ redakti interesejon Aldoni aŭ forigi ŝatatan ejojn @@ -3679,7 +3671,6 @@ Vi povas enigi alton de via akvoveturilo por eviti malaltajn pontojn. Estu konscia, ke se ponto estas movebla, la alto en ĝia malfermita stato estos uzata. Enigu alton de akvoveturilo por eviti malaltajn pontojn. Estu konscia, ke se ponto estas movebla, la alto en ĝia malfermita stato estos uzata. Enigu larĝon de akvoveturilo por eviti mallarĝajn pontojn - Montri/kaŝi Mapillary Kaŝi Mapillary Montri Mapillary Ŝaltilo por montri aŭ kaŝi tavolon de Mapillary sur la mapo. diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 5ab5e53945..12460550ce 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -2120,10 +2120,8 @@ Nombre de la acción rápida duplicado Un botón que muestra u oculta los puntos favoritos en el mapa. Un botón que muestra u oculta los PDI en el mapa. - Mostrar u ocultar Favoritos Mostrar Favoritos Ocultar Favoritos - Mostrar u ocultar PDI Mostrar %1$s Ocultar %1$s Añadir una categoría @@ -2388,7 +2386,6 @@ Descarga la capa superpuesta del mapa «Sombreado» para mostrar el sombreado vertical. Instala el complemento «Curvas de nivel» para mostrar las áreas verticales graduadas. Ocultar desde el nivel de zoom - Mostrar u ocultar notas de OSM Mostrar notas de OSM Ocultar notas de OSM Un botón que muestra u oculta las notas de OSM en el mapa. @@ -2846,7 +2843,6 @@ Tipos de caminos Bajar en Esperar en la parada - Mostrar u ocultar trazas Un botón que muestra u oculta las trazas elegidas en el mapa. Ocultar trazas Mostrar trazas @@ -3267,11 +3263,9 @@ Un botón que muestra u oculta las curvas de nivel en el mapa. Mostrar curvas de nivel Ocultar curvas de nivel - Mostrar u ocultar curvas de nivel Un botón que muestra u oculta el sombreado de las colinas en el mapa. Mostrar el sombreado Ocultar el sombreado - Mostrar u ocultar el sombreado Imposible iniciar el motor de habla sintetizada. Simular la ubicación usando una traza GPX grabada. Exportar perfil @@ -3495,7 +3489,6 @@ Permite ver el sombreado o el mapa de pendientes. Puedes leer más sobre estos tipos de mapas en nuestro sitio. Sombreado Pendientes - Mostrar u ocultar terreno Ocultar terreno Mostrar terreno Un botón que muestra u oculta la capa del terreno en el mapa. @@ -3614,7 +3607,6 @@ Puedes acceder a estas acciones pulsando el botón «%1$s». Ocultar transporte público Mostrar transporte público - Mostrar u ocultar transporte público Botón que muestra u oculta el transporte público en el mapa. Crear o editar PDI Puestos de estacionamiento @@ -3697,7 +3689,6 @@ Legal Mantener Desinstalar - Mostrar u ocultar Mapillary Ocultar Mapillary Mostrar Mapillary Un botón que alterna la capa de Mapillary en el mapa. diff --git a/OsmAnd/res/values-es-rUS/strings.xml b/OsmAnd/res/values-es-rUS/strings.xml index a231dfc79f..c2f3dbff3b 100644 --- a/OsmAnd/res/values-es-rUS/strings.xml +++ b/OsmAnd/res/values-es-rUS/strings.xml @@ -2120,10 +2120,8 @@ Nombre de la acción rápida duplicado Un botón que muestra u oculta los puntos favoritos en el mapa. Un botón que muestra u oculta los PDI en el mapa. - Mostrar u ocultar Favoritos Mostrar Favoritos Ocultar Favoritos - Mostrar u ocultar PDI Mostrar %1$s Ocultar %1$s Añadir una categoría @@ -2388,7 +2386,6 @@ Descarga la capa superpuesta del mapa «Sombreado» para mostrar el sombreado vertical. Instala el complemento «Curvas de nivel» para mostrar las áreas verticales graduadas. Ocultar desde el nivel de zoom - Mostrar u ocultar notas de OSM Mostrar notas de OSM Ocultar notas de OSM Un botón que muestra u oculta las notas de OSM en el mapa. @@ -2846,7 +2843,6 @@ Tipos de caminos Bajar en Esperar en la parada - Mostrar u ocultar trazas Un botón que muestra u oculta las trazas elegidas en el mapa. Ocultar trazas Mostrar trazas @@ -3266,11 +3262,9 @@ Un botón que muestra u oculta las curvas de nivel en el mapa. Mostrar curvas de nivel Ocultar curvas de nivel - Mostrar u ocultar curvas de nivel Un botón que muestra u oculta el sombreado de las colinas en el mapa. Mostrar el sombreado Ocultar el sombreado - Mostrar u ocultar el sombreado Imposible iniciar el motor de habla sintetizada. Simular la ubicación usando una traza GPX grabada. Exportar perfil @@ -3496,7 +3490,6 @@ La ruta será recalculada si la distancia a la ubicación actual es mayor que el valor elegido. %1$s de %2$s Pendientes - Mostrar u ocultar terreno Ocultar terreno Mostrar terreno Un botón que muestra u oculta la capa del terreno en el mapa. @@ -3614,7 +3607,6 @@ Puedes acceder a estas acciones pulsando el botón «%1$s». Ocultar transporte público Mostrar transporte público - Mostrar u ocultar transporte público Botón que muestra u oculta el transporte público en el mapa. Crear o editar PDI Puestos de estacionamiento @@ -3695,7 +3687,6 @@ \nPulsa en «%2$s», para borrar todos los datos relacionados con los radares de velocidad (alertas, notificaciones y PDI) hasta reinstalar OsmAnd completamente. Mantener Desinstalar - Mostrar u ocultar Mapillary Ocultar Mapillary Mostrar Mapillary Un botón que alterna la capa de Mapillary en el mapa. diff --git a/OsmAnd/res/values-es/strings.xml b/OsmAnd/res/values-es/strings.xml index b0b779d318..7028da0a54 100644 --- a/OsmAnd/res/values-es/strings.xml +++ b/OsmAnd/res/values-es/strings.xml @@ -2117,10 +2117,8 @@ Nombre de la acción rápida duplicado Un botón que muestra u oculta los Favoritos en el mapa. Un botón que muestra u oculta los PDI en el mapa. - Mostrar/ocultar Favoritos Mostrar Favoritos Ocultar Favoritos - Mostrar/ocultar PDI Mostrar %1$s Ocultar %1$s Añadir una categoría @@ -2382,7 +2380,6 @@ Permite acceder a áreas privadas. Nivel de zoom de pantalla: %1$s Para largas distancias: Añada destinos intermedios si no se encuentra ninguna ruta en 10 minutos. - Mostrar u ocultar notas de OSM Mostrar notas de OSM Ocultar notas de OSM Botón para mostrar u ocultar las notas de OSM en el mapa. @@ -2843,7 +2840,6 @@ Tipos de caminos Bajarse en Esperar en la parada - Mostrar/ocultar trazas Un botón que muestra u oculta las trazas elegidas en el mapa. Ocultar trazas Mostrar trazas @@ -3260,11 +3256,9 @@ Un botón que muestra u oculta las curvas de nivel en el mapa. Mostrar curvas de nivel Ocultar curvas de nivel - Mostrar/ocultar curvas de nivel Un botón que muestra u oculta la sombra de una colina en el mapa. Mostrar el sombreado Ocultar el sombreado - Mostrar/ocultar el sombreado Imposible iniciar el motor de habla sintetizada. Exportar perfil Perfil de OsmAnd: %1$s @@ -3464,7 +3458,6 @@ Recalcular ruta en caso de desvío %1$s de %2$s Cuestas - Mostrar o esconder terreno Esconder terreno Mostrar terreno Un botón para mostrar o esconder una capa de terreno en el mapa. @@ -3513,7 +3506,6 @@ Marcadores de mapa Favoritos Perfiles de navegación - Mostrar u ocultar transporte público Ocultar transporte público Mostrar transporte público Crear o editar POI @@ -3692,7 +3684,6 @@ Puedes establecer la altura del navío para evitar los puentes bajos. Ten en cuenta que si el puente es móvil, usaremos su altura en estado abierto. Fija la altura del navío para evitar los puentes bajos. Ten en cuenta que si el puente es móvil, usaremos su altura en estado abierto. Fija el ancho del navío para evitar puentes estrechos - Mostrar/ocultar Mapillary Ocultar Mapillary Mostrar Mapillary Un conmutador para mostrar u ocultar la capa de Mapillary en el mapa. diff --git a/OsmAnd/res/values-et/strings.xml b/OsmAnd/res/values-et/strings.xml index 7061f624dc..e4c166344e 100644 --- a/OsmAnd/res/values-et/strings.xml +++ b/OsmAnd/res/values-et/strings.xml @@ -162,7 +162,6 @@ Paigalda Mapillary piltide lisamiseks sellesse asukohta kaardil. Siin puuduvad fotod. Taaskäivita otsing - Lülita OSM märkmed sisse või välja Näita OSM märkmed Peida OSM Notes Täname sind tagasiside eest @@ -601,7 +600,6 @@ Pöörangupõhine Välju Sisene peatuses - Kuva/peida rajad Nupp valitud radade kaardil kuvamiseks või peitmiseks. Peida rajad Kuva rajad @@ -993,11 +991,9 @@ Nupp kõrgusjoonte kuvamiseks või peitmiseks kaardil. Kuva kõrgusjooned Peida kõrgusjooned - Kuva/peida kõrgusjooned Nupp künkavarjutuste kuvamiseks või peitmiseks kaardil. Kuva künkavarjutus Peida künkavarjutus - Kuva/peida künkavarjutus Kõnesünteesi mootorit ei saa käivitada. Ekspordi profiil OsmAnd profiil: %1$s @@ -3127,10 +3123,8 @@ Koht Dubleerimise vältimiseks nimetati kiirtegevus ümber %1$s. Kiirtegevuse nime duplikaat - Kuva/peida lemmikud Kuva lemmikud Peida lemmikud - Kuva/peida HP Kuva %1$s Peida %1$s Lisa kategooria @@ -3441,7 +3435,6 @@ Teekonna ümberarvutus, kui kaugus teekonnast praegusesse asukohta on suurem valitud väärtusest. %1$s %2$s-st Nõlvad - Kuva või peida maastik Peida maastik Kuva maastik Nupp maastikukihi kuvamiseks või peitmiseks kaardil. @@ -3530,7 +3523,6 @@ Otsi huvipunktide tüüpe Peida ühistranspordi teave Näita ühistranspordi teavet - Kuva või peida ühistransport Nupp, mis kuvab või peidab ühistranspordiandmed kaardil. Lisa või muuda huvipunkti Öine kaart @@ -3541,7 +3533,6 @@ Madalate sildade vältimiseks saad kirjeldada laeva kõrguse. Palun arvesta, et liikuva silla puhul me kasutame seda kõrgust ka siis, kui sild on avatud. Madalate sildade vältimiseks kirjelda laeva kõrgus. Palun arvesta, et liikuva silla puhul me kasutame seda kõrgust ka siis, kui sild on avatud. Lühikeste sildade vältimiseks kirjelda laeva laius - Näita või peida Mapillary andmed Peida Mapillary andmed Näita Mapillary andmeid Nupp, mis näitab või peidab kaardil Mapillary kihti. diff --git a/OsmAnd/res/values-eu/strings.xml b/OsmAnd/res/values-eu/strings.xml index 44936b286b..4c5c550856 100644 --- a/OsmAnd/res/values-eu/strings.xml +++ b/OsmAnd/res/values-eu/strings.xml @@ -2125,10 +2125,8 @@ Area honi dagokio: %1$s x %2$s Pantailaren erdian aparkaleku bat gehitzeko botoia. " hona gorde da: " Tokia - Erakutsi/ezkutatu gogokoak Erakutsi gogokoak Ezkutatu gogokoak - Erakutsi/ezkutatu POI Erakutsi %1$s Ezkutatu %1$s Gehitu kategoria bat @@ -2269,7 +2267,6 @@ Area honi dagokio: %1$s x %2$s Handitu bilaketaren erradioa Ez da ezer aurkitu Aldatu bilaketa edo handitu erradioa. - Erakutsi edo ezkutatu OSM oharrak Erakutsi OSM oharrak Ezkutatu OSM oharrak Mapan OSM oharrak erakutsi edo ezkutatzeko botoia. @@ -2846,7 +2843,6 @@ Area honi dagokio: %1$s x %2$s Aldatu Erakutsi gehiago Bistaratutako lorratzak - Erakutsi/ezkutatu lorratzak Gehitu tarteko puntua %1$d transferentzia Gehitu irteera eta helburua @@ -3267,11 +3263,9 @@ Area honi dagokio: %1$s x %2$s Sestra-kurbak mapan erakusteko edo ezkutatzeko botoia. Erakutsi sestra-kurbak Ezkutatu sestra-kurbak - Erakutsi/ezkutatu sestra-kurbak Erliebe-itzalak mapan erakutsi edo ezkutatzeko botoia. Erakutsi erliebe-itzalak Ezkutatu erliebe-itzalak - Erakutsi/ezkutatu erliebe-itzalak Ezin da testu-ahots motorra abiarazi. Simulatu zure posizioa grabatutako GPX lorratz bat erabiliz. Esportatu profila @@ -3491,7 +3485,6 @@ Area honi dagokio: %1$s x %2$s Mapako terreno geruza erakutsi edo ezkutatzeko botoia. Erakutsi terrenoa Ezkutatu terrenoa - Erakutsi edo ezkutatu terrenoa Maldak Erliebea Gaitu erliebea edo malda mapa ikusteko. Mapa mota hauei buruz gehiago irakur dezakezu gure gunean @@ -3555,7 +3548,6 @@ Area honi dagokio: %1$s x %2$s Nabigazio profilak Ezkutatu garraio publikoa Erakutsi garraio publikoa - Erakutsi edo ezkutatu garraio publikoa OsmAnd aztarnaria Jarraitu Pertsonalizatu \"Tiradera\", \"Konfiguratu mapa\" eta \"Laster-menua\" ataletan dauden elementu kopurua. @@ -3675,7 +3667,6 @@ Area honi dagokio: %1$s x %2$s metro Erakutsi edo ezkutatu maparen xehetasun gehigarriak Gauerako mapa - Erakutsi/ezkutatu Mapillary Ezkutatu Mapillary Erakutsi Mapillary Egina diff --git a/OsmAnd/res/values-fa/strings.xml b/OsmAnd/res/values-fa/strings.xml index 6c5174e96c..d7b7728f89 100644 --- a/OsmAnd/res/values-fa/strings.xml +++ b/OsmAnd/res/values-fa/strings.xml @@ -2180,10 +2180,8 @@ نام تکراری برای کنش فوری دکمه‌ای برای پنهان/آشکارکردن علاقه‌مندی‌ها روی نقشه. دکمه‌ای برای پنهان/آشکارکردن POIها روی نقشه. - آشکار/پنهان‌کردن علاقه‌مندی‌ها نشان‌دادن علاقه‌مندی‌ها مخفی‌کردن علاقه‌مندی‌ها - آشکار/پنهان‌کردن POIها نشان‌دادن %1$s پنهان‌کردن %1$s افزودن دسته @@ -2288,7 +2286,6 @@ مقصد شما در ناحیه‌ای با دسترسی خصوصی قرار دارد. دسترسی به جاده‌های خصوصی برای این سفر مجاز شود؟ شروع مجدد جست‌وجو چیزی پیدا نشد - آشکار/پنهان‌کردن یادداشت‌های OSM آشکارکردن یادداشت‌های OSM پنهان‌کردن یادداشت‌های OSM دکمه‌ای برای آشکار/پنهان کردن یادداشت‌های OSM بر روی نقشه. @@ -2866,7 +2863,6 @@ نوع جاده‌ها ایستگاه پیاده‌شدن ایستگاه سوارشدن - آشکار/پنهان کردن ردها دکمه‌ای برای آشکار/پنهان کردن ردهای انتخابی بر روی نقشه. پنهان‌کردن ردها آشکارکردن ردها @@ -3286,11 +3282,9 @@ دکمه‌ای برای آشکار/پنهان کردن منحنی‌های میزان روی نقشه. نشان‌دادن منحنی‌های میزان پنهان‌کردن منحنی‌های میزان - آشکار/پنهان کردن منحنی‌های میزان دکمه‌ای برای آشکار/پنهان کردن سایه‌روشن‌ها روی نقشه. نشان‌دادن سایه‌روشن‌ها پنهان‌کردن سایه‌روشن‌ها - آشکار/پنهان کردن سایه‌روشن‌ها شروع موتور متن به گفتار ناموفق بود. موقعیت خود را با استفاده از یک رد GPX ضبط‌شده شبیه‌سازی کنید. پروفایل OsmAnd:‏ %1$s @@ -3523,7 +3517,6 @@ سایه‌روشن %1$s از %2$s شیب‌ها - آشکار یا پنهان کردن ناهمواری‌ها پنهان‌کردن ناهمواری‌ها نمایش ناهمواری‌ها دکمه‌ای برای آشکار یا پنهان کردن لایهٔ ناهمواری‌ها روی نقشه. @@ -3640,7 +3633,6 @@ برای دسترسی به این کنش‌ها می‌توانید روی دکمهٔ «%1$s» بزنید. مخفی‌کردن حمل‌ونقل عمومی نمایش حمل‌ونقل عمومی - آشکار یا پنهان کردن حمل‌ونقل عمومی دکمه‌ای برای آشکار یا پنهان کردن حمل‌ونقل عمومی روی نقشه. با لمس دکمهٔ عملیاتی بین پروفایل‌های انتخاب‌شده جابه‌جا شوید. افزودن پروفایل @@ -3710,7 +3702,6 @@ می‌توانید ارتفاع کشتی را برای پرهیز از پل‌های کوتاه وارد کنید. به یاد داشته باشید که اگر پل متحرک است، در حالت باز نیز ارتفاع کشتی را در نظر می‌گیریم. ارتفاع کشتی را برای پرهیز از پل‌های کوتاه وارد کنید. به یاد داشته باشید که اگر پل متحرک است، در حالت باز نیز ارتفاع کشتی را در نظر می‌گیریم. عرض کشتی را برای پرهیز از پل های باریک وارد کنید - آشکار/پنهان کردن مپیلاری آشکارکردن مپیلاری پنهان‌کردن مپیلاری دکمه‌ای برای آشکار/پنهان کردن لایهٔ مپیلاری روی نقشه. diff --git a/OsmAnd/res/values-fi/strings.xml b/OsmAnd/res/values-fi/strings.xml index 3801bf19b4..53a392d864 100644 --- a/OsmAnd/res/values-fi/strings.xml +++ b/OsmAnd/res/values-fi/strings.xml @@ -1920,10 +1920,8 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t KP lista Viesti Konfiguroi kartta - Näytä/piilota suosikit Näytä suosikit Piilota suosikit - Näytä/piilota KP:t Näytä %1$s Piilota %1$s Lisää luokka @@ -2002,7 +2000,6 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t Mapillary Käynnistä haku uudelleen Mitään ei löytynyt - Näytä/piilota OSM-huomautukset Näytä OSM-huomautukset Piilota OSM-huomautukset Lajiteltu etäisyyden perusteella @@ -2275,7 +2272,6 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t Muuta Näytä lisää Näytetyt jäljet - Näytä/piilota GPX jäljet Profiilin asetukset: Määritä profiili Vaihda profiilia @@ -2306,10 +2302,8 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t OSM-muokkaukset Näytä korkeuskäyrät Piilota korkeuskäyrät - Näytä/piilota korkeuskäyrät Näytä rinnevarjostus Piilota rinnevarjostus - Näytä/piilota rinnevarjostus Vie profiili OsmAnd profiili: %1$s \'%1$s\' on jo olemassa. Korvataanko\? diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 7eec7e78e9..009e95320a 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -2099,10 +2099,8 @@ Emplacement Ce nom existe déjà, l\'action rapide a été renommée en %1$s. Nom d\'action rapide en double - Afficher / masquer les favoris Afficher les favoris Masquer les favoris - Afficher / masquer les points d\'intérêt Afficher %1$s Masquer %1$s Ajouter une catégorie @@ -2305,7 +2303,6 @@ Téléchargez le greffon \'Courbes de niveaux\' pour mieux visualiser le relief. Masquer à partir du niveau de zoom Téléchargez la sur-couche \'Ombrage du relief\' pour mieux visualiser le relief. - Afficher ou masquer les notes OSM Afficher les notes OSM Masquer les notes OSM Bouton pour afficher ou masquer les notes OSM sur la carte. @@ -2834,7 +2831,6 @@ Instructions pas à pas Types de route Sortir à - Afficher / masquer les traces Masquer les traces Afficher les traces Activer les modifications de transports publics en temps réel avec OsmAnd Live. @@ -3255,11 +3251,9 @@ Bouton affichant ou masquant les courbes de niveaux sur la carte. Afficher les courbes de niveaux Masquer les courbes de niveaux - Afficher / masquer les courbes de niveaux Bouton affichant ou masquant l\'ombrage du relief sur la carte. Afficher l\'ombrage du relief Masquer l\'ombrage du relief - Afficher / masquer l\'ombrage du relief Impossible de démarrer le moteur de synthèse vocale. Simulez votre position à l\'aide d\'une trace GPX enregistrée. Exporter le profil @@ -3486,7 +3480,6 @@ Active l\'affichage de l\'ombrage du relief et l\'inclinaison. Vous pouvez en savoir plus sur ces types de cartes sur notre site. Ombrage du relief Pentes - Affiche ou masque le terrain Masquer le terrain Afficher le terrain Un bouton pour afficher ou masquer la couche terrain sur la carte. @@ -3602,7 +3595,6 @@ Vous pouvez accéder à ces actions en appuyant sur le bouton \"%1$s\". Masquer les transports publics Afficher les transports publics - Affiche ou masque les transports publics Bouton pour afficher ou masquer les transports publics sur la carte. Créer ou modifier un PI Emplacements de stationnement @@ -3671,7 +3663,6 @@ Vous pouvez définir la hauteur du navire pour éviter les ponts bas. Souvenez-vous que si le pont est mobile, nous utiliserons sa hauteur en position ouverte. Définir la hauteur du navire afin d\'éviter les ponts bas. Souvenez-vous que si le pont est mobile, nous utiliserons sa hauteur en position ouverte. Définir la largeur du navire pour éviter les ponts étroits - Afficher/masquer Mapillary Masquer Mapillary Afficher Mapillary Bouton pour afficher ou masquer la couche Mapillary sur la carte. diff --git a/OsmAnd/res/values-gl/strings.xml b/OsmAnd/res/values-gl/strings.xml index 31607c9fc5..5f9a1579e7 100644 --- a/OsmAnd/res/values-gl/strings.xml +++ b/OsmAnd/res/values-gl/strings.xml @@ -2087,10 +2087,8 @@ Lon %2$s Duplicidade do nome da acción rápida Un botón que amosa ou agocha os Favoritos no mapa. Un botón que amosa ou agocha os PDI no mapa. - Amosar/Agochar os Favoritos Amosar Favoritos Agochar os Favoritos - Amosar/Agochar os PDI Amosar %1$s Agochar %1$s Engadir unha categoría @@ -2228,7 +2226,6 @@ Lon %2$s Reiniciar procura Aumentar o raio de procura Non se atopou ren - Amosar ou agochar as notas do OSM Amosar notas do OSM Agochar notas do OSM Ordenado por distancia @@ -2853,7 +2850,6 @@ Lon %2$s Trocar Amosar máis Pistas amosadas - Amosar/agochar pistas Un botón que amosa ou agocha as pistas escollidas no mapa. Agochar pistas Amosar pistas @@ -3273,11 +3269,9 @@ Lon %2$s Un botón que amosa ou agocha as curvas de nivel no mapa. Amosar curvas de nivel Agochar curvas de nivel - Amosar/agochar curvas de nivel Un botón que amosa ou agocha a sombra dos outeiros no mapa. Amosar sombreados Agochar sombreados - Amosar/agochar sombreados Non é posíbel comezar o motor de síntese de voz. Simular a túa posición empregando unha pista GPX gravada. Exportar o perfil @@ -3552,7 +3546,6 @@ Lon %2$s A ruta será recalculada se a distancia á localización actual é maior que o valor escollido. %1$s de %2$s Pendentes - Amosar ou agochar terreo Agochar terreo Amosar terreo Un botón que amosa ou agocha a capa do terreo no mapa. @@ -3621,7 +3614,6 @@ Lon %2$s Podes acceder a estas accións premendo no botón “%1$s”. Agochar transporte público Amosar transporte público - Amosar ou agochar transporte público Botón que amosa ou agocha o transporte público no mapa. Crear ou editar PDI Posicións de aparcamento @@ -3691,7 +3683,6 @@ Lon %2$s Podes definir a altura da embarcación para evitar pontes baixas. Lémbrate se a ponte é móbil, empregaremos a súa altura no estado aberto. Define o alto da embarcación para evitar pontes baixas. Lémbrate se a ponte é móbil, empregaremos a súa altura no estado aberto. Estabelecer o largo da embarcación para evitar pontes estreitas - Amosar/agochar o Mapillary Agochar o Mapillary Un botón para amosar ou agochar a capa do Mapillary no mapa. Amosar o Mapillary diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 47a3917779..6c14826ad9 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -2112,10 +2112,8 @@ A gyorsművelet neve kétszer szerepel Gomb, amely a térképen megjeleníti vagy elrejti a Kedvenc helyeket. Gomb, amely a térképen megjeleníti vagy elrejti az érdekes pontokat (POI-kat). - Kedvencek megjelenítése/elrejtése Kedvencek megjelenítése Kedvencek elrejtése - POI-k megjelenítése/elrejtése %1$s megjelenítése %1$s elrejtése Kategória hozzáadása @@ -2239,7 +2237,6 @@ Utca kijelölése itt: %1$s Cím megadása - OSM-jegyzetek megjelenítése / elrejtése OSM-jegyzetek megjelenítése OSM-jegyzetek elrejtése Gomb, amely a térképen megjeleníti vagy elrejti az OSM-jegyzeteket. @@ -2797,7 +2794,6 @@ Részletes navigáció Úttípusok Szálljon le itt: - Nyomvonalak megjelenítése/elrejtése Gomb, amely a térképen megjeleníti vagy elrejti a nyomvonalakat. Nyomvonalak elrejtése Nyomvonalak megjelenítése @@ -3097,10 +3093,8 @@ Biztos, hogy az összes (%1$d) térképet frissíti\? Szintvonalak megjelenítése Szintvonalak elrejtése - Szintvonalak megjelenítése/elrejtése Domborzatárnyékolás megjelenítése Domborzatárnyékolás elrejtése - Domborzatárnyékolás megjelenítése/elrejtése Nyomvonal tárolási mappája A nyomvonalak tárolhatók a \'rec\' mappában, illetve havi vagy napi bontás szerinti mappákban. Nyomvonalak felvétele a \'rec\' mappába @@ -3414,7 +3408,6 @@ Az útvonal újraszámításra kerül, amennyiben az útvonal és a jelenlegi helyzet közötti távolság nagyobb, mint a kiválasztott érték. %1$s a %2$s-ból Lejtők - Domborzat megjelenítése vagy elrejtése Domborzat elrejtése Domborzat megjelenítése Váltógomb, amely a térképen megjeleníti vagy elrejti a domborzati réteget. @@ -3513,7 +3506,6 @@ Nem támogatott művelet: %1$s Tömegközlekedés elrejtése Tömegközlekedés megjelenítése - Tömegközlekedés megjelenítése vagy elrejtése POI készítése vagy módosítása Parkolási pozíció Kedvenc hozzáadása vagy módosítása @@ -3602,7 +3594,6 @@ Adja meg a hajómagasságot az alacsony hidak elkerüléséhez. Ne feledje, amennyiben a híd mozdítható, a nyitott állapotú magasságát vesszük figyelembe. Megadhatja a hajómagasságot az alacsony hidak elkerüléséhez. Ne feledje, amennyiben a híd mozdítható, a nyitott állapotú magasságát vesszük figyelembe. Adja meg a hajószélességet a keskeny hidak elkerüléséhez - Mapillary megjelenítése/elrejtése Mapillary elrejtése Mapillary megjelenítése Váltógomb, amely a térképen megjeleníti vagy elrejti a Mapillary réteget. diff --git a/OsmAnd/res/values-hy/strings.xml b/OsmAnd/res/values-hy/strings.xml index 4d997b73ce..6e8df0fd50 100644 --- a/OsmAnd/res/values-hy/strings.xml +++ b/OsmAnd/res/values-hy/strings.xml @@ -247,7 +247,6 @@ Ավելացնել որոնման շառավղը Ոչինչ չի գտնվել Փոխել հարցումը կամ ավելացնել որոնման շառավիղը։ - Ցույց տալ/թաքցնել OSM նշումները Ցույց տալ OSM նշումները Թաքցնել OSM նշումները Քարտեզի վրա ցույց տալ կամ թաքցնել OSM նշումները կոճակը: @@ -2484,10 +2483,8 @@ Կրկնօրինակ անուն գտնվեց Սեղմելով գործողության կոճակը ցույց կտա կամ կթաքցնի «Սիրված» կետերը քարտեզի վրա: Սեղմելով գործողության կոճակը ցույց կտա կամ կթաքցնի POI կետերը քարտեզի վրա: - Ցուցադրել/թաքցնել «Սիրված»-ը Ցուցադրել «Սիրված»-ը Թաքցնել «Սիրված»-ը - Ցուցադրել/թաքցնել POI Ցուցադրել %1$s Թաքցնել %1$s Ավելացնել կատեգորիա @@ -2870,7 +2867,6 @@ Պահել ակտիվ Ջնջել Որոշ երկրներում արագության վերահսկողության տեսախցիկների ծանուցումը արգելված է օրենքով ։ - Ցույց տալ/Թաքցնել Mapillary Թաքցնել Ցույց տալ Mapillary Անջատիչ - Mapillary շերտը ցույց տալու կամ թաքցնել ու քարտեզի վրա: @@ -2961,7 +2957,6 @@ Նավիգացիոն պրոֆիլներ Թաքցնել հասարակական տրանսպորտը Ցույց տալ հասարակական տրանսպորտը - Ցույց տալ / թաքցնել հասարակական տրանսպորտը Կոճակ, որը ցույց է տալիս կամ թաքցնում է հասարակական տրանսպորտը քարտեզի վրա: Ստեղծել / Խմբագրել POI Ավելացնել / Խմբագրել Սիրվածն-րը diff --git a/OsmAnd/res/values-id/strings.xml b/OsmAnd/res/values-id/strings.xml index 066b53f1b6..8b558c3b81 100644 --- a/OsmAnd/res/values-id/strings.xml +++ b/OsmAnd/res/values-id/strings.xml @@ -233,7 +233,6 @@ Tingkatkan radius pencarian Tidak ada yang ditemukan Ubah kata pencarian atau tingkatkan radius pencarian. - Tampil/sembunyikan Catatan OSM Tampilkan Catatan OSM Sembunyikan Catatan OSM Mengetuk tombol tindakan akan menampilkan atau menyembunyikan Catatan OSM di peta. diff --git a/OsmAnd/res/values-is/strings.xml b/OsmAnd/res/values-is/strings.xml index baf977ae9c..fa58745492 100644 --- a/OsmAnd/res/values-is/strings.xml +++ b/OsmAnd/res/values-is/strings.xml @@ -1801,10 +1801,8 @@ Forstilling á nafni " vistað í " Staður - Birta/Fela eftirlæti Birta eftirlæti Fela eftirlæti - Birta/Fela merkisstaði Sýna %1$s Fela %1$s Bæta við flokki @@ -2049,7 +2047,6 @@ Byrja leit aftur Stækka radíus leitar Ekkert fannst - Birta/fela OSM-minnispunkta Birta OSM-minnispunkta Fela OSM-minnispunkta Raðað eftir vegalengd @@ -2850,7 +2847,6 @@ Gerðir vega Fara útaf við Fara um borð við stöðvunina - Birta/Fela ferla Hnappur til að birta eða fela valda ferla á kortinu. Fela ferla Birta ferla @@ -3270,11 +3266,9 @@ Hnappur til að birta eða fela hæðarlínur á kortinu. Birta hæðarlínur Fela hæðarlínur - Birta/Fela hæðarlínur Hnappur til að birta eða fela hæðaskyggingu á kortinu. Birta hæðaskyggingu Fela hæðaskyggingu - Birta/Fela hæðaskyggingu Gat ekki ræst talgervil. Herma eftir staðsetningu þinni með áður skráðum GPX-ferli. Flytja út snið @@ -3497,7 +3491,6 @@ Virkja til að sjá hæðaskyggingar eða brekkur á korti. Þú getur lesið meira um þessa eiginleika á vefnum okkar. Hæðaskygging Brekkur - Birta eða fela yfirborð Fela yfirborð Sýna yfirborð Hnappur til að birta eða fela yfirborðslag á kortinu. @@ -3610,7 +3603,6 @@ Þú getur komist í þessar aðgerðir með því að ýta á \"%1$s\"-hnappinn. Áskrift - OsmAnd Live Alltaf - Birta eða fela almenningssamgöngur Endurheimta sjálfgefna röð atriða Óstudd tegund Leiðsagnarleiðbeiningar @@ -3672,7 +3664,6 @@ Merktar hraðamyndavélar Halda virku Aðvaranir vegna hraðamyndavéla eru bannaðar með lögum í sumum löndum. - Sýna/fela Mapillary Fela Mapillary Sýna Mapillary Víxlhnappur til að birta eða fela Mapillary-lagið á kortinu. diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index b0fed91a00..e30bfe222d 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -2120,10 +2120,8 @@ Nome dell\'azione veloce duplicato Questo pulsante d’azione mostra o nasconde i preferiti sulla mappa. Questo pulsante azione mostra o nasconde i PDI sulla mappa. - Mostra/nascondi preferiti Mostra preferiti Nascondi preferiti - Mostra/nascondi PDI Mostra %1$s Nascondi %1$s Aggiungi una categoria @@ -2250,7 +2248,6 @@ Aumenta il raggio di ricerca Nessun risultato Cambia la ricerca o aumenta il raggio. - Mostra/nascondi le Note OSM Mostra le note OSM Nascondi le note OSM Toccando il pulsante azione verranno mostrate o nascoste le note OSM sulla mappa. @@ -2829,7 +2826,6 @@ Tipi di strade Mostra di più Tracciati visualizzati - Mostra/nascondi tracce GPX Nascondi Tracciati GPX Mostra Tracciati GPX Modalità %s @@ -3254,11 +3250,9 @@ Un controllo per mostrare o nascondere nella mappa le linee isoipse. Mostra le linee isoipse Nascondi le linee isoipse - Mostra/nascondi le linee isoipse Un controllo per mostrare o nascondere nella mappa le ombreggiature dei rilievi. Mostra l\'ombreggiatura dei rilievi Nascondi l\'ombreggiatura dei rilievi - Mostra/nascondi l\'ombreggiatura dei rilievi Impossibile avviare il motore dal-testo-alla-voce. Simula la mia posizione utilizzando una traccia GPX registrata. Utilizzata per stimare l\'orario d\'arrivo per le strade di tipo sconosciute e come limite di velocità per tutte le strade (può influenzare il calcolo del percorso) @@ -3478,7 +3472,6 @@ Un bottone per mostrare o nascondere la vista rilievo sulla mappa. Mostra rilievo Nascondi rilievo - Mostra/nascondi rilievo Pendenze Ombreggiatura rilievi Puoi avere maggiori informazioni sulle Pendenze in %1$s. @@ -3516,7 +3509,6 @@ Oggetti Nascondi i trasporti pubblici Mostra i trasporti pubblici - Mostra/nascondi i trasporti pubblici Il pulsante mostra o nasconde nella mappa i trasporti pubblici. Crea/Modifica PDI Posizione di parcheggio @@ -3672,7 +3664,6 @@ Puoi mpostare l\'altezza dell\'imbarcazione per evitare ponti bassi. Ricorda che, se il ponte è mobile, useremo la sua altezza da aperto. Imposta l\'altezza dell\'imbarcazione per evitare ponti bassi. Ricorda che, se il ponte è mobile, useremo la sua altezza da aperto. Imposta la larghezza della\"imbarcazione per evitare i ponti stretti - Mostra/nascondi Mapillary Nascondi Mapillary Mostra Mapillary Un pulsante per visualizzare nella mappa o nascondere il livello Mapillary . diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index a9c6fff921..4899a2373e 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -1125,7 +1125,6 @@ הגדלת רדיוס החיפוש לא נמצא כלום עריכת החיפוש או הגדלת הטווח. - הצגה או הסתרה של הערות OSM הצגת הערות OSM הסתרת הערות OSM כפתור להצגה או להסתרה של הערות OSM על המפה. @@ -1649,10 +1648,8 @@ מיקום בורר להצגה או הסתרה של הנקודות המועדפות במפה. בורר להצגה או הסתרה של נקודות עניין במפה. - הצגה/הסתרה של מועדפים הצגת מועדפים הסתרת מועדפים - הצגה/הסרה של נקודות עניין הצגת %1$s הסתרת %1$s הוספת קטגוריה @@ -2843,7 +2840,6 @@ פנייה אחר פנייה סוגי כבישים לצאת ב־ - הצגה/הסתרה של מסלולים כפתור להצגה או הסתרה של המסלולים הנבחרים במפה. הסתרת מסלולים הצגת מסלולים @@ -3259,11 +3255,9 @@ כפתור להצגה או להסתרה של קווי מתאר במפה. הצגת קווי מתאר הסתרת קווי מתאר - הצגה/הסתרה של קווי מתאר כפתור להצגה או הסתרה של הצללות במפה. הצגת הצללה הסתרת הצללה - הצגה/הסתרה של הצללה לא ניתן להפעיל מנוע המרת טקסט לדיבור. הדמיית המיקום שלך באמצעות מסלול GPX שהוקלט מראש. ייצוא פרופיל @@ -3470,7 +3464,6 @@ הצללה %1$s מתוך %2$s מדרונות - הצגה או הסתרה של תוואי שטח הסתרת תוואי שטח הצגת תוואי שטח כפתור להצגה או הסתרה של שכבת תוואי שטח על גבי המפה. @@ -3593,7 +3586,6 @@ ניתן לגשת לפעולות האלו על ידי לחיצה על הכפתור „%1$s”. הסתרת תחבורה ציבורית הצגת תחבורה ציבורית - הצגת או הסתרת תחב״צ כפתור להצגה או הסתרה של תחבורה ציבורית על המפה. יצירה או עריכה של נקודת עניין מקומות חנייה @@ -3686,7 +3678,6 @@ ניתן להגדיר את גובה כלי השיט כדי להימנע מגשרים נמוכים. נא לשים לב שאם הגשר נע, אנו נשתמש בגובהו במצב הפתוח. יש להגדיר את גובה כלי השיט כדי להימנע מגשרים נמוכים. נא לשים לב שאם הגשר נע, אנו נשתמש בגובהו במצב הפתוח. הגדרת רוחב כלי השיט כדי להימנע מגשרים צרים - הצגת/הסתרת Mapillary הסתרת Mapillary הצגת Mapillary מפסק להצגה או הסתרה של שכבת Mapillary על גבי המפה. diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index a5edb2aaeb..bbde03f05b 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -2141,10 +2141,8 @@ POIの更新は利用できません クイックアクション名の重複 マップ画面でのお気に入り地点の表示/非表示の切替が出来ます。 マップ画面でのPOIの表示/非表示の切替が出来ます。 - お気に入りの表示/非表示 お気に入りを表示 お気に入りを非表示 - POIの表示/非表示 %1$sを表示 %1$sを非表示 カテゴリーを追加 @@ -2349,7 +2347,6 @@ POIの更新は利用できません  • オプションで速度と標高表示ができます  • 等高線と山陰の表示(要追加プラグイン) " - OSMメモの表示/非表示 OSMメモを表示 OSMメモを非表示 マップ画面でのOSMメモの表示/非表示を切り替えるボタンです。 @@ -2792,7 +2789,6 @@ POIの更新は利用できません 入れ替え さらに表示 マップ上の経路 - GPX経路の表示/非表示 マップ上にある選択したGPX経路の表示/非表示を切り替えるボタンです。 経路の非表示 経路の表示 @@ -3269,11 +3265,9 @@ POIの更新は利用できません マップ上の等高線の表示/非表示を切り替えられるボタンです。 等高線を表示 等高線を非表示 - 等高線を表示/非表示 マップ上の陰影起伏図の表示/非表示を切り替えられるボタンです。 陰影起伏図を表示 陰影起伏図を非表示 - 陰影起伏図の表示/非表示 テキスト読み上げエンジンを起動できません。 プロファイルのエクスポート OsmAndプロファイル:%1$s @@ -3497,7 +3491,6 @@ POIの更新は利用できません ズームレベル 陰影起伏図 勾配 - 地形を表示/非表示 地形を非表示 地形を表示 マップ上の地形レイヤーの表示/非表示を切り替えるボタンです。 @@ -3510,7 +3503,6 @@ POIの更新は利用できません 最小 公共交通機関を非表示 公共交通機関を表示 - 公共交通機関の表示/非表示 マップ内公共交通機関の表示/非表示を切り替えるボタンです。 POIの作成/編集 駐車位置 @@ -3737,7 +3729,6 @@ POIの更新は利用できません 低い橋を避けるために船の高さを調整できます。橋が可動式の場合は、開いた状態の高さが参照されます。 低い橋を避けるために船の高さを設定します。注:橋が可動式の場合は、開いた状態の高さが参照されます。 狭い橋を避けるために船の幅を設定します - Mapillaryの表示切替 Mapillaryを非表示 Mapillaryを表示 マップ上のMapillaryレイヤーの表示/非表示を切り替えるトグルボタンです。 diff --git a/OsmAnd/res/values-ka/strings.xml b/OsmAnd/res/values-ka/strings.xml index 786b5de97c..843bb16d97 100644 --- a/OsmAnd/res/values-ka/strings.xml +++ b/OsmAnd/res/values-ka/strings.xml @@ -1223,7 +1223,6 @@ ახალი პროფილის ჩაწერა %1$s %2$s-დან დაქანებები - რელიეფის ჩვენება/დამალვა რელიეფის დამალვა რელიეფის ჩვენება რელიეფის შრის საჩვენებელი ღილაკი. @@ -1799,7 +1798,6 @@ %1$d გადმოწერა ბილიკების ჩვენება ბილიკების დამალვა - ბილიკების ჩვენება/დამალვა გამოსვლა %1$s-ით ნაჩვენები ბილიკები @@ -1959,10 +1957,8 @@ რუკის გამართვა %1$s-ის დამალვა %1$s-ის ჩვენება - POI-ს ჩვენება/დამალვა რჩეულების დამალვა რჩეულების ჩვენება - რჩეულების ჩვენება/დამალვა მოქმედების წაშლა მოქმედების დამატება რჩეულის დამატება @@ -2220,7 +2216,6 @@ მიმართულების ისრები მოტოციკლი Enduro მოტორიანი სკუტერი - Mapillary-ის ჩვენება/დამალვა Mapillary-ის დამალვა Mapillary-ის ჩვენება წავშალოთ ყველა\? @@ -2287,7 +2282,6 @@ საწყისი წერტილი პროფილის იმპორტი პროფილის ექსპორტი - ბორცვების დამალვა/ჩვენება ბორცვების დამალვა ბორცვების ჩვენება %1$s კბ @@ -2365,7 +2359,6 @@ როგორ გავხსნათ Wikipedia-ს სტატიები\? მოგესალმებით სატესტო ვერსიაში რუკაზე ისრების ჩვენება - OSM-ჩანაწერების ჩვენება ან დამალვა აკრიფეთ ქალაქის სახელი ან მისამართი %1$s-ის რუკაზე ჩვენება მდებარეობა: @@ -2561,7 +2554,6 @@ შეტყობნებები რუკის დიალოგის ფანჯარა OsmAnd-ის პროფილი: %1$s - კონტურული ხაზების ჩვენება/დამალვა კონტურული ხაზების დამალვა კონტურული ხაზების ჩვენება ყველა რუკის განახლება diff --git a/OsmAnd/res/values-kn/strings.xml b/OsmAnd/res/values-kn/strings.xml index 9ecd3c89bb..fcc64923ac 100644 --- a/OsmAnd/res/values-kn/strings.xml +++ b/OsmAnd/res/values-kn/strings.xml @@ -322,11 +322,9 @@ ನಕ್ಷೆಯಲ್ಲಿ ಬಾಹ್ಯರೇಖೆಗಳನ್ನು ತೋರಿಸಲು ಅಥವಾ ಮರೆಮಾಡಲು ಟಾಗಲ್. ಬಾಹ್ಯರೇಖೆ ರೇಖೆಗಳನ್ನು ತೋರಿಸಿ ಬಾಹ್ಯರೇಖೆ ರೇಖೆಗಳನ್ನು ಮರೆಮಾಡಿ - ಬಾಹ್ಯರೇಖೆಗಳನ್ನು ತೋರಿಸಿ / ಮರೆಮಾಡಿ ನಕ್ಷೆಯಲ್ಲಿ \'ಹಿಲ್ಶೇಡ್\' ಅನ್ನು ತೋರಿಸಲು ಅಥವಾ ಮರೆಮಾಡಲು ಟಾಗಲ್ ಮಾಡಿ. ಹಿಲ್ಶೇಡ್ ತೋರಿಸು ಹಿಲ್ಶೇಡ್ ಅನ್ನು ಮರೆಮಾಡಿ - ಹಿಲ್ಶೇಡ್ ಅನ್ನು ತೋರಿಸಿ / ಮರೆಮಾಡಿ text-to-speech ಎಂಜಿನ್ ಅನ್ನು ಪ್ರಾರಂಭಿಸಲು ಸಾಧ್ಯವಿಲ್ಲ ಪ್ರೊಫೈಲನ್ನು ಬೇರೆಡೆಗೆ ರಫ್ತುಮಾಡಿ OsmAnd ಪ್ರೊಫೈಲ್:%1$s diff --git a/OsmAnd/res/values-lt/strings.xml b/OsmAnd/res/values-lt/strings.xml index eb1d4b98bc..c096fe2a30 100644 --- a/OsmAnd/res/values-lt/strings.xml +++ b/OsmAnd/res/values-lt/strings.xml @@ -2048,7 +2048,6 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka. Pridėti veiksmą Ištrinti veiksmą Vieta - Rodyti/slėpti LV Pridėti kategoriją Pranešimas Žemėlapio stiliai @@ -2069,7 +2068,6 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka. Padidinti paieškos spindulį Nepavyko nieko rasti Pakeiskite paieškos užklausą arba padidinkite paieškos spindulį. - Rodyti/slėpti OSM Pastabas Rodyti OSM Pastabas Slėpti OSM Pastabas Ieškoti parankiniuose @@ -2141,7 +2139,6 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka. Rodyti parankinių dialogą Rodyti tarpinį dialogo langą " įrašytas į " - Rodyti/slėpti parankinius Rodyti Parankinius Slėpti Parankinius Rodyti %1$s @@ -2620,7 +2617,6 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka. Dienos metas Kelių tipai Rodyti daugiau - Rodyti/slėpti GPX pėdsakus Paspaudus šį mygtuką žemėlapyje parodomi arba paslepiami GPX pėdsakai Slėpti GPX pėdsakus Rodyti GPX pėdsakus @@ -2730,7 +2726,6 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka. Atkurti Ieškoti gatvės Matuoti atstumą - Rodyti/paslėpti viešąjį transportą Paslėpti viešąjį transportą Rodyti viešąjį transportą Pridėti profilį diff --git a/OsmAnd/res/values-lv/strings.xml b/OsmAnd/res/values-lv/strings.xml index 7120ce1b02..2d59b4fb2a 100644 --- a/OsmAnd/res/values-lv/strings.xml +++ b/OsmAnd/res/values-lv/strings.xml @@ -2072,10 +2072,8 @@ Apraksta laukumu: %1$s x %2$s Vieta Spiežot darbības pogu, tiks rādīti vai slēpti favorīti. Spiežot darbības pogu, tiks rādīti vai slēpti POI. - Rādīt/nerādīt izlasi Rādīt favorītus Nerādīt izlasi - Rādīt/slēpt POI Rādīt %1$s Paslēpt %1$s Pievienot kategoriju @@ -2202,7 +2200,6 @@ Apraksta laukumu: %1$s x %2$s Paplašināt meklēšanas rādiusu Neko neatrada Meklējiet pēc cita vārda vai palieliniet meklēšanas rādiusu. - Rādīt/nerādīt OSM piezīmes Atļaut piekļūšanu privātajām teritorijām. Maršruta gaitā iespējot kartes pagriešanas animāciju no manas atrašanās vietas. Ieslēdz vai izslēdz automātisko tālummaiņu, atkarībā no kustības ātruma. @@ -2670,7 +2667,6 @@ No Afganistānas līdz Zimbabvei, no Austrālijas līdz ASV, Argentīna, Brazīl Soli pa solim Iziet pie Soliņš pieturā - Rādīt/Slēpt GPX trekus Nospiežot šo pogu, tiek parādīti vai slēpti izvēlētie GPX treki uz kartes Paslēpt GPX trekus Parādīt GPX trekus diff --git a/OsmAnd/res/values-ml/strings.xml b/OsmAnd/res/values-ml/strings.xml index 9b57d104e0..a3d79f3089 100644 --- a/OsmAnd/res/values-ml/strings.xml +++ b/OsmAnd/res/values-ml/strings.xml @@ -1695,7 +1695,6 @@ "വീണ്ടും തെരയുക " "തെരച്ചില്‍ വൃത്തം വലുതാക്കുക " "ഒന്നും കണ്ടെത്താനായില്ല " - "ഓഎസ് എം കുറിപ്പുകള്‍ (നോട്ട്സ്) കാണിക്കുക/കാണിക്കാതിരിക്കുക " ഓഎസ് എം കുറിപ്പുകള്‍ (നോട്ട്സ്) കാണിക്കുക "ഓഎസ് എം കുറിപ്പുകള്‍ (നോട്ട്സ്) കാണിക്കാതിരിക്കുക " ഓഎസ് എം കുറിപ്പുകള്‍ (നോട്ട്സ്) കാണാന്‍/കാണാതിരിക്കാന്‍ ഈ ആക്ഷന്‍ ബട്ടണ്‍ അമത്തുക @@ -2343,10 +2342,8 @@ സ്ഥലം "അതിവേഗ പ്രവൃത്തിയുടെ നാമം ഉപയോഗത്തിലുണ്ട്, ഡ്യൂപ്ലിക്കേഷൻ ഒഴിവാക്കുന്നതിന് %1$s എന്നാക്കി മാറ്റി." ദ്രുത പ്രവർത്തനത്തിന്റെ പേര് ഒന്നിലധികം പകര്‍പ്പിലുണ്ട് - പ്രിയപ്പെട്ടവ കാണിക്കുക / മറയ്ക്കുക പ്രിയപ്പെട്ടവ കാണിക്കുക പ്രിയങ്കരങ്ങൾ മറയ്ക്കുക - POI കാണിക്കുക / മറയ്ക്കുക %1$s കാണിക്കുക %1$s മറയ്ക്കുക ഒരു വിഭാഗം ചേർക്കുക @@ -2650,7 +2647,6 @@ %1$s-ല്‍ പുറത്തേക്ക് എത്തുക സ്റ്റോപ്പിൽ നിന്ന് കയറുക - GPX ട്രാക്കുകൾ കാണിക്കുക / മറയ്ക്കുക "ഈ ബട്ടണ്‍ തെരഞ്ഞെടുത്ത GPX ട്രാക്കുകൾ മാപ്പില്‍ കാണിക്കാന്‍ /മറയ്ക്കാന്‍ ഉപയോഗിക്കാം" GPX ട്രാക്കുകൾ മറയ്ക്കുക GPX ട്രാക്കുകൾ കാണിക്കുക diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index 5d0a58d52d..f26d7030f4 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -1970,11 +1970,9 @@ Kartinnstilling Legg til en kategori Skjul favoritter - Vis/skjul interessepunkt Vis %1$s Skjul %1$s Vis favoritter - Vis/skjul favoritter Sted Legg til favoritt Tale på/av @@ -2132,7 +2130,6 @@ Filtrer bilder etter innsender, dato eller type. Kun aktivt på nærgående forstørrelsesnivå. Installer Mapillary for å legge til bilder i denne kartposisjonen. Foto på gatenivå for alle. Oppdag plasser, samarbeid, fang inn verden. - Vis/skjul OSM-notater Vis OSM-notater Skjul OSM-notater Knapp til å vise eller skjule OSM-notater på kartet. @@ -2852,7 +2849,6 @@ Veityper Gå av på Sitt på stoppet - Vis/skjul spor Knapp for å vise eller skjule valgte spor på kartet. Skjul spor Vis spor @@ -3164,11 +3160,9 @@ Foretrekk veier uten fast dekke framfor med fast dekke for ruting. Vis koter Skjul koter - Vis/skjul koter En knapp for å vise eller skjule relieffskygger på kartet. Vis relieffskygge Skjul relieffskygge - Vis/skjul relieffskygge Kan ikke starte tekst-til-tale-motor. Simuler posisjonen din ved bruk av et innspilt GPX-spor. OsmAnd-profil: %1$s @@ -3393,7 +3387,6 @@ Åpne innstillinger Terreng %1$s av %2$s - Vis eller skjul terreng Skjul terreng Vis terreng Slett beskrivelse @@ -3455,7 +3448,6 @@ Vis offentlig transport Tilbake til redigering Opprett eller rediger interessepunkt - Vis eller skjul offentlig transport Legg til profil Knapp for vising eller skjuling av offentlig transport på kartet. Direkte-til-punkt @@ -3582,7 +3574,6 @@ Du kan sette fartøyhøyde for å unngå lave broer. Hvis broen endrer høyde, brukes høyden i åpen tilstand. Slett nærmeste målpunkt Navngi punktet - Vis/skjul Mapillary Skjul Mapillary Vis Mapillary Peiling diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 5209bca499..1c682d61d9 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -2118,10 +2118,8 @@ Sneltoets-duplicaat Een schakelknop om Favorieten al dan niet te tonen op de kaart. Een schakelknop om POI’s al dan niet op de kaart te tonen. - Favorieten tonen /verbergen Favorieten tonen Favorieten verbergen - POI’s tonen/verbergen %1$s tonen %1$s verbergen Categorie toevoegen @@ -2327,7 +2325,6 @@ \n Naam bevat erg veel hoofdletters, toch doorgaan? Zoek in Favorieten - OSM-opmerkingen tonen of verbergen OSM-opmerkingen tonen OSM-opmerkingen verbergen Knop om OSM-opmerkingen al dan niet te tonen. @@ -2859,7 +2856,6 @@ Wissel Toon meer Getoonde tracks - GPX-tracks tonen/verbergen Een knop om geselecteerde GPX-tracks al dan niet te tonen op de kaart. GPX-tracks verbergen GPX-tracks tonen @@ -3131,11 +3127,9 @@ Knop om hoogtelijnen al dan niet te tonen op de kaart. Hoogtelijnen tonen Hoogtelijnen verbergen - Hoogtelijnen tonen/verbergen Knop om de reliëfschaduw al dan niet te tonen op de kaart. Reliëfschaduw tonen Reliëfschaduw verbergen - Reliëfschaduw tonen/verbergen Track opgeslagen Toon knooppunt van de fietsroutes Hoogtelijnen en reliëfschaduw @@ -3408,7 +3402,6 @@ Kan profiel niet back-uppen. %1$s van %2$s Hellingen - Terrein tonen / verbergen Terrein verbergen Terrein tonen Een knop om de terreinlaag al dan niet te tonen op de kaart. @@ -3445,7 +3438,6 @@ Het toepassen van deze wijzigingen wist de cache van deze rasterkaartbron Stel de hoogte van het vaartuig in Stel de hoogte van het vaartuig in om lage bruggen te vermijden. Let op, als de brug beweegbaar is, gebruiken we de hoogte in geopende toestand. - Mapillary tonen/verbergen Mapillary verbergen Mapillary tonen Een schakelknop om de Mapillary-laag al dan niet te tonen op de kaart. @@ -3563,7 +3555,6 @@ POI-types zoeken OV-informatie verbergen OV-informatie tonen - OV-informatie tonen/verbergen Knop om OV-informatie al dan niet te tonen op de kaart. Favoriet toevoegen / bewerken POI toevoegen / bewerken diff --git a/OsmAnd/res/values-oc/strings.xml b/OsmAnd/res/values-oc/strings.xml index 28149e979a..788aa757e2 100644 --- a/OsmAnd/res/values-oc/strings.xml +++ b/OsmAnd/res/values-oc/strings.xml @@ -136,7 +136,6 @@ De l\'envèrs Mostrar mai Traças vesedoiras - Mòstrar/ Amagar la traça GPS De quichar sus lo boton mòstra ò amaga la traça GPS sus la mapa Amagar la traça GPS Mostrar la traça GPS @@ -484,11 +483,9 @@ Un commutador per mostrar o amagar lei corbas de nivèu sus la mapa. Mostrar lei corbas de nivèu Amagar lei corbas de nivèu - Mòstra/Amaga lei corbas de nivèu Un commutador per mostrar o amagar l\'ombrejat de relèu de la mapa. Mostrar l’ombrejat de relèu Amagar l’ombrejat de relèu - Mòstra/Amaga l’ombrejat de relèu Exportar lo perfiu Perfiu d\'OsmAnd: %1$s Lo perfiu \'%1$s\' existís ja. Lo volètz subrescriure\? diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml index 384f3f73a1..1e00cb7e75 100644 --- a/OsmAnd/res/values-pl/strings.xml +++ b/OsmAnd/res/values-pl/strings.xml @@ -2134,10 +2134,8 @@ Kopia nazwy szybkiej czynności Przełącznik wyświetlania lub ukrywania ulubionych miejsc na mapie. Przełącznik wyświetlania lub ukrywania użytecznych miejsc na mapie. - Przełącz widoczność ulubionych Pokaż Ulubione Ukryj Ulubione - Przełącz widoczność użytecznych miejsc Tworzenie elementów Ta wiadomość uzupełni się w polu komentarza. Wiadomość @@ -2282,7 +2280,6 @@ Zainstaluj wtyczkę \'Poziomice\', aby pokazać stopniowane obszary pionowe. Pobierz mapę \"Cieniowanie Rzeźby Terenu\", by wyświetlić cieniowanie pionowe. Kup i zainstaluj wtyczkę \'Poziomice\', aby pokazać stopniowane obszary pionowe. - Pokaż lub ukryj uwagi OSM Pokaż uwagi OSM Ukryj uwagi OSM Przybliżony zasięg i jakość mapy: @@ -2845,7 +2842,6 @@ Wymień Wyświetl więcej Wyświetlane ślady - Pokaż/Ukryj ślady Przycisk do pokazywania lub ukrywania wybranych śladów na mapie. Ukryj ślady Pokaż ślady @@ -3266,10 +3262,8 @@ Przełącza wyświetlenie poziomic na mapie. Wyświetl poziomice Ukryj poziomice - Przełącz widoczność poziomic Wyświetl cieniowanie terenu Ukryj cieniowanie terenu - Przełącz widoczność cieniowania terenu Przycisk do pokazywania lub ukrywania cieniowania terenu na mapie. Nie można uruchomić mechanizmu zamiany tekstu na mowę. Wspólne @@ -3486,7 +3480,6 @@ Przycisk do wyświetlania lub ukrywania warstwy terenu na mapie. Pokaż teren Ukryj teren - Pokaż lub ukryj teren Nachylenie Włącz, aby wyświetlić cieniowanie wzniesień lub stoków. Możesz przeczytać więcej o tego rodzaju mapach na naszej stronie. Legenda @@ -3613,7 +3606,6 @@ Powrót do edycji Ukryj transport publiczny Pokaż transport publiczny - Pokaż lub ukryj transport publiczny Utwórz lub edytuj użyteczne miejsce Dodaj lub edytuj ulubione miejsce Przycisk akcji przełącza między wybranymi profilami. @@ -3665,7 +3657,6 @@ Ustaw wysokość statku, by unikać niskich mostów. Uwaga: dla mostów zwodzonych liczymy wysokość podniesionego mostu. Ustaw wysokość statku Ustaw szerokość statku, by unikać wąskich mostów - Pokaż/ukryj Mapillary Ukryj Mapillary Pokaż Mapillary Wprowadź szerokość pojazdu, niektóre restrykcje dróg mogą dotyczyć szerokich pojazdów. diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 7a21af4cd6..34bd6feef6 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -2049,7 +2049,6 @@ Aumentar o raio de busca Nada encontrado Modifique o texto da pesquisa ou aumente o raio de busca. - Mostrar ou ocultar notas do OSM Mostrar Anotações do OSM Ocultar notas OSM Botão para mostrar ou ocultar notas do OSM no mapa. @@ -2457,10 +2456,8 @@ Nome de ação rápida duplicado Uma alternância para mostrar ou ocultar os pontos Favoritos no mapa. Alternar para mostrar ou ocultar POIs no mapa. - Mostrar/ocultar favoritos Mostrar Favoritos Ocultar favoritos - Mostrar/ocultar POI Mostrar %1$s Ocultar %1$s Adicionar uma categoria @@ -2841,7 +2838,6 @@ Tipos de estrada Desembarque em Embarque na parada - Mostrar/ocultar trilhas Um botão para mostrar ou ocultar as trilhas selecionadas no mapa. Ocultar trilhas Mostrar trilhas @@ -3259,11 +3255,9 @@ Botão que mostra ou oculta linhas de contorno no mapa. Mostrar curvas de nível Ocultar linhas de contorno - Mostrar/ocultar linhas de contorno Um botão para mostrar ou ocultar sombras de relevo. Mostrar sombras de relevo Ocultar sombras de relevo - Mostrar/ocultar sombras de relevo Não é possível iniciar o mecanismo de conversão de texto em fala. Simule sua posição usando um rasteador GPX gravada. Exportar perfil @@ -3489,7 +3483,6 @@ Sombras de relevo %1$s de %2$s Encostas - Mostrar ou ocultar terreno Ocultar terreno Mostrar terreno Um botão para mostrar ou ocultar a camada do terreno no mapa. @@ -3606,7 +3599,6 @@ Você pode acessar essas ações tocando no botão “%1$s”. Ocultar transporte público Mostrar transporte público - Mostrar ou ocultar transporte público Botão que mostra ou oculta o transporte público no mapa. Criar ou editar POI Posições de estacionamento @@ -3675,7 +3667,6 @@ Você pode definir a altura da embarcação para evitar pontes baixas. Lembre-se, se a ponte for móvel, usaremos sua altura no estado aberto. Defina a altura da embarcação para evitar pontes baixas. Lembre-se, se a ponte for móvel, usaremos sua altura no estado aberto. Defina a largura da embarcação para evitar pontes estreitas - Mostrar/ocultar Mapillary Ocultar Mapillary Mostrar Mapillary Uma alternância para mostrar ou ocultar a camada Mapillary no mapa. diff --git a/OsmAnd/res/values-pt/strings.xml b/OsmAnd/res/values-pt/strings.xml index b5ddfb1f86..d94decabf7 100644 --- a/OsmAnd/res/values-pt/strings.xml +++ b/OsmAnd/res/values-pt/strings.xml @@ -1911,7 +1911,6 @@ Aumentar raio de pesquisa Nada encontrado Altere a pesquisa ou aumente o raio dela. - Mostrar ou ocultar anotações do OSM Mostrar anotações OSM Ocultar anotações do OSM Botão para mostrar ou ocultar anotações OSM no mapa. @@ -2725,10 +2724,8 @@ Nome de ação rápida duplicado Uma alternância para mostrar ou ocultar os pontos favoritos no mapa. Uma alternância para mostrar ou ocultar PIs no mapa. - Mostrar/esconder favoritos Mostrar Favoritos Esconder favoritos - Mostrar/esconder POI Mostrar %1$s Esconder %1$s Adicionar uma categoria @@ -2894,7 +2891,6 @@ Trocar Mostrar mais Trilhos mostrados - Mostrar/ocultar trilhos Um botão para mostrar ou ocultar trilhos selecionados no mapa. Ocultar trilhos Sem elétricos @@ -3286,11 +3282,9 @@ Botão que mostra ou oculta curvas de nível no mapa. Mostrar curvas de nível Ocultar curvas de nível - Mostrar/ocultar curvas de nível Um botão para mostrar ou ocultar sombras de relevo. Mostrar sombras de relevo Ocultar sombras de relevo - Mostrar/ocultar sombras de relevo Não é possível iniciar o mecanismo de conversão de texto em fala. Simule a sua posição usando um caminho GPX gravado. Exportar o perfil @@ -3345,7 +3339,6 @@ Sombras de relevo %1$s de %2$s Pistas - Mostrar ou ocultar terrenos Ocultar terreno Mostrar terreno Um botão para mostrar ou esconder a camada do terreno no mapa. @@ -3593,7 +3586,6 @@ Combinar categorias de POI de categorias diferentes. Toque em trocar para selecionar tudo, toque no lado esquerdo para seleção da categoria. Ocultar o transporte público Mostrar transporte público - Mostrar ou ocultar transportes públicos Botão que mostra ou oculta o transporte público no mapa. Criar ou editar um POI Posições de estacionamento @@ -3712,7 +3704,6 @@ Pode definir a altura da embarcação para evitar pontes baixas. Lembre-se, se a ponte for móvel, usaremos sua altura no estado aberto. Cadeira de rodas para a frente Controlar o nível de ampliação do mapa pelos botões de volume do aparelho. - Mostrar/ocultar Mapillary Desinstalar radares de velocidade Anotaçaõ OSM fechada Desinstalar e reiniciar diff --git a/OsmAnd/res/values-ro/strings.xml b/OsmAnd/res/values-ro/strings.xml index 22bec3c3c9..f216bc900e 100644 --- a/OsmAnd/res/values-ro/strings.xml +++ b/OsmAnd/res/values-ro/strings.xml @@ -1803,7 +1803,6 @@ Măriți aria de căutare Nimic găsit Modifică criteriile de căutare sau mărește aria de căutare. - Comutare note OSM Arată notele OSM Ascunde notele OSM Atingând acest buton de acțiune, se afișează sau se ascund notele OSM de pe hartă. @@ -2204,7 +2203,6 @@ Schimbați Afișați mai multe Trasee afișate - Afișați/Ascundeți traseele GPX Ascundeți traseele GPX Afișați traseele GPX Selectați destinația mai întâi @@ -2383,11 +2381,9 @@ Comută pentru a afișa sau ascunde liniile de contur pe hartă. Afişează conturul liniilor Ascunde conturul liniilor - Afişează-ascunde conturul liniilor Comută pentru a arăta sau ascunde umbrele de pe hartă. Arata si umbrele Ascunde afisarea umbrelor - Afişează/ascunde umbrele Motorul text-to-speech nu porneste. Exportă profilul Profil osmand exportat %1$s @@ -2825,7 +2821,6 @@ tone metrii Adăugare surse online - Afișare/ascundere Mapillary Ascundere Mapillary Afișare Mapillary O comutare pentru a afișa sau ascunde stratul Mapillary pe hartă. diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index b77fe2b33d..629a956ea1 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -40,7 +40,6 @@ Увеличить радиус поиска Ничего не найдено Изменить запрос или увеличить радиус поиска. - Показать/скрыть OSM-заметки Показать OSM-заметки Скрыть OSM-заметки Переключатель отображения OSM-заметок на карте. @@ -147,7 +146,6 @@ Обнаружен дубликат имени Переключатель, чтобы показать или скрыть избранные точки на карте. Переключатель, чтобы показать или скрыть POI на карте. - Показать/скрыть избранные Категория Действия Если оставить это поле пустым, то оно будет автоматически заполнено адресом или названием места. @@ -2260,7 +2258,6 @@ Вы уверены, что хотите удалить действие «%s»\? Показать избранные Скрыть избранные - Показать/скрыть POI Показать %1$s Скрыть %1$s Настройки карты @@ -2868,7 +2865,6 @@ Поменять Показать больше Отображаемые треки - Показать/скрыть треки Скрыть треки Показать треки Время суток @@ -3230,11 +3226,9 @@ Переключатель, показывающая или скрывающая контурные линии на карте. Показать контурные линии Скрыть контурные линии - Показать/скрыть контурные линии Переключатель, чтобы показать или скрыть затенение рельефа на карте. Показать затенение рельефа Скрыть затенение рельефа - Показать/скрыть затенение рельефа Экспорт профиля Профиль OsmAnd: %1$s «%1$s» уже существует. Перезаписать\? @@ -3482,7 +3476,6 @@ Пересчитывать маршрут в случае отклонения %1$s из %2$s Настройка минимального и максимального уровней масштабирования, при которых слой будет отображаться. - Показать или скрыть рельеф Переключатель, чтобы показать или скрыть слой рельефа местности на карте. Показать рельеф Скрыть рельеф @@ -3611,7 +3604,6 @@ Функции, доступные при нажатии кнопки «%1$s». Скрыть общественный транспорт Показать общественный транспорт - Показать/скрыть общественный транспорт Добавить или изменить избранное Создать или изменить POI Возврат к редактированию @@ -3680,7 +3672,6 @@ Вы можете указать высоту судна, чтобы избегать низких мостов. Имейте в виду, что если мост раздвижной, будет использована его высота в открытом состоянии. Укажите высоту судна, чтобы избежать низких мостов. Имейте в виду, что если мост раздвижной, будет использована его высота в открытом состоянии. Укажите ширину судна, чтобы избежать узких мостов - Показать/скрыть Mapillary Скрыть Mapillary Показать Mapillary Переключатель, чтобы показать или скрыть слой Mapillary на карте. diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index 0f5d4c3fdb..800c4709a5 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -2119,10 +2119,8 @@ Ammustra una ventana intermèdia Unu butone pro ammustrare o cuare sos puntos preferidos in sa mapa. Unu butone pro ammustrare o cuare sos PDI in sa mapa. - Ammustra/cua sos preferidos Ammustra sos preferidos Cua sos preferidos - Ammustra/cua sos PDI Ammustra %1$s Cua %1$s Annanghe una categoria @@ -2389,7 +2387,6 @@ Còmpora e installa s\'estensione \'Curvas de Livellu\' pro ammustrare sas àreas verticales graduadas. Chirca in sos preferidos Ordinados pro distàntzia - Ammustra/cua sas notas OSM Ammustra sas notas OSM Cua sas notas OSM Unu butone pro ammustrare o cuare sas Notas OSM in sa mapa. @@ -2844,7 +2841,6 @@ Castas de àndalas Essi in Àrtzia in sa firmada - Ammustra/cua sas rastas Unu butone pro ammustrare o cuare sas rastas ischertadas in sa mapa. Istichi sas rastas Ammustra sas rastas @@ -3264,11 +3260,9 @@ Butone chi ammustrat o cuat sas curvas de livellu in sa mapa. Ammustra sas curvas de livellu Cua sas curvas de livellu - Ammustra/cua sas curvas de livellu Unu butone pro ammustrare o cuare sas umbraduras de sos rilievos in sa mapa. Ammustra sas umbraduras de sos rilievos Cua sas umbraduras de sos rilievos - Ammustra/cua sas umbraduras de sos rilievos Allughidura de su motore de sìntesi vocale fallida. Sìmula sa positzione tua impreende una rasta GPX registrada. Esporta su profilu @@ -3494,7 +3488,6 @@ Umbraduras de sos rilievos %1$s de %2$s Pistas - Ammustra o cua su terrinu Cua su terrinu Ammustra su terrinu Unu butone pro ammustrare o cuare s\'istratu de su terrinu in sa mapa. @@ -3612,7 +3605,6 @@ Podes atzèdere a custas atziones incarchende su butone \"%1$s\". Cua sos trasportos pùblicos Ammustra sos trasportos pùblicos - Ammustra o cua sos trasportos pùblicos Butone pro ammustrare o cuare sos trasportos pùblicos in sa mapa. Crea o modìfica unu PDI Logos de parchègiu @@ -3680,7 +3672,6 @@ Podes impostare s\'artària de sa barca pro evitare sos pontes bassos. Ammenta·ti chi, si su ponte est mòbile, amus a impreare s\'artària sua de cando est abertu. Imposta s\'artària de sa barca pro evitare sos pontes bassos. Ammenta·ti chi, si su ponte est mòbile, amus a impreare s\'artària sua de cando est abertu. Imposta sa largària de sa barca pro evitare pontes astrintos - Ammustra/cua Mapillary Cua Mapillary Ammustra Mapillary Unu butone pro ammustrare o cuare s\'istratu de Mapillary in sa mapa. diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index 2fd8af51aa..77703c92a5 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -2124,10 +2124,8 @@ Duplicitný názov rýchlej akcie Prepínač pre zobrazenie alebo skrytie Obľúbených bodov na mape. Prepínač pre zobrazenie alebo skrytie bodov záujmu na mape. - Zobraziť/skryť Obľúbené body Zobraziť Obľúbené body Skryť Obľúbené body - Zobraziť/skryť body záujmu Zobraziť %1$s Skryť %1$s Pridať kategóriu @@ -2387,7 +2385,6 @@ Stiahnite mapu \"Vrstevnice\" pre tento región. Zoradené podľa vzdialenosti Hľadať v Obľúbených bodoch - Zobraziť alebo skryť OSM poznámky Zobraziť OSM poznámky Skryť OSM poznámky Tlačidlo pre zobrazenie alebo skrytie OSM poznámok na mape. @@ -2844,7 +2841,6 @@ Druhy ciest Vystúpte na Nastúpte na zastávke - Zobraziť/skryť stopy Tlačidlo pre zobrazenie alebo skrytie zvolených stôp na mape. Skryť stopy Zobraziť stopy @@ -3274,11 +3270,9 @@ Tlačidlo pre zobrazenie alebo skrytie vrstevníc na mape. Zobraziť vrstevnice Skryť vrstevnice - Zobraziť/skryť vrstevnice Tlačidlo pre zobrazenie alebo skrytie tieňovaných svahov na mape. Zobraziť tieňované svahy Skryť tieňované svahy - Zobraziť/skryť tieňované svahy Nepodarilo sa spustiť modul prevodu textu na reč. Simulovať polohu pomocou zaznamenanej stopy GPX. Importovať profil @@ -3492,7 +3486,6 @@ Trasa bude prepočítaná ak vzdialenosť od trasy k aktuálnej polohe je väčšia ako zvolená hodnota. %1$s z %2$s Sklony svahov - Zobraziť alebo skryť terén Skryť terén Zobraziť terén Tlačidlo pre zobrazenie alebo skrytie vrstvy terénu na mape. @@ -3608,7 +3601,6 @@ \n Skryť verejnú dopravu Zobraziť verejnú dopravu - Zobraziť alebo skryť verejnú dopravu Tlačidlo na zobrazenie alebo skrytie verejnej dopravy na mape. Vytvoriť alebo upraviť bod záujmu Parkovacie miesta @@ -3689,7 +3681,6 @@ \nZvoľte %2$s a všetky údaje o rýchlostných radaroch budú odstránené, až kým nebude OsmAnd znovu preinštalovaný. Ponechať aktívne V niektorých krajinách je varovanie pred rýchlostnými radarmi zakázané zákonom. - Zobraziť/skryť Mapillary Skryť Mapillary Zobraziť Mapillary Prepínač pre zobrazenie alebo skrytie vrstvy Mapillary na mape. diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml index e78029cd1b..ef4d7e4679 100644 --- a/OsmAnd/res/values-sl/strings.xml +++ b/OsmAnd/res/values-sl/strings.xml @@ -2095,10 +2095,8 @@ Ali ste prepričani, da želite izbrisati dejanje »%s«? Ime dejanja Mesto - Pokaži/Skrij priljubljene Pokaži priljubljene Skrij priljubljene - Pokaži/Skrij točke POI Pokaži %1$s Skrij %1$s Dodaj kategorijo @@ -2258,7 +2256,6 @@ Povečaj območje iskanja Ni zadetkov Poskusite zamenjati iskalni niz ali pa povečajte obseg iskanja. - Preklopi vidnost opomb OSM Pokaži Opombe OSM Skrij Opombe OSM Razvrščeno po razdalji @@ -2874,7 +2871,6 @@ Zamenjaj Pokaži več Prikazane sledi - Pokaži/Skrij sledi GPX Skrij sledi GPX Pokaži sledi GPX Najprej je treba dodati cilj @@ -3241,7 +3237,6 @@ Skrij Mapillary Prikaži mapillary Dodaj spletni vir - Prikaži/skrij Mapillary Odstrani in ponovno zaženi Uporabi gumbe za glasnost za približevanje Prejmi zemljevide Wikipedije diff --git a/OsmAnd/res/values-sr/strings.xml b/OsmAnd/res/values-sr/strings.xml index a548052f4a..084c6de825 100644 --- a/OsmAnd/res/values-sr/strings.xml +++ b/OsmAnd/res/values-sr/strings.xml @@ -1245,7 +1245,6 @@ Повећај област претраге Нема ничег пронађеног Промените претрагу или повећајте област претраге. - Приказује или сакрива OSM белешке Прикажи белешке ОСМ-а Сакриј белешке ОСМ-а Дугме да прикажите или да сакријете OSM белешке на карти. @@ -2218,10 +2217,8 @@ Прикажи дијалог за Омиљене " сачувано у " Место - Прикажи/сакриј Омиљене Прикажи Омиљене Сакриј Омиљене - Прикажи/сакриј тачке од интереса Прикажи %1$s Сакриј %1$s Додај категорију @@ -2901,7 +2898,6 @@ Прикажи још Приказане путање Укрцавање на стајању - Прикажи/сакриј путање Дугме које приказује или сакрива одабране путање са карте. Сакриј путање Прикажи путање @@ -3264,11 +3260,9 @@ Дугме које приказује или сакрива линије изохипси на карти. Прикажи изохипсе Сакриј изохипсе - Прикажи/сакриј изохипсе Дугме које приказује или сакрива рељеф на карти. Прикажи рељеф Сакриј рељеф - Прикажи/сакриј рељеф Не могу да покренем мотор за синтетизовање гласа. Симулирајте Вашу позицију користећу снимљену GPX стазу. Извези профил @@ -3467,7 +3461,6 @@ Поврати све поставке профила\? Чувам нови профил Не могу да направим резервну копију профила. - Прикажи или сакриј терен Сакриј терен Прикажи терен Дугме да прикаже или сакрите слој терена на карти. @@ -3510,7 +3503,6 @@ Профили навођења Сакриј јавни превоз Прикажи јавни превоз - Прикажи или сакриј јавни превоз Дугме које приказује или скрива јавни превоз на карти. Паркинг позиције Поврати подразумевани поредак ставки @@ -3587,7 +3579,6 @@ Држи активним Избриши Упозорења за радаре су законом забрањене у неким државама. - Прикажи/сакриј Mapillary Сакриј Mapillary Прикажи Mapillary Јоруба diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index bb3003ee19..502d5544dd 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -2025,10 +2025,8 @@ Om du tycker om OsmAnd och OSM och vill stödja dem så är detta ett utmärkt s Lägg till favorit " har sparats i " Plats - Visa/Dölj favoriter Visa favoriter Dölj favoriter - Visa/Dölj POI Visa %1$s Dölj %1$s Lägg till en kategori @@ -2125,7 +2123,6 @@ Vänligen tillhandahåll fullständig kod Välj stad Välj postnummer Autozoomning på/av - Visa/Dölj OSM-anteckningar Visa OSM-anteckningar Dölj OSM-anteckningar Ett tryck på denna åtgärdsknapp visar eller döljer OSM-anteckningar på kartan. diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 2d2101489a..243127892f 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -1981,7 +1981,6 @@ Düşük Su İşlem Adı - OSM notlarını göster ya da gizle OSM notlarını göster OSM notlarını gizle OSM notlarını haritada göstermek veya gizlemek için bir düğme. @@ -2443,7 +2442,6 @@ Yol türleri Takas Daha fazla görüntüle - Yolları göster/gizle Yolları Gizle Yolları Göster Ev ekle @@ -2964,10 +2962,8 @@ " kaydedildi " Yer Hızlı eylem adı yinelenen - Sık Kullanılanları göster/gizle Sık Kullanılanları göster Sık Kullanılanları gizle - POI göster/gizle %1$s göster %1$s gizle Kategori ekle @@ -3267,11 +3263,9 @@ Eş yükselti eğrilerini haritada gösterme veya gizleme düğmesi. Eş yükselti eğrilerini göster Eş yükselti eğrilerini gizle - Eş yükselti eğrilerini göster/gizle Haritada tepe gölgelerini göstermek veya gizlemek için bir düğme. Tepe gölgesini göster Tepe gölgesini gizle - Tepe gölgesini göster/gizle Metinden konuşmaya motoru başlatılamıyor. Kayıtlı bir GPX yolu kullanarak konumunuzu simüle edin. Profili dışa aktar @@ -3497,7 +3491,6 @@ Güzergahtan geçerli konuma olan mesafe seçilen değerden fazla ise güzergah yeniden hesaplanacaktır. %1$s / %2$s Yamaçlar - Araziyi göster veya gizle Araziyi gizle Araziyi göster Haritada arazi katmanını göstermek veya gizlemek için bir düğme. @@ -3615,7 +3608,6 @@ Bu eylemlere “%1$s” düğmesine dokunarak erişebilirsiniz. Toplu taşıma araçlarını gizle Toplu taşıma araçlarını göster - Toplu taşıma araçlarını göster veya gizle Haritada toplu taşıma araçlarını gösteren veya gizleyen düğme. POI oluştur veya düzenle Park etme alanları @@ -3683,7 +3675,6 @@ Alçak köprülerden kaçınmak için gemi yüksekliğini ayarlayabilirsiniz. Köprü hareket edebiliyorsa, açık durumdaki yüksekliğini kullanacağımızı unutmayın. Alçak köprülerden kaçınmak için gemi yüksekliğini ayarlayın. Köprü hareket edebiliyorsa, açık durumdaki yüksekliğini kullanacağımızı unutmayın. Dar köprülerden kaçınmak için gemi genişliğini ayarlayın - Mapillary\'i göster/gizle Mapillary\'i gizle Mapillary\'i göster Harita üzerinde Mapillary katmanını göstermek veya gizlemek için bir geçiş. diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 6fba4223b3..7d92f4dbac 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -2093,10 +2093,8 @@ Вилучити дію Ви впевнені, що хочете вилучити дію „%s“? Місце - Показати/приховати Закладки Показати Закладки Приховати Закладки - Показати/приховати POI Показати %1$s Приховати %1$s Додати категорію @@ -2210,7 +2208,6 @@ Нічого не знайдено Місце призначення розташовано в області з приватним доступом. Дозволити доступ до приватних доріг у цій подорожі\? Змініть пошуковий запит або ж розширте пошуковий радіус. - Показати/приховати примітки OSM Показати примітки OSM Приховати примітки OSM Натискання на кнопку дії покаже чи приховає примітки OSM на мапі. @@ -2804,7 +2801,6 @@ Поміняти Показати більше Показані треки - Показати/Приховати треки Приховати треки Показати треки Спершу додайте пункт призначення @@ -3267,11 +3263,9 @@ Увімк/вимк показ горизонталей. Показати горизонталі Сховати горизонталі - Показати/приховати горизонталі Кнопка, що показує чи приховує горизонталі на мапі. Показати затемнення рельєфу Приховати затемнення рельєфу - Показати/приховати затемнення рельєфу Не вдається запустити рушій мовлення. Відтворити свою позицію за допомогою записаного треку GPX. Експорт профілю @@ -3496,7 +3490,6 @@ Пагорб %1$s з %2$s Схили - Показати чи приховати рельєф Сховати місцевість Показати місцевість Кнопка для відображення або приховування шару місцевості на мапі. @@ -3612,7 +3605,6 @@ Розташування припаркованого авто Приховати громадський транспорт Показати громадський транспорт - Показати чи приховати громадський транспорт Кнопка показу або приховування громадського транспорту на мапі. Створити чи змінити POI Додати чи змінити закладку @@ -3681,7 +3673,6 @@ Ви можете встановити висоту судна, щоб уникнути низьких мостів. Майте на увазі, якщо міст рухомий, використовуватиметься його висота у відкритому стані. Встановіть висоту судна, щоб уникнути низьких мостів. Майте на увазі, якщо міст рухомий, використовуватиметься його висота у відкритому стані. Встановіть ширину судна, щоб уникнути вузьких мостів - Увімкнути/вимкнути Mapillary Вимкнути Mapillary Показати Mapillary Перемикач показує/приховує шар Mapillary на мапі. diff --git a/OsmAnd/res/values-zh-rCN/strings.xml b/OsmAnd/res/values-zh-rCN/strings.xml index 4f46e46e40..390f33407d 100644 --- a/OsmAnd/res/values-zh-rCN/strings.xml +++ b/OsmAnd/res/values-zh-rCN/strings.xml @@ -1249,7 +1249,6 @@ 增加搜索范围 什么都没找到 更改搜索或增加其半径。 - 显示/隐藏 OSM 注记 显示 OSM 注记 隐藏 OSM 注记 添加照片 @@ -2382,10 +2381,8 @@ 快速动作名称重复 轻触动作按钮将会在地图上显示或隐收藏夹标点。 轻触动作按钮将会在地图上显示或隐藏 POI。 - 显示/隐藏收藏夹 显示收藏夹 隐藏收藏夹 - 显示/隐藏 POI 显示 %1$s 隐藏 %1$s 添加类别 @@ -2732,7 +2729,6 @@ 逐步 道路类型 退出于 - 显示/隐藏GPX轨迹 在地图中显示或隐藏已选中的GPX轨迹的按钮。 隐藏GPX轨迹 显示GPX路径 @@ -2894,7 +2890,6 @@ 透明度 缩放等级 图例 - 显示/隐藏地形 隐藏地形 显示地形 删除描述 @@ -2919,7 +2914,6 @@ 订阅 - OsmAnd Live 隐藏公共交通 显示公共交通 - 显示/隐藏公共交通 创建/编辑兴趣点 编辑在线资源 正轴等角圆柱投影 @@ -2934,7 +2928,6 @@ 您可以设置船只高度,以避免过低桥梁。请记住,如果桥是可移动的,我们将使用它在打开状态下的高度。 设置船只高度,以避免过低桥梁。请记住,如果桥是可移动的,我们将使用它在打开状态下的高度。 设置船只宽度以避免狭窄的桥梁 - 显示/隐藏Mapillary 隐藏Mapillary 显示Mapillary %1$s 已删除 @@ -2959,9 +2952,7 @@ 允许专家路线 节点网络 隐藏罗盘标尺 - 显示/隐藏山体阴影 隐藏山体阴影 - 显示/隐藏轮廓线 隐藏轮廓线 在地图上显示或隐藏地形图层的按钮。 显示或隐藏其他地图细节 diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 21e5de09a5..bfa817bfa3 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -2092,10 +2092,8 @@ 預設的名稱 " 儲存到 " 場所 - 顯示/隱藏我的收藏 顯示我的收藏 隱藏我的收藏 - 顯示/隱藏 POI 顯示 %1$s 隱藏 %1$s 增加一項類別 @@ -2382,7 +2380,6 @@ 安裝「等高線」外掛程式以顯示漸層垂直區域。 自此縮放等級開始隱藏 按距離排序 - 顯示或隱藏 OSM 註記 顯示 OSM 註記 隱藏 OSM 註記 在我的最愛中搜尋 @@ -2839,7 +2836,6 @@ 道路類型 離開於 站點的座位 - 顯示/隱藏軌跡 在地圖上顯示或隱藏所選軌跡的按鈕。 隱藏軌跡 顯示軌跡 @@ -3259,11 +3255,9 @@ 在地圖上顯示或隱藏等高線的按鈕。 顯示等高線 隱藏等高線 - 顯示/隱藏等高線 在地圖上顯示或隱藏地形陰影的按鈕。 顯示地形陰影 隱藏地形陰影 - 顯示/隱藏地形陰影 無法啟動文字轉語音引擎。 使用已紀錄的 GPX 軌跡模擬您的位置。 匯出設定檔 @@ -3490,7 +3484,6 @@ 啟用以檢視地形陰影或坡度圖。您可以在我們的網站上閱讀更多關於這些地圖類型的資訊。 地形陰影 坡度 - 顯示或隱藏地形 隱藏地形 顯示地形 用於顯示或隱藏地圖上地形圖層的按鈕。 @@ -3607,7 +3600,6 @@ 您可以透過點選「%1$s」按鈕存取這些動作。 隱藏大眾運輸 在地圖上顯示或隱藏大眾運輸的按鈕。 - 顯示或隱藏大眾運輸 建立或編輯 POI 停車位置 新增與編輯收藏 @@ -3675,7 +3667,6 @@ 您可以設定船艦高度以避免矮橋。請記住,如果橋是可動式的,我們將會使用其在開啟狀態的高度。 設定船艦高度以避免矮橋。請記住,如果橋是可動式的,我們將會使用其開啟狀態的高度。 設定船艦寬度以避免窄橋 - 顯示/隱藏 Mapillary 隱藏 Mapillary 顯示 Mapillary 在地圖上顯示或隱藏 Mapillary 圖層的開關。 diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index ed1259ed1f..c43425fa92 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,12 +12,14 @@ --> + Show/hide + Copy POI name The recording will be continued. + Select category or add new one Distance by tap A toggle to show or hide the Coordinates widget on the map. Show Coordinates widget Hide Coordinates widget - Show/Hide coordinates widget Routing could avoid strong uphills. Application restart required to apply some settings. On pause @@ -342,7 +344,6 @@ A toggle to show or hide the Mapillary layer on the map. Show Mapillary Hide Mapillary - Show/hide Mapillary Set vessel width to avoid narrow bridges Set vessel height to avoid low bridges. Keep in mind, if the bridge is movable, we will use its height in the open state. You can set vessel height to avoid low bridges. Keep in mind, if the bridge is movable, we will use its height in the open state. @@ -419,7 +420,6 @@ Parking positions Create or edit POI Button showing or hiding public transport on the map. - Show or hide public transport Show public transport Hide public transport @@ -521,7 +521,6 @@ A button to show or hide terrain layer on the map. Show terrain Hide terrain - Show or hide terrain Slopes %1$s of %2$s The route will be recalculated if the distance from the route to the current location is more than selected value. @@ -724,11 +723,9 @@ Button showing or hiding contour lines on the map. Show contour lines Hide contour lines - Show/hide contour lines A button to show or hide hillshades on the map. Show hillshade Hide hillshade - Show/hide hillshade You can apply this change to all or only the selected profile. Shared Prefer unpaved roads @@ -1115,7 +1112,6 @@ Swap Show more Displayed tracks - Show/hide tracks A button to show or hide selected tracks on the map. Hide Tracks Show Tracks @@ -1528,7 +1524,6 @@ Increase search radius Nothing found Change the search or increase its radius. - Show or hide OSM notes Show OSM notes Hide OSM notes Button to show or hide OSM notes on the map. @@ -2278,7 +2273,7 @@ Add Add to \'Favorites\' My Position - My Places + My places Favorites Tracks Currently recording track @@ -4012,10 +4007,8 @@ Quick action name duplicate A toggle to show or hide the Favorite points on the map. A toggle to show or hide POIs on the map. - Show/hide Favorites Show Favorites Hide Favorites - Show/hide POI Show %1$s Hide %1$s Add a category diff --git a/OsmAnd/res/xml/profile_appearance.xml b/OsmAnd/res/xml/profile_appearance.xml index 9c042ddeaa..87ec511b69 100644 --- a/OsmAnd/res/xml/profile_appearance.xml +++ b/OsmAnd/res/xml/profile_appearance.xml @@ -21,12 +21,12 @@ diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index e410aac3d3..f385a4af8e 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -336,6 +336,43 @@ public class AndroidUtils { ); } + public static ColorStateList createCheckedColorIntStateList(@ColorInt int normal, @ColorInt int checked) { + return createCheckedColorIntStateList(false, normal, checked, 0, 0); + } + + public static ColorStateList createCheckedColorIntStateList(boolean night, + @ColorInt int lightNormal, @ColorInt int lightChecked, + @ColorInt int darkNormal, @ColorInt int darkChecked) { + return createColorIntStateList(night, android.R.attr.state_checked, + lightNormal, lightChecked, darkNormal, darkChecked); + } + + public static ColorStateList createEnabledColorIntStateList(@ColorInt int normal, @ColorInt int pressed) { + return createEnabledColorIntStateList(false, normal, pressed, 0, 0); + } + + public static ColorStateList createEnabledColorIntStateList(boolean night, + @ColorInt int lightNormal, @ColorInt int lightPressed, + @ColorInt int darkNormal, @ColorInt int darkPressed) { + return createColorIntStateList(night, android.R.attr.state_enabled, + lightNormal, lightPressed, darkNormal, darkPressed); + } + + private static ColorStateList createColorIntStateList(boolean night, int state, + @ColorInt int lightNormal, @ColorInt int lightState, + @ColorInt int darkNormal, @ColorInt int darkState) { + return new ColorStateList( + new int[][]{ + new int[]{state}, + new int[]{} + }, + new int[]{ + night ? darkState : lightState, + night ? darkNormal : lightNormal + } + ); + } + public static StateListDrawable createCheckedStateListDrawable(Drawable normal, Drawable checked) { return createStateListDrawable(normal, checked, android.R.attr.state_checked); } diff --git a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java index bbfa4f89b8..b8a467d991 100644 --- a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java +++ b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java @@ -133,7 +133,7 @@ public class ConnectedApp implements Comparable { CompoundButton btn = view.findViewById(R.id.toggle_item); if (btn != null && btn.getVisibility() == View.VISIBLE) { btn.setChecked(!btn.isChecked()); - menuAdapter.getItem(position).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + menuAdapter.getItem(position).setColor(app, btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); return false; } @@ -146,7 +146,7 @@ public class ConnectedApp implements Comparable { if (layersPref.set(isChecked)) { ContextMenuItem item = adapter.getItem(position); if (item != null) { - item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(app, isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); item.setSelected(isChecked); adapter.notifyDataSetChanged(); } @@ -162,7 +162,7 @@ public class ConnectedApp implements Comparable { .setListener(listener) .setSelected(layersEnabled) .setIcon(R.drawable.ic_extension_dark) - .setColor(layersEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, layersEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .createItem()); } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 3687602716..e82907a9e4 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -417,8 +417,12 @@ public class OsmandAidlApi { } private void registerReceiver(BroadcastReceiver rec, MapActivity ma, String filter) { - receivers.put(filter, rec); - ma.registerReceiver(rec, new IntentFilter(filter)); + try { + receivers.put(filter, rec); + ma.registerReceiver(rec, new IntentFilter(filter)); + } catch (IllegalStateException e) { + LOG.error(e); + } } private void registerRemoveMapWidgetReceiver(MapActivity mapActivity) { diff --git a/OsmAnd/src/net/osmand/data/FavouritePoint.java b/OsmAnd/src/net/osmand/data/FavouritePoint.java index 7205b4a422..f87083363f 100644 --- a/OsmAnd/src/net/osmand/data/FavouritePoint.java +++ b/OsmAnd/src/net/osmand/data/FavouritePoint.java @@ -11,6 +11,9 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import net.osmand.GPXUtilities.WptPt; +import net.osmand.Location; +import net.osmand.ResultMatcher; +import net.osmand.binary.RouteDataObject; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.BooleanPreference; @@ -42,6 +45,8 @@ public class FavouritePoint implements Serializable, LocationPoint { private boolean visible = true; private SpecialPointType specialPointType = null; private BackgroundType backgroundType = null; + private double altitude; + private long timestamp; public FavouritePoint() { } @@ -50,10 +55,24 @@ public class FavouritePoint implements Serializable, LocationPoint { this.latitude = latitude; this.longitude = longitude; this.category = category; - if(name == null) { + if (name == null) { name = ""; } this.name = name; + timestamp = System.currentTimeMillis(); + initPersonalType(); + } + + public FavouritePoint(double latitude, double longitude, String name, String category, double altitude, long timestamp) { + this.latitude = latitude; + this.longitude = longitude; + this.category = category; + if (name == null) { + name = ""; + } + this.name = name; + this.altitude = altitude; + this.timestamp = timestamp != 0 ? timestamp : System.currentTimeMillis(); initPersonalType(); } @@ -69,25 +88,56 @@ public class FavouritePoint implements Serializable, LocationPoint { this.address = favouritePoint.address; this.iconId = favouritePoint.iconId; this.backgroundType = favouritePoint.backgroundType; + this.altitude = favouritePoint.altitude; + this.timestamp = favouritePoint.timestamp; initPersonalType(); } private void initPersonalType() { - if(FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY.equals(category)) { - for(SpecialPointType p : SpecialPointType.values()) { - if(p.typeName.equals(this.name)) { + if (FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY.equals(category)) { + for (SpecialPointType p : SpecialPointType.values()) { + if (p.typeName.equals(this.name)) { this.specialPointType = p; } } } } + public void initAltitude(OsmandApplication app) { + initAltitude(app, null); + } + + public void initAltitude(OsmandApplication app, final Runnable callback) { + Location location = new Location("", latitude, longitude); + app.getLocationProvider().getRouteSegment(location, null, false, + new ResultMatcher() { + + @Override + public boolean publish(RouteDataObject routeDataObject) { + if (routeDataObject != null) { + LatLon latLon = new LatLon(latitude, longitude); + routeDataObject.calculateHeightArray(latLon); + altitude = routeDataObject.heightByCurrentLocation; + } + if (callback != null) { + callback.run(); + } + return true; + } + + @Override + public boolean isCancelled() { + return false; + } + }); + } + public SpecialPointType getSpecialPointType() { return specialPointType; } public int getColor() { - return color; + return color; } @Nullable @@ -171,6 +221,22 @@ public class FavouritePoint implements Serializable, LocationPoint { this.longitude = longitude; } + public double getAltitude() { + return altitude; + } + + public void setAltitude(double altitude) { + this.altitude = altitude; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + public String getCategory() { return category; } @@ -200,7 +266,7 @@ public class FavouritePoint implements Serializable, LocationPoint { initPersonalType(); } - public String getDescription () { + public String getDescription() { return description; } @@ -256,7 +322,8 @@ public class FavouritePoint implements Serializable, LocationPoint { } else if (!originObjectName.equals(fp.originObjectName)) return false; - return (this.latitude == fp.latitude) && (this.longitude == fp.longitude); + return (this.latitude == fp.latitude) && (this.longitude == fp.longitude) && + (this.altitude == fp.altitude) && (this.timestamp == fp.timestamp); } @Override @@ -265,6 +332,8 @@ public class FavouritePoint implements Serializable, LocationPoint { int result = 1; result = prime * result + (int) Math.floor(latitude * 10000); result = prime * result + (int) Math.floor(longitude * 10000); + result = prime * result + (int) Math.floor(altitude * 10000); + result = prime * result + (int) Math.floor(timestamp * 10000); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((category == null) ? 0 : category.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode()); @@ -289,7 +358,9 @@ public class FavouritePoint implements Serializable, LocationPoint { this.iconId = iconId; } - public String getCategory() { return FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY; } + public String getCategory() { + return FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY; + } public String getName() { return typeName; @@ -384,7 +455,7 @@ public class FavouritePoint implements Serializable, LocationPoint { name = ""; } FavouritePoint fp; - fp = new FavouritePoint(pt.lat, pt.lon, name, categoryName); + fp = new FavouritePoint(pt.lat, pt.lon, name, categoryName, pt.ele, pt.time); fp.setDescription(pt.desc); if (pt.comment != null) { fp.setOriginObjectName(pt.comment); @@ -405,6 +476,8 @@ public class FavouritePoint implements Serializable, LocationPoint { WptPt pt = new WptPt(); pt.lat = getLatitude(); pt.lon = getLongitude(); + pt.ele = getAltitude(); + pt.time = getTimestamp(); if (!isVisible()) { pt.getExtensionsToWrite().put(HIDDEN, "true"); } diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index 381125e0ec..5fdea403d3 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -249,8 +249,7 @@ public class ContextMenuAdapter { final ContextMenuItem item = getItem(position); int layoutId = item.getLayout(); layoutId = layoutId != ContextMenuItem.INVALID_ID ? layoutId : DEFAULT_LAYOUT_ID; - int currentModeColorRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode); - int currentModeColor = ContextCompat.getColor(app, currentModeColorRes); + int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode); if (layoutId == R.layout.mode_toggles) { final Set selected = new LinkedHashSet<>(); return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(), @@ -278,15 +277,13 @@ public class ContextMenuAdapter { } if (layoutId == R.layout.main_menu_drawer_btn_switch_profile || layoutId == R.layout.main_menu_drawer_btn_configure_profile) { - int colorResId = item.getColorRes(); - int colorNoAlpha = ContextCompat.getColor(app, colorResId); - + int colorNoAlpha = item.getColor(); TextView title = convertView.findViewById(R.id.title); title.setText(item.getTitle()); if (layoutId == R.layout.main_menu_drawer_btn_switch_profile) { ImageView icon = convertView.findViewById(R.id.icon); - icon.setImageDrawable(mIconsCache.getIcon(item.getIcon(), colorResId)); + icon.setImageDrawable(mIconsCache.getPaintedIcon(item.getIcon(), colorNoAlpha)); ImageView icArrow = convertView.findViewById(R.id.ic_expand_list); icArrow.setImageDrawable(mIconsCache.getIcon(item.getSecondaryIcon())); TextView desc = convertView.findViewById(R.id.description); @@ -306,16 +303,13 @@ public class ContextMenuAdapter { return convertView; } if (layoutId == R.layout.profile_list_item) { - int tag = item.getTag(); - - int colorResId = item.getColorRes(); - int colorNoAlpha = ContextCompat.getColor(app, colorResId); + int colorNoAlpha = item.getColor(); TextView title = convertView.findViewById(R.id.title); TextView desc = convertView.findViewById(R.id.description); ImageView icon = convertView.findViewById(R.id.icon); title.setText(item.getTitle()); - + convertView.findViewById(R.id.divider_up).setVisibility(View.INVISIBLE); convertView.findViewById(R.id.divider_bottom).setVisibility(View.INVISIBLE); convertView.findViewById(R.id.menu_image).setVisibility(View.GONE); @@ -331,7 +325,7 @@ public class ContextMenuAdapter { AndroidUiHelper.updateVisibility(icon, true); AndroidUiHelper.updateVisibility(desc, true); AndroidUtils.setTextPrimaryColor(app, title, nightMode); - icon.setImageDrawable(mIconsCache.getIcon(item.getIcon(), colorResId)); + icon.setImageDrawable(mIconsCache.getPaintedIcon(item.getIcon(), colorNoAlpha)); desc.setText(item.getDescription()); boolean selectedMode = tag == PROFILES_CHOSEN_PROFILE_TAG; if (selectedMode) { @@ -419,17 +413,18 @@ public class ContextMenuAdapter { } } else { if (item.getIcon() != ContextMenuItem.INVALID_ID) { - int colorRes = item.getColorRes(); - if (colorRes == ContextMenuItem.INVALID_ID) { - if (!item.shouldSkipPainting()) { - colorRes = lightTheme ? R.color.icon_color_default_light : R.color.icon_color_default_dark; - } else { - colorRes = 0; - } + Integer color = item.getColor(); + Drawable drawable; + if (color == null) { + int colorRes = lightTheme ? R.color.icon_color_default_light : R.color.icon_color_default_dark; + colorRes = item.shouldSkipPainting() ? 0 : colorRes; + drawable = mIconsCache.getIcon(item.getIcon(), colorRes); } else if (profileDependent) { - colorRes = currentModeColorRes; + drawable = mIconsCache.getPaintedIcon(item.getIcon(), currentModeColor); + } else { + drawable = mIconsCache.getPaintedIcon(item.getIcon(), color); } - final Drawable drawable = mIconsCache.getIcon(item.getIcon(), colorRes); + ((AppCompatImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable); convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE); } else if (convertView.findViewById(R.id.icon) != null) { diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java index 3718169532..1ab526cbeb 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java @@ -19,8 +19,8 @@ public class ContextMenuItem { private String title; @DrawableRes private int mIcon; - @ColorRes - private int colorRes; + @ColorInt + private Integer color; @DrawableRes private int secondaryIcon; private Boolean selected; @@ -48,7 +48,7 @@ public class ContextMenuItem { private ContextMenuItem(@StringRes int titleId, String title, @DrawableRes int icon, - @ColorRes int colorRes, + @ColorInt Integer color, @DrawableRes int secondaryIcon, Boolean selected, int progress, @@ -72,7 +72,7 @@ public class ContextMenuItem { this.titleId = titleId; this.title = title; this.mIcon = icon; - this.colorRes = colorRes; + this.color = color; this.secondaryIcon = secondaryIcon; this.selected = selected; this.progress = progress; @@ -109,23 +109,17 @@ public class ContextMenuItem { return mIcon; } - @ColorRes - public int getColorRes() { - return colorRes; - } - - @ColorRes - public int getThemedColorRes(Context context) { - if (skipPaintingWithoutColor || getColorRes() != INVALID_ID) { - return getColorRes(); - } else { - return UiUtilities.getDefaultColorRes(context); - } + @ColorInt + public Integer getColor() { + return color; } @ColorInt public int getThemedColor(Context context) { - return ContextCompat.getColor(context, getThemedColorRes(context)); + if (skipPaintingWithoutColor || color != null) { + return color; + } + return ContextCompat.getColor(context, UiUtilities.getDefaultColorRes(context)); } @DrawableRes @@ -212,8 +206,10 @@ public class ContextMenuItem { this.secondaryIcon = secondaryIcon; } - public void setColorRes(int colorRes) { - this.colorRes = colorRes; + public void setColor(Context context, @ColorRes int colorRes) { + if (colorRes != INVALID_ID) { + this.color = ContextCompat.getColor(context, colorRes); + } } public void setSelected(boolean selected) { @@ -268,8 +264,8 @@ public class ContextMenuItem { private String mTitle; @DrawableRes private int mIcon = INVALID_ID; - @ColorRes - private int mColorRes = INVALID_ID; + @ColorInt + private Integer mColor = null; @DrawableRes private int mSecondaryIcon = INVALID_ID; private Boolean mSelected = null; @@ -307,8 +303,15 @@ public class ContextMenuItem { return this; } - public ItemBuilder setColor(@ColorRes int colorRes) { - mColorRes = colorRes; + public ItemBuilder setColor(@ColorInt Integer color) { + mColor = color; + return this; + } + + public ItemBuilder setColor(Context context, @ColorRes int colorRes) { + if (colorRes != INVALID_ID) { + mColor = ContextCompat.getColor(context, colorRes); + } return this; } @@ -422,7 +425,7 @@ public class ContextMenuItem { } public ContextMenuItem createItem() { - ContextMenuItem item = new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon, + ContextMenuItem item = new ContextMenuItem(mTitleId, mTitle, mIcon, mColor, mSecondaryIcon, mSelected, mProgress, mLayout, mLoading, mIsCategory, mIsClickable, mSkipPaintingWithoutColor, mOrder, mDescription, mOnUpdateCallback, mItemClickListener, mIntegerListener, mProgressListener, mItemDeleteAction, mHideDivider, mHideCompoundButton, mMinHeight, mTag, mId); diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 992a0e42c6..9fffc074c2 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -361,6 +361,9 @@ public class FavouritesDbHelper { } public boolean addFavourite(FavouritePoint p, boolean saveImmediately) { + if (Double.isNaN(p.getAltitude()) || p.getAltitude() == 0) { + p.initAltitude(context); + } if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) { return true; } @@ -545,6 +548,7 @@ public class FavouritesDbHelper { cancelAddressRequest(p); p.setLatitude(lat); p.setLongitude(lon); + p.initAltitude(context); if (description != null) { p.setDescription(description); } diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 83ed3214c3..f34fc008f5 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -32,7 +32,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.track.GpxSplitType; import net.osmand.util.Algorithms; @@ -964,7 +964,7 @@ public class GpxSelectionHelper { } public boolean isFollowTrack(OsmandApplication app) { - RouteProvider.GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute(); if (routeParams != null) { return gpxFile.path.equals(routeParams.getFile().path); } diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java index 0b2683fcc6..8b62b540b3 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java @@ -18,7 +18,7 @@ import net.osmand.GPXUtilities; import net.osmand.Location; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.settings.backend.ApplicationMode; import java.util.ArrayList; @@ -59,7 +59,7 @@ public class OsmAndLocationSimulation { boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; ApplicationMode appMode = app.getSettings().getApplicationMode(); - int selectedModeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode)); + int selectedModeColor = appMode.getProfileColor(nightMode); AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ma, themeRes)); builder.setTitle(R.string.animate_route); diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index d3543a6df1..42bc4dbc59 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -468,7 +468,7 @@ public abstract class OsmandPlugin { FragmentManager fm = mapActivity.getSupportFragmentManager(); Fragment fragment = fm.findFragmentByTag(fragmentData.tag); if (fragment != null) { - fm.beginTransaction().remove(fragment).commit(); + fm.beginTransaction().remove(fragment).commitAllowingStateLoss(); } } } diff --git a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java index 472899862b..bd77ebf33b 100644 --- a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java @@ -10,7 +10,7 @@ import net.osmand.data.LatLon; import net.osmand.data.LocationPoint; import net.osmand.data.PointDescription; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelperUtils; import net.osmand.plus.settings.backend.ApplicationMode; diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java index aaa9d01f8b..269800c630 100644 --- a/OsmAnd/src/net/osmand/plus/UiUtilities.java +++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java @@ -553,7 +553,7 @@ public class UiUtilities { switch (type) { case PROFILE_DEPENDENT: ApplicationMode appMode = app.getSettings().getApplicationMode(); - activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode)); + activeColor = appMode.getProfileColor(nightMode); break; case TOOLBAR: activeColor = Color.WHITE; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 2273c91742..7e0a07e40c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -93,6 +93,7 @@ import net.osmand.plus.importfiles.ImportHelper; import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment; +import net.osmand.plus.mapcontextmenu.editors.SelectFavoriteCategoryBottomSheet; import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu; import net.osmand.plus.mapmarkers.MapMarker; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 2bb6f5caec..48cc860cb7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -69,7 +69,7 @@ import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.profiles.ProfileDataUtils; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.WaypointsFragment; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; @@ -441,7 +441,7 @@ public class MapActivityActions implements DialogProvider { } adapter.addItem(itemBuilder - .setTitleId(R.string.plan_a_route, mapActivity) + .setTitleId(R.string.plan_route, mapActivity) .setId(MAP_CONTEXT_MENU_MEASURE_DISTANCE) .setIcon(R.drawable.ic_action_ruler) .setOrder(MEASURE_DISTANCE_ITEM_ORDER) @@ -489,7 +489,7 @@ public class MapActivityActions implements DialogProvider { // new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, // REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION); //} - } else if (standardId == R.string.plan_a_route) { + } else if (standardId == R.string.plan_route) { mapActivity.getContextMenu().close(); MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), new LatLon(latitude, longitude)); } else if (standardId == R.string.avoid_road) { @@ -753,7 +753,7 @@ public class MapActivityActions implements DialogProvider { optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.profile_list_item) .setIcon(appMode.getIconRes()) - .setColor(appMode.getIconColorInfo().getColor(nightMode)) + .setColor(appMode.getProfileColor(nightMode)) .setTag(tag) .setTitle(appMode.toHumanString()) .setDescription(modeDescription) @@ -770,7 +770,7 @@ public class MapActivityActions implements DialogProvider { int activeColorPrimaryResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.profile_list_item) - .setColor(activeColorPrimaryResId) + .setColor(app, activeColorPrimaryResId) .setTag(PROFILES_CONTROL_BUTTON_TAG) .setTitle(getString(R.string.shared_string_manage)) .setListener(new ItemClickListener() { @@ -963,7 +963,7 @@ public class MapActivityActions implements DialogProvider { } }).createItem()); - optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.plan_a_route, mapActivity) + optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.plan_route, mapActivity) .setId(DRAWER_MEASURE_DISTANCE_ID) .setIcon(R.drawable.ic_action_plan_route) .setListener(new ItemClickListener() { @@ -1083,7 +1083,7 @@ public class MapActivityActions implements DialogProvider { .setId(DRAWER_SWITCH_PROFILE_ID) .setIcon(currentMode.getIconRes()) .setSecondaryIcon(icArrowResId) - .setColor(currentMode.getIconColorInfo().getColor(nightMode)) + .setColor(currentMode.getProfileColor(nightMode)) .setTitle(currentMode.toHumanString()) .setDescription(modeDescription) .setListener(new ItemClickListener() { @@ -1097,7 +1097,7 @@ public class MapActivityActions implements DialogProvider { .createItem()); optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.main_menu_drawer_btn_configure_profile) .setId(DRAWER_CONFIGURE_PROFILE_ID) - .setColor(currentMode.getIconColorInfo().getColor(nightMode)) + .setColor(currentMode.getProfileColor(nightMode)) .setTitle(getString(R.string.configure_profile)) .setListener(new ItemClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index 8c0d09f150..ccdef9484e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -437,7 +437,7 @@ public class MapActivityLayers { } else { builder.setIcon(R.drawable.mx_user_defined); } - builder.setColor(ContextMenuItem.INVALID_ID); + builder.setColor(activity, ContextMenuItem.INVALID_ID); builder.setSkipPaintingWithoutColor(true); adapter.addItem(builder.createItem()); } @@ -495,7 +495,7 @@ public class MapActivityLayers { OsmandApplication app = getApplication(); boolean nightMode = isNightMode(app); int themeRes = getThemeRes(app); - int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode)); + int selectedModeColor = settings.getApplicationMode().getProfileColor(nightMode); DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter( items, nightMode, selectedItem, app, selectedModeColor, themeRes, new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java index 44222d5586..639bed2bdf 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java @@ -120,13 +120,13 @@ public class AppModeDialog { final View selection = tb.findViewById(R.id.selection); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); if (checked) { - iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode))); + iv.setImageDrawable(ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_checked))); - selection.setBackgroundResource(mode.getIconColorInfo().getColor(nightMode)); + selection.setBackgroundColor(mode.getProfileColor(nightMode)); selection.setVisibility(View.VISIBLE); } else { if (useMapTheme) { - iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode))); + iv.setImageDrawable(ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode))); iv.setBackgroundResource(AndroidUtils.resolveAttribute(themedCtx, android.R.attr.selectableItemBackground)); } else { iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes())); @@ -171,7 +171,7 @@ public class AppModeDialog { final boolean checked = selected.contains(mode); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); ImageView selection = tb.findViewById(R.id.selection); - Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)); + Drawable drawable = ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)); if (checked) { iv.setImageDrawable(drawable); iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_checked))); @@ -184,7 +184,7 @@ public class AppModeDialog { } else { if (useMapTheme) { if (Build.VERSION.SDK_INT >= 21) { - Drawable active = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)); + Drawable active = ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)); drawable = AndroidUtils.createPressedStateListDrawable(drawable, active); } iv.setImageDrawable(drawable); @@ -195,7 +195,7 @@ public class AppModeDialog { AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.btn_border_pressed_trans_light, R.drawable.btn_border_pressed_trans_light); } } else { - iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode))); + iv.setImageDrawable(ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode))); } iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_unchecked))); } @@ -232,7 +232,7 @@ public class AppModeDialog { int metricsY = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height); View tb = layoutInflater.inflate(layoutId, null); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); - iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(isNightMode(ctx, useMapTheme)))); + iv.setImageDrawable(ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(isNightMode(ctx, useMapTheme)))); iv.setContentDescription(mode.toHumanString()); // tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null); LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY); diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java index c8c9a70785..4728c0bce3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java @@ -121,7 +121,7 @@ public class StartGPSStatus extends OsmAndAction { cb.setLayoutParams(lp); cb.setPadding(dp8, 0, 0, 0); int textColorPrimary = ContextCompat.getColor(activity, isNightMode() ? R.color.text_color_primary_dark : R.color.text_color_primary_light); - int selectedModeColor = ContextCompat.getColor(activity, getSettings().getApplicationMode().getIconColorInfo().getColor(isNightMode())); + int selectedModeColor = getSettings().getApplicationMode().getProfileColor(isNightMode()); cb.setTextColor(textColorPrimary); UiUtilities.setupCompoundButton(isNightMode(), selectedModeColor, cb); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index b7f15624b4..6d425ef65e 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -678,7 +678,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.layer_recordings) { SHOW_RECORDINGS.set(!SHOW_RECORDINGS.get()); - adapter.getItem(pos).setColorRes(SHOW_RECORDINGS.get() ? + adapter.getItem(pos).setColor(app, SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); updateLayers(mapView, mapActivity); @@ -690,7 +690,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { .setId(RECORDING_LAYER) .setSelected(SHOW_RECORDINGS.get()) .setIcon(R.drawable.ic_action_micro_dark) - .setColor(SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(mapActivity, SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setItemDeleteAction(makeDeleteAction(SHOW_RECORDINGS)) .setListener(listener).createItem()); } diff --git a/OsmAnd/src/net/osmand/plus/base/BottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/BottomSheetDialogFragment.java index c33b183b65..4a9924fd0e 100644 --- a/OsmAnd/src/net/osmand/plus/base/BottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/BottomSheetDialogFragment.java @@ -10,6 +10,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; +import androidx.annotation.ColorInt; import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; @@ -91,6 +92,16 @@ public abstract class BottomSheetDialogFragment extends DialogFragment { } } + @Nullable + protected Drawable getPaintedIcon(@DrawableRes int drawableRes, @ColorInt int color) { + OsmandApplication app = getMyApplication(); + if (app != null) { + return app.getUIUtilities().getPaintedIcon(drawableRes, color); + } else { + return null; + } + } + @Nullable protected Drawable getContentIcon(@DrawableRes int drawableRes) { OsmandApplication app = getMyApplication(); diff --git a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java index 46708ce5ae..26fe55e1e8 100644 --- a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java +++ b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java @@ -18,7 +18,7 @@ import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java index 10fa8a461e..a8c508433e 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; +import androidx.annotation.ColorInt; import androidx.annotation.ColorRes; import androidx.annotation.LayoutRes; import androidx.core.content.ContextCompat; @@ -22,6 +23,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri private ColorStateList buttonTintList; private OnCheckedChangeListener onCheckedChangeListener; @ColorRes private int compoundButtonColorId; + @ColorInt private Integer compoundButtonColor; private CompoundButton compoundButton; @@ -80,6 +82,10 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri this.compoundButtonColorId = compoundButtonColorId; } + public void setCompoundButtonColor(@ColorInt int compoundButtonColor) { + this.compoundButtonColor = compoundButtonColor; + } + public CompoundButton getCompoundButton() { return compoundButton; } @@ -91,7 +97,9 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri if (compoundButton != null) { compoundButton.setChecked(checked); compoundButton.setOnCheckedChangeListener(onCheckedChangeListener); - if (compoundButtonColorId != INVALID_ID) { + if (compoundButtonColor != null) { + UiUtilities.setupCompoundButton(nightMode, compoundButtonColor, compoundButton); + } else if (compoundButtonColorId != INVALID_ID) { UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(context, compoundButtonColorId), compoundButton); } else { CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList); @@ -105,6 +113,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri protected ColorStateList buttonTintList; protected OnCheckedChangeListener onCheckedChangeListener; @ColorRes protected int compoundButtonColorId = INVALID_ID; + @ColorInt protected Integer compoundButtonColor = null; public Builder setChecked(boolean checked) { this.checked = checked; @@ -125,6 +134,11 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri this.compoundButtonColorId = compoundButtonColorId; return this; } + + public Builder setCompoundButtonColor(@ColorInt int compoundButtonColor) { + this.compoundButtonColor = compoundButtonColor; + return this; + } public BottomSheetItemWithCompoundButton create() { return new BottomSheetItemWithCompoundButton(customView, diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 4afb671275..fc4bb84f0e 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -1004,7 +1004,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo new TransactionBuilder(mapActivity.getSupportFragmentManager(), settings, mapActivity); builder.addFragmentsData(fragmentsData) .addFragmentsData(OsmandPlugin.getPluginsCardsList()) - .getFragmentTransaction().commit(); + .getFragmentTransaction().commitAllowingStateLoss(); } private void removeFragment(String tag) { diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 5b8f38d2b9..5a69f5b2cd 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -172,7 +172,7 @@ public class ConfigureMapMenu { final MapActivity activity, final int themeRes, final boolean nightMode) { final OsmandApplication app = activity.getMyApplication(); final OsmandSettings settings = app.getSettings(); - final int selectedProfileColorRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode); + final int selectedProfileColor = settings.getApplicationMode().getProfileColor(nightMode); MapLayerMenuListener l = new MapLayerMenuListener(activity, adapter); adapter.addItem(new ContextMenuItem.ItemBuilder() .setId(SHOW_CATEGORY_ID) @@ -184,7 +184,7 @@ public class ConfigureMapMenu { .setId(FAVORITES_ID) .setTitleId(R.string.shared_string_favorites, activity) .setSelected(settings.SHOW_FAVORITES.get()) - .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_action_favorite) .setItemDeleteAction(makeDeleteAction(settings.SHOW_FAVORITES)) .setListener(l) @@ -196,7 +196,7 @@ public class ConfigureMapMenu { .setTitleId(R.string.layer_poi, activity) .setSelected(selected) .setDescription(app.getPoiFilters().getSelectedPoiFiltersName(wiki)) - .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_action_info_dark) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(l).createItem()); @@ -205,7 +205,7 @@ public class ConfigureMapMenu { .setId(POI_OVERLAY_LABELS_ID) .setTitleId(R.string.layer_amenity_label, activity) .setSelected(settings.SHOW_POI_LABEL.get()) - .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_action_text_dark) .setItemDeleteAction(makeDeleteAction(settings.SHOW_POI_LABEL)) .setListener(l).createItem()); @@ -217,7 +217,7 @@ public class ConfigureMapMenu { .setIcon(R.drawable.ic_action_transport_bus) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setSelected(selected) - .setColor(selected ? selectedProfileColorRes : ContextMenuItem.INVALID_ID) + .setColor(selected ? selectedProfileColor : null) .setListener(l).createItem()); selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles(); @@ -226,7 +226,7 @@ public class ConfigureMapMenu { .setTitleId(R.string.layer_gpx_layer, activity) .setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles()) .setDescription(app.getSelectedGpxHelper().getGpxDescription()) - .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_action_polygom_dark) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(l).createItem()); @@ -236,7 +236,7 @@ public class ConfigureMapMenu { .setId(MAP_MARKERS_ID) .setTitleId(R.string.map_markers, activity) .setSelected(selected) - .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_action_flag) .setItemDeleteAction(makeDeleteAction(settings.SHOW_MAP_MARKERS)) .setListener(l).createItem()); @@ -267,8 +267,7 @@ public class ConfigureMapMenu { final int themeRes, final boolean nightMode) { final OsmandApplication app = activity.getMyApplication(); final OsmandSettings settings = app.getSettings(); - final int selectedProfileColorRes = settings.APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode); - final int selectedProfileColor = ContextCompat.getColor(app, selectedProfileColorRes); + final int selectedProfileColor = settings.APPLICATION_MODE.get().getProfileColor(nightMode); adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity) .setId(MAP_RENDERING_CATEGORY_ID) @@ -705,7 +704,6 @@ public class ConfigureMapMenu { for (int i = 0; i < prefs.size(); i++) { prefs.get(i).set(false); } - adapter.getItem(pos).setColorRes(ContextMenuItem.INVALID_ID); a.notifyDataSetInvalidated(); activity.refreshMapComplete(); activity.getMapLayers().updateLayers(activity.getMapView()); @@ -739,7 +737,7 @@ public class ConfigureMapMenu { } } } - builder.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + builder.setColor(activity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); if (useDescription) { final String descr = getDescription(prefs, includedPrefs); builder.setDescription(descr); @@ -840,7 +838,7 @@ public class ConfigureMapMenu { selected |= prefs.get(i).get(); } adapter.getItem(pos).setSelected(selected); - adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.getItem(pos).setColor(activity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); a.notifyDataSetInvalidated(); } }); @@ -875,7 +873,7 @@ public class ConfigureMapMenu { } else { adapter.getItem(pos).setSelected(selected); } - adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.getItem(pos).setColor(activity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); } a.notifyDataSetInvalidated(); activity.refreshMapComplete(); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java index 673f1ce3e7..fbfc5e6fc6 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java @@ -98,7 +98,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet { @Override public void createMenuItems(Bundle savedInstanceState) { - int selectedProfileColorRes = app.getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode); + int selectedProfileColor = app.getSettings().APPLICATION_MODE.get().getProfileColor(nightMode); float spacing = getResources().getDimension(R.dimen.line_spacing_extra_description); LinearLayout linearLayout = new LinearLayout(app); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); @@ -139,7 +139,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet { streetLightsNightPref.set(!onLeftClick); } }) - .setCompoundButtonColorId(selectedProfileColorRes) + .setCompoundButtonColor(selectedProfileColor) .setChecked(pref.get()) .setTitle(propertyName) .setIconHidden(true) @@ -160,7 +160,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet { } else if (!STREET_LIGHTING_NIGHT.equals(property.getAttrName())) { final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1]; item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() - .setCompoundButtonColorId(selectedProfileColorRes) + .setCompoundButtonColor(selectedProfileColor) .setChecked(pref.get()) .setTitle(propertyName) .setIconHidden(true) @@ -217,7 +217,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet { } if (adapter != null) { adapter.getItem(position).setSelected(checked); - adapter.getItem(position).setColorRes(checked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.getItem(position).setColor(app, checked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.getItem(position).setDescription(getString( R.string.ltr_or_rtl_combine_via_slash, String.valueOf(selected), diff --git a/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java b/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java index 29a64bcee4..d3f6fc053d 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java @@ -77,7 +77,7 @@ final class MapLayerMenuListener extends OnRowItemClick { public boolean processResult(Boolean result) { if (item != null) { item.setSelected(result); - item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(mapActivity, result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); } return true; @@ -86,7 +86,7 @@ final class MapLayerMenuListener extends OnRowItemClick { boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication()); if (!selected && item != null) { item.setSelected(true); - item.setColorRes(R.color.osmand_orange); + item.setColor(mapActivity, R.color.osmand_orange); adapter.notifyDataSetChanged(); } return false; @@ -94,7 +94,7 @@ final class MapLayerMenuListener extends OnRowItemClick { CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item); if (btn != null && btn.getVisibility() == View.VISIBLE) { btn.setChecked(!btn.isChecked()); - menuAdapter.getItem(pos).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + menuAdapter.getItem(pos).setColor(mapActivity, btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); return false; } else { @@ -110,7 +110,7 @@ final class MapLayerMenuListener extends OnRowItemClick { final PoiFiltersHelper poiFiltersHelper = mapActivity.getMyApplication().getPoiFilters(); final ContextMenuItem item = menuAdapter.getItem(pos); if (item.getSelected() != null) { - item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(mapActivity, isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); } if (itemId == R.string.layer_poi) { PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter(); @@ -139,7 +139,7 @@ final class MapLayerMenuListener extends OnRowItemClick { @Override public boolean processResult(Boolean result) { item.setSelected(result); - item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(mapActivity, result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); return true; } @@ -171,7 +171,7 @@ final class MapLayerMenuListener extends OnRowItemClick { boolean selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles(); item.setSelected(selected); item.setDescription(app.getSelectedGpxHelper().getGpxDescription()); - item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(mapActivity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); } }); @@ -189,7 +189,7 @@ final class MapLayerMenuListener extends OnRowItemClick { boolean selected = pf.isShowingAnyPoi(wiki); item.setSelected(selected); item.setDescription(pf.getSelectedPoiFiltersName(wiki)); - item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(mapActivity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); } }; diff --git a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapViewQuickActionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapViewQuickActionsBottomSheet.java index 4c5f199824..5b7ba9cc9e 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapViewQuickActionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapViewQuickActionsBottomSheet.java @@ -174,8 +174,8 @@ public class SelectMapViewQuickActionsBottomSheet extends MenuBottomSheetDialogF if (appMode != null) { boolean selected = key.equals(selectedItem); int iconId = appMode.getIconRes(); - int colorId = appMode.getIconColorInfo().getColor(nightMode); - Drawable icon = getIcon(iconId, colorId); + int color = appMode.getProfileColor(nightMode); + Drawable icon = getPaintedIcon(iconId, color); String translatedName = appMode.toHumanString(); createItemRow(selected, counter, icon, translatedName, key); counter++; diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 3081c0680b..3b259ab241 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -516,13 +516,13 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement .setTitleId(R.string.shared_string_refresh, getContext()) .setIcon(R.drawable.ic_action_refresh_dark) .setListener(listener) - .setColor(iconColorResId) + .setColor(getContext(), iconColorResId) .createItem()); optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(R.string.shared_string_delete, getContext()) .setIcon(R.drawable.ic_action_delete_dark) .setListener(listener) - .setColor(iconColorResId) + .setColor(getContext(), iconColorResId) .createItem()); optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(R.string.local_index_mi_backup, getContext()) @@ -554,7 +554,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); } if (contextMenuItem.getIcon() != -1) { - Drawable icMenuItem = getMyApplication().getUIUtilities().getIcon(contextMenuItem.getIcon(), contextMenuItem.getColorRes()); + Drawable icMenuItem = getMyApplication().getUIUtilities().getPaintedIcon(contextMenuItem.getIcon(), contextMenuItem.getColor()); item.setIcon(icMenuItem); } diff --git a/OsmAnd/src/net/osmand/plus/importfiles/FavoritesImportTask.java b/OsmAnd/src/net/osmand/plus/importfiles/FavoritesImportTask.java index fd37d049eb..b62de4923c 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/FavoritesImportTask.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/FavoritesImportTask.java @@ -24,7 +24,7 @@ class FavoritesImportTask extends BaseLoadAsyncTask { private boolean forceImportFavourites; public FavoritesImportTask(@NonNull FragmentActivity activity, @NonNull GPXFile gpxFile, - @NonNull String fileName, boolean forceImportFavourites) { + @NonNull String fileName, boolean forceImportFavourites) { super(activity); this.gpxFile = gpxFile; this.fileName = fileName; diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index e65727b6c1..e35c6e8955 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -6,6 +6,7 @@ import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; +import android.os.AsyncTask.Status; import android.os.Build; import android.os.Bundle; import android.provider.OpenableColumns; @@ -25,6 +26,8 @@ import net.osmand.PlatformUtil; import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.plus.AppInitializer; +import net.osmand.plus.AppInitializer.AppInitializeListener; +import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -212,7 +215,7 @@ public class ImportHelper { public static String getNameFromContentUri(OsmandApplication app, Uri contentUri) { try { String name; - Cursor returnCursor = app.getContentResolver().query(contentUri, new String[] {OpenableColumns.DISPLAY_NAME}, null, null, null); + Cursor returnCursor = app.getContentResolver().query(contentUri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null); if (returnCursor != null && returnCursor.moveToFirst()) { int columnIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); if (columnIndex != -1) { @@ -687,7 +690,7 @@ public class ImportHelper { } else { fpCat = p.category; } - FavouritePoint point = new FavouritePoint(p.lat, p.lon, p.name, fpCat); + FavouritePoint point = new FavouritePoint(p.lat, p.lon, p.name, fpCat, p.ele, 0); if (p.desc != null) { point.setDescription(p.desc); } @@ -707,14 +710,16 @@ public class ImportHelper { @SuppressWarnings("unchecked") private

void executeImportTask(final AsyncTask importTask, final P... requests) { if (app.isApplicationInitializing()) { - app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() { + app.getAppInitializer().addListener(new AppInitializeListener() { @Override - public void onProgress(AppInitializer init, AppInitializer.InitEvents event) { + public void onProgress(AppInitializer init, InitEvents event) { } @Override public void onFinish(AppInitializer init) { - importTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requests); + if (importTask.getStatus() == Status.PENDING) { + importTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requests); + } } }); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 3fe1e4452b..38bf3feb78 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -1036,6 +1036,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL title = ""; } String originObjectName = ""; + double altitude = 0; + long timestamp = System.currentTimeMillis(); Object object = getObject(); if (object != null) { if (object instanceof Amenity) { @@ -1043,10 +1045,13 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } else if (object instanceof TransportStop) { originObjectName = ((TransportStop) object).toStringEn(); } + if (object instanceof WptPt) { + altitude = ((WptPt) object).ele; + } } FavoritePointEditor favoritePointEditor = getFavoritePointEditor(); if (favoritePointEditor != null) { - favoritePointEditor.add(getLatLon(), title, getStreetStr(), originObjectName); + favoritePointEditor.add(getLatLon(), title, getStreetStr(), originObjectName, altitude, timestamp); } } }); @@ -1074,7 +1079,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) { layer.populateObjectContextMenu(latLon, getObject(), menuAdapter, mapActivity); } - mapActivity.getMapActions().addActionsToAdapter(configure ? 0 : latLon.getLatitude(), configure ? 0 : latLon.getLongitude(), menuAdapter, configure ? null : getObject(), configure); } + mapActivity.getMapActions().addActionsToAdapter(configure ? 0 : latLon.getLatitude(), configure ? 0 : latLon.getLongitude(), menuAdapter, configure ? null : getObject(), configure); + } return menuAdapter; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/AddNewFavoriteCategoryBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/AddNewFavoriteCategoryBottomSheet.java new file mode 100644 index 0000000000..d90c06b609 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/AddNewFavoriteCategoryBottomSheet.java @@ -0,0 +1,248 @@ +package net.osmand.plus.mapcontextmenu.editors; + +import android.content.res.ColorStateList; +import android.os.Bundle; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentActivity; + +import com.google.android.material.textfield.TextInputEditText; +import com.google.android.material.textfield.TextInputLayout; + +import net.osmand.AndroidUtils; +import net.osmand.plus.FavouritesDbHelper; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; +import net.osmand.plus.helpers.ColorDialogs; +import net.osmand.plus.myplaces.AddNewTrackFolderBottomSheet; +import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.plus.track.ColorsCard; +import net.osmand.plus.track.CustomColorBottomSheet; +import net.osmand.util.Algorithms; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class AddNewFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFragment implements CustomColorBottomSheet.ColorPickerListener, BaseCard.CardListener { + + + public static final String TAG = AddNewTrackFolderBottomSheet.class.getName(); + private static final String KEY_CTX_EDIT_CAT_EDITOR_TAG = "key_ctx_edit_cat_editor_tag"; + private static final String KEY_CTX_EDIT_GPX_FILE = "key_ctx_edit_gpx_file"; + private static final String KEY_CTX_EDIT_GPX_CATEGORIES = "key_ctx_edit_gpx_categories"; + private static final String KEY_CTX_EDIT_CAT_NEW = "key_ctx_edit_cat_new"; + private static final String KEY_CTX_EDIT_CAT_NAME = "key_ctx_edit_cat_name"; + private static final String KEY_CTX_EDIT_CAT_COLOR = "key_ctx_edit_cat_color"; + FavouritesDbHelper favoritesHelper; + private boolean isNew = true; + private String name = ""; + private boolean isGpx; + private ArrayList gpxCategories; + private int selectedColor; + private ColorsCard colorsCard; + private TextInputEditText editText; + private TextInputLayout nameTextBox; + private View view; + private String editorTag; + private SelectFavoriteCategoryBottomSheet.CategorySelectionListener selectionListener; + + public static AddNewFavoriteCategoryBottomSheet createInstance(@NonNull String editorTag, @Nullable Set gpxCategories, boolean isGpx) { + AddNewFavoriteCategoryBottomSheet fragment = new AddNewFavoriteCategoryBottomSheet(); + Bundle bundle = new Bundle(); + bundle.putString(KEY_CTX_EDIT_CAT_EDITOR_TAG, editorTag); + bundle.putBoolean(KEY_CTX_EDIT_GPX_FILE, isGpx); + if (gpxCategories != null) { + bundle.putStringArrayList(KEY_CTX_EDIT_GPX_CATEGORIES, new ArrayList<>(gpxCategories)); + } + fragment.setArguments(bundle); + fragment.setRetainInstance(true); + return fragment; + } + + public void setSelectionListener(SelectFavoriteCategoryBottomSheet.CategorySelectionListener selectionListener) { + this.selectionListener = selectionListener; + } + + @Override + protected int getRightBottomButtonTextId() { + return R.string.shared_string_save; + } + + private boolean isGpxCategoryExists(@NonNull String name) { + boolean res = false; + if (gpxCategories != null) { + String nameLC = name.toLowerCase(); + for (String category : gpxCategories) { + if (category.toLowerCase().equals(nameLC)) { + res = true; + break; + } + } + } + return res; + } + + @Override + protected void onRightBottomButtonClick() { + name = editText.getText().toString().trim(); + FragmentActivity activity = getActivity(); + if (activity != null) { + boolean exists = isGpx ? isGpxCategoryExists(name) : favoritesHelper.groupExists(name); + if (exists) { + AlertDialog.Builder b = new AlertDialog.Builder(activity); + b.setMessage(getString(R.string.favorite_category_dublicate_message)); + b.setNegativeButton(R.string.shared_string_ok, null); + b.show(); + } else { + if (activity instanceof MapActivity) { + if (!isGpx) { + favoritesHelper.addEmptyCategory(name, selectedColor); + } + PointEditor editor = ((MapActivity) activity).getContextMenu().getPointEditor(editorTag); + + if (editor != null) { + editor.setCategory(name, selectedColor); + } + + if (selectionListener != null) { + selectionListener.onCategorySelected(name, selectedColor); + } + } + dismiss(); + } + } + } + + @Override + protected UiUtilities.DialogButtonType getRightBottomButtonType() { + return UiUtilities.DialogButtonType.PRIMARY; + } + + @Nullable + public FavouritesDbHelper getHelper() { + return favoritesHelper; + } + + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + saveState(outState); + super.onSaveInstanceState(outState); + } + + public void saveState(Bundle bundle) { + bundle.putString(KEY_CTX_EDIT_CAT_EDITOR_TAG, editorTag); + bundle.putString(KEY_CTX_EDIT_CAT_NEW, Boolean.valueOf(isNew).toString()); + bundle.putString(KEY_CTX_EDIT_CAT_NAME, editText.getText().toString().trim()); + bundle.putString(KEY_CTX_EDIT_CAT_COLOR, "" + selectedColor); + bundle.putBoolean(KEY_CTX_EDIT_GPX_FILE, isGpx); + if (gpxCategories != null) { + bundle.putStringArrayList(KEY_CTX_EDIT_GPX_CATEGORIES, gpxCategories); + } + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + OsmandApplication app = requiredMyApplication(); + favoritesHelper = app.getFavorites(); + + if (savedInstanceState != null) { + restoreState(savedInstanceState); + } else if (getArguments() != null) { + restoreState(getArguments()); + } + + + items.add(new TitleItem(getString(R.string.favorite_category_add_new_title))); + selectedColor = getResources().getColor(R.color.color_favorite); + + view = UiUtilities.getInflater(app, nightMode).inflate(R.layout.add_new_favorite_category, null); + nameTextBox = view.findViewById(R.id.name_text_box); + nameTextBox.setBoxBackgroundColorResource(nightMode ? R.color.list_background_color_dark : R.color.activity_background_color_light); + nameTextBox.setHint(app.getResources().getString(R.string.favorite_category_name)); + ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat + .getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light)); + nameTextBox.setDefaultHintTextColor(colorStateList); + editText = view.findViewById(R.id.name_edit_text); + editText.setText(name); + editText.requestFocus(); + AndroidUtils.softKeyboardDelayed(getActivity(), editText); + nameTextBox.setStartIconTintList(ColorStateList.valueOf(selectedColor)); + nameTextBox.setBoxStrokeColorStateList(ColorStateList.valueOf(selectedColor)); + + BaseBottomSheetItem editFolderName = new BaseBottomSheetItem.Builder() + .setCustomView(view) + .create(); + items.add(editFolderName); + MapActivity mapActivity = (MapActivity) getActivity(); + List colors = new ArrayList<>(); + for (int color : ColorDialogs.pallette) { + colors.add(color); + } + colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors, app.getSettings().CUSTOM_TRACK_COLORS, null); + colorsCard.setListener(this); + LinearLayout selectColor = view.findViewById(R.id.select_color); + selectColor.addView(colorsCard.build(view.getContext())); + } + + private void updateColorSelector(int color) { + ((TextView) view.findViewById(R.id.color_name)).setText(ColorDialogs.getColorName(color)); + selectedColor = color; + nameTextBox.setStartIconTintList(ColorStateList.valueOf(selectedColor)); + nameTextBox.setBoxStrokeColorStateList(ColorStateList.valueOf(selectedColor)); + } + + @Override + public void onCardLayoutNeeded(@NonNull BaseCard card) { + + } + + @Override + public void onCardPressed(@NonNull BaseCard card) { + if (card instanceof ColorsCard) { + int color = ((ColorsCard) card).getSelectedColor(); + updateColorSelector(color); + } + } + + @Override + public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) { + + } + + @Override + public void onColorSelected(Integer prevColor, int newColor) { + colorsCard.onColorSelected(prevColor, newColor); + int color = colorsCard.getSelectedColor(); + updateColorSelector(color); + } + + public void restoreState(Bundle bundle) { + editorTag = bundle.getString(KEY_CTX_EDIT_CAT_EDITOR_TAG); + String isNewStr = bundle.getString(KEY_CTX_EDIT_CAT_NEW); + if (isNewStr != null) { + isNew = Boolean.parseBoolean(isNewStr); + } + name = bundle.getString(KEY_CTX_EDIT_CAT_NAME); + if (name == null) { + name = ""; + } + String colorStr = bundle.getString(KEY_CTX_EDIT_CAT_COLOR); + if (!Algorithms.isEmpty(colorStr)) { + selectedColor = Integer.parseInt(colorStr); + } + isGpx = bundle.getBoolean(KEY_CTX_EDIT_GPX_FILE, false); + gpxCategories = bundle.getStringArrayList(KEY_CTX_EDIT_GPX_CATEGORIES); + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java index 513cd707d5..2d2836234c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java @@ -27,7 +27,7 @@ public class FavoritePointEditor extends PointEditor { return favorite; } - public void add(LatLon latLon, String title, String address, String originObjectName) { + public void add(LatLon latLon, String title, String address, String originObjectName, double altitude, long timestamp) { MapActivity mapActivity = getMapActivity(); if (latLon == null || mapActivity == null) { return; @@ -37,7 +37,7 @@ public class FavoritePointEditor extends PointEditor { if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) { lastCategory = ""; } - favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory); + favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory, altitude, timestamp); favorite.setDescription(""); favorite.setAddress(address.isEmpty() ? title : address); favorite.setOriginObjectName(originObjectName); @@ -64,7 +64,6 @@ public class FavoritePointEditor extends PointEditor { favorite.setDescription(""); favorite.setAddress(""); favorite.setOriginObjectName(originObjectName); - FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java index fe05bf4296..e50b1fe724 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java @@ -190,7 +190,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment { final FavouritePoint favorite = getFavorite(); if (favorite != null) { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), - getNameTextValue(), getCategoryTextValue()); + getNameTextValue(), getCategoryTextValue(), favorite.getAltitude(), favorite.getTimestamp()); point.setDescription(getDescriptionTextValue()); point.setAddress(getAddressTextValue()); AlertDialog.Builder builder = FavouritesDbHelper.checkDuplicates(point, helper, getMapActivity()); @@ -198,7 +198,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment { if (favorite.getName().equals(point.getName()) && favorite.getCategory().equals(point.getCategory()) && Algorithms.stringsEqual(favorite.getDescription(), point.getDescription()) && - Algorithms.stringsEqual(favorite.getAddress(),point.getAddress())) { + Algorithms.stringsEqual(favorite.getAddress(), point.getAddress())) { if (needDismiss) { dismiss(false); } @@ -209,7 +209,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment { builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(),point.getAddress(), needDismiss); + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), point.getAddress(), needDismiss); } }); builder.create().show(); @@ -225,9 +225,9 @@ public class FavoritePointEditorFragment extends PointEditorFragment { FavoritePointEditor editor = getFavoritePointEditor(); if (editor != null && helper != null) { if (editor.isNew()) { - doAddFavorite(name, category, description,address); + doAddFavorite(name, category, description, address); } else { - helper.editFavouriteName(favorite, name, category, description,address); + helper.editFavouriteName(favorite, name, category, description, address); } } MapActivity mapActivity = getMapActivity(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java index 3e4093d253..d0f2e31d13 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java @@ -75,6 +75,9 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { FavouritesDbHelper helper = getHelper(); if (editor != null && helper != null) { FavouritePoint favorite = editor.getFavorite(); + if (favorite == null && savedInstanceState != null) { + favorite = (FavouritePoint) savedInstanceState.getSerializable(FavoriteDialogs.KEY_FAVORITE); + } this.favorite = favorite; this.group = helper.getGroup(favorite); this.color = favorite.getColor(); @@ -109,6 +112,12 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { return view; } + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putSerializable(FavoriteDialogs.KEY_FAVORITE, getFavorite()); + } + private void replacePressed() { Bundle args = new Bundle(); args.putSerializable(FavoriteDialogs.KEY_FAVORITE, getFavorite()); @@ -242,7 +251,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { final FavouritePoint favorite = getFavorite(); if (favorite != null) { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), - getNameTextValue(), getCategoryTextValue()); + getNameTextValue(), getCategoryTextValue(), favorite.getAltitude(), favorite.getTimestamp()); point.setDescription(isDescriptionAvailable() ? getDescriptionTextValue() : null); point.setAddress(isAddressAvailable() ? getAddressTextValue() : null); point.setColor(color); @@ -258,7 +267,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { final FavouritePoint favorite = getFavorite(); if (favorite != null) { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), - getNameTextValue(), getCategoryTextValue()); + getNameTextValue(), getCategoryTextValue(), favorite.getAltitude(), favorite.getTimestamp()); point.setDescription(isDescriptionAvailable() ? getDescriptionTextValue() : null); point.setAddress(isAddressAvailable() ? getAddressTextValue() : null); point.setColor(color); @@ -302,7 +311,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { } private void doSave(FavouritePoint favorite, String name, String category, String description, String address, - @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, boolean needDismiss) { + @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, boolean needDismiss) { FavouritesDbHelper helper = getHelper(); FavoritePointEditor editor = getFavoritePointEditor(); if (editor != null && helper != null) { @@ -329,8 +338,8 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { } private void doEditFavorite(FavouritePoint favorite, String name, String category, String description, String address, - @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, - FavouritesDbHelper helper) { + @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, + FavouritesDbHelper helper) { OsmandApplication app = getMyApplication(); if (app != null) { app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category); @@ -342,7 +351,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { } private void doAddFavorite(String name, String category, String description, String address, @ColorInt int color, - BackgroundType backgroundType, @DrawableRes int iconId) { + BackgroundType backgroundType, @DrawableRes int iconId) { OsmandApplication app = getMyApplication(); FavouritesDbHelper helper = getHelper(); FavouritePoint favorite = getFavorite(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java index c24a29ff71..8b8fc64f5b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java @@ -24,6 +24,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; @@ -31,6 +32,7 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; +import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.widgets.AutoCompleteTextViewEx; import net.osmand.util.Algorithms; @@ -136,9 +138,10 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment { @Override public boolean onTouch(final View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { + FragmentManager fragmentManager = getFragmentManager(); DialogFragment dialogFragment = createSelectCategoryDialog(); - if (dialogFragment != null) { - dialogFragment.show(getChildFragmentManager(), SelectCategoryDialogFragment.TAG); + if (fragmentManager != null && dialogFragment != null) { + dialogFragment.show(fragmentManager, SelectFavoriteCategoryBottomSheet.class.getSimpleName()); } return true; } @@ -179,7 +182,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment { protected DialogFragment createSelectCategoryDialog() { PointEditor editor = getEditor(); if (editor != null) { - return SelectCategoryDialogFragment.createInstance(editor.getFragmentTag()); + return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); } else { return null; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index e59ce02373..c4799987f0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -38,6 +38,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -49,6 +50,7 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; +import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.mapcontextmenu.MapContextMenu; @@ -190,9 +192,10 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen groupList.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - DialogFragment dialogFragment = createSelectCategoryDialog(); - if (dialogFragment != null) { - dialogFragment.show(getChildFragmentManager(), SelectCategoryDialogFragment.TAG); + FragmentManager fragmentManager = getFragmentManager(); + DialogFragment dialogFragment = createSelectCategoryDialog(); + if (fragmentManager != null && dialogFragment != null) { + dialogFragment.show(fragmentManager, SelectFavoriteCategoryBottomSheet.class.getSimpleName()); } } }); @@ -474,7 +477,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen if (!ColorDialogs.isPaletteColor(customColor)) { colors.add(customColor); } - colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors); + colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors, app.getSettings().CUSTOM_TRACK_COLORS, null); colorsCard.setListener(this); LinearLayout selectColor = view.findViewById(R.id.select_color); selectColor.addView(colorsCard.build(view.getContext())); @@ -732,7 +735,18 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen protected DialogFragment createSelectCategoryDialog() { PointEditor editor = getEditor(); if (editor != null) { - return SelectCategoryDialogFragment.createInstance(editor.getFragmentTag()); + return SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); + } else { + return null; + } + } + + @Nullable + protected AddNewFavoriteCategoryBottomSheet createAddCategoryDialog() { + PointEditor editor = getEditor(); + if (editor != null) { + return AddNewFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), getCategories(), + !editor.getFragmentTag().equals(FavoritePointEditor.TAG)); } else { return null; } @@ -887,8 +901,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen return true; } - ; - String getNameTextValue() { EditText nameEdit = view.findViewById(R.id.name_edit); return nameEdit.getText().toString().trim(); @@ -1006,12 +1018,10 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen holder.groupButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - PointEditor editor = getEditor(); - if (editor != null) { - EditCategoryDialogFragment dialogFragment = - EditCategoryDialogFragment.createInstance(editor.getFragmentTag(), getCategories(), - !editor.getFragmentTag().equals(FavoritePointEditor.TAG)); - dialogFragment.show(requireActivity().getSupportFragmentManager(), EditCategoryDialogFragment.TAG); + FragmentManager fragmentManager = getFragmentManager(); + DialogFragment dialogFragment = createAddCategoryDialog(); + if (fragmentManager != null && dialogFragment != null) { + dialogFragment.show(fragmentManager, SelectFavoriteCategoryBottomSheet.class.getSimpleName()); } } }); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/RtePtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/RtePtEditorFragment.java index 840ebba24f..9bbbb0ec34 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/RtePtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/RtePtEditorFragment.java @@ -23,7 +23,7 @@ public class RtePtEditorFragment extends WptPtEditorFragment { @Override protected DialogFragment createSelectCategoryDialog() { PointEditor editor = getEditor(); - return editor != null ? SelectCategoryDialogFragment.createInstance(editor.getFragmentTag()) : null; + return editor != null ? SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()) : null; } public static void showInstance(final MapActivity mapActivity) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java new file mode 100644 index 0000000000..c3ee4169dc --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectFavoriteCategoryBottomSheet.java @@ -0,0 +1,232 @@ +package net.osmand.plus.mapcontextmenu.editors; + +import android.app.Activity; +import android.graphics.PorterDuff; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.ScrollView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; +import androidx.fragment.app.FragmentActivity; + +import net.osmand.AndroidUtils; +import net.osmand.GPXUtilities; +import net.osmand.plus.FavouritesDbHelper; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.helpers.FontCache; +import net.osmand.plus.myplaces.AddNewTrackFolderBottomSheet; +import net.osmand.util.Algorithms; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFragment { + + public static final String TAG = SelectFavoriteCategoryBottomSheet.class.getSimpleName(); + private static final String KEY_CTX_SEL_CAT_EDITOR_TAG = "key_ctx_sel_cat_editor_tag"; + private static String editorTag; + private OsmandApplication app; + private GPXUtilities.GPXFile gpxFile; + private Map gpxCategories; + private SelectFavoriteCategoryBottomSheet.CategorySelectionListener selectionListener; + + + private static Drawable getIcon(final Activity activity, int resId, int color) { + Drawable drawable = AppCompatResources.getDrawable(activity, resId); + if (drawable != null) { + drawable = DrawableCompat.wrap(drawable).mutate(); + drawable.clearColorFilter(); + drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); + } + return drawable; + } + + public static SelectFavoriteCategoryBottomSheet createInstance(String editorTag) { + SelectFavoriteCategoryBottomSheet fragment = new SelectFavoriteCategoryBottomSheet(); + Bundle bundle = new Bundle(); + bundle.putString(KEY_CTX_SEL_CAT_EDITOR_TAG, editorTag); + fragment.setArguments(bundle); + fragment.setRetainInstance(true); + return fragment; + } + + public void setSelectionListener(SelectFavoriteCategoryBottomSheet.CategorySelectionListener selectionListener) { + this.selectionListener = selectionListener; + } + + public GPXUtilities.GPXFile getGpxFile() { + return gpxFile; + } + + public void setGpxFile(GPXUtilities.GPXFile gpxFile) { + this.gpxFile = gpxFile; + } + + public void setGpxCategories(Map gpxCategories) { + this.gpxCategories = gpxCategories; + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + app = requiredMyApplication(); + if (savedInstanceState != null) { + restoreState(savedInstanceState); + } else if (getArguments() != null) { + restoreState(getArguments()); + } + + BaseBottomSheetItem titleItem = new BottomSheetItemWithDescription.Builder() + .setDescription(getString(R.string.select_category_descr)) + .setTitle(getString(R.string.favorite_category_select)) + .setLayoutId(R.layout.bottom_sheet_item_title_with_description) + .create(); + items.add(titleItem); + final FragmentActivity activity = requireActivity(); + + View addNewCategoryView = UiUtilities.getInflater(app, nightMode).inflate(R.layout.bottom_sheet_item_with_descr_64dp, null); + addNewCategoryView.setMinimumHeight(getResources().getDimensionPixelSize(R.dimen.bottom_sheet_list_item_height)); + TextView title = addNewCategoryView.findViewById(R.id.title); + Typeface typeface = FontCache.getRobotoMedium(getContext()); + title.setTypeface(typeface); + AndroidUiHelper.updateVisibility(addNewCategoryView.findViewById(R.id.description), false); + BaseBottomSheetItem addNewFolderItem = new SimpleBottomSheetItem.Builder() + .setTitle(getString(R.string.favorite_category_add_new)) + .setTitleColorId(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light) + .setIcon(getActiveIcon(R.drawable.ic_action_folder_add)) + .setLayoutId(R.layout.bottom_sheet_item_with_descr_64dp) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MapActivity mapActivity = (MapActivity) getActivity(); + Set categories = gpxCategories != null ? gpxCategories.keySet() : null; + AddNewFavoriteCategoryBottomSheet fragment = AddNewFavoriteCategoryBottomSheet.createInstance(editorTag, categories, gpxFile != null); + if (mapActivity != null) { + fragment.show(mapActivity.getSupportFragmentManager(), AddNewTrackFolderBottomSheet.class.getName()); + } + fragment.setSelectionListener(selectionListener); + dismiss(); + } + }) + .setCustomView(addNewCategoryView) + .create(); + items.add(addNewFolderItem); + + DividerItem dividerItem = new DividerItem(app); + dividerItem.setMargins(0, 0, 0, 0); + items.add(dividerItem); + + View favoriteCategoryList = UiUtilities.getInflater(app, nightMode).inflate(R.layout.favorite_categories_dialog, null); + ScrollView scrollContainer = favoriteCategoryList.findViewById(R.id.scroll_container); + final int dp16 = AndroidUtils.dpToPx(app, 16f); + scrollContainer.setPadding(dp16,0, dp16,0); + LinearLayout favoriteCategoryContainer = favoriteCategoryList.findViewById(R.id.list_container); + + final FavouritesDbHelper favoritesHelper = app.getFavorites(); + if (gpxFile != null) { + if (gpxCategories != null) { + for (Map.Entry e : gpxCategories.entrySet()) { + String categoryName = e.getKey(); + String favoriteCategoryCount = String.valueOf(e.getKey().length()); + favoriteCategoryContainer.addView(createCategoryItem(activity, nightMode, categoryName, e.getValue(), favoriteCategoryCount, false)); + } + } + } else { + List gs = favoritesHelper.getFavoriteGroups(); + for (final FavouritesDbHelper.FavoriteGroup category : gs) { + String favoriteCategoryCount; + if (Algorithms.isEmpty(category.getPoints())) { + favoriteCategoryCount = app.getString(R.string.shared_string_empty); + } else { + favoriteCategoryCount = String.valueOf(category.getPoints().size()); + } + favoriteCategoryContainer.addView(createCategoryItem(activity, nightMode, category.getDisplayName(getContext()), + category.getColor(), favoriteCategoryCount, !category.isVisible())); + } + } + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(favoriteCategoryList) + .create()); + } + + private View createCategoryItem(@NonNull final Activity activity, boolean nightMode, final String categoryName, final int categoryColor, String categoryPointCount, boolean isHidden) { + View itemView = UiUtilities.getInflater(activity, nightMode).inflate(R.layout.bottom_sheet_item_with_descr_and_radio_btn, null); + final AppCompatImageView button = (AppCompatImageView) itemView.findViewById(R.id.icon); + final int dp8 = AndroidUtils.dpToPx(app, 8f); + button.setPadding(0,0, dp8,0); + LinearLayout descriptionContainer = itemView.findViewById(R.id.descriptionContainer); + descriptionContainer.setPadding(0, 0, 0, 0); + View divider = itemView.findViewById(R.id.divider_bottom); + divider.setVisibility(View.GONE); + itemView.setPadding(0, 0, 0, 0); + final RadioButton compoundButton = itemView.findViewById(R.id.compound_button); + int activeColorId = nightMode ? + R.color.active_color_primary_dark : R.color.active_color_primary_light; + int disableColorId = nightMode ? + R.color.icon_color_default_dark : R.color.icon_color_default_light; + UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app, + nightMode ? activeColorId : disableColorId), compoundButton); + + if (isHidden) { + button.setImageResource(R.drawable.ic_action_hide); + } else { + if (categoryColor != 0) { + button.setImageDrawable(getIcon(activity, R.drawable.ic_action_folder, categoryColor)); + } else { + button.setImageDrawable(getIcon(activity, R.drawable.ic_action_folder, ContextCompat.getColor(activity, + gpxFile != null ? R.color.gpx_color_point : R.color.color_favorite))); + } + } + String name = categoryName.length() == 0 ? getString(R.string.shared_string_favorites) : categoryName; + TextView text = itemView.findViewById(R.id.title); + TextView description = itemView.findViewById(R.id.description); + text.setText(name); + description.setText(String.valueOf(categoryPointCount)); + descriptionContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FragmentActivity a = getActivity(); + compoundButton.setSelected(true); + if (a instanceof MapActivity) { + PointEditor pointEditor = ((MapActivity) a).getContextMenu().getPointEditor(editorTag); + if (pointEditor != null) { + pointEditor.setCategory(categoryName, categoryColor); + } + if (selectionListener != null) { + selectionListener.onCategorySelected(categoryName, categoryColor); + } + } + dismiss(); + } + }); + return itemView; + } + + public void restoreState(Bundle bundle) { + editorTag = bundle.getString(KEY_CTX_SEL_CAT_EDITOR_TAG); + } + + public interface CategorySelectionListener { + + void onCategorySelected(String category, int color); + } + +} diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java index f5ef3033c8..a3efbca5ad 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java @@ -67,7 +67,7 @@ public class WptPtEditorFragment extends PointEditorFragment { protected DialogFragment createSelectCategoryDialog() { WptPtEditor editor = getWptPtEditor(); if (editor != null) { - SelectCategoryDialogFragment selectCategoryDialogFragment = SelectCategoryDialogFragment.createInstance(editor.getFragmentTag()); + SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); GPXFile gpx = editor.getGpxFile(); if (gpx != null) { selectCategoryDialogFragment.setGpxFile(gpx); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index c948b5414e..456049403e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -81,7 +81,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { protected DialogFragment createSelectCategoryDialog() { WptPtEditor editor = getWptPtEditor(); if (editor != null) { - SelectCategoryDialogFragment selectCategoryDialogFragment = SelectCategoryDialogFragment.createInstance(editor.getFragmentTag()); + SelectFavoriteCategoryBottomSheet selectCategoryDialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag()); GPXFile gpx = editor.getGpxFile(); if (gpx != null) { selectCategoryDialogFragment.setGpxFile(gpx); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java index 005433cbe2..897de79b6c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java @@ -36,7 +36,7 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingPar import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.VoiceGuidanceRoutingParameter; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; @@ -373,13 +373,13 @@ public class RoutePreferencesMenu { } private void updateSpinnerItems(final TextView gpxSpinner) { - RouteProvider.GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); gpxSpinner.setText(rp == null ? mapActivity.getString(R.string.shared_string_none) : new File(rp.getFile().path).getName()); } private void showOptionsMenu(final TextView gpxSpinner) { - RouteProvider.GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); final PopupMenu optionsMenu = new PopupMenu(gpxSpinner.getContext(), gpxSpinner); MenuItem item = optionsMenu.getMenu().add( mapActivity.getString(R.string.shared_string_none)); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java index 53384024ff..5d040765b6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java @@ -38,7 +38,7 @@ public class ShareMenu extends BaseMenuController { MESSAGE(R.drawable.ic_action_message, R.string.shared_string_send), CLIPBOARD(R.drawable.ic_action_copy, R.string.shared_string_copy), ADDRESS(R.drawable.ic_action_street_name, R.string.copy_address), - NAME(R.drawable.ic_action_copy, R.string.copy_location_name), + NAME(R.drawable.ic_action_copy, R.string.copy_poi_name), COORDINATES(R.drawable.ic_action_copy, R.string.copy_coordinates), GEO(R.drawable.ic_world_globe_dark, R.string.share_geo), QR_CODE(R.drawable.ic_action_qrcode, R.string.shared_string_qr_code); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java index 6b03cd3a6a..3cf0398d87 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java @@ -61,8 +61,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { final int backgroundColor = ContextCompat.getColor(getActivity(), nightMode ? R.color.activity_background_color_dark : R.color.activity_background_color_light); final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM); - final int currentModeColorRes = getMyApplication().getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode); - final int currentModeColor = ContextCompat.getColor(getActivity(), currentModeColorRes); + final int currentModeColor = getMyApplication().getSettings().getApplicationMode().getProfileColor(nightMode); final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_mapillary_filters, null); view.findViewById(R.id.mapillary_filters_linear_layout).setBackgroundColor(backgroundColor); @@ -71,17 +70,17 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { final View toggleRow = view.findViewById(R.id.toggle_row); final boolean selected = settings.SHOW_MAPILLARY.get(); final int toggleActionStringId = selected ? R.string.shared_string_on : R.string.shared_string_off; - int toggleIconColorId; + int toggleIconColor; int toggleIconId; if (selected) { toggleIconId = R.drawable.ic_action_view; - toggleIconColorId = currentModeColorRes; + toggleIconColor = currentModeColor; } else { toggleIconId = R.drawable.ic_action_hide; - toggleIconColorId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; + toggleIconColor = ContextCompat.getColor(getContext(), nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light); } ((AppCompatTextView) toggleRow.findViewById(R.id.toggle_row_title)).setText(toggleActionStringId); - final Drawable drawable = getIcon(toggleIconId, toggleIconColorId); + final Drawable drawable = getPaintedContentIcon(toggleIconId, toggleIconColor); ((AppCompatImageView) toggleRow.findViewById(R.id.toggle_row_icon)).setImageDrawable(drawable); final CompoundButton toggle = (CompoundButton) toggleRow.findViewById(R.id.toggle_row_toggle); toggle.setOnCheckedChangeListener(null); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index bc2b0dbc95..4be50700cc 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -185,7 +185,7 @@ public class MapillaryPlugin extends OsmandPlugin { ContextMenuItem item = adapter.getItem(pos); if (item != null) { item.setSelected(settings.SHOW_MAPILLARY.get()); - item.setColorRes(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(app, settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); } } @@ -201,7 +201,7 @@ public class MapillaryPlugin extends OsmandPlugin { .setTitleId(R.string.street_level_imagery, mapActivity) .setDescription("Mapillary") .setSelected(settings.SHOW_MAPILLARY.get()) - .setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_action_mapillary) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setItemDeleteAction(makeDeleteAction(settings.SHOW_MAPILLARY)) diff --git a/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java index fcf881c0eb..2d883e223c 100644 --- a/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java @@ -99,8 +99,7 @@ public class InputZoomLevelsBottomSheet extends MenuBottomSheetDialogFragment { final TextView maxZoomValue = sliderView.findViewById(R.id.zoom_value_max); maxZoomValue.setText(String.valueOf(maxZoom)); RangeSlider slider = sliderView.findViewById(R.id.zoom_slider); - int colorProfileRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode); - int colorProfile = ContextCompat.getColor(app, colorProfileRes); + int colorProfile = app.getSettings().getApplicationMode().getProfileColor(nightMode); UiUtilities.setupSlider(slider, nightMode, colorProfile, true); slider.setValueFrom(SLIDER_FROM); slider.setValueTo(SLIDER_TO); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index bf6ee212dc..74f636802a 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -1350,7 +1350,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route snapToRoadBtn.setVisibility(View.VISIBLE); profileWithConfig.setVisibility(View.GONE); } else { - icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode)); + icon = getPaintedContentIcon(appMode.getIconRes(), appMode.getProfileColor(nightMode)); snapToRoadBtn.setVisibility(View.GONE); profileWithConfig.setVisibility(View.VISIBLE); } @@ -2073,7 +2073,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route private void startTrackNavigation() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - if (editingCtx.hasRoute()) { + if (editingCtx.hasRoute() || editingCtx.hasChanges()) { String trackName = getSuggestedFileName(); GPXFile gpx = editingCtx.exportGpx(trackName); if (gpx != null) { diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java index 35397f269e..8c8eacee67 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java @@ -55,7 +55,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm icon = getContentIcon(R.drawable.ic_action_split_interval); } else { description = routeAppMode.toHumanString(); - icon = getIcon(routeAppMode.getIconRes(), routeAppMode.getIconColorInfo().getColor(nightMode)); + icon = getPaintedIcon(routeAppMode.getIconRes(), routeAppMode.getProfileColor(nightMode)); } } else { description = getString(R.string.shared_string_undefined); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java b/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java index 8fc3be3037..179ad54645 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java @@ -49,7 +49,7 @@ public class ProfileCard extends BaseCard { for (int i = 0; i < modes.size(); i++) { ApplicationMode mode = modes.get(i); LinearLayout container = view.findViewById(R.id.content_container); - Drawable icon = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)); + Drawable icon = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)); String title = mode.toHumanString(); View.OnClickListener onClickListener = new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java index 54bc3469be..12eff78327 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java @@ -117,7 +117,7 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetBeha for (int i = 0; i < modes.size(); i++) { ApplicationMode mode = modes.get(i); if (!"public_transport".equals(mode.getRoutingProfile())) { - icon = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)); + icon = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)); addProfileView(navigationType, onClickListener, i, icon, mode.toHumanString(), mode.equals(appMode)); } } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java index b18592edb8..d482299931 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java @@ -403,7 +403,7 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo if (MeasurementEditingContext.DEFAULT_APP_MODE.equals(routeAppMode)) { icon = getContentIcon(R.drawable.ic_action_split_interval); } else { - icon = getIcon(routeAppMode.getIconRes(), routeAppMode.getIconColorInfo().getColor(nightMode)); + icon = getPaintedIcon(routeAppMode.getIconRes(), routeAppMode.getProfileColor(nightMode)); } return icon; } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java index 35f3bc47cd..082633a854 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java @@ -106,7 +106,7 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme for (int i = 0; i < modes.size(); i++) { ApplicationMode mode = modes.get(i); - Drawable icon = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)); + Drawable icon = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)); addProfileView(container, onClickListener, i, icon, mode.toHumanString()); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index a3d2b78bd5..2799ac8ded 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -560,7 +560,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { ApplicationMode appMode = app.getSettings().getApplicationMode(); int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light); int textColorSecondary = ContextCompat.getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light); - int selectedModeColor = ContextCompat.getColor(uiCtx, appMode.getIconColorInfo().getColor(nightMode)); + int selectedModeColor = appMode.getProfileColor(nightMode); LinearLayout ll = new LinearLayout(uiCtx); final int dp24 = AndroidUtils.dpToPx(uiCtx, 24f); final int dp8 = AndroidUtils.dpToPx(uiCtx, 8f); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 640d01e4c9..bbaf9295f7 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -116,8 +116,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { container = itemView.findViewById(R.id.always_ask_and_range_slider_container); RangeSlider intervalSlider = itemView.findViewById(R.id.interval_slider); intervalSlider.setValueTo(secondsLength + minutesLength - 1); - int currentModeColorRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode); - int currentModeColor = ContextCompat.getColor(app, currentModeColorRes); + int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode); UiUtilities.setupSlider(intervalSlider, nightMode, currentModeColor, true); container.setVisibility(View.GONE); intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 22615a2f76..b5f33884ac 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -1005,6 +1005,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } } }); + notifyDataSetChanged(); } public Set getSelectedGpx() { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java index 1e8efe343b..674ee76042 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java @@ -121,7 +121,7 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment final ApplicationMode mode = app.getSettings().getApplicationMode(); final BottomSheetItemWithCompoundButton[] showOnMapItem = new BottomSheetItemWithCompoundButton[1]; showOnMapItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() - .setCompoundButtonColorId(mode.getIconColorInfo().getColor(nightMode)) + .setCompoundButtonColor(mode.getProfileColor(nightMode)) .setChecked(checked) .setTitle(getString(R.string.shared_string_show_on_map)) .setCustomView(getCustomButtonView(app, mode, checked, nightMode)) diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingFactory.java b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingFactory.java deleted file mode 100644 index 4b92000847..0000000000 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.osmand.plus.onlinerouting; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import net.osmand.plus.onlinerouting.engine.EngineType; -import net.osmand.plus.onlinerouting.engine.GraphhopperEngine; -import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine; -import net.osmand.plus.onlinerouting.engine.OrsEngine; -import net.osmand.plus.onlinerouting.engine.OsrmEngine; - -import java.util.Map; - -public class OnlineRoutingFactory { - - public static OnlineRoutingEngine createEngine(@NonNull EngineType type) { - return createEngine(type, null); - } - - @NonNull - public static OnlineRoutingEngine createEngine(@NonNull EngineType type, - @Nullable Map params) { - switch (type) { - case GRAPHHOPPER: - return new GraphhopperEngine(params); - case OSRM: - return new OsrmEngine(params); - case ORS: - return new OrsEngine(params); - default: - throw new IllegalArgumentException( - "Online routing type {" + type.name() + "} not supported"); - } - } - -} diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingHelper.java b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingHelper.java index de36b87449..9ae8f5cb02 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingHelper.java @@ -18,14 +18,20 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; +import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.zip.GZIPInputStream; +import java.util.zip.ZipInputStream; +import static net.osmand.util.Algorithms.GZIP_FILE_SIGNATURE; +import static net.osmand.util.Algorithms.ZIP_FILE_SIGNATURE; import static net.osmand.util.Algorithms.isEmpty; public class OnlineRoutingHelper { @@ -88,7 +94,7 @@ public class OnlineRoutingHelper { boolean leftSideNavigation) throws IOException, JSONException { String url = engine.getFullUrl(path); String content = makeRequest(url); - return engine.parseServerResponse(content, app, leftSideNavigation); + return engine.parseResponse(content, app, leftSideNavigation); } @NonNull @@ -98,7 +104,7 @@ public class OnlineRoutingHelper { StringBuilder content = new StringBuilder(); BufferedReader reader; if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { - reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + reader = new BufferedReader(new InputStreamReader(getInputStream(connection))); } else { reader = new BufferedReader(new InputStreamReader(connection.getErrorStream())); } @@ -113,6 +119,18 @@ public class OnlineRoutingHelper { return content.toString(); } + private InputStream getInputStream(@NonNull HttpURLConnection connection) throws IOException { + ByteArrayInputStream localIS = Algorithms.createByteArrayIS(connection.getInputStream()); + if (Algorithms.checkFileSignature(localIS, ZIP_FILE_SIGNATURE)) { + ZipInputStream zipIS = new ZipInputStream(localIS); + zipIS.getNextEntry(); // set position to reading for the first item + return zipIS; + } else if (Algorithms.checkFileSignature(localIS, GZIP_FILE_SIGNATURE)) { + return new GZIPInputStream(localIS); + } + return localIS; + } + public void saveEngine(@NonNull OnlineRoutingEngine engine) { deleteInaccessibleParameters(engine); String key = createEngineKeyIfNeeded(engine); diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingUtils.java b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingUtils.java index 90eb4ea83c..ce8ea65f7c 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingUtils.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingUtils.java @@ -7,8 +7,8 @@ import androidx.annotation.NonNull; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import net.osmand.plus.onlinerouting.engine.EngineType; import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine; +import net.osmand.plus.onlinerouting.engine.EngineType; import net.osmand.util.Algorithms; import org.json.JSONArray; @@ -60,10 +60,10 @@ public class OnlineRoutingUtils { for (int i = 0; i < itemsJson.length(); i++) { JSONObject object = itemsJson.getJSONObject(i); if (object.has(TYPE) && object.has(PARAMS)) { - EngineType type = EngineType.getTypeByName(object.getString(TYPE)); + OnlineRoutingEngine type = EngineType.getTypeByName(object.getString(TYPE)); String paramsString = object.getString(PARAMS); HashMap params = gson.fromJson(paramsString, typeToken); - OnlineRoutingEngine engine = OnlineRoutingFactory.createEngine(type, params); + OnlineRoutingEngine engine = type.newInstance(params); if (!Algorithms.isEmpty(engine.getStringKey())) { engines.add(engine); } @@ -82,7 +82,7 @@ public class OnlineRoutingUtils { continue; } JSONObject jsonObject = new JSONObject(); - jsonObject.put(TYPE, engine.getType().name()); + jsonObject.put(TYPE, engine.getTypeName()); jsonObject.put(PARAMS, gson.toJson(engine.getParams(), type)); jsonArray.put(jsonObject); } diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/VehicleType.java b/OsmAnd/src/net/osmand/plus/onlinerouting/VehicleType.java index 9936f8efbf..494f3aa7a1 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/VehicleType.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/VehicleType.java @@ -6,6 +6,7 @@ import androidx.annotation.NonNull; import androidx.annotation.StringRes; public class VehicleType { + private final String key; @StringRes private final int titleId; diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/EngineType.java b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/EngineType.java index 431ad33a3d..5b6614691e 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/EngineType.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/EngineType.java @@ -1,34 +1,38 @@ package net.osmand.plus.onlinerouting.engine; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import net.osmand.util.Algorithms; -public enum EngineType { - GRAPHHOPPER("Graphhopper"), - OSRM("OSRM"), - ORS("Openroute Service"); +public class EngineType { - private final String title; + public final static OnlineRoutingEngine GRAPHHOPPER_TYPE = new GraphhopperEngine(null); + public final static OnlineRoutingEngine OSRM_TYPE = new OsrmEngine(null); + public final static OnlineRoutingEngine ORS_TYPE = new OrsEngine(null); + public final static OnlineRoutingEngine GPX_TYPE = new GpxEngine(null); - EngineType(String title) { - this.title = title; - } + private static OnlineRoutingEngine[] enginesTypes; - public String getTitle() { - return title; + public static OnlineRoutingEngine[] values() { + if (enginesTypes == null) { + enginesTypes = new OnlineRoutingEngine[]{ + GRAPHHOPPER_TYPE, + OSRM_TYPE, + ORS_TYPE, + GPX_TYPE + }; + } + return enginesTypes; } @NonNull - public static EngineType getTypeByName(@Nullable String name) { - if (!Algorithms.isEmpty(name)) { - for (EngineType type : values()) { - if (type.name().equals(name)) { - return type; - } + public static OnlineRoutingEngine getTypeByName(@NonNull String typeName) { + for (OnlineRoutingEngine type : values()) { + if (Algorithms.objectEquals(type.getTypeName(), typeName)) { + return type; } } return values()[0]; } + } diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/GpxEngine.java b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/GpxEngine.java new file mode 100644 index 0000000000..6dc5ed6d88 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/GpxEngine.java @@ -0,0 +1,111 @@ +package net.osmand.plus.onlinerouting.engine; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.data.LatLon; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.onlinerouting.EngineParameter; +import net.osmand.plus.onlinerouting.VehicleType; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static net.osmand.plus.onlinerouting.engine.EngineType.GPX_TYPE; + +public class GpxEngine extends OnlineRoutingEngine { + + public GpxEngine(@Nullable Map params) { + super(params); + } + + @NonNull + @Override + public OnlineRoutingEngine getType() { + return GPX_TYPE; + } + + @Override + @NonNull + public String getTitle() { + return "GPX"; + } + + @NonNull + @Override + public String getTypeName() { + return "GPX"; + } + + @Override + protected void makeFullUrl(@NonNull StringBuilder sb, + @NonNull List path) { + sb.append("?"); + for (int i = 0; i < path.size(); i++) { + LatLon point = path.get(i); + sb.append("point=") + .append(point.getLatitude()) + .append(',') + .append(point.getLongitude()); + if (i < path.size() - 1) { + sb.append('&'); + } + } + } + + @NonNull + @Override + public String getStandardUrl() { + return ""; + } + + @Override + protected void collectAllowedVehicles(@NonNull List vehicles) { + + } + + @Override + protected void collectAllowedParameters(@NonNull Set params) { + params.add(EngineParameter.KEY); + params.add(EngineParameter.CUSTOM_NAME); + params.add(EngineParameter.NAME_INDEX); + params.add(EngineParameter.CUSTOM_URL); + } + + @Override + public OnlineRoutingEngine newInstance(Map params) { + return new GpxEngine(params); + } + + @Override + @Nullable + public OnlineRoutingResponse parseResponse(@NonNull String content, + @NonNull OsmandApplication app, + boolean leftSideNavigation) { + GPXFile gpxFile = parseGpx(content); + return gpxFile != null ? new OnlineRoutingResponse(parseGpx(content)) : null; + } + + @Override + public boolean isResultOk(@NonNull StringBuilder errorMessage, + @NonNull String content) { + return parseGpx(content) != null; + } + + private GPXFile parseGpx(@NonNull String content) { + InputStream gpxStream; + try { + gpxStream = new ByteArrayInputStream(content.getBytes("UTF-8")); + return GPXUtilities.loadGPXFile(gpxStream); + } catch (UnsupportedEncodingException e) { + LOG.debug("Error when parsing GPX from server response: " + e.getMessage()); + } + return null; + } +} diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/GraphhopperEngine.java b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/GraphhopperEngine.java index 930ebcab8d..f86e8e66fc 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/GraphhopperEngine.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/GraphhopperEngine.java @@ -20,10 +20,12 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; +import static net.osmand.plus.onlinerouting.engine.EngineType.GRAPHHOPPER_TYPE; import static net.osmand.util.Algorithms.isEmpty; -public class GraphhopperEngine extends OnlineRoutingEngine { +public class GraphhopperEngine extends JsonOnlineRoutingEngine { public GraphhopperEngine(@Nullable Map params) { super(params); @@ -31,8 +33,20 @@ public class GraphhopperEngine extends OnlineRoutingEngine { @NonNull @Override - public EngineType getType() { - return EngineType.GRAPHHOPPER; + public OnlineRoutingEngine getType() { + return GRAPHHOPPER_TYPE; + } + + @Override + @NonNull + public String getTitle() { + return "Graphhopper"; + } + + @NonNull + @Override + public String getTypeName() { + return "GRAPHHOPPER"; } @NonNull @@ -42,8 +56,18 @@ public class GraphhopperEngine extends OnlineRoutingEngine { } @Override - protected void collectAllowedParameters() { - allowParameters(EngineParameter.API_KEY); + protected void collectAllowedParameters(@NonNull Set params) { + params.add(EngineParameter.KEY); + params.add(EngineParameter.VEHICLE_KEY); + params.add(EngineParameter.CUSTOM_NAME); + params.add(EngineParameter.NAME_INDEX); + params.add(EngineParameter.CUSTOM_URL); + params.add(EngineParameter.API_KEY); + } + + @Override + public OnlineRoutingEngine newInstance(Map params) { + return new GraphhopperEngine(params); } @Override @@ -63,16 +87,19 @@ public class GraphhopperEngine extends OnlineRoutingEngine { protected void makeFullUrl(@NonNull StringBuilder sb, @NonNull List path) { sb.append("?"); - for (LatLon point : path) { + for (int i = 0; i < path.size(); i++) { + LatLon point = path.get(i); sb.append("point=") .append(point.getLatitude()) .append(',') - .append(point.getLongitude()) - .append('&'); + .append(point.getLongitude()); + if (i < path.size() - 1) { + sb.append('&'); + } } String vehicle = get(EngineParameter.VEHICLE_KEY); if (!isEmpty(vehicle)) { - sb.append("vehicle=").append(vehicle); + sb.append('&').append("vehicle=").append(vehicle); } String apiKey = get(EngineParameter.API_KEY); if (!isEmpty(apiKey)) { @@ -82,10 +109,9 @@ public class GraphhopperEngine extends OnlineRoutingEngine { } @Nullable - @Override - public OnlineRoutingResponse parseServerResponse(@NonNull JSONObject root, - @NonNull OsmandApplication app, - boolean leftSideNavigation) throws JSONException { + protected OnlineRoutingResponse parseServerResponse(@NonNull JSONObject root, + @NonNull OsmandApplication app, + boolean leftSideNavigation) throws JSONException { String encoded = root.getString("points"); List points = GeoPolylineParserUtil.parse(encoded, GeoPolylineParserUtil.PRECISION_5); if (isEmpty(points)) return null; @@ -223,4 +249,5 @@ public class GraphhopperEngine extends OnlineRoutingEngine { protected String getRootArrayKey() { return "paths"; } + } diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/JsonOnlineRoutingEngine.java b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/JsonOnlineRoutingEngine.java new file mode 100644 index 0000000000..dcd191da19 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/JsonOnlineRoutingEngine.java @@ -0,0 +1,82 @@ +package net.osmand.plus.onlinerouting.engine; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.GPXUtilities.WptPt; +import net.osmand.Location; +import net.osmand.data.LatLon; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.routing.RouteProvider; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static net.osmand.util.Algorithms.isEmpty; + +public abstract class JsonOnlineRoutingEngine extends OnlineRoutingEngine { + + public JsonOnlineRoutingEngine(@Nullable Map params) { + super(params); + } + + @Nullable + public OnlineRoutingResponse parseResponse(@NonNull String content, + @NonNull OsmandApplication app, + boolean leftSideNavigation) throws JSONException { + JSONObject root = parseRootResponseObject(content); + return root != null ? parseServerResponse(root, app, leftSideNavigation) : null; + } + + @Nullable + protected JSONObject parseRootResponseObject(@NonNull String content) throws JSONException { + JSONObject fullJSON = new JSONObject(content); + String key = getRootArrayKey(); + JSONArray array = null; + if (fullJSON.has(key)) { + array = fullJSON.getJSONArray(key); + } + return array != null && array.length() > 0 ? array.getJSONObject(0) : null; + } + + public boolean isResultOk(@NonNull StringBuilder errorMessage, + @NonNull String content) throws JSONException { + JSONObject obj = new JSONObject(content); + String messageKey = getErrorMessageKey(); + if (obj.has(messageKey)) { + String message = obj.getString(messageKey); + errorMessage.append(message); + } + return obj.has(getRootArrayKey()); + } + + @Nullable + protected abstract OnlineRoutingResponse parseServerResponse(@NonNull JSONObject root, + @NonNull OsmandApplication app, + boolean leftSideNavigation) throws JSONException; + + @NonNull + protected abstract String getRootArrayKey(); + + @NonNull + protected abstract String getErrorMessageKey(); + + @NonNull + protected static List convertRouteToLocationsList(@NonNull List route) { + List result = new ArrayList<>(); + if (!isEmpty(route)) { + for (LatLon pt : route) { + WptPt wpt = new WptPt(); + wpt.lat = pt.getLatitude(); + wpt.lon = pt.getLongitude(); + result.add(RouteProvider.createLocation(wpt)); + } + } + return result; + } +} diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OnlineRoutingEngine.java b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OnlineRoutingEngine.java index 0752282c70..670375c0b5 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OnlineRoutingEngine.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OnlineRoutingEngine.java @@ -5,24 +5,21 @@ import android.content.Context; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import net.osmand.GPXUtilities.WptPt; +import net.osmand.GPXUtilities.GPXFile; import net.osmand.Location; +import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.onlinerouting.EngineParameter; -import net.osmand.plus.onlinerouting.OnlineRoutingFactory; import net.osmand.plus.onlinerouting.VehicleType; import net.osmand.plus.routing.RouteDirectionInfo; -import net.osmand.plus.routing.RouteProvider; import net.osmand.util.Algorithms; -import org.json.JSONArray; +import org.apache.commons.logging.Log; import org.json.JSONException; -import org.json.JSONObject; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -34,6 +31,8 @@ import static net.osmand.util.Algorithms.isEmpty; public abstract class OnlineRoutingEngine implements Cloneable { + protected static final Log LOG = PlatformUtil.getLog(OnlineRoutingEngine.class); + public final static String ONLINE_ROUTING_ENGINE_PREFIX = "online_routing_engine_"; public final static VehicleType CUSTOM_VEHICLE = new VehicleType("", R.string.shared_string_custom); @@ -46,11 +45,17 @@ public abstract class OnlineRoutingEngine implements Cloneable { this.params.putAll(params); } collectAllowedVehiclesInternal(); - collectAllowedParametersInternal(); + collectAllowedParameters(allowedParameters); } @NonNull - public abstract EngineType getType(); + public abstract OnlineRoutingEngine getType(); + + @NonNull + public abstract String getTitle(); + + @NonNull + public abstract String getTypeName(); @Nullable public String getStringKey() { @@ -100,45 +105,13 @@ public abstract class OnlineRoutingEngine implements Cloneable { @NonNull public abstract String getStandardUrl(); - public OnlineRoutingResponse parseServerResponse(@NonNull String content, - @NonNull OsmandApplication app, - boolean leftSideNavigation) throws JSONException { - JSONObject root = parseRootResponseObject(content); - return root != null ? parseServerResponse(root, app, leftSideNavigation) : null; - } - @Nullable - protected abstract OnlineRoutingResponse parseServerResponse(@NonNull JSONObject root, - @NonNull OsmandApplication app, - boolean leftSideNavigation) throws JSONException; + public abstract OnlineRoutingResponse parseResponse(@NonNull String content, + @NonNull OsmandApplication app, + boolean leftSideNavigation) throws JSONException; - @Nullable - protected JSONObject parseRootResponseObject(@NonNull String content) throws JSONException { - JSONObject fullJSON = new JSONObject(content); - String responseArrayKey = getRootArrayKey(); - JSONArray array = null; - if (fullJSON.has(responseArrayKey)) { - array = fullJSON.getJSONArray(responseArrayKey); - } - return array != null && array.length() > 0 ? array.getJSONObject(0) : null; - } - - @NonNull - protected abstract String getRootArrayKey(); - - @NonNull - protected List convertRouteToLocationsList(@NonNull List route) { - List result = new ArrayList<>(); - if (!isEmpty(route)) { - for (LatLon pt : route) { - WptPt wpt = new WptPt(); - wpt.lat = pt.getLatitude(); - wpt.lon = pt.getLongitude(); - result.add(RouteProvider.createLocation(wpt)); - } - } - return result; - } + public abstract boolean isResultOk(@NonNull StringBuilder errorMessage, + @NonNull String content) throws JSONException; @NonNull public Map getParams() { @@ -171,23 +144,12 @@ public abstract class OnlineRoutingEngine implements Cloneable { return Collections.unmodifiableList(allowedVehicles); } - private void collectAllowedParametersInternal() { - allowedParameters.clear(); - allowParameters(EngineParameter.KEY, EngineParameter.VEHICLE_KEY, - EngineParameter.CUSTOM_NAME, EngineParameter.NAME_INDEX, EngineParameter.CUSTOM_URL); - collectAllowedParameters(); - } - - protected abstract void collectAllowedParameters(); + protected abstract void collectAllowedParameters(@NonNull Set params); public boolean isParameterAllowed(EngineParameter key) { return allowedParameters.contains(key); } - protected void allowParameters(@NonNull EngineParameter... allowedParams) { - allowedParameters.addAll(Arrays.asList(allowedParams)); - } - @Nullable private String getSelectedVehicleName(@NonNull Context ctx) { String key = get(EngineParameter.VEHICLE_KEY); @@ -216,24 +178,10 @@ public abstract class OnlineRoutingEngine implements Cloneable { return CUSTOM_VEHICLE; } - public boolean checkServerResponse(@NonNull StringBuilder errorMessage, - @NonNull String content) throws JSONException { - JSONObject obj = new JSONObject(content); - String messageKey = getErrorMessageKey(); - if (obj.has(messageKey)) { - String message = obj.getString(messageKey); - errorMessage.append(message); - } - return obj.has(getRootArrayKey()); - } - - @NonNull - protected abstract String getErrorMessageKey(); - @NonNull @Override public Object clone() { - return OnlineRoutingFactory.createEngine(getType(), getParams()); + return newInstance(getParams()); } @Override @@ -246,20 +194,30 @@ public abstract class OnlineRoutingEngine implements Cloneable { return Algorithms.objectEquals(getParams(), engine.getParams()); } + public abstract OnlineRoutingEngine newInstance(Map params); + @NonNull public static String generateKey() { return ONLINE_ROUTING_ENGINE_PREFIX + System.currentTimeMillis(); } public static class OnlineRoutingResponse { + private List route; private List directions; + private GPXFile gpxFile; + // constructor for JSON responses public OnlineRoutingResponse(List route, List directions) { this.route = route; this.directions = directions; } + // constructor for GPX responses + public OnlineRoutingResponse(GPXFile gpxFile) { + this.gpxFile = gpxFile; + } + public List getRoute() { return route; } @@ -267,5 +225,10 @@ public abstract class OnlineRoutingEngine implements Cloneable { public List getDirections() { return directions; } + + public GPXFile getGpxFile() { + return gpxFile; + } } + } diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OrsEngine.java b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OrsEngine.java index ed9168ccf9..16a5452caa 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OrsEngine.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OrsEngine.java @@ -17,10 +17,12 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; +import static net.osmand.plus.onlinerouting.engine.EngineType.ORS_TYPE; import static net.osmand.util.Algorithms.isEmpty; -public class OrsEngine extends OnlineRoutingEngine { +public class OrsEngine extends JsonOnlineRoutingEngine { public OrsEngine(@Nullable Map params) { super(params); @@ -28,8 +30,20 @@ public class OrsEngine extends OnlineRoutingEngine { @NonNull @Override - public EngineType getType() { - return EngineType.ORS; + public OnlineRoutingEngine getType() { + return ORS_TYPE; + } + + @Override + @NonNull + public String getTitle() { + return "Openroute Service"; + } + + @NonNull + @Override + public String getTypeName() { + return "ORS"; } @NonNull @@ -39,8 +53,18 @@ public class OrsEngine extends OnlineRoutingEngine { } @Override - protected void collectAllowedParameters() { - allowParameters(EngineParameter.API_KEY); + protected void collectAllowedParameters(@NonNull Set params) { + params.add(EngineParameter.KEY); + params.add(EngineParameter.VEHICLE_KEY); + params.add(EngineParameter.CUSTOM_NAME); + params.add(EngineParameter.NAME_INDEX); + params.add(EngineParameter.CUSTOM_URL); + params.add(EngineParameter.API_KEY); + } + + @Override + public OnlineRoutingEngine newInstance(Map params) { + return new OrsEngine(params); } @Override @@ -109,4 +133,5 @@ public class OrsEngine extends OnlineRoutingEngine { protected String getRootArrayKey() { return "features"; } + } diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OsrmEngine.java b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OsrmEngine.java index 4d75b2b440..20d98c0daf 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OsrmEngine.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/engine/OsrmEngine.java @@ -22,20 +22,34 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; +import static net.osmand.plus.onlinerouting.engine.EngineType.OSRM_TYPE; import static net.osmand.util.Algorithms.isEmpty; import static net.osmand.util.Algorithms.objectEquals; -public class OsrmEngine extends OnlineRoutingEngine { +public class OsrmEngine extends JsonOnlineRoutingEngine { public OsrmEngine(@Nullable Map params) { super(params); } @Override - public @NonNull - EngineType getType() { - return EngineType.OSRM; + @NonNull + public OnlineRoutingEngine getType() { + return OSRM_TYPE; + } + + @Override + @NonNull + public String getTitle() { + return "OSRM"; + } + + @NonNull + @Override + public String getTypeName() { + return "OSRM"; } @NonNull @@ -45,7 +59,17 @@ public class OsrmEngine extends OnlineRoutingEngine { } @Override - protected void collectAllowedParameters() { + protected void collectAllowedParameters(@NonNull Set params) { + params.add(EngineParameter.KEY); + params.add(EngineParameter.VEHICLE_KEY); + params.add(EngineParameter.CUSTOM_NAME); + params.add(EngineParameter.NAME_INDEX); + params.add(EngineParameter.CUSTOM_URL); + } + + @Override + public OnlineRoutingEngine newInstance(Map params) { + return new OsrmEngine(params); } @Override @@ -76,9 +100,9 @@ public class OsrmEngine extends OnlineRoutingEngine { @Nullable @Override - public OnlineRoutingResponse parseServerResponse(@NonNull JSONObject root, - @NonNull OsmandApplication app, - boolean leftSideNavigation) throws JSONException { + protected OnlineRoutingResponse parseServerResponse(@NonNull JSONObject root, + @NonNull OsmandApplication app, + boolean leftSideNavigation) throws JSONException { String encodedPoints = root.getString("geometry"); List points = GeoPolylineParserUtil.parse(encodedPoints, GeoPolylineParserUtil.PRECISION_5); if (isEmpty(points)) return null; @@ -225,13 +249,14 @@ public class OsrmEngine extends OnlineRoutingEngine { @NonNull @Override - protected String getErrorMessageKey() { - return "message"; + protected String getRootArrayKey() { + return "routes"; } @NonNull @Override - protected String getRootArrayKey() { - return "routes"; + protected String getErrorMessageKey() { + return "message"; } + } diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java index 39951b4c2c..1a2be2b134 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java @@ -78,7 +78,7 @@ public class OnlineRoutingCard extends BaseCard { bottomDivider = view.findViewById(R.id.bottom_divider); button = view.findViewById(R.id.button); - int activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode)); + int activeColor = appMode.getProfileColor(nightMode); textFieldBoxes.setPrimaryColor(activeColor); textFieldBoxes.setGravityFloatingLabel(Gravity.START); diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingEngineFragment.java b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingEngineFragment.java index 008bb75852..175e22016e 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingEngineFragment.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingEngineFragment.java @@ -39,12 +39,11 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem; import net.osmand.plus.onlinerouting.EngineParameter; -import net.osmand.plus.onlinerouting.OnlineRoutingFactory; import net.osmand.plus.onlinerouting.OnlineRoutingHelper; import net.osmand.plus.onlinerouting.OnlineRoutingUtils; import net.osmand.plus.onlinerouting.VehicleType; -import net.osmand.plus.onlinerouting.engine.EngineType; import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine; +import net.osmand.plus.onlinerouting.engine.EngineType; import net.osmand.plus.onlinerouting.ui.OnlineRoutingCard.OnTextChangedListener; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.settings.backend.ApplicationMode; @@ -54,7 +53,9 @@ import org.json.JSONException; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine.CUSTOM_VEHICLE; @@ -201,15 +202,15 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { typeCard = new OnlineRoutingCard(mapActivity, isNightMode(), appMode); typeCard.build(mapActivity); typeCard.setHeaderTitle(getString(R.string.shared_string_type)); - List serverItems = new ArrayList<>(); - for (EngineType server : EngineType.values()) { - serverItems.add(new HorizontalSelectionItem(server.getTitle(), server)); + List typeItems = new ArrayList<>(); + for (OnlineRoutingEngine type : EngineType.values()) { + typeItems.add(new HorizontalSelectionItem(type.getTitle(), type)); } - typeCard.setSelectionMenu(serverItems, engine.getType().getTitle(), + typeCard.setSelectionMenu(typeItems, engine.getType().getTitle(), new CallbackWithObject() { @Override public boolean processResult(HorizontalSelectionItem result) { - EngineType type = (EngineType) result.getObject(); + OnlineRoutingEngine type = (OnlineRoutingEngine) result.getObject(); if (engine.getType() != type) { changeEngineType(type); return true; @@ -366,9 +367,9 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { }); } - private void changeEngineType(EngineType type) { + private void changeEngineType(OnlineRoutingEngine type) { OnlineRoutingEngine tmp = (OnlineRoutingEngine) engine.clone(); - engine = OnlineRoutingFactory.createEngine(type, tmp.getParams()); + engine = type.newInstance(tmp.getParams()); // after changing the type, select the vehicle // with the same name that was selected before @@ -462,7 +463,7 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { boolean resultOk = false; try { String response = helper.makeRequest(exampleCard.getEditedText()); - resultOk = requestedEngine.checkServerResponse(errorMessage, response); + resultOk = requestedEngine.isResultOk(errorMessage, response); } catch (IOException | JSONException e) { errorMessage.append(e.toString()); } @@ -514,6 +515,12 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { } else { apiKeyCard.hide(); } + if (engine.isParameterAllowed(EngineParameter.VEHICLE_KEY)) { + vehicleCard.show(); + } else { + + vehicleCard.hide(); + } } else if (vehicleCard.equals(card)) { VehicleType vt = engine.getSelectedVehicleType(); @@ -609,7 +616,7 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { } private void saveState(@NonNull Bundle outState) { - outState.putString(ENGINE_TYPE_KEY, engine.getType().name()); + outState.putString(ENGINE_TYPE_KEY, engine.getTypeName()); for (EngineParameter key : EngineParameter.values()) { String value = engine.get(key); if (value != null) { @@ -626,14 +633,15 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { editedEngineKey = savedState.getString(EngineParameter.KEY.name()); initEngine = createInitStateEngine(); String typeKey = savedState.getString(ENGINE_TYPE_KEY); - EngineType type = EngineType.getTypeByName(typeKey); - engine = OnlineRoutingFactory.createEngine(type); + OnlineRoutingEngine type = EngineType.getTypeByName(typeKey); + Map params = new HashMap<>(); for (EngineParameter key : EngineParameter.values()) { String value = savedState.getString(key.name()); if (value != null) { - engine.put(key, value); + params.put(key.name(), value); } } + engine = type.newInstance(params); customVehicleKey = savedState.getString(ENGINE_CUSTOM_VEHICLE_KEY); selectedLocation = ExampleLocation.valueOf(savedState.getString(EXAMPLE_LOCATION_KEY)); appMode = ApplicationMode.valueOfStringKey(savedState.getString(APP_MODE_KEY), null); @@ -656,7 +664,7 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { if (editedEngine != null) { engine = (OnlineRoutingEngine) editedEngine.clone(); } else { - engine = OnlineRoutingFactory.createEngine(EngineType.values()[0]); + engine = EngineType.values()[0].newInstance(null); String vehicle = engine.getAllowedVehicles().get(0).getKey(); engine.put(EngineParameter.VEHICLE_KEY, vehicle); if (editedEngineKey != null) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 4f25b58761..731129e915 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -324,7 +324,7 @@ public class OsmEditingPlugin extends OsmandPlugin { .setTitleId(R.string.layer_osm_bugs, mapActivity) .setSelected(settings.SHOW_OSM_BUGS.get()) .setIcon(R.drawable.ic_action_osm_note) - .setColor(settings.SHOW_OSM_BUGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, settings.SHOW_OSM_BUGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(new ContextMenuAdapter.OnRowItemClick() { @@ -343,7 +343,7 @@ public class OsmEditingPlugin extends OsmandPlugin { if (itemId == R.string.layer_osm_bugs) { OsmandPreference showOsmBugs = settings.SHOW_OSM_BUGS; showOsmBugs.set(isChecked); - adapter.getItem(pos).setColorRes(showOsmBugs.get() ? + adapter.getItem(pos).setColor(app, showOsmBugs.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); updateLayers(mapActivity.getMapView(), mapActivity); @@ -359,14 +359,14 @@ public class OsmEditingPlugin extends OsmandPlugin { .setTitleId(R.string.layer_osm_edits, mapActivity) .setSelected(settings.SHOW_OSM_EDITS.get()) .setIcon(R.drawable.ic_action_openstreetmap_logo) - .setColor(settings.SHOW_OSM_EDITS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, settings.SHOW_OSM_EDITS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setListener(new ContextMenuAdapter.OnRowItemClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.layer_osm_edits) { OsmandPreference showOsmEdits = settings.SHOW_OSM_EDITS; showOsmEdits.set(isChecked); - adapter.getItem(pos).setColorRes(showOsmEdits.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.getItem(pos).setColor(app, showOsmEdits.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); updateLayers(mapActivity.getMapView(), mapActivity); } @@ -404,7 +404,7 @@ public class OsmEditingPlugin extends OsmandPlugin { final AvailableGPXFragment f = ((AvailableGPXFragment) fragment); optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_upload_gpx, activity) .setIcon(R.drawable.ic_action_export) - .setColor(R.color.color_white) + .setColor(app, R.color.color_white) .setListener(new ItemClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java index 3c7c387a36..f521eba6b1 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java @@ -46,7 +46,7 @@ public class OsmNotesMenu { final boolean nightMode = isNightMode(app); final int themeRes = getThemeRes(app); - final int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode)); + final int selectedModeColor = settings.getApplicationMode().getProfileColor(nightMode); final int osmNotesStringId = R.string.layer_osm_bugs; final int showZoomLevelStringId = R.string.show_from_zoom_level; @@ -110,7 +110,7 @@ public class OsmNotesMenu { .setTitleId(osmNotesStringId, mapActivity) .setDescription(mapActivity.getString(R.string.switch_osm_notes_visibility_desc)) .setIcon(R.drawable.ic_action_osm_note) - .setColor(toggleIconColorId) + .setColor(app, toggleIconColorId) .setListener(l) .setSelected(showOsmBugs) .createItem()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/ShowHideOSMBugAction.java b/OsmAnd/src/net/osmand/plus/osmedit/ShowHideOSMBugAction.java index 39082ea6e9..a50d53f7d5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/ShowHideOSMBugAction.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/ShowHideOSMBugAction.java @@ -15,10 +15,10 @@ import net.osmand.plus.quickaction.QuickActionType; public class ShowHideOSMBugAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(24, - "osmbug.showhide", ShowHideOSMBugAction.class). - nameRes(R.string.quick_action_showhide_osmbugs_title).iconRes(R.drawable.ic_action_osm_note).nonEditable(). - category(QuickActionType.CONFIGURE_MAP); - + "osmbug.showhide", ShowHideOSMBugAction.class) + .nameActionRes(R.string.quick_action_showhide_title) + .nameRes(R.string.osm_notes).iconRes(R.drawable.ic_action_osm_note).nonEditable() + .category(QuickActionType.CONFIGURE_MAP); public ShowHideOSMBugAction() { super(TYPE); diff --git a/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java b/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java index 8ddd677be2..55d8d350e1 100644 --- a/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java +++ b/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java @@ -310,13 +310,12 @@ public class RearrangePoiFiltersFragment extends DialogFragment implements Selec ImageView profileIcon = (ImageView) view.findViewById(R.id.profile_icon); if (profileIcon != null) { int iconRes = selectedAppMode.getIconRes(); - int iconColor = selectedAppMode.getIconColorInfo().getColor(nightMode); - profileIcon.setImageDrawable(uiUtilities.getPaintedIcon(iconRes, iconColor)); + profileIcon.setImageDrawable(uiUtilities.getPaintedIcon(iconRes, selectedAppMode.getProfileColor(nightMode))); } View profileButton = view.findViewById(R.id.profile_button); if (profileButton != null) { - int iconColor = getSelectedAppMode().getIconColorInfo().getColor(nightMode); + int iconColor = getSelectedAppMode().getProfileColor(nightMode); int bgColor = ContextCompat.getColor(app, nightMode ? R.color.divider_color_dark : R.color.active_buttons_and_links_text_light); int selectedColor = UiUtilities.getColorWithAlpha(iconColor, 0.3f); diff --git a/OsmAnd/src/net/osmand/plus/profiles/AppProfileArrayAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/AppProfileArrayAdapter.java index 58f1c721ab..6107476426 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/AppProfileArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/profiles/AppProfileArrayAdapter.java @@ -67,7 +67,7 @@ public class AppProfileArrayAdapter extends ArrayAdapter { Drawable iconDrawable; boolean lightContent = app.getSettings().isLightContent(); if (mode.isSelected()) { - iconDrawable = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColor(!lightContent)); + iconDrawable = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getIconColor(!lightContent)); } else { iconDrawable = app.getUIUtilities().getIcon(mode.getIconRes(), lightContent); } diff --git a/OsmAnd/src/net/osmand/plus/profiles/ConfigureProfileMenuAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/ConfigureProfileMenuAdapter.java index a2e024f860..6a92563647 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ConfigureProfileMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ConfigureProfileMenuAdapter.java @@ -6,10 +6,12 @@ import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; +import androidx.annotation.ColorInt; import androidx.annotation.ColorRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.view.ContextThemeWrapper; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import net.osmand.PlatformUtil; @@ -35,8 +37,8 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter getItems() { @@ -137,9 +140,9 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter() { @@ -274,8 +275,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment { private boolean deleted; private boolean customProfile; - EditProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, boolean customProfile, boolean deleted, ProfileIconColors iconColor, int order) { - super(name, descr, stringKey, iconRes, isSelected, iconColor); + EditProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, + boolean customProfile, boolean deleted, @ColorInt int iconColorLight, @ColorInt int iconColorDark, int order) { + super(name, descr, stringKey, iconRes, isSelected, iconColorLight, iconColorDark); this.customProfile = customProfile; this.deleted = deleted; this.order = order; @@ -365,10 +367,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment { if (iconRes == 0 || iconRes == -1) { iconRes = R.drawable.ic_action_world_globe; } - int profileColorResId = mode.getIconColor(nightMode); - int colorNoAlpha = ContextCompat.getColor(app, profileColorResId); + int colorNoAlpha = mode.getIconColor(nightMode); - profileViewHolder.icon.setImageDrawable(uiUtilities.getIcon(iconRes, profileColorResId)); + profileViewHolder.icon.setImageDrawable(uiUtilities.getPaintedIcon(iconRes, colorNoAlpha)); //set up cell color Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f); diff --git a/OsmAnd/src/net/osmand/plus/profiles/OnlineRoutingEngineDataObject.java b/OsmAnd/src/net/osmand/plus/profiles/OnlineRoutingEngineDataObject.java index fd0f593462..ea513b405c 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/OnlineRoutingEngineDataObject.java +++ b/OsmAnd/src/net/osmand/plus/profiles/OnlineRoutingEngineDataObject.java @@ -12,7 +12,7 @@ public class OnlineRoutingEngineDataObject extends ProfileDataObject { String description, String stringKey, int order) { - super(name, description, stringKey, R.drawable.ic_world_globe_dark, false, null); + super(name, description, stringKey, R.drawable.ic_world_globe_dark, false, null, null); this.order = order; } diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileDataObject.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileDataObject.java index 35b5be5620..048c7693d1 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfileDataObject.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileDataObject.java @@ -1,5 +1,6 @@ package net.osmand.plus.profiles; +import androidx.annotation.ColorInt; import androidx.annotation.ColorRes; import androidx.annotation.NonNull; @@ -12,15 +13,20 @@ public class ProfileDataObject implements Comparable { private String stringKey; private boolean isSelected; private boolean isEnabled; - private ProfileIconColors iconColor; + @ColorInt + private Integer iconColorLight; + @ColorInt + private Integer iconColorDark; - public ProfileDataObject(String name, String description, String stringKey, int iconRes, boolean isSelected, ProfileIconColors iconColor) { + public ProfileDataObject(String name, String description, String stringKey, int iconRes, boolean isSelected, + @ColorInt Integer iconColorLight, @ColorInt Integer iconColorDark) { this.name = name; this.iconRes = iconRes; this.description = description; this.isSelected = isSelected; this.stringKey = stringKey; - this.iconColor = iconColor; + this.iconColorLight = iconColorLight; + this.iconColorDark = iconColorDark; } public String getName() { @@ -55,8 +61,9 @@ public class ProfileDataObject implements Comparable { return stringKey; } - @ColorRes public int getIconColor(boolean isNightMode) { - return iconColor.getColor(isNightMode); + @ColorInt + public int getIconColor(boolean isNightMode) { + return isNightMode ? iconColorDark : iconColorLight; } @Override diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java index 6306dee9cc..bc939546cf 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java @@ -33,7 +33,7 @@ public class ProfileDataUtils { description = getAppModeDescription(app, mode); } profiles.add(new ProfileDataObject(mode.toHumanString(), description, - mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo())); + mode.getStringKey(), mode.getIconRes(), false, mode.getProfileColor(false), mode.getProfileColor(true))); } return profiles; } diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileIconColors.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileIconColors.java index 3fd97cc523..e7bccfde64 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfileIconColors.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileIconColors.java @@ -31,6 +31,7 @@ public enum ProfileIconColors { return name; } + @ColorRes public int getColor(boolean nightMode) { return nightMode ? nightColor : dayColor; } diff --git a/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java b/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java index ab808de360..43c3b80953 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java +++ b/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java @@ -11,7 +11,7 @@ public class RoutingProfileDataObject extends ProfileDataObject { private String fileName; public RoutingProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, String fileName) { - super(name, descr, stringKey, iconRes, isSelected, null); + super(name, descr, stringKey, iconRes, isSelected, null, null); this.fileName = fileName; } diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectCopyProfilesMenuAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/SelectCopyProfilesMenuAdapter.java index efe1b00a2e..53dbef23bd 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SelectCopyProfilesMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SelectCopyProfilesMenuAdapter.java @@ -67,10 +67,9 @@ public class SelectCopyProfilesMenuAdapter extends AbstractProfileMenuAdapter { private static final Log LOG = PlatformUtil.getLog(SelectProfileMenuAdapter.class); @@ -33,8 +33,8 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter items = new ArrayList<>(); private final OsmandApplication app; private ApplicationMode appMode; - @ColorRes - private int selectedIconColorRes; + @ColorInt + private int selectedIconColor; private boolean bottomButton; private String bottomButtonText; private static final String BUTTON_ITEM = "button_item"; @@ -53,9 +53,8 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter getItems() { @@ -100,11 +99,10 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter cl; private int category; @@ -36,6 +38,11 @@ public class QuickActionType { return this; } + public QuickActionType nameActionRes(int nameActionRes) { + this.nameActionRes = nameActionRes; + return this; + } + public QuickActionType category(int cat) { this.category = cat; return this; @@ -101,6 +108,10 @@ public class QuickActionType { return nameRes; } + public int getActionNameRes() { + return nameActionRes; + } + public int getIconRes() { return iconRes; } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java index 526c16a285..f1bc2c927a 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java @@ -12,10 +12,12 @@ import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.ColorInt; import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; import androidx.appcompat.widget.SwitchCompat; +import androidx.core.content.ContextCompat; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; @@ -161,8 +163,8 @@ public abstract class SwitchableAction extends QuickAction { OsmandApplication app = (OsmandApplication) context.getApplicationContext(); - Drawable icon = app.getUIUtilities().getIcon( - getItemIconRes(app, item), getItemIconColorRes(app, item)); + Drawable icon = app.getUIUtilities().getPaintedIcon( + getItemIconRes(app, item), getItemIconColor(app, item)); holder.icon.setImageDrawable(icon); holder.title.setText(getItemName(context, item)); @@ -310,10 +312,11 @@ public abstract class SwitchableAction extends QuickAction { return R.drawable.ic_map; } - @ColorRes - protected int getItemIconColorRes(OsmandApplication app, T item) { + @ColorInt + protected int getItemIconColor(OsmandApplication app, T item) { boolean nightMode = !app.getSettings().isLightContent(); - return nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; + int colorRes = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; + return ContextCompat.getColor(app, colorRes); } protected abstract diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/FavoriteAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/FavoriteAction.java index fbe79b0681..ecd277b092 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/FavoriteAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/FavoriteAction.java @@ -22,6 +22,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment; +import net.osmand.plus.mapcontextmenu.editors.SelectFavoriteCategoryBottomSheet; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.widgets.AutoCompleteTextViewEx; @@ -175,13 +176,13 @@ public class FavoriteAction extends QuickAction { @Override public void onClick(final View view) { - SelectCategoryDialogFragment dialogFragment = SelectCategoryDialogFragment.createInstance(""); + SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(""); dialogFragment.show( activity.getSupportFragmentManager(), SelectCategoryDialogFragment.TAG); - dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() { + dialogFragment.setSelectionListener(new SelectFavoriteCategoryBottomSheet.CategorySelectionListener() { @Override public void onCategorySelected(String category, int color) { @@ -191,12 +192,12 @@ public class FavoriteAction extends QuickAction { } }); - SelectCategoryDialogFragment dialogFragment = (SelectCategoryDialogFragment) + SelectFavoriteCategoryBottomSheet dialogFragment = (SelectFavoriteCategoryBottomSheet) activity.getSupportFragmentManager().findFragmentByTag(SelectCategoryDialogFragment.TAG); if (dialogFragment != null) { - dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() { + dialogFragment.setSelectionListener(new SelectFavoriteCategoryBottomSheet.CategorySelectionListener() { @Override public void onCategorySelected(String category, int color) { @@ -211,7 +212,7 @@ public class FavoriteAction extends QuickAction { if (dialog != null) { - dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() { + dialogFragment.setSelectionListener(new SelectFavoriteCategoryBottomSheet.CategorySelectionListener() { @Override public void onCategorySelected(String category, int color) { diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/GPXAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/GPXAction.java index 6fc153bb23..d0bfd98cbf 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/GPXAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/GPXAction.java @@ -16,6 +16,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment; +import net.osmand.plus.mapcontextmenu.editors.SelectFavoriteCategoryBottomSheet; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.widgets.AutoCompleteTextViewEx; @@ -119,13 +120,13 @@ public class GPXAction extends QuickAction { @Override public void onClick(final View view) { - SelectCategoryDialogFragment dialogFragment = SelectCategoryDialogFragment.createInstance(""); + SelectFavoriteCategoryBottomSheet dialogFragment = SelectFavoriteCategoryBottomSheet.createInstance(""); dialogFragment.show( activity.getSupportFragmentManager(), - SelectCategoryDialogFragment.TAG); + SelectFavoriteCategoryBottomSheet.TAG); - dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() { + dialogFragment.setSelectionListener(new SelectFavoriteCategoryBottomSheet.CategorySelectionListener() { @Override public void onCategorySelected(String category, int color) { @@ -135,12 +136,12 @@ public class GPXAction extends QuickAction { } }); - SelectCategoryDialogFragment dialogFragment = (SelectCategoryDialogFragment) + SelectFavoriteCategoryBottomSheet dialogFragment = (SelectFavoriteCategoryBottomSheet) activity.getSupportFragmentManager().findFragmentByTag(SelectCategoryDialogFragment.TAG); if (dialogFragment != null) { - dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() { + dialogFragment.setSelectionListener(new SelectFavoriteCategoryBottomSheet.CategorySelectionListener() { @Override public void onCategorySelected(String category, int color) { @@ -155,7 +156,7 @@ public class GPXAction extends QuickAction { if (dialog != null) { - dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() { + dialogFragment.setSelectionListener(new SelectFavoriteCategoryBottomSheet.CategorySelectionListener() { @Override public void onCategorySelected(String category, int color) { diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideCoordinatesWidgetAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideCoordinatesWidgetAction.java index d0f0728c19..f1a450d09e 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideCoordinatesWidgetAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideCoordinatesWidgetAction.java @@ -14,9 +14,10 @@ import net.osmand.plus.quickaction.QuickActionType; public class ShowHideCoordinatesWidgetAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(35, "coordinates.showhide", ShowHideCoordinatesWidgetAction.class) - .nameRes(R.string.quick_action_showhide_coordinates_widget) + .nameActionRes(R.string.quick_action_showhide_title) + .nameRes(R.string.coordinates_widget) .iconRes(R.drawable.ic_action_coordinates_widget).nonEditable() - .category(QuickActionType.CONFIGURE_MAP); + .category(QuickActionType.CONFIGURE_SCREEN); public ShowHideCoordinatesWidgetAction() { super(TYPE); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideFavoritesAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideFavoritesAction.java index 0bad3af2a9..3393af785e 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideFavoritesAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideFavoritesAction.java @@ -14,11 +14,11 @@ import net.osmand.plus.quickaction.QuickActionType; public class ShowHideFavoritesAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(4, - "favorites.showhide", ShowHideFavoritesAction.class). - nameRes(R.string.quick_action_showhide_favorites_title).iconRes(R.drawable.ic_action_favorite).nonEditable(). - category(QuickActionType.CONFIGURE_MAP); - - + "favorites.showhide", ShowHideFavoritesAction.class) + .nameActionRes(R.string.quick_action_showhide_title) + .nameRes(R.string.shared_string_favorites) + .iconRes(R.drawable.ic_action_favorite).nonEditable() + .category(QuickActionType.CONFIGURE_MAP); public ShowHideFavoritesAction() { super(TYPE); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideGpxTracksAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideGpxTracksAction.java index 34ce197220..1e67f1a6ac 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideGpxTracksAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideGpxTracksAction.java @@ -16,10 +16,10 @@ public class ShowHideGpxTracksAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(28, - "gpx.showhide", ShowHideGpxTracksAction.class). - nameRes(R.string.quick_action_show_hide_gpx_tracks).iconRes(R.drawable.ic_action_polygom_dark).nonEditable(). - category(QuickActionType.CONFIGURE_MAP); - + "gpx.showhide", ShowHideGpxTracksAction.class) + .nameActionRes(R.string.quick_action_showhide_title) + .nameRes(R.string.show_gpx).iconRes(R.drawable.ic_action_polygom_dark).nonEditable() + .category(QuickActionType.CONFIGURE_MAP); public ShowHideGpxTracksAction() { super(TYPE); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideMapillaryAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideMapillaryAction.java index ba6c7d7391..709d589537 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideMapillaryAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideMapillaryAction.java @@ -18,7 +18,8 @@ public class ShowHideMapillaryAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(33, "mapillary.showhide", ShowHideMapillaryAction.class) - .nameRes(R.string.quick_action_showhide_mapillary_title) + .nameActionRes(R.string.quick_action_showhide_title) + .nameRes(R.string.mapillary) .iconRes(R.drawable.ic_action_mapillary).nonEditable() .category(QuickActionType.CONFIGURE_MAP); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHidePoiAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHidePoiAction.java index 4c2d452e64..735b9efdc1 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHidePoiAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHidePoiAction.java @@ -37,10 +37,11 @@ public class ShowHidePoiAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(5, - "poi.showhide", ShowHidePoiAction.class). - nameRes(R.string.quick_action_showhide_poi_title).iconRes(R.drawable.ic_action_info_dark). - category(QuickActionType.CONFIGURE_MAP); - + "poi.showhide", ShowHidePoiAction.class) + .nameActionRes(R.string.quick_action_showhide_title) + .nameRes(R.string.poi) + .iconRes(R.drawable.ic_action_info_dark) + .category(QuickActionType.CONFIGURE_MAP); public static final String KEY_FILTERS = "filters"; @@ -353,7 +354,6 @@ public class ShowHidePoiAction extends QuickAction { builder.setIcon(R.drawable.mx_user_defined); } - builder.setColor(ContextMenuItem.INVALID_ID); builder.setSkipPaintingWithoutColor(true); adapter.addItem(builder.createItem()); } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideTransportLinesAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideTransportLinesAction.java index 61f04f2c6f..d4c6bd0788 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideTransportLinesAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideTransportLinesAction.java @@ -16,7 +16,8 @@ public class ShowHideTransportLinesAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(31, "transport.showhide", ShowHideTransportLinesAction.class) - .nameRes(R.string.quick_action_show_hide_transport) + .nameActionRes(R.string.quick_action_showhide_title) + .nameRes(R.string.poi_filter_public_transport) .iconRes(R.drawable.ic_action_transport_bus).nonEditable() .category(QuickActionType.CONFIGURE_MAP); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java index 3710f9832b..da31b61466 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java @@ -5,6 +5,7 @@ import android.text.TextUtils; import android.view.View; import android.widget.Toast; +import androidx.annotation.ColorInt; import androidx.appcompat.widget.SwitchCompat; import com.google.gson.Gson; @@ -182,13 +183,14 @@ public class SwitchProfileAction extends SwitchableAction { } @Override - protected int getItemIconColorRes(OsmandApplication app, String item) { + @ColorInt + protected int getItemIconColor(OsmandApplication app, String item) { ApplicationMode appMode = getModeForKey(item); if (appMode != null) { boolean nightMode = !app.getSettings().isLightContent(); - return appMode.getIconColorInfo().getColor(nightMode); + return appMode.getProfileColor(nightMode); } - return super.getItemIconColorRes(app, item); + return super.getItemIconColor(app, item); } @Override diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 59ba2dadf7..b43171e632 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -13,7 +13,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; -import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -325,7 +324,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { : mapActivity.getString(R.string.shared_string_none); item.setDescription(overlayMapDescr); item.setSelected(hasOverlayDescription); - item.setColorRes(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(app, hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); } } @@ -350,7 +349,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { item.setDescription(underlayMapDescr); item.setSelected(hasUnderlayDescription); - item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(app, hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); @@ -383,7 +382,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { .setId(OVERLAY_MAP) .setDescription(overlayMapDescr) .setSelected(hasOverlayDescription) - .setColor(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_layer_top) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(listener) @@ -399,7 +398,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { .setId(UNDERLAY_MAP) .setDescription(underlayMapDescr) .setSelected(hasUnderlayDescription) - .setColor(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_layer_bottom) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(listener) @@ -485,7 +484,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { final boolean[] selected = new boolean[downloaded.size()]; boolean nightMode = isNightMode(activity); int themeResId = getThemeRes(activity); - int selectedProfileColor = ContextCompat.getColor(app, app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode)); + int selectedProfileColor = app.getSettings().getApplicationMode().getProfileColor(nightMode); DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createMultiChoiceAdapter(names, nightMode, selected, app, selectedProfileColor, themeResId, new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java index 38f6053887..41147171c5 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java @@ -11,6 +11,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.ColorInt; import androidx.annotation.ColorRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -64,8 +65,8 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr private List compoundButtons = new ArrayList<>(); private boolean hideImpassableRoads; - @ColorRes - private int compoundButtonColorId = INVALID_ID; + @ColorInt + private Integer compoundButtonColor = null; private ApplicationMode appMode; public void setHideImpassableRoads(boolean hideImpassableRoads) { @@ -236,7 +237,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1]; item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() - .setCompoundButtonColorId(compoundButtonColorId) + .setCompoundButtonColor(compoundButtonColor) .setChecked(selected) .setTitle(parameterName) .setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon) @@ -254,8 +255,8 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr } } - public void setCompoundButtonColorId(@ColorRes int compoundButtonColorId) { - this.compoundButtonColorId = compoundButtonColorId; + public void setCompoundButtonColor(@ColorInt int compoundButtonColor) { + this.compoundButtonColor = compoundButtonColor; } @Override diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index 89afe180e2..e75efb2c25 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -58,7 +58,7 @@ import net.osmand.plus.routepreparationmenu.RouteDetailsFragment.CumulativeInfo; import net.osmand.plus.routepreparationmenu.RouteDetailsFragment.RouteDetailsFragmentListener; import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard; import net.osmand.plus.routing.RouteDirectionInfo; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 93b26b82a4..b5abb80b65 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -58,8 +58,8 @@ import net.osmand.plus.routepreparationmenu.cards.SelectTrackCard; import net.osmand.plus.routepreparationmenu.cards.TrackEditCard; import net.osmand.plus.routepreparationmenu.cards.TracksToFollowCard; import net.osmand.plus.routing.IRouteInformationListener; -import net.osmand.plus.routing.RouteProvider; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.track.TrackSelectSegmentBottomSheet; @@ -224,7 +224,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca RoutingHelper routingHelper = app.getRoutingHelper(); GPXRouteParamsBuilder rparams = routingHelper.getCurrentGPXRoute(); - boolean osmandRouter = mode.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = mode.getRouteService() == RouteService.OSMAND; if (rparams != null && osmandRouter) { cardsContainer.addView(buildDividerView(cardsContainer, false)); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index f88f499125..2475d70f34 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -100,7 +100,7 @@ import net.osmand.plus.routepreparationmenu.cards.SimpleRouteCard; import net.osmand.plus.routepreparationmenu.cards.TracksCard; import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.RouteCalculationResult; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelperUtils; import net.osmand.plus.routing.TransportRoutingHelper; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java index 8ba86dfe35..9e3c633544 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java @@ -11,6 +11,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.ColorInt; import androidx.annotation.ColorRes; import androidx.appcompat.widget.SwitchCompat; import androidx.core.content.ContextCompat; @@ -46,7 +47,8 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRo import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteSimulationItem; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.ShowAlongTheRouteItem; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.TimeConditionalRoutingItem; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +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.CommonPreference; @@ -84,8 +86,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { private RoutingHelper routingHelper; private RoutingOptionsHelper routingOptionsHelper; private ApplicationMode applicationMode; - @ColorRes - private int selectedModeColorId; + @ColorInt + private int selectedModeColor; private boolean currentMuteState; private boolean currentUseHeightState; private MapActivity mapActivity; @@ -149,7 +151,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { if (dialogMode == null) { dialogMode = DialogMode.DIRECTIONS; } - selectedModeColorId = applicationMode.getIconColorInfo().getColor(nightMode); + selectedModeColor = applicationMode.getProfileColor(nightMode); voiceMuteChangeListener = new StateChangedListener() { @Override public void stateChanged(Boolean change) { @@ -271,7 +273,6 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) { boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode); - int selectedModeColor = ContextCompat.getColor(app, selectedModeColorId); final View itemView = UiUtilities.getInflater(app, nightMode).inflate( R.layout.bottom_sheet_item_with_descr_switch_and_additional_button_56dp, null, false); final ImageView icon = itemView.findViewById(R.id.icon); @@ -310,7 +311,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { Drawable drawable = app.getUIUtilities().getIcon(R.drawable.ic_action_settings, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light); if (Build.VERSION.SDK_INT >= 21) { - Drawable activeDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_settings, selectedModeColorId); + Drawable activeDrawable = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_settings, selectedModeColor); drawable = AndroidUtils.createPressedStateListDrawable(drawable, activeDrawable); } voicePromptsBtnImage.setImageDrawable(drawable); @@ -358,7 +359,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() .setChecked(!active) - .setCompoundButtonColorId(selectedModeColorId) + .setCompoundButtonColor(selectedModeColor) .setDescription(getElevationDescription(parameter)) .setIcon(getContentIcon(active ? parameter.getActiveIconId() : parameter.getDisabledIconId())) .setTitle(getString(R.string.routing_attr_height_obstacles_name)) @@ -387,7 +388,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) { final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1]; timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() - .setCompoundButtonColorId(selectedModeColorId) + .setCompoundButtonColor(selectedModeColor) .setChecked(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getModeValue(applicationMode)) .setIcon(getContentIcon((optionsItem.getActiveIconId()))) .setTitle(getString(R.string.temporary_conditional_routing)) @@ -433,7 +434,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) { final BottomSheetItemWithCompoundButton[] simulateNavigationItem = new BottomSheetItemWithCompoundButton[1]; simulateNavigationItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() - .setCompoundButtonColorId(selectedModeColorId) + .setCompoundButtonColor(selectedModeColor) .setChecked(settings.simulateNavigation) .setIcon(getContentIcon(R.drawable.ic_action_start_navigation)) .setTitle(getString(R.string.simulate_navigation)) @@ -470,7 +471,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem); AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(); avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE); - avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId); + avoidRoadsFragment.setCompoundButtonColor(selectedModeColor); avoidRoadsFragment.setApplicationMode(applicationMode); avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG); updateMenu(); @@ -492,7 +493,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(); avoidRoadsFragment.setHideImpassableRoads(true); avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE); - avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId); + avoidRoadsFragment.setCompoundButtonColor(selectedModeColor); avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG); updateMenu(); } @@ -501,7 +502,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { } private BaseBottomSheetItem createGpxRoutingItem(final LocalRoutingParameter optionsItem) { - RouteProvider.GPXRouteParamsBuilder routeParamsBuilder = mapActivity.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder routeParamsBuilder = mapActivity.getRoutingHelper().getCurrentGPXRoute(); String description = null; int descriptionColorId; if (routeParamsBuilder == null) { @@ -565,7 +566,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { if (parameter != null) { final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1]; BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder(); - builder.setCompoundButtonColorId(selectedModeColorId); + builder.setCompoundButtonColor(selectedModeColor); int iconId = -1; if (parameter.routingParameter != null || parameter instanceof RoutingOptionsHelper.OtherLocalRoutingParameter) { builder.setTitle(parameter.getText(mapActivity)); @@ -661,11 +662,11 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { private List getRoutingParameters(ApplicationMode applicationMode) { List routingParameters; - boolean osmandRouter = applicationMode.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = applicationMode.getRouteService() == RouteService.OSMAND; if (!osmandRouter) { - if (applicationMode.getRouteService() == RouteProvider.RouteService.STRAIGHT) { + if (applicationMode.getRouteService() == RouteService.STRAIGHT) { routingParameters = AppModeOptions.STRAIGHT.routingParameters; - } else if (applicationMode.getRouteService() == RouteProvider.RouteService.DIRECT_TO) { + } else if (applicationMode.getRouteService() == RouteService.DIRECT_TO) { routingParameters = AppModeOptions.DIRECT_TO.routingParameters; } else { routingParameters = AppModeOptions.OTHER.routingParameters; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java index 72e985c353..5f405c90b6 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java @@ -37,9 +37,8 @@ import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.helpers.FileNameTranslationHelper; -import net.osmand.plus.routing.RouteProvider; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.voice.JSMediaCommandPlayerImpl; @@ -153,7 +152,7 @@ public class RoutingOptionsHelper { Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode); int themeRes = getThemeRes(app); ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode(); - int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode)); + int selectedModeColor = selectedAppMode.getProfileColor(nightMode); DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter( entries, nightMode, selected, app, selectedModeColor, themeRes, new View.OnClickListener() { @Override @@ -243,24 +242,25 @@ public class RoutingOptionsHelper { TargetPointsHelper tg = app.getTargetPointsHelper(); List ps = rp.getPoints(app); if (ps.size() > 0) { + TargetPoint pointToStart = tg.getPointToStart(); + TargetPoint pointToNavigate = tg.getPointToNavigate(); if (rp.getFile().hasRoute()) { tg.clearStartPoint(false); Location finishLoc = ps.get(ps.size() - 1); - TargetPoint pn = tg.getPointToNavigate(); - tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1, pn != null ? pn.getOriginalPointDescription() : null); + tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), + false, -1, pointToNavigate != null ? pointToNavigate.getOriginalPointDescription() : null); tg.updateRouteAndRefresh(true); } else { Location first = ps.get(0); Location end = ps.get(ps.size() - 1); - TargetPoint pn = tg.getPointToNavigate(); boolean update = false; - if (pn == null - || MapUtils.getDistance(pn.point, new LatLon(first.getLatitude(), first.getLongitude())) < 10) { + if (pointToNavigate == null + || MapUtils.getDistance(pointToNavigate.point, new LatLon(first.getLatitude(), first.getLongitude())) < 10) { tg.navigateToPoint(new LatLon(end.getLatitude(), end.getLongitude()), false, -1); update = true; } - if (tg.getPointToStart() == null - || MapUtils.getDistance(tg.getPointToStart().point, + if (pointToStart == null + || MapUtils.getDistance(pointToStart.point, new LatLon(end.getLatitude(), end.getLongitude())) < 10) { tg.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()), false, null); update = true; @@ -334,7 +334,7 @@ public class RoutingOptionsHelper { final boolean nightMode = isNightMode(app); Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode); ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode(); - final int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode)); + final int selectedModeColor = selectedAppMode.getProfileColor(nightMode); AlertDialog.Builder builder = new AlertDialog.Builder(themedContext); final int layout = R.layout.list_menu_item_native_singlechoice; @@ -458,7 +458,7 @@ public class RoutingOptionsHelper { public List getOsmandRouterParameters(ApplicationMode am) { OsmandSettings settings = app.getSettings(); List list = new ArrayList(); - boolean osmandRouter = am.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = am.getRouteService() == RouteService.OSMAND; if (!osmandRouter) { list.add(new OtherLocalRoutingParameter(R.string.calculate_osmand_route_without_internet, app.getString(R.string.calculate_osmand_route_without_internet), settings.GPX_ROUTE_CALC_OSMAND_PARTS.get())); @@ -490,7 +490,7 @@ public class RoutingOptionsHelper { } public List getRoutingParametersInner(ApplicationMode am) { - boolean osmandRouter = am.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = am.getRouteService() == RouteService.OSMAND; if (!osmandRouter) { return getOsmandRouterParameters(am); } @@ -1061,7 +1061,7 @@ public class RoutingOptionsHelper { private List getRoutingParametersForProfileType(ApplicationMode appMode) { if (appMode != null) { - boolean osmandRouter = appMode.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = appMode.getRouteService() == RouteService.OSMAND; if (!osmandRouter) { return PermanentAppModeOptions.OTHER.routingParameters; } else if (appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java index 7272b7a2ea..48707d7713 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java @@ -356,7 +356,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment } } }); - int selectedProfileColor = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(isNightMode(app))); + int selectedProfileColor = getAppMode().getProfileColor(isNightMode(app)); UiUtilities.setupCompoundButton(nightMode, selectedProfileColor, compoundButton); convertView.setOnClickListener(new View.OnClickListener() { @@ -516,7 +516,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment selected = i; } } - int selectedProfileColor = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(nightMode)); + int selectedProfileColor = getAppMode().getProfileColor(nightMode); DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter( names, nightMode, selected, app, selectedProfileColor, themeRes, new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java index 646e2da386..e924b46aba 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java @@ -20,7 +20,7 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.helpers.TrackSelectSegmentAdapter; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.util.Algorithms; import java.io.File; diff --git a/OsmAnd/src/net/osmand/plus/routing/GPXRouteParams.java b/OsmAnd/src/net/osmand/plus/routing/GPXRouteParams.java new file mode 100644 index 0000000000..9290195acd --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/GPXRouteParams.java @@ -0,0 +1,214 @@ +package net.osmand.plus.routing; + +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.Route; +import net.osmand.GPXUtilities.WptPt; +import net.osmand.Location; +import net.osmand.PlatformUtil; +import net.osmand.data.LatLon; +import net.osmand.data.LocationPoint; +import net.osmand.data.WptLocationPoint; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.router.RouteSegmentResult; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static net.osmand.plus.routing.RouteProvider.collectSegmentPointsFromGpx; +import static net.osmand.router.RouteExporter.OSMAND_ROUTER_V2; + +public class GPXRouteParams { + + private static final String OSMAND_ROUTER = "OsmAndRouter"; + + protected List wpt; + protected List route; + protected List directions; + protected List points = new ArrayList<>(); + protected List segmentEndpoints = new ArrayList<>(); + protected List routePoints = new ArrayList<>(); + protected boolean reverse; + protected boolean passWholeRoute; + protected boolean calculateOsmAndRoute; + protected boolean useIntermediatePointsRTE; + protected boolean calculateOsmAndRouteParts; + + boolean addMissingTurns = true; + + public List getPoints() { + return points; + } + + public List getWpt() { + return wpt; + } + + public Location getStartPointForRoute() { + if (!points.isEmpty()) { + return points.get(0); + } + return null; + } + + public Location getEndPointForRoute() { + if (!points.isEmpty()) { + return points.get(points.size()); + } + return null; + } + + public LatLon getLastPoint() { + if (!points.isEmpty()) { + Location l = points.get(points.size() - 1); + return new LatLon(l.getLatitude(), l.getLongitude()); + } + return null; + } + + public GPXRouteParams prepareGPXFile(GPXRouteParamsBuilder builder) { + GPXFile file = builder.file; + reverse = builder.reverse; + passWholeRoute = builder.passWholeRoute; + calculateOsmAndRouteParts = builder.calculateOsmAndRouteParts; + useIntermediatePointsRTE = builder.isUseIntermediatePointsRTE(); + builder.calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute; + if (!file.isPointsEmpty()) { + wpt = new ArrayList(file.getPoints().size()); + for (WptPt w : file.getPoints()) { + wpt.add(new WptLocationPoint(w)); + } + } + int selectedSegment = builder.getSelectedSegment(); + if (OSMAND_ROUTER_V2.equals(file.author)) { + route = RouteProvider.parseOsmAndGPXRoute(points, file, segmentEndpoints, selectedSegment); + if (selectedSegment == -1) { + routePoints = file.getRoutePoints(); + } else { + routePoints = file.getRoutePoints(selectedSegment); + } + if (reverse) { + Collections.reverse(points); + Collections.reverse(routePoints); + Collections.reverse(segmentEndpoints); + } + addMissingTurns = route != null && route.isEmpty(); + } else if (file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)) { + directions = RouteProvider.parseOsmAndGPXRoute(points, file, segmentEndpoints, + OSMAND_ROUTER.equals(file.author), builder.leftSide, 10, selectedSegment); + if (OSMAND_ROUTER.equals(file.author) && file.hasRtePt()) { + // For files generated by OSMAND_ROUTER use directions contained unaltered + addMissingTurns = false; + } + if (reverse) { + // clear directions all turns should be recalculated + directions = null; + Collections.reverse(points); + Collections.reverse(segmentEndpoints); + addMissingTurns = true; + } + } else { + // first of all check tracks + if (!useIntermediatePointsRTE) { + collectSegmentPointsFromGpx(file, points, segmentEndpoints, selectedSegment); + } + if (points.isEmpty()) { + for (Route rte : file.routes) { + for (WptPt pt : rte.points) { + points.add(RouteProvider.createLocation(pt)); + } + } + } + if (reverse) { + Collections.reverse(points); + Collections.reverse(segmentEndpoints); + } + } + return this; + } + + public static class GPXRouteParamsBuilder { + + private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(GPXRouteParamsBuilder.class); + + boolean calculateOsmAndRoute = false; + // parameters + private final GPXFile file; + private boolean reverse; + private boolean leftSide; + private boolean passWholeRoute; + private boolean calculateOsmAndRouteParts; + private int selectedSegment = -1; + + public GPXRouteParamsBuilder(GPXFile file, OsmandSettings settings) { + leftSide = settings.DRIVING_REGION.get().leftHandDriving; + this.file = file; + } + + public boolean isReverse() { + return reverse; + } + + public boolean isCalculateOsmAndRouteParts() { + return calculateOsmAndRouteParts; + } + + public void setCalculateOsmAndRouteParts(boolean calculateOsmAndRouteParts) { + this.calculateOsmAndRouteParts = calculateOsmAndRouteParts; + } + + public boolean isUseIntermediatePointsRTE() { + return file.hasRtePt() && !file.hasTrkPt(); + } + + public boolean isCalculateOsmAndRoute() { + return calculateOsmAndRoute; + } + + public void setCalculateOsmAndRoute(boolean calculateOsmAndRoute) { + this.calculateOsmAndRoute = calculateOsmAndRoute; + } + + public int getSelectedSegment() { + return selectedSegment; + } + + public void setSelectedSegment(int selectedSegment) { + this.selectedSegment = selectedSegment; + } + + public void setPassWholeRoute(boolean passWholeRoute) { + this.passWholeRoute = passWholeRoute; + } + + public boolean isPassWholeRoute() { + return passWholeRoute; + } + + public GPXRouteParams build(OsmandApplication app) { + GPXRouteParams res = new GPXRouteParams(); + try { + res.prepareGPXFile(this); + } catch (RuntimeException e) { + log.error(e.getMessage(), e); + app.showShortToastMessage(app.getString(R.string.gpx_parse_error) + " " + e.getMessage()); + } + return res; + } + + public void setReverse(boolean reverse) { + this.reverse = reverse; + } + + public GPXFile getFile() { + return file; + } + + public List getPoints(OsmandApplication app) { + GPXRouteParams copy = build(app); + return copy.getPoints(); + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routing/GpxApproximator.java b/OsmAnd/src/net/osmand/plus/routing/GpxApproximator.java index 65e683a734..ca10de2812 100644 --- a/OsmAnd/src/net/osmand/plus/routing/GpxApproximator.java +++ b/OsmAnd/src/net/osmand/plus/routing/GpxApproximator.java @@ -7,7 +7,6 @@ import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.routing.RouteProvider.RoutingEnvironment; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.router.RouteCalculationProgress; import net.osmand.router.RoutePlannerFrontEnd.GpxPoint; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java index 7b38b5c91a..0c4f2a4cb6 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java @@ -4,7 +4,6 @@ import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.routing.RouteProvider.GPXRouteParams; import net.osmand.router.RouteCalculationProgress; import java.util.List; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index e6efcc321f..7b7bd7d8d9 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -15,7 +15,6 @@ import net.osmand.data.QuadRect; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; -import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.router.ExitInfo; import net.osmand.router.RouteSegmentResult; @@ -291,12 +290,16 @@ public class RouteCalculationResult { } public List getOriginalRoute(int startIndex) { + return getOriginalRoute(startIndex, segments.size()); + } + + public List getOriginalRoute(int startIndex, int endIndex) { if (segments.size() == 0) { return null; } - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(segments.get(startIndex++)); - for (int i = startIndex; i < segments.size(); i++) { + for (int i = startIndex; i < endIndex; i++) { if (segments.get(i - 1) != segments.get(i)) { list.add(segments.get(i)); } diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 3f0a30c99f..e5974fc32d 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -1,7 +1,6 @@ package net.osmand.plus.routing; -import android.content.Context; import android.os.Bundle; import android.util.Base64; @@ -16,8 +15,6 @@ import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.LatLon; -import net.osmand.data.LocationPoint; -import net.osmand.data.WptLocationPoint; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; @@ -25,6 +22,7 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.onlinerouting.OnlineRoutingHelper; import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine.OnlineRoutingResponse; import net.osmand.plus.render.NativeOsmandLibrary; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; @@ -70,279 +68,14 @@ import javax.xml.parsers.ParserConfigurationException; import btools.routingapp.IBRouterService; -import static net.osmand.router.RouteExporter.OSMAND_ROUTER_V2; - public class RouteProvider { + private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(RouteProvider.class); - private static final String OSMAND_ROUTER = "OsmAndRouter"; private static final int MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT = 60; private static final int ADDITIONAL_DISTANCE_FOR_START_POINT = 300; private static final int MIN_STRAIGHT_DIST = 50000; - public enum RouteService { - OSMAND("OsmAnd (offline)"), - BROUTER("BRouter (offline)"), - STRAIGHT("Straight line"), - DIRECT_TO("Direct To"), - ONLINE("Online engine"); - - private final String name; - - RouteService(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public boolean isOnline() { - return this != OSMAND && this != BROUTER; - } - - boolean isAvailable(OsmandApplication ctx) { - if (this == BROUTER) { - return ctx.getBRouterService() != null; - } - return true; - } - - public static RouteService[] getAvailableRouters(OsmandApplication ctx) { - List list = new ArrayList<>(); - for (RouteService r : values()) { - if (r.isAvailable(ctx)) { - list.add(r); - } - } - return list.toArray(new RouteService[0]); - } - } - - public static class RoutingEnvironment { - private RoutePlannerFrontEnd router; - private RoutingContext ctx; - private RoutingContext complexCtx; - private PrecalculatedRouteDirection precalculated; - - public RoutingEnvironment(RoutePlannerFrontEnd router, RoutingContext ctx, RoutingContext complexCtx, PrecalculatedRouteDirection precalculated) { - this.router = router; - this.ctx = ctx; - this.complexCtx = complexCtx; - this.precalculated = precalculated; - } - - public RoutePlannerFrontEnd getRouter() { - return router; - } - - public RoutingContext getCtx() { - return ctx; - } - - public RoutingContext getComplexCtx() { - return complexCtx; - } - - public PrecalculatedRouteDirection getPrecalculated() { - return precalculated; - } - } - - public RouteProvider() { - } - - public static class GPXRouteParamsBuilder { - boolean calculateOsmAndRoute = false; - // parameters - private final GPXFile file; - private boolean reverse; - private boolean leftSide; - private boolean passWholeRoute; - private boolean calculateOsmAndRouteParts; - private int selectedSegment = -1; - - public GPXRouteParamsBuilder(GPXFile file, OsmandSettings settings) { - leftSide = settings.DRIVING_REGION.get().leftHandDriving; - this.file = file; - } - - public boolean isReverse() { - return reverse; - } - - public boolean isCalculateOsmAndRouteParts() { - return calculateOsmAndRouteParts; - } - - public void setCalculateOsmAndRouteParts(boolean calculateOsmAndRouteParts) { - this.calculateOsmAndRouteParts = calculateOsmAndRouteParts; - } - - public boolean isUseIntermediatePointsRTE() { - return file.hasRtePt() && !file.hasTrkPt(); - } - - public boolean isCalculateOsmAndRoute() { - return calculateOsmAndRoute; - } - - public void setCalculateOsmAndRoute(boolean calculateOsmAndRoute) { - this.calculateOsmAndRoute = calculateOsmAndRoute; - } - - public int getSelectedSegment() { - return selectedSegment; - } - - public void setSelectedSegment(int selectedSegment) { - this.selectedSegment = selectedSegment; - } - - public void setPassWholeRoute(boolean passWholeRoute) { - this.passWholeRoute = passWholeRoute; - } - - public boolean isPassWholeRoute() { - return passWholeRoute; - } - - public GPXRouteParams build(OsmandApplication app) { - GPXRouteParams res = new GPXRouteParams(); - try { - res.prepareGPXFile(this); - } catch (RuntimeException e) { - log.error(e.getMessage(), e); - app.showShortToastMessage(app.getString(R.string.gpx_parse_error) + " " + e.getMessage()); - } - return res; - } - - public void setReverse(boolean reverse) { - this.reverse = reverse; - } - - public GPXFile getFile() { - return file; - } - - public List getPoints(OsmandApplication app) { - GPXRouteParams copy = build(app); - return copy.getPoints(); - } - } - - public static class GPXRouteParams { - List points = new ArrayList<>(); - List directions; - List route; - List routePoints = new ArrayList<>(); - boolean reverse; - boolean calculateOsmAndRoute; - boolean passWholeRoute; - boolean calculateOsmAndRouteParts; - boolean useIntermediatePointsRTE; - private List wpt; - - boolean addMissingTurns = true; - - public List getPoints() { - return points; - } - - public Location getStartPointForRoute(){ - if(!points.isEmpty()){ - return points.get(0); - } - return null; - } - - public Location getEndPointForRoute(){ - if(!points.isEmpty()){ - return points.get(points.size()); - } - return null; - } - - public LatLon getLastPoint() { - if(!points.isEmpty()){ - Location l = points.get(points.size() - 1); - LatLon point = new LatLon(l.getLatitude(), l.getLongitude()); - return point; - } - return null; - } - - public GPXRouteParams prepareGPXFile(GPXRouteParamsBuilder builder) { - GPXFile file = builder.file; - reverse = builder.reverse; - passWholeRoute = builder.passWholeRoute; - calculateOsmAndRouteParts = builder.calculateOsmAndRouteParts; - useIntermediatePointsRTE = builder.isUseIntermediatePointsRTE(); - builder.calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute; - if (!file.isPointsEmpty()) { - wpt = new ArrayList(file.getPoints().size()); - for(WptPt w : file.getPoints()) { - wpt.add(new WptLocationPoint(w)); - } - } - int selectedSegment = builder.getSelectedSegment(); - if (OSMAND_ROUTER_V2.equals(file.author)) { - route = parseOsmAndGPXRoute(points, file, selectedSegment); - if (selectedSegment == -1) { - routePoints = file.getRoutePoints(); - } else { - routePoints = file.getRoutePoints(selectedSegment); - } - if (reverse) { - Collections.reverse(points); - Collections.reverse(routePoints); - } - addMissingTurns = route != null && route.isEmpty(); - } else if (file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)) { - directions = parseOsmAndGPXRoute(points, file, OSMAND_ROUTER.equals(file.author), builder.leftSide, 10, selectedSegment); - if (OSMAND_ROUTER.equals(file.author) && file.hasRtePt()) { - // For files generated by OSMAND_ROUTER use directions contained unaltered - addMissingTurns = false; - } - if (reverse) { - // clear directions all turns should be recalculated - directions = null; - Collections.reverse(points); - addMissingTurns = true; - } - } else { - // first of all check tracks - if (!useIntermediatePointsRTE) { - List segments = file.getNonEmptyTrkSegments(false); - if (selectedSegment != -1 && segments.size() > selectedSegment) { - TrkSegment segment = segments.get(selectedSegment); - for (WptPt p : segment.points) { - points.add(createLocation(p)); - } - } else { - for (TrkSegment tkSeg : segments) { - for (WptPt p : tkSeg.points) { - points.add(createLocation(p)); - } - } - } - } - if (points.isEmpty()) { - for (Route rte : file.routes) { - for (WptPt pt : rte.points) { - points.add(createLocation(pt)); - } - } - } - if (reverse) { - Collections.reverse(points); - } - } - return this; - } - } - public static Location createLocation(WptPt pt){ Location loc = new Location("OsmandRouteProvider"); loc.setLatitude(pt.lat); @@ -420,8 +153,9 @@ public class RouteProvider { GPXRouteParams gpxParams = routeParams.gpxRoute; boolean calcWholeRoute = routeParams.gpxRoute.passWholeRoute && (routeParams.previousToRecalculate == null || !routeParams.onlyStartPointChanged); boolean calculateOsmAndRouteParts = gpxParams.calculateOsmAndRouteParts; + boolean reverseRoutePoints = gpxParams.reverse && gpxParams.routePoints.size() > 1; List gpxRouteResult = routeParams.gpxRoute.route; - if (gpxParams.reverse && gpxParams.routePoints.size() > 1) { + if (reverseRoutePoints) { List gpxRouteLocations = new ArrayList<>(); List gpxRoute = new ArrayList<>(); WptPt firstGpxPoint = gpxParams.routePoints.get(0); @@ -481,18 +215,25 @@ public class RouteProvider { List firstSegmentRoute = null; List lastSegmentRoute = null; List gpxRoute; + if (nearestGpxPointInd > 0) { nearestGpxLocation = gpxRouteLocations.get(nearestGpxPointInd); - gpxRoute = result.getOriginalRoute(nearestGpxPointInd); - if (gpxRoute.size() > 0) { - gpxRoute.remove(0); - } - } else { - if (!gpxRouteLocations.isEmpty()) { - nearestGpxLocation = gpxRouteLocations.get(0); - } - gpxRoute = result.getOriginalRoute(); + } else if (!gpxRouteLocations.isEmpty()) { + nearestGpxLocation = gpxRouteLocations.get(0); } + if (calculateOsmAndRouteParts && !reverseRoutePoints && !Algorithms.isEmpty(gpxParams.segmentEndpoints)) { + gpxRoute = findRouteWithIntermediateSegments(routeParams, result, gpxRouteLocations, gpxParams.segmentEndpoints, nearestGpxPointInd); + } else { + if (nearestGpxPointInd > 0) { + gpxRoute = result.getOriginalRoute(nearestGpxPointInd); + if (gpxRoute.size() > 0) { + gpxRoute.remove(0); + } + } else { + gpxRoute = result.getOriginalRoute(); + } + } + if (calculateOsmAndRouteParts && routeParams.start != null && nearestGpxLocation != null && nearestGpxLocation.distanceTo(routeParams.start) > MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT) { @@ -534,6 +275,7 @@ public class RouteProvider { } final List inputDirections = gpxParams.directions; List gpxDirections = calcDirections(startI, endI, inputDirections); + insertIntermediateSegments(routeParams, gpxRoute, gpxDirections, gpxParams.segmentEndpoints, calculateOsmAndRouteParts); insertInitialSegment(routeParams, gpxRoute, gpxDirections, calculateOsmAndRouteParts); insertFinalSegment(routeParams, gpxRoute, gpxDirections, calculateOsmAndRouteParts); @@ -683,6 +425,68 @@ public class RouteProvider { } } + public void insertIntermediateSegments(RouteCalculationParams routeParams, List points, List directions, + List segmentEndpoints, boolean calculateOsmAndRouteParts) { + for (int i = 0; i < segmentEndpoints.size() - 1; i++) { + Location prevSegmentPoint = segmentEndpoints.get(i); + Location newSegmentPoint = segmentEndpoints.get(i + 1); + + if (prevSegmentPoint.distanceTo(newSegmentPoint) <= MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT) { + continue; + } + int index = points.indexOf(newSegmentPoint); + if (calculateOsmAndRouteParts && index != -1 && points.contains(prevSegmentPoint)) { + LatLon end = new LatLon(newSegmentPoint.getLatitude(), newSegmentPoint.getLongitude()); + RouteCalculationResult newRes = findOfflineRouteSegment(routeParams, prevSegmentPoint, end); + + if (newRes != null && newRes.isCalculated()) { + List loct = newRes.getImmutableAllLocations(); + List dt = newRes.getImmutableAllDirections(); + + for (RouteDirectionInfo directionInfo : dt) { + directionInfo.routePointOffset += points.size(); + } + points.addAll(index, loct); + directions.addAll(dt); + } + } + } + } + + public List findRouteWithIntermediateSegments(RouteCalculationParams routeParams, + RouteCalculationResult result, + List gpxRouteLocations, + List segmentEndpoints, + int nearestGpxPointInd) { + List newGpxRoute = new ArrayList<>(); + + int lastIndex = nearestGpxPointInd; + for (int i = 0; i < segmentEndpoints.size() - 1; i++) { + Location prevSegmentPoint = segmentEndpoints.get(i); + Location newSegmentPoint = segmentEndpoints.get(i + 1); + + if (prevSegmentPoint.distanceTo(newSegmentPoint) <= MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT) { + continue; + } + int indexNew = findNearestGpxPointIndexFromRoute(gpxRouteLocations, newSegmentPoint, routeParams.gpxRoute.calculateOsmAndRouteParts); + int indexPrev = findNearestGpxPointIndexFromRoute(gpxRouteLocations, prevSegmentPoint, routeParams.gpxRoute.calculateOsmAndRouteParts); + if (indexPrev != -1 && indexPrev > nearestGpxPointInd && indexNew != -1) { + newGpxRoute.addAll(result.getOriginalRoute(lastIndex, indexPrev)); + lastIndex = indexNew; + + LatLon end = new LatLon(newSegmentPoint.getLatitude(), newSegmentPoint.getLongitude()); + RouteCalculationResult newRes = findOfflineRouteSegment(routeParams, prevSegmentPoint, end); + List segmentResults = newRes.getOriginalRoute(); + if (!Algorithms.isEmpty(segmentResults)) { + newGpxRoute.addAll(segmentResults); + } + } + } + newGpxRoute.addAll(result.getOriginalRoute(lastIndex)); + + return newGpxRoute; + } + private RouteCalculationResult findOfflineRouteSegment(RouteCalculationParams rParams, Location start, LatLon end) { RouteCalculationParams newParams = new RouteCalculationParams(); @@ -771,13 +575,6 @@ public class RouteProvider { return nearestPointIndex; } - protected String getString(Context ctx, int resId){ - if(ctx == null){ - return ""; //$NON-NLS-1$ - } - return ctx.getString(resId); - } - public RoutingEnvironment getRoutingEnvironment(OsmandApplication ctx, ApplicationMode mode, LatLon start, LatLon end) throws IOException { RouteCalculationParams params = new RouteCalculationParams(); params.ctx = ctx; @@ -788,11 +585,11 @@ public class RouteProvider { } public List generateGpxPoints(RoutingEnvironment env, GpxRouteApproximation gctx, LocationsHolder locationsHolder) { - return env.router.generateGpxPoints(gctx, locationsHolder); + return env.getRouter().generateGpxPoints(gctx, locationsHolder); } public GpxRouteApproximation calculateGpxPointsApproximation(RoutingEnvironment env, GpxRouteApproximation gctx, List points, ResultMatcher resultMatcher) throws IOException, InterruptedException { - return env.router.searchGpxRoute(gctx, points, resultMatcher); + return env.getRouter().searchGpxRoute(gctx, points, resultMatcher); } protected RoutingEnvironment calculateRoutingEnvironment(RouteCalculationParams params, boolean calcGPXRoute, boolean skipComplex) throws IOException { @@ -885,7 +682,7 @@ public class RouteProvider { if (params.intermediates != null) { inters = new ArrayList(params.intermediates); } - return calcOfflineRouteImpl(params, env.router, env.ctx, env.complexCtx, st, en, inters, env.precalculated); + return calcOfflineRouteImpl(params, env.getRouter(), env.getCtx(), env.getComplexCtx(), st, en, inters, env.getPrecalculated()); } private RoutingConfiguration initOsmAndRoutingConfig(Builder config, final RouteCalculationParams params, OsmandSettings settings, @@ -1012,7 +809,9 @@ public class RouteProvider { return new RouteCalculationResult("Empty result"); } - private static List parseOsmAndGPXRoute(List points, GPXFile gpxFile, int selectedSegment) { + protected static List parseOsmAndGPXRoute(List points, GPXFile gpxFile, + List segmentEndpoints, + int selectedSegment) { List segments = gpxFile.getNonEmptyTrkSegments(false); if (selectedSegment != -1 && segments.size() > selectedSegment) { TrkSegment segment = segments.get(selectedSegment); @@ -1022,37 +821,51 @@ public class RouteProvider { RouteImporter routeImporter = new RouteImporter(segment); return routeImporter.importRoute(); } else { - for (TrkSegment ts : segments) { - for (WptPt p : ts.points) { - points.add(createLocation(p)); - } - } + collectPointsFromSegments(segments, points, segmentEndpoints); RouteImporter routeImporter = new RouteImporter(gpxFile); return routeImporter.importRoute(); } } - private static List parseOsmAndGPXRoute(List points, GPXFile gpxFile, boolean osmandRouter, - boolean leftSide, float defSpeed, int selectedSegment) { + protected static void collectSegmentPointsFromGpx(GPXFile gpxFile, List points, + List segmentEndpoints, int selectedSegment) { + List segments = gpxFile.getNonEmptyTrkSegments(false); + if (selectedSegment != -1 && segments.size() > selectedSegment) { + TrkSegment segment = segments.get(selectedSegment); + for (WptPt wptPt : segment.points) { + points.add(createLocation(wptPt)); + } + } else { + collectPointsFromSegments(segments, points, segmentEndpoints); + } + } + + protected static void collectPointsFromSegments(List segments, List points, List segmentEndpoints) { + Location lastPoint = null; + for (int i = 0; i < segments.size(); i++) { + TrkSegment segment = segments.get(i); + for (WptPt wptPt : segment.points) { + points.add(createLocation(wptPt)); + } + if (i <= segments.size() - 1 && lastPoint != null) { + segmentEndpoints.add(lastPoint); + segmentEndpoints.add(points.get((points.size() - segment.points.size()))); + } + lastPoint = points.get(points.size() - 1); + } + } + + protected static List parseOsmAndGPXRoute(List points, GPXFile gpxFile, + List segmentEndpoints, + boolean osmandRouter, boolean leftSide, + float defSpeed, int selectedSegment) { List directions = null; if (!osmandRouter) { for (WptPt pt : gpxFile.getPoints()) { points.add(createLocation(pt)); } } else { - List segments = gpxFile.getNonEmptyTrkSegments(false); - if (selectedSegment != -1 && segments.size() > selectedSegment) { - TrkSegment segment = segments.get(selectedSegment); - for (WptPt p : segment.points) { - points.add(createLocation(p)); - } - } else { - for (TrkSegment ts : segments) { - for (WptPt p : ts.points) { - points.add(createLocation(p)); - } - } - } + collectSegmentPointsFromGpx(gpxFile, points, segmentEndpoints, selectedSegment); } float[] distanceToEnd = new float[points.size()]; for (int i = points.size() - 2; i >= 0; i--) { @@ -1228,16 +1041,28 @@ public class RouteProvider { } private RouteCalculationResult findOnlineRoute(RouteCalculationParams params) throws IOException, JSONException { - OnlineRoutingHelper helper = params.ctx.getOnlineRoutingHelper(); - String stringKey = params.mode.getRoutingProfile(); + OsmandApplication app = params.ctx; + OnlineRoutingHelper helper = app.getOnlineRoutingHelper(); + OsmandSettings settings = app.getSettings(); + String engineKey = params.mode.getRoutingProfile(); OnlineRoutingResponse response = - helper.calculateRouteOnline(stringKey, getPathFromParams(params), params.leftSide); + helper.calculateRouteOnline(engineKey, getPathFromParams(params), params.leftSide); + if (response != null) { - params.intermediates = null; - return new RouteCalculationResult(response.getRoute(), response.getDirections(), params, null, false); - } else { - return new RouteCalculationResult("Route is empty"); + if (response.getGpxFile() != null) { + GPXRouteParamsBuilder builder = new GPXRouteParamsBuilder(response.getGpxFile(), settings); + params.gpxRoute = builder.build(app); + return calculateGpxRoute(params); + } + List route = response.getRoute(); + List directions = response.getDirections(); + if (!Algorithms.isEmpty(route) && !Algorithms.isEmpty(directions)) { + params.intermediates = null; + return new RouteCalculationResult(route, directions, params, null, false); + } } + + return new RouteCalculationResult("Route is empty"); } private static List getPathFromParams(RouteCalculationParams params) { @@ -1305,9 +1130,10 @@ public class RouteProvider { bpars.putString("turnInstructionFormat", "osmand"); bpars.putString("acceptCompressedResult", "true"); - OsmandApplication ctx = (OsmandApplication) params.ctx; + OsmandApplication ctx = params.ctx; List res = new ArrayList(); - List dir = new ArrayList<>(); + List dir = new ArrayList<>(); + List segmentEndpoints = new ArrayList<>(); IBRouterService brouterService = ctx.getBRouterService(); if (brouterService == null) { @@ -1320,22 +1146,22 @@ public class RouteProvider { boolean isZ64Encoded = gpxMessage.startsWith("ejY0"); // base-64 version of "z64" - if (!( isZ64Encoded || gpxMessage.startsWith("<") ) ) { + if (!(isZ64Encoded || gpxMessage.startsWith("<"))) { return new RouteCalculationResult(gpxMessage); } InputStream gpxStream; - if ( isZ64Encoded ) { - ByteArrayInputStream bais = new ByteArrayInputStream( Base64.decode(gpxMessage, Base64.DEFAULT) ); - bais.read( new byte[3] ); // skip prefix - gpxStream = new GZIPInputStream( bais ); + if (isZ64Encoded) { + ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decode(gpxMessage, Base64.DEFAULT)); + bais.read(new byte[3]); // skip prefix + gpxStream = new GZIPInputStream(bais); } else { gpxStream = new ByteArrayInputStream(gpxMessage.getBytes("UTF-8")); } GPXFile gpxFile = GPXUtilities.loadGPXFile(gpxStream); - dir = parseOsmAndGPXRoute(res, gpxFile, true, params.leftSide, params.mode.getDefaultSpeed(), -1); + dir = parseOsmAndGPXRoute(res, gpxFile, segmentEndpoints, true, params.leftSide, params.mode.getDefaultSpeed(), -1); if (dir != null) { addMissingTurns = false; @@ -1378,6 +1204,4 @@ public class RouteProvider { } return new RouteCalculationResult(segments, computeDirections, params, null, false); } - - -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java b/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java index 175003fe18..8fb8201dea 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java @@ -6,6 +6,7 @@ import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.router.RouteCalculationProgress; @@ -179,7 +180,7 @@ class RouteRecalculationHelper { } public void recalculateRouteInBackground(final Location start, final LatLon end, final List intermediates, - final RouteProvider.GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged, boolean onlyStartPointChanged) { + final GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged, boolean onlyStartPointChanged) { if (start == null || end == null) { return; } @@ -207,7 +208,7 @@ class RouteRecalculationHelper { params.mode = mode; params.ctx = app; boolean updateProgress = false; - if (params.mode.getRouteService() == RouteProvider.RouteService.OSMAND) { + if (params.mode.getRouteService() == RouteService.OSMAND) { params.calculationProgress = new RouteCalculationProgress(); updateProgress = true; } else { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteService.java b/OsmAnd/src/net/osmand/plus/routing/RouteService.java new file mode 100644 index 0000000000..6565b09106 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/RouteService.java @@ -0,0 +1,45 @@ +package net.osmand.plus.routing; + +import net.osmand.plus.OsmandApplication; + +import java.util.ArrayList; +import java.util.List; + +public enum RouteService { + OSMAND("OsmAnd (offline)"), + BROUTER("BRouter (offline)"), + STRAIGHT("Straight line"), + DIRECT_TO("Direct To"), + ONLINE("Online engine"); + + private final String name; + + RouteService(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public boolean isOnline() { + return this != OSMAND && this != BROUTER; + } + + boolean isAvailable(OsmandApplication ctx) { + if (this == BROUTER) { + return ctx.getBRouterService() != null; + } + return true; + } + + public static RouteService[] getAvailableRouters(OsmandApplication ctx) { + List list = new ArrayList<>(); + for (RouteService r : values()) { + if (r.isAvailable(ctx)) { + list.add(r); + } + } + return list.toArray(new RouteService[0]); + } +} diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingEnvironment.java b/OsmAnd/src/net/osmand/plus/routing/RoutingEnvironment.java new file mode 100644 index 0000000000..15b484cc67 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingEnvironment.java @@ -0,0 +1,36 @@ +package net.osmand.plus.routing; + +import net.osmand.router.PrecalculatedRouteDirection; +import net.osmand.router.RoutePlannerFrontEnd; +import net.osmand.router.RoutingContext; + +public class RoutingEnvironment { + + private RoutingContext ctx; + private RoutingContext complexCtx; + private RoutePlannerFrontEnd router; + private PrecalculatedRouteDirection precalculated; + + public RoutingEnvironment(RoutePlannerFrontEnd router, RoutingContext ctx, RoutingContext complexCtx, PrecalculatedRouteDirection precalculated) { + this.router = router; + this.ctx = ctx; + this.complexCtx = complexCtx; + this.precalculated = precalculated; + } + + public RoutePlannerFrontEnd getRouter() { + return router; + } + + public RoutingContext getCtx() { + return ctx; + } + + public RoutingContext getComplexCtx() { + return complexCtx; + } + + public PrecalculatedRouteDirection getPrecalculated() { + return precalculated; + } +} diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 1addb2f50a..8ab9405ee1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -20,9 +20,7 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; -import net.osmand.plus.routing.RouteProvider.RouteService; -import net.osmand.plus.routing.RouteProvider.RoutingEnvironment; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; import net.osmand.plus.settings.backend.OsmandSettings; @@ -670,9 +668,9 @@ public class RoutingHelper { private static float getDefaultAllowedDeviation(OsmandSettings settings, ApplicationMode mode, float posTolerance) { if (settings.DISABLE_OFFROUTE_RECALC.getModeValue(mode)) { return -1.0f; - } else if (mode.getRouteService() == RouteProvider.RouteService.DIRECT_TO) { + } else if (mode.getRouteService() == RouteService.DIRECT_TO) { return -1.0f; - } else if (mode.getRouteService() == RouteProvider.RouteService.STRAIGHT) { + } else if (mode.getRouteService() == RouteService.STRAIGHT) { MetricsConstants mc = settings.METRIC_SYSTEM.getModeValue(mode); if (mc == MetricsConstants.KILOMETERS_AND_METERS || mc == MetricsConstants.MILES_AND_METERS) { return 500.f; diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java index 08da774f27..637e3078e7 100644 --- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java @@ -18,7 +18,6 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.render.NativeOsmandLibrary; import net.osmand.plus.routing.RouteCalculationParams.RouteCalculationResultListener; -import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java index 29a50aae4b..3d84bcf850 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java @@ -1,6 +1,8 @@ package net.osmand.plus.settings.backend; +import androidx.annotation.ColorInt; import androidx.annotation.DrawableRes; +import androidx.core.content.ContextCompat; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -12,7 +14,7 @@ import net.osmand.plus.R; import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.profiles.NavigationIcon; import net.osmand.plus.profiles.ProfileIconColors; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.RouteService; import net.osmand.util.Algorithms; import org.apache.commons.lang3.StringUtils; @@ -469,6 +471,15 @@ public class ApplicationMode { return app.getSettings().LOCATION_ICON.getModeValue(this); } + @ColorInt + public int getProfileColor(boolean nightMode) { + Integer customProfileColor = getCustomIconColor(); + if (customProfileColor != null) { + return customProfileColor; + } + return ContextCompat.getColor(app, getIconColorInfo().getColor(nightMode)); + } + public void setLocationIcon(LocationIcon locationIcon) { if (locationIcon != null) { app.getSettings().LOCATION_ICON.setModeValue(this, locationIcon); @@ -485,6 +496,28 @@ public class ApplicationMode { } } + public List getCustomIconColors() { + return app.getSettings().CUSTOM_ICON_COLORS.getStringsListForProfile(this); + } + + public void setCustomIconColors(List customColors) { + app.getSettings().CUSTOM_ICON_COLORS.setModeValues(this, customColors); + } + + public Integer getCustomIconColor() { + try { + String customColor = app.getSettings().CUSTOM_ICON_COLOR.getModeValue(this); + return Algorithms.isEmpty(customColor) ? null : Algorithms.parseColor(customColor); + } catch (IllegalArgumentException e) { + return null; + } + } + + public void setCustomIconColor(Integer customIconColor) { + String valueToSave = customIconColor == null ? null : Algorithms.colorToString(customIconColor); + app.getSettings().CUSTOM_ICON_COLOR.setModeValue(this, valueToSave); + } + public int getOrder() { return app.getSettings().APP_MODE_ORDER.getModeValue(this); } @@ -582,6 +615,7 @@ public class ApplicationMode { mode.setRoutingProfile(builder.routingProfile); mode.setRouteService(builder.routeService); mode.setIconColor(builder.iconColor); + mode.setCustomIconColor(builder.customIconColor); mode.setLocationIcon(builder.locationIcon); mode.setNavigationIcon(builder.navigationIcon); mode.setOrder(builder.order); @@ -604,6 +638,7 @@ public class ApplicationMode { builder.setUserProfileName(modeBean.userProfileName); builder.setIconResName(modeBean.iconName); builder.setIconColor(modeBean.iconColor); + builder.setCustomIconColor(modeBean.customIconColor); builder.setRoutingProfile(modeBean.routingProfile); builder.setRouteService(modeBean.routeService); builder.setLocationIcon(modeBean.locIcon); @@ -623,6 +658,7 @@ public class ApplicationMode { mb.stringKey = stringKey; mb.userProfileName = getUserProfileName(); mb.iconColor = getIconColorInfo(); + mb.customIconColor = getCustomIconColor(); mb.iconName = getIconName(); mb.parent = parentAppMode != null ? parentAppMode.getStringKey() : null; mb.routeService = getRouteService(); @@ -699,6 +735,7 @@ public class ApplicationMode { private String routingProfile; private String iconResName; private ProfileIconColors iconColor; + private Integer customIconColor; private LocationIcon locationIcon; private NavigationIcon navigationIcon; private int order = -1; @@ -722,6 +759,7 @@ public class ApplicationMode { applicationMode.setRouteService(routeService); applicationMode.setRoutingProfile(routingProfile); applicationMode.setIconResName(iconResName); + applicationMode.setCustomIconColor(customIconColor); applicationMode.setIconColor(iconColor); applicationMode.setLocationIcon(locationIcon); applicationMode.setNavigationIcon(navigationIcon); @@ -770,6 +808,11 @@ public class ApplicationMode { return this; } + public ApplicationModeBuilder setCustomIconColor(Integer customIconColor) { + this.customIconColor = customIconColor; + return this; + } + public ApplicationModeBuilder setOrder(int order) { this.order = order; return this; @@ -798,6 +841,8 @@ public class ApplicationMode { @Expose public ProfileIconColors iconColor = ProfileIconColors.DEFAULT; @Expose + public Integer customIconColor = null; + @Expose public String routingProfile = null; @Expose public RouteService routeService = RouteService.OSMAND; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 44831fa52c..0762f453f1 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -48,7 +48,7 @@ import net.osmand.plus.profiles.NavigationIcon; import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.render.RendererRegistry; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.srtmplugin.TerrainMode; import net.osmand.plus.views.layers.RadiusRulerControlLayer.RadiusRulerMode; import net.osmand.plus.voice.CommandPlayer; @@ -983,6 +983,10 @@ public class OsmandSettings { public final CommonPreference ICON_COLOR = new EnumStringPreference<>(this, "app_mode_icon_color", ProfileIconColors.DEFAULT, ProfileIconColors.values()).makeProfile().cache(); + public final ListStringPreference CUSTOM_ICON_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_icon_colors", null, ",").makeProfile().cache(); + + public final CommonPreference CUSTOM_ICON_COLOR = new StringPreference(this, "custom_icon_color", null).makeProfile().cache(); + public final CommonPreference USER_PROFILE_NAME = new StringPreference(this, "user_profile_name", "").makeProfile().cache(); public final CommonPreference PARENT_APP_MODE = new StringPreference(this, "parent_app_mode", null).makeProfile().cache(); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java index 88405fd010..203c0a2323 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java @@ -301,6 +301,7 @@ public class ProfileSettingsItem extends OsmandSettingsItem { OsmandSettings settings = app.getSettings(); return new String[] { settings.ICON_COLOR.getId(), + settings.CUSTOM_ICON_COLOR.getId(), settings.ICON_RES_NAME.getId(), settings.PARENT_APP_MODE.getId(), settings.ROUTING_PROFILE.getId(), diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/AnnouncementTimeBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/AnnouncementTimeBottomSheet.java index 00db145474..bbec0c6211 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/AnnouncementTimeBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/AnnouncementTimeBottomSheet.java @@ -171,7 +171,7 @@ public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet } private void setProfileColorToSeekBar() { - int color = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(nightMode)); + int color = getAppMode().getProfileColor(nightMode); LayerDrawable seekBarProgressLayer = (LayerDrawable) ContextCompat.getDrawable(app, R.drawable.seekbar_progress_announcement_time); diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java index 5eb3dd226c..6b0e2089d8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java @@ -103,7 +103,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { }) .create(); if (isProfileDependent()) { - preferenceBtn[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode)); + preferenceBtn[0].setCompoundButtonColor(getAppMode().getProfileColor(nightMode)); } items.add(preferenceBtn[0]); @@ -133,8 +133,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { Context themedCtx = UiUtilities.getThemedContext(app, nightMode); View buttonView = customView.findViewById(R.id.button_container); - int colorRes = mode.getIconColorInfo().getColor(nightMode); - int color = checked ? ContextCompat.getColor(themedCtx, colorRes) : AndroidUtils.getColorFromAttr(themedCtx, R.attr.divider_color_basic); + int color = checked ? mode.getProfileColor(nightMode) : AndroidUtils.getColorFromAttr(themedCtx, R.attr.divider_color_basic); int bgColor = UiUtilities.getColorWithAlpha(color, checked ? 0.1f : 0.5f); int selectedColor = UiUtilities.getColorWithAlpha(color, checked ? 0.3f : 0.5f); diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java index badfcbfb2c..25b00e338c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.view.View; import android.widget.TextView; +import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -65,6 +66,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment { private int checkedColor; private int uncheckedColor; private int disabledColor; + @ColorInt private int appModeColor; @Override @@ -101,7 +103,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment { on = getString(R.string.shared_string_enabled); off = getString(R.string.shared_string_disabled); - appModeColor = appMode.getIconColorInfo().getColor(nightMode); + appModeColor = appMode.getProfileColor(nightMode); activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic); disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary); checkedColor = (nightMode ? app.getResources().getColor(R.color.text_color_primary_dark) : app.getResources().getColor(R.color.text_color_primary_light)); @@ -122,7 +124,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment { private void createUseHeightButton(Context context) { boolean checked = useHeightPref.getModeValue(appMode); useHeightButton = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() - .setCompoundButtonColorId(appModeColor) + .setCompoundButtonColor(appModeColor) .setChecked(checked) .setTitle(checked ? on : off) .setTitleColorId(checked ? activeColor : disabledColor) diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/MultiSelectPreferencesBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/MultiSelectPreferencesBottomSheet.java index 71881876b3..90b88a264d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/MultiSelectPreferencesBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/MultiSelectPreferencesBottomSheet.java @@ -89,7 +89,7 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet .setTag(prefId) .create(); if (isProfileDependent()) { - item[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode)); + item[0].setCompoundButtonColor(getAppMode().getProfileColor(nightMode)); } items.add(item[0]); } diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java index c270ea0ed8..7bde0e8034 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java @@ -84,8 +84,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot entryValues = new Float[]{9.1f, 18.3f, 30.5f, 45.7f, 91.5f, 183.0f, 482.0f, 965.0f, 1609.0f}; } - final int appModeColorId = appMode.getIconColorInfo().getColor(nightMode); - final int appModeColor = ContextCompat.getColor(themedCtx, appModeColorId); + final int appModeColor = appMode.getProfileColor(nightMode); final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic); final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary); @@ -108,7 +107,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1]; preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() .setChecked(enabled) - .setCompoundButtonColorId(appModeColorId) + .setCompoundButtonColor(appModeColor) .setTitle(enabled ? on : off) .setTitleColorId(enabled ? activeColor : disabledColor) .setCustomView(getCustomButtonView(app, getAppMode(), enabled, nightMode)) diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ResetProfilePrefsBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ResetProfilePrefsBottomSheet.java index e9317533bc..69e225b4c0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ResetProfilePrefsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ResetProfilePrefsBottomSheet.java @@ -38,18 +38,17 @@ public class ResetProfilePrefsBottomSheet extends BasePreferenceBottomSheet { String title = getString(customProfile ? R.string.restore_all_profile_settings : R.string.reset_all_profile_settings); items.add(new TitleItem(title)); - int profileColor = mode.getIconColorInfo().getColor(nightMode); - int colorNoAlpha = ContextCompat.getColor(ctx, profileColor); + int colorNoAlpha = mode.getProfileColor(nightMode); Drawable backgroundIcon = UiUtilities.getColoredSelectableDrawable(ctx, colorNoAlpha, 0.3f); Drawable[] layers = {new ColorDrawable(UiUtilities.getColorWithAlpha(colorNoAlpha, 0.10f)), backgroundIcon}; BaseBottomSheetItem profileItem = new BottomSheetItemWithCompoundButton.Builder() .setChecked(true) - .setCompoundButtonColorId(profileColor) - .setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor))) + .setCompoundButtonColor(colorNoAlpha) + .setButtonTintList(ColorStateList.valueOf(colorNoAlpha)) .setDescription(ProfileDataUtils.getAppModeDescription(ctx, mode)) - .setIcon(getIcon(mode.getIconRes(), profileColor)) + .setIcon(getPaintedIcon(mode.getIconRes(), colorNoAlpha)) .setTitle(mode.toHumanString()) .setBackground(new LayerDrawable(layers)) .setLayoutId(R.layout.preference_profile_item_with_radio_btn) diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SingleSelectPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SingleSelectPreferenceBottomSheet.java index dc673207b2..2a214cdbe3 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SingleSelectPreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SingleSelectPreferenceBottomSheet.java @@ -6,6 +6,7 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -69,8 +70,11 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet final BaseBottomSheetItem[] preferenceItem = new BottomSheetItemWithCompoundButton[1]; preferenceItem[0] = new BottomSheetItemWithCompoundButton.Builder() .setChecked(i == selectedEntryIndex) - .setButtonTintList(AndroidUtils.createCheckedColorStateList(ctx, R.color.icon_color_default_light, - isProfileDependent() ? getAppMode().getIconColorInfo().getColor(nightMode) : getActiveColorId())) + .setButtonTintList(AndroidUtils.createCheckedColorIntStateList( + ContextCompat.getColor(ctx,R.color.icon_color_default_light), + isProfileDependent() ? + getAppMode().getProfileColor(nightMode) : + ContextCompat.getColor(ctx, getActiveColorId()))) .setTitle(entries[i]) .setTag(i) .setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left) diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/WakeTimeBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/WakeTimeBottomSheet.java index 149aa5b0a4..13dff97c94 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/WakeTimeBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/WakeTimeBottomSheet.java @@ -118,8 +118,7 @@ public class WakeTimeBottomSheet extends BasePreferenceBottomSheet { } }); - int appModeColorId = getAppMode().getIconColorInfo().getColor(nightMode); - int appModeColor = ContextCompat.getColor(themedCtx, appModeColorId); + int appModeColor = getAppMode().getProfileColor(nightMode); UiUtilities.setupSlider(slider, nightMode, appModeColor, true); items.add(new BaseBottomSheetItem.Builder() diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index 63dab74fd4..e6d39cade8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -680,12 +680,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl @ColorInt protected int getActiveProfileColor() { - return ContextCompat.getColor(app, getActiveProfileColorRes()); - } - - @ColorRes - protected int getActiveProfileColorRes() { - return isProfileDependent() ? getSelectedAppMode().getIconColorInfo().getColor(isNightMode()) : R.color.icon_color_active_light; + return isProfileDependent() ? + getSelectedAppMode().getProfileColor(isNightMode()) : + ContextCompat.getColor(app, nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light); } @ColorRes @@ -801,7 +798,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl protected Drawable getActiveIcon(@DrawableRes int id) { UiUtilities cache = getIconsCache(); - return cache != null ? cache.getIcon(id, getActiveProfileColorRes()) : null; + return cache != null ? cache.getPaintedIcon(id, getActiveProfileColor()) : null; } protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) { @@ -829,7 +826,8 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl Drawable icon = AndroidUtils.createEnabledStateListDrawable(disabled, enabled); if (Build.VERSION.SDK_INT < 21) { - ColorStateList colorStateList = AndroidUtils.createEnabledColorStateList(app, R.color.icon_color_default_light, getActiveProfileColorRes()); + int defaultColor = ContextCompat.getColor(app, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light); + ColorStateList colorStateList = AndroidUtils.createEnabledColorIntStateList(defaultColor, getActiveProfileColor()); icon = DrawableCompat.wrap(icon); DrawableCompat.setTintList(icon, colorStateList); return icon; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index 078197da4f..4b8e40f1a0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -6,9 +6,6 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; - import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; @@ -33,12 +30,16 @@ import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.util.Algorithms; -import org.apache.commons.logging.Log; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; import java.io.File; import java.util.List; +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.RecyclerView; + import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype; public class DuplicatesSettingsAdapter extends RecyclerView.Adapter { @@ -121,7 +122,10 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter colors = new ArrayList<>(); + for (ProfileIconColors color : ProfileIconColors.values()) { + colors.add(ContextCompat.getColor(app, color.getColor(isNightMode()))); } - updateProfileNameAppearance(); - updateProfileButton(); + colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors, app.getSettings().CUSTOM_ICON_COLORS, getSelectedAppMode()); + colorsCard.setListener(this); + colorsCardContainer.addView(colorsCard.build(app)); + updateColorName(); } private void updateProfileNameAppearance() { if (profileName != null) { if (profileName.isFocusable() && profileName.isFocusableInTouchMode()) { - int selectedColor = ContextCompat.getColor(app, changedProfile.color.getColor(isNightMode())); + int selectedColor = changedProfile.getActualColor(); profileNameOtfb.setPrimaryColor(selectedColor); profileName.getBackground().mutate().setColorFilter(selectedColor, PorterDuff.Mode.SRC_ATOP); } @@ -560,8 +541,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O private View createLocationIconView(final LocationIcon locationIcon, ViewGroup rootView) { FrameLayout locationIconView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode()) .inflate(R.layout.preference_select_icon_button, rootView, false); - int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor( - app.getDaynightHelper().isNightModeForMapControls())); + int changedProfileColor = changedProfile.getActualColor(); LayerDrawable locationIconDrawable = (LayerDrawable) AppCompatResources.getDrawable(app, locationIcon.getIconId()); if (locationIconDrawable != null) { DrawableCompat.setTint(DrawableCompat.wrap(locationIconDrawable.getDrawable(1)), changedProfileColor); @@ -609,7 +589,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O LayerDrawable navigationIconDrawable = (LayerDrawable) AppCompatResources.getDrawable(app, navigationIcon.getIconId()); if (navigationIconDrawable != null) { DrawableCompat.setTint(DrawableCompat.wrap(navigationIconDrawable.getDrawable(1)), - ContextCompat.getColor(app, changedProfile.color.getColor(app.getDaynightHelper().isNightModeForMapControls()))); + changedProfile.getActualColor()); } ImageView imageView = navigationIconView.findViewById(R.id.icon); imageView.setImageDrawable(navigationIconDrawable); @@ -634,8 +614,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O }); ImageView outlineRect = navigationIconView.findViewById(R.id.outlineRect); GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_icon_button_outline); - int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor( - app.getDaynightHelper().isNightModeForMapControls())); + int changedProfileColor = changedProfile.getActualColor(); if (rectContourDrawable != null) { rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), changedProfileColor); } @@ -660,13 +639,13 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O } private void setIconColor(int iconRes) { - int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor( - app.getDaynightHelper().isNightModeForMapControls())); + int changedProfileColor = changedProfile.getActualColor(); View iconItem = iconItems.findViewWithTag(iconRes); if (iconItem != null) { + int newColor = changedProfile.getActualColor(); AndroidUtils.setBackground(iconItem.findViewById(R.id.background), UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.circle_background_light), - UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, changedProfile.color.getColor(isNightMode())), 0.1f))); + UiUtilities.getColorWithAlpha(newColor, 0.1f))); ImageView outlineCircle = iconItem.findViewById(R.id.outline); GradientDrawable circleContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.circle_contour_bg_light); if (circleContourDrawable != null) { @@ -775,6 +754,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O mode.setRoutingProfile(changedProfile.routingProfile); mode.setRouteService(changedProfile.routeService); mode.setIconColor(changedProfile.color); + mode.setCustomIconColor(changedProfile.customColor); mode.setLocationIcon(changedProfile.locationIcon); mode.setNavigationIcon(changedProfile.navigationIcon); @@ -795,6 +775,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O .setRoutingProfile(changedProfile.routingProfile) .setRouteService(changedProfile.routeService) .setIconColor(changedProfile.color) + .setCustomIconColor(changedProfile.customColor) .setLocationIcon(changedProfile.locationIcon) .setNavigationIcon(changedProfile.navigationIcon); @@ -931,6 +912,18 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O } } + private void updateColorName() { + if (colorsCard == null || colorName == null) { + return; + } + int selectedColor = colorsCard.getSelectedColor(); + if (colorsCard.isBaseColor(selectedColor)) { + colorName.setText(changedProfile.getProfileColorByColorValue(selectedColor).getName()); + } else { + colorName.setText(R.string.custom_color); + } + } + @Override public void onProfileSelected(Bundle args) { String profileKey = args.getString(PROFILE_KEY_ARG); @@ -938,6 +931,53 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O updateParentProfile(profileKey, imported); } + @Override + public void onCardLayoutNeeded(@NonNull BaseCard card) { + } + + @Override + public void onCardPressed(@NonNull BaseCard card) { + if (card instanceof ColorsCard) { + ColorsCard cardOfColors = (ColorsCard) card; + int color = cardOfColors.getSelectedColor(); + + if (color == changedProfile.getActualColor()) { + return; + } + + if (cardOfColors.isBaseColor(color)) { + changedProfile.customColor = null; + changedProfile.color = changedProfile.getProfileColorByColorValue(color); + } else { + changedProfile.customColor = cardOfColors.getSelectedColor(); + changedProfile.color = null; + } + + if (iconItems != null) { + updateIconColor(changedProfile.iconRes); + } + + updateColorName(); + updateProfileNameAppearance(); + updateProfileButton(); + setVerticalScrollBarEnabled(false); + updatePreference(findPreference(MASTER_PROFILE)); + updatePreference(findPreference(LOCATION_ICON_ITEMS)); + updatePreference(findPreference(NAV_ICON_ITEMS)); + setVerticalScrollBarEnabled(true); + } + } + + @Override + public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) { + } + + @Override + public void onColorSelected(Integer prevColor, int newColor) { + colorsCard.onColorSelected(prevColor, newColor); + this.onCardPressed(colorsCard); + } + public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable String appMode, boolean imported) { try { Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName); @@ -963,12 +1003,29 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O ApplicationMode parent = null; String name; ProfileIconColors color; + Integer customColor = null; int iconRes; String routingProfile; - RouteProvider.RouteService routeService; + RouteService routeService; NavigationIcon navigationIcon; LocationIcon locationIcon; + @ColorInt + public int getActualColor() { + return customColor != null ? + customColor : ContextCompat.getColor(app, color.getColor(isNightMode())); + } + + public ProfileIconColors getProfileColorByColorValue(int colorValue) { + for (ProfileIconColors color : ProfileIconColors.values()) { + if (ContextCompat.getColor(app, color.getColor(true)) == colorValue + || ContextCompat.getColor(app, color.getColor(false)) == colorValue) { + return color; + } + } + return ProfileIconColors.DEFAULT; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -982,6 +1039,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O if (parent != null ? !parent.equals(that.parent) : that.parent != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (color != that.color) return false; + if (customColor != null ? !customColor.equals(that.customColor) : that.customColor != null) return false; if (routingProfile != null ? !routingProfile.equals(that.routingProfile) : that.routingProfile != null) return false; if (routeService != that.routeService) return false; @@ -995,6 +1053,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O result = 31 * result + (parent != null ? parent.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (color != null ? color.hashCode() : 0); + result = 31 * result + (customColor != null ? customColor.hashCode() : 0); result = 31 * result + iconRes; result = 31 * result + (routingProfile != null ? routingProfile.hashCode() : 0); result = 31 * result + (routeService != null ? routeService.hashCode() : 0); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java index 4ec93b68ef..eb4f09f4aa 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java @@ -31,6 +31,7 @@ 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.RoutingHelper; @@ -229,7 +230,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP fastRoute.setSummaryOn(R.string.shared_string_on); fastRoute.setSummaryOff(R.string.shared_string_off); - if (am.getRouteService() == RouteProvider.RouteService.OSMAND) { + if (am.getRouteService() == RouteService.OSMAND) { GeneralRouter router = app.getRouter(am); clearParameters(); if (router != null) { @@ -308,10 +309,10 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP } } setupTimeConditionalRoutingPref(); - } else if (am.getRouteService() == RouteProvider.RouteService.BROUTER) { + } else if (am.getRouteService() == RouteService.BROUTER) { screen.addPreference(fastRoute); setupTimeConditionalRoutingPref(); - } else if (am.getRouteService() == RouteProvider.RouteService.STRAIGHT) { + } else if (am.getRouteService() == RouteService.STRAIGHT) { Preference straightAngle = new Preference(app.getApplicationContext()); straightAngle.setPersistent(false); straightAngle.setKey(settings.ROUTE_STRAIGHT_ANGLE.getId()); @@ -443,7 +444,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP }); builder.setNegativeButton(R.string.shared_string_cancel, null); - int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode)); + int selectedModeColor = mode.getProfileColor(nightMode); setupAngleSlider(angleValue, sliderView, nightMode, selectedModeColor); builder.show(); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java index 7885a6700b..1b6f80848f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java @@ -25,8 +25,7 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.helpers.enums.SpeedConstants; -import net.osmand.plus.routing.RouteProvider.RouteService; -import net.osmand.plus.routing.RoutingHelper; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.StringPreference; import net.osmand.plus.settings.bottomsheets.VehicleParametersBottomSheet; @@ -280,7 +279,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O } }); - int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode)); + int selectedModeColor = mode.getProfileColor(nightMode); if (!defaultSpeedOnly) { setupSpeedSlider(SpeedSliderType.DEFAULT_SPEED, speedUnits, defaultValue, minValue, maxValue, min, max, seekbarView, selectedModeColor); setupSpeedSlider(SpeedSliderType.MIN_SPEED, speedUnits, defaultValue, minValue, maxValue, min, max, seekbarView, selectedModeColor); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java index 15d33c8fa3..0a67a3cfb0 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java @@ -21,11 +21,10 @@ import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE public class ContourLinesAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(29, - "contourlines.showhide", ContourLinesAction.class). - nameRes(R.string.quick_action_show_hide_contour_lines).iconRes(R.drawable.ic_plugin_srtm).nonEditable(). - category(QuickActionType.CONFIGURE_MAP); - - + "contourlines.showhide", ContourLinesAction.class) + .nameActionRes(R.string.quick_action_showhide_title) + .nameRes(R.string.srtm_plugin_name).iconRes(R.drawable.ic_plugin_srtm).nonEditable() + .category(QuickActionType.CONFIGURE_MAP); public ContourLinesAction() { super(TYPE); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java index 86abdee880..0b4f6d831c 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java @@ -184,7 +184,7 @@ public class ContourLinesMenu { contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(toggleActionStringId, mapActivity) .setIcon(toggleIconId) - .setColor(toggleIconColorId) + .setColor(app, toggleIconColorId) .setListener(l) .setSelected(selected).createItem()); if (selected) { @@ -225,7 +225,7 @@ public class ContourLinesMenu { .setTitleId(R.string.srtm_plugin_name, mapActivity) .setLayout(R.layout.list_item_icon_and_right_btn) .setIcon(R.drawable.ic_plugin_srtm) - .setColor(R.color.osmand_orange) + .setColor(app, R.color.osmand_orange) .setDescription(app.getString(R.string.shared_string_plugin)) .setListener(l).createItem()); } else { diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index e58bf4ef89..bf070b158a 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -10,7 +10,6 @@ import android.widget.ArrayAdapter; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; -import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; import net.osmand.data.LatLon; @@ -303,7 +302,7 @@ public class SRTMPlugin extends OsmandPlugin { if (item != null) { item.setDescription(app.getString(R.string.display_zoom_level, getPrefDescription(app, contourLinesProp, pref))); - item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); item.setSelected(selected); adapter.notifyDataSetChanged(); } @@ -322,7 +321,7 @@ public class SRTMPlugin extends OsmandPlugin { } ContextMenuItem item = adapter.getItem(position); if (item != null) { - item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); item.setSelected(selected); adapter.notifyDataSetChanged(); } @@ -346,7 +345,7 @@ public class SRTMPlugin extends OsmandPlugin { .setSelected(contourLinesSelected) .setIcon(R.drawable.ic_plugin_srtm) .setDescription(app.getString(R.string.display_zoom_level, descr)) - .setColor(contourLinesSelected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, contourLinesSelected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setItemDeleteAction(makeDeleteAction(settings.CONTOUR_LINES_ZOOM)) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(listener).createItem()); @@ -360,7 +359,7 @@ public class SRTMPlugin extends OsmandPlugin { ? R.string.shared_string_hillshade : R.string.download_slope_maps)) .setSelected(terrainEnabled) - .setColor(terrainEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, terrainEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_action_hillshade_dark) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setItemDeleteAction(makeDeleteAction(settings.TERRAIN, settings.TERRAIN_MODE)) @@ -473,7 +472,7 @@ public class SRTMPlugin extends OsmandPlugin { possibleValues[j]); } - int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode)); + int selectedModeColor = settings.getApplicationMode().getProfileColor(nightMode); DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter( possibleValuesString, nightMode, i, app, selectedModeColor, themeRes, new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java index fdeb099cfa..988f6a5782 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java @@ -16,8 +16,8 @@ import net.osmand.plus.quickaction.QuickActionType; public class TerrainAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(30, - "terrain.showhide", TerrainAction.class). - nameRes(R.string.quick_action_show_hide_terrain).iconRes(R.drawable.ic_action_hillshade_dark).nonEditable(). + "terrain.showhide", TerrainAction.class).nameActionRes(R.string.quick_action_showhide_title). + nameRes(R.string.shared_string_terrain).iconRes(R.drawable.ic_action_hillshade_dark).nonEditable(). category(QuickActionType.CONFIGURE_MAP); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java index c142ebcf5c..1475a0a7fd 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java @@ -75,7 +75,6 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL private boolean nightMode; private boolean terrainEnabled; - private int colorProfileRes; private int colorProfile; private TextView downloadDescriptionTv; @@ -144,8 +143,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL uiUtilities = app.getUIUtilities(); nightMode = app.getDaynightHelper().isNightModeForMapControls(); srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class); - colorProfileRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode); - colorProfile = ContextCompat.getColor(app, colorProfileRes); + colorProfile = settings.getApplicationMode().getProfileColor(nightMode); terrainEnabled = srtmPlugin.isTerrainLayerEnabled(); super.onCreate(savedInstanceState); } @@ -238,7 +236,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL String transparency = transparencyValue + "%"; int minZoom = Math.max(srtmPlugin.getTerrainMinZoom(), TERRAIN_MIN_ZOOM); int maxZoom = Math.min(srtmPlugin.getTerrainMaxZoom(), TERRAIN_MAX_ZOOM); - iconIv.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_hillshade_dark, colorProfileRes)); + iconIv.setImageDrawable(uiUtilities.getPaintedIcon(R.drawable.ic_action_hillshade_dark, colorProfile)); stateTv.setText(R.string.shared_string_enabled); transparencySlider.setValue(transparencyValue); transparencyValueTv.setText(transparency); diff --git a/OsmAnd/src/net/osmand/plus/track/ColorsCard.java b/OsmAnd/src/net/osmand/plus/track/ColorsCard.java index 9fee9408c4..5f83dfc6c8 100644 --- a/OsmAnd/src/net/osmand/plus/track/ColorsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/ColorsCard.java @@ -7,12 +7,6 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; -import androidx.core.graphics.ColorUtils; -import androidx.fragment.app.Fragment; - import com.google.android.material.internal.FlowLayout; import net.osmand.AndroidUtils; @@ -22,6 +16,8 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.ListStringPreference; import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.util.Algorithms; @@ -30,6 +26,11 @@ import org.apache.commons.logging.Log; import java.util.ArrayList; import java.util.List; +import androidx.annotation.ColorInt; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.ColorUtils; +import androidx.fragment.app.Fragment; + public class ColorsCard extends BaseCard implements ColorPickerListener { public static final int MAX_CUSTOM_COLORS = 6; @@ -41,6 +42,9 @@ public class ColorsCard extends BaseCard implements ColorPickerListener { private Fragment targetFragment; + private ApplicationMode appMode; + private ListStringPreference colorsListPreference; + private List colors; private List customColors; @@ -51,12 +55,14 @@ public class ColorsCard extends BaseCard implements ColorPickerListener { return R.layout.colors_card; } - public ColorsCard(MapActivity mapActivity, int selectedColor, Fragment targetFragment, List colors) { + public ColorsCard(MapActivity mapActivity, int selectedColor, Fragment targetFragment, List colors, ListStringPreference colorsListPreference, ApplicationMode appMode) { super(mapActivity); this.targetFragment = targetFragment; this.selectedColor = selectedColor; this.colors = colors; - customColors = getCustomColors(app); + this.colorsListPreference = colorsListPreference; + this.customColors = getCustomColors(colorsListPreference, appMode); + this.appMode = appMode; } public int getSelectedColor() { @@ -215,9 +221,18 @@ public class ColorsCard extends BaseCard implements ColorPickerListener { return app.getUIUtilities().getPaintedIcon(R.drawable.ic_bg_transparency, transparencyColor); } - public static List getCustomColors(@NonNull OsmandApplication app) { + public static List getCustomColors(ListStringPreference colorsListPreference) { + return getCustomColors(colorsListPreference, null); + } + + public static List getCustomColors(ListStringPreference colorsListPreference, ApplicationMode appMode) { List colors = new ArrayList<>(); - List colorNames = app.getSettings().CUSTOM_TRACK_COLORS.getStringsList(); + List colorNames; + if (appMode == null) { + colorNames = colorsListPreference.getStringsList(); + } else { + colorNames = colorsListPreference.getStringsListForProfile(appMode); + } if (colorNames != null) { for (String colorHex : colorNames) { try { @@ -233,12 +248,24 @@ public class ColorsCard extends BaseCard implements ColorPickerListener { return colors; } + public int getIndexOfSelectedColor() { + return customColors.indexOf(selectedColor); + } + + public boolean isBaseColor(int color) { + return colors.contains(color); + } + private void saveCustomColors() { List colorNames = new ArrayList<>(); for (Integer color : customColors) { String colorHex = Algorithms.colorToString(color); colorNames.add(colorHex); } - app.getSettings().CUSTOM_TRACK_COLORS.setStringsList(colorNames); + if (appMode == null) { + colorsListPreference.setStringsList(colorNames); + } else { + colorsListPreference.setStringsListForProfile(appMode, colorNames); + } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index f586700ef2..4642175b09 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -360,7 +360,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement @Override public void onColorSelected(Integer prevColor, int newColor) { if (prevColor != null) { - List customColors = ColorsCard.getCustomColors(app); + List customColors = ColorsCard.getCustomColors(app.getSettings().CUSTOM_TRACK_COLORS); int index = customColors.indexOf(prevColor); if (index != ColorsCard.INVALID_VALUE) { saveCustomColorsToTracks(prevColor, newColor); @@ -670,7 +670,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { List colors = getTrackColors(); - colorsCard = new ColorsCard(mapActivity, trackDrawInfo.getColor(), this, colors); + colorsCard = new ColorsCard(mapActivity, trackDrawInfo.getColor(), this, colors, app.getSettings().CUSTOM_TRACK_COLORS, null); colorsCard.setListener(this); cardsContainer.addView(colorsCard.build(mapActivity)); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 9cdbf2e6a7..357ea3ba8a 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -82,8 +82,8 @@ import net.osmand.plus.myplaces.TrackActivityFragmentAdapter; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; -import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.search.QuickSearchDialogFragment; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.plus.track.TrackSelectSegmentBottomSheet.OnSegmentSelectedListener; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; @@ -1160,7 +1160,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { startNavigationForGPX(gpxFile, mapActivity.getMapActions()); - RouteProvider.GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); if (paramsBuilder != null) { paramsBuilder.setSelectedSegment(selectedSegment); app.getRoutingHelper().onSettingsChanged(true); diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java b/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java index 4e91d5700e..5ccac24296 100644 --- a/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java +++ b/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java @@ -80,8 +80,7 @@ public class TransportLinesMenu { final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); final Context themedCtx = UiUtilities.getThemedContext(mapActivity, nightMode); - final int profileColorResId = appMode.getIconColorInfo().getColor(nightMode); - final int profileColor = ContextCompat.getColor(themedCtx, profileColorResId); + final int profileColor = appMode.getProfileColor(nightMode); final AlertDialog.Builder b = new AlertDialog.Builder(themedCtx); b.setTitle(themedCtx.getString(R.string.rendering_category_transport)); @@ -123,7 +122,7 @@ public class TransportLinesMenu { View v = super.getView(position, convertView, parent); final ImageView icon = (ImageView) v.findViewById(R.id.icon); if (checkedItems[position]) { - icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], profileColorResId)); + icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconIds[position], profileColor)); } else { icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position])); } @@ -138,7 +137,7 @@ public class TransportLinesMenu { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checkedItems[position] = isChecked; if (checkedItems[position]) { - icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], profileColorResId)); + icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconIds[position], profileColor)); } else { icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position])); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index 8fa3f2bf50..945796a726 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -20,6 +20,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; @@ -888,7 +889,7 @@ public class MapControlsLayer extends OsmandMapLayer { compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); ApplicationMode appMode = settings.getApplicationMode(); - layersHud.setIconColorId(appMode.getIconColorInfo().getColor(isNight)); + layersHud.setIconColor(appMode.getProfileColor(isNight)); if (layersHud.setIconResId(appMode.getIconRes())) { layersHud.update(app, isNight); } @@ -1095,8 +1096,7 @@ public class MapControlsLayer extends OsmandMapLayer { transparencyBarLayout.setVisibility(View.GONE); } boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); - int selectedModeColor = ContextCompat.getColor(app, - appMode.getIconColorInfo().getColor(nightMode)); + int selectedModeColor = appMode.getProfileColor(nightMode); UiUtilities.setupSlider(transparencySlider, nightMode, selectedModeColor); } @@ -1115,6 +1115,10 @@ public class MapControlsLayer extends OsmandMapLayer { private int resDarkId; private int resClrLight = R.color.map_button_icon_color_light; private int resClrDark = R.color.map_button_icon_color_dark; + @ColorInt + private Integer clrIntLight = null; + @ColorInt + private Integer clrIntDark = null; private String id; private boolean flipIconForRtl; @@ -1223,11 +1227,14 @@ public class MapControlsLayer extends OsmandMapLayer { } public boolean resetIconColors() { - if (resClrLight == R.color.map_button_icon_color_light && resClrDark == R.color.map_button_icon_color_dark) { + if (resClrLight == R.color.map_button_icon_color_light && resClrDark == R.color.map_button_icon_color_dark + && clrIntLight == null && clrIntDark == null) { return false; } resClrLight = R.color.map_button_icon_color_light; resClrDark = R.color.map_button_icon_color_dark; + clrIntLight = null; + clrIntDark = null; f = true; return true; } @@ -1242,6 +1249,16 @@ public class MapControlsLayer extends OsmandMapLayer { return this; } + public MapHudButton setIconColor(@ColorInt Integer clr) { + if (clrIntLight == clr && clrIntDark == clr) { + return this; + } + clrIntLight = clr; + clrIntDark = clr; + f = true; + return this; + } + public MapHudButton setIconsId(int icnLight, int icnDark) { if (resLightId == icnLight && resDarkId == icnDark) { return this; @@ -1262,6 +1279,17 @@ public class MapControlsLayer extends OsmandMapLayer { return this; } + public MapHudButton setIconColor(@ColorInt int clrLight, @ColorInt int clrDark) { + if (clrIntLight == clrLight && clrIntDark == clrDark) { + return this; + } + clrIntLight = clrLight; + clrIntDark = clrDark; + f = true; + return this; + + } + @SuppressLint("NewApi") @SuppressWarnings("deprecation") public void update(OsmandApplication ctx, boolean night) { @@ -1283,7 +1311,11 @@ public class MapControlsLayer extends OsmandMapLayer { } else if (resLightId != 0 && !nightMode) { d = ctx.getUIUtilities().getIcon(resLightId); } else if (resId != 0) { - d = ctx.getUIUtilities().getIcon(resId, nightMode ? resClrDark : resClrLight); + if (clrIntLight != null && clrIntDark != null) { + d = ctx.getUIUtilities().getPaintedIcon(resId, nightMode ? clrIntDark : clrIntLight); + } else { + d = ctx.getUIUtilities().getIcon(resId, nightMode ? resClrDark : resClrLight); + } if (flipIconForRtl) { d = AndroidUtils.getDrawableForDirection(ctx, d); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java index 16952876a8..3c60b1af49 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java @@ -1,5 +1,6 @@ package net.osmand.plus.views.layers; +import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -11,6 +12,7 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.RectF; import android.graphics.drawable.LayerDrawable; +import androidx.annotation.ColorInt; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; @@ -48,7 +50,8 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay private OsmandMapTileView view; private ApplicationMode appMode; - private int colorId; + @ColorInt + private int color; private LayerDrawable navigationIcon; private int navigationIconId; private LayerDrawable locationIcon; @@ -160,30 +163,32 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay } private void updateIcons(ApplicationMode appMode, boolean nighMode, boolean locationOutdated) { - int colorId = locationOutdated ? ProfileIconColors.getOutdatedLocationColor(nighMode) : appMode.getIconColorInfo().getColor(nighMode); + Context ctx = view.getContext(); + int color = locationOutdated ? + ContextCompat.getColor(ctx, ProfileIconColors.getOutdatedLocationColor(nighMode)) : + appMode.getProfileColor(nighMode); int locationIconId = appMode.getLocationIcon().getIconId(); int navigationIconId = appMode.getNavigationIcon().getIconId(); int headingIconId = appMode.getLocationIcon().getHeadingIconId(); if (appMode != this.appMode || this.nm != nighMode || this.locationOutdated != locationOutdated - || this.colorId != colorId + || this.color != color || this.locationIconId != locationIconId || this.headingIconId != headingIconId || this.navigationIconId != navigationIconId) { this.appMode = appMode; - this.colorId = colorId; + this.color = color; this.nm = nighMode; this.locationOutdated = locationOutdated; this.locationIconId = locationIconId; this.headingIconId = headingIconId; this.navigationIconId = navigationIconId; - int color = ContextCompat.getColor(view.getContext(), colorId); - navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), navigationIconId); + navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(ctx, navigationIconId); if (navigationIcon != null) { DrawableCompat.setTint(navigationIcon.getDrawable(1), color); } headingIcon = BitmapFactory.decodeResource(view.getResources(), headingIconId); headingPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); - locationIcon = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), locationIconId); + locationIcon = (LayerDrawable) AppCompatResources.getDrawable(ctx, locationIconId); if (locationIcon != null) { DrawableCompat.setTint(DrawableCompat.wrap(locationIcon.getDrawable(1)), color); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index f966b7d897..083d94f4ff 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -32,7 +32,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteDirectionInfo; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.views.OsmandMapLayer; @@ -360,8 +360,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } } else { RouteCalculationResult route = helper.getRoute(); - boolean directTo = route.getRouteService() == RouteProvider.RouteService.DIRECT_TO; - boolean straight = route.getRouteService() == RouteProvider.RouteService.STRAIGHT; + boolean directTo = route.getRouteService() == RouteService.DIRECT_TO; + boolean straight = route.getRouteService() == RouteService.STRAIGHT; publicTransportRouteGeometry.clearRoute(); routeGeometry.updateRoute(tb, route); if (directTo) { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index 2c9d6af19d..a64fb19f02 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -9,7 +9,6 @@ import android.widget.LinearLayout; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.StringRes; -import androidx.core.content.ContextCompat; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; @@ -468,7 +467,7 @@ public class MapWidgetRegistry { .setTitleId(R.string.configure_screen_quick_action, mapActivity) .setIcon(R.drawable.ic_quick_action) .setSelected(selected) - .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(new ContextMenuAdapter.OnRowItemClick() { @Override @@ -504,7 +503,7 @@ public class MapWidgetRegistry { } ContextMenuItem item = adapter.getItem(position); item.setSelected(visible); - item.setColorRes(visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(app, visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.notifyDataSetChanged(); } @@ -522,12 +521,11 @@ public class MapWidgetRegistry { final boolean selected = r.visibleCollapsed(mode) || r.visible(mode); final String desc = mapActivity.getString(R.string.shared_string_collapse); final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); - final int currentModeColorRes = mode.getIconColorInfo().getColor(nightMode); - final int currentModeColor = ContextCompat.getColor(app, currentModeColorRes); + final int currentModeColor = mode.getProfileColor(nightMode); ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder() .setIcon(r.getDrawableMenu()) .setSelected(selected) - .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setSecondaryIcon(r.widget != null ? R.drawable.ic_action_additional_option : ContextMenuItem.INVALID_ID) .setDescription(r.visibleCollapsed(mode) ? desc : null) .setListener(new ContextMenuAdapter.OnRowItemClick() { @@ -557,7 +555,7 @@ public class MapWidgetRegistry { final int id = menuItemIds[i]; boolean isChecked = id == checkedId; String title = app.getString(titleId); - Drawable icon = isChecked && selected ? ic.getIcon(iconId, currentModeColorRes) : ic.getThemedIcon(iconId); + Drawable icon = isChecked && selected ? ic.getPaintedIcon(iconId, currentModeColor) : ic.getThemedIcon(iconId); items.add(new PopUpMenuItem.Builder(app) .setTitle(title) .setIcon(icon) @@ -646,7 +644,7 @@ public class MapWidgetRegistry { } ContextMenuItem item = adapter.getItem(position); item.setSelected(visible); - item.setColorRes(visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + item.setColor(app, visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); item.setDescription(visible && collapsed ? desc : null); adapter.notifyDataSetChanged(); } diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java b/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java index 2fdf57b9be..e9534e55e4 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java @@ -71,7 +71,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen public void createMenuItems(Bundle savedInstanceState) { final int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; - final int profileColorResId = appMode.getIconColorInfo().getColor(nightMode); + final int profileColor = appMode.getProfileColor(nightMode); final int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding); final int contentPaddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small); @@ -86,7 +86,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen final BottomSheetItemWithCompoundButton[] btnSelectAll = new BottomSheetItemWithCompoundButton[1]; btnSelectAll[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() .setChecked(this.isGlobalWikiPoiEnabled) - .setCompoundButtonColorId(profileColorResId) + .setCompoundButtonColor(profileColor) .setTitle(getString(R.string.shared_string_all_languages)) .setTitleColorId(activeColorResId) .setCustomView(getCustomButtonView()) @@ -174,15 +174,15 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen int disableColorId = nightMode ? R.color.active_buttons_and_links_text_disabled_dark : R.color.active_buttons_and_links_text_disabled_light; - int profileColorId = appMode.getIconColorInfo().getColor(nightMode); + int profileColor = appMode.getProfileColor(nightMode); + int disableColor = ContextCompat.getColor(app, disableColorId); for (BottomSheetItemWithCompoundButton item : languageItems) { item.getView().setEnabled(enable); item.setTitleColorId(enable ? textColorPrimaryId : disableColorId); CompoundButton cb = item.getCompoundButton(); if (cb != null) { cb.setEnabled(enable); - UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app, enable ? - profileColorId : disableColorId), cb); + UiUtilities.setupCompoundButton(nightMode, enable ? profileColor : disableColor, cb); } } } @@ -254,7 +254,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor); AndroidUtils.setBackground(buttonView, bgDrawable); - int selectedModeColorId = appMode.getIconColorInfo().getColor(nightMode); + int selectedModeColorId = appMode.getProfileColor(nightMode); UiUtilities.setupCompoundButton(nightMode, selectedModeColorId, cb); return buttonView; diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java index 1b97f6df1c..f08f02966e 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java @@ -141,7 +141,7 @@ public class WikipediaPlugin extends OsmandPlugin { ContextMenuItem item = adapter.getItem(pos); if (item != null) { item.setSelected(selected); - item.setColorRes(selected ? + item.setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); item.setDescription(selected ? getLanguagesSummary() : null); adapter.notifyDataSetChanged(); @@ -160,7 +160,7 @@ public class WikipediaPlugin extends OsmandPlugin { .setTitleId(R.string.shared_string_wikipedia, mapActivity) .setDescription(selected ? getLanguagesSummary() : null) .setSelected(selected) - .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_plugin_wikipedia) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(listener).createItem()); diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPoiMenu.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPoiMenu.java index 28c2639a35..a2cb6b5b71 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPoiMenu.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPoiMenu.java @@ -74,7 +74,7 @@ public class WikipediaPoiMenu { .setTitleId(toggleActionStringId, mapActivity) .setDescription(summary) .setIcon(toggleIconId) - .setColor(toggleIconColorId) + .setColor(app, toggleIconColorId) .setListener(l) .setSelected(enabled).createItem());