Merge pull request #9330 from osmandapp/gpx_appearance
Gpx track appearance
This commit is contained in:
commit
29e8e1facc
12 changed files with 1154 additions and 577 deletions
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
package net.osmand;
|
package net.osmand;
|
||||||
|
|
||||||
|
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -42,7 +43,9 @@ import java.util.Stack;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class GPXUtilities {
|
public class GPXUtilities {
|
||||||
|
|
||||||
public final static Log log = PlatformUtil.getLog(GPXUtilities.class);
|
public final static Log log = PlatformUtil.getLog(GPXUtilities.class);
|
||||||
|
|
||||||
private static final String ICON_NAME_EXTENSION = "icon";
|
private static final String ICON_NAME_EXTENSION = "icon";
|
||||||
private static final String DEFAULT_ICON_NAME = "special_star";
|
private static final String DEFAULT_ICON_NAME = "special_star";
|
||||||
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
||||||
|
@ -115,6 +118,13 @@ public class GPXUtilities {
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getExtensionsToWrite() {
|
||||||
|
if (extensions == null) {
|
||||||
|
extensions = new LinkedHashMap<>();
|
||||||
|
}
|
||||||
|
return extensions;
|
||||||
|
}
|
||||||
|
|
||||||
public GPXExtensionsWriter getExtensionsWriter() {
|
public GPXExtensionsWriter getExtensionsWriter() {
|
||||||
return extensionsWriter;
|
return extensionsWriter;
|
||||||
}
|
}
|
||||||
|
@ -148,14 +158,7 @@ public class GPXUtilities {
|
||||||
getExtensionsToWrite().remove("color");
|
getExtensionsToWrite().remove("color");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getExtensionsToWrite() {
|
protected int parseColor(String colorString, int defColor) {
|
||||||
if (extensions == null) {
|
|
||||||
extensions = new LinkedHashMap<>();
|
|
||||||
}
|
|
||||||
return extensions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int parseColor(String colorString, int defColor) {
|
|
||||||
if (!Algorithms.isEmpty(colorString)) {
|
if (!Algorithms.isEmpty(colorString)) {
|
||||||
if (colorString.charAt(0) == '#') {
|
if (colorString.charAt(0) == '#') {
|
||||||
long color = Long.parseLong(colorString.substring(1), 16);
|
long color = Long.parseLong(colorString.substring(1), 16);
|
||||||
|
@ -1510,6 +1513,139 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
return new QuadRect(left, top, right, bottom);
|
return new QuadRect(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGradientScaleColor(GradientScaleType gradientScaleType, int defColor) {
|
||||||
|
String clrValue = null;
|
||||||
|
if (extensions != null) {
|
||||||
|
clrValue = extensions.get(gradientScaleType.getTypeName());
|
||||||
|
}
|
||||||
|
return parseColor(clrValue, defColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGradientScaleColor(GradientScaleType gradientScaleType, int gradientScaleColor) {
|
||||||
|
getExtensionsToWrite().put(gradientScaleType.getTypeName(), Algorithms.colorToString(gradientScaleColor));
|
||||||
|
}
|
||||||
|
|
||||||
|
public GradientScaleType getGradientScaleType() {
|
||||||
|
if (extensions != null) {
|
||||||
|
String gradientScaleTypeName = extensions.get("gradient_scale_type");
|
||||||
|
if (!Algorithms.isEmpty(gradientScaleTypeName)) {
|
||||||
|
try {
|
||||||
|
return GradientScaleType.valueOf(gradientScaleTypeName);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.error("Error reading gradientScaleType", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGradientScaleType(GradientScaleType gradientScaleType) {
|
||||||
|
getExtensionsToWrite().put("gradient_scale_type", gradientScaleType.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpxSplitType getSplitType() {
|
||||||
|
if (extensions != null) {
|
||||||
|
String gradientScaleTypeName = extensions.get("split_type");
|
||||||
|
if (!Algorithms.isEmpty(gradientScaleTypeName)) {
|
||||||
|
try {
|
||||||
|
return GpxSplitType.valueOf(gradientScaleTypeName);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.error("Error reading GpxSplitType", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSplitType(GpxSplitType gpxSplitType) {
|
||||||
|
getExtensionsToWrite().put("split_type", gpxSplitType.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSplitInterval() {
|
||||||
|
if (extensions != null) {
|
||||||
|
String splitIntervalStr = extensions.get("split_interval");
|
||||||
|
if (!Algorithms.isEmpty(splitIntervalStr)) {
|
||||||
|
try {
|
||||||
|
return Double.parseDouble(splitIntervalStr);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.error("Error reading split_interval", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSplitInterval(double splitInterval) {
|
||||||
|
getExtensionsToWrite().put("split_interval", String.valueOf(splitInterval));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWidth(String defWidth) {
|
||||||
|
String widthValue = null;
|
||||||
|
if (extensions != null) {
|
||||||
|
widthValue = extensions.get("width");
|
||||||
|
}
|
||||||
|
return widthValue != null ? widthValue : defWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(String width) {
|
||||||
|
getExtensionsToWrite().put("width", width);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowArrows() {
|
||||||
|
String showArrows = null;
|
||||||
|
if (extensions != null) {
|
||||||
|
showArrows = extensions.get("show_arrows");
|
||||||
|
}
|
||||||
|
return Boolean.parseBoolean(showArrows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowArrows(boolean showArrows) {
|
||||||
|
getExtensionsToWrite().put("show_arrows", String.valueOf(showArrows));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowStartFinish() {
|
||||||
|
if (extensions != null && extensions.containsKey("show_start_finish")) {
|
||||||
|
return Boolean.parseBoolean(extensions.get("show_start_finish"));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowStartFinish(boolean showStartFinish) {
|
||||||
|
getExtensionsToWrite().put("show_start_finish", String.valueOf(showStartFinish));
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum GradientScaleType {
|
||||||
|
SPEED("gradient_speed_color"),
|
||||||
|
ALTITUDE("gradient_altitude_color"),
|
||||||
|
SLOPE("gradient_slope_color");
|
||||||
|
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
GradientScaleType(String typeName) {
|
||||||
|
this.typeName = typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeName() {
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum GpxSplitType {
|
||||||
|
NO_SPLIT(-1),
|
||||||
|
DISTANCE(1),
|
||||||
|
TIME(2);
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
GpxSplitType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String asString(GPXFile file) {
|
public static String asString(GPXFile file) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.AppInitializer;
|
import net.osmand.plus.AppInitializer;
|
||||||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||||
import net.osmand.plus.AppInitializer.InitEvents;
|
import net.osmand.plus.AppInitializer.InitEvents;
|
||||||
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
|
@ -60,7 +61,6 @@ import net.osmand.plus.SQLiteTileSource;
|
||||||
import net.osmand.plus.settings.backend.SettingsHelper;
|
import net.osmand.plus.settings.backend.SettingsHelper;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
|
||||||
import net.osmand.plus.helpers.ColorDialogs;
|
import net.osmand.plus.helpers.ColorDialogs;
|
||||||
import net.osmand.plus.helpers.ExternalApiHelper;
|
import net.osmand.plus.helpers.ExternalApiHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
|
@ -1146,7 +1146,7 @@ public class OsmandAidlApi {
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) {
|
private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) {
|
||||||
final int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor(
|
final int col = GpxAppearanceAdapter.parseTrackColor(
|
||||||
app.getRendererRegistry().getCurrentSelectedRenderer(), color);
|
app.getRendererRegistry().getCurrentSelectedRenderer(), color);
|
||||||
if (!destinationExists) {
|
if (!destinationExists) {
|
||||||
GpxDataItem gpxDataItem = new GpxDataItem(destination, col);
|
GpxDataItem gpxDataItem = new GpxDataItem(destination, col);
|
||||||
|
@ -1390,7 +1390,7 @@ public class OsmandAidlApi {
|
||||||
int color = dataItem.getColor();
|
int color = dataItem.getColor();
|
||||||
String colorName = "";
|
String colorName = "";
|
||||||
if (color != 0) {
|
if (color != 0) {
|
||||||
colorName = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color);
|
colorName = GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color);
|
||||||
}
|
}
|
||||||
net.osmand.aidlapi.gpx.AGpxFileDetails details = null;
|
net.osmand.aidlapi.gpx.AGpxFileDetails details = null;
|
||||||
GPXTrackAnalysis analysis = dataItem.getAnalysis();
|
GPXTrackAnalysis analysis = dataItem.getAnalysis();
|
||||||
|
@ -1431,7 +1431,7 @@ public class OsmandAidlApi {
|
||||||
if (file.getName().equals(gpxFileName)) {
|
if (file.getName().equals(gpxFileName)) {
|
||||||
int color = dataItem.getColor();
|
int color = dataItem.getColor();
|
||||||
if (color != 0) {
|
if (color != 0) {
|
||||||
return ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color);
|
return GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package net.osmand.plus;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile.GradientScaleType;
|
||||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||||
|
@ -15,8 +17,9 @@ import java.util.List;
|
||||||
|
|
||||||
public class GPXDatabase {
|
public class GPXDatabase {
|
||||||
|
|
||||||
|
private static final int DB_VERSION = 11;
|
||||||
private static final String DB_NAME = "gpx_database";
|
private static final String DB_NAME = "gpx_database";
|
||||||
private static final int DB_VERSION = 10;
|
|
||||||
private static final String GPX_TABLE_NAME = "gpxTable";
|
private static final String GPX_TABLE_NAME = "gpxTable";
|
||||||
private static final String GPX_COL_NAME = "fileName";
|
private static final String GPX_COL_NAME = "fileName";
|
||||||
private static final String GPX_COL_DIR = "fileDir";
|
private static final String GPX_COL_DIR = "fileDir";
|
||||||
|
@ -56,9 +59,19 @@ public class GPXDatabase {
|
||||||
|
|
||||||
private static final String GPX_COL_JOIN_SEGMENTS = "joinSegments";
|
private static final String GPX_COL_JOIN_SEGMENTS = "joinSegments";
|
||||||
|
|
||||||
public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1;
|
private static final String GPX_COL_SHOW_ARROWS = "showArrows";
|
||||||
public static final int GPX_SPLIT_TYPE_DISTANCE = 1;
|
|
||||||
public static final int GPX_SPLIT_TYPE_TIME = 2;
|
private static final String GPX_COL_SHOW_START_FINISH = "showStartFinish";
|
||||||
|
|
||||||
|
private static final String GPX_COL_WIDTH = "width";
|
||||||
|
|
||||||
|
private static final String GPX_COL_GRADIENT_SPEED_COLOR = "gradientSpeedColor";
|
||||||
|
|
||||||
|
private static final String GPX_COL_GRADIENT_ALTITUDE_COLOR = "gradientAltitudeColor";
|
||||||
|
|
||||||
|
private static final String GPX_COL_GRADIENT_SLOPE_COLOR = "gradientSlopeColor";
|
||||||
|
|
||||||
|
private static final String GPX_COL_GRADIENT_SCALE_TYPE = "gradientScaleType";
|
||||||
|
|
||||||
private static final String GPX_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + GPX_TABLE_NAME + " (" +
|
private static final String GPX_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + GPX_TABLE_NAME + " (" +
|
||||||
GPX_COL_NAME + " TEXT, " +
|
GPX_COL_NAME + " TEXT, " +
|
||||||
|
@ -89,7 +102,14 @@ public class GPXDatabase {
|
||||||
GPX_COL_API_IMPORTED + " int, " + // 1 = true, 0 = false
|
GPX_COL_API_IMPORTED + " int, " + // 1 = true, 0 = false
|
||||||
GPX_COL_WPT_CATEGORY_NAMES + " TEXT, " +
|
GPX_COL_WPT_CATEGORY_NAMES + " TEXT, " +
|
||||||
GPX_COL_SHOW_AS_MARKERS + " int, " + // 1 = true, 0 = false
|
GPX_COL_SHOW_AS_MARKERS + " int, " + // 1 = true, 0 = false
|
||||||
GPX_COL_JOIN_SEGMENTS + " int);"; // 1 = true, 0 = false
|
GPX_COL_JOIN_SEGMENTS + " int, " + // 1 = true, 0 = false
|
||||||
|
GPX_COL_SHOW_ARROWS + " int, " + // 1 = true, 0 = false
|
||||||
|
GPX_COL_SHOW_START_FINISH + " int, " + // 1 = true, 0 = false
|
||||||
|
GPX_COL_WIDTH + " TEXT, " +
|
||||||
|
GPX_COL_GRADIENT_SPEED_COLOR + " TEXT, " +
|
||||||
|
GPX_COL_GRADIENT_ALTITUDE_COLOR + " TEXT, " +
|
||||||
|
GPX_COL_GRADIENT_SLOPE_COLOR + " TEXT, " +
|
||||||
|
GPX_COL_GRADIENT_SCALE_TYPE+ " TEXT);";
|
||||||
|
|
||||||
private static final String GPX_TABLE_SELECT = "SELECT " +
|
private static final String GPX_TABLE_SELECT = "SELECT " +
|
||||||
GPX_COL_NAME + ", " +
|
GPX_COL_NAME + ", " +
|
||||||
|
@ -117,7 +137,14 @@ public class GPXDatabase {
|
||||||
GPX_COL_API_IMPORTED + ", " +
|
GPX_COL_API_IMPORTED + ", " +
|
||||||
GPX_COL_WPT_CATEGORY_NAMES + ", " +
|
GPX_COL_WPT_CATEGORY_NAMES + ", " +
|
||||||
GPX_COL_SHOW_AS_MARKERS + ", " +
|
GPX_COL_SHOW_AS_MARKERS + ", " +
|
||||||
GPX_COL_JOIN_SEGMENTS +
|
GPX_COL_JOIN_SEGMENTS + ", " +
|
||||||
|
GPX_COL_SHOW_ARROWS + ", " +
|
||||||
|
GPX_COL_SHOW_START_FINISH + ", " +
|
||||||
|
GPX_COL_WIDTH + ", " +
|
||||||
|
GPX_COL_GRADIENT_SPEED_COLOR + ", " +
|
||||||
|
GPX_COL_GRADIENT_ALTITUDE_COLOR + ", " +
|
||||||
|
GPX_COL_GRADIENT_SLOPE_COLOR + ", " +
|
||||||
|
GPX_COL_GRADIENT_SCALE_TYPE +
|
||||||
" FROM " + GPX_TABLE_NAME;
|
" FROM " + GPX_TABLE_NAME;
|
||||||
|
|
||||||
private static final String GPX_TABLE_UPDATE_ANALYSIS = "UPDATE " +
|
private static final String GPX_TABLE_UPDATE_ANALYSIS = "UPDATE " +
|
||||||
|
@ -144,15 +171,23 @@ public class GPXDatabase {
|
||||||
private OsmandApplication context;
|
private OsmandApplication context;
|
||||||
|
|
||||||
public static class GpxDataItem {
|
public static class GpxDataItem {
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
private GPXTrackAnalysis analysis;
|
private GPXTrackAnalysis analysis;
|
||||||
|
private String width;
|
||||||
|
private GradientScaleType gradientScaleType;
|
||||||
private int color;
|
private int color;
|
||||||
private long fileLastModifiedTime;
|
private int gradientSpeedColor;
|
||||||
|
private int gradientAltitudeColor;
|
||||||
|
private int gradientSlopeColor;
|
||||||
private int splitType;
|
private int splitType;
|
||||||
private double splitInterval;
|
private double splitInterval;
|
||||||
|
private long fileLastModifiedTime;
|
||||||
private boolean apiImported;
|
private boolean apiImported;
|
||||||
private boolean showAsMarkers;
|
private boolean showAsMarkers;
|
||||||
private boolean joinSegments;
|
private boolean joinSegments;
|
||||||
|
private boolean showArrows;
|
||||||
|
private boolean showStartFinish;
|
||||||
|
|
||||||
public GpxDataItem(File file, GPXTrackAnalysis analysis) {
|
public GpxDataItem(File file, GPXTrackAnalysis analysis) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
@ -164,6 +199,22 @@ public class GPXDatabase {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GpxDataItem(File file, @NonNull GPXFile gpxFile) {
|
||||||
|
this.file = file;
|
||||||
|
color = gpxFile.getColor(0);
|
||||||
|
width = gpxFile.getWidth(null);
|
||||||
|
showArrows = gpxFile.isShowArrows();
|
||||||
|
showStartFinish = gpxFile.isShowStartFinish();
|
||||||
|
gradientScaleType = gpxFile.getGradientScaleType();
|
||||||
|
gradientSpeedColor = gpxFile.getGradientScaleColor(GradientScaleType.SPEED, 0);
|
||||||
|
gradientSlopeColor = gpxFile.getGradientScaleColor(GradientScaleType.SLOPE, 0);
|
||||||
|
gradientAltitudeColor = gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE, 0);
|
||||||
|
if (gpxFile.getSplitType() != null && gpxFile.getSplitInterval() != 0) {
|
||||||
|
splitType = gpxFile.getSplitType().getType();
|
||||||
|
splitInterval = gpxFile.getSplitInterval();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public File getFile() {
|
public File getFile() {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -177,6 +228,27 @@ public class GPXDatabase {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GradientScaleType getGradientScaleType() {
|
||||||
|
return gradientScaleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGradientSpeedColor() {
|
||||||
|
return gradientSpeedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGradientAltitudeColor() {
|
||||||
|
return gradientAltitudeColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGradientSlopeColor() {
|
||||||
|
return gradientSlopeColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public long getFileLastModifiedTime() {
|
public long getFileLastModifiedTime() {
|
||||||
return fileLastModifiedTime;
|
return fileLastModifiedTime;
|
||||||
}
|
}
|
||||||
|
@ -209,8 +281,12 @@ public class GPXDatabase {
|
||||||
return joinSegments;
|
return joinSegments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJoinSegments(boolean joinSegments) {
|
public boolean isShowArrows() {
|
||||||
this.joinSegments = joinSegments;
|
return showArrows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowStartFinish() {
|
||||||
|
return showStartFinish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -341,6 +417,20 @@ public class GPXDatabase {
|
||||||
" SET " + GPX_COL_JOIN_SEGMENTS + " = ? " +
|
" SET " + GPX_COL_JOIN_SEGMENTS + " = ? " +
|
||||||
"WHERE " + GPX_COL_JOIN_SEGMENTS + " IS NULL", new Object[]{0});
|
"WHERE " + GPX_COL_JOIN_SEGMENTS + " IS NULL", new Object[]{0});
|
||||||
}
|
}
|
||||||
|
if (oldVersion < 11) {
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SHOW_ARROWS + " int");
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SHOW_START_FINISH + " int");
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_WIDTH + " TEXT");
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_SPEED_COLOR + " TEXT");
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_ALTITUDE_COLOR + " TEXT");
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_SLOPE_COLOR + " TEXT");
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_GRADIENT_SCALE_TYPE + " TEXT");
|
||||||
|
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " +
|
||||||
|
"WHERE " + GPX_COL_SHOW_ARROWS + " IS NULL", new Object[]{0});
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " +
|
||||||
|
"WHERE " + GPX_COL_SHOW_START_FINISH + " IS NULL", new Object[]{1});
|
||||||
|
}
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + GPX_INDEX_NAME_DIR + " ON " + GPX_TABLE_NAME + " (" + GPX_COL_NAME + ", " + GPX_COL_DIR + ");");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + GPX_INDEX_NAME_DIR + " ON " + GPX_TABLE_NAME + " (" + GPX_COL_NAME + ", " + GPX_COL_DIR + ");");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,8 +481,7 @@ public class GPXDatabase {
|
||||||
try {
|
try {
|
||||||
String fileName = getFileName(item.file);
|
String fileName = getFileName(item.file);
|
||||||
String fileDir = getFileDir(item.file);
|
String fileDir = getFileDir(item.file);
|
||||||
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " +
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_COLOR + " = ? " +
|
||||||
GPX_COL_COLOR + " = ? " +
|
|
||||||
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
new Object[] { (color == 0 ? "" : Algorithms.colorToString(color)), fileName, fileDir });
|
new Object[] { (color == 0 ? "" : Algorithms.colorToString(color)), fileName, fileDir });
|
||||||
item.color = color;
|
item.color = color;
|
||||||
|
@ -404,6 +493,106 @@ public class GPXDatabase {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean updateGradientScaleColor(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType, int gradientScaleColor) {
|
||||||
|
SQLiteConnection db = openConnection(false);
|
||||||
|
if (db != null) {
|
||||||
|
try {
|
||||||
|
String fileName = getFileName(item.file);
|
||||||
|
String fileDir = getFileDir(item.file);
|
||||||
|
String columnName = null;
|
||||||
|
if (GradientScaleType.SPEED == gradientScaleType) {
|
||||||
|
columnName = GPX_COL_GRADIENT_SPEED_COLOR;
|
||||||
|
item.gradientSpeedColor = gradientScaleColor;
|
||||||
|
} else if (GradientScaleType.ALTITUDE == gradientScaleType) {
|
||||||
|
columnName = GPX_COL_GRADIENT_ALTITUDE_COLOR;
|
||||||
|
item.gradientAltitudeColor = gradientScaleColor;
|
||||||
|
} else if (GradientScaleType.SLOPE == gradientScaleType) {
|
||||||
|
columnName = GPX_COL_GRADIENT_SLOPE_COLOR;
|
||||||
|
item.gradientSlopeColor = gradientScaleColor;
|
||||||
|
}
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + columnName + " = ? " +
|
||||||
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
|
new Object[] {(gradientScaleColor == 0 ? "" : Algorithms.colorToString(gradientScaleColor)), fileName, fileDir});
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateGradientScaleType(@NonNull GpxDataItem item, GradientScaleType gradientScaleType) {
|
||||||
|
SQLiteConnection db = openConnection(false);
|
||||||
|
if (db != null) {
|
||||||
|
try {
|
||||||
|
String fileName = getFileName(item.file);
|
||||||
|
String fileDir = getFileDir(item.file);
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_GRADIENT_SCALE_TYPE + " = ? " +
|
||||||
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
|
new Object[] {(gradientScaleType == null ? "" : gradientScaleType.name()), fileName, fileDir});
|
||||||
|
item.gradientScaleType = gradientScaleType;
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateShowArrows(GpxDataItem item, boolean showArrows) {
|
||||||
|
SQLiteConnection db = openConnection(false);
|
||||||
|
if (db != null) {
|
||||||
|
try {
|
||||||
|
String fileName = getFileName(item.file);
|
||||||
|
String fileDir = getFileDir(item.file);
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " +
|
||||||
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
|
new Object[] {showArrows ? 1 : 0, fileName, fileDir});
|
||||||
|
item.showArrows = showArrows;
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateShowStartFinish(GpxDataItem item, boolean showStartFinish) {
|
||||||
|
SQLiteConnection db = openConnection(false);
|
||||||
|
if (db != null) {
|
||||||
|
try {
|
||||||
|
String fileName = getFileName(item.file);
|
||||||
|
String fileDir = getFileDir(item.file);
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " +
|
||||||
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
|
new Object[] {showStartFinish ? 1 : 0, fileName, fileDir});
|
||||||
|
item.showStartFinish = showStartFinish;
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateWidth(GpxDataItem item, String width) {
|
||||||
|
SQLiteConnection db = openConnection(false);
|
||||||
|
if (db != null) {
|
||||||
|
try {
|
||||||
|
String fileName = getFileName(item.file);
|
||||||
|
String fileDir = getFileDir(item.file);
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_WIDTH + " = ? " +
|
||||||
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
|
new Object[] {width, fileName, fileDir});
|
||||||
|
item.width = width;
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) {
|
public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) {
|
||||||
SQLiteConnection db = openConnection(false);
|
SQLiteConnection db = openConnection(false);
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
|
@ -433,7 +622,7 @@ public class GPXDatabase {
|
||||||
GPX_COL_JOIN_SEGMENTS + " = ? " +
|
GPX_COL_JOIN_SEGMENTS + " = ? " +
|
||||||
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
new Object[]{joinSegments ? 1 : 0, fileName, fileDir});
|
new Object[]{joinSegments ? 1 : 0, fileName, fileDir});
|
||||||
item.setJoinSegments(joinSegments);
|
item.joinSegments = joinSegments;
|
||||||
} finally {
|
} finally {
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
@ -516,14 +705,17 @@ public class GPXDatabase {
|
||||||
} else {
|
} else {
|
||||||
color = Algorithms.colorToString(item.color);
|
color = Algorithms.colorToString(item.color);
|
||||||
}
|
}
|
||||||
|
String gradientScaleType = item.gradientScaleType != null ? item.gradientScaleType.name() : null;
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
db.execSQL(
|
db.execSQL(
|
||||||
"INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
"INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
new Object[] {fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime,
|
new Object[] {fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime,
|
||||||
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
|
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
|
||||||
a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints,
|
a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints,
|
||||||
color, item.file.lastModified(), item.splitType, item.splitInterval, item.apiImported ? 1 : 0,
|
color, item.file.lastModified(), item.splitType, item.splitInterval, item.apiImported ? 1 : 0,
|
||||||
Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0});
|
Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0,
|
||||||
|
item.joinSegments ? 1 : 0, item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width,
|
||||||
|
item.gradientSpeedColor, item.gradientAltitudeColor, item.gradientSlopeColor, gradientScaleType});
|
||||||
} else {
|
} else {
|
||||||
db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" +
|
db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" +
|
||||||
GPX_COL_NAME + ", " +
|
GPX_COL_NAME + ", " +
|
||||||
|
@ -534,9 +726,19 @@ public class GPXDatabase {
|
||||||
GPX_COL_SPLIT_INTERVAL + ", " +
|
GPX_COL_SPLIT_INTERVAL + ", " +
|
||||||
GPX_COL_API_IMPORTED + ", " +
|
GPX_COL_API_IMPORTED + ", " +
|
||||||
GPX_COL_SHOW_AS_MARKERS + ", " +
|
GPX_COL_SHOW_AS_MARKERS + ", " +
|
||||||
GPX_COL_JOIN_SEGMENTS +
|
GPX_COL_JOIN_SEGMENTS + ", " +
|
||||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
GPX_COL_SHOW_ARROWS + ", " +
|
||||||
new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0});
|
GPX_COL_SHOW_START_FINISH + ", " +
|
||||||
|
GPX_COL_WIDTH + ", " +
|
||||||
|
GPX_COL_GRADIENT_SPEED_COLOR + ", " +
|
||||||
|
GPX_COL_GRADIENT_ALTITUDE_COLOR + ", " +
|
||||||
|
GPX_COL_GRADIENT_SLOPE_COLOR + ", " +
|
||||||
|
GPX_COL_GRADIENT_SCALE_TYPE +
|
||||||
|
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval,
|
||||||
|
item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0,
|
||||||
|
item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width,
|
||||||
|
item.gradientSpeedColor, item.gradientAltitudeColor, item.gradientSlopeColor, gradientScaleType});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,6 +819,13 @@ public class GPXDatabase {
|
||||||
String wptCategoryNames = query.getString(23);
|
String wptCategoryNames = query.getString(23);
|
||||||
boolean showAsMarkers = query.getInt(24) == 1;
|
boolean showAsMarkers = query.getInt(24) == 1;
|
||||||
boolean joinSegments = query.getInt(25) == 1;
|
boolean joinSegments = query.getInt(25) == 1;
|
||||||
|
boolean showArrows = query.getInt(26) == 1;
|
||||||
|
boolean showStartFinish = query.getInt(27) == 1;
|
||||||
|
String width = query.getString(28);
|
||||||
|
String gradientSpeedColor = query.getString(29);
|
||||||
|
String gradientAltitudeColor = query.getString(30);
|
||||||
|
String gradientSlopeColor = query.getString(31);
|
||||||
|
String gradientScaleType = query.getString(32);
|
||||||
|
|
||||||
GPXTrackAnalysis a = new GPXTrackAnalysis();
|
GPXTrackAnalysis a = new GPXTrackAnalysis();
|
||||||
a.totalDistance = totalDistance;
|
a.totalDistance = totalDistance;
|
||||||
|
@ -647,20 +856,37 @@ public class GPXDatabase {
|
||||||
dir = context.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
dir = context.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||||
}
|
}
|
||||||
GpxDataItem item = new GpxDataItem(new File(dir, fileName), a);
|
GpxDataItem item = new GpxDataItem(new File(dir, fileName), a);
|
||||||
try {
|
item.color = parseColor(color);
|
||||||
item.color = Algorithms.isEmpty(color) ? 0 : Algorithms.parseColor(color);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
item.color = 0;
|
|
||||||
}
|
|
||||||
item.fileLastModifiedTime = fileLastModifiedTime;
|
item.fileLastModifiedTime = fileLastModifiedTime;
|
||||||
item.splitType = splitType;
|
item.splitType = splitType;
|
||||||
item.splitInterval = splitInterval;
|
item.splitInterval = splitInterval;
|
||||||
item.apiImported = apiImported;
|
item.apiImported = apiImported;
|
||||||
item.showAsMarkers = showAsMarkers;
|
item.showAsMarkers = showAsMarkers;
|
||||||
item.joinSegments = joinSegments;
|
item.joinSegments = joinSegments;
|
||||||
|
item.showArrows = showArrows;
|
||||||
|
item.showStartFinish = showStartFinish;
|
||||||
|
item.width = width;
|
||||||
|
item.gradientSpeedColor = parseColor(gradientSpeedColor);
|
||||||
|
item.gradientAltitudeColor = parseColor(gradientAltitudeColor);
|
||||||
|
item.gradientSlopeColor = parseColor(gradientSlopeColor);
|
||||||
|
|
||||||
|
try {
|
||||||
|
item.gradientScaleType = Algorithms.isEmpty(gradientScaleType) ? null : GradientScaleType.valueOf(gradientScaleType);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
item.gradientScaleType = null;
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int parseColor(String color) {
|
||||||
|
try {
|
||||||
|
return Algorithms.isEmpty(color) ? 0 : Algorithms.parseColor(color);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<GpxDataItem> getItems() {
|
public List<GpxDataItem> getItems() {
|
||||||
List<GpxDataItem> items = new ArrayList<>();
|
List<GpxDataItem> items = new ArrayList<>();
|
||||||
|
|
|
@ -8,6 +8,8 @@ import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile.GpxSplitType;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile.GradientScaleType;
|
||||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||||
|
@ -77,14 +79,44 @@ public class GpxDbHelper {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean updateGradientScaleColor(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType, int color) {
|
||||||
|
boolean res = db.updateGradientScaleColor(item, gradientScaleType, color);
|
||||||
|
putToCache(item);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @Nullable GradientScaleType gradientScaleType) {
|
||||||
|
boolean res = db.updateGradientScaleType(item, gradientScaleType);
|
||||||
|
putToCache(item);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) {
|
public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) {
|
||||||
boolean res = db.updateShowAsMarkers(item, showAsMarkers);
|
boolean res = db.updateShowAsMarkers(item, showAsMarkers);
|
||||||
putToCache(item);
|
putToCache(item);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateSplit(@NonNull GpxDataItem item, int splitType, double splitInterval) {
|
public boolean updateShowArrows(GpxDataItem item, boolean showArrows) {
|
||||||
boolean res = db.updateSplit(item, splitType, splitInterval);
|
boolean res = db.updateShowArrows(item, showArrows);
|
||||||
|
putToCache(item);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateShowStartFinish(GpxDataItem item, boolean showStartFinish) {
|
||||||
|
boolean res = db.updateShowStartFinish(item, showStartFinish);
|
||||||
|
putToCache(item);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateWidth(GpxDataItem item, String width) {
|
||||||
|
boolean res = db.updateWidth(item, width);
|
||||||
|
putToCache(item);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateSplit(@NonNull GpxDataItem item, @NonNull GpxSplitType splitType, double splitInterval) {
|
||||||
|
boolean res = db.updateSplit(item, splitType.getType(), splitInterval);
|
||||||
putToCache(item);
|
putToCache(item);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +189,7 @@ public class GpxDbHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readGpxItem(@NonNull File gpxFile, @Nullable GpxDataItem item, @Nullable GpxDataItemCallback callback) {
|
private void readGpxItem(@NonNull File gpxFile, @Nullable GpxDataItem item, @Nullable GpxDataItemCallback callback) {
|
||||||
readingItemsMap.put(gpxFile, item != null ? item : new GpxDataItem(null, null));
|
readingItemsMap.put(gpxFile, item != null ? item : new GpxDataItem(null, (GPXTrackAnalysis) null));
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
readingItemsCallbacks.put(gpxFile, callback);
|
readingItemsCallbacks.put(gpxFile, callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile.GpxSplitType;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile.GradientScaleType;
|
||||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||||
import net.osmand.GPXUtilities.Route;
|
import net.osmand.GPXUtilities.Route;
|
||||||
import net.osmand.GPXUtilities.Track;
|
import net.osmand.GPXUtilities.Track;
|
||||||
|
@ -51,7 +53,11 @@ public class GpxSelectionHelper {
|
||||||
private static final String BACKUP = "backup";
|
private static final String BACKUP = "backup";
|
||||||
private static final String BACKUPMODIFIEDTIME = "backupTime";
|
private static final String BACKUPMODIFIEDTIME = "backupTime";
|
||||||
private static final String COLOR = "color";
|
private static final String COLOR = "color";
|
||||||
|
private static final String WIDTH = "width";
|
||||||
private static final String SELECTED_BY_USER = "selected_by_user";
|
private static final String SELECTED_BY_USER = "selected_by_user";
|
||||||
|
private static final String SHOW_ARROWS = "show_arrows";
|
||||||
|
private static final String GRADIENT_SCALE_TYPE = "gradient_scale_type";
|
||||||
|
private static final String SHOW_START_FINISH = "show_start_finish";
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -167,17 +173,17 @@ public class GpxSelectionHelper {
|
||||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
||||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
List<GpxDisplayGroup> groups = app.getSelectedGpxHelper().collectDisplayGroups(gpxFile);
|
List<GpxDisplayGroup> groups = app.getSelectedGpxHelper().collectDisplayGroups(gpxFile);
|
||||||
if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_NO_SPLIT) {
|
if (dataItem.getSplitType() == GpxSplitType.NO_SPLIT.getType()) {
|
||||||
for (GpxDisplayGroup model : groups) {
|
for (GpxDisplayGroup model : groups) {
|
||||||
model.noSplit(app);
|
model.noSplit(app);
|
||||||
}
|
}
|
||||||
selectedGpxFile.setDisplayGroups(groups, app);
|
selectedGpxFile.setDisplayGroups(groups, app);
|
||||||
} else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) {
|
} else if (dataItem.getSplitType() == GpxSplitType.DISTANCE.getType()) {
|
||||||
for (GpxDisplayGroup model : groups) {
|
for (GpxDisplayGroup model : groups) {
|
||||||
model.splitByDistance(app, dataItem.getSplitInterval(), dataItem.isJoinSegments());
|
model.splitByDistance(app, dataItem.getSplitInterval(), dataItem.isJoinSegments());
|
||||||
}
|
}
|
||||||
selectedGpxFile.setDisplayGroups(groups, app);
|
selectedGpxFile.setDisplayGroups(groups, app);
|
||||||
} else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_TIME) {
|
} else if (dataItem.getSplitType() == GpxSplitType.TIME.getType()) {
|
||||||
for (GpxDisplayGroup model : groups) {
|
for (GpxDisplayGroup model : groups) {
|
||||||
model.splitByTime(app, (int) dataItem.getSplitInterval(), dataItem.isJoinSegments());
|
model.splitByTime(app, (int) dataItem.getSplitInterval(), dataItem.isJoinSegments());
|
||||||
}
|
}
|
||||||
|
@ -515,6 +521,29 @@ public class GpxSelectionHelper {
|
||||||
int clr = Algorithms.parseColor(obj.getString(COLOR));
|
int clr = Algorithms.parseColor(obj.getString(COLOR));
|
||||||
gpx.setColor(clr);
|
gpx.setColor(clr);
|
||||||
}
|
}
|
||||||
|
for (GradientScaleType scaleType : GradientScaleType.values()) {
|
||||||
|
if (obj.has(scaleType.getTypeName())) {
|
||||||
|
int clr = Algorithms.parseColor(obj.getString(scaleType.getTypeName()));
|
||||||
|
gpx.setGradientScaleColor(scaleType, clr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (obj.has(SHOW_ARROWS)) {
|
||||||
|
boolean showArrows = obj.optBoolean(SHOW_ARROWS, false);
|
||||||
|
gpx.setShowArrows(showArrows);
|
||||||
|
}
|
||||||
|
if (obj.has(GRADIENT_SCALE_TYPE)) {
|
||||||
|
String gradientScaleTypeName = obj.optString(GRADIENT_SCALE_TYPE);
|
||||||
|
if (!Algorithms.isEmpty(gradientScaleTypeName)) {
|
||||||
|
gpx.setGradientScaleType(GradientScaleType.valueOf(gradientScaleTypeName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (obj.has(SHOW_START_FINISH)) {
|
||||||
|
boolean showStartFinish = obj.optBoolean(SHOW_START_FINISH, false);
|
||||||
|
gpx.setShowStartFinish(showStartFinish);
|
||||||
|
}
|
||||||
|
if (obj.has(WIDTH)) {
|
||||||
|
gpx.setWidth(obj.getString(WIDTH));
|
||||||
|
}
|
||||||
if (gpx.error != null) {
|
if (gpx.error != null) {
|
||||||
save = true;
|
save = true;
|
||||||
} else if (obj.has(BACKUP)) {
|
} else if (obj.has(BACKUP)) {
|
||||||
|
@ -554,6 +583,20 @@ public class GpxSelectionHelper {
|
||||||
if (s.gpxFile.getColor(0) != 0) {
|
if (s.gpxFile.getColor(0) != 0) {
|
||||||
obj.put(COLOR, Algorithms.colorToString(s.gpxFile.getColor(0)));
|
obj.put(COLOR, Algorithms.colorToString(s.gpxFile.getColor(0)));
|
||||||
}
|
}
|
||||||
|
if (s.gpxFile.getWidth(null) != null) {
|
||||||
|
obj.put(WIDTH, s.gpxFile.getWidth(null));
|
||||||
|
}
|
||||||
|
if (s.gpxFile.getGradientScaleType() != null) {
|
||||||
|
obj.put(GRADIENT_SCALE_TYPE, s.gpxFile.getGradientScaleType());
|
||||||
|
}
|
||||||
|
obj.put(SHOW_ARROWS, s.gpxFile.isShowArrows());
|
||||||
|
obj.put(SHOW_START_FINISH, s.gpxFile.isShowStartFinish());
|
||||||
|
for (GradientScaleType scaleType : GradientScaleType.values()) {
|
||||||
|
int gradientScaleColor = s.gpxFile.getGradientScaleColor(scaleType, 0);
|
||||||
|
if (gradientScaleColor != 0) {
|
||||||
|
obj.put(scaleType.getTypeName(), Algorithms.colorToString(gradientScaleColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
obj.put(SELECTED_BY_USER, s.selectedByUser);
|
obj.put(SELECTED_BY_USER, s.selectedByUser);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -606,6 +649,23 @@ public class GpxSelectionHelper {
|
||||||
if (dataItem.getColor() != 0) {
|
if (dataItem.getColor() != 0) {
|
||||||
gpx.setColor(dataItem.getColor());
|
gpx.setColor(dataItem.getColor());
|
||||||
}
|
}
|
||||||
|
if (dataItem.getGradientSpeedColor() != 0) {
|
||||||
|
gpx.setGradientScaleColor(GradientScaleType.SPEED, dataItem.getGradientSpeedColor());
|
||||||
|
}
|
||||||
|
if (dataItem.getGradientAltitudeColor() != 0) {
|
||||||
|
gpx.setGradientScaleColor(GradientScaleType.ALTITUDE, dataItem.getGradientAltitudeColor());
|
||||||
|
}
|
||||||
|
if (dataItem.getGradientSlopeColor() != 0) {
|
||||||
|
gpx.setGradientScaleColor(GradientScaleType.SLOPE, dataItem.getGradientSlopeColor());
|
||||||
|
}
|
||||||
|
if (dataItem.getGradientScaleType() != null) {
|
||||||
|
gpx.setGradientScaleType(dataItem.getGradientScaleType());
|
||||||
|
}
|
||||||
|
if (dataItem.getWidth() != null) {
|
||||||
|
gpx.setWidth(dataItem.getWidth());
|
||||||
|
}
|
||||||
|
gpx.setShowArrows(dataItem.isShowArrows());
|
||||||
|
gpx.setShowStartFinish(dataItem.isShowStartFinish());
|
||||||
sf.setJoinSegments(dataItem.isJoinSegments());
|
sf.setJoinSegments(dataItem.isJoinSegments());
|
||||||
}
|
}
|
||||||
sf.setGpxFile(gpx, app);
|
sf.setGpxFile(gpx, app);
|
||||||
|
|
|
@ -2,9 +2,7 @@ package net.osmand.plus.dialogs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
@ -25,8 +23,6 @@ import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
|
||||||
import net.osmand.GPXUtilities;
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.core.android.MapRendererContext;
|
import net.osmand.core.android.MapRendererContext;
|
||||||
|
@ -35,20 +31,14 @@ import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
||||||
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
|
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
import net.osmand.plus.DialogListItemAdapter;
|
import net.osmand.plus.DialogListItemAdapter;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.MapActivityLayers;
|
|
||||||
import net.osmand.plus.activities.PluginActivity;
|
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
|
||||||
import net.osmand.plus.render.RendererRegistry;
|
import net.osmand.plus.render.RendererRegistry;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||||
|
@ -57,8 +47,6 @@ import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
import net.osmand.plus.transport.TransportLinesMenu;
|
import net.osmand.plus.transport.TransportLinesMenu;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||||
import net.osmand.plus.wikipedia.WikipediaPoiMenu;
|
|
||||||
import net.osmand.render.RenderingRule;
|
|
||||||
import net.osmand.render.RenderingRuleProperty;
|
import net.osmand.render.RenderingRuleProperty;
|
||||||
import net.osmand.render.RenderingRuleStorageProperties;
|
import net.osmand.render.RenderingRuleStorageProperties;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
@ -67,7 +55,6 @@ import net.osmand.util.SunriseSunset;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -101,7 +88,6 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.ROUTES_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.SHOW_CATEGORY_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.SHOW_CATEGORY_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TEXT_SIZE_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TEXT_SIZE_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TRANSPORT_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TRANSPORT_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.WIKIPEDIA_ID;
|
|
||||||
import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction;
|
import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction;
|
||||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_DENSITY_ATTR;
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_DENSITY_ATTR;
|
||||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR;
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR;
|
||||||
|
@ -181,188 +167,12 @@ public class ConfigureMapMenu {
|
||||||
return customRules;
|
return customRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class LayerMenuListener extends OnRowItemClick {
|
|
||||||
private MapActivity ma;
|
|
||||||
private ContextMenuAdapter cm;
|
|
||||||
|
|
||||||
private LayerMenuListener(MapActivity ma, ContextMenuAdapter cm) {
|
|
||||||
this.ma = ma;
|
|
||||||
this.cm = cm;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> getAlreadySelectedGpx() {
|
|
||||||
GpxSelectionHelper selectedGpxHelper = ma.getMyApplication().getSelectedGpxHelper();
|
|
||||||
List<GpxSelectionHelper.SelectedGpxFile> selectedGpxFiles = selectedGpxHelper.getSelectedGPXFiles();
|
|
||||||
|
|
||||||
List<String> files = new ArrayList<>();
|
|
||||||
for (GpxSelectionHelper.SelectedGpxFile file : selectedGpxFiles) {
|
|
||||||
files.add(file.getGpxFile().path);
|
|
||||||
}
|
|
||||||
if (selectedGpxFiles.isEmpty()) {
|
|
||||||
Map<GPXUtilities.GPXFile, Long> fls = selectedGpxHelper.getSelectedGpxFilesBackUp();
|
|
||||||
for(Map.Entry<GPXUtilities.GPXFile, Long> f : fls.entrySet()) {
|
|
||||||
if(!Algorithms.isEmpty(f.getKey().path)) {
|
|
||||||
File file = new File(f.getKey().path);
|
|
||||||
if(file.exists() && !file.isDirectory()) {
|
|
||||||
files.add(f.getKey().path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onRowItemClick(final ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int pos) {
|
|
||||||
if (itemId == R.string.layer_poi) {
|
|
||||||
showPoiFilterDialog(adapter, adapter.getItem(pos));
|
|
||||||
return false;
|
|
||||||
} else if (itemId == R.string.layer_gpx_layer && cm.getItem(pos).getSelected()) {
|
|
||||||
showGpxSelectionDialog(adapter, adapter.getItem(pos));
|
|
||||||
return false;
|
|
||||||
} else if (itemId == R.string.rendering_category_transport) {
|
|
||||||
final ContextMenuItem item = adapter.getItem(pos);
|
|
||||||
TransportLinesMenu.showTransportsDialog(ma, new CallbackWithObject<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public boolean processResult(Boolean result) {
|
|
||||||
if (item != null) {
|
|
||||||
item.setSelected(result);
|
|
||||||
item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
boolean selected = TransportLinesMenu.isShowLines(ma.getMyApplication());
|
|
||||||
if (!selected && item != null) {
|
|
||||||
item.setSelected(true);
|
|
||||||
item.setColorRes(R.color.osmand_orange);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
|
|
||||||
if (btn != null && btn.getVisibility() == View.VISIBLE) {
|
|
||||||
btn.setChecked(!btn.isChecked());
|
|
||||||
cm.getItem(pos).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return onContextMenuClick(adapter, itemId, pos, false, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
|
||||||
final int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
final OsmandSettings settings = ma.getMyApplication().getSettings();
|
|
||||||
final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters();
|
|
||||||
final ContextMenuItem item = cm.getItem(pos);
|
|
||||||
if (item.getSelected() != null) {
|
|
||||||
item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
|
||||||
}
|
|
||||||
if (itemId == R.string.layer_poi) {
|
|
||||||
PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
|
|
||||||
poiFiltersHelper.clearSelectedPoiFilters(wiki);
|
|
||||||
if (isChecked) {
|
|
||||||
showPoiFilterDialog(adapter, adapter.getItem(pos));
|
|
||||||
} else {
|
|
||||||
adapter.getItem(pos).setDescription(
|
|
||||||
poiFiltersHelper.getSelectedPoiFiltersName(wiki));
|
|
||||||
}
|
|
||||||
} else if (itemId == R.string.layer_amenity_label) {
|
|
||||||
settings.SHOW_POI_LABEL.set(isChecked);
|
|
||||||
} else if (itemId == R.string.shared_string_favorites) {
|
|
||||||
settings.SHOW_FAVORITES.set(isChecked);
|
|
||||||
} else if (itemId == R.string.layer_gpx_layer) {
|
|
||||||
final GpxSelectionHelper selectedGpxHelper = ma.getMyApplication().getSelectedGpxHelper();
|
|
||||||
if (selectedGpxHelper.isShowingAnyGpxFiles()) {
|
|
||||||
selectedGpxHelper.clearAllGpxFilesToShow(true);
|
|
||||||
adapter.getItem(pos).setDescription(selectedGpxHelper.getGpxDescription());
|
|
||||||
} else {
|
|
||||||
showGpxSelectionDialog(adapter, adapter.getItem(pos));
|
|
||||||
}
|
|
||||||
} else if (itemId == R.string.rendering_category_transport) {
|
|
||||||
boolean selected = TransportLinesMenu.isShowLines(ma.getMyApplication());
|
|
||||||
TransportLinesMenu.toggleTransportLines(ma, !selected, new CallbackWithObject<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public boolean processResult(Boolean result) {
|
|
||||||
item.setSelected(result);
|
|
||||||
item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (itemId == R.string.map_markers) {
|
|
||||||
settings.SHOW_MAP_MARKERS.set(isChecked);
|
|
||||||
} else if (itemId == R.string.layer_map) {
|
|
||||||
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
|
||||||
Intent intent = new Intent(ma, PluginActivity.class);
|
|
||||||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, OsmandRasterMapsPlugin.ID);
|
|
||||||
ma.startActivity(intent);
|
|
||||||
} else {
|
|
||||||
ContextMenuItem it = adapter.getItem(pos);
|
|
||||||
ma.getMapLayers().selectMapLayer(ma.getMapView(), it, adapter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
ma.getMapLayers().updateLayers(ma.getMapView());
|
|
||||||
ma.getMapView().refreshMap();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showGpxSelectionDialog(final ArrayAdapter<ContextMenuItem> adapter,
|
|
||||||
final ContextMenuItem item) {
|
|
||||||
AlertDialog dialog = ma.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(),
|
|
||||||
ma.getMapView());
|
|
||||||
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
||||||
@Override
|
|
||||||
public void onDismiss(DialogInterface dialog) {
|
|
||||||
OsmandApplication app = ma.getMyApplication();
|
|
||||||
boolean selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles();
|
|
||||||
item.setSelected(selected);
|
|
||||||
item.setDescription(app.getSelectedGpxHelper().getGpxDescription());
|
|
||||||
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void showPoiFilterDialog(final ArrayAdapter<ContextMenuItem> adapter,
|
|
||||||
final ContextMenuItem item) {
|
|
||||||
final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters();
|
|
||||||
final PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
|
|
||||||
MapActivityLayers.DismissListener dismissListener =
|
|
||||||
new MapActivityLayers.DismissListener() {
|
|
||||||
@Override
|
|
||||||
public void dismiss() {
|
|
||||||
PoiFiltersHelper pf = ma.getMyApplication().getPoiFilters();
|
|
||||||
boolean selected = pf.isShowingAnyPoi(wiki);
|
|
||||||
item.setSelected(selected);
|
|
||||||
item.setDescription(pf.getSelectedPoiFiltersName(wiki));
|
|
||||||
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (poiFiltersHelper.isShowingAnyPoi(wiki)) {
|
|
||||||
ma.getMapLayers().showMultichoicePoiFilterDialog(ma.getMapView(),
|
|
||||||
dismissListener);
|
|
||||||
} else {
|
|
||||||
ma.getMapLayers().showSingleChoicePoiFilterDialog(ma.getMapView(),
|
|
||||||
dismissListener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createLayersItems(List<RenderingRuleProperty> customRules, ContextMenuAdapter adapter,
|
private void createLayersItems(List<RenderingRuleProperty> customRules, ContextMenuAdapter adapter,
|
||||||
final MapActivity activity, final int themeRes, final boolean nightMode) {
|
final MapActivity activity, final int themeRes, final boolean nightMode) {
|
||||||
final OsmandApplication app = activity.getMyApplication();
|
final OsmandApplication app = activity.getMyApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
final int selectedProfileColorRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode);
|
final int selectedProfileColorRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode);
|
||||||
final int selectedProfileColor = ContextCompat.getColor(app, selectedProfileColorRes);
|
MapLayerMenuListener l = new MapLayerMenuListener(activity, adapter);
|
||||||
LayerMenuListener l = new LayerMenuListener(activity, adapter);
|
|
||||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||||
.setId(SHOW_CATEGORY_ID)
|
.setId(SHOW_CATEGORY_ID)
|
||||||
.setTitleId(R.string.shared_string_show, activity)
|
.setTitleId(R.string.shared_string_show, activity)
|
||||||
|
@ -1299,230 +1109,35 @@ public class ConfigureMapMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StringSpinnerArrayAdapter extends ArrayAdapter<String> {
|
private static class StringSpinnerArrayAdapter extends ArrayAdapter<String> {
|
||||||
|
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
|
||||||
public StringSpinnerArrayAdapter(Context context, boolean nightMode) {
|
public StringSpinnerArrayAdapter(Context context, boolean nightMode) {
|
||||||
super(context, android.R.layout.simple_spinner_item);
|
super(context, android.R.layout.simple_spinner_item);
|
||||||
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
OsmandApplication app = (OsmandApplication )getContext().getApplicationContext();
|
|
||||||
this.nightMode = nightMode;
|
this.nightMode = nightMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
TextView label = (TextView) super.getView(position, convertView, parent);
|
|
||||||
|
|
||||||
String text = getItem(position);
|
|
||||||
label.setText(text);
|
|
||||||
label.setTextColor(nightMode ?
|
|
||||||
ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_dark) : ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_light));
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
|
||||||
TextView label = (TextView) super.getDropDownView(position, convertView, parent);
|
|
||||||
|
|
||||||
String text = getItem(position);
|
|
||||||
label.setText(text);
|
|
||||||
label.setTextColor(nightMode ?
|
|
||||||
ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_dark) : ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_light));
|
|
||||||
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class GpxAppearanceAdapter extends ArrayAdapter<AppearanceListItem> {
|
|
||||||
|
|
||||||
private OsmandApplication app;
|
|
||||||
private int currentColor;
|
|
||||||
private GpxAppearanceAdapterType adapterType = GpxAppearanceAdapterType.TRACK_WIDTH_COLOR;
|
|
||||||
|
|
||||||
public enum GpxAppearanceAdapterType {
|
|
||||||
TRACK_WIDTH,
|
|
||||||
TRACK_COLOR,
|
|
||||||
TRACK_WIDTH_COLOR
|
|
||||||
}
|
|
||||||
|
|
||||||
public GpxAppearanceAdapter(Context context, String currentColorValue, GpxAppearanceAdapterType adapterType) {
|
|
||||||
super(context, R.layout.rendering_prop_menu_item);
|
|
||||||
this.app = (OsmandApplication) getContext().getApplicationContext();
|
|
||||||
this.adapterType = adapterType;
|
|
||||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
|
||||||
this.currentColor = parseTrackColor(renderer, currentColorValue);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GpxAppearanceAdapter(Context context, int currentColor, GpxAppearanceAdapterType adapterType) {
|
|
||||||
super(context, R.layout.rendering_prop_menu_item);
|
|
||||||
this.app = (OsmandApplication) getContext().getApplicationContext();
|
|
||||||
this.adapterType = adapterType;
|
|
||||||
this.currentColor = currentColor;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
RenderingRuleProperty trackWidthProp = null;
|
|
||||||
RenderingRuleProperty trackColorProp = null;
|
|
||||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
|
||||||
if (renderer != null) {
|
|
||||||
if (adapterType == GpxAppearanceAdapterType.TRACK_WIDTH || adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) {
|
|
||||||
trackWidthProp = renderer.PROPS.getCustomRule(CURRENT_TRACK_WIDTH_ATTR);
|
|
||||||
}
|
|
||||||
if (adapterType == GpxAppearanceAdapterType.TRACK_COLOR || adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) {
|
|
||||||
trackColorProp = renderer.PROPS.getCustomRule(CURRENT_TRACK_COLOR_ATTR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackWidthProp != null) {
|
|
||||||
AppearanceListItem item = new AppearanceListItem(CURRENT_TRACK_WIDTH_ATTR, "",
|
|
||||||
SettingsActivity.getStringPropertyValue(getContext(), trackWidthProp.getDefaultValueDescription()));
|
|
||||||
add(item);
|
|
||||||
for (int j = 0; j < trackWidthProp.getPossibleValues().length; j++) {
|
|
||||||
item = new AppearanceListItem(CURRENT_TRACK_WIDTH_ATTR,
|
|
||||||
trackWidthProp.getPossibleValues()[j],
|
|
||||||
SettingsActivity.getStringPropertyValue(getContext(), trackWidthProp.getPossibleValues()[j]));
|
|
||||||
add(item);
|
|
||||||
}
|
|
||||||
item.setLastItem(true);
|
|
||||||
}
|
|
||||||
if (trackColorProp != null) {
|
|
||||||
AppearanceListItem item = new AppearanceListItem(CURRENT_TRACK_COLOR_ATTR, "",
|
|
||||||
SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getDefaultValueDescription()),
|
|
||||||
parseTrackColor(renderer, ""));
|
|
||||||
add(item);
|
|
||||||
for (int j = 0; j < trackColorProp.getPossibleValues().length; j++) {
|
|
||||||
item = new AppearanceListItem(CURRENT_TRACK_COLOR_ATTR,
|
|
||||||
trackColorProp.getPossibleValues()[j],
|
|
||||||
SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getPossibleValues()[j]),
|
|
||||||
parseTrackColor(renderer, trackColorProp.getPossibleValues()[j]));
|
|
||||||
add(item);
|
|
||||||
}
|
|
||||||
item.setLastItem(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int parseTrackColor(RenderingRulesStorage renderer, String colorName) {
|
|
||||||
int defaultColor = -1;
|
|
||||||
RenderingRule gpxRule = null;
|
|
||||||
if (renderer != null) {
|
|
||||||
gpxRule = renderer.getRenderingAttributeRule("gpx");
|
|
||||||
}
|
|
||||||
if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) {
|
|
||||||
List<RenderingRule> rules = gpxRule.getIfElseChildren().get(0).getIfElseChildren();
|
|
||||||
for (RenderingRule r : rules) {
|
|
||||||
String cName = r.getStringPropertyValue(CURRENT_TRACK_COLOR_ATTR);
|
|
||||||
if (!Algorithms.isEmpty(cName) && cName.equals(colorName)) {
|
|
||||||
return r.getIntPropertyValue(COLOR_ATTR);
|
|
||||||
}
|
|
||||||
if (cName == null && defaultColor == -1) {
|
|
||||||
defaultColor = r.getIntPropertyValue(COLOR_ATTR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return defaultColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String parseTrackColorName(RenderingRulesStorage renderer, int color) {
|
|
||||||
RenderingRule gpxRule = null;
|
|
||||||
if (renderer != null) {
|
|
||||||
gpxRule = renderer.getRenderingAttributeRule("gpx");
|
|
||||||
}
|
|
||||||
if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) {
|
|
||||||
List<RenderingRule> rules = gpxRule.getIfElseChildren().get(0).getIfElseChildren();
|
|
||||||
for (RenderingRule r : rules) {
|
|
||||||
String cName = r.getStringPropertyValue(CURRENT_TRACK_COLOR_ATTR);
|
|
||||||
if (!Algorithms.isEmpty(cName) && color == r.getIntPropertyValue(COLOR_ATTR)) {
|
|
||||||
return cName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Algorithms.colorToString(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||||
AppearanceListItem item = getItem(position);
|
TextView label = (TextView) super.getView(position, convertView, parent);
|
||||||
View v = convertView;
|
setupLabel(label, getItem(position));
|
||||||
if (v == null) {
|
return label;
|
||||||
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
|
|
||||||
}
|
|
||||||
if (item != null) {
|
|
||||||
TextView textView = (TextView) v.findViewById(R.id.text1);
|
|
||||||
textView.setText(item.localizedValue);
|
|
||||||
if (item.attrName == CURRENT_TRACK_WIDTH_ATTR) {
|
|
||||||
int iconId;
|
|
||||||
if (item.value.equals("bold")) {
|
|
||||||
iconId = R.drawable.ic_action_gpx_width_bold;
|
|
||||||
} else if (item.value.equals("medium")) {
|
|
||||||
iconId = R.drawable.ic_action_gpx_width_medium;
|
|
||||||
} else {
|
|
||||||
iconId = R.drawable.ic_action_gpx_width_thin;
|
|
||||||
}
|
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
|
||||||
app.getUIUtilities().getPaintedIcon(iconId, currentColor), null);
|
|
||||||
} else {
|
|
||||||
if (item.color == -1) {
|
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
|
||||||
app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
|
|
||||||
} else {
|
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
|
||||||
app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, item.color), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));
|
|
||||||
v.findViewById(R.id.divider).setVisibility(item.lastItem
|
|
||||||
&& position < getCount() - 1 ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AppearanceListItem {
|
@Override
|
||||||
private String attrName;
|
public View getDropDownView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||||
private String value;
|
TextView label = (TextView) super.getDropDownView(position, convertView, parent);
|
||||||
private String localizedValue;
|
setupLabel(label, getItem(position));
|
||||||
private int color;
|
return label;
|
||||||
private boolean lastItem;
|
|
||||||
|
|
||||||
public AppearanceListItem(String attrName, String value, String localizedValue) {
|
|
||||||
this.attrName = attrName;
|
|
||||||
this.value = value;
|
|
||||||
this.localizedValue = localizedValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppearanceListItem(String attrName, String value, String localizedValue, int color) {
|
private void setupLabel(TextView label, String text) {
|
||||||
this.attrName = attrName;
|
int colorId = nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light;
|
||||||
this.value = value;
|
label.setText(text);
|
||||||
this.localizedValue = localizedValue;
|
label.setTextColor(ContextCompat.getColorStateList(getContext(), colorId));
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAttrName() {
|
|
||||||
return attrName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLocalizedValue() {
|
|
||||||
return localizedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLastItem() {
|
|
||||||
return lastItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastItem(boolean lastItem) {
|
|
||||||
this.lastItem = lastItem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
214
OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java
Normal file
214
OsmAnd/src/net/osmand/plus/dialogs/GpxAppearanceAdapter.java
Normal file
|
@ -0,0 +1,214 @@
|
||||||
|
package net.osmand.plus.dialogs;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
|
import net.osmand.render.RenderingRule;
|
||||||
|
import net.osmand.render.RenderingRuleProperty;
|
||||||
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.AppearanceListItem> {
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private GpxAppearanceAdapterType adapterType;
|
||||||
|
private int currentColor;
|
||||||
|
|
||||||
|
public enum GpxAppearanceAdapterType {
|
||||||
|
TRACK_WIDTH,
|
||||||
|
TRACK_COLOR,
|
||||||
|
TRACK_WIDTH_COLOR
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpxAppearanceAdapter(Context context, String currentColorValue, GpxAppearanceAdapterType adapterType) {
|
||||||
|
super(context, R.layout.rendering_prop_menu_item);
|
||||||
|
this.app = (OsmandApplication) context.getApplicationContext();
|
||||||
|
this.adapterType = adapterType;
|
||||||
|
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
|
this.currentColor = parseTrackColor(renderer, currentColorValue);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpxAppearanceAdapter(Context context, int currentColor, GpxAppearanceAdapterType adapterType) {
|
||||||
|
super(context, R.layout.rendering_prop_menu_item);
|
||||||
|
this.app = (OsmandApplication) context.getApplicationContext();
|
||||||
|
this.adapterType = adapterType;
|
||||||
|
this.currentColor = currentColor;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||||
|
AppearanceListItem item = getItem(position);
|
||||||
|
View v = convertView;
|
||||||
|
if (v == null) {
|
||||||
|
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
|
||||||
|
}
|
||||||
|
if (item != null) {
|
||||||
|
TextView textView = (TextView) v.findViewById(R.id.text1);
|
||||||
|
textView.setText(item.localizedValue);
|
||||||
|
if (ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR.equals(item.attrName)) {
|
||||||
|
int iconId;
|
||||||
|
if ("bold".equals(item.value)) {
|
||||||
|
iconId = R.drawable.ic_action_gpx_width_bold;
|
||||||
|
} else if ("medium".equals(item.value)) {
|
||||||
|
iconId = R.drawable.ic_action_gpx_width_medium;
|
||||||
|
} else {
|
||||||
|
iconId = R.drawable.ic_action_gpx_width_thin;
|
||||||
|
}
|
||||||
|
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||||
|
app.getUIUtilities().getPaintedIcon(iconId, currentColor), null);
|
||||||
|
} else {
|
||||||
|
if (item.color == -1) {
|
||||||
|
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||||
|
app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
|
||||||
|
} else {
|
||||||
|
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||||
|
app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, item.color), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));
|
||||||
|
v.findViewById(R.id.divider).setVisibility(item.lastItem
|
||||||
|
&& position < getCount() - 1 ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
RenderingRuleProperty trackWidthProp = null;
|
||||||
|
RenderingRuleProperty trackColorProp = null;
|
||||||
|
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
|
if (renderer != null) {
|
||||||
|
if (adapterType == GpxAppearanceAdapterType.TRACK_WIDTH || adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) {
|
||||||
|
trackWidthProp = renderer.PROPS.getCustomRule(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR);
|
||||||
|
}
|
||||||
|
if (adapterType == GpxAppearanceAdapterType.TRACK_COLOR || adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) {
|
||||||
|
trackColorProp = renderer.PROPS.getCustomRule(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trackWidthProp != null) {
|
||||||
|
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR, "",
|
||||||
|
SettingsActivity.getStringPropertyValue(getContext(), trackWidthProp.getDefaultValueDescription()));
|
||||||
|
add(item);
|
||||||
|
for (int j = 0; j < trackWidthProp.getPossibleValues().length; j++) {
|
||||||
|
item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR,
|
||||||
|
trackWidthProp.getPossibleValues()[j],
|
||||||
|
SettingsActivity.getStringPropertyValue(getContext(), trackWidthProp.getPossibleValues()[j]));
|
||||||
|
add(item);
|
||||||
|
}
|
||||||
|
item.setLastItem(true);
|
||||||
|
}
|
||||||
|
if (trackColorProp != null) {
|
||||||
|
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR, "",
|
||||||
|
SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getDefaultValueDescription()),
|
||||||
|
parseTrackColor(renderer, ""));
|
||||||
|
add(item);
|
||||||
|
for (int j = 0; j < trackColorProp.getPossibleValues().length; j++) {
|
||||||
|
item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR,
|
||||||
|
trackColorProp.getPossibleValues()[j],
|
||||||
|
SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getPossibleValues()[j]),
|
||||||
|
parseTrackColor(renderer, trackColorProp.getPossibleValues()[j]));
|
||||||
|
add(item);
|
||||||
|
}
|
||||||
|
item.setLastItem(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int parseTrackColor(RenderingRulesStorage renderer, String colorName) {
|
||||||
|
int defaultColor = -1;
|
||||||
|
RenderingRule gpxRule = null;
|
||||||
|
if (renderer != null) {
|
||||||
|
gpxRule = renderer.getRenderingAttributeRule("gpx");
|
||||||
|
}
|
||||||
|
if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) {
|
||||||
|
List<RenderingRule> rules = gpxRule.getIfElseChildren().get(0).getIfElseChildren();
|
||||||
|
for (RenderingRule r : rules) {
|
||||||
|
String cName = r.getStringPropertyValue(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR);
|
||||||
|
if (!Algorithms.isEmpty(cName) && cName.equals(colorName)) {
|
||||||
|
return r.getIntPropertyValue(ConfigureMapMenu.COLOR_ATTR);
|
||||||
|
}
|
||||||
|
if (cName == null && defaultColor == -1) {
|
||||||
|
defaultColor = r.getIntPropertyValue(ConfigureMapMenu.COLOR_ATTR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String parseTrackColorName(RenderingRulesStorage renderer, int color) {
|
||||||
|
RenderingRule gpxRule = null;
|
||||||
|
if (renderer != null) {
|
||||||
|
gpxRule = renderer.getRenderingAttributeRule("gpx");
|
||||||
|
}
|
||||||
|
if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) {
|
||||||
|
List<RenderingRule> rules = gpxRule.getIfElseChildren().get(0).getIfElseChildren();
|
||||||
|
for (RenderingRule r : rules) {
|
||||||
|
String cName = r.getStringPropertyValue(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR);
|
||||||
|
if (!Algorithms.isEmpty(cName) && color == r.getIntPropertyValue(ConfigureMapMenu.COLOR_ATTR)) {
|
||||||
|
return cName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Algorithms.colorToString(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AppearanceListItem {
|
||||||
|
|
||||||
|
private String attrName;
|
||||||
|
private String value;
|
||||||
|
private String localizedValue;
|
||||||
|
private int color;
|
||||||
|
private boolean lastItem;
|
||||||
|
|
||||||
|
public AppearanceListItem(String attrName, String value, String localizedValue) {
|
||||||
|
this.attrName = attrName;
|
||||||
|
this.value = value;
|
||||||
|
this.localizedValue = localizedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppearanceListItem(String attrName, String value, String localizedValue, int color) {
|
||||||
|
this.attrName = attrName;
|
||||||
|
this.value = value;
|
||||||
|
this.localizedValue = localizedValue;
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAttrName() {
|
||||||
|
return attrName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedValue() {
|
||||||
|
return localizedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLastItem() {
|
||||||
|
return lastItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastItem(boolean lastItem) {
|
||||||
|
this.lastItem = lastItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
210
OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java
Normal file
210
OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java
Normal file
|
@ -0,0 +1,210 @@
|
||||||
|
package net.osmand.plus.dialogs;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
|
import net.osmand.CallbackWithObject;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
|
||||||
|
import net.osmand.plus.ContextMenuItem;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.MapActivityLayers;
|
||||||
|
import net.osmand.plus.activities.PluginActivity;
|
||||||
|
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||||
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
import net.osmand.plus.transport.TransportLinesMenu;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
final class MapLayerMenuListener extends OnRowItemClick {
|
||||||
|
|
||||||
|
private MapActivity mapActivity;
|
||||||
|
private ContextMenuAdapter menuAdapter;
|
||||||
|
|
||||||
|
MapLayerMenuListener(MapActivity mapActivity, ContextMenuAdapter menuAdapter) {
|
||||||
|
this.mapActivity = mapActivity;
|
||||||
|
this.menuAdapter = menuAdapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getAlreadySelectedGpx() {
|
||||||
|
GpxSelectionHelper selectedGpxHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
|
||||||
|
List<SelectedGpxFile> selectedGpxFiles = selectedGpxHelper.getSelectedGPXFiles();
|
||||||
|
|
||||||
|
List<String> files = new ArrayList<>();
|
||||||
|
for (SelectedGpxFile file : selectedGpxFiles) {
|
||||||
|
files.add(file.getGpxFile().path);
|
||||||
|
}
|
||||||
|
if (selectedGpxFiles.isEmpty()) {
|
||||||
|
Map<GPXFile, Long> fls = selectedGpxHelper.getSelectedGpxFilesBackUp();
|
||||||
|
for (Map.Entry<GPXFile, Long> f : fls.entrySet()) {
|
||||||
|
if (!Algorithms.isEmpty(f.getKey().path)) {
|
||||||
|
File file = new File(f.getKey().path);
|
||||||
|
if (file.exists() && !file.isDirectory()) {
|
||||||
|
files.add(f.getKey().path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onRowItemClick(final ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int pos) {
|
||||||
|
if (itemId == R.string.layer_poi) {
|
||||||
|
showPoiFilterDialog(adapter, adapter.getItem(pos));
|
||||||
|
return false;
|
||||||
|
} else if (itemId == R.string.layer_gpx_layer && menuAdapter.getItem(pos).getSelected()) {
|
||||||
|
showGpxSelectionDialog(adapter, adapter.getItem(pos));
|
||||||
|
return false;
|
||||||
|
} else if (itemId == R.string.rendering_category_transport) {
|
||||||
|
final ContextMenuItem item = adapter.getItem(pos);
|
||||||
|
TransportLinesMenu.showTransportsDialog(mapActivity, new CallbackWithObject<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public boolean processResult(Boolean result) {
|
||||||
|
if (item != null) {
|
||||||
|
item.setSelected(result);
|
||||||
|
item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication());
|
||||||
|
if (!selected && item != null) {
|
||||||
|
item.setSelected(true);
|
||||||
|
item.setColorRes(R.color.osmand_orange);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
|
||||||
|
if (btn != null && btn.getVisibility() == View.VISIBLE) {
|
||||||
|
btn.setChecked(!btn.isChecked());
|
||||||
|
menuAdapter.getItem(pos).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return onContextMenuClick(adapter, itemId, pos, false, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||||
|
final int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
|
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||||
|
final PoiFiltersHelper poiFiltersHelper = mapActivity.getMyApplication().getPoiFilters();
|
||||||
|
final ContextMenuItem item = menuAdapter.getItem(pos);
|
||||||
|
if (item.getSelected() != null) {
|
||||||
|
item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
}
|
||||||
|
if (itemId == R.string.layer_poi) {
|
||||||
|
PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
|
||||||
|
poiFiltersHelper.clearSelectedPoiFilters(wiki);
|
||||||
|
if (isChecked) {
|
||||||
|
showPoiFilterDialog(adapter, adapter.getItem(pos));
|
||||||
|
} else {
|
||||||
|
adapter.getItem(pos).setDescription(
|
||||||
|
poiFiltersHelper.getSelectedPoiFiltersName(wiki));
|
||||||
|
}
|
||||||
|
} else if (itemId == R.string.layer_amenity_label) {
|
||||||
|
settings.SHOW_POI_LABEL.set(isChecked);
|
||||||
|
} else if (itemId == R.string.shared_string_favorites) {
|
||||||
|
settings.SHOW_FAVORITES.set(isChecked);
|
||||||
|
} else if (itemId == R.string.layer_gpx_layer) {
|
||||||
|
final GpxSelectionHelper selectedGpxHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
|
||||||
|
if (selectedGpxHelper.isShowingAnyGpxFiles()) {
|
||||||
|
selectedGpxHelper.clearAllGpxFilesToShow(true);
|
||||||
|
adapter.getItem(pos).setDescription(selectedGpxHelper.getGpxDescription());
|
||||||
|
} else {
|
||||||
|
showGpxSelectionDialog(adapter, adapter.getItem(pos));
|
||||||
|
}
|
||||||
|
} else if (itemId == R.string.rendering_category_transport) {
|
||||||
|
boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication());
|
||||||
|
TransportLinesMenu.toggleTransportLines(mapActivity, !selected, new CallbackWithObject<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public boolean processResult(Boolean result) {
|
||||||
|
item.setSelected(result);
|
||||||
|
item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (itemId == R.string.map_markers) {
|
||||||
|
settings.SHOW_MAP_MARKERS.set(isChecked);
|
||||||
|
} else if (itemId == R.string.layer_map) {
|
||||||
|
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
||||||
|
Intent intent = new Intent(mapActivity, PluginActivity.class);
|
||||||
|
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, OsmandRasterMapsPlugin.ID);
|
||||||
|
mapActivity.startActivity(intent);
|
||||||
|
} else {
|
||||||
|
ContextMenuItem it = adapter.getItem(pos);
|
||||||
|
mapActivity.getMapLayers().selectMapLayer(mapActivity.getMapView(), it, adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
|
||||||
|
mapActivity.getMapView().refreshMap();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showGpxSelectionDialog(final ArrayAdapter<ContextMenuItem> adapter,
|
||||||
|
final ContextMenuItem item) {
|
||||||
|
AlertDialog dialog = mapActivity.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(),
|
||||||
|
mapActivity.getMapView());
|
||||||
|
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
|
boolean selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles();
|
||||||
|
item.setSelected(selected);
|
||||||
|
item.setDescription(app.getSelectedGpxHelper().getGpxDescription());
|
||||||
|
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showPoiFilterDialog(final ArrayAdapter<ContextMenuItem> adapter,
|
||||||
|
final ContextMenuItem item) {
|
||||||
|
final PoiFiltersHelper poiFiltersHelper = mapActivity.getMyApplication().getPoiFilters();
|
||||||
|
final PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
|
||||||
|
MapActivityLayers.DismissListener dismissListener =
|
||||||
|
new MapActivityLayers.DismissListener() {
|
||||||
|
@Override
|
||||||
|
public void dismiss() {
|
||||||
|
PoiFiltersHelper pf = mapActivity.getMyApplication().getPoiFilters();
|
||||||
|
boolean selected = pf.isShowingAnyPoi(wiki);
|
||||||
|
item.setSelected(selected);
|
||||||
|
item.setDescription(pf.getSelectedPoiFiltersName(wiki));
|
||||||
|
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (poiFiltersHelper.isShowingAnyPoi(wiki)) {
|
||||||
|
mapActivity.getMapLayers().showMultichoicePoiFilterDialog(mapActivity.getMapView(),
|
||||||
|
dismissListener);
|
||||||
|
} else {
|
||||||
|
mapActivity.getMapLayers().showSingleChoicePoiFilterDialog(mapActivity.getMapView(),
|
||||||
|
dismissListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,7 +80,6 @@ import net.osmand.plus.OsmAndConstants;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
|
@ -90,10 +89,11 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.PluginActivity;
|
import net.osmand.plus.activities.PluginActivity;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu.AppearanceListItem;
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter;
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.routing.RouteCalculationResult;
|
import net.osmand.plus.routing.RouteCalculationResult;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.render.RenderingRuleProperty;
|
import net.osmand.render.RenderingRuleProperty;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.router.RouteStatisticsHelper;
|
import net.osmand.router.RouteStatisticsHelper;
|
||||||
|
@ -540,9 +540,9 @@ public class GpxUiHelper {
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
AppearanceListItem item = gpxApprAdapter.getItem(position);
|
AppearanceListItem item = gpxApprAdapter.getItem(position);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
if (item.getAttrName() == CURRENT_TRACK_WIDTH_ATTR) {
|
if (CURRENT_TRACK_WIDTH_ATTR.equals(item.getAttrName())) {
|
||||||
gpxAppearanceParams.put(CURRENT_TRACK_WIDTH_ATTR, item.getValue());
|
gpxAppearanceParams.put(CURRENT_TRACK_WIDTH_ATTR, item.getValue());
|
||||||
} else if (item.getAttrName() == CURRENT_TRACK_COLOR_ATTR) {
|
} else if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) {
|
||||||
gpxAppearanceParams.put(CURRENT_TRACK_COLOR_ATTR, item.getValue());
|
gpxAppearanceParams.put(CURRENT_TRACK_COLOR_ATTR, item.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ public class GpxUiHelper {
|
||||||
}
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX,
|
loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX,
|
||||||
s.toArray(new String[s.size()]));
|
s.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
|
|
@ -32,7 +32,7 @@ import net.osmand.data.FavouritePoint.BackgroundType;
|
||||||
import net.osmand.plus.AppInitializer;
|
import net.osmand.plus.AppInitializer;
|
||||||
import net.osmand.plus.CustomOsmandPlugin;
|
import net.osmand.plus.CustomOsmandPlugin;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.GPXDatabase;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -1017,10 +1017,10 @@ public class ImportHelper {
|
||||||
gpxFile.path = toWrite.getAbsolutePath();
|
gpxFile.path = toWrite.getAbsolutePath();
|
||||||
File file = new File(gpxFile.path);
|
File file = new File(gpxFile.path);
|
||||||
if (!destinationExists) {
|
if (!destinationExists) {
|
||||||
GPXDatabase.GpxDataItem item = new GPXDatabase.GpxDataItem(file, gpxFile.getColor(0));
|
GpxDataItem item = new GpxDataItem(file, gpxFile);
|
||||||
app.getGpxDbHelper().add(item);
|
app.getGpxDbHelper().add(item);
|
||||||
} else {
|
} else {
|
||||||
GPXDatabase.GpxDataItem item = app.getGpxDbHelper().getItem(file);
|
GpxDataItem item = app.getGpxDbHelper().getItem(file);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
app.getGpxDbHelper().clearAnalysis(item);
|
app.getGpxDbHelper().clearAnalysis(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.myplaces;
|
package net.osmand.plus.myplaces;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
@ -14,8 +15,10 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -36,12 +39,12 @@ import com.squareup.picasso.RequestCreator;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile.GpxSplitType;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.PicassoUtils;
|
import net.osmand.PicassoUtils;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.plus.GPXDatabase;
|
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
|
@ -49,13 +52,16 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||||
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
||||||
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.NewGpxData;
|
||||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||||
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
||||||
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
||||||
|
@ -71,6 +77,7 @@ import java.util.Map;
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
|
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
|
||||||
|
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR;
|
||||||
|
|
||||||
public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
|
|
||||||
|
@ -356,50 +363,27 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
final GPXFile gpxFile = getGpx();
|
||||||
colorListPopupWindow = new ListPopupWindow(activity);
|
if (activity != null && gpxFile != null) {
|
||||||
colorListPopupWindow.setAnchorView(colorView);
|
final GpxAppearanceAdapter appearanceAdapter = new GpxAppearanceAdapter(activity,
|
||||||
colorListPopupWindow.setContentWidth(AndroidUtils.dpToPx(app, 200f));
|
gpxFile.getColor(0), GpxAppearanceAdapterType.TRACK_WIDTH_COLOR);
|
||||||
colorListPopupWindow.setModal(true);
|
OnItemClickListener itemClickListener = new OnItemClickListener() {
|
||||||
colorListPopupWindow.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
|
|
||||||
colorListPopupWindow.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
|
|
||||||
colorListPopupWindow.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
|
|
||||||
GPXFile gpxFile = getGpx();
|
|
||||||
final ConfigureMapMenu.GpxAppearanceAdapter gpxApprAdapter = new ConfigureMapMenu.GpxAppearanceAdapter(activity,
|
|
||||||
gpxFile.getColor(0), ConfigureMapMenu.GpxAppearanceAdapter.GpxAppearanceAdapterType.TRACK_COLOR);
|
|
||||||
colorListPopupWindow.setAdapter(gpxApprAdapter);
|
|
||||||
colorListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
ConfigureMapMenu.AppearanceListItem item = gpxApprAdapter.getItem(position);
|
AppearanceListItem item = appearanceAdapter.getItem(position);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) {
|
if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) {
|
||||||
GPXFile gpx = getGpx();
|
setGpxColor(item, gpxFile);
|
||||||
int clr = item.getColor();
|
} else if (CURRENT_TRACK_WIDTH_ATTR.equals(item.getAttrName())) {
|
||||||
if (vis.isChecked()) {
|
setGpxWidth(item, gpxFile);
|
||||||
if (gpx != null) {
|
|
||||||
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, vis.isChecked(), false);
|
|
||||||
if (clr != 0 && sf.getModifiableGpxFile() != null) {
|
|
||||||
sf.getModifiableGpxFile().setColor(clr);
|
|
||||||
if (getGpxDataItem() != null) {
|
|
||||||
app.getGpxDbHelper().updateColor(getGpxDataItem(), clr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (getGpxDataItem() != null) {
|
|
||||||
app.getGpxDbHelper().updateColor(getGpxDataItem(), clr);
|
|
||||||
}
|
|
||||||
if (gpx != null && gpx.showCurrentTrack) {
|
|
||||||
app.getSettings().CURRENT_TRACK_COLOR.set(clr);
|
|
||||||
}
|
|
||||||
refreshTrackBitmap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
colorListPopupWindow.dismiss();
|
colorListPopupWindow.dismiss();
|
||||||
updateColorView(colorView);
|
updateColorView(colorView);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
colorListPopupWindow = createPopupWindow(activity, splitIntervalView, appearanceAdapter, itemClickListener);
|
||||||
colorListPopupWindow.show();
|
colorListPopupWindow.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,16 +399,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
splitListPopupWindow = new ListPopupWindow(activity);
|
ListAdapter adapter = new ArrayAdapter<>(activity, R.layout.popup_list_text_item, options);
|
||||||
splitListPopupWindow.setAnchorView(splitIntervalView);
|
OnItemClickListener itemClickListener = new OnItemClickListener() {
|
||||||
splitListPopupWindow.setContentWidth(AndroidUtils.dpToPx(app, 200f));
|
|
||||||
splitListPopupWindow.setModal(true);
|
|
||||||
splitListPopupWindow.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
|
|
||||||
splitListPopupWindow.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
|
|
||||||
splitListPopupWindow.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
|
|
||||||
splitListPopupWindow.setAdapter(new ArrayAdapter<>(activity,
|
|
||||||
R.layout.popup_list_text_item, options));
|
|
||||||
splitListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
@ -433,7 +409,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
splitListPopupWindow.dismiss();
|
splitListPopupWindow.dismiss();
|
||||||
updateSplitIntervalView(splitIntervalView);
|
updateSplitIntervalView(splitIntervalView);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
splitListPopupWindow = createPopupWindow(activity, splitIntervalView, adapter, itemClickListener);
|
||||||
splitListPopupWindow.show();
|
splitListPopupWindow.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,6 +428,55 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setGpxColor(AppearanceListItem item, GPXFile gpxFile) {
|
||||||
|
int color = item.getColor();
|
||||||
|
if (vis.isChecked()) {
|
||||||
|
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, vis.isChecked(), false);
|
||||||
|
if (color != 0 && sf.getModifiableGpxFile() != null) {
|
||||||
|
sf.getModifiableGpxFile().setColor(color);
|
||||||
|
if (getGpxDataItem() != null) {
|
||||||
|
app.getGpxDbHelper().updateColor(getGpxDataItem(), color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (getGpxDataItem() != null) {
|
||||||
|
app.getGpxDbHelper().updateColor(getGpxDataItem(), color);
|
||||||
|
}
|
||||||
|
if (gpxFile.showCurrentTrack) {
|
||||||
|
app.getSettings().CURRENT_TRACK_COLOR.set(color);
|
||||||
|
}
|
||||||
|
refreshTrackBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setGpxWidth(AppearanceListItem item, GPXFile gpxFile) {
|
||||||
|
String width = item.getValue();
|
||||||
|
if (vis.isChecked()) {
|
||||||
|
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, vis.isChecked(), false);
|
||||||
|
if (width != null && sf.getModifiableGpxFile() != null) {
|
||||||
|
sf.getModifiableGpxFile().setWidth(width);
|
||||||
|
if (getGpxDataItem() != null) {
|
||||||
|
app.getGpxDbHelper().updateWidth(getGpxDataItem(), width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (getGpxDataItem() != null) {
|
||||||
|
app.getGpxDbHelper().updateWidth(getGpxDataItem(), width);
|
||||||
|
}
|
||||||
|
refreshTrackBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ListPopupWindow createPopupWindow(Activity activity, View anchorView, ListAdapter adapter, OnItemClickListener itemClickListener) {
|
||||||
|
ListPopupWindow popupWindow = new ListPopupWindow(activity);
|
||||||
|
popupWindow.setAnchorView(anchorView);
|
||||||
|
popupWindow.setContentWidth(AndroidUtils.dpToPx(app, 200f));
|
||||||
|
popupWindow.setModal(true);
|
||||||
|
popupWindow.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
|
||||||
|
popupWindow.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
|
||||||
|
popupWindow.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
|
||||||
|
popupWindow.setAdapter(adapter);
|
||||||
|
popupWindow.setOnItemClickListener(itemClickListener);
|
||||||
|
|
||||||
|
return popupWindow;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private View getDescriptionCardView(Context context) {
|
private View getDescriptionCardView(Context context) {
|
||||||
GPXFile gpx = getGpx();
|
GPXFile gpx = getGpx();
|
||||||
|
@ -738,13 +764,13 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
double splitInterval = getGpxDataItem().getSplitInterval();
|
double splitInterval = getGpxDataItem().getSplitInterval();
|
||||||
int position = 0;
|
int position = 0;
|
||||||
|
|
||||||
if (splitType == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) {
|
if (splitType == GpxSplitType.DISTANCE.getType()) {
|
||||||
position = distanceSplit.indexOf(splitInterval);
|
position = distanceSplit.indexOf(splitInterval);
|
||||||
} else if (splitType == GPXDatabase.GPX_SPLIT_TYPE_TIME) {
|
} else if (splitType == GpxSplitType.TIME.getType()) {
|
||||||
position = timeSplit.indexOf((int) splitInterval);
|
position = timeSplit.indexOf((int) splitInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
return position > 0 ? position : 0;
|
return Math.max(position, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColorView(View colorView) {
|
private void updateColorView(View colorView) {
|
||||||
|
@ -759,10 +785,9 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
final RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
final OsmandSettings.CommonPreference<String> prefColor
|
CommonPreference<String> prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
|
||||||
= app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
|
color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColor.get());
|
||||||
color = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor(renderer, prefColor.get());
|
|
||||||
}
|
}
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
colorImageView.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle));
|
colorImageView.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle));
|
||||||
|
@ -852,20 +877,20 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSplitInDatabase() {
|
private void updateSplitInDatabase() {
|
||||||
int splitType = 0;
|
|
||||||
double splitInterval = 0;
|
double splitInterval = 0;
|
||||||
|
GpxSplitType splitType = null;
|
||||||
if (selectedSplitInterval == 0) {
|
if (selectedSplitInterval == 0) {
|
||||||
splitType = GPXDatabase.GPX_SPLIT_TYPE_NO_SPLIT;
|
splitType = GpxSplitType.NO_SPLIT;
|
||||||
splitInterval = 0;
|
splitInterval = 0;
|
||||||
} else if (distanceSplit.get(selectedSplitInterval) > 0) {
|
} else if (distanceSplit.get(selectedSplitInterval) > 0) {
|
||||||
splitType = GPXDatabase.GPX_SPLIT_TYPE_DISTANCE;
|
splitType = GpxSplitType.DISTANCE;
|
||||||
splitInterval = distanceSplit.get(selectedSplitInterval);
|
splitInterval = distanceSplit.get(selectedSplitInterval);
|
||||||
} else if (timeSplit.get(selectedSplitInterval) > 0) {
|
} else if (timeSplit.get(selectedSplitInterval) > 0) {
|
||||||
splitType = GPXDatabase.GPX_SPLIT_TYPE_TIME;
|
splitType = GpxSplitType.TIME;
|
||||||
splitInterval = timeSplit.get(selectedSplitInterval);
|
splitInterval = timeSplit.get(selectedSplitInterval);
|
||||||
}
|
}
|
||||||
GpxDataItem item = getGpxDataItem();
|
GpxDataItem item = getGpxDataItem();
|
||||||
if (item != null) {
|
if (item != null && splitType != null) {
|
||||||
app.getGpxDbHelper().updateSplit(item, splitType, splitInterval);
|
app.getGpxDbHelper().updateSplit(item, splitType, splitInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.views;
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Align;
|
import android.graphics.Paint.Align;
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.Paint.Style;
|
||||||
|
@ -11,6 +10,7 @@ import android.graphics.PorterDuff.Mode;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.LayerDrawable;
|
import android.graphics.drawable.LayerDrawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
@ -21,11 +21,13 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
|
@ -40,6 +42,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
|
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
||||||
|
@ -55,6 +58,8 @@ import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -67,29 +72,30 @@ import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR;
|
||||||
|
|
||||||
public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IMoveObjectProvider, MapTextProvider<WptPt> {
|
public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IMoveObjectProvider, MapTextProvider<WptPt> {
|
||||||
|
|
||||||
|
private static final Log log = PlatformUtil.getLog(GPXLayer.class);
|
||||||
|
|
||||||
private static final double TOUCH_RADIUS_MULTIPLIER = 1.5;
|
private static final double TOUCH_RADIUS_MULTIPLIER = 1.5;
|
||||||
|
private static final int DEFAULT_WIDTH_MULTIPLIER = 7;
|
||||||
private static final int START_ZOOM = 7;
|
private static final int START_ZOOM = 7;
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
private Paint paint2;
|
|
||||||
private boolean isPaint2;
|
|
||||||
private Paint shadowPaint;
|
private Paint shadowPaint;
|
||||||
private boolean isShadowPaint;
|
private Paint paintIcon;
|
||||||
private Paint paint_1;
|
|
||||||
private boolean isPaint_1;
|
|
||||||
private int cachedHash;
|
private int cachedHash;
|
||||||
private int cachedColor;
|
private int cachedColor;
|
||||||
private Paint paintIcon;
|
|
||||||
private int currentTrackColor;
|
private int currentTrackColor;
|
||||||
|
private float defaultTrackWidth;
|
||||||
|
private Map<String, Float> cachedTrackWidth = new HashMap<>();
|
||||||
|
|
||||||
|
private Drawable startPointIcon;
|
||||||
|
private Drawable finishPointIcon;
|
||||||
private LayerDrawable selectedPoint;
|
private LayerDrawable selectedPoint;
|
||||||
private TrackChartPoints trackChartPoints;
|
private TrackChartPoints trackChartPoints;
|
||||||
|
|
||||||
private GpxSelectionHelper selectedGpxHelper;
|
private GpxSelectionHelper selectedGpxHelper;
|
||||||
private MapMarkersHelper mapMarkersHelper;
|
private MapMarkersHelper mapMarkersHelper;
|
||||||
private Paint paintBmp;
|
|
||||||
private List<WptPt> cache = new ArrayList<>();
|
private List<WptPt> cache = new ArrayList<>();
|
||||||
private Map<WptPt, SelectedGpxFile> pointFileMap = new HashMap<>();
|
private Map<WptPt, SelectedGpxFile> pointFileMap = new HashMap<>();
|
||||||
private MapTextLayer textLayer;
|
private MapTextLayer textLayer;
|
||||||
|
@ -134,26 +140,14 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
paint.setStyle(Style.STROKE);
|
paint.setStyle(Style.STROKE);
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint2 = new Paint();
|
|
||||||
paint2.setStyle(Style.STROKE);
|
|
||||||
paint2.setAntiAlias(true);
|
|
||||||
shadowPaint = new Paint();
|
shadowPaint = new Paint();
|
||||||
shadowPaint.setStyle(Style.STROKE);
|
shadowPaint.setStyle(Style.STROKE);
|
||||||
shadowPaint.setAntiAlias(true);
|
shadowPaint.setAntiAlias(true);
|
||||||
paint_1 = new Paint();
|
|
||||||
paint_1.setStyle(Style.STROKE);
|
|
||||||
paint_1.setAntiAlias(true);
|
|
||||||
|
|
||||||
paintBmp = new Paint();
|
|
||||||
paintBmp.setAntiAlias(true);
|
|
||||||
paintBmp.setFilterBitmap(true);
|
|
||||||
paintBmp.setDither(true);
|
|
||||||
|
|
||||||
paintTextIcon = new Paint();
|
paintTextIcon = new Paint();
|
||||||
paintTextIcon.setTextSize(10 * view.getDensity());
|
paintTextIcon.setTextSize(10 * view.getDensity());
|
||||||
paintTextIcon.setTextAlign(Align.CENTER);
|
paintTextIcon.setTextAlign(Align.CENTER);
|
||||||
paintTextIcon.setFakeBoldText(true);
|
paintTextIcon.setFakeBoldText(true);
|
||||||
// paintTextIcon.setColor(Color.WHITE);
|
|
||||||
paintTextIcon.setAntiAlias(true);
|
paintTextIcon.setAntiAlias(true);
|
||||||
|
|
||||||
textLayer = view.getLayerByClass(MapTextLayer.class);
|
textLayer = view.getLayerByClass(MapTextLayer.class);
|
||||||
|
@ -164,7 +158,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
paintOuterRect = new Paint();
|
paintOuterRect = new Paint();
|
||||||
paintOuterRect.setStyle(Style.STROKE);
|
paintOuterRect.setStyle(Style.STROKE);
|
||||||
paintOuterRect.setAntiAlias(true);
|
paintOuterRect.setAntiAlias(true);
|
||||||
// paintOuterRect.setColor(Color.WHITE);
|
|
||||||
paintOuterRect.setStrokeWidth(3);
|
paintOuterRect.setStrokeWidth(3);
|
||||||
paintOuterRect.setAlpha(255);
|
paintOuterRect.setAlpha(255);
|
||||||
paintGridCircle = new Paint();
|
paintGridCircle = new Paint();
|
||||||
|
@ -179,6 +172,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
paintIcon = new Paint();
|
paintIcon = new Paint();
|
||||||
selectedPoint = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), R.drawable.map_location_default);
|
selectedPoint = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), R.drawable.map_location_default);
|
||||||
|
|
||||||
|
UiUtilities iconsCache = view.getApplication().getUIUtilities();
|
||||||
|
startPointIcon = iconsCache.getIcon(R.drawable.map_track_point_start);
|
||||||
|
finishPointIcon = iconsCache.getIcon(R.drawable.map_track_point_finish);
|
||||||
|
|
||||||
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
|
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
|
||||||
|
|
||||||
visitedColor = ContextCompat.getColor(view.getApplication(), R.color.color_ok);
|
visitedColor = ContextCompat.getColor(view.getApplication(), R.color.color_ok);
|
||||||
|
@ -213,6 +210,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
|
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
|
||||||
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
|
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
|
||||||
|
drawSelectedFilesStartEndPoints(canvas, tileBox, selectedGPXFiles);
|
||||||
}
|
}
|
||||||
if (textLayer != null && isTextVisible()) {
|
if (textLayer != null && isTextVisible()) {
|
||||||
textLayer.putData(this, cache);
|
textLayer.putData(this, cache);
|
||||||
|
@ -220,29 +218,28 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int updatePaints(int color, boolean routePoints, boolean currentTrack, DrawSettings nightMode, RotatedTileBox tileBox) {
|
private int updatePaints(int color, String width, boolean routePoints, boolean currentTrack, DrawSettings drawSettings, RotatedTileBox tileBox) {
|
||||||
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
final boolean isNight = nightMode != null && nightMode.isNightMode();
|
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
||||||
int hsh = calculateHash(rrs, routePoints, isNight, tileBox.getMapDensity(), tileBox.getZoom(),
|
int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(),
|
||||||
currentTrackColorPref.get(), currentTrackWidthPref.get());
|
currentTrackColorPref.get(), currentTrackWidthPref.get());
|
||||||
if (hsh != cachedHash) {
|
if (hash != cachedHash) {
|
||||||
cachedHash = hsh;
|
cachedHash = hash;
|
||||||
cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track);
|
cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track);
|
||||||
|
defaultTrackWidth = DEFAULT_WIDTH_MULTIPLIER * view.getDensity();
|
||||||
if (rrs != null) {
|
if (rrs != null) {
|
||||||
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
|
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
|
||||||
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, isNight);
|
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
|
||||||
CommonPreference<String> p = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
|
if (currentTrackColorPref != null && currentTrackColorPref.isSet()) {
|
||||||
if (p != null && p.isSet()) {
|
|
||||||
RenderingRuleProperty ctColor = rrs.PROPS.get(CURRENT_TRACK_COLOR_ATTR);
|
RenderingRuleProperty ctColor = rrs.PROPS.get(CURRENT_TRACK_COLOR_ATTR);
|
||||||
if (ctColor != null) {
|
if (ctColor != null) {
|
||||||
req.setStringFilter(ctColor, p.get());
|
req.setStringFilter(ctColor, currentTrackColorPref.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommonPreference<String> p2 = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR);
|
if (currentTrackWidthPref != null && currentTrackWidthPref.isSet()) {
|
||||||
if (p2 != null && p2.isSet()) {
|
|
||||||
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
|
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
|
||||||
if (ctWidth != null) {
|
if (ctWidth != null) {
|
||||||
req.setStringFilter(ctWidth, p2.get());
|
req.setStringFilter(ctWidth, currentTrackWidthPref.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String additional = "";
|
String additional = "";
|
||||||
|
@ -262,26 +259,54 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
rc.setDensityValue((float) tileBox.getMapDensity());
|
rc.setDensityValue((float) tileBox.getMapDensity());
|
||||||
cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR);
|
cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR);
|
||||||
osmandRenderer.updatePaint(req, paint, 0, false, rc);
|
osmandRenderer.updatePaint(req, paint, 0, false, rc);
|
||||||
isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc);
|
|
||||||
isPaint_1 = osmandRenderer.updatePaint(req, paint_1, -1, false, rc);
|
if (req.isSpecified(rrs.PROPS.R_SHADOW_RADIUS)) {
|
||||||
isShadowPaint = req.isSpecified(rrs.PROPS.R_SHADOW_RADIUS);
|
int shadowColor = req.getIntPropertyValue(rrs.PROPS.R_SHADOW_COLOR);
|
||||||
if (isShadowPaint) {
|
float shadowRadius = rc.getComplexValue(req, rrs.PROPS.R_SHADOW_RADIUS);
|
||||||
ColorFilter cf = new PorterDuffColorFilter(req.getIntPropertyValue(rrs.PROPS.R_SHADOW_COLOR),
|
shadowPaint.setColorFilter(new PorterDuffColorFilter(shadowColor, Mode.SRC_IN));
|
||||||
Mode.SRC_IN);
|
shadowPaint.setStrokeWidth(paint.getStrokeWidth() + 2 * shadowRadius);
|
||||||
shadowPaint.setColorFilter(cf);
|
}
|
||||||
shadowPaint.setStrokeWidth(paint.getStrokeWidth() + 2
|
for (String key : cachedTrackWidth.keySet()) {
|
||||||
* rc.getComplexValue(req, rrs.PROPS.R_SHADOW_RADIUS));
|
acquireTrackWidth(key, rrs, req, rc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Rendering attribute gpx is not found !");
|
log.error("Rendering attribute gpx is not found !");
|
||||||
paint.setStrokeWidth(7 * view.getDensity());
|
for (String key : cachedTrackWidth.keySet()) {
|
||||||
|
cachedTrackWidth.put(key, defaultTrackWidth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paint.setColor(color == 0 ? cachedColor : color);
|
paint.setColor(color == 0 ? cachedColor : color);
|
||||||
|
Float strikeWidth = cachedTrackWidth.get(width);
|
||||||
|
if (strikeWidth != null) {
|
||||||
|
paint.setStrokeWidth(strikeWidth);
|
||||||
|
}
|
||||||
return cachedColor;
|
return cachedColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
||||||
|
if (!Algorithms.isEmpty(widthKey) && Algorithms.isInt(widthKey)) {
|
||||||
|
try {
|
||||||
|
int widthDp = Integer.parseInt(widthKey);
|
||||||
|
float widthF = AndroidUtils.dpToPx(view.getApplication(), widthDp);
|
||||||
|
cachedTrackWidth.put(widthKey, widthF);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
cachedTrackWidth.put(widthKey, defaultTrackWidth);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
|
||||||
|
if (ctWidth != null) {
|
||||||
|
req.setStringFilter(ctWidth, widthKey);
|
||||||
|
}
|
||||||
|
if (req.searchRenderingAttribute("gpx")) {
|
||||||
|
float widthF = rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH);
|
||||||
|
cachedTrackWidth.put(widthKey, widthF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int calculateHash(Object... o) {
|
private int calculateHash(Object... o) {
|
||||||
return Arrays.hashCode(o);
|
return Arrays.hashCode(o);
|
||||||
}
|
}
|
||||||
|
@ -368,6 +393,34 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
|
if (selectedGpxFile.getGpxFile().isShowStartFinish()) {
|
||||||
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
|
TrkSegment endSegment = segments.get(segments.size() - 1);
|
||||||
|
|
||||||
|
WptPt start = segments.get(0).points.get(0);
|
||||||
|
WptPt end = endSegment.points.get(endSegment.points.size() - 1);
|
||||||
|
|
||||||
|
drawPoint(canvas, tileBox, start, startPointIcon);
|
||||||
|
drawPoint(canvas, tileBox, end, finishPointIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, WptPt wptPt, Drawable icon) {
|
||||||
|
int pointX = (int) tileBox.getPixXFromLatLon(wptPt.lat, wptPt.lon);
|
||||||
|
int pointY = (int) tileBox.getPixYFromLatLon(wptPt.lat, wptPt.lon);
|
||||||
|
|
||||||
|
icon.setBounds(pointX - icon.getIntrinsicWidth() / 2,
|
||||||
|
pointY - icon.getIntrinsicHeight() / 2,
|
||||||
|
pointX + icon.getIntrinsicWidth() / 2,
|
||||||
|
pointY + icon.getIntrinsicHeight() / 2);
|
||||||
|
icon.draw(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
if (tileBox.getZoom() >= START_ZOOM) {
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
float textScale = view.getSettings().TEXT_SCALE.get();
|
float textScale = view.getSettings().TEXT_SCALE.get();
|
||||||
|
@ -518,7 +571,12 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
|
|
||||||
private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox,
|
private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox,
|
||||||
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
||||||
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
|
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
||||||
|
if (!cachedTrackWidth.containsKey(width)) {
|
||||||
|
cachedTrackWidth.put(width, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
SelectedGpxFile currentTrack = null;
|
SelectedGpxFile currentTrack = null;
|
||||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
for (SelectedGpxFile g : selectedGPXFiles) {
|
||||||
if (g.isShowCurrentTrack()) {
|
if (g.isShowCurrentTrack()) {
|
||||||
|
@ -536,6 +594,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
RotatedTileBox tileBox, DrawSettings settings) {
|
RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
for (TrkSegment ts : segments) {
|
for (TrkSegment ts : segments) {
|
||||||
|
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
||||||
int color = selectedGpxFile.getGpxFile().getColor(0);
|
int color = selectedGpxFile.getGpxFile().getColor(0);
|
||||||
if (currentTrack) {
|
if (currentTrack) {
|
||||||
color = currentTrackColor;
|
color = currentTrackColor;
|
||||||
|
@ -550,7 +609,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
ts.renderer = new Renderable.StandardTrack(ts.points, 17.2);
|
ts.renderer = new Renderable.StandardTrack(ts.points, 17.2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updatePaints(color, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
|
updatePaints(color, width, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
|
||||||
if (ts.renderer instanceof Renderable.RenderableSegment) {
|
if (ts.renderer instanceof Renderable.RenderableSegment) {
|
||||||
((Renderable.RenderableSegment) ts.renderer).drawSegment(view.getZoom(), paint, canvas, tileBox);
|
((Renderable.RenderableSegment) ts.renderer).drawSegment(view.getZoom(), paint, canvas, tileBox);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue