Fix #9902
This commit is contained in:
parent
735cfb3dce
commit
e1086074c5
9 changed files with 145 additions and 37 deletions
|
@ -11,6 +11,7 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="start_finish_icons">Start/finish icons</string>
|
||||
<string name="sort_name_ascending">Name: A – Z</string>
|
||||
<string name="sort_name_descending">Name: Z – A</string>
|
||||
<string name="sort_last_modified">Last modified</string>
|
||||
|
|
|
@ -25,10 +25,13 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
|
||||
public static final String TRACK_WIDTH_BOLD = "bold";
|
||||
public static final String TRACK_WIDTH_MEDIUM = "medium";
|
||||
public static final String SHOW_START_FINISH_ATTR = "show_start_finish_attr";
|
||||
|
||||
private OsmandApplication app;
|
||||
private GpxAppearanceAdapterType adapterType;
|
||||
private int currentColor;
|
||||
private boolean showStartFinishIcons;
|
||||
private boolean nightMode;
|
||||
|
||||
public enum GpxAppearanceAdapterType {
|
||||
TRACK_WIDTH,
|
||||
|
@ -36,20 +39,15 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
TRACK_WIDTH_COLOR
|
||||
}
|
||||
|
||||
public GpxAppearanceAdapter(Context context, String currentColorValue, GpxAppearanceAdapterType adapterType) {
|
||||
public GpxAppearanceAdapter(Context context, String currentColorValue, GpxAppearanceAdapterType adapterType,
|
||||
boolean showStartFinishIcons, boolean nightMode) {
|
||||
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;
|
||||
this.showStartFinishIcons = showStartFinishIcons;
|
||||
this.nightMode = nightMode;
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -58,8 +56,9 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
AppearanceListItem item = getItem(position);
|
||||
View v = convertView;
|
||||
Context context = getContext();
|
||||
if (v == null) {
|
||||
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
|
||||
v = LayoutInflater.from(context).inflate(R.layout.rendering_prop_menu_item, null);
|
||||
}
|
||||
if (item != null) {
|
||||
TextView textView = (TextView) v.findViewById(R.id.text1);
|
||||
|
@ -68,7 +67,7 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
int iconId = getWidthIconId(item.value);
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
app.getUIUtilities().getPaintedIcon(iconId, currentColor), null);
|
||||
} else {
|
||||
} else if (ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR.equals(item.attrName)) {
|
||||
if (item.color == -1) {
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
|
||||
|
@ -76,8 +75,12 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, item.color), null);
|
||||
}
|
||||
} else if (SHOW_START_FINISH_ATTR.equals(item.attrName)) {
|
||||
int iconId = showStartFinishIcons ? R.drawable.ic_check_box_dark : R.drawable.ic_check_box_outline_dark;
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, app.getUIUtilities().getIcon(iconId,
|
||||
nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light), null);
|
||||
}
|
||||
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));
|
||||
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(context, 10f));
|
||||
v.findViewById(R.id.divider).setVisibility(item.lastItem
|
||||
&& position < getCount() - 1 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
@ -95,10 +98,15 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
}
|
||||
|
||||
private void init() {
|
||||
addAll(getAppearanceItems(app, adapterType));
|
||||
addAll(getAppearanceItems(app, adapterType, showStartFinishIcons));
|
||||
}
|
||||
|
||||
public static List<AppearanceListItem> getAppearanceItems(OsmandApplication app, GpxAppearanceAdapterType adapterType) {
|
||||
return getAppearanceItems(app, adapterType, false);
|
||||
}
|
||||
|
||||
public static List<AppearanceListItem> getAppearanceItems(OsmandApplication app, GpxAppearanceAdapterType adapterType,
|
||||
boolean showStartFinishIcons) {
|
||||
List<AppearanceListItem> items = new ArrayList<>();
|
||||
RenderingRuleProperty trackWidthProp = null;
|
||||
RenderingRuleProperty trackColorProp = null;
|
||||
|
@ -118,11 +126,19 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
trackWidthProp.getPossibleValues()[j],
|
||||
SettingsActivity.getStringPropertyValue(app, trackWidthProp.getPossibleValues()[j]));
|
||||
items.add(item);
|
||||
if (j == trackWidthProp.getPossibleValues().length - 1) {
|
||||
item.setLastItem(true);
|
||||
if (adapterType != GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) {
|
||||
if (j == trackWidthProp.getPossibleValues().length - 1) {
|
||||
item.setLastItem(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adapterType == GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) {
|
||||
AppearanceListItem startFinishIconsitem = new AppearanceListItem(SHOW_START_FINISH_ATTR,
|
||||
showStartFinishIcons ? "false" : "true", app.getString(R.string.start_finish_icons));
|
||||
items.add(startFinishIconsitem);
|
||||
startFinishIconsitem.setLastItem(true);
|
||||
}
|
||||
if (trackColorProp != null) {
|
||||
for (int j = 0; j < trackColorProp.getPossibleValues().length; j++) {
|
||||
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR,
|
||||
|
|
|
@ -125,6 +125,7 @@ import static net.osmand.plus.OsmAndFormatter.YARDS_IN_ONE_METER;
|
|||
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
||||
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
|
||||
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR;
|
||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.SHOW_START_FINISH_ATTR;
|
||||
|
||||
public class GpxUiHelper {
|
||||
|
||||
|
@ -532,7 +533,8 @@ public class GpxUiHelper {
|
|||
popup.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
|
||||
final GpxAppearanceAdapter gpxApprAdapter = new GpxAppearanceAdapter(new ContextThemeWrapper(activity, themeRes),
|
||||
gpxAppearanceParams.containsKey(CURRENT_TRACK_COLOR_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_COLOR_ATTR) : prefColor.get(),
|
||||
GpxAppearanceAdapter.GpxAppearanceAdapterType.TRACK_WIDTH_COLOR);
|
||||
GpxAppearanceAdapter.GpxAppearanceAdapterType.TRACK_WIDTH_COLOR,
|
||||
gpxAppearanceParams.containsKey(SHOW_START_FINISH_ATTR) ? "true".equals(gpxAppearanceParams.get(SHOW_START_FINISH_ATTR)) : app.getSettings().SHOW_START_FINISH_ICONS.get(), nightMode);
|
||||
popup.setAdapter(gpxApprAdapter);
|
||||
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
|
@ -544,6 +546,8 @@ public class GpxUiHelper {
|
|||
gpxAppearanceParams.put(CURRENT_TRACK_WIDTH_ATTR, item.getValue());
|
||||
} else if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) {
|
||||
gpxAppearanceParams.put(CURRENT_TRACK_COLOR_ATTR, item.getValue());
|
||||
} else if (SHOW_START_FINISH_ATTR.equals(item.getAttrName())) {
|
||||
gpxAppearanceParams.put(SHOW_START_FINISH_ATTR, item.getValue());
|
||||
}
|
||||
}
|
||||
popup.dismiss();
|
||||
|
@ -567,9 +571,13 @@ public class GpxUiHelper {
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (gpxAppearanceParams.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : gpxAppearanceParams.entrySet()) {
|
||||
final OsmandSettings.CommonPreference<String> pref
|
||||
= app.getSettings().getCustomRenderProperty(entry.getKey());
|
||||
pref.set(entry.getValue());
|
||||
if (SHOW_START_FINISH_ATTR.equals(entry.getKey())) {
|
||||
app.getSettings().SHOW_START_FINISH_ICONS.set("true".equals(entry.getValue()));
|
||||
} else {
|
||||
final OsmandSettings.CommonPreference<String> pref
|
||||
= app.getSettings().getCustomRenderProperty(entry.getKey());
|
||||
pref.set(entry.getValue());
|
||||
}
|
||||
}
|
||||
if (activity instanceof MapActivity) {
|
||||
ConfigureMapMenu.refreshMapComplete((MapActivity) activity);
|
||||
|
|
|
@ -2214,6 +2214,8 @@ public class OsmandSettings {
|
|||
}
|
||||
}.makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> SHOW_START_FINISH_ICONS = new BooleanPreference("show_start_finish_icons", true).makeGlobal().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> GPX_ROUTE_CALC_OSMAND_PARTS = new BooleanPreference("gpx_routing_calculate_osmand_route", true).makeGlobal().cache();
|
||||
// public final OsmandPreference<Boolean> GPX_CALCULATE_RTEPT = new BooleanPreference("gpx_routing_calculate_rtept", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> GPX_ROUTE_CALC = new BooleanPreference("calc_gpx_route", false).makeGlobal().cache();
|
||||
|
|
59
OsmAnd/src/net/osmand/plus/track/ShowStartFinishCard.java
Normal file
59
OsmAnd/src/net/osmand/plus/track/ShowStartFinishCard.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package net.osmand.plus.track;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
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 net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
|
||||
|
||||
class ShowStartFinishCard extends BaseCard {
|
||||
|
||||
private TrackDrawInfo trackDrawInfo;
|
||||
private OsmandPreference<Boolean> showStartFinishPreference;
|
||||
|
||||
public ShowStartFinishCard(@NonNull MapActivity mapActivity, @NonNull TrackDrawInfo trackDrawInfo) {
|
||||
super(mapActivity);
|
||||
this.showStartFinishPreference = app.getSettings().SHOW_START_FINISH_ICONS;
|
||||
this.trackDrawInfo = trackDrawInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCardLayoutId() {
|
||||
return R.layout.bottom_sheet_item_with_switch;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateContent() {
|
||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.icon), false);
|
||||
|
||||
TextView titleView = view.findViewById(R.id.title);
|
||||
titleView.setText(R.string.track_show_start_finish_icons);
|
||||
|
||||
final CompoundButton compoundButton = view.findViewById(R.id.compound_button);
|
||||
//compoundButton.setChecked(trackDrawInfo.isShowStartFinish());
|
||||
compoundButton.setChecked(showStartFinishPreference.get());
|
||||
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean checked = !compoundButton.isChecked();
|
||||
compoundButton.setChecked(checked);
|
||||
//trackDrawInfo.setShowStartFinish(checked);
|
||||
showStartFinishPreference.set(checked);
|
||||
mapActivity.refreshMap();
|
||||
|
||||
CardListener listener = getListener();
|
||||
if (listener != null) {
|
||||
listener.onCardPressed(ShowStartFinishCard.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -62,9 +62,10 @@ import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM;
|
|||
public class TrackAppearanceFragment extends ContextMenuScrollFragment implements CardListener, ColorPickerListener {
|
||||
|
||||
public static final String TAG = TrackAppearanceFragment.class.getName();
|
||||
|
||||
private static final Log log = PlatformUtil.getLog(TrackAppearanceFragment.class);
|
||||
|
||||
private static final String SHOW_START_FINISH_ICONS_INITIAL_VALUE_KEY = "showStartFinishIconsInitialValueKey";
|
||||
|
||||
private OsmandApplication app;
|
||||
|
||||
@Nullable
|
||||
|
@ -79,6 +80,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
private TrackWidthCard trackWidthCard;
|
||||
private SplitIntervalCard splitIntervalCard;
|
||||
private TrackColoringCard trackColoringCard;
|
||||
private boolean showStartFinishIconsInitialValue;
|
||||
|
||||
private ImageView trackIcon;
|
||||
private View buttonsShadow;
|
||||
|
@ -134,9 +136,12 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
if (!selectedGpxFile.isShowCurrentTrack()) {
|
||||
gpxDataItem = app.getGpxDbHelper().getItem(new File(trackDrawInfo.getFilePath()));
|
||||
}
|
||||
showStartFinishIconsInitialValue = savedInstanceState.getBoolean(SHOW_START_FINISH_ICONS_INITIAL_VALUE_KEY,
|
||||
app.getSettings().SHOW_START_FINISH_ICONS.get());
|
||||
} else if (arguments != null) {
|
||||
String gpxFilePath = arguments.getString(TRACK_FILE_NAME);
|
||||
boolean currentRecording = arguments.getBoolean(CURRENT_RECORDING, false);
|
||||
showStartFinishIconsInitialValue = app.getSettings().SHOW_START_FINISH_ICONS.get();
|
||||
|
||||
if (gpxFilePath == null && !currentRecording) {
|
||||
log.error("Required extra '" + TRACK_FILE_NAME + "' is missing");
|
||||
|
@ -152,7 +157,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
} else {
|
||||
gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFilePath));
|
||||
trackDrawInfo = new TrackDrawInfo(gpxDataItem, false);
|
||||
trackDrawInfo = new TrackDrawInfo(app, gpxDataItem, false);
|
||||
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath);
|
||||
}
|
||||
updateTrackColor();
|
||||
|
@ -294,6 +299,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
trackDrawInfo.saveToBundle(outState);
|
||||
outState.putBoolean(SHOW_START_FINISH_ICONS_INITIAL_VALUE_KEY, showStartFinishIconsInitialValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -455,6 +461,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
discardSplitChanges();
|
||||
discardShowStartFinishChanges();
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
activity.onBackPressed();
|
||||
|
@ -520,7 +527,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
|
||||
gpxFile.setSplitInterval(trackDrawInfo.getSplitInterval());
|
||||
gpxFile.setShowArrows(trackDrawInfo.isShowArrows());
|
||||
gpxFile.setShowStartFinish(trackDrawInfo.isShowStartFinish());
|
||||
//gpxFile.setShowStartFinish(trackDrawInfo.isShowStartFinish());
|
||||
|
||||
if (gpxFile.showCurrentTrack) {
|
||||
app.getSettings().CURRENT_TRACK_COLOR.set(trackDrawInfo.getColor());
|
||||
|
@ -551,6 +558,10 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
}
|
||||
}
|
||||
|
||||
private void discardShowStartFinishChanges() {
|
||||
app.getSettings().SHOW_START_FINISH_ICONS.set(showStartFinishIconsInitialValue);
|
||||
}
|
||||
|
||||
void applySplit(GpxSplitType splitType, int timeSplit, double distanceSplit) {
|
||||
if (splitIntervalCard != null) {
|
||||
splitIntervalCard.updateContent();
|
||||
|
@ -599,6 +610,10 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
directionArrowsCard.setListener(this);
|
||||
cardsContainer.addView(directionArrowsCard.build(mapActivity));
|
||||
|
||||
ShowStartFinishCard showStartFinishCard = new ShowStartFinishCard(mapActivity, trackDrawInfo);
|
||||
showStartFinishCard.setListener(this);
|
||||
cardsContainer.addView(showStartFinishCard.build(mapActivity));
|
||||
|
||||
trackColoringCard = new TrackColoringCard(mapActivity, trackDrawInfo, this);
|
||||
trackColoringCard.setListener(this);
|
||||
cardsContainer.addView(trackColoringCard.build(mapActivity));
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
@ -41,8 +42,6 @@ import org.apache.commons.logging.Log;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems;
|
||||
|
||||
public class TrackColoringCard extends BaseCard implements ColorPickerListener {
|
||||
|
||||
private static final int MINIMUM_CONTRAST_RATIO = 3;
|
||||
|
@ -131,7 +130,7 @@ public class TrackColoringCard extends BaseCard implements ColorPickerListener {
|
|||
selectColor.addView(createDividerView(selectColor));
|
||||
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
for (AppearanceListItem appearanceListItem : getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_COLOR)) {
|
||||
for (AppearanceListItem appearanceListItem : GpxAppearanceAdapter.getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_COLOR)) {
|
||||
if (!colors.contains(appearanceListItem.getColor())) {
|
||||
colors.add(appearanceListItem.getColor());
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING;
|
||||
|
@ -40,7 +41,7 @@ public class TrackDrawInfo {
|
|||
readBundle(bundle);
|
||||
}
|
||||
|
||||
public TrackDrawInfo(GpxDataItem gpxDataItem, boolean currentRecording) {
|
||||
public TrackDrawInfo(@NonNull OsmandApplication app, @NonNull GpxDataItem gpxDataItem, boolean currentRecording) {
|
||||
filePath = gpxDataItem.getFile().getPath();
|
||||
width = gpxDataItem.getWidth();
|
||||
gradientScaleType = gpxDataItem.getGradientScaleType();
|
||||
|
|
|
@ -453,7 +453,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
if (segment.points.size() >= 2) {
|
||||
WptPt start = segment.points.get(0);
|
||||
WptPt end = segment.points.get(segment.points.size() - 1);
|
||||
drawStartEndPoints(canvas, tileBox, start, end);
|
||||
drawStartEndPoints(canvas, tileBox, start, selectedGpxFile.isShowCurrentTrack() ? null : end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -461,24 +461,28 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
}
|
||||
}
|
||||
|
||||
private void drawStartEndPoints(Canvas canvas, RotatedTileBox tileBox, WptPt start, WptPt end) {
|
||||
int startX = (int) tileBox.getPixXFromLatLon(start.lat, start.lon);
|
||||
int startY = (int) tileBox.getPixYFromLatLon(start.lat, start.lon);
|
||||
int endX = (int) tileBox.getPixXFromLatLon(end.lat, end.lon);
|
||||
int endY = (int) tileBox.getPixYFromLatLon(end.lat, end.lon);
|
||||
private void drawStartEndPoints(@NonNull Canvas canvas, @NonNull RotatedTileBox tileBox, @Nullable WptPt start, @Nullable WptPt end) {
|
||||
int startX = start != null ? (int) tileBox.getPixXFromLatLon(start.lat, start.lon) : 0;
|
||||
int startY = start != null ? (int) tileBox.getPixYFromLatLon(start.lat, start.lon) : 0;
|
||||
int endX = end != null ? (int) tileBox.getPixXFromLatLon(end.lat, end.lon) : 0;
|
||||
int endY = end != null ? (int) tileBox.getPixYFromLatLon(end.lat, end.lon) : 0;
|
||||
|
||||
int iconSize = AndroidUtils.dpToPx(view.getContext(), 14);
|
||||
QuadRect startRectWithoutShadow = calculateRect(startX, startY, iconSize, iconSize);
|
||||
QuadRect endRectWithoutShadow = calculateRect(endX, endY, iconSize, iconSize);
|
||||
|
||||
if (QuadRect.intersects(startRectWithoutShadow, endRectWithoutShadow)) {
|
||||
if (start != null && end != null && QuadRect.intersects(startRectWithoutShadow, endRectWithoutShadow)) {
|
||||
QuadRect startAndFinishRect = calculateRect(startX, startY, startAndFinishIcon.getIntrinsicWidth(), startAndFinishIcon.getIntrinsicHeight());
|
||||
drawPoint(canvas, startAndFinishRect, startAndFinishIcon);
|
||||
} else {
|
||||
QuadRect startRect = calculateRect(startX, startY, startPointIcon.getIntrinsicWidth(), startPointIcon.getIntrinsicHeight());
|
||||
QuadRect endRect = calculateRect(endX, endY, finishPointIcon.getIntrinsicWidth(), finishPointIcon.getIntrinsicHeight());
|
||||
drawPoint(canvas, startRect, startPointIcon);
|
||||
drawPoint(canvas, endRect, finishPointIcon);
|
||||
if (start != null) {
|
||||
QuadRect startRect = calculateRect(startX, startY, startPointIcon.getIntrinsicWidth(), startPointIcon.getIntrinsicHeight());
|
||||
drawPoint(canvas, startRect, startPointIcon);
|
||||
}
|
||||
if (end != null) {
|
||||
QuadRect endRect = calculateRect(endX, endY, finishPointIcon.getIntrinsicWidth(), finishPointIcon.getIntrinsicHeight());
|
||||
drawPoint(canvas, endRect, finishPointIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -711,6 +715,8 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
}
|
||||
|
||||
private boolean isShowStartFinishForTrack(GPXFile gpxFile) {
|
||||
return view.getApplication().getSettings().SHOW_START_FINISH_ICONS.get();
|
||||
/*
|
||||
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||
return trackDrawInfo.isShowStartFinish();
|
||||
} else if (gpxFile.showCurrentTrack) {
|
||||
|
@ -718,6 +724,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
} else {
|
||||
return gpxFile.isShowStartFinish();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private boolean hasTrackDrawInfoForTrack(GPXFile gpxFile) {
|
||||
|
|
Loading…
Reference in a new issue