Fix current track color
This commit is contained in:
parent
0e3eb1ce9c
commit
b891b1e133
3 changed files with 27 additions and 3 deletions
|
@ -1051,6 +1051,8 @@ public class OsmandSettings {
|
|||
|
||||
public final OsmandPreference<Long> LAST_UPDATES_CARD_REFRESH = new LongPreference("last_updates_card_refresh", 0).makeGlobal();
|
||||
|
||||
public final CommonPreference<Integer> CURRENT_TRACK_COLOR = new IntPreference("current_track_color", 0).makeGlobal().cache();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5000).makeProfile();
|
||||
|
||||
|
|
|
@ -125,6 +125,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
|||
private boolean updateEnable;
|
||||
private View headerView;
|
||||
private int trackColor;
|
||||
private int currentTrackColor;
|
||||
private Paint paint;
|
||||
private Bitmap selectedPoint;
|
||||
private LatLon selectedPointLatLon;
|
||||
|
@ -322,6 +323,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
|||
} else if (getGpxDataItem() != null) {
|
||||
app.getGpxDatabase().updateColor(getGpxDataItem(), clr);
|
||||
}
|
||||
if (getGpx().showCurrentTrack) {
|
||||
app.getSettings().CURRENT_TRACK_COLOR.set(clr);
|
||||
}
|
||||
refreshTrackBitmap();
|
||||
}
|
||||
}
|
||||
|
@ -435,8 +439,14 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
|||
}
|
||||
|
||||
private void refreshTrackBitmap() {
|
||||
SelectedGpxFile sf = new SelectedGpxFile();
|
||||
sf.setGpxFile(getGpx());
|
||||
currentTrackColor = app.getSettings().CURRENT_TRACK_COLOR.get();
|
||||
SelectedGpxFile sf;
|
||||
if (getGpx().showCurrentTrack) {
|
||||
sf = app.getSavingTrackHelper().getCurrentTrack();
|
||||
} else {
|
||||
sf = new SelectedGpxFile();
|
||||
sf.setGpxFile(getGpx());
|
||||
}
|
||||
Bitmap bmp = mapBitmap.copy(mapBitmap.getConfig(), true);
|
||||
Canvas canvas = new Canvas(bmp);
|
||||
drawTrack(canvas, rotatedTileBox, sf);
|
||||
|
@ -458,6 +468,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
|||
List<TrkSegment> segments = g.getPointsToDisplay();
|
||||
for (TrkSegment ts : segments) {
|
||||
int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
|
||||
if (g.isShowCurrentTrack()) {
|
||||
color = currentTrackColor;
|
||||
}
|
||||
if (color == 0) {
|
||||
color = ts.getColor(trackColor);
|
||||
}
|
||||
|
@ -580,7 +593,11 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
|||
final ImageView colorImageView = (ImageView) colorView.findViewById(R.id.colorImage);
|
||||
int color = getGpxDataItem() != null ? getGpxDataItem().getColor() : 0;
|
||||
if (color == 0 && getGpx() != null) {
|
||||
color = getGpx().getColor(0);
|
||||
if (getGpx().showCurrentTrack) {
|
||||
color = app.getSettings().CURRENT_TRACK_COLOR.get();
|
||||
} else {
|
||||
color = getGpx().getColor(0);
|
||||
}
|
||||
}
|
||||
if (color == 0) {
|
||||
final RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
|
|
|
@ -66,6 +66,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private int cachedColor;
|
||||
private Paint paintIcon;
|
||||
private Bitmap pointSmall;
|
||||
private int currentTrackColor;
|
||||
|
||||
private Bitmap selectedPoint;
|
||||
private LatLon selectedPointLatLon;
|
||||
|
@ -173,6 +174,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
} else {
|
||||
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
|
||||
cache.clear();
|
||||
currentTrackColor = view.getSettings().CURRENT_TRACK_COLOR.get();
|
||||
if (!selectedGPXFiles.isEmpty()) {
|
||||
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
|
||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||
|
@ -389,6 +391,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
List<TrkSegment> segments = g.getPointsToDisplay();
|
||||
for (TrkSegment ts : segments) {
|
||||
int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
|
||||
if (g.isShowCurrentTrack()) {
|
||||
color = currentTrackColor;
|
||||
}
|
||||
if (color == 0) {
|
||||
color = ts.getColor(cachedColor);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue