Merge branch 'r3.8'
This commit is contained in:
commit
87609c43c1
10 changed files with 86 additions and 42 deletions
|
@ -124,9 +124,11 @@ public class Algorithms {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFileNameWithoutExtension(String name) {
|
public static String getFileNameWithoutExtension(String name) {
|
||||||
int i = name.lastIndexOf('.');
|
if (name != null) {
|
||||||
if (i >= 0) {
|
int index = name.lastIndexOf('.');
|
||||||
name = name.substring(0, i);
|
if (index != -1) {
|
||||||
|
return name.substring(0, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,10 +216,12 @@
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/add_point_button"
|
android:id="@+id/add_point_button"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="@dimen/measurement_tool_button_width"
|
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
layout="@layout/bottom_sheet_dialog_button" />
|
android:minWidth="@dimen/measurement_tool_button_width" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -153,16 +153,6 @@ public class AndroidUtils {
|
||||||
R.color.icon_color_default_light, R.color.wikivoyage_active_dark);
|
R.color.icon_color_default_light, R.color.wikivoyage_active_dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String trimExtension(String src) {
|
|
||||||
if (src != null) {
|
|
||||||
int index = src.lastIndexOf('.');
|
|
||||||
if (index != -1) {
|
|
||||||
return src.substring(0, index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return src;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String addColon(OsmandApplication app, @StringRes int stringRes) {
|
public static String addColon(OsmandApplication app, @StringRes int stringRes) {
|
||||||
return app.getString(R.string.ltr_or_rtl_combine_via_colon, app.getString(stringRes), "").trim();
|
return app.getString(R.string.ltr_or_rtl_combine_via_colon, app.getString(stringRes), "").trim();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.FileUtils;
|
import net.osmand.FileUtils;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
@ -526,7 +525,7 @@ public class MapMarkersHelper {
|
||||||
|
|
||||||
private MapMarkersGroup createGPXMarkerGroup(File fl) {
|
private MapMarkersGroup createGPXMarkerGroup(File fl) {
|
||||||
return new MapMarkersGroup(getMarkerGroupId(fl),
|
return new MapMarkersGroup(getMarkerGroupId(fl),
|
||||||
AndroidUtils.trimExtension(fl.getName()),
|
Algorithms.getFileNameWithoutExtension(fl.getName()),
|
||||||
MapMarkersGroup.GPX_TYPE);
|
MapMarkersGroup.GPX_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,13 +298,15 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
|
||||||
return (menuState & (MenuState.HEADER_ONLY | MenuState.HALF_SCREEN)) != 0;
|
return (menuState & (MenuState.HEADER_ONLY | MenuState.HALF_SCREEN)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment, @NonNull LocationsHolder locationsHolder) {
|
public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment,
|
||||||
|
@NonNull LocationsHolder locationsHolder, @Nullable ApplicationMode appMode) {
|
||||||
try {
|
try {
|
||||||
if (!fm.isStateSaved()) {
|
if (!fm.isStateSaved()) {
|
||||||
GpxApproximationFragment fragment = new GpxApproximationFragment();
|
GpxApproximationFragment fragment = new GpxApproximationFragment();
|
||||||
fragment.setRetainInstance(true);
|
fragment.setRetainInstance(true);
|
||||||
fragment.setTargetFragment(targetFragment, REQUEST_CODE);
|
fragment.setTargetFragment(targetFragment, REQUEST_CODE);
|
||||||
fragment.setLocationsHolder(locationsHolder);
|
fragment.setLocationsHolder(locationsHolder);
|
||||||
|
fragment.setSnapToRoadAppMode(appMode);
|
||||||
fm.beginTransaction()
|
fm.beginTransaction()
|
||||||
.replace(R.id.fragmentContainer, fragment, TAG)
|
.replace(R.id.fragmentContainer, fragment, TAG)
|
||||||
.addToBackStack(TAG)
|
.addToBackStack(TAG)
|
||||||
|
@ -348,12 +350,19 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProfileSelect(ApplicationMode applicationMode) {
|
public void onProfileSelect(ApplicationMode applicationMode) {
|
||||||
if (snapToRoadAppMode != applicationMode) {
|
if (setSnapToRoadAppMode(applicationMode)) {
|
||||||
snapToRoadAppMode = applicationMode;
|
|
||||||
calculateGpxApproximation();
|
calculateGpxApproximation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean setSnapToRoadAppMode(ApplicationMode appMode) {
|
||||||
|
if (appMode != null && snapToRoadAppMode != appMode) {
|
||||||
|
snapToRoadAppMode = appMode;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public LocationsHolder getLocationsHolder() {
|
public LocationsHolder getLocationsHolder() {
|
||||||
return locationsHolder;
|
return locationsHolder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -706,8 +706,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
case SnapTrackWarningFragment.CONTINUE_RESULT_CODE:
|
case SnapTrackWarningFragment.CONTINUE_RESULT_CODE:
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
ApplicationMode mode = editingCtx.getAppMode();
|
||||||
|
if (mode == ApplicationMode.DEFAULT || "public_transport".equals(mode.getRoutingProfile())) {
|
||||||
|
mode = null;
|
||||||
|
}
|
||||||
GpxApproximationFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
GpxApproximationFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
this, new LocationsHolder(editingCtx.getPoints()));
|
this, new LocationsHolder(editingCtx.getPoints()), mode);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1517,12 +1521,20 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
private String getSuggestedFileName() {
|
private String getSuggestedFileName() {
|
||||||
GpxData gpxData = editingCtx.getGpxData();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
String displayedName;
|
String displayedName = null;
|
||||||
if (gpxData == null) {
|
if (gpxData != null) {
|
||||||
|
GPXFile gpxFile = gpxData.getGpxFile();
|
||||||
|
if (!Algorithms.isEmpty(gpxFile.path)) {
|
||||||
|
displayedName = Algorithms.getFileNameWithoutExtension(new File(gpxFile.path).getName());
|
||||||
|
} else if (!Algorithms.isEmpty(gpxFile.tracks)) {
|
||||||
|
displayedName = gpxFile.tracks.get(0).name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gpxData == null || displayedName == null) {
|
||||||
String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
|
String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
|
||||||
displayedName = FileUtils.createUniqueFileName(requireMyApplication(), suggestedName, GPX_INDEX_DIR, GPX_FILE_EXT);
|
displayedName = FileUtils.createUniqueFileName(requireMyApplication(), suggestedName, GPX_INDEX_DIR, GPX_FILE_EXT);
|
||||||
} else {
|
} else {
|
||||||
displayedName = AndroidUtils.trimExtension(new File(gpxData.getGpxFile().path).getName());
|
displayedName = Algorithms.getFileNameWithoutExtension(new File(gpxData.getGpxFile().path).getName());
|
||||||
}
|
}
|
||||||
return displayedName;
|
return displayedName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import androidx.viewpager.widget.ViewPager;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.FileUtils;
|
import net.osmand.FileUtils;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
@ -482,12 +483,18 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
|
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
|
||||||
|
|
||||||
String fileName;
|
String fileName = null;
|
||||||
if (paramsBuilder == null || paramsBuilder.getFile() == null || paramsBuilder.getFile().path == null) {
|
if (paramsBuilder != null && paramsBuilder.getFile() != null) {
|
||||||
|
GPXFile gpxFile = paramsBuilder.getFile();
|
||||||
|
if (!Algorithms.isEmpty(gpxFile.path)) {
|
||||||
|
fileName = Algorithms.getFileNameWithoutExtension(new File(gpxFile.path).getName());
|
||||||
|
} else if (!Algorithms.isEmpty(gpxFile.tracks)) {
|
||||||
|
fileName = gpxFile.tracks.get(0).name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Algorithms.isEmpty(fileName)) {
|
||||||
String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
|
String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
|
||||||
fileName = FileUtils.createUniqueFileName(app, suggestedName, IndexConstants.GPX_INDEX_DIR, GPX_FILE_EXT);
|
fileName = FileUtils.createUniqueFileName(app, suggestedName, IndexConstants.GPX_INDEX_DIR, GPX_FILE_EXT);
|
||||||
} else {
|
|
||||||
fileName = AndroidUtils.trimExtension(new File(paramsBuilder.getFile().path).getName());
|
|
||||||
}
|
}
|
||||||
SaveAsNewTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
SaveAsNewTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
ChooseRouteFragment.this, null, fileName,
|
ChooseRouteFragment.this, null, fileName,
|
||||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.ValueHolder;
|
import net.osmand.ValueHolder;
|
||||||
|
@ -205,7 +206,6 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
SelectTrackCard selectTrackCard = new SelectTrackCard(mapActivity);
|
SelectTrackCard selectTrackCard = new SelectTrackCard(mapActivity);
|
||||||
selectTrackCard.setListener(this);
|
selectTrackCard.setListener(this);
|
||||||
cardsContainer.addView(selectTrackCard.build(mapActivity));
|
cardsContainer.addView(selectTrackCard.build(mapActivity));
|
||||||
cardsContainer.addView(buildDividerView(cardsContainer, false));
|
|
||||||
|
|
||||||
ApplicationMode mode = app.getRoutingHelper().getAppMode();
|
ApplicationMode mode = app.getRoutingHelper().getAppMode();
|
||||||
|
|
||||||
|
@ -213,13 +213,16 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
GPXRouteParamsBuilder rparams = routingHelper.getCurrentGPXRoute();
|
GPXRouteParamsBuilder rparams = routingHelper.getCurrentGPXRoute();
|
||||||
boolean osmandRouter = mode.getRouteService() == RouteProvider.RouteService.OSMAND;
|
boolean osmandRouter = mode.getRouteService() == RouteProvider.RouteService.OSMAND;
|
||||||
if (rparams != null && osmandRouter) {
|
if (rparams != null && osmandRouter) {
|
||||||
if (!gpxFile.hasRoute() || gpxFile.hasRtePt()) {
|
boolean showReverseCard = !routingHelper.isCurrentGPXRouteV2();
|
||||||
|
if (showReverseCard) {
|
||||||
|
cardsContainer.addView(buildDividerView(cardsContainer, false));
|
||||||
|
|
||||||
ReverseTrackCard reverseTrackCard = new ReverseTrackCard(mapActivity, rparams.isReverse());
|
ReverseTrackCard reverseTrackCard = new ReverseTrackCard(mapActivity, rparams.isReverse());
|
||||||
reverseTrackCard.setListener(this);
|
reverseTrackCard.setListener(this);
|
||||||
cardsContainer.addView(reverseTrackCard.build(mapActivity));
|
cardsContainer.addView(reverseTrackCard.build(mapActivity));
|
||||||
}
|
}
|
||||||
if (!gpxFile.hasRtePt() && !gpxFile.hasRoute()) {
|
if (!gpxFile.hasRtePt() && !gpxFile.hasRoute()) {
|
||||||
cardsContainer.addView(buildDividerView(cardsContainer, true));
|
cardsContainer.addView(buildDividerView(cardsContainer, showReverseCard));
|
||||||
|
|
||||||
AttachTrackToRoadsCard attachTrackCard = new AttachTrackToRoadsCard(mapActivity);
|
AttachTrackToRoadsCard attachTrackCard = new AttachTrackToRoadsCard(mapActivity);
|
||||||
attachTrackCard.setListener(this);
|
attachTrackCard.setListener(this);
|
||||||
|
@ -431,14 +434,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
if (card instanceof ImportTrackCard) {
|
if (card instanceof ImportTrackCard) {
|
||||||
importTrack();
|
importTrack();
|
||||||
} else if (card instanceof TrackEditCard) {
|
} else if (card instanceof TrackEditCard || card instanceof AttachTrackToRoadsCard) {
|
||||||
openPlanRoute(true);
|
openPlanRoute();
|
||||||
close();
|
close();
|
||||||
} else if (card instanceof SelectTrackCard) {
|
} else if (card instanceof SelectTrackCard) {
|
||||||
updateSelectionMode(true);
|
updateSelectionMode(true);
|
||||||
} else if (card instanceof AttachTrackToRoadsCard) {
|
|
||||||
openPlanRoute(false);
|
|
||||||
close();
|
|
||||||
} else if (card instanceof ReverseTrackCard
|
} else if (card instanceof ReverseTrackCard
|
||||||
|| card instanceof NavigateTrackOptionsCard) {
|
|| card instanceof NavigateTrackOptionsCard) {
|
||||||
updateMenu();
|
updateMenu();
|
||||||
|
@ -486,6 +486,14 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
this.gpxFile = gpxFile;
|
this.gpxFile = gpxFile;
|
||||||
|
List<WptPt> points = gpxFile.getRoutePoints();
|
||||||
|
if (!points.isEmpty()) {
|
||||||
|
ApplicationMode mode = ApplicationMode.valueOfStringKey(points.get(0).getProfileType(), null);
|
||||||
|
if (mode != null) {
|
||||||
|
app.getRoutingHelper().setAppMode(mode);
|
||||||
|
app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
mapActivity.getMapActions().setGPXRouteParams(gpxFile);
|
mapActivity.getMapActions().setGPXRouteParams(gpxFile);
|
||||||
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
||||||
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||||
|
@ -542,7 +550,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openPlanRoute(boolean useAppMode) {
|
public void openPlanRoute() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null && gpxFile != null) {
|
if (mapActivity != null && gpxFile != null) {
|
||||||
editingTrack = true;
|
editingTrack = true;
|
||||||
|
@ -552,9 +560,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
GpxData gpxData = new GpxData(gpxFile, rect, actionType, segment);
|
GpxData gpxData = new GpxData(gpxFile, rect, actionType, segment);
|
||||||
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
||||||
editingContext.setGpxData(gpxData);
|
editingContext.setGpxData(gpxData);
|
||||||
if (useAppMode) {
|
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
|
||||||
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
|
|
||||||
}
|
|
||||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true);
|
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
import net.osmand.plus.OsmAndLocationSimulation;
|
import net.osmand.plus.OsmAndLocationSimulation;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -47,6 +48,7 @@ import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
||||||
import net.osmand.router.GeneralRouter;
|
import net.osmand.router.GeneralRouter;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -342,14 +344,19 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
private BaseBottomSheetItem createGpxRoutingItem(final LocalRoutingParameter optionsItem) {
|
private BaseBottomSheetItem createGpxRoutingItem(final LocalRoutingParameter optionsItem) {
|
||||||
RouteProvider.GPXRouteParamsBuilder routeParamsBuilder = mapActivity.getRoutingHelper().getCurrentGPXRoute();
|
RouteProvider.GPXRouteParamsBuilder routeParamsBuilder = mapActivity.getRoutingHelper().getCurrentGPXRoute();
|
||||||
String description;
|
String description = null;
|
||||||
int descriptionColorId;
|
int descriptionColorId;
|
||||||
if (routeParamsBuilder == null) {
|
if (routeParamsBuilder == null) {
|
||||||
descriptionColorId = nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light;
|
descriptionColorId = nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light;
|
||||||
description = mapActivity.getString(R.string.follow_track_descr);
|
description = mapActivity.getString(R.string.follow_track_descr);
|
||||||
} else {
|
} else {
|
||||||
descriptionColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
descriptionColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||||
description = new File(routeParamsBuilder.getFile().path).getName();
|
GPXFile gpxFile = routeParamsBuilder.getFile();
|
||||||
|
if (!Algorithms.isEmpty(gpxFile.path)) {
|
||||||
|
description = new File(gpxFile.path).getName();
|
||||||
|
} else if (!Algorithms.isEmpty(gpxFile.tracks)) {
|
||||||
|
description = gpxFile.tracks.get(0).name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BottomSheetItemWithDescription.Builder()
|
return new BottomSheetItemWithDescription.Builder()
|
||||||
|
|
|
@ -12,6 +12,7 @@ import androidx.appcompat.view.ContextThemeWrapper;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
|
@ -19,6 +20,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -115,6 +117,14 @@ public class TracksCard extends BaseCard {
|
||||||
v.setOnClickListener(new View.OnClickListener() {
|
v.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
List<GPXUtilities.WptPt> points = item.file.getRoutePoints();
|
||||||
|
if (!points.isEmpty()) {
|
||||||
|
ApplicationMode mode = ApplicationMode.valueOfStringKey(points.get(0).getProfileType(), null);
|
||||||
|
if (mode != null) {
|
||||||
|
app.getRoutingHelper().setAppMode(mode);
|
||||||
|
app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
mapActivity.getMapActions().setGPXRouteParams(item.file);
|
mapActivity.getMapActions().setGPXRouteParams(item.file);
|
||||||
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue