Fix track selection for appearance screen

This commit is contained in:
Vitaliy 2020-07-17 12:13:09 +03:00
parent 16e9c3f4af
commit e47d638027
2 changed files with 27 additions and 10 deletions

View file

@ -64,7 +64,6 @@ import net.osmand.plus.wikipedia.WikiArticleHelper;
import net.osmand.plus.wikivoyage.WikivoyageUtils;
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
import net.osmand.plus.wikivoyage.data.TravelArticle;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
import java.util.List;
@ -385,16 +384,34 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
@Override
public void onClick(View v) {
TrackActivity activity = getTrackActivity();
GpxDataItem gpxDataItem = getGpxDataItem();
GPXFile gpx = getGpx();
if (gpx != null && activity != null) {
WptPt point = gpx.tracks.get(0).segments.get(0).points.get(0);
LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null;
if (activity != null && pointToShow != null) {
boolean gpxFileSelected = isGpxFileSelected(gpx);
if (!gpxFileSelected) {
Intent intent = activity.getIntent();
if (intent != null) {
intent.putExtra(TrackActivity.SHOW_TEMPORARILY, true);
}
}
setTrackVisibilityOnMap(true);
OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(latLon.getLatitude(), latLon.getLongitude(),
final OsmandSettings settings = app.getSettings();
String trackName;
if (gpx.showCurrentTrack) {
trackName = app.getString(R.string.shared_string_currently_recording_track);
} else if (gpxDataItem != null) {
trackName = gpxDataItem.getFile().getName();
} else {
trackName = gpx.path;
}
settings.setMapLocationToShow(pointToShow.getLatitude(), pointToShow.getLongitude(),
settings.getLastKnownMapZoom(),
new PointDescription(PointDescription.POINT_TYPE_GPX, Algorithms.getFileWithoutDirs(gpx.path)),
false, gpx);
new PointDescription(PointDescription.POINT_TYPE_WPT, trackName),
false,
gpx
);
MapActivity.launchMapActivityMoveToTop(activity);
}

View file

@ -225,10 +225,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
if (trackChartPoints != null) {
drawXAxisPoints(canvas, tileBox);
}
drawDirectionArrows(canvas, tileBox, selectedGPXFiles);
drawSelectedFilesStartEndPoints(canvas, tileBox, selectedGPXFiles);
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
drawSelectedFilesStartEndPoints(canvas, tileBox, selectedGPXFiles);
drawDirectionArrows(canvas, tileBox, selectedGPXFiles);
}
if (textLayer != null && isTextVisible()) {
textLayer.putData(this, cache);