Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a0efd289b9
3 changed files with 135 additions and 120 deletions
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="number_of_gpx_files_selected_pattern">%s GPX files selected</string>
|
||||
<string name="rendering_value_thin_name">Thin</string>
|
||||
<string name="rendering_value_medium_name">Medium</string>
|
||||
<string name="rendering_value_bold_name">Bold</string>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
|
@ -28,30 +30,41 @@ public class GpxSelectionHelper {
|
|||
private static final String FILE = "file";
|
||||
private static final String COLOR = "color";
|
||||
private OsmandApplication app;
|
||||
// save into settings
|
||||
// public final CommonPreference<Boolean> SHOW_CURRENT_GPX_TRACK =
|
||||
// new BooleanPreference("show_current_gpx_track", false).makeGlobal().cache();
|
||||
private List<SelectedGpxFile> selectedGPXFiles = new java.util.ArrayList<SelectedGpxFile>();
|
||||
@NonNull
|
||||
private List<SelectedGpxFile> selectedGPXFiles = new java.util.ArrayList<>();
|
||||
private SavingTrackHelper savingTrackHelper;
|
||||
|
||||
public GpxSelectionHelper(OsmandApplication osmandApplication, SavingTrackHelper trackHelper) {
|
||||
this.app = osmandApplication;
|
||||
savingTrackHelper = trackHelper;
|
||||
}
|
||||
|
||||
|
||||
public void clearAllGpxFileToShow() {
|
||||
selectedGPXFiles.clear();
|
||||
saveCurrentSelections();
|
||||
}
|
||||
|
||||
|
||||
public boolean isShowingAnyGpxFiles() {
|
||||
return !selectedGPXFiles.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
public List<SelectedGpxFile> getSelectedGPXFiles() {
|
||||
return selectedGPXFiles;
|
||||
}
|
||||
|
||||
public String getGpxDescription() {
|
||||
if (selectedGPXFiles.size() == 1) {
|
||||
File file = new File(selectedGPXFiles.get(0).getGpxFile().path);
|
||||
return Algorithms.getFileNameWithoutExtension(file);
|
||||
} else if (selectedGPXFiles.size() == 0) {
|
||||
return app.getResources().getString(R.string.none);
|
||||
} else {
|
||||
return app.getResources().getString(R.string.number_of_gpx_files_selected_pattern,
|
||||
selectedGPXFiles.size());
|
||||
}
|
||||
}
|
||||
|
||||
public SelectedGpxFile getSelectedGPXFile(WptPt point) {
|
||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
||||
if (g.getGpxFile().points.contains(point)) {
|
||||
|
@ -61,25 +74,25 @@ public class GpxSelectionHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public final String getString(int resId, Object... formatArgs) {
|
||||
private String getString(int resId, Object... formatArgs) {
|
||||
return app.getString(resId, formatArgs);
|
||||
}
|
||||
|
||||
public List<GpxDisplayGroup> collectDisplayGroups(GPXFile g) {
|
||||
List<GpxDisplayGroup> dg = new ArrayList<GpxSelectionHelper.GpxDisplayGroup>();
|
||||
List<GpxDisplayGroup> dg = new ArrayList<>();
|
||||
String name = g.path;
|
||||
if(g.showCurrentTrack){
|
||||
name = getString(R.string.shared_string_currently_recording_track);
|
||||
if (g.showCurrentTrack) {
|
||||
name = getString(R.string.shared_string_currently_recording_track);
|
||||
} else {
|
||||
int i = name.lastIndexOf('/');
|
||||
if(i >= 0) {
|
||||
if (i >= 0) {
|
||||
name = name.substring(i + 1);
|
||||
}
|
||||
i = name.lastIndexOf('\\');
|
||||
if(i >= 0) {
|
||||
if (i >= 0) {
|
||||
name = name.substring(i + 1);
|
||||
}
|
||||
if(name.endsWith(".gpx")) {
|
||||
if (name.endsWith(".gpx")) {
|
||||
name = name.substring(0, name.length() - 4);
|
||||
}
|
||||
name = name.replace('_', ' ');
|
||||
|
@ -95,7 +108,7 @@ public class GpxSelectionHelper {
|
|||
String ks = (k++) + "";
|
||||
group.setName(getString(R.string.gpx_selection_track, name, g.tracks.size() == 1 ? "" : ks));
|
||||
String d = "";
|
||||
if(t.name != null && t.name.length() > 0) {
|
||||
if (t.name != null && t.name.length() > 0) {
|
||||
d = t.name + " " + d;
|
||||
}
|
||||
group.setDescription(d);
|
||||
|
@ -110,7 +123,7 @@ public class GpxSelectionHelper {
|
|||
group.gpxName = name;
|
||||
group.setType(GpxDisplayItemType.TRACK_ROUTE_POINTS);
|
||||
String d = getString(R.string.gpx_selection_number_of_points, name, route.points.size());
|
||||
if(route.name != null && route.name.length() > 0) {
|
||||
if (route.name != null && route.name.length() > 0) {
|
||||
d = route.name + " " + d;
|
||||
}
|
||||
group.setDescription(d);
|
||||
|
@ -135,7 +148,7 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (g.points.size() > 0) {
|
||||
GpxDisplayGroup group = new GpxDisplayGroup(g);
|
||||
group.gpxName = name;
|
||||
|
@ -154,7 +167,7 @@ public class GpxSelectionHelper {
|
|||
if (Algorithms.isEmpty(item.name)) {
|
||||
item.name = getString(R.string.gpx_selection_point, k + "");
|
||||
}
|
||||
item.expanded = true;
|
||||
item.expanded = true;
|
||||
item.locationStart = r;
|
||||
item.locationEnd = r;
|
||||
list.add(item);
|
||||
|
@ -162,47 +175,49 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
return dg;
|
||||
}
|
||||
|
||||
|
||||
private static void processGroupTrack(OsmandApplication app, GpxDisplayGroup group) {
|
||||
List<GpxDisplayItem> list = group.getModifiableList();
|
||||
String timeSpanClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_time_span_color));
|
||||
String speedClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_speed));
|
||||
String ascClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_altitude_asc));
|
||||
String descClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_altitude_desc));
|
||||
String distanceClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_distance_color));
|
||||
String timeSpanClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_time_span_color));
|
||||
String speedClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_speed));
|
||||
String ascClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_altitude_asc));
|
||||
String descClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_altitude_desc));
|
||||
String distanceClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_distance_color));
|
||||
final float eleThreshold = 3;
|
||||
// int t = 1;
|
||||
for (TrkSegment r : group.track.segments) {
|
||||
if (r.points.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
GPXTrackAnalysis[] as ;
|
||||
GPXTrackAnalysis[] as;
|
||||
boolean split = true;
|
||||
if(group.splitDistance > 0) {
|
||||
as = r.splitByDistance(group.splitDistance).toArray(new GPXTrackAnalysis[0]);
|
||||
} else if(group.splitTime > 0) {
|
||||
as = r.splitByTime(group.splitTime).toArray(new GPXTrackAnalysis[0]);
|
||||
if (group.splitDistance > 0) {
|
||||
List<GPXTrackAnalysis> trackSegments = r.splitByDistance(group.splitDistance);
|
||||
as = trackSegments.toArray(new GPXTrackAnalysis[trackSegments.size()]);
|
||||
} else if (group.splitTime > 0) {
|
||||
List<GPXTrackAnalysis> trackSegments = r.splitByTime(group.splitTime);
|
||||
as = trackSegments.toArray(new GPXTrackAnalysis[trackSegments.size()]);
|
||||
} else {
|
||||
split = false;
|
||||
as = new GPXTrackAnalysis[] {GPXTrackAnalysis.segment(0, r)};
|
||||
as = new GPXTrackAnalysis[]{GPXTrackAnalysis.segment(0, r)};
|
||||
}
|
||||
for(GPXTrackAnalysis analysis : as) {
|
||||
for (GPXTrackAnalysis analysis : as) {
|
||||
GpxDisplayItem item = new GpxDisplayItem();
|
||||
item.group = group;
|
||||
if(split) {
|
||||
if (split) {
|
||||
item.splitMetric = analysis.metricEnd;
|
||||
item.secondarySplitMetric = analysis.secondaryMetricEnd;
|
||||
item.splitName = formatSplitName(analysis.metricEnd, group, app);
|
||||
item.splitName += " ("+formatSecondarySplitName(analysis.secondaryMetricEnd, group, app) +") ";
|
||||
item.splitName += " (" + formatSecondarySplitName(analysis.secondaryMetricEnd, group, app) + ") ";
|
||||
}
|
||||
|
||||
|
||||
item.description = GpxUiHelper.getDescription(app, analysis, true);
|
||||
item.analysis = analysis;
|
||||
String name = "";
|
||||
// if(group.track.segments.size() > 1) {
|
||||
// name += t++ + ". ";
|
||||
// }
|
||||
if(!group.isSplitDistance()) {
|
||||
if (!group.isSplitDistance()) {
|
||||
name += GpxUiHelper.getColorValue(distanceClr, OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app));
|
||||
}
|
||||
if ((analysis.timeSpan > 0 || analysis.timeMoving > 0) && !group.isSplitTime()) {
|
||||
|
@ -223,20 +238,20 @@ public class GpxSelectionHelper {
|
|||
if (analysis.isElevationSpecified()) {
|
||||
if (name.length() != 0)
|
||||
name += ", ";
|
||||
name += GpxUiHelper.getColorValue(descClr, OsmAndFormatter.getFormattedAlt(analysis.minElevation, app));
|
||||
name += " - ";
|
||||
name += GpxUiHelper.getColorValue(ascClr, OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app));
|
||||
name += GpxUiHelper.getColorValue(descClr, OsmAndFormatter.getFormattedAlt(analysis.minElevation, app));
|
||||
name += " - ";
|
||||
name += GpxUiHelper.getColorValue(ascClr, OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app));
|
||||
}
|
||||
if (analysis.isElevationSpecified() && (analysis.diffElevationUp > eleThreshold ||
|
||||
analysis.diffElevationDown > eleThreshold) ) {
|
||||
if (analysis.isElevationSpecified() && (analysis.diffElevationUp > eleThreshold ||
|
||||
analysis.diffElevationDown > eleThreshold)) {
|
||||
if (name.length() != 0)
|
||||
name += ", ";
|
||||
if(analysis.diffElevationDown > eleThreshold) {
|
||||
name += GpxUiHelper.getColorValue(descClr, " \u2193 "+
|
||||
if (analysis.diffElevationDown > eleThreshold) {
|
||||
name += GpxUiHelper.getColorValue(descClr, " \u2193 " +
|
||||
OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app));
|
||||
}
|
||||
if(analysis.diffElevationUp > eleThreshold) {
|
||||
name += GpxUiHelper.getColorValue(ascClr, " \u2191 "+
|
||||
if (analysis.diffElevationUp > eleThreshold) {
|
||||
name += GpxUiHelper.getColorValue(ascClr, " \u2191 " +
|
||||
OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app));
|
||||
}
|
||||
}
|
||||
|
@ -245,9 +260,9 @@ public class GpxSelectionHelper {
|
|||
item.locationEnd = analysis.locationEnd;
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String formatSecondarySplitName(double metricEnd, GpxDisplayGroup group, OsmandApplication app) {
|
||||
if (group.isSplitDistance()) {
|
||||
return Algorithms.formatDuration((int) metricEnd);
|
||||
|
@ -280,14 +295,14 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
|
||||
public SelectedGpxFile getSelectedFileByPath(String path) {
|
||||
for(SelectedGpxFile s : selectedGPXFiles) {
|
||||
if(s.getGpxFile().path.equals(path)) {
|
||||
for (SelectedGpxFile s : selectedGPXFiles) {
|
||||
if (s.getGpxFile().path.equals(path)) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public SelectedGpxFile getSelectedFileByName(String path) {
|
||||
for (SelectedGpxFile s : selectedGPXFiles) {
|
||||
if (s.getGpxFile().path.endsWith("/" + path)) {
|
||||
|
@ -308,41 +323,40 @@ public class GpxSelectionHelper {
|
|||
|
||||
public void setGpxFileToDisplay(GPXFile... gpxs) {
|
||||
// special case for gpx current route
|
||||
for(GPXFile gpx : gpxs) {
|
||||
boolean show = true;
|
||||
selectGpxFileImpl(gpx, show, false);
|
||||
for (GPXFile gpx : gpxs) {
|
||||
selectGpxFileImpl(gpx, true, false);
|
||||
}
|
||||
saveCurrentSelections();
|
||||
}
|
||||
|
||||
|
||||
public void loadGPXTracks(IProgress p) {
|
||||
String load = app.getSettings().SELECTED_GPX.get();
|
||||
if(!Algorithms.isEmpty(load)) {
|
||||
if (!Algorithms.isEmpty(load)) {
|
||||
try {
|
||||
JSONArray ar = new JSONArray(load);
|
||||
boolean save = false;
|
||||
for(int i = 0; i < ar.length(); i++) {
|
||||
for (int i = 0; i < ar.length(); i++) {
|
||||
JSONObject obj = ar.getJSONObject(i);
|
||||
if(obj.has(FILE)) {
|
||||
if (obj.has(FILE)) {
|
||||
File fl = new File(obj.getString(FILE));
|
||||
if(p != null) {
|
||||
if (p != null) {
|
||||
p.startTask(getString(R.string.loading_smth, fl.getName()), -1);
|
||||
}
|
||||
GPXFile gpx = GPXUtilities.loadGPXFile(app, fl);
|
||||
if(obj.has(COLOR)) {
|
||||
if (obj.has(COLOR)) {
|
||||
int clr = Algorithms.parseColor(obj.getString(COLOR));
|
||||
gpx.setColor(clr);
|
||||
}
|
||||
if(gpx.warning != null) {
|
||||
if (gpx.warning != null) {
|
||||
save = true;
|
||||
} else {
|
||||
selectGpxFile(gpx, true, false);
|
||||
}
|
||||
} else if(obj.has(CURRENT_TRACK)) {
|
||||
} else if (obj.has(CURRENT_TRACK)) {
|
||||
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack());
|
||||
}
|
||||
}
|
||||
if(save) {
|
||||
if (save) {
|
||||
saveCurrentSelections();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -354,15 +368,15 @@ public class GpxSelectionHelper {
|
|||
|
||||
private void saveCurrentSelections() {
|
||||
JSONArray ar = new JSONArray();
|
||||
for(SelectedGpxFile s : selectedGPXFiles) {
|
||||
if(s.gpxFile != null && !s.notShowNavigationDialog) {
|
||||
for (SelectedGpxFile s : selectedGPXFiles) {
|
||||
if (s.gpxFile != null && !s.notShowNavigationDialog) {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
if(s.isShowCurrentTrack()) {
|
||||
if (s.isShowCurrentTrack()) {
|
||||
obj.put(CURRENT_TRACK, true);
|
||||
} else if(!Algorithms.isEmpty(s.gpxFile.path)) {
|
||||
} else if (!Algorithms.isEmpty(s.gpxFile.path)) {
|
||||
obj.put(FILE, s.gpxFile.path);
|
||||
if(s.gpxFile.getColor(0) != 0) {
|
||||
if (s.gpxFile.getColor(0) != 0) {
|
||||
obj.put(COLOR, Algorithms.colorToString(s.gpxFile.getColor(0)));
|
||||
}
|
||||
}
|
||||
|
@ -376,23 +390,24 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
|
||||
private SelectedGpxFile selectGpxFileImpl(GPXFile gpx, boolean show, boolean notShowNavigationDialog) {
|
||||
boolean displayed = false;
|
||||
SelectedGpxFile sf ;
|
||||
if(gpx != null && gpx.showCurrentTrack) {
|
||||
boolean displayed;
|
||||
SelectedGpxFile sf;
|
||||
if (gpx != null && gpx.showCurrentTrack) {
|
||||
sf = savingTrackHelper.getCurrentTrack();
|
||||
sf.notShowNavigationDialog = notShowNavigationDialog;
|
||||
displayed = selectedGPXFiles.contains(sf);
|
||||
} else {
|
||||
assert gpx != null;
|
||||
sf = getSelectedFileByPath(gpx.path);
|
||||
displayed = sf != null;
|
||||
if(show && sf == null) {
|
||||
if (show && sf == null) {
|
||||
sf = new SelectedGpxFile();
|
||||
sf.setGpxFile(gpx);
|
||||
sf.notShowNavigationDialog = notShowNavigationDialog;
|
||||
}
|
||||
}
|
||||
if(displayed != show) {
|
||||
if(show) {
|
||||
if (displayed != show) {
|
||||
if (show) {
|
||||
selectedGPXFiles.add(sf);
|
||||
} else {
|
||||
selectedGPXFiles.remove(sf);
|
||||
|
@ -400,14 +415,14 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
return sf;
|
||||
}
|
||||
|
||||
|
||||
public SelectedGpxFile selectGpxFile(GPXFile gpx, boolean show, boolean notShowNavigationDialog) {
|
||||
SelectedGpxFile sf = selectGpxFileImpl(gpx, show, notShowNavigationDialog);
|
||||
saveCurrentSelections();
|
||||
return sf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class SelectedGpxFile {
|
||||
public boolean notShowNavigationDialog = false;
|
||||
|
||||
|
@ -416,21 +431,21 @@ public class GpxSelectionHelper {
|
|||
private int color;
|
||||
private GPXTrackAnalysis trackAnalysis;
|
||||
private long modifiedTime = -1;
|
||||
private List<TrkSegment> processedPointsToDisplay = new ArrayList<TrkSegment>();
|
||||
private List<TrkSegment> processedPointsToDisplay = new ArrayList<>();
|
||||
private boolean routePoints;
|
||||
|
||||
private List<GpxDisplayGroup> displayGroups;
|
||||
|
||||
|
||||
public void setGpxFile(GPXFile gpxFile) {
|
||||
this.gpxFile = gpxFile;
|
||||
if(gpxFile.tracks.size() > 0) {
|
||||
if (gpxFile.tracks.size() > 0) {
|
||||
this.color = gpxFile.tracks.get(0).getColor(0);
|
||||
}
|
||||
processPoints();
|
||||
}
|
||||
|
||||
public GPXTrackAnalysis getTrackAnalysis() {
|
||||
if(modifiedTime != gpxFile.modifiedTime) {
|
||||
if (modifiedTime != gpxFile.modifiedTime) {
|
||||
update();
|
||||
}
|
||||
return trackAnalysis;
|
||||
|
@ -440,44 +455,44 @@ public class GpxSelectionHelper {
|
|||
modifiedTime = gpxFile.modifiedTime;
|
||||
trackAnalysis = gpxFile.getAnalysis(
|
||||
Algorithms.isEmpty(gpxFile.path) ? System.currentTimeMillis() :
|
||||
new File(gpxFile.path).lastModified());
|
||||
new File(gpxFile.path).lastModified());
|
||||
displayGroups = null;
|
||||
}
|
||||
|
||||
public void processPoints() {
|
||||
update();
|
||||
this.processedPointsToDisplay = gpxFile.proccessPoints();
|
||||
if(this.processedPointsToDisplay.isEmpty()) {
|
||||
if (this.processedPointsToDisplay.isEmpty()) {
|
||||
this.processedPointsToDisplay = gpxFile.processRoutePoints();
|
||||
routePoints = !this.processedPointsToDisplay.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isRoutePoints() {
|
||||
return routePoints;
|
||||
}
|
||||
|
||||
|
||||
public List<TrkSegment> getPointsToDisplay() {
|
||||
return processedPointsToDisplay;
|
||||
}
|
||||
|
||||
|
||||
public List<TrkSegment> getModifiablePointsToDisplay() {
|
||||
return processedPointsToDisplay;
|
||||
}
|
||||
|
||||
|
||||
public GPXFile getGpxFile() {
|
||||
return gpxFile;
|
||||
}
|
||||
|
||||
|
||||
public GPXFile getModifiableGpxFile() {
|
||||
// call process points after
|
||||
return gpxFile;
|
||||
}
|
||||
|
||||
|
||||
public boolean isShowCurrentTrack() {
|
||||
return showCurrentTrack;
|
||||
}
|
||||
|
||||
|
||||
public void setShowCurrentTrack(boolean showCurrentTrack) {
|
||||
this.showCurrentTrack = showCurrentTrack;
|
||||
}
|
||||
|
@ -487,14 +502,14 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
|
||||
public List<GpxDisplayGroup> getDisplayGroups() {
|
||||
if(modifiedTime != gpxFile.modifiedTime) {
|
||||
if (modifiedTime != gpxFile.modifiedTime) {
|
||||
update();
|
||||
}
|
||||
return displayGroups;
|
||||
}
|
||||
|
||||
|
||||
public void setDisplayGroups(List<GpxDisplayGroup> displayGroups) {
|
||||
if(modifiedTime != gpxFile.modifiedTime) {
|
||||
if (modifiedTime != gpxFile.modifiedTime) {
|
||||
update();
|
||||
}
|
||||
this.displayGroups = displayGroups;
|
||||
|
@ -502,17 +517,17 @@ public class GpxSelectionHelper {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public enum GpxDisplayItemType {
|
||||
TRACK_SEGMENT,
|
||||
TRACK_POINTS,
|
||||
TRACK_ROUTE_POINTS
|
||||
}
|
||||
|
||||
|
||||
public static class GpxDisplayGroup {
|
||||
|
||||
|
||||
private GpxDisplayItemType type = GpxDisplayItemType.TRACK_SEGMENT;
|
||||
private List<GpxDisplayItem> list = new ArrayList<GpxDisplayItem>();
|
||||
private List<GpxDisplayItem> list = new ArrayList<>();
|
||||
private GPXFile gpx;
|
||||
private String gpxName;
|
||||
private String name;
|
||||
|
@ -521,7 +536,7 @@ public class GpxSelectionHelper {
|
|||
private double splitDistance = -1;
|
||||
private int splitTime = -1;
|
||||
private int color;
|
||||
|
||||
|
||||
public GpxDisplayGroup(GPXFile gpx) {
|
||||
this.gpx = gpx;
|
||||
}
|
||||
|
@ -529,11 +544,11 @@ public class GpxSelectionHelper {
|
|||
public void setTrack(Track track) {
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
|
||||
public GPXFile getGpx() {
|
||||
return gpx;
|
||||
}
|
||||
|
||||
|
||||
public Track getTrack() {
|
||||
return track;
|
||||
}
|
||||
|
@ -544,18 +559,18 @@ public class GpxSelectionHelper {
|
|||
group.name = name;
|
||||
group.description = description;
|
||||
group.track = track;
|
||||
group.list = new ArrayList<GpxSelectionHelper.GpxDisplayItem>(list);
|
||||
group.list = new ArrayList<>(list);
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -567,15 +582,15 @@ public class GpxSelectionHelper {
|
|||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public List<GpxDisplayItem> getModifiableList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public GpxDisplayItemType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public void setType(GpxDisplayItemType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -583,15 +598,15 @@ public class GpxSelectionHelper {
|
|||
public boolean isSplitDistance() {
|
||||
return splitDistance > 0;
|
||||
}
|
||||
|
||||
|
||||
public double getSplitDistance() {
|
||||
return splitDistance;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSplitTime() {
|
||||
return splitTime > 0;
|
||||
}
|
||||
|
||||
|
||||
public int getSplitTime() {
|
||||
return splitTime;
|
||||
}
|
||||
|
@ -604,30 +619,30 @@ public class GpxSelectionHelper {
|
|||
list.clear();
|
||||
splitDistance = -1;
|
||||
splitTime = -1;
|
||||
processGroupTrack(app, this );
|
||||
processGroupTrack(app, this);
|
||||
}
|
||||
|
||||
public void splitByDistance(OsmandApplication app, double meters) {
|
||||
list.clear();
|
||||
splitDistance = meters;
|
||||
splitTime = -1;
|
||||
processGroupTrack(app, this );
|
||||
processGroupTrack(app, this);
|
||||
}
|
||||
|
||||
public void splitByTime(OsmandApplication app, int seconds) {
|
||||
list.clear();
|
||||
splitDistance = -1;
|
||||
splitTime = seconds;
|
||||
processGroupTrack(app, this );
|
||||
processGroupTrack(app, this);
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class GpxDisplayItem {
|
||||
|
||||
|
||||
public GPXTrackAnalysis analysis;
|
||||
public GpxDisplayGroup group;
|
||||
public WptPt locationStart;
|
||||
|
@ -640,9 +655,5 @@ public class GpxSelectionHelper {
|
|||
public String url;
|
||||
public Bitmap image;
|
||||
public boolean expanded;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -142,8 +142,10 @@ public class ConfigureMapMenu {
|
|||
} else if (itemId == R.string.shared_string_favorites) {
|
||||
settings.SHOW_FAVORITES.set(isChecked);
|
||||
} else if (itemId == R.string.layer_gpx_layer) {
|
||||
if (ma.getMyApplication().getSelectedGpxHelper().isShowingAnyGpxFiles()) {
|
||||
ma.getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
final GpxSelectionHelper selectedGpxHelper = ma.getMyApplication().getSelectedGpxHelper();
|
||||
if (selectedGpxHelper.isShowingAnyGpxFiles()) {
|
||||
selectedGpxHelper.clearAllGpxFileToShow();
|
||||
adapter.getItem(pos).setDescription(selectedGpxHelper.getGpxDescription());
|
||||
} else {
|
||||
AlertDialog dialog = ma.getMapLayers()
|
||||
.showGPXFileLayer(getAlreadySelectedGpx(), ma.getMapView());
|
||||
|
@ -151,7 +153,7 @@ public class ConfigureMapMenu {
|
|||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
boolean areAnyGpxTracksVisible =
|
||||
ma.getMyApplication().getSelectedGpxHelper().isShowingAnyGpxFiles();
|
||||
selectedGpxHelper.isShowingAnyGpxFiles();
|
||||
item.setSelected(areAnyGpxTracksVisible);
|
||||
item.setColorRes(areAnyGpxTracksVisible ? R.color.osmand_orange : defaultColor);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
@ -222,6 +224,7 @@ public class ConfigureMapMenu {
|
|||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.layer_gpx_layer, activity)
|
||||
.setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles())
|
||||
.setDescription(app.getSelectedGpxHelper().getGpxDescription())
|
||||
.setColor(selected ? R.color.osmand_orange : defaultColor)
|
||||
.setIcon(R.drawable.ic_action_polygom_dark)
|
||||
.setSecondaryIcon(R.drawable.ic_action_additional_option)
|
||||
|
|
Loading…
Reference in a new issue