Add new track appearance prefs for current recording track
This commit is contained in:
parent
7567a1b3ae
commit
dd40c4dce6
5 changed files with 143 additions and 94 deletions
|
@ -50,7 +50,7 @@
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/appearance_icon"
|
android:id="@+id/track_icon"
|
||||||
android:layout_width="@dimen/standard_icon_size"
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
android:layout_height="@dimen/standard_icon_size"
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
@ -94,7 +94,8 @@
|
||||||
android:id="@+id/map_controls_container"
|
android:id="@+id/map_controls_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom">
|
android:layout_gravity="bottom"
|
||||||
|
tools:visibility="invisible">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/map_ruler"
|
layout="@layout/map_ruler"
|
||||||
|
@ -104,8 +105,7 @@
|
||||||
android:layout_marginStart="@dimen/fab_margin_right"
|
android:layout_marginStart="@dimen/fab_margin_right"
|
||||||
android:layout_marginLeft="@dimen/fab_margin_right"
|
android:layout_marginLeft="@dimen/fab_margin_right"
|
||||||
android:layout_marginEnd="@dimen/fab_margin_right"
|
android:layout_marginEnd="@dimen/fab_margin_right"
|
||||||
android:layout_marginRight="@dimen/fab_margin_right"
|
android:layout_marginRight="@dimen/fab_margin_right" />
|
||||||
tools:visibility="invisible" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/map_hud_controls"
|
layout="@layout/map_hud_controls"
|
||||||
|
@ -115,8 +115,7 @@
|
||||||
android:layout_marginStart="@dimen/fab_margin_right"
|
android:layout_marginStart="@dimen/fab_margin_right"
|
||||||
android:layout_marginLeft="@dimen/fab_margin_right"
|
android:layout_marginLeft="@dimen/fab_margin_right"
|
||||||
android:layout_marginEnd="@dimen/fab_margin_right"
|
android:layout_marginEnd="@dimen/fab_margin_right"
|
||||||
android:layout_marginRight="@dimen/fab_margin_right"
|
android:layout_marginRight="@dimen/fab_margin_right" />
|
||||||
tools:visibility="invisible" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -2194,6 +2194,9 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Long> LAST_UPDATES_CARD_REFRESH = new LongPreference("last_updates_card_refresh", 0).makeGlobal();
|
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();
|
public final CommonPreference<Integer> CURRENT_TRACK_COLOR = new IntPreference("current_track_color", 0).makeGlobal().cache();
|
||||||
|
public final CommonPreference<String> CURRENT_TRACK_WIDTH = new StringPreference("current_track_width", "").makeGlobal().cache();
|
||||||
|
public final CommonPreference<Boolean> CURRENT_TRACK_SHOW_ARROWS = new BooleanPreference("current_track_show_arrows", false).makeGlobal().cache();
|
||||||
|
public final CommonPreference<Boolean> CURRENT_TRACK_SHOW_START_FINISH = new BooleanPreference("current_track_show_start_finish", true).makeGlobal().cache();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// 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();
|
public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5000).makeProfile();
|
||||||
|
|
|
@ -9,9 +9,11 @@ import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -74,7 +76,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
private TrackWidthCard trackWidthCard;
|
private TrackWidthCard trackWidthCard;
|
||||||
private SplitIntervalCard splitIntervalCard;
|
private SplitIntervalCard splitIntervalCard;
|
||||||
|
|
||||||
private ImageView appearanceIcon;
|
private ImageView trackIcon;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMainLayoutId() {
|
public int getMainLayoutId() {
|
||||||
|
@ -131,6 +133,10 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
}
|
}
|
||||||
if (currentRecording) {
|
if (currentRecording) {
|
||||||
trackDrawInfo = new TrackDrawInfo(true);
|
trackDrawInfo = new TrackDrawInfo(true);
|
||||||
|
trackDrawInfo.setColor(app.getSettings().CURRENT_TRACK_COLOR.get());
|
||||||
|
trackDrawInfo.setWidth(app.getSettings().CURRENT_TRACK_WIDTH.get());
|
||||||
|
trackDrawInfo.setShowArrows(app.getSettings().CURRENT_TRACK_SHOW_ARROWS.get());
|
||||||
|
trackDrawInfo.setShowStartFinish(app.getSettings().CURRENT_TRACK_SHOW_START_FINISH.get());
|
||||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||||
} else {
|
} else {
|
||||||
gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFilePath));
|
gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFilePath));
|
||||||
|
@ -163,13 +169,14 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
appearanceIcon = view.findViewById(R.id.appearance_icon);
|
trackIcon = view.findViewById(R.id.track_icon);
|
||||||
|
|
||||||
if (isPortrait()) {
|
if (isPortrait()) {
|
||||||
updateCardsLayout();
|
updateCardsLayout();
|
||||||
}
|
}
|
||||||
updateCards();
|
setupCards();
|
||||||
updateButtons(view);
|
setupButtons(view);
|
||||||
|
setupScrollShadow();
|
||||||
updateAppearanceIcon();
|
updateAppearanceIcon();
|
||||||
if (!isPortrait()) {
|
if (!isPortrait()) {
|
||||||
int widthNoShadow = getLandscapeNoShadowWidth();
|
int widthNoShadow = getLandscapeNoShadowWidth();
|
||||||
|
@ -327,7 +334,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
|
|
||||||
private void updateAppearanceIcon() {
|
private void updateAppearanceIcon() {
|
||||||
Drawable icon = getTrackIcon(app, trackDrawInfo.getWidth(), trackDrawInfo.isShowArrows(), trackDrawInfo.getColor());
|
Drawable icon = getTrackIcon(app, trackDrawInfo.getWidth(), trackDrawInfo.isShowArrows(), trackDrawInfo.getColor());
|
||||||
appearanceIcon.setImageDrawable(icon);
|
trackIcon.setImageDrawable(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adjustMapPosition(int y) {
|
private void adjustMapPosition(int y) {
|
||||||
|
@ -387,7 +394,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtons(View view) {
|
private void setupButtons(View view) {
|
||||||
View buttonsContainer = view.findViewById(R.id.buttons_container);
|
View buttonsContainer = view.findViewById(R.id.buttons_container);
|
||||||
buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.route_info_bg));
|
buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.route_info_bg));
|
||||||
View saveButton = view.findViewById(R.id.right_bottom_button);
|
View saveButton = view.findViewById(R.id.right_bottom_button);
|
||||||
|
@ -418,6 +425,26 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
|
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupScrollShadow() {
|
||||||
|
int shadowIconId = isNightMode() ? R.drawable.bg_contextmenu_shadow : R.drawable.bg_contextmenu_shadow;
|
||||||
|
final Drawable shadowIcon = app.getUIUtilities().getIcon(shadowIconId);
|
||||||
|
|
||||||
|
final ScrollView scrollView = getBottomScrollView();
|
||||||
|
final FrameLayout bottomContainer = getBottomContainer();
|
||||||
|
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScrollChanged() {
|
||||||
|
int scrollY = scrollView.getScrollY();
|
||||||
|
if (scrollY <= 0 && bottomContainer.getForeground() != null) {
|
||||||
|
bottomContainer.setForeground(null);
|
||||||
|
} else if (scrollY > 0 && bottomContainer.getForeground() == null) {
|
||||||
|
bottomContainer.setForeground(shadowIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void saveTrackInfo() {
|
private void saveTrackInfo() {
|
||||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
|
|
||||||
|
@ -440,6 +467,9 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
|
|
||||||
if (gpxFile.showCurrentTrack) {
|
if (gpxFile.showCurrentTrack) {
|
||||||
app.getSettings().CURRENT_TRACK_COLOR.set(trackDrawInfo.getColor());
|
app.getSettings().CURRENT_TRACK_COLOR.set(trackDrawInfo.getColor());
|
||||||
|
app.getSettings().CURRENT_TRACK_WIDTH.set(trackDrawInfo.getWidth());
|
||||||
|
app.getSettings().CURRENT_TRACK_SHOW_ARROWS.set(trackDrawInfo.isShowArrows());
|
||||||
|
app.getSettings().CURRENT_TRACK_SHOW_START_FINISH.set(trackDrawInfo.isShowStartFinish());
|
||||||
} else {
|
} else {
|
||||||
if (gpxDataItem != null) {
|
if (gpxDataItem != null) {
|
||||||
gpxDataItem = new GpxDataItem(new File(gpxFile.path), gpxFile);
|
gpxDataItem = new GpxDataItem(new File(gpxFile.path), gpxFile);
|
||||||
|
@ -508,7 +538,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCards() {
|
private void setupCards() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
ViewGroup cardsContainer = getCardsContainer();
|
ViewGroup cardsContainer = getCardsContainer();
|
||||||
|
|
|
@ -109,6 +109,10 @@ public class TrackDrawInfo {
|
||||||
this.showArrows = showArrows;
|
this.showArrows = showArrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowStartFinish(boolean showStartFinish) {
|
||||||
|
this.showStartFinish = showStartFinish;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isShowStartFinish() {
|
public boolean isShowStartFinish() {
|
||||||
return showStartFinish;
|
return showStartFinish;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,9 +89,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
private Paint shadowPaint;
|
private Paint shadowPaint;
|
||||||
private Paint paintIcon;
|
private Paint paintIcon;
|
||||||
|
|
||||||
private int cachedHash;
|
private int cachedHash;
|
||||||
|
@ColorInt
|
||||||
private int cachedColor;
|
private int cachedColor;
|
||||||
private int currentTrackColor;
|
|
||||||
private float defaultTrackWidth;
|
private float defaultTrackWidth;
|
||||||
private Map<String, Float> cachedTrackWidth = new HashMap<>();
|
private Map<String, Float> cachedTrackWidth = new HashMap<>();
|
||||||
|
|
||||||
|
@ -129,8 +130,13 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
@ColorInt
|
@ColorInt
|
||||||
private int grayColor;
|
private int grayColor;
|
||||||
|
|
||||||
private CommonPreference<String> currentTrackColorPref;
|
private CommonPreference<String> defaultTrackColorPref;
|
||||||
|
private CommonPreference<String> defaultTrackWidthPref;
|
||||||
|
|
||||||
|
private CommonPreference<Integer> currentTrackColorPref;
|
||||||
private CommonPreference<String> currentTrackWidthPref;
|
private CommonPreference<String> currentTrackWidthPref;
|
||||||
|
private CommonPreference<Boolean> currentTrackShowArrowsPref;
|
||||||
|
private CommonPreference<Boolean> currentTrackShowStartFinishPref;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initLayer(OsmandMapTileView view) {
|
public void initLayer(OsmandMapTileView view) {
|
||||||
|
@ -138,8 +144,14 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
selectedGpxHelper = view.getApplication().getSelectedGpxHelper();
|
selectedGpxHelper = view.getApplication().getSelectedGpxHelper();
|
||||||
mapMarkersHelper = view.getApplication().getMapMarkersHelper();
|
mapMarkersHelper = view.getApplication().getMapMarkersHelper();
|
||||||
osmandRenderer = view.getApplication().getResourceManager().getRenderer().getRenderer();
|
osmandRenderer = view.getApplication().getResourceManager().getRenderer().getRenderer();
|
||||||
currentTrackColorPref = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
|
|
||||||
currentTrackWidthPref = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR);
|
currentTrackColorPref = view.getSettings().CURRENT_TRACK_COLOR;
|
||||||
|
currentTrackWidthPref = view.getSettings().CURRENT_TRACK_WIDTH;
|
||||||
|
currentTrackShowArrowsPref = view.getSettings().CURRENT_TRACK_SHOW_ARROWS;
|
||||||
|
currentTrackShowStartFinishPref = view.getSettings().CURRENT_TRACK_SHOW_START_FINISH;
|
||||||
|
defaultTrackColorPref = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR).cache();
|
||||||
|
defaultTrackWidthPref = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR).cache();
|
||||||
|
|
||||||
initUI();
|
initUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +240,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
|
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
|
||||||
cache.clear();
|
cache.clear();
|
||||||
currentTrackColor = view.getSettings().CURRENT_TRACK_COLOR.get();
|
|
||||||
if (!selectedGPXFiles.isEmpty()) {
|
if (!selectedGPXFiles.isEmpty()) {
|
||||||
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
|
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
|
||||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||||
|
@ -249,7 +260,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
||||||
int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(),
|
int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(),
|
||||||
currentTrackColorPref.get(), currentTrackWidthPref.get());
|
defaultTrackColorPref.get(), defaultTrackWidthPref.get());
|
||||||
if (hash != cachedHash) {
|
if (hash != cachedHash) {
|
||||||
cachedHash = hash;
|
cachedHash = hash;
|
||||||
cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track);
|
cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track);
|
||||||
|
@ -257,16 +268,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (rrs != null) {
|
if (rrs != null) {
|
||||||
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
|
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
|
||||||
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
|
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
|
||||||
if (currentTrackColorPref != null && currentTrackColorPref.isSet()) {
|
if (defaultTrackColorPref != null && defaultTrackColorPref.isSet()) {
|
||||||
RenderingRuleProperty ctColor = rrs.PROPS.get(CURRENT_TRACK_COLOR_ATTR);
|
RenderingRuleProperty ctColor = rrs.PROPS.get(CURRENT_TRACK_COLOR_ATTR);
|
||||||
if (ctColor != null) {
|
if (ctColor != null) {
|
||||||
req.setStringFilter(ctColor, currentTrackColorPref.get());
|
req.setStringFilter(ctColor, defaultTrackColorPref.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentTrackWidthPref != null && currentTrackWidthPref.isSet()) {
|
if (defaultTrackWidthPref != null && defaultTrackWidthPref.isSet()) {
|
||||||
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
|
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
|
||||||
if (ctWidth != null) {
|
if (ctWidth != null) {
|
||||||
req.setStringFilter(ctWidth, currentTrackWidthPref.get());
|
req.setStringFilter(ctWidth, defaultTrackWidthPref.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String additional = "";
|
String additional = "";
|
||||||
|
@ -305,10 +316,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paint.setColor(color == 0 ? cachedColor : color);
|
paint.setColor(color == 0 ? cachedColor : color);
|
||||||
Float strikeWidth = cachedTrackWidth.get(width);
|
paint.setStrokeWidth(getTrackWidth(width, defaultTrackWidth));
|
||||||
if (strikeWidth != null) {
|
|
||||||
paint.setStrokeWidth(strikeWidth);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
||||||
|
@ -342,17 +350,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (tileBox.getZoom() >= START_ZOOM) {
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
// request to load
|
// request to load
|
||||||
OsmandApplication app = view.getApplication();
|
OsmandApplication app = view.getApplication();
|
||||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
List<GpxDisplayGroup> groups = g.getDisplayGroups(app);
|
List<GpxDisplayGroup> groups = selectedGpxFile.getDisplayGroups(app);
|
||||||
if (groups != null && !groups.isEmpty()) {
|
if (!Algorithms.isEmpty(groups)) {
|
||||||
int color = g.getGpxFile().getColor(0);
|
int color = getTrackColor(selectedGpxFile.getGpxFile(), cachedColor);
|
||||||
if (color == 0) {
|
|
||||||
color = g.getModifiableGpxFile().getColor(0);
|
|
||||||
}
|
|
||||||
if (color == 0) {
|
|
||||||
color = cachedColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
paintInnerRect.setColor(color);
|
paintInnerRect.setColor(color);
|
||||||
paintInnerRect.setAlpha(179);
|
paintInnerRect.setAlpha(179);
|
||||||
|
|
||||||
|
@ -416,25 +417,12 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private void drawDirectionArrows(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
private void drawDirectionArrows(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
if (!tileBox.isZoomAnimated()) {
|
if (!tileBox.isZoomAnimated()) {
|
||||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
boolean showArrows = selectedGpxFile.getGpxFile().isShowArrows();
|
boolean showArrows = isShowArrowsForTrack(selectedGpxFile.getGpxFile());
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
showArrows = trackDrawInfo.isShowArrows();
|
|
||||||
}
|
|
||||||
if (showArrows) {
|
if (showArrows) {
|
||||||
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
|
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
|
||||||
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
String width = getTrackWidthName(selectedGpxFile.getGpxFile(), defaultTrackWidthPref.get());
|
||||||
int color = selectedGpxFile.getGpxFile().getColor(cachedColor);
|
float trackWidth = getTrackWidth(width, defaultTrackWidth);
|
||||||
if (selectedGpxFile.isShowCurrentTrack()) {
|
int color = getTrackColor(selectedGpxFile.getGpxFile(), cachedColor);
|
||||||
color = currentTrackColor;
|
|
||||||
}
|
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
color = trackDrawInfo.getColor();
|
|
||||||
width = trackDrawInfo.getWidth();
|
|
||||||
}
|
|
||||||
Float trackWidth = cachedTrackWidth.get(width);
|
|
||||||
if (trackWidth == null) {
|
|
||||||
trackWidth = defaultTrackWidth;
|
|
||||||
}
|
|
||||||
int contrastColor = UiUtilities.getContrastColor(view.getApplication(), color, false);
|
int contrastColor = UiUtilities.getContrastColor(view.getApplication(), color, false);
|
||||||
GeometryWayStyle arrowsWayStyle = new GeometryArrowsWayStyle(wayContext, arrowBitmap, contrastColor, color, trackWidth);
|
GeometryWayStyle arrowsWayStyle = new GeometryArrowsWayStyle(wayContext, arrowBitmap, contrastColor, color, trackWidth);
|
||||||
for (TrkSegment segment : selectedGpxFile.getPointsToDisplay()) {
|
for (TrkSegment segment : selectedGpxFile.getPointsToDisplay()) {
|
||||||
|
@ -587,10 +575,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
if (tileBox.getZoom() >= START_ZOOM) {
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
boolean showStartFinish = selectedGpxFile.getGpxFile().isShowStartFinish();
|
boolean showStartFinish = isShowStartFinishForTrack(selectedGpxFile.getGpxFile());
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
showStartFinish = trackDrawInfo.isShowStartFinish();
|
|
||||||
}
|
|
||||||
if (showStartFinish) {
|
if (showStartFinish) {
|
||||||
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
for (TrkSegment segment : segments) {
|
for (TrkSegment segment : segments) {
|
||||||
|
@ -605,11 +590,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasTrackDrawInfoForSelectedGpx(SelectedGpxFile selectedGpxFile) {
|
|
||||||
return trackDrawInfo != null && (trackDrawInfo.isCurrentRecording() && selectedGpxFile.isShowCurrentTrack()
|
|
||||||
|| selectedGpxFile.getGpxFile().path.equals(trackDrawInfo.getFilePath()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawStartEndPoints(Canvas canvas, RotatedTileBox tileBox, WptPt start, WptPt end) {
|
private void drawStartEndPoints(Canvas canvas, RotatedTileBox tileBox, WptPt start, WptPt end) {
|
||||||
int startX = (int) tileBox.getPixXFromLatLon(start.lat, start.lon);
|
int startX = (int) tileBox.getPixXFromLatLon(start.lat, start.lon);
|
||||||
int startY = (int) tileBox.getPixYFromLatLon(start.lat, start.lon);
|
int startY = (int) tileBox.getPixYFromLatLon(start.lat, start.lon);
|
||||||
|
@ -717,13 +697,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
|
private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
|
||||||
int color = trackChartPoints.getSegmentColor();
|
int color = trackChartPoints.getSegmentColor();
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
color = trackChartPoints.getGpx().getColor(0);
|
color = getTrackColor(trackChartPoints.getGpx(), cachedColor);
|
||||||
if (trackChartPoints.getGpx().showCurrentTrack) {
|
|
||||||
color = currentTrackColor;
|
|
||||||
}
|
|
||||||
if (color == 0) {
|
|
||||||
color = cachedColor;
|
|
||||||
}
|
|
||||||
trackChartPoints.setSegmentColor(color);
|
trackChartPoints.setSegmentColor(color);
|
||||||
}
|
}
|
||||||
paintGridCircle.setColor(color);
|
paintGridCircle.setColor(color);
|
||||||
|
@ -782,21 +756,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
|
|
||||||
private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox,
|
private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox,
|
||||||
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
||||||
|
SelectedGpxFile currentTrack = null;
|
||||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
String width = getTrackWidthName(selectedGpxFile.getGpxFile(), defaultTrackWidthPref.get());
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
width = trackDrawInfo.getWidth();
|
|
||||||
}
|
|
||||||
if (!cachedTrackWidth.containsKey(width)) {
|
if (!cachedTrackWidth.containsKey(width)) {
|
||||||
cachedTrackWidth.put(width, null);
|
cachedTrackWidth.put(width, null);
|
||||||
}
|
}
|
||||||
}
|
if (selectedGpxFile.isShowCurrentTrack()) {
|
||||||
SelectedGpxFile currentTrack = null;
|
currentTrack = selectedGpxFile;
|
||||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
|
||||||
if (g.isShowCurrentTrack()) {
|
|
||||||
currentTrack = g;
|
|
||||||
} else {
|
} else {
|
||||||
drawSelectedFileSegments(g, false, canvas, tileBox, settings);
|
drawSelectedFileSegments(selectedGpxFile, false, canvas, tileBox, settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentTrack != null) {
|
if (currentTrack != null) {
|
||||||
|
@ -805,21 +774,11 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas,
|
private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas,
|
||||||
RotatedTileBox tileBox, DrawSettings settings) {
|
RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
for (TrkSegment ts : segments) {
|
for (TrkSegment ts : segments) {
|
||||||
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
String width = getTrackWidthName(selectedGpxFile.getGpxFile(), defaultTrackWidthPref.get());
|
||||||
int color = selectedGpxFile.getGpxFile().getColor(0);
|
int color = getTrackColor(selectedGpxFile.getGpxFile(), ts.getColor(cachedColor));
|
||||||
if (currentTrack) {
|
|
||||||
color = currentTrackColor;
|
|
||||||
}
|
|
||||||
if (color == 0) {
|
|
||||||
color = ts.getColor(cachedColor);
|
|
||||||
}
|
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
color = trackDrawInfo.getColor();
|
|
||||||
width = trackDrawInfo.getWidth();
|
|
||||||
}
|
|
||||||
if (ts.renderer == null && !ts.points.isEmpty()) {
|
if (ts.renderer == null && !ts.points.isEmpty()) {
|
||||||
if (currentTrack) {
|
if (currentTrack) {
|
||||||
ts.renderer = new Renderable.CurrentTrack(ts.points);
|
ts.renderer = new Renderable.CurrentTrack(ts.points);
|
||||||
|
@ -834,6 +793,60 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float getTrackWidth(String width, float defaultTrackWidth) {
|
||||||
|
Float trackWidth = cachedTrackWidth.get(width);
|
||||||
|
return trackWidth != null ? trackWidth : defaultTrackWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getTrackColor(GPXFile gpxFile, int defaultColor) {
|
||||||
|
int color;
|
||||||
|
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||||
|
color = trackDrawInfo.getColor();
|
||||||
|
} else if (gpxFile.showCurrentTrack) {
|
||||||
|
color = currentTrackColorPref.get();
|
||||||
|
} else {
|
||||||
|
color = gpxFile.getColor(defaultColor);
|
||||||
|
}
|
||||||
|
return color != 0 ? color : defaultColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTrackWidthName(GPXFile gpxFile, String defaultWidth) {
|
||||||
|
String width;
|
||||||
|
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||||
|
width = trackDrawInfo.getWidth();
|
||||||
|
} else if (gpxFile.showCurrentTrack) {
|
||||||
|
width = currentTrackWidthPref.get();
|
||||||
|
} else {
|
||||||
|
width = gpxFile.getWidth(defaultWidth);
|
||||||
|
}
|
||||||
|
return width != null ? width : defaultWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isShowArrowsForTrack(GPXFile gpxFile) {
|
||||||
|
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||||
|
return trackDrawInfo.isShowArrows();
|
||||||
|
} else if (gpxFile.showCurrentTrack) {
|
||||||
|
return currentTrackShowArrowsPref.get();
|
||||||
|
} else {
|
||||||
|
return gpxFile.isShowArrows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isShowStartFinishForTrack(GPXFile gpxFile) {
|
||||||
|
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||||
|
return trackDrawInfo.isShowStartFinish();
|
||||||
|
} else if (gpxFile.showCurrentTrack) {
|
||||||
|
return currentTrackShowStartFinishPref.get();
|
||||||
|
} else {
|
||||||
|
return gpxFile.isShowStartFinish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasTrackDrawInfoForTrack(GPXFile gpxFile) {
|
||||||
|
return trackDrawInfo != null && (trackDrawInfo.isCurrentRecording() && gpxFile.showCurrentTrack
|
||||||
|
|| gpxFile.path.equals(trackDrawInfo.getFilePath()));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isPointVisited(WptPt o) {
|
private boolean isPointVisited(WptPt o) {
|
||||||
boolean visit = false;
|
boolean visit = false;
|
||||||
String visited = o.getExtensionsToRead().get("VISITED_KEY");
|
String visited = o.getExtensionsToRead().get("VISITED_KEY");
|
||||||
|
|
Loading…
Reference in a new issue