Add trackDrawInfo for drawing unsaved gpx parameters
This commit is contained in:
parent
6773ef5031
commit
fce394f3f7
8 changed files with 233 additions and 101 deletions
|
@ -6,23 +6,19 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
|
||||
import java.io.File;
|
||||
import net.osmand.plus.track.TrackDrawInfo;
|
||||
|
||||
public class DirectionArrowsCard extends BaseCard {
|
||||
|
||||
private SelectedGpxFile selectedGpxFile;
|
||||
private TrackDrawInfo trackDrawInfo;
|
||||
|
||||
public DirectionArrowsCard(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile) {
|
||||
public DirectionArrowsCard(@NonNull MapActivity mapActivity, @NonNull TrackDrawInfo trackDrawInfo) {
|
||||
super(mapActivity);
|
||||
this.selectedGpxFile = selectedGpxFile;
|
||||
this.trackDrawInfo = trackDrawInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,27 +34,16 @@ public class DirectionArrowsCard extends BaseCard {
|
|||
titleView.setText(R.string.gpx_direction_arrows);
|
||||
|
||||
final CompoundButton compoundButton = view.findViewById(R.id.compound_button);
|
||||
compoundButton.setChecked(selectedGpxFile.getGpxFile().isShowStartFinish());
|
||||
compoundButton.setChecked(trackDrawInfo.isShowStartFinish());
|
||||
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean checked = !compoundButton.isChecked();
|
||||
compoundButton.setChecked(checked);
|
||||
setShowArrows(checked);
|
||||
trackDrawInfo.setShowArrows(checked);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setShowArrows(boolean showArrows) {
|
||||
if (selectedGpxFile.getGpxFile() != null) {
|
||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
gpxFile.setShowArrows(showArrows);
|
||||
GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path));
|
||||
if (gpxDataItem != null) {
|
||||
app.getGpxDbHelper().updateShowArrows(gpxDataItem, showArrows);
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -346,11 +346,11 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
return groups;
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile) {
|
||||
public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo) {
|
||||
try {
|
||||
if (fragmentManager.findFragmentByTag(SplitIntervalBottomSheet.TAG) == null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(SELECTED_TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path);
|
||||
args.putString(SELECTED_TRACK_FILE_PATH, trackDrawInfo.getFilePath());
|
||||
|
||||
SplitIntervalBottomSheet splitIntervalBottomSheet = new SplitIntervalBottomSheet();
|
||||
splitIntervalBottomSheet.setArguments(args);
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
@ -13,11 +12,11 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
|||
|
||||
public class SplitIntervalCard extends BaseCard {
|
||||
|
||||
private SelectedGpxFile selectedGpxFile;
|
||||
private TrackDrawInfo trackDrawInfo;
|
||||
|
||||
public SplitIntervalCard(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile) {
|
||||
public SplitIntervalCard(@NonNull MapActivity mapActivity, TrackDrawInfo trackDrawInfo) {
|
||||
super(mapActivity);
|
||||
this.selectedGpxFile = selectedGpxFile;
|
||||
this.trackDrawInfo = trackDrawInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +36,7 @@ public class SplitIntervalCard extends BaseCard {
|
|||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), selectedGpxFile);
|
||||
SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -80,6 +80,24 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMapLayers().getGpxLayer().setTrackDrawInfo(trackDrawInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMapLayers().getGpxLayer().setTrackDrawInfo(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putString(SELECTED_TRACK_FILE_PATH, selectedGpxFile.getGpxFile().path);
|
||||
|
@ -167,16 +185,16 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
|||
ViewGroup cardsContainer = getCardsContainer();
|
||||
cardsContainer.removeAllViews();
|
||||
|
||||
BaseCard splitIntervalCard = new SplitIntervalCard(mapActivity, selectedGpxFile);
|
||||
BaseCard splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo);
|
||||
cardsContainer.addView(splitIntervalCard.build(mapActivity));
|
||||
|
||||
BaseCard arrowsCard = new DirectionArrowsCard(mapActivity, selectedGpxFile);
|
||||
BaseCard arrowsCard = new DirectionArrowsCard(mapActivity, trackDrawInfo);
|
||||
cardsContainer.addView(arrowsCard.build(mapActivity));
|
||||
|
||||
TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile);
|
||||
TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile, trackDrawInfo);
|
||||
cardsContainer.addView(trackColoringCard.build(mapActivity));
|
||||
|
||||
BaseCard width = new TrackWidthCard(mapActivity, selectedGpxFile);
|
||||
BaseCard width = new TrackWidthCard(mapActivity, trackDrawInfo);
|
||||
cardsContainer.addView(width.build(mapActivity));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
@ -30,7 +27,6 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
import net.osmand.plus.widgets.FlowLayout;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -39,6 +35,7 @@ import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems;
|
|||
|
||||
public class TrackColoringCard extends BaseCard {
|
||||
|
||||
private TrackDrawInfo trackDrawInfo;
|
||||
private SelectedGpxFile selectedGpxFile;
|
||||
|
||||
private GradientScaleType selectedScaleType;
|
||||
|
@ -46,8 +43,9 @@ public class TrackColoringCard extends BaseCard {
|
|||
@ColorInt
|
||||
private int selectedColor;
|
||||
|
||||
public TrackColoringCard(MapActivity mapActivity, GpxSelectionHelper.SelectedGpxFile selectedGpxFile) {
|
||||
public TrackColoringCard(MapActivity mapActivity, SelectedGpxFile selectedGpxFile, TrackDrawInfo trackDrawInfo) {
|
||||
super(mapActivity);
|
||||
this.trackDrawInfo = trackDrawInfo;
|
||||
this.selectedGpxFile = selectedGpxFile;
|
||||
}
|
||||
|
||||
|
@ -120,35 +118,13 @@ public class TrackColoringCard extends BaseCard {
|
|||
newColor.findViewById(R.id.outline).setVisibility(View.VISIBLE);
|
||||
}
|
||||
selectedColor = color;
|
||||
setGpxColor(color);
|
||||
}
|
||||
|
||||
private void setGpxColor(int color) {
|
||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
if (gpxFile != null) {
|
||||
if (color != 0) {
|
||||
selectedGpxFile.getGpxFile().setColor(color);
|
||||
GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path));
|
||||
if (gpxDataItem != null) {
|
||||
app.getGpxDbHelper().updateColor(gpxDataItem, color);
|
||||
}
|
||||
}
|
||||
if (gpxFile.showCurrentTrack) {
|
||||
app.getSettings().CURRENT_TRACK_COLOR.set(color);
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
trackDrawInfo.setColor(color);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
||||
private GradientScaleType getSelectedScaleType() {
|
||||
if (selectedScaleType == null) {
|
||||
String gradientScaleType = selectedGpxFile.getGpxFile().getGradientScaleType();
|
||||
for (GradientScaleType item : GradientScaleType.values()) {
|
||||
if (item.name().equalsIgnoreCase(gradientScaleType)) {
|
||||
selectedScaleType = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
selectedScaleType = trackDrawInfo.getGradientScaleType();
|
||||
if (selectedScaleType == null) {
|
||||
selectedScaleType = GradientScaleType.SOLID;
|
||||
}
|
||||
|
@ -171,18 +147,6 @@ public class TrackColoringCard extends BaseCard {
|
|||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.select_color), visible);
|
||||
}
|
||||
|
||||
private void setGradientScaleType(GradientScaleType gradientScaleType) {
|
||||
if (selectedGpxFile.getGpxFile() != null) {
|
||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
gpxFile.setGradientScaleType(gradientScaleType.getTypeName());
|
||||
GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path));
|
||||
if (gpxDataItem != null) {
|
||||
app.getGpxDbHelper().updateGradientScaleType(gpxDataItem, gradientScaleType);
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
private class GpxWidthAdapter extends RecyclerView.Adapter<GpxWidthViewHolder> {
|
||||
|
||||
private List<GradientScaleType> items;
|
||||
|
@ -237,7 +201,8 @@ public class TrackColoringCard extends BaseCard {
|
|||
notifyItemChanged(holder.getAdapterPosition());
|
||||
notifyItemChanged(prevSelectedPosition);
|
||||
|
||||
setGradientScaleType(selectedScaleType);
|
||||
trackDrawInfo.setGradientScaleType(selectedScaleType);
|
||||
mapActivity.refreshMap();
|
||||
|
||||
updateHeader();
|
||||
updateCustomWidthSlider();
|
||||
|
|
160
OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java
Normal file
160
OsmAnd/src/net/osmand/plus/track/TrackDrawInfo.java
Normal file
|
@ -0,0 +1,160 @@
|
|||
package net.osmand.plus.track;
|
||||
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
|
||||
public class TrackDrawInfo {
|
||||
|
||||
private String filePath;
|
||||
private String width;
|
||||
private GradientScaleType gradientScaleType;
|
||||
private int color;
|
||||
private int gradientSpeedColor;
|
||||
private int gradientAltitudeColor;
|
||||
private int gradientSlopeColor;
|
||||
private int splitType;
|
||||
private double splitInterval;
|
||||
private long fileLastModifiedTime;
|
||||
private boolean apiImported;
|
||||
private boolean showAsMarkers;
|
||||
private boolean joinSegments;
|
||||
private boolean showArrows;
|
||||
private boolean showStartFinish;
|
||||
|
||||
public TrackDrawInfo(GpxDataItem gpxDataItem) {
|
||||
filePath = gpxDataItem.getFile().getPath();
|
||||
width = gpxDataItem.getWidth();
|
||||
gradientScaleType = gpxDataItem.getGradientScaleType();
|
||||
color = gpxDataItem.getColor();
|
||||
gradientSpeedColor = gpxDataItem.getGradientSpeedColor();
|
||||
gradientAltitudeColor = gpxDataItem.getGradientAltitudeColor();
|
||||
gradientSlopeColor = gpxDataItem.getGradientSlopeColor();
|
||||
splitType = gpxDataItem.getSplitType();
|
||||
splitInterval = gpxDataItem.getSplitInterval();
|
||||
fileLastModifiedTime = gpxDataItem.getFileLastModifiedTime();
|
||||
apiImported = gpxDataItem.isApiImported();
|
||||
showAsMarkers = gpxDataItem.isShowAsMarkers();
|
||||
joinSegments = gpxDataItem.isJoinSegments();
|
||||
showArrows = gpxDataItem.isShowArrows();
|
||||
showStartFinish = gpxDataItem.isShowStartFinish();
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public String getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(String width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public GradientScaleType getGradientScaleType() {
|
||||
return gradientScaleType;
|
||||
}
|
||||
|
||||
public void setGradientScaleType(GradientScaleType gradientScaleType) {
|
||||
this.gradientScaleType = gradientScaleType;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getGradientSpeedColor() {
|
||||
return gradientSpeedColor;
|
||||
}
|
||||
|
||||
public void setGradientSpeedColor(int gradientSpeedColor) {
|
||||
this.gradientSpeedColor = gradientSpeedColor;
|
||||
}
|
||||
|
||||
public int getGradientAltitudeColor() {
|
||||
return gradientAltitudeColor;
|
||||
}
|
||||
|
||||
public void setGradientAltitudeColor(int gradientAltitudeColor) {
|
||||
this.gradientAltitudeColor = gradientAltitudeColor;
|
||||
}
|
||||
|
||||
public int getGradientSlopeColor() {
|
||||
return gradientSlopeColor;
|
||||
}
|
||||
|
||||
public void setGradientSlopeColor(int gradientSlopeColor) {
|
||||
this.gradientSlopeColor = gradientSlopeColor;
|
||||
}
|
||||
|
||||
public int getSplitType() {
|
||||
return splitType;
|
||||
}
|
||||
|
||||
public void setSplitType(int splitType) {
|
||||
this.splitType = splitType;
|
||||
}
|
||||
|
||||
public double getSplitInterval() {
|
||||
return splitInterval;
|
||||
}
|
||||
|
||||
public void setSplitInterval(double splitInterval) {
|
||||
this.splitInterval = splitInterval;
|
||||
}
|
||||
|
||||
public long getFileLastModifiedTime() {
|
||||
return fileLastModifiedTime;
|
||||
}
|
||||
|
||||
public void setFileLastModifiedTime(long fileLastModifiedTime) {
|
||||
this.fileLastModifiedTime = fileLastModifiedTime;
|
||||
}
|
||||
|
||||
public boolean isApiImported() {
|
||||
return apiImported;
|
||||
}
|
||||
|
||||
public void setApiImported(boolean apiImported) {
|
||||
this.apiImported = apiImported;
|
||||
}
|
||||
|
||||
public boolean isShowAsMarkers() {
|
||||
return showAsMarkers;
|
||||
}
|
||||
|
||||
public void setShowAsMarkers(boolean showAsMarkers) {
|
||||
this.showAsMarkers = showAsMarkers;
|
||||
}
|
||||
|
||||
public boolean isJoinSegments() {
|
||||
return joinSegments;
|
||||
}
|
||||
|
||||
public void setJoinSegments(boolean joinSegments) {
|
||||
this.joinSegments = joinSegments;
|
||||
}
|
||||
|
||||
public boolean isShowArrows() {
|
||||
return showArrows;
|
||||
}
|
||||
|
||||
public void setShowArrows(boolean showArrows) {
|
||||
this.showArrows = showArrows;
|
||||
}
|
||||
|
||||
public boolean isShowStartFinish() {
|
||||
return showStartFinish;
|
||||
}
|
||||
|
||||
public void setShowStartFinish(boolean showStartFinish) {
|
||||
this.showStartFinish = showStartFinish;
|
||||
}
|
||||
}
|
|
@ -17,9 +17,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -30,7 +27,6 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class TrackWidthCard extends BaseCard {
|
||||
|
@ -39,14 +35,14 @@ public class TrackWidthCard extends BaseCard {
|
|||
private final static int CUSTOM_WIDTH_MIN = 1;
|
||||
private final static int CUSTOM_WIDTH_MAX = 24;
|
||||
|
||||
private SelectedGpxFile selectedGpxFile;
|
||||
private TrackDrawInfo trackDrawInfo;
|
||||
|
||||
private AppearanceListItem selectedItem;
|
||||
private List<AppearanceListItem> appearanceItems;
|
||||
|
||||
public TrackWidthCard(MapActivity mapActivity, SelectedGpxFile selectedGpxFile) {
|
||||
public TrackWidthCard(MapActivity mapActivity, TrackDrawInfo trackDrawInfo) {
|
||||
super(mapActivity);
|
||||
this.selectedGpxFile = selectedGpxFile;
|
||||
this.trackDrawInfo = trackDrawInfo;
|
||||
appearanceItems = getWidthAppearanceItems();
|
||||
}
|
||||
|
||||
|
@ -67,7 +63,7 @@ public class TrackWidthCard extends BaseCard {
|
|||
|
||||
private AppearanceListItem getSelectedItem() {
|
||||
if (selectedItem == null) {
|
||||
String selectedWidth = selectedGpxFile.getGpxFile().getWidth(null);
|
||||
String selectedWidth = trackDrawInfo.getWidth();
|
||||
for (AppearanceListItem item : appearanceItems) {
|
||||
if (Algorithms.objectEquals(item.getValue(), selectedWidth)
|
||||
|| ((Algorithms.isEmpty(selectedWidth) || Algorithms.isInt(selectedWidth))
|
||||
|
@ -83,7 +79,7 @@ public class TrackWidthCard extends BaseCard {
|
|||
private List<AppearanceListItem> getWidthAppearanceItems() {
|
||||
List<AppearanceListItem> items = GpxAppearanceAdapter.getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_WIDTH);
|
||||
|
||||
String selectedWidth = selectedGpxFile.getGpxFile().getWidth(null);
|
||||
String selectedWidth = trackDrawInfo.getWidth();
|
||||
String customWidth = !Algorithms.isEmpty(selectedWidth) && Algorithms.isInt(selectedWidth) ? selectedWidth : String.valueOf(CUSTOM_WIDTH_MIN);
|
||||
|
||||
items.add(new AppearanceListItem(CUSTOM_WIDTH, customWidth, app.getString(R.string.shared_string_custom)));
|
||||
|
@ -141,15 +137,8 @@ public class TrackWidthCard extends BaseCard {
|
|||
}
|
||||
|
||||
private void setGpxWidth(String width) {
|
||||
if (selectedGpxFile.getGpxFile() != null) {
|
||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
gpxFile.setWidth(width);
|
||||
GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFile.path));
|
||||
if (gpxDataItem != null) {
|
||||
app.getGpxDbHelper().updateWidth(gpxDataItem, width);
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
trackDrawInfo.setWidth(width);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
||||
private class GpxWidthAdapter extends RecyclerView.Adapter<GpxWidthViewHolder> {
|
||||
|
@ -201,12 +190,7 @@ public class TrackWidthCard extends BaseCard {
|
|||
}
|
||||
|
||||
private void updateWidthIcon(GpxWidthViewHolder holder, AppearanceListItem item) {
|
||||
int color;
|
||||
if (selectedGpxFile.isShowCurrentTrack()) {
|
||||
color = app.getSettings().CURRENT_TRACK_COLOR.get();
|
||||
} else {
|
||||
color = selectedGpxFile.getGpxFile().getColor(0);
|
||||
}
|
||||
int color = trackDrawInfo.getColor();
|
||||
|
||||
int iconId;
|
||||
if (CUSTOM_WIDTH.equals(item.getAttrName())) {
|
||||
|
|
|
@ -49,6 +49,7 @@ import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
|||
import net.osmand.plus.render.OsmandRenderer;
|
||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.track.TrackDrawInfo;
|
||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||
import net.osmand.plus.views.ContextMenuLayer.IMoveObjectProvider;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
|
@ -92,6 +93,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
private Drawable startPointIcon;
|
||||
private Drawable finishPointIcon;
|
||||
private LayerDrawable selectedPoint;
|
||||
private TrackDrawInfo trackDrawInfo;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
|
||||
private GpxSelectionHelper selectedGpxHelper;
|
||||
|
@ -136,6 +138,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
this.trackChartPoints = trackChartPoints;
|
||||
}
|
||||
|
||||
public void setTrackDrawInfo(TrackDrawInfo trackDrawInfo) {
|
||||
this.trackDrawInfo = trackDrawInfo;
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
paint = new Paint();
|
||||
paint.setStyle(Style.STROKE);
|
||||
|
@ -396,7 +402,11 @@ 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()) {
|
||||
boolean showStartFinish = selectedGpxFile.getGpxFile().isShowStartFinish();
|
||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
||||
showStartFinish = trackDrawInfo.isShowStartFinish();
|
||||
}
|
||||
if (showStartFinish) {
|
||||
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||
TrkSegment endSegment = segments.get(segments.size() - 1);
|
||||
|
||||
|
@ -410,6 +420,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
}
|
||||
}
|
||||
|
||||
private boolean hasTrackDrawInfoForSelectedGpx(SelectedGpxFile selectedGpxFile) {
|
||||
return trackDrawInfo != null && trackDrawInfo.getFilePath().equals(selectedGpxFile.getGpxFile().path);
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -573,6 +587,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
||||
width = trackDrawInfo.getWidth();
|
||||
}
|
||||
if (!cachedTrackWidth.containsKey(width)) {
|
||||
cachedTrackWidth.put(width, null);
|
||||
}
|
||||
|
@ -602,6 +619,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
if (color == 0) {
|
||||
color = ts.getColor(cachedColor);
|
||||
}
|
||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
||||
color = trackDrawInfo.getColor();
|
||||
width = trackDrawInfo.getWidth();
|
||||
}
|
||||
if (ts.renderer == null && !ts.points.isEmpty()) {
|
||||
if (currentTrack) {
|
||||
ts.renderer = new Renderable.CurrentTrack(ts.points);
|
||||
|
|
Loading…
Reference in a new issue